diff --git a/AUTHORS b/AUTHORS
index e97f4e4aab91ff0223752e5db74a16c8704503ac..f12487efb9583473d7c5e99f93742dc94969e357 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3,7 +3,7 @@ Ernest Artiaga <ernest.artiaga(at)bsc.es>
 Danny Auble <auble1(at)llnl.gov>
 Susanne Balle <susanne.balle(at)hp.com>
 Anton Blanchard <anton(at)samba.org>
-Hongjia Cao <hgcao(at)nudt.edu.cn>
+Hongjia Cao <hjcao(at)nudt.edu.cn>
 Chuck Clouston <Chuck.Clouston(at)bull.com>
 Daniel Christians <Daniel.Christians(at)hp.com>
 Gilles Civario <gilles.civario(at)bull.net>
@@ -11,8 +11,9 @@ Chris Dunlap <cdunlap(at)llnl.gov>
 Joey Ekstrom <ekstrom1(at)llnl.gov>
 Jim Garlick <garlick(at)llnl.gov>
 Mark Grondona <mgrondona(at)llnl.gov>
-Christopher Holmes <cholmes(at)hp.com>
 Takao Hatazaki <takao.hatazaki(at)hp.com>
+Matthieu Hautreux <matthieu.hautreux(at)cea.fr>
+Christopher Holmes <cholmes(at)hp.com>
 Nathan Huff <nhuff(at)geekshanty.com>
 David Jackson <jacksond(at)clusterresources.com>
 Greg Johnson <gjohnson(at)lanl.gov>
diff --git a/BUILD.NOTES b/BUILD.NOTES
index 2d52a948d1eff86c2507101f290e4d113296f22a..b8eff4b6315fc011b79d908c897984aa1d9b5226 100644
--- a/BUILD.NOTES
+++ b/BUILD.NOTES
@@ -65,12 +65,15 @@ Linux cluster (See BlueGene and AIX specific notes below for some differences).
 BlueGene build notes:
 3. Use the rpm make target to create the new RPMs. This requires a .rpmmacros
    (.rpmrc for newer versions of rpmbuild) file containing:
+	%_prefix                /usr
 	%_slurm_sysconfdir      /etc/slurm
-	%_with_debug            1
 	%_with_bluegene         1
+	%_with_debug            1
 	%with_cflags		CFLAGS=-m64
    Build on Service Node with using the following syntax
    rpmbuild -ta slurm-...bz2
+   The RPM files get written to the directory
+   /usr/src/packages/RPMS/ppc64
 
 To build and run on AIX:
 0. svn co https://eris.llnl.gov/svn/slurm/trunk slurm
@@ -151,7 +154,7 @@ Some RPM commands:
   rpm -i --ignoresize slurm-1.1.9-1.rpm (install a new rpm)
 For main SLURM plugin installation on BGL service node:
   rpm -i --force --nodeps --ignoresize slurm-1.1.9-1.rpm
-
+  rpm -U --force --nodeps --ignoresize slurm-1.1.9-1.rpm  (upgrade option)
 
 To clear a wedged job:
   /bgl/startMMCSconsole
@@ -183,7 +186,7 @@ Before new major release:
  - Test on ia64, i386, x86_64, BGL, AIX, OSX, XCPU
  - Test on Elan and IB switches
  - Test fail-over of slurmctld
- - Test for memory leaks in slurmctld and slurmd
+ - Test for memory leaks in slurmctld, slurmd and slurmdbd with various plugins
  - Change API version number
  - Review and release web pages
  - Review and release code
diff --git a/COPYING b/COPYING
index 55269c8e3ac4b51299dfaa0e4a1f4d7af084f177..afd7942bac3f40c9e6b4474682314e021c84b99e 100644
--- a/COPYING
+++ b/COPYING
@@ -17,27 +17,27 @@ also delete it here.
 
 OUR NOTICE AND TERMS OF AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE
 
-Our Preamble Notice
+Auspices
 
-A. This notice is required to be provided under our contract with the U.S.
-Department of Energy (DOE). This work was produced at the University
-of California, Lawrence Livermore National Laboratory under Contract
-No. W-7405-ENG-48 with the DOE.
+This work performed under the auspices of the U.S. Department of Energy by 
+Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
 
-B. Neither the United States Government nor the University of California
-nor any of their employees, makes any warranty, express or implied, or
-assumes any liability or responsibility for the accuracy, completeness, or
-usefulness of any information, apparatus, product, or process disclosed, or
-represents that its use would not infringe privately-owned rights.
+Disclaimer
 
-C. Also, reference herein to any specific commercial products, process, or
-services by trade names, trademark, manufacturer or otherwise does not
+This work was sponsored by an agency of the United States government. 
+Neither the United States Government nor Lawrence Livermore National 
+Security, LLC, nor any of their employees, makes any warranty, express 
+or implied, or assumes any liability or responsibility for the accuracy, 
+completeness, or usefulness of any information, apparatus, product, or 
+process disclosed, or represents that its use would not infringe privately
+owned rights. References herein to any specific commercial products, process, 
+or services by trade names, trademark, manufacturer or otherwise does not
 necessarily constitute or imply its endorsement, recommendation, or
-favoring by the United States Government or the University of California.
-The views and opinions of authors expressed herein do not necessarily
-state or reflect those of the United States Government or the University of
-California, and shall not be used for advertising or product endorsement
-purposes.
+favoring by the United States Government or the Lawrence Livermore National
+Security, LLC. The views and opinions of authors expressed herein do not 
+necessarily state or reflect those of the United States government or 
+Lawrence Livermore National Security, LLC, and shall not be used for 
+advertising or product endorsement purposes.
 
 =============================================================================
 
diff --git a/DISCLAIMER b/DISCLAIMER
index 0242772661d867ec406f1a7955c4ab89e544e6fb..ea55a6dbacea33dba418ba350ac159bf8f1dea10 100644
--- a/DISCLAIMER
+++ b/DISCLAIMER
@@ -1,33 +1,50 @@
-Copyright (C) 2002-2006 The Regents of the University of California.
+Copyright (C) 2008 Lawrence Livermore National Security and Hewlett-Packard.
+Copyright (C) 2002-2007 The Regents of the University of California, 
+   Linux NetworX, Hewlett-Packard and Bull.
 Produced at Lawrence Livermore National Laboratory, Hewlett-Packard, 
-Linux NetworX, and other sites.
+Bull, Linux NetworX, and others.
 
 Written by:
-Ernest Artiaga <ernest.artiaga@bsc.es>
-Danny Auble <auble1@llnl.gov>
-Susanne Balle <susanne.balle@hp.com>
-Daniel Christians <Daniel.Christians@hp.com>
-Chris Dunlap <cdunlap@llnl.gov>
-Joey Ekstrom <ekstrom1@llnl.gov>
-Jim Garlick <garlick@llnl.gov>
-Mark Grondona <grondona1@llnl.gov>
-Christopher Holmes <cholmes@hp.com>
-Takae Hatazaki <takao.hatazaki@hp.com>
-Nathan Huff <nhuff@geekshanty.com>
-David Jackson <jacksond@clusterresources.com>
-Greg Johnson <gjohnson@lanl.gov>
-Morris Jette <jette1@llnl.gov>
-Jason King <king49@llnl.gov>
-Chris Morrone <morrone2@llnl.gov>
-Brian O'Sullivan <bos@pathscale.com>
-Daniel Palermo <dan.palermo@hp.com>
-Dan Phung <phung4@llnl.gov>
-Andy Riebs <Andy.Riebs@hp.com>
-Jeff Squyres <jsquyres@lam-mpi.org>
-Keven Tew <tew1@llnl.gov>
-Jay Windley <jwindley@lnxi.com>
+Don Albert <Don.Albert(at)bull.com>
+Ernest Artiaga <ernest.artiaga(at)bsc.es>
+Danny Auble <auble1(at)llnl.gov>
+Susanne Balle <susanne.balle(at)hp.com>
+Anton Blanchard <anton(at)samba.org>
+Hongjia Cao <hgcao(at)nudt.edu.cn>
+Chuck Clouston <Chuck.Clouston(at)bull.com>
+Daniel Christians <Daniel.Christians(at)hp.com>
+Gilles Civario <gilles.civario(at)bull.net>
+Chris Dunlap <cdunlap(at)llnl.gov>
+Joey Ekstrom <ekstrom1(at)llnl.gov>
+Jim Garlick <garlick(at)llnl.gov>
+Mark Grondona <mgrondona(at)llnl.gov>
+Christopher Holmes <cholmes(at)hp.com>
+Takao Hatazaki <takao.hatazaki(at)hp.com>
+Nathan Huff <nhuff(at)geekshanty.com>
+David Jackson <jacksond(at)clusterresources.com>
+Greg Johnson <gjohnson(at)lanl.gov>
+Morris Jette <jette1(at)llnl.gov>
+Jason King <king49(at)llnl.gov>
+Nancy Kritkausky <Nancy.Kritkausky(at)bull.com>
+Bernard Li <bli(at)bcgsc.ca>
+Puenlap Lee <Puen-Lap.Lee(at)bull.com>
+Donna Mecozzi <mecozzi1(at)llnl.gov>
+Chris Morrone <morrone2(at)llnl.gov>
+Bryan O'Sullivan <bos(at)pathscale.com>
+Gennaro Oliva <oliva.g(at)na.icar.cnr.it>
+Daniel Palermo <dan.palermo(at)hp.com>
+Dan Phung <phung4(at)llnl.gov>
+Ashley Pitman <ashley(at)quadrics.com>
+Andy Riebs <Andy.Riebs(at)hp.com>
+Asier Roa <asier.roa(at)bsc.es>
+Federico Sacerdoti <Federico.Sacerdoti(at)deshaw.com>
+Jeff Squyres <jsquyres(at)lam-mpi.org>
+Keven Tew <tew1(at)llnl.gov>
+Prashanth Tamraparni <prashanth.tamraparni(at)hp.com>
+Jay Windley <jwindley(at)lnxi.com>
+Ann-Marie Wunderlin<Anne-Marie.Wunderlin(at)Bull.com>
 
-UCRL-CODE-226842.
+LLNL-CODE-402394.
 
 This file is part of SLURM, a resource management program.
 For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -51,25 +68,27 @@ OUR NOTICE AND TERMS OF AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE
 
 Our Preamble Notice
 
-A. This notice is required to be provided under our contract with the U.S.
-Department of Energy (DOE). This work was produced at the University 
-of California, Lawrence Livermore National Laboratory under Contract 
-No. W-7405-ENG-48 with the DOE.
+Auspices
 
-B. Neither the United States Government nor the University of California 
-nor any of their employees, makes any warranty, express or implied, or 
-assumes any liability or responsibility for the accuracy, completeness, or 
-usefulness of any information, apparatus, product, or process disclosed, or 
-represents that its use would not infringe privately-owned rights.
+This work performed under the auspices of the U.S. Department of Energy by 
+Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
 
-C. Also, reference herein to any specific commercial products, process, or 
-services by trade names, trademark, manufacturer or otherwise does not 
-necessarily constitute or imply its endorsement, recommendation, or 
-favoring by the United States Government or the University of California. 
-The views and opinions of authors expressed herein do not necessarily 
-state or reflect those of the United States Government or the University of 
-California, and shall not be used for advertising or product endorsement 
-purposes.
+Disclaimer
+
+This work was sponsored by an agency of the United States government. 
+Neither the United States Government nor Lawrence Livermore National 
+Security, LLC, nor any of their employees, makes any warranty, express 
+or implied, or assumes any liability or responsibility for the accuracy, 
+completeness, or usefulness of any information, apparatus, product, or 
+process disclosed, or represents that its use would not infringe privately
+owned rights. References herein to any specific commercial products, process, 
+or services by trade names, trademark, manufacturer or otherwise does not
+necessarily constitute or imply its endorsement, recommendation, or
+favoring by the United States Government or the Lawrence Livermore National
+Security, LLC. The views and opinions of authors expressed herein do not 
+necessarily state or reflect those of the United States government or 
+Lawrence Livermore National Security, LLC, and shall not be used for 
+advertising or product endorsement purposes.
 
 The precise terms and conditions for copying, distribution and modification 
 is provided in the file named "COPYING" in this directory.
diff --git a/META b/META
index 50b7e7dbe4c9540f0508e8bbe3841990df88eadd..21ee366df29d9bf63634a01bb6dd397419d92fdd 100644
--- a/META
+++ b/META
@@ -1,11 +1,11 @@
   Api_age:       0
-  Api_current:   11
+  Api_current:   13
   Api_revision:  0
   Major:         1
   Meta:          1
-  Micro:         27
-  Minor:         2
+  Micro:         3
+  Minor:         3
   Name:          slurm
   Release:       1
   Release_tags:  
-  Version:       1.2.27
+  Version:       1.3.3
diff --git a/Makefile.am b/Makefile.am
index 50c3348950d82a66c423e58d9b28c57a6460a9b3..33a35825db436a263a4f77159b1c6db546ad1375 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,7 @@ EXTRA_DIST =			\
 	etc/slurm.conf.example	\
 	etc/slurm.epilog.clean	\
 	etc/init.d.slurm	\
+	etc/init.d.slurmdbd	\
 	autogen.sh		\
 	slurm.spec		\
 	README			\
diff --git a/Makefile.in b/Makefile.in
index 010f7d2a84849fcbf5b4e924e48da2be6e221868..b06636b446ef1f854ba14cd3ab762a6f2bbd4c1f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -39,6 +39,7 @@ DIST_COMMON = README $(am__configure_deps) $(pkginclude_HEADERS) \
 	$(srcdir)/config.h.in $(srcdir)/config.xml.in \
 	$(top_srcdir)/configure \
 	$(top_srcdir)/contribs/perlapi/libslurm-perl/Makefile.PL.in \
+	$(top_srcdir)/contribs/phpext/slurm_php/config.m4.in \
 	$(top_srcdir)/slurm/slurm.h.in AUTHORS COPYING ChangeLog \
 	INSTALL NEWS
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -48,6 +49,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -70,7 +73,8 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h $(top_builddir)/slurm/slurm.h
 CONFIG_CLEAN_FILES = config.xml \
-	contribs/perlapi/libslurm-perl/Makefile.PL
+	contribs/perlapi/libslurm-perl/Makefile.PL \
+	contribs/phpext/slurm_php/config.m4
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -128,6 +132,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -141,10 +146,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -164,7 +172,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -175,6 +186,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -190,6 +203,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -205,6 +219,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -270,6 +285,7 @@ EXTRA_DIST = \
 	etc/slurm.conf.example	\
 	etc/slurm.epilog.clean	\
 	etc/init.d.slurm	\
+	etc/init.d.slurmdbd	\
 	autogen.sh		\
 	slurm.spec		\
 	README			\
@@ -365,6 +381,8 @@ config.xml: $(top_builddir)/config.status $(srcdir)/config.xml.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 contribs/perlapi/libslurm-perl/Makefile.PL: $(top_builddir)/config.status $(top_srcdir)/contribs/perlapi/libslurm-perl/Makefile.PL.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
+contribs/phpext/slurm_php/config.m4: $(top_builddir)/config.status $(top_srcdir)/contribs/phpext/slurm_php/config.m4.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -467,8 +485,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -493,8 +511,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -504,13 +522,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
@@ -581,6 +598,10 @@ dist-bzip2: distdir
 	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
 	$(am__remove_distdir)
 
+dist-lzma: distdir
+	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+	$(am__remove_distdir)
+
 dist-tarZ: distdir
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__remove_distdir)
@@ -607,6 +628,8 @@ distcheck: dist
 	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
 	  bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lzma*) \
+	  unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
 	*.tar.Z*) \
 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 	*.shar.gz*) \
@@ -762,8 +785,8 @@ uninstall-am: uninstall-pkgincludeHEADERS
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
 	all all-am am--refresh check check-am clean clean-generic \
 	clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
-	dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
-	distclean-generic distclean-hdr distclean-libtool \
+	dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
+	distclean distclean-generic distclean-hdr distclean-libtool \
 	distclean-local distclean-tags distcleancheck distdir \
 	distuninstallcheck dvi dvi-am html html-am info info-am \
 	install install-am install-data install-data-am install-dvi \
diff --git a/NEWS b/NEWS
index 3dc5b0fd1bf03dec95f0368b92ff48c16420e643..83bf170afe4cb20a09f357648c0496885a10763d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,354 @@
 This file describes changes in recent versions of SLURM. It primarily
 documents those changes that are of interest to users and admins.
 
+* Changes in SLURM 1.3.3
+========================
+ -- Add mpi_openmpi plugin to the main SLURM RPM.
+ -- Prevent invalid memory reference when using srun's --cpu_bind=cores option
+    (slurm-1.3.2-1.cea1.patch from Matthieu Hautreux, CEA).
+ -- Task affinity plugin modified to support a particular cpu bind type: cores,
+    sockets, threads, or none. Accomplished by setting an environment variable
+    SLURM_ENFORCE_CPU_TYPE (slurm-1.3.2-1.cea2.patch from Matthieu Hautreux, 
+    CEA).
+ -- For BlueGene only, log "Prolog failure" once per job not once per node.
+ -- Reopen slurmctld log file after reconfigure or SIGHUP is received.
+ -- In TaskPlugin=task/affinity, fix possible infinite loop for slurmd.
+ -- Accounting rollup works for mysql plugin.  Automatic rollup when using 
+    slurmdbd.
+ -- Copied job stat logic out of sacct into sstat in the future sacct -stat 
+    will be deprecated.
+ -- Correct sbatch processing of --nice option with negative values.
+ -- Add squeue formatted print option %Q to print a job's integer priority.
+ -- In sched/backfill, fix bug that was changing a pending job's shared value
+    to zero (possibly changing a pending job's resource requirements from a 
+    processor on some node to the full node).
+
+* Changes in SLURM 1.3.2
+========================
+ -- Get --ntasks-per-node option working for sbatch command.
+ -- BLUEGENE: Added logic to give back a best block on overlapped mode 
+    in test_only mode
+ -- BLUEGENE: Updated debug info and man pages for better help with the 
+    numpsets option and to fail correctly with bad image request for building
+    blocks.
+ -- In sched/wiki and sched/wiki2 properly support Slurm license consumption
+    (job state reported as "Hold" when required licenses are not available).
+ -- In sched/wiki2 JobWillRun command, don't return an error code if the job(s)
+    can not be started at that time. Just return an error message (from 
+    Doug Wightman, CRI).
+ -- Fix bug if sched/wiki or sched/wiki2 are configured and no job comment is 
+    set.
+ -- scontrol modified to report partition partition's "DisableRootJobs" value.
+ -- Fix bug in setting host address for PMI communications (mpich2 only).
+ -- Fix for memory size accounting on some architectures.
+ -- In sbatch and salloc, change --dependency's one letter option from "-d"
+    to "-P" (continue to accept "-d", but change the documentation).
+ -- Only check that task_epilog and task_prolog are runable by the job's
+    user, not as root.
+ -- In sbatch, if specifying an alternate directory (--workdir/-D), then
+    input, output and error files are in that directory rather than the 
+    directory from which the command is executed
+ -- NOTE: Fully operational with Moab version 5.2.3+. Change SUBMITCMD in
+    moab.cfg to be the location of sbatch rather than srun. Also set 
+    HostFormat=2 in SLURM's wiki.conf for improved performance.
+ -- NOTE: We needed to change an RPC from version 1.3.1. You must upgrade 
+    all nodes in a cluster from v1.3.1 to v1.3.2 at the same time.
+ -- Postgres plugin will work from job accounting, not for association 
+    management yet.
+ -- For srun/sbatch --get-user-env option (Moab use only) look for "env"
+    command in both /bin and /usr/sbin (for Suse Linux).
+ -- Fix bug in processing job feature requests with node counts (could fail
+    to schedule job if some nodes have not associated features).
+ -- Added nodecnt and gid to jobcomp/script
+ -- Insure that nodes select in "srun --will-run" command or the equivalent in
+    sched/wiki2 are in the job's partition.
+ -- BLUGENE - changed partition Min|MaxNodes to represent c-node counts
+    instead of base partitions
+ -- In sched/gang only, prevent possible invalid memory reference when 
+    slurmctld is reconfigured, e.g. "scontrol reconfig".
+ -- In select/linear only, prevent invalid memory reference in log message when
+    nodes are added to slurm.conf and then "scontrol reconfig" is executed. 
+
+* Changes in SLURM 1.3.1
+========================
+ -- Correct logic for processing batch job's memory limit enforcement.
+ -- Fix bug that was setting a job's requeue value on any update of the 
+    job using the "scontrol update" command. The invalid value of an 
+    updated job prevents it's recovery when slurmctld restarts.
+ -- Add support for cluster-wide consumable resources. See "Licenses"
+    parameter in slurm.conf man page and "--licenses" option in salloc, 
+    sbatch and srun man pages.
+ -- Major changes in select/cons_res to support FastSchedule=2 with more
+    resources configured than actually exist (useful for testing purposes).
+ -- Modify srun --test-only response to include expected initiation time 
+    for a job as well as the nodes to be allocated and processor count
+    (for use by Moab).
+ -- Correct sched/backfill to properly honor job dependencies.
+ -- Correct select/cons_res logic to allocate CPUs properly if there is
+    more than one thread per core (previously failed to allocate all cores).
+ -- Correct select/linear logic in shared job count (was off by 1).
+ -- Add support for job preeption based upon partition priority (in sched/gang,
+    preempt.patch from Chris Holmes, HP).
+ -- Added much better logic for mysql accounting.  
+ -- Finished all basic functionality for sacctmgr.
+ -- Added load file logic to sacctmgr for setting up a cluster in one step.
+ -- NOTE: We needed to change an RPC from version 1.3.0. You must upgrade 
+    all nodes in a cluster from v1.3.0 to v1.3.1 at the same time.
+ -- NOTE: Work is currently underway to improve placement of jobs for gang
+    scheduling and preemption.
+ -- NOTE: Work is underway to provide additional tools for reporting 
+    accounting information.
+
+* Changes in SLURM 1.3.0
+========================
+ -- In sched/wiki2, add processor count to JOBWILLRUN response.
+ -- Add event trigger for node entering DRAINED state.
+ -- Build properly without OpenSSL installed (OpenSSL is recommended, but not 
+    required).
+ -- Added slurmdbd, and modified accounting_storage plugin to talk to it. 
+    Allowing multiple slurm systems to securly store and gather information
+    not only about jobs, but the system also. See accounting web page for more
+    information.    
+
+* Changes in SLURM 1.3.0-pre11
+==============================
+ -- Restructure the sbcast RPC to take advantage of larger buffers available
+    in Slurm v1.3 RPCs.
+ -- Fix several memory leaks.
+ -- In scontrol, show job's Requeue value, permit change of Requeue and Comment
+    values.
+ -- In slurmctld job record, add QOS (quality of service) value for accounting
+    purposes with Maui and Moab.
+ -- Log to a job's stderr when it is being cancelled explicitly or upon reaching
+    it's time limit.
+ -- Only permit a job's account to be changed while that job is PENDING.
+ -- Fix race condition in job suspend/resume (slurmd.sus_res.patch from HP).
+
+* Changes in SLURM 1.3.0-pre10
+==============================
+ -- Add support for node-specific "arch" (architecture) and "os" (operating 
+    system) fields. These fields are set based upon values reported by the
+    slurmd daemon on each compute node using SLURM_ARCH and SLURM_OS environment 
+    variables (if set, the uname function otherwise) and are intended to support
+    changes in real time changes in operating system. These values are reported
+    by "scontrol show node" plus the sched/wiki and sched/wiki2 plugins for Maui
+    and Moab respectively.
+ -- In sched/wiki and sched/wiki2: add HostFormat and HidePartitionJobs to 
+    "scontrol show config" SCHEDULER_CONF output.
+ -- In sched/wiki2: accept hostname expression as input for GETNODES command.
+ -- Add JobRequeue configuration parameter and --requeue option to the sbatch
+    command.
+ -- Add HealthCheckInterval and HealthCheckProgram configuration parameters.
+ -- Add SlurmDbdAddr, SlurmDbdAuthInfo and SlurmDbdPort configuration parameters.
+ -- Modify select/linear to achieve better load leveling with gang scheduler.
+ -- Develop the sched/gang plugin to support select/linear and
+    select/cons_res. If sched/gang is enabled and Shared=FORCE is configured
+    for a partition, this plugin will gang-schedule or "timeslice" jobs that
+    share common resources within the partition. Note that resources that are
+    shared across partitions are not gang-scheduled.
+ -- Add EpilogMsgTime configuration parameter. See "man slurm.conf" for details.
+ -- Increase default MaxJobCount configuration parameter from 2000 to 5000. 
+ -- Move all database common files from src/common to new lib in src/database.
+ -- Move sacct to src/accounting added sacctmgr for scontrol like operations 
+    to accounting infrastructure.
+ -- Basic functions of sacctmgr in place to make for administration of 
+    accounting.
+ -- Moved clusteracct_storage plugin to accounting_storage plugin,
+    jobacct_storage is still it's own plugin for now.
+ -- Added template for slurm php extention.
+ -- Add infrastructure to support allocation of cluster-wide licenses to jobs.
+    Full support will be added some time after version 1.3.0 is released.
+ -- In sched/wiki2 with select/bluegene, add support for WILLRUN command
+    to accept multiple jobs with start time specifications.
+
+* Changes in SLURM 1.3.0-pre9
+=============================
+ -- Add spank support to sbatch. Note that spank_local_user() will be called 
+    with step_layout=NULL and gid=SLURM_BATCH_SCRIPT and spank_fini() will 
+    be called immediately afterwards.
+ -- Made configure use mysql_config to find location of mysql database install
+    Removed bluegene specific information from the general database tables.
+ -- Re-write sched/backfill to utilize new will-run logic in the select 
+    plugins. It now supports select/cons_res and all job options (required
+    nodes, excluded nodes, contiguous, etc.).
+ -- Modify scheduling logic to better support overlapping partitions.
+ -- Add --task-mem option and remove --job-mem option from srun, salloc, and 
+    sbatch commands. Enforce step memory limit, if specified and there is
+    no job memory limit specified (--mem). Also see DefMemPerTask and
+    MaxMemPerTask in "man slurm.conf". Enforcement is dependent upon job
+    accounting being enabled with non-zero value for JoabAcctGatherFrequency.
+ -- Change default node tmp_disk size to zero (for diskless nodes).
+
+* Changes in SLURM 1.3.0-pre8
+=============================
+ -- Modify how strings are packed in the RPCs, Maximum string size 
+    increased from 64KB (16-bit size field) to 4GB (32-bit size field).
+ -- Fix bug that prevented time value of "INFINITE" from being processed.
+ -- Added new srun/sbatch option "--open-mode" to control how output/error 
+    files are opened ("t" for truncate, "a" for append).
+ -- Added checkpoint/xlch plugin for use with XLCH (Hongjia Cao, NUDT).
+ -- Added srun option --checkpoint-path for use with XLCH (Hongjia Cao, NUDT).
+ -- Added new srun/salloc/sbatch option "--acctg-freq" for user control over 
+    accounting data collection polling interval.
+ -- In sched/wiki2 add support for hostlist expression use in GETNODES command
+    with HostFormat=2 in the wiki.conf file.
+ -- Added new scontrol option "setdebug" that can change the slurmctld daemons
+    debug level at any time (Hongjia Cao, NUDT).
+ -- Track total total suspend time for jobs and steps for accounting purposes.
+ -- Add version information to partition state file.
+ -- Added 'will-run' functionality to all of the select plugins (bluegene,
+    linear, and cons_res) to return node list and time job can start based 
+    on other jobs running.
+ -- Major restructuring of node selection logic. select/linear now supports
+    partition max_share parameter and tries to match like size jobs on the 
+    same nodes to improve gang scheduling performance. Also supports treating 
+    memory as consumable resource for job preemption and  gang scheduling if 
+    SelectTypeParameter=CR_Memory in slurm.conf.
+ -- BLUEGENE: Reorganized bluegene plugin for maintainability sake.
+ -- Major restructuring of data structures in select/cons_res.
+ -- Support job, node and partition names of arbitrary size.
+ -- Fix bug that caused slurmd to hang when using select/linear with
+    task/affinity.
+
+* Changes in SLURM 1.3.0-pre7
+=============================
+ -- Fix a bug in the processing of srun's --exclusive option for a job step.
+
+* Changes in SLURM 1.3.0-pre6
+=============================
+ -- Add support for configurable number of jobs to share resources using the 
+    partition Shared parameter in slurm.conf (e.g. "Shared=FORCE:3" for two 
+    jobs to share the resources). From Chris Holmes, HP.
+ -- Made salloc use api instead of local code for message handling.
+
+* Changes in SLURM 1.3.0-pre5
+=============================
+ -- Add select_g_reconfigure() function to node changes in slurmctld configuration
+    that can impact node scheduling.
+ -- scontrol to set/get partition's MaxTime and job's Timelimit in minutes plus
+    new formats: min:sec, hr:min:sec, days-hr:min:sec, days-hr, etc.
+ -- scontrol "notify" command added to send message to stdout of srun for 
+    specified job id.
+ -- For BlueGene, make alpha part of node location specification be case insensitive.
+ -- Report scheduler-plugin specific configuration information with the 
+    "scontrol show configuration" command on the SCHEDULER_CONF line. This
+    information is not found in the "slurm.conf" file, but a scheduler plugin 
+    specific configuration (e.g. "wiki.conf").
+ -- sview partition information reported now includes partition priority.
+ -- Expand job dependency specification to support concurrent execution, 
+    testing of job exit status and multiple job IDs.
+
+* Changes in SLURM 1.3.0-pre4
+=============================
+ -- Job step launch in srun is now done from the slurm api's all further
+    modifications to job launch should be done there.
+ -- Add new partition configuration parameter Priority. Add job count to 
+    Shared parameter.
+ -- Add new configuration parameters DefMemPerTask, MaxMemPerTask, and 
+    SchedulerTimeSlice.
+ -- In sched/wiki2, return REJMESSAGE with details on why a job was 
+    requeued (e.g. what node failed).
+
+* Changes in SLURM 1.3.0-pre3
+=============================
+ -- Remove slaunch command
+ -- Added srun option "--checkpoint=time" for job step to automatically be 
+    checkpointed on a period basis.
+ -- Change behavior of "scancel -s KILL <jobid>" to send SIGKILL to all job
+    steps rather than cancelling the job. This now matches the behavior of
+    all other signals. "scancel <jobid>" still cancels the job and all steps.
+ -- Add support for new job step options --exclusive and --immediate. Permit
+    job steps to be queued when resources are not available within an existing 
+    job allocation to dedicate the resources to the job step. Useful for
+    executing simultaneous job steps. Provides resource management both at 
+    the level of jobs and job steps.
+ -- Add support for feature count in job constraints, for example
+    srun --nodes=16 --constraint=graphics*4 ...
+    Based upon work by Kumar Krishna (HP, India).
+ -- Add multi-core options to salloc and sbatch commands (sbatch.patch and
+    cleanup.patch from Chris Holmes, HP).
+ -- In select/cons_res properly release resources allocated to job being 
+    suspended (rmbreak.patch, from Chris Holmes, HP).
+ -- Removed database and jobacct plugin replaced with jobacct_storage 
+    and jobacct_gather for easier hooks for further expansion of the
+    jobacct plugin.
+
+* Changes in SLURM 1.3.0-pre2
+=============================
+ -- Added new srun option --pty to start job with pseudo terminal attached 
+    to task 0 (all other tasks have I/O discarded)
+ -- Disable user specifying jobid when sched/wiki2 configured (needed for 
+    Moab releases until early 2007).
+ -- Report command, args and working directory for batch jobs with 
+    "scontrol show job".
+
+* Changes in SLURM 1.3.0-pre1
+=============================
+ -- !!! SRUN CHANGES !!!
+    The srun options -A/--allocate, -b/--batch, and -a/--attach have been
+    removed!  That functionality is now available in the separate commands
+    salloc, sbatch, and sattach, respectively.
+ -- Add new node state FAILING plus trigger for when node enters that state.
+ -- Add new configuration paramter "PrivateData". This can be used to 
+    prevent a user from seeing jobs or job steps belonging to other users.
+ -- Added configuration parameters for node power save mode: ResumeProgram
+    ResumeRate, SuspendExcNodes, SuspendExcParts, SuspendProgram and 
+    SuspendRate.
+ -- Slurmctld maintains the IP address (rather than hostname) for srun 
+    communications. This fixes some possible network routing issues.
+ -- Added global database plugin.  Job accounting and Job completion are the 
+    first to use it.  Follow documentation to add more to the plugin.
+ -- Removed no-longer-needed jobacct/common/common_slurmctld.c since that is
+    replaced by the database plugin.
+ -- Added new configuration parameter: CryptoType.
+    Moved existing digital signature logic into new plugin: crypto/openssl.
+    Added new support for crypto/munge (available with GPL license).
+
+* Changes in SLURM 1.2.31
+=========================
+
+* Changes in SLURM 1.2.30
+=========================
+ -- Fix for gold not to print out 720 error messages since they are
+    potentally harmful.
+ -- In sched/wiki2 (Moab), permit changes to a pending job's required features:
+    CMD=CHANGEJOB ARG=<jobid> RFEATURES=<features>
+ -- Fix for not aborting when node selection doesn't load, fatal error instead
+ -- In sched/wiki and sched/wiki2 DO NOT report a job's state as "Hold" if it's
+    dependencies have not been satisfied. This reverses a changed made in SLURM
+    version 1.2.29 (which was requested by Cluster Resources, but places jobs 
+    in a HELD state indefinitely).
+
+* Changes in SLURM 1.2.29
+=========================
+ -- Modified global configuration option "DisableRootJobs" from number (0 or 1)
+    to boolean (YES or NO) to match partition parameter.
+ -- Set "DisableRootJobs" for a partition to match the global parameters value 
+    for newly created partitions.
+ -- In sched/wiki and sched/wiki2 report a node's updated features if changed
+    after startup using "scontrol update ..." command.
+ -- In sched/wiki and sched/wiki2 report a job's state as "Hold" if it's 
+    dependencies have not been satisfied.
+ -- In sched/wiki and sched/wiki2 do not process incoming requests until
+    slurm configuration is completely loaded.
+ -- In sched/wiki and sched/wiki2 do not report a job's node count after it 
+    has completed (slurm decrements the allocated node count when the nodes
+    transition from completing to idle state).
+ -- If job prolog or epilog fail, log the program's exit code.
+ -- In jobacct/gold map job names containing any non-alphanumeric characters 
+    to '_' to avoid MySQL parsing problems.
+ -- In jobacct/linux correct parsing if command name contains spaces.
+ -- In sched/wiki and sched/wiki2 report make job info TASK count reflect the 
+    actual task allocation (not requested tasks) even after job terminates.
+    Useful for accounting purposes only.
+
+* Changes in SLURM 1.2.28
+=========================
+ -- Added configuration option "DisableRootJobs" for parameter 
+    "PartitionName".  See "man slurm.conf" for details.
+ -- Fix for faking a large system to correctly handle node_id in the task
+    afffinity plugin for ia64 systems.
+
 * Changes in SLURM 1.2.27
 =========================
  -- Record job eligible time in accounting database (for jobacct/gold only).
@@ -15,6 +363,7 @@ documents those changes that are of interest to users and admins.
  -- Enhance job requeue on node failure to be more robust.
  -- Added configuration parameter "DisableRootJobs". See "man slurm.conf" 
     for details.
+ -- Fixed issue with account = NULL in Gold job accounting plugin
 
 * Changes in SLURM 1.2.26
 =========================
@@ -25,8 +374,6 @@ documents those changes that are of interest to users and admins.
  -- In srun and sbatch, do not check the PATH env var if an absolute pathname 
     of the program is specified (previously reported an error if no PATH).
  -- Correct output of "sinfo -o %C" (CPU counts by node state).
- -- Treat attempt to submit a batch job against an existing resource allocation
-    as an error if sched/wiki2 is configured (Moab).
 
 * Changes in SLURM 1.2.25
 =========================
@@ -2878,4 +3225,4 @@ documents those changes that are of interest to users and admins.
  -- Change directory to /tmp in slurmd if daemonizing.
  -- Logfiles are reopened on reconfigure.
  
-$Id: NEWS 13871 2008-04-15 15:47:33Z jette $
+$Id: NEWS 14153 2008-05-29 16:55:52Z jette $
diff --git a/README b/README
index 0828b6ccd60a879294332a37d352dd580805d6a2..1a782d3695684d39ca42b0ee0090a2da6ad58261 100644
--- a/README
+++ b/README
@@ -62,71 +62,10 @@ quick description of the subdirectories of the SLURM distribution follows:
 COMPILING AND INSTALLING THE DISTRIBUTION
 -----------------------------------------
 
-Please the the INSTALL file for basic instructions. You will need a
-working installation of OpenSSL.
-
-SLURM does not use reserved ports to authenticate communication
-between components. You will need to have at least one "auth"
-plugin. Currently, only three authentication plugins are available:
-"auth/none," "auth/authd," and "auth/munge." The "auth/none" plugin is
-built and used by default, but one of either Brent Chun's authd, or Chris
-Dunlap's Munge should be installed in order to get properly authenticated
-communications.  The configure script in the top-level directory of this
-distribution will determine which authentication plugins may be built.
-
-
-OpenSSL:
-http://www.openssl.org
-
-AUTHD:
-http://www.theether.org/authd/
-
-MUNGE:
-http://www.llnl.gov/linux/munge/
-
-
-CONFIGURATION
--------------
-
-An annotated sample configuration file for SLURM is provided with this
-distribution as etc/slurm.conf.example. Edit this config file to suit
-your site and cluster, then copy it to `$sysconfdir/slurm.conf,' where
-sysconfdir defaults to PREFIX/etc unless explicitly overwritten in the
-`configure' or `make' steps.
-
-Once the config file is installed in the proper location, you'll need
-to create the keys for SLURM job credential creation and verification.
-The following openssl commands should be used:
-
- > openssl genrsa -out /path/to/private/key 1024
- > openssl rsa -in /path/to/private/key -pubout -out /path/to/public/key
-
-The private key and public key locations should be those specified by
-JobCredentialPrivateKey and JobCredentialPublicCertificate in the SLURM
-config file.
-
-
-RUNNING SLURM
--------------
-
-Once a valid configuration has been set up and installed, the SLURM
-controller, slurmctld, should be started on the primary and backup
-control machines, and the SLURM compute node daemon, slurmd, should be
-started on each compute server.
-
-The slurmd daemons need to run as root for production use, but may be
-run as a user for testing purposes (obviously no jobs may be run as
-any other user in that configuration). The SLURM controller, slurmctld,
-need to be run as the configured SlurmUser (see your config file).
-
-Man pages are the best source of information about SLURM commands and
-daemons. Please see: slurmctld(8), slurmd(8), scontrol(1), sinfo(1),
-squeue(1), scancel(1), and srun(1).
-
-Also, take a look at the Quickstart Guide to get acquainted with
-running and managing jobs with SLURM: doc/html/quickstart_admin.html
-or PREFIX/share/doc/quickstart_admin.html.
-
+Please see the instructions at 
+  http://www.llnl.gov/linux/slurm/quickstart_admin.html
+Extensive documentation is available from our home page at 
+  http://www.llnl.gov/linux/slurm
 
 PROBLEMS
 --------
@@ -134,4 +73,4 @@ PROBLEMS
 If you experience problems compiling, installing, or running SLURM
 please send e-mail to either slurm-dev@lists.llnl.gov.
 
-$Id: README 11977 2007-08-09 17:49:08Z da $
+$Id: README 11978 2007-08-09 17:53:54Z da $
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 8bc14d0faf19fef16ba4f159fd07e50cfdbb636a..858d9ebfdf30dcbb8d39d762ddf6f7eab2c7438a 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -1,148 +1,236 @@
-RELEASE NOTES FOR SLURM VERSION 1.2
-13 March 2007
+RELEASE NOTES FOR SLURM VERSION 1.3
+14 May 2008
 
 
 IMPORTANT NOTE:
-SLURM state files in version 1.2 are different from those of version 1.1.
+SLURM state files in version 1.3 are different from those of version 1.2.
 After installing SLURM version 1.2, plan to restart without preserving 
-jobs or other state information. Restart daemons with the "-c" option or 
-use "/etc/init.d/slurm startclean".
-
-NEW COMMANDS
-
-* Several new commands have been added to perform individual srun functions.
-  The srun command will continue to exist, but these commands may offer 
-  greater clarity and ease of use. The srun options --allocate, --attach, 
-  and --batch will eventually cease being supported. The new commands are 
+jobs or other state information. While SLURM version 1.2 is still running, 
+cancel all pending and running jobs (e.g.
+"scancel --state=pending; scancel --state=running"). Then stop and restart 
+daemons with the "-c" option or use "/etc/init.d/slurm startclean".
+
+There are substantial changes in the slurm.conf configuration file. It 
+is recommended that you rebuild your configuration file using the tool
+doc/html/configurator.html that comes with the distribution. The node 
+information is unchanged and the partition information only changes for 
+the Shared and Priority parameters, so those portions of your old 
+slurml.conf file may be copied into the new file.
+
+Two areas of substantial change are accounting and job scheduling.
+Slurm is now able to save accounting information in a database, 
+either MySQL or PostGreSQL. We have written a new daemon, slurmdbd 
+(Slurm DataBase Daemon), to serve as a centralized data manager for 
+multiple Slurm clusters. A new tool sacctmgr is available to manage
+user accounting information through SlurmdDBD and a variety of 
+other tools are still under development to generate assorted 
+acccounting reports including graphics and a web interface. Slurm 
+now supports gang scheduling (time-slicing of parallel jobs for 
+improved responsiveness and system utilization). Many related 
+scheduling changes have also been made. 
+
+There are changes in SLURM's RPMs. There is a new RPM called 
+slurmdbd (SLURM DataBase Daemon) used to provide a secure 
+SLURM database interface for accounting purposes (more information 
+about that below). The SLURM plugins have been moved to a new
+RPM called slurm-plugins. If the slurmdbd is installed it 
+requires the slurm-plugins, but not the other slurm components.
+The base SLURM plugin requires the plugins, which used to be
+within that RPM. 
+
+Many enhancements have been made for better Slurm integration with 
+Moab and Maui schedulers. Moab development work is still underway 
+to support Slurm v1.3. Moab users should not upgrade to Slurm v1.3
+until this work has been completed.
+
+Major changes in Slurm version 1.3 are described below. Some changes
+made after the initial release of Slurm version 1.2 are also noted.
+Many less significant changes are not identified here. A complete list 
+of changes can be found in the NEWS file. Man pages should be consulted
+for more details about command and configuration parameter changes.
+
+
+COMMAND CHANGES
+===============
+* The srun options --allocate, --attach and --batch have been removed.
+  Use the new commands added in SLURM version 1.2 for this functionality:
   salloc  - Create a job allocation (functions like "srun --allocate")
   sattach - Attach to an existing job step (functions like "srun --attach")
   sbatch  - Submit a batch job script (functions like "srun --batch")
+  These commands generally have the same options as the srun command.
   See the individual man pages for more information. 
 
-* A new command, strigger, was added to manage event triggers. This was 
-  added in SLURM version 1.2.2. See strigger's man pages for details.
-
-* A new GUI is available for viewing and modifying state information, sview.
-  Note that sview will only be built on systems which have libglade-2.0 and 
-  gtk+-2.0 installed.
-
-
-CONFIGURATION FILE CHANGES
+* The slaunch command has been removed. Use the srun command instead.
+
+* The srun option --exclusive has been added for job steps to be 
+  allocated processors not already assigned to other job steps. This 
+  can be used to execute multiple job steps simultaneously within a 
+  job allocation and have SLURM perform resource management for the 
+  job steps much like it does for jobs. If dedicated resources are 
+  not immediately available, the job step will be executed later 
+  unless the --immediate option is also set.
+
+* Support is now provided for feature counts in job constraints. For 
+  example: srun --nodes=16 --constraint=graphics*4 ...
+
+* The srun option --pty has been added to start the job with a pseudo 
+  terminal attached to task zero (all other tasks have I/O discarded).
+
+* Job time limits can be specified using the following formats: min, 
+  min:sec, hour:min:sec, and days-hour:min:sec (formerly only supported 
+  minutes).
+
+* scontrol now shows job TimeLimit and partition MaxTime in the format of
+  [days-]hours:minutes:seconds or "UNLIMITED". The scontrol update options 
+  for times now accept minutes, minutes:seconds, hours:minutes:seconds, 
+  days-hours, days-hours:minutes, days-hours:minutes:seconds or "UNLIMITED".
+  This new format also applies to partition MaxTime in the slurm.conf file.
+
+* scontrol "notify" command added to send message to stdout of srun for 
+  specified job id. 
+
+* Support has been added for a much richer job dependency specification 
+  including testing of exit codes and multiple dependencies.
+
+* The srun options --checkpoint=<interval> and --checkpoint-path=<file_path>
+  have been added.
+
+* Event trigger support was added in Slurm v1.2.2. The command strigger
+  was added to manage the triggers.
+
+* Added a --task-mem option and removed --job-mem option from srun, salloc, 
+  and sbatch commands. Memory limits are applied on a per-task basis.
+
+
+SCHEDULING CHANGES
+==================
+* The sched/backfill plugin has been largely re-written. It now supports 
+  select/cons_res and all job options (required nodes, excluded nodes, 
+  contiguous, etc.).
+
+* Added a new partition parameter, Priority. A job's scheduling priority is 
+  based upon two factors. First the priority of its partition and second the 
+  job's priority. Since nodes can be configured in multiple partitions, this 
+  can be used to configure high priority partitions (queues).
+
+* The partition parameter Shared now has a job count. For example:
+  Shared=YES:4     (Up to 4 jobs may share each resource, user control)
+  Shared=FORCE:2   (Up to 2 jobs may share each resource, no user control)
+
+* Added new parameters DefMemPerTask and MaxMemPerTask to control the default
+  and maximum memory per task. Any task that exceeds the specified size will 
+  be terminated (enforcement requires job accounting to be enabled with a 
+  non-zero value for JoabAcctGatherFrequency).
+
+* The select linear plugin (allocating whole nodes to jobs) can treat memory 
+  as a consumable resource with SelectTypeParameter=CR_Memory configured.
+
+* A new scheduler type, gang, was added for gang scheduling (time-slicing of 
+  parallel jobs). Note: The Slurm gang scheduler is not compatible with the
+  LSF, Maui or Moab schedulers.
+
+* The new parameter, SchedulerTimeSlice, controls the length of gang scheduler 
+  time slices.
+
+* Added a new parameter, Licenses to support cluster-wide consumable 
+  resources. The --licenses option was also added to salloc, sbatch, 
+  and srun.
+
+* The Shared=exclusive option in conjunction with SelectType=select/cons_res
+  can be used to dedicate whole nodes to jobs in specific partitions while
+  allocating sockets, cores, or hyperthreads in other partitions.
+
+* Changes in the interface with the Moab and Maui scheduler have been 
+  extensive providing far better integration between the systems.
+  * Many more parameters are shared between the systems.
+  * A new wiki.conf parameter, ExcludePartitions, can be used to enable 
+    Slurm-based scheduling of jobs in specific partitions to achieve
+    better responsiveness while losing Moab or Maui policy controls.
+  * Another new wiki.conf parameter, HidePartitionJobs, can be used to 
+    to hide jobs in specific partitions from Moab or Maui as well. See
+    the wiki.conf man pages for details. 
+  * Moab relies upon Slurm to get a user's environment variables upon 
+    job submission. If this can not be accomplished within a few seconds 
+    (see the GetEnvTimeout parameter) then cache files can be used. Use
+    contribs/env_cache_builder.c to build these cache files.
+
+
+ACCOUNTING CHANGES
+==================
+* The job accounting plugin has been split into two components: gathering
+  of data and storing the data. The JobAcctType parameter has been replaced by
+  JobAcctGatherType (AIX or Linux) and AccountingStorageType (MySQL, PostGreSQL,
+  filetext, and SlurmDBD). Storing the accounting information into a database
+  will provide you with greater flexibility in managing the data.
+
+* A new daemon SlurmDBD (Slurm DataBase Daemon) has been added. This can 
+  be used to securely manage the accounting data for several Slurm clusters
+  in a central location. Several new parameters have been added to support
+  SlurmDBD, all starting with SlurmDBD. Note that the SlurmDBD daemon is 
+  designed to use a Slurm JobAcctStorageType plugin to use MySQL now. 
+  It also uses existing Slurm authentication plugins.
 
-* The slurm.conf configuration file now supports a "Include" directive to
-  include other files inline.
+* A new command, sacctmgr, is available for managing user accounts in
+  SlurmDBD has been added. This information is required for use of SlurmDBD
+  to manage job accounting data. Information is maintained based upon 
+  an "association", which has four components: cluster name, Slurm partition, 
+  user name and bank account. This tool can also be used to maintain 
+  scheduling policy information that can be uploaded to Moab (various 
+  resource limits and fair-share values) See the sacctmgr man page and 
+  accounting web page for more information. Additional tools to generate 
+  accounting reports are currently under development and will be released 
+  soon.
+
+* Job completion records can now be written to a MySQL or PostGreSQL
+  database in addition to a test file as controlled using the JobCompType
+  parameter.
 
-* Added new configuration parameter MessageTimeout (replaces #define in the
-  code).
 
-* Added new configuration parameter MailProg (in case mail program is not
-  at "/bin/mail").
+OTHER CONFIGURATION CHANGES
+===========================
+* A new parameter, JobRequeue, to control default job behavior after a node 
+  failure (requeue or kill the job). The sbatch--requeue option can be used to
+  override the system default.
+
+* Added new parameters HealthCheckInterval and HealthCheckProgram to 
+  automatically test the health of compute nodes.
+
+* New parameters UnkillableStepProgram and UnkillableStepTimeout offer
+  better control when user processes can not be killed. For example
+  nodes can be automatically rebooted (added in Slurm v1.2.12)
+
+* A new parameter, JobFileAppend, controls how to proceed when a job's
+  output or error file already exist (truncate the file or append to it, 
+  added in slurm v1.2.13). Users can override this using the --open-mode
+  option when submitting a job.
+
+* Checkpoint plugins have been added for XLCH and OpenMPI.
+
+* A new parameter, PrivateData, can be used to prevent users from being 
+  able to view jobs or job steps belonging to other users.
+
+* A new parameter CryptoType to specify digital signature plugin to be used
+  Options are crypto/openssl (default) or crypto/munge (for a GPL license).
+
+* Several Slurm MPI plugins were added to support srun launch of MPI tasks
+  including mpich1_p4 (Slurm v1.2.10) and mpich-mx (Slurm v1.2.11). 
+
+* Cpuset logic was added to the task/affinity plugin in Slurm v1.2.3. 
+  Set TaskPluginParam=cpusets to enable.
 
-* Added new configuration parameter TaskPluginParam (for future use, to 
-  control which task affinity functions are used, "cpusets" or "sched" for 
-  schedsetaffinity).
 
-* Removed defunct configuration parameter, ShedulerAuth. It has been rendered 
-  obsolete by the new wiki.conf file.
-
-* Several new configuration parameters can be used to specify architectural
-  details of the nodes: Sockets, CoresPerSocket, and ThreadsPerCore.
-  For multi-core systems, these parameters will typically need to be 
-  specified in the configuration file.
-
-* For select/cons_res, an assortment of consumable resources can be supported 
-  including: CPUs, cores, sockets and/or memory. See new configuration 
-  parameter SelectTypeParameters.
-
-* For BlueGene systems only: Alternate BlrtsImage, LinuxImage, MloaderImage,
-  and RamDiskImage file can be specified along with specific groups that 
-  can use them.
+OTHER CHANGES
+=============
+* Perl APIs and Torque wrappers for Torque/PBS to SLURM migration were 
+  added in Slurm v1.2.13 in the contribs directory. SLURM now works 
+  directly with Globus using the PBS GRAM.
 
-* MPI plugin for use with MPICH-GM renamed from "mpich-gm" to "mpichgm". 
-  (There was previously some inconsistent naming.)
+* Support was added for several additional PMI functions to be used by 
+  MPICH2 and MVAPICH2. Support for an PMI_TIME environment variable was
+  also added for user to control how PMI communications are spread out 
+  in time. Scalability up to 16k tasks has been achieved. 
 
-OTHER CHANGES
+* New node state FAILING has been added along with event trigger for it.
+  This is similar to DRAINING, but is intended for fault prediction work.
+  A trigger was also added for nodes becoming DRAINED.
 
-* Several srun options are available to control layout of tasks across the 
-  cores on a node: --extra-node-info, --ntasks-per-node, --sockets-per-node,
-  --cores-per-socket, --threads-per-core, --minsockets, --mincores, 
-  --minthreads, --ntasks-per-socket, --ntasks-per-core, and --ntasks-per-node.
-
-* New scontrol, sinfo and squeue options can be used to view socket, core,
-  and task details by job and/or node.
-
-* The scontrol and squeue commands will provide a more detailed explanation 
-  of why a job was put into FAILED state.
-
-* Permit batch jobs to be requeued ("scontrol requeue <jobid>" or
-  "srun --batch --no-requeue ..." to prevent).
-
-* View a job's exit code using "scontrol show job".
-
-* Added "account" field to job and step accounting information and sacct output.
-
-* Added new job field, "comment". Set by srun, salloc and sbatch. View
-  with "scontrol show job". Used by sched/wiki2.
-
-* Added support for OS X operating system.
-
-* A job step's actual run time is maintained with suspend/resume use.
-
-* Added support for Portable Linux Processor Affinity in the task/affinity 
-  plugin (PLPA, see http://www.open-mpi.org/software/plpa).
-
-* There is a new version of the Wiki scheduler plugin to interface with
-  the Moab Scheduler. It can be accessed with the slurm.conf parameter 
-  "SchedulerType=sched/wiki2". Continue using "SchedulerType=sched/wiki"
-  for the Maui Scheduler at this time and see the section below for details. 
-  If you use sched/wiki2, you will at least need to add a wiki.conf file. 
-  Key differences include:
-  - Node and job data returned is correct (several errors in old plugin)
-  - Node data includes partition information (CCLASS field)
-  - Improved error handling
-  - Support added for configuration file ("wiki.conf" in same directory
-    as "slurm.conf" file, see "man wiki.conf" for details)
-  - Support added for job modify, suspend/resume, and requeue
-  - Authentication of communications now supported
-  - Notification of scheduler on events (job submitted or termination)
-  - There is no longer a "sched-wiki" RPM. All files are in the main RPM.
-
-* The sched/wiki plugin has been re-written for use with the Maui Scheduler.
-  Some time in early 2007 the Maui Scheduler should be upgraded to use 
-  the additional capabilities offered by sched/wiki2. Changes in sched/wiki
-  include:
-  - Node and job data returned is correct (several errors in old plugin)
-  - Support added for configuration file ("wiki.conf" in same directory
-    as "slurm.conf" file, see "man wiki.conf" for details). Currently 
-    wiki.conf is only used to store an authentication key, which is not 
-    used by most versions of the Maui Scheduler.
-  - There is no longer a "sched-wiki" RPM. All files are in the main RPM.
-
-* The features associated with a node can now be changed using the 
-  "scontrol update" and "sview" commands.
-
-* For BlueGene system only: Added "--reboot" option to srun, salloc, and 
-  sbatch commands to force booting of nodes before starting the job.
-
-* For BlueGene Systems only: Changed way of keeping track of smaller 
-  partitions using ionode range instead of quarter nodecard notation. 
-  (i.e. bgl000[0-3] instead of bgl000.0.0)
-
-* For BlueGene Systems only: New scontrol options to down specific ionodes 
-  without having to create blocks there  (i.e. 
-  "scontrol update subbp=bgl000[0-3] state=error"). This will down the first 
-  four ionodes or on a BGL system the first nodecard in the base partition.
-
-* For BlueGene Systems only: sinfo will now display correct node counts for 
-  blocks in an error state or blocks and small blocks that are allocated.
-  This results in some overlap of nodes displayed if you are running with
-  Small blocks but the node counts will be correct for the states given. 
-
-* For BlueGene Systems only: A state save/recover file has been added to save
-  the state of the system (primarily for blocks in an error state) to be loaded
-  when the system has been brought back up.
-
-* Added "scontrol listpids" command to identify processes associated with 
-  specific jobs and/or steps.
-  
-See the file NEWS for more details.
diff --git a/aclocal.m4 b/aclocal.m4
index 595115a0c7dc799d9716d4bd825ec211bc053378..c9bd7cc5bf8ba08087c2430775bfc00f7e06173e 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.10 -*- Autoconf -*-
+# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -11,14 +11,17 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-m4_if(m4_PACKAGE_VERSION, [2.61],,
-[m4_fatal([this file was generated for autoconf 2.61.
-You have another version of autoconf.  If you want to use that,
-you should regenerate the build system entirely.], [63])])
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(AC_AUTOCONF_VERSION, [2.61],,
+[m4_warning([this file was generated for autoconf 2.61.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
 
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 
-# serial 51 Debian 1.5.24-1ubuntu1 AC_PROG_LIBTOOL
+# serial 52 Debian 1.5.26-1ubuntu1 AC_PROG_LIBTOOL
 
 
 # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
@@ -106,7 +109,6 @@ AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
 AC_REQUIRE([AC_OBJEXT])dnl
 AC_REQUIRE([AC_EXEEXT])dnl
 dnl
-
 AC_LIBTOOL_SYS_MAX_CMD_LEN
 AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
 AC_LIBTOOL_OBJDIR
@@ -208,6 +210,8 @@ file_magic*)
   ;;
 esac
 
+_LT_REQUIRED_DARWIN_CHECKS
+
 AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
 AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
 enable_win32_dll=yes, enable_win32_dll=no)
@@ -287,9 +291,80 @@ ac_outfile=conftest.$ac_objext
 echo "$lt_simple_link_test_code" >conftest.$ac_ext
 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 ])# _LT_LINKER_BOILERPLATE
 
+# _LT_REQUIRED_DARWIN_CHECKS
+# --------------------------
+# Check for some things on darwin
+AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+   [lt_cv_ld_exported_symbols_list=yes],
+   [lt_cv_ld_exported_symbols_list=no])
+   LDFLAGS="$save_LDFLAGS"
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[0123]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[[012]]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
 
 # _LT_AC_SYS_LIBPATH_AIX
 # ----------------------
@@ -614,7 +689,11 @@ sparc*-*solaris*)
     *64-bit*)
       case $lt_cv_prog_gnu_ld in
       yes*) LD="${LD-ld} -m elf64_sparc" ;;
-      *)    LD="${LD-ld} -64" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
       esac
       ;;
     esac
@@ -707,7 +786,7 @@ AC_CACHE_CHECK([$1], [$2],
        $2=yes
      fi
    fi
-   $rm conftest*
+   $rm -r conftest*
    LDFLAGS="$save_LDFLAGS"
 ])
 
@@ -978,7 +1057,7 @@ else
     AC_CHECK_FUNC([shl_load],
 	  [lt_cv_dlopen="shl_load"],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
 	[AC_CHECK_FUNC([dlopen],
 	      [lt_cv_dlopen="dlopen"],
 	  [AC_CHECK_LIB([dl], [dlopen],
@@ -986,7 +1065,7 @@ else
 	    [AC_CHECK_LIB([svld], [dlopen],
 		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
 	      ])
 	    ])
 	  ])
@@ -1303,7 +1382,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[[4-9]]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -1836,6 +1915,13 @@ esac
 AC_MSG_RESULT([$dynamic_linker])
 test "$dynamic_linker" = no && can_build_shared=no
 
+AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec],
+[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"])
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec],
+[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"])
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
 if test "$GCC" = yes; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
@@ -2335,7 +2421,7 @@ lt_cv_deplibs_check_method='unknown'
 # whether `pass_all' will *always* work, you probably want this one.
 
 case $host_os in
-aix4* | aix5*)
+aix[[4-9]]*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -2771,7 +2857,7 @@ aix3*)
   fi
   ;;
 
-aix4* | aix5*)
+aix[[4-9]]*)
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
@@ -2828,6 +2914,7 @@ _LT_AC_TAGVAR(postdep_objects, $1)=
 _LT_AC_TAGVAR(predeps, $1)=
 _LT_AC_TAGVAR(postdeps, $1)=
 _LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
 
 # Source file extension for C++ test sources.
 ac_ext=cpp
@@ -2937,7 +3024,7 @@ case $host_os in
     # FIXME: insert proper C++ library support
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
-  aix4* | aix5*)
+  aix[[4-9]]*)
     if test "$host_cpu" = ia64; then
       # On IA64, the linker does run time linking by default, so we don't
       # have to do anything special.
@@ -2950,7 +3037,7 @@ case $host_os in
       # Test if we are trying to use run time linking or normal
       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
       # need to do runtime linking.
-      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	for ld_flag in $LDFLAGS; do
 	  case $ld_flag in
 	  *-brtl*)
@@ -3096,51 +3183,23 @@ case $host_os in
     fi
   ;;
       darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
       output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
+      _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
       fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       else
       case $cc_basename in
         xlc*)
@@ -3391,7 +3450,7 @@ case $host_os in
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
+      pgCC* | pgcpp*)
         # Portland Group C++ compiler
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
   	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
@@ -3826,7 +3885,8 @@ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
 # compiler output when linking a shared library.
 # Parse the compiler output and extract the necessary
 # objects, libraries and library flags.
-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
 dnl we can't use the lt_simple_compile_test_code here,
 dnl because it contains code intended for an executable,
 dnl not a library.  It's possible we should let each
@@ -3951,6 +4011,11 @@ fi
 
 $rm -f confest.$objext
 
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+  _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
 # PORTME: override above test on systems where it is broken
 ifelse([$1],[CXX],
 [case $host_os in
@@ -4007,7 +4072,6 @@ solaris*)
   ;;
 esac
 ])
-
 case " $_LT_AC_TAGVAR(postdeps, $1) " in
 *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
 esac
@@ -4092,7 +4156,7 @@ aix3*)
     postinstall_cmds='$RANLIB $lib'
   fi
   ;;
-aix4* | aix5*)
+aix[[4-9]]*)
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
@@ -4269,6 +4333,7 @@ if test -f "$ltmain"; then
     _LT_AC_TAGVAR(predeps, $1) \
     _LT_AC_TAGVAR(postdeps, $1) \
     _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \
     _LT_AC_TAGVAR(archive_cmds, $1) \
     _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
     _LT_AC_TAGVAR(postinstall_cmds, $1) \
@@ -4331,7 +4396,7 @@ ifelse([$1], [],
 # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 # Free Software Foundation, Inc.
 #
 # This file is part of GNU Libtool:
@@ -4568,6 +4633,10 @@ predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
 # shared library.
 postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
@@ -4917,7 +4986,7 @@ EOF
     echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
     cat conftest.$ac_ext >&5
   fi
-  rm -f conftest* conftst*
+  rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
   if test "$pipe_works" = yes; then
@@ -4974,7 +5043,8 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -5011,7 +5081,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
     esac
   else
     case $host_os in
-      aix4* | aix5*)
+      aix[[4-9]]*)
 	# All AIX code is PIC.
 	if test "$host_cpu" = ia64; then
 	  # AIX 5 now supports IA64 processor
@@ -5107,7 +5177,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
 	    ;;
-	  pgCC*)
+	  pgCC* | pgcpp*)
 	    # Portland Group C++ compiler.
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
@@ -5258,7 +5328,8 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
       ;;
 
     darwin* | rhapsody*)
@@ -5328,7 +5399,8 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
     mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -5465,7 +5537,7 @@ AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
 #
 if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
   AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
-    _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1),
     [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
     [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
      "" | " "*) ;;
@@ -5489,7 +5561,7 @@ esac
 #
 wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
 AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
-  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+  _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1),
   $lt_tmp_static_flag,
   [],
   [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
@@ -5505,7 +5577,7 @@ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
 ifelse([$1],[CXX],[
   _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   case $host_os in
-  aix4* | aix5*)
+  aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
     # -C means demangle to AIX nm, but means don't demangle with GNU nm
     if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
@@ -5527,6 +5599,7 @@ ifelse([$1],[CXX],[
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   esac
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
 ],[
   runpath_var=
   _LT_AC_TAGVAR(allow_undefined_flag, $1)=
@@ -5557,12 +5630,14 @@ ifelse([$1],[CXX],[
   # it will be wrapped by ` (' and `)$', so one must not match beginning or
   # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
   # as well as any symbol that contains `d'.
-  _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
   # the symbol is explicitly referenced.  Since portable code cannot
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
   extract_expsyms_cmds=
   # Just being paranoid about ensuring that cc_basename is set.
   _LT_CC_BASENAME([$compiler])
@@ -5612,7 +5687,7 @@ ifelse([$1],[CXX],[
 
     # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
+    aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
       if test "$host_cpu" != ia64; then
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -5832,7 +5907,7 @@ _LT_EOF
       fi
       ;;
 
-    aix4* | aix5*)
+    aix[[4-9]]*)
       if test "$host_cpu" = ia64; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
@@ -5852,7 +5927,7 @@ _LT_EOF
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 	# need to do runtime linking.
-	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
   	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
   	    aix_use_runtimelinking=yes
@@ -6012,11 +6087,10 @@ _LT_EOF
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
     else
       case $cc_basename in
         xlc*)
@@ -6597,7 +6671,7 @@ AC_SUBST([SED])
 AC_MSG_RESULT([$SED])
 ])
 
-# Copyright (C) 2002, 2003, 2005, 2006  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005, 2006, 2007  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -6612,7 +6686,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
 [am__api_version='1.10'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.10], [],
+m4_if([$1], [1.10.1], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -6628,8 +6702,10 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.10])dnl
-_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)])
+[AM_AUTOMAKE_VERSION([1.10.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
@@ -6901,7 +6977,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
   # each Makefile.in and add a new line on top of each file to say so.
   # Grep'ing the whole file is not good either: AIX grep has a line
   # limit of 2048, but all sed's we know have understand at least 4000.
-  if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
+  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
     dirpart=`AS_DIRNAME("$mf")`
   else
     continue
@@ -6949,13 +7025,13 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 # Do all the work for Automake.                             -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006 Free Software Foundation, Inc.
+# 2005, 2006, 2008 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 12
+# serial 13
 
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
@@ -7060,16 +7136,17 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC],
 # our stamp files there.
 AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
 [# Compute $1's index in $config_headers.
+_am_arg=$1
 _am_stamp_count=1
 for _am_header in $config_headers :; do
   case $_am_header in
-    $1 | $1:* )
+    $_am_arg | $_am_arg:* )
       break ;;
     * )
       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
   esac
 done
-echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
 # Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
 #
@@ -7370,7 +7447,7 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
 # _AM_SUBST_NOTMAKE(VARIABLE)
 # ---------------------------
-# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in.
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
 # This macro is traced by Automake.
 AC_DEFUN([_AM_SUBST_NOTMAKE])
 
@@ -7476,6 +7553,8 @@ m4_include([auxdir/x_ac__system_configuration.m4])
 m4_include([auxdir/x_ac_affinity.m4])
 m4_include([auxdir/x_ac_aix.m4])
 m4_include([auxdir/x_ac_bluegene.m4])
+m4_include([auxdir/x_ac_cflags.m4])
+m4_include([auxdir/x_ac_databases.m4])
 m4_include([auxdir/x_ac_debug.m4])
 m4_include([auxdir/x_ac_elan.m4])
 m4_include([auxdir/x_ac_federation.m4])
diff --git a/auxdir/Makefile.am b/auxdir/Makefile.am
index 9cbc77a9816ae3ef1a998ff86a6c686fe3a9c221..c89c5c0377b1985b92d55ef2f6cd759ec93d12a3 100644
--- a/auxdir/Makefile.am
+++ b/auxdir/Makefile.am
@@ -1,5 +1,5 @@
 ##****************************************************************************
-## $Id: Makefile.am 7550 2006-03-21 00:16:26Z jette $
+## $Id: Makefile.am 14089 2008-05-20 21:17:09Z da $
 ##****************************************************************************
 ## Process this file with automake to produce Makefile.in.
 ##****************************************************************************
@@ -12,6 +12,7 @@ EXTRA_DIST = \
     x_ac_affinity.m4 \
     x_ac_aix.m4 \
     x_ac_bluegene.m4 \
+    x_ac_cflags.m4 \
     x_ac_debug.m4 \
     x_ac_elan.m4 \
     x_ac_federation.m4 \
diff --git a/auxdir/Makefile.in b/auxdir/Makefile.in
index a3675c3e47c4aa16228cce515db2423ee3d79e8b..12a7cce9093208b73042b6b008ab0ac81e243037 100644
--- a/auxdir/Makefile.in
+++ b/auxdir/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -42,6 +42,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -88,6 +90,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -101,10 +104,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -124,7 +130,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -135,6 +144,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -150,6 +161,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -165,6 +177,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -229,6 +242,7 @@ EXTRA_DIST = \
     x_ac_affinity.m4 \
     x_ac_aix.m4 \
     x_ac_bluegene.m4 \
+    x_ac_cflags.m4 \
     x_ac_debug.m4 \
     x_ac_elan.m4 \
     x_ac_federation.m4 \
diff --git a/auxdir/config.guess b/auxdir/config.guess
index 0f0fe712ae6d6e0cfa6d50da3b1812ef530de814..278f9e9e07c1d1a3bda668e6529bcce3006cfbdf 100755
--- a/auxdir/config.guess
+++ b/auxdir/config.guess
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
 #   Inc.
 
-timestamp='2007-03-06'
+timestamp='2007-07-22'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -330,7 +330,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
-    i86pc:SunOS:5.*:*)
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
 	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     sun4*:SunOS:6*:*)
@@ -793,7 +793,7 @@ EOF
 	exit ;;
     *:Interix*:[3456]*)
     	case ${UNAME_MACHINE} in
-	    x86) 
+	    x86)
 		echo i586-pc-interix${UNAME_RELEASE}
 		exit ;;
 	    EM64T | authenticamd)
diff --git a/auxdir/config.sub b/auxdir/config.sub
index 5defff65a6e4cd091921d9bcab0ab286092ec39e..1761d8bdf6307c02067b3581e183ba2fdef7e1fa 100755
--- a/auxdir/config.sub
+++ b/auxdir/config.sub
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
 #   Inc.
 
-timestamp='2007-01-18'
+timestamp='2007-06-28'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -475,8 +475,8 @@ case $basic_machine in
 		basic_machine=craynv-cray
 		os=-unicosmp
 		;;
-	cr16c)
-		basic_machine=cr16c-unknown
+	cr16)
+		basic_machine=cr16-unknown
 		os=-elf
 		;;
 	crds | unos)
@@ -683,6 +683,10 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-mingw32
 		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
diff --git a/auxdir/depcomp b/auxdir/depcomp
index ca5ea4e1ef9c125b1cb1fc7d51c93d8747637deb..e5f9736c7239301c765e2d7abefb9bb9b9237ac5 100755
--- a/auxdir/depcomp
+++ b/auxdir/depcomp
@@ -1,9 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2006-10-15.18
+scriptversion=2007-03-29.01
 
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
 # Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -215,34 +215,39 @@ aix)
   # current directory.  Also, the AIX compiler puts `$object:' at the
   # start of each line; $object doesn't have directory information.
   # Version 6 uses the directory in both cases.
-  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
-  tmpdepfile="$stripped.u"
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
   if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
     "$@" -Wc,-M
   else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
     "$@" -M
   fi
   stat=$?
 
-  if test -f "$tmpdepfile"; then :
-  else
-    stripped=`echo "$stripped" | sed 's,^.*/,,'`
-    tmpdepfile="$stripped.u"
-  fi
-
   if test $stat -eq 0; then :
   else
-    rm -f "$tmpdepfile"
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
     exit $stat
   fi
 
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
   if test -f "$tmpdepfile"; then
-    outname="$stripped.o"
     # Each line is of the form `foo.o: dependent.h'.
     # Do two passes, one to just change these to
     # `$object: dependent.h' and one to simply `dependent.h:'.
-    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
-    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
   else
     # The sourcefile does not contain any dependencies, so just
     # store a dummy comment line, to avoid errors with the Makefile
diff --git a/auxdir/install-sh b/auxdir/install-sh
index 4fbbae7b7ff932e5af542dbe9612f193a68ed4d1..a5897de6ea7f74f83fd793474bb4738d32884719 100755
--- a/auxdir/install-sh
+++ b/auxdir/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2006-10-14.15
+scriptversion=2006-12-25.00
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -48,7 +48,7 @@ IFS=" ""	$nl"
 # set DOITPROG to echo to test this script
 
 # Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
+doit=${DOITPROG-}
 if test -z "$doit"; then
   doit_exec=exec
 else
@@ -58,34 +58,49 @@ fi
 # Put in absolute file names if you don't have them in your path;
 # or use environment vars.
 
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
 
-posix_glob=
 posix_mkdir=
 
 # Desired mode of installed file.
 mode=0755
 
+chgrpcmd=
 chmodcmd=$chmodprog
 chowncmd=
-chgrpcmd=
-stripcmd=
+mvcmd=$mvprog
 rmcmd="$rmprog -f"
-mvcmd="$mvprog"
+stripcmd=
+
 src=
 dst=
 dir_arg=
-dstarg=
+dst_arg=
+
+copy_on_change=false
 no_target_directory=
 
-usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
    or: $0 [OPTION]... SRCFILES... DIRECTORY
    or: $0 [OPTION]... -t DIRECTORY SRCFILES...
    or: $0 [OPTION]... -d DIRECTORIES...
@@ -95,65 +110,55 @@ In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
 In the 4th, create DIRECTORIES.
 
 Options:
--c         (ignored)
--d         create directories instead of installing files.
--g GROUP   $chgrpprog installed files to GROUP.
--m MODE    $chmodprog installed files to MODE.
--o USER    $chownprog installed files to USER.
--s         $stripprog installed files.
--t DIRECTORY  install into DIRECTORY.
--T         report an error if DSTFILE is a directory.
---help     display this help and exit.
---version  display version info and exit.
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
 
 Environment variables override the default commands:
-  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
 "
 
 while test $# -ne 0; do
   case $1 in
-    -c) shift
-        continue;;
+    -c) ;;
+
+    -C) copy_on_change=true;;
 
-    -d) dir_arg=true
-        shift
-        continue;;
+    -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-        shift
-        shift
-        continue;;
+	shift;;
 
     --help) echo "$usage"; exit $?;;
 
     -m) mode=$2
-        shift
-        shift
 	case $mode in
 	  *' '* | *'	'* | *'
 '*	  | *'*'* | *'?'* | *'['*)
 	    echo "$0: invalid mode: $mode" >&2
 	    exit 1;;
 	esac
-        continue;;
+	shift;;
 
     -o) chowncmd="$chownprog $2"
-        shift
-        shift
-        continue;;
+	shift;;
 
-    -s) stripcmd=$stripprog
-        shift
-        continue;;
+    -s) stripcmd=$stripprog;;
 
-    -t) dstarg=$2
-	shift
-	shift
-	continue;;
+    -t) dst_arg=$2
+	shift;;
 
-    -T) no_target_directory=true
-	shift
-	continue;;
+    -T) no_target_directory=true;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
@@ -165,21 +170,22 @@ while test $# -ne 0; do
 
     *)  break;;
   esac
+  shift
 done
 
-if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   # When -d is used, all remaining arguments are directories to create.
   # When -t is used, the destination is already specified.
   # Otherwise, the last argument is the destination.  Remove it from $@.
   for arg
   do
-    if test -n "$dstarg"; then
+    if test -n "$dst_arg"; then
       # $@ is not empty: it contains at least $arg.
-      set fnord "$@" "$dstarg"
+      set fnord "$@" "$dst_arg"
       shift # fnord
     fi
     shift # arg
-    dstarg=$arg
+    dst_arg=$arg
   done
 fi
 
@@ -224,7 +230,7 @@ for src
 do
   # Protect names starting with `-'.
   case $src in
-    -*) src=./$src ;;
+    -*) src=./$src;;
   esac
 
   if test -n "$dir_arg"; then
@@ -242,22 +248,22 @@ do
       exit 1
     fi
 
-    if test -z "$dstarg"; then
+    if test -z "$dst_arg"; then
       echo "$0: no destination specified." >&2
       exit 1
     fi
 
-    dst=$dstarg
+    dst=$dst_arg
     # Protect names starting with `-'.
     case $dst in
-      -*) dst=./$dst ;;
+      -*) dst=./$dst;;
     esac
 
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
       if test -n "$no_target_directory"; then
-	echo "$0: $dstarg: Is a directory" >&2
+	echo "$0: $dst_arg: Is a directory" >&2
 	exit 1
       fi
       dstdir=$dst
@@ -378,26 +384,19 @@ do
       # directory the slow way, step by step, checking for races as we go.
 
       case $dstdir in
-	/*) prefix=/ ;;
-	-*) prefix=./ ;;
-	*)  prefix= ;;
+	/*) prefix='/';;
+	-*) prefix='./';;
+	*)  prefix='';;
       esac
 
-      case $posix_glob in
-        '')
-	  if (set -f) 2>/dev/null; then
-	    posix_glob=true
-	  else
-	    posix_glob=false
-	  fi ;;
-      esac
+      eval "$initialize_posix_glob"
 
       oIFS=$IFS
       IFS=/
-      $posix_glob && set -f
+      $posix_glob set -f
       set fnord $dstdir
       shift
-      $posix_glob && set +f
+      $posix_glob set +f
       IFS=$oIFS
 
       prefixes=
@@ -459,41 +458,54 @@ do
     # ignore errors from any of these, just make sure not to ignore
     # errors from the above "$doit $cpprog $src $dsttmp" command.
     #
-    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
-      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
-      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
-      && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
-    # Now rename the file to the real destination.
-    { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
-      || {
-	   # The rename failed, perhaps because mv can't rename something else
-	   # to itself, or perhaps because mv is so ancient that it does not
-	   # support -f.
-
-	   # Now remove or move aside any old file at destination location.
-	   # We try this two ways since rm can't unlink itself on some
-	   # systems and the destination file might be busy for other
-	   # reasons.  In this case, the final cleanup might fail but the new
-	   # file should still install successfully.
-	   {
-	     if test -f "$dst"; then
-	       $doit $rmcmd -f "$dst" 2>/dev/null \
-	       || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
-		     && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
-	       || {
-		 echo "$0: cannot unlink or rename $dst" >&2
-		 (exit 1); exit 1
-	       }
-	     else
-	       :
-	     fi
-	   } &&
-
-	   # Now rename the file to the real destination.
-	   $doit $mvcmd "$dsttmp" "$dst"
-	 }
-    } || exit 1
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
 
     trap '' 0
   fi
diff --git a/auxdir/ltmain.sh b/auxdir/ltmain.sh
index 2160ef7b98e6697002a1135c180d1886099d38cc..e420facf55f8bf28e0d73c486fbecb4a7deadf5e 100644
--- a/auxdir/ltmain.sh
+++ b/auxdir/ltmain.sh
@@ -2,7 +2,7 @@
 # NOTE: Changing this file will not affect anything until you rerun configure.
 #
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007  Free Software Foundation, Inc.
+# 2007, 2008  Free Software Foundation, Inc.
 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
 #
 # This program is free software; you can redistribute it and/or modify
@@ -43,8 +43,8 @@ EXIT_FAILURE=1
 
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION="1.5.24 Debian 1.5.24-1ubuntu1"
-TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
+VERSION="1.5.26 Debian 1.5.26-1ubuntu1"
+TIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
 
 # Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
@@ -113,15 +113,21 @@ esac
 # These must not be set unconditionally because not all systems understand
 # e.g. LANG=C (notably SCO).
 # We save the old values to restore during execute mode.
-for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+lt_env=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
   eval "if test \"\${$lt_var+set}\" = set; then
 	  save_$lt_var=\$$lt_var
+	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
 	  $lt_var=C
 	  export $lt_var
 	fi"
 done
 
+if test -n "$lt_env"; then
+  lt_env="env $lt_env"
+fi
+
 # Make sure IFS has a sensible default
 lt_nl='
 '
@@ -485,7 +491,7 @@ do
     echo "\
 $PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
 
-Copyright (C) 2007  Free Software Foundation, Inc.
+Copyright (C) 2008  Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
     exit $?
@@ -788,6 +794,7 @@ if test -z "$show_help"; then
     *.for) xform=for ;;
     *.java) xform=java ;;
     *.obj) xform=obj ;;
+    *.sx) xform=sx ;;
     esac
 
     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
@@ -956,7 +963,7 @@ EOF
       $run $rm "$lobj" "$output_obj"
 
       $show "$command"
-      if $run eval "$command"; then :
+      if $run eval $lt_env "$command"; then :
       else
 	test -n "$output_obj" && $run $rm $removelist
 	exit $EXIT_FAILURE
@@ -1028,7 +1035,7 @@ EOF
       command="$command$suppress_output"
       $run $rm "$obj" "$output_obj"
       $show "$command"
-      if $run eval "$command"; then :
+      if $run eval $lt_env "$command"; then :
       else
 	$run $rm $removelist
 	exit $EXIT_FAILURE
@@ -1161,6 +1168,7 @@ EOF
     thread_safe=no
     vinfo=
     vinfo_number=no
+    single_module="${wl}-single_module"
 
     func_infer_tag $base_compile
 
@@ -1646,6 +1654,11 @@ EOF
 	continue
 	;;
 
+      -multi_module)
+	single_module="${wl}-multi_module"
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
@@ -2152,7 +2165,12 @@ EOF
 	    continue
 	  fi
 	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
-	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
+	  if test "$linkmode" = lib; then
+	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+	  else
+	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+	  fi
+	  for searchdir in $searchdirs; do
 	    for search_ext in .la $std_shrext .so .a; do
 	      # Search the libtool library
 	      lib="$searchdir/lib${name}${search_ext}"
@@ -2948,12 +2966,18 @@ EOF
 		  # we do not want to link against static libs,
 		  # but need to link against shared
 		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
 		  if test -n "$deplibrary_names" ; then
 		    for tmp in $deplibrary_names ; do
 		      depdepl=$tmp
 		    done
-		    if test -f "$path/$depdepl" ; then
+		    if test -f "$deplibdir/$depdepl" ; then
+		      depdepl="$deplibdir/$depdepl"
+	      	    elif test -f "$path/$depdepl" ; then
 		      depdepl="$path/$depdepl"
+		    else
+		      # Can't find it, oh well...
+		      depdepl=
 		    fi
 		    # do not add paths which are already there
 		    case " $newlib_search_path " in
@@ -3101,9 +3125,10 @@ EOF
 
     case $linkmode in
     oldlib)
-      if test -n "$deplibs"; then
-	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
-      fi
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
+      esac
 
       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
 	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
@@ -4245,9 +4270,10 @@ EOF
       ;;
 
     obj)
-      if test -n "$deplibs"; then
-	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
-      fi
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
+      esac
 
       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
 	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
@@ -6486,7 +6512,7 @@ relink_command=\"$relink_command\""
       fi
 
       # Restore saved environment variables
-      for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
       do
 	eval "if test \"\${save_$lt_var+set}\" = set; then
 		$lt_var=\$save_$lt_var; export $lt_var
diff --git a/auxdir/slurm.m4 b/auxdir/slurm.m4
index 9f4cfbf62cd38aaf96a8fea40679c1630f9535c9..20060e456f8f52ecc452fb245e175a1df5a544c2 100644
--- a/auxdir/slurm.m4
+++ b/auxdir/slurm.m4
@@ -1,5 +1,5 @@
 ##*****************************************************************************
-## $Id: slurm.m4 8192 2006-05-25 00:15:05Z morrone $
+## $Id: slurm.m4 13389 2008-02-27 22:03:57Z jette $
 ##*****************************************************************************
 #  AUTHOR:
 #    Mark A. Grondona <mgrondona@llnl.gov>
@@ -13,7 +13,6 @@
 AC_DEFUN([X_AC_SLURM_PORTS],
 [
   AC_MSG_CHECKING(for slurmctld default port)
-
   AC_ARG_WITH(slurmctld-port,
     AS_HELP_STRING(--with-slurmctld-port=N,set slurmctld default port [[6817]]),
         [ if test `expr match "$withval" '[[0-9]]*$'` -gt 0; then
@@ -22,11 +21,11 @@ AC_DEFUN([X_AC_SLURM_PORTS],
         ]
   )
   AC_MSG_RESULT(${slurmctldport=$1})
-
   AC_DEFINE_UNQUOTED(SLURMCTLD_PORT, [$slurmctldport],
                      [Define the default port number for slurmctld])
   AC_SUBST(SLURMCTLD_PORT)
   
+
   AC_MSG_CHECKING(for slurmd default port)
   AC_ARG_WITH(slurmd-port,
     AS_HELP_STRING(--with-slurmd-port=N,set slurmd default port [[6818]]),
@@ -36,12 +35,23 @@ AC_DEFUN([X_AC_SLURM_PORTS],
         ]
   )
   AC_MSG_RESULT(${slurmdport=$2})
-
   AC_DEFINE_UNQUOTED(SLURMD_PORT, [$slurmdport],
                      [Define the default port number for slurmd])
-
   AC_SUBST(SLURMD_PORT)
   
+
+  AC_MSG_CHECKING(for slurmdbd default port)
+  AC_ARG_WITH(slurmdbd-port,
+    AS_HELP_STRING(--with-slurmdbd-port=N,set slurmdbd default port [[6819]]),
+        [ if test `expr match "$withval" '[[0-9]]*$'` -gt 0; then
+            slurmdbdport="$withval"
+          fi
+        ]
+  )
+  AC_MSG_RESULT(${slurmdbdport=$3})
+  AC_DEFINE_UNQUOTED(SLURMDBD_PORT, [$slurmdbdport],
+                     [Define the default port number for slurmdbd])
+  AC_SUBST(SLURMDBD_PORT)
 ])
 dnl
 dnl Check for program_invocation_name
diff --git a/auxdir/x_ac_aix.m4 b/auxdir/x_ac_aix.m4
index 026932d93685b71789bd6494881b2e38ee0ad5ea..9aa4c892f929609cdaa98c9335541f91d229a7d3 100644
--- a/auxdir/x_ac_aix.m4
+++ b/auxdir/x_ac_aix.m4
@@ -1,5 +1,5 @@
 ##*****************************************************************************
-## $Id: x_ac_aix.m4 11723 2007-06-15 22:15:14Z morrone $
+## $Id: x_ac_aix.m4 11741 2007-06-20 18:42:19Z da $
 ##*****************************************************************************
 #  AUTHOR:
 #    Morris Jette <jette@llnl.gov>
diff --git a/auxdir/x_ac_bluegene.m4 b/auxdir/x_ac_bluegene.m4
index dd995545fa5e9b898425612176b946a456f1a024..24d743be3f5dc27ad2d518bd567031565cd1d931 100644
--- a/auxdir/x_ac_bluegene.m4
+++ b/auxdir/x_ac_bluegene.m4
@@ -1,5 +1,5 @@
 ##*****************************************************************************
-## $Id: x_ac_bluegene.m4 8863 2006-08-10 18:47:55Z da $
+## $Id: x_ac_bluegene.m4 14087 2008-05-20 19:35:45Z da $
 ##*****************************************************************************
 #  AUTHOR:
 #    Morris Jette <jette1@llnl.gov>
@@ -45,14 +45,14 @@ AC_DEFUN([X_AC_BLUEGENE],
          		have_bg_ar=yes
 			bg_bridge_so="$bg_dir/lib64/libbglbridge.so"
        	 		bg_ldflags="$bg_ldflags -L$bg_dir/lib64 -L/usr/lib64 -Wl,--unresolved-symbols=ignore-in-shared-libs -lbglbridge -lbgldb -ltableapi -lbglmachine -lexpat -lsaymessage"
-      		fi
+        	fi
       
       		# Search for required DB2 library in the directory
       		if test -z "$have_db2" -a -f "$bg_dir/lib64/libdb2.so" ; then
          		have_db2=yes
 	 	 	bg_db2_so="$bg_dir/lib64/libdb2.so"
        	 		bg_ldflags="$bg_ldflags -L$bg_dir/lib64 -ldb2"
-      		fi
+       		fi
 
       		# Search for headers in the directory
       		if test -z "$have_bg_hdr" -a -f "$bg_dir/include/rm_api.h" ; then
@@ -75,7 +75,7 @@ AC_DEFUN([X_AC_BLUEGENE],
 
   	if test ! -z "$have_bg_files" ; then
       		BG_INCLUDES="$bg_includes"
-      		AC_DEFINE(HAVE_BG_FILES, 1, [Define to 1 if have Blue Gene files])
+		AC_DEFINE(HAVE_BG_FILES, 1, [Define to 1 if have Blue Gene files])
 
       		AC_DEFINE_UNQUOTED(BG_BRIDGE_SO, "$bg_bridge_so", [Define the BG_BRIDGE_SO value])
 		AC_DEFINE_UNQUOTED(BG_DB2_SO, "$bg_db2_so", [Define the BG_DB2_SO value])
diff --git a/auxdir/x_ac_databases.m4 b/auxdir/x_ac_databases.m4
new file mode 100644
index 0000000000000000000000000000000000000000..056eb840a33562a238c359cd52d0cec5fb6c4c61
--- /dev/null
+++ b/auxdir/x_ac_databases.m4
@@ -0,0 +1,111 @@
+##*****************************************************************************
+## $Id: x_ac_databases.m4 5401 2005-09-22 01:56:49Z da $
+##*****************************************************************************
+#  AUTHOR:
+#    Danny Auble  <da@llnl.gov>
+#
+#  SYNOPSIS:
+#    X_AC_DATABASES
+#
+#  DESCRIPTION:
+#    Test for Different Database apis. If found define appropriate ENVs. 
+##*****************************************************************************
+
+AC_DEFUN([X_AC_DATABASES],
+[
+	#Check for MySQL
+	ac_have_mysql="no"
+	### Check for mysql_config program
+    	AC_PATH_PROG(HAVEMYSQLCONFIG, mysql_config, no)
+	if test x$HAVEMYSQLCONFIG = xno; then
+        	AC_MSG_WARN([*** mysql_config not found. Evidently no MySQL install on system.])
+	else
+		# check for mysql-5.0.0+
+		mysql_config_major_version=`$HAVEMYSQLCONFIG --version | \
+			sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[a-zA-Z0-9]]*\)/\1/'`
+    		mysql_config_minor_version=`$HAVEMYSQLCONFIG --version | \
+			sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[a-zA-Z0-9]]*\)/\2/'`
+    		mysql_config_micro_version=`$HAVEMYSQLCONFIG --version | \
+			sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[a-zA-Z0-9]]*\)/\3/'`
+
+		if test $mysql_config_major_version -lt 5; then
+	   		AC_MSG_WARN([*** mysql-$mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version available, we need >= mysql-5.0.0 installed for the mysql interface.])
+            		ac_have_mysql="no"
+		else 
+		# mysql_config puts -I on the front of the dir.  We don't 
+		# want that so we remove it.
+			MYSQL_CFLAGS=`$HAVEMYSQLCONFIG --cflags`
+			MYSQL_LIBS=`$HAVEMYSQLCONFIG --libs_r`
+			if test -z "$MYSQL_LIBS"; then
+				MYSQL_LIBS=`$HAVEMYSQLCONFIG --libs`
+			fi
+			save_CFLAGS="$CFLAGS"
+			save_LIBS="$LIBS"
+       			CFLAGS="$MYSQL_CFLAGS $save_CFLAGS"
+			LIBS="$MYSQL_LIBS $save_LIBS"
+			AC_TRY_LINK([#include <mysql.h>],[
+          				int main()
+          				{
+						MYSQL mysql;
+            					(void) mysql_init(&mysql);
+						(void) mysql_close(&mysql);
+            				}
+        				],
+				[ac_have_mysql="yes"],
+				[ac_have_mysql="no"])
+			CFLAGS="$save_CFLAGS"
+			LIBS="$save_LIBS"
+       			if test "$ac_have_mysql" == "yes"; then
+            			AC_MSG_RESULT([MySQL test program built properly.])
+            			AC_SUBST(MYSQL_LIBS)
+				AC_SUBST(MYSQL_CFLAGS)
+				AC_DEFINE(HAVE_MYSQL, 1, [Define to 1 if using MySQL libaries])
+			else
+ 				MYSQL_CFLAGS=""
+				MYSQL_LIBS=""
+       				AC_MSG_WARN([*** MySQL test program execution failed.])
+			fi        	
+		fi
+      	fi
+
+
+	#Check for PostgreSQL
+	ac_have_postgres="no"
+	### Check for pg_config program
+    	AC_PATH_PROG(HAVEPGCONFIG, pg_config, no)
+	if test x$HAVEPGCONFIG = xno; then
+        	AC_MSG_WARN([*** pg_config not found. Evidently no PostgreSQL install on system.])
+	else
+		PGSQL_INCLUDEDIR=`$HAVEPGCONFIG --includedir`
+		PGSQL_LIBDIR=`$HAVEPGCONFIG --libdir`
+		PGSQL_CFLAGS="-I$PGSQL_INCLUDEDIR -L$PGSQL_LIBDIR" 
+		save_CFLAGS="$CFLAGS"
+        	CFLAGS="$PGSQL_CFLAGS $save_CFLAGS"
+                
+		PGSQL_LIBS=" -lpq"
+	       	save_LIBS="$LIBS"
+        	LIBS="$PGSQL_LIBS $save_LIBS"
+       		AC_TRY_LINK([#include <libpq-fe.h>],[
+          			int main()
+       	  			{
+					PGconn     *conn;
+					conn = PQconnectdb("dbname = postgres");
+       					(void) PQfinish(conn);
+            			}
+        			],
+			[ac_have_pgsql="yes"],
+			[ac_have_pgsql="no"])
+		LIBS="$save_LIBS"
+       		CFLAGS="$save_CFLAGS"
+		if test "$ac_have_pgsql" == "yes"; then
+    			AC_MSG_RESULT([PostgreSQL test program built properly.])
+            		AC_SUBST(PGSQL_LIBS)
+			AC_SUBST(PGSQL_CFLAGS)
+			AC_DEFINE(HAVE_PGSQL, 1, [Define to 1 if using PostgreSQL libaries])
+		else	
+			PGSQL_CFLAGS=""
+			PGSQL_LIBS=""
+       			AC_MSG_WARN([*** PostgreSQL test program execution failed.])
+		fi        	
+      	fi
+])
diff --git a/auxdir/x_ac_gtk.m4 b/auxdir/x_ac_gtk.m4
index 827d28a13c2d3ff0a9cefd9e4fba9fc5a2a87b2e..cdd4d779885ecf03a7f8e1e473a3411e20b596cd 100644
--- a/auxdir/x_ac_gtk.m4
+++ b/auxdir/x_ac_gtk.m4
@@ -18,8 +18,8 @@ AC_DEFUN([X_AC_GTK],
     ac_have_gtk="yes"
 
 ### Check for pkg-config program
-    AC_PATH_PROG(HAVEPKGCONFIG, pkg-config, $PATH)
-    if test -z "$HAVEPKGCONFIG"; then
+    AC_PATH_PROG(HAVEPKGCONFIG, pkg-config, no)
+    if test x$HAVEPKGCONFIG = xno; then
         AC_MSG_WARN([*** pkg-config not found. Cannot probe for libglade-2.0 or gtk+-2.0.])
         ac_have_gtk="no"
     fi
diff --git a/auxdir/x_ac_slurm_ssl.m4 b/auxdir/x_ac_slurm_ssl.m4
index 9a8fe3b12b7ff069f1c5ce37cb81cbcb5f13d643..7f3baaeabe99145380630541b0deab0392e2d391 100644
--- a/auxdir/x_ac_slurm_ssl.m4
+++ b/auxdir/x_ac_slurm_ssl.m4
@@ -1,5 +1,5 @@
 ##*****************************************************************************
-## $Id: x_ac_slurm_ssl.m4 12827 2007-12-14 22:29:30Z da $
+## $Id: x_ac_slurm_ssl.m4 13975 2008-05-02 23:48:39Z da $
 ##*****************************************************************************
 #  AUTHOR:
 #     Mark Grondona <mgrondona@llnl.gov>
@@ -15,16 +15,15 @@
 
 AC_DEFUN([X_AC_SLURM_WITH_SSL], [
 
-  ac_slurm_with_ssl=no
   ssl_default_dirs="/usr/local/openssl64 /usr/local/openssl /usr/lib/openssl    \
                     /usr/local/ssl /usr/lib/ssl /usr/local \
-                    /usr/pkg /opt /opt/openssl"
+                    /usr/pkg /opt /opt/openssl /usr"
   
   AC_SUBST(SSL_LDFLAGS)
   AC_SUBST(SSL_LIBS)
   AC_SUBST(SSL_CPPFLAGS)
   
-  SSL_LIBS="-lcrypto"
+  SSL_LIB_TEST="-lcrypto"
   
   AC_ARG_WITH(ssl,
     AS_HELP_STRING(--with-ssl=PATH,Specify path to OpenSSL installation),
@@ -36,7 +35,7 @@ AC_DEFUN([X_AC_SLURM_WITH_SSL], [
   	# which is specified with --with-ssl), and libtool is not setting
   	# the correct runtime library path in the binaries.
   	if test "x$ac_have_aix" = "xyes"; then
-  		SSL_LIBS="-lcrypto-static"
+  		SSL_LIB_TEST="-lcrypto-static"
   	fi
     ])
   
@@ -46,21 +45,20 @@ AC_DEFUN([X_AC_SLURM_WITH_SSL], [
   if test "x$prefix" != "xNONE" ; then
   	tryssldir="$tryssldir $prefix"
   fi
-  if test "x$tryssldir" == "xno" ; then
-     AC_MSG_ERROR([OpenSSL libary is required for SLURM operation, download from www.openssl.org])
-  fi
-  
-  AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
+
+  if test "x$tryssldir" != "xno" ; then
+    AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
   	for ssldir in $tryssldir "" $ssl_default_dirs; do 
   		CPPFLAGS="$saved_CPPFLAGS"
   		LDFLAGS="$saved_LDFLAGS"
-  		LIBS="$saved_LIBS $SSL_LIBS"
+  		LIBS="$saved_LIBS $SSL_LIB_TEST"
   		
   		# Skip directories if they don't exist
   		if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
   			continue;
   		fi
-  		if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
+  		sslincludedir="$ssldir"
+  		if test ! -z "$ssldir"; then
   			# Try to use $ssldir/lib if it exists, otherwise 
   			# $ssldir
   			if test -d "$ssldir/lib" ; then
@@ -77,12 +75,16 @@ AC_DEFUN([X_AC_SLURM_WITH_SSL], [
   			# Try to use $ssldir/include if it exists, otherwise 
   			# $ssldir
   			if test -d "$ssldir/include" ; then
+				sslincludedir="$ssldir/include"
   				CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
   			else
   				CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
   			fi
   		fi
-  
+		test -f "$sslincludedir/openssl/rand.h" || continue
+		test -f "$sslincludedir/openssl/hmac.h" || continue
+		test -f "$sslincludedir/openssl/sha.h" || continue
+
   		# Basic test to check for compatible version and correct linking
   		AC_RUN_IFELSE([AC_LANG_SOURCE([[
   #include <stdlib.h>
@@ -99,27 +101,26 @@ AC_DEFUN([X_AC_SLURM_WITH_SSL], [
   	return(RAND_status() <= 0);
   }
   			]])],[
-  				found_crypto=1
+  				ac_have_openssl="yes"
   				break;
   			],[
   		],[])
   
-  		if test ! -z "$found_crypto" ; then
+  		if test ! -z "$ac_have_openssl" ; then
   			break;
   		fi
   	done
   
-  	if test -z "$found_crypto" ; then
-  		AC_MSG_ERROR([Could not find working OpenSSL library, download from www.openssl.org])
-  	fi
-  	if test -z "$ssldir" ; then
-  		ssldir="(system)"
-  	fi
-  
-  	ac_cv_openssldir=$ssldir
-  ])
-  
-  if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; then
+	if test ! -z "$ac_have_openssl" ; then
+		ac_cv_openssldir=$ssldir
+	fi
+    ])
+  fi
+
+  if test ! -z "$ac_have_openssl" ; then
+    SSL_LIBS="$SSL_LIB_TEST"
+    AC_DEFINE(HAVE_OPENSSL, 1, [define if you have openssl.])
+    if (test ! -z "$ac_cv_openssldir") ; then
   	dnl Need to recover ssldir - test above runs in subshell
   	ssldir=$ac_cv_openssldir
   	if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
@@ -138,10 +139,14 @@ AC_DEFUN([X_AC_SLURM_WITH_SSL], [
   			SSL_CPPFLAGS="-I$ssldir"
   		fi
   	fi
-  fi
+    fi
   
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/evp.h>]], [[EVP_MD_CTX_cleanup(NULL);]])],[AC_DEFINE(HAVE_EVP_MD_CTX_CLEANUP, 1,
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/evp.h>]], [[EVP_MD_CTX_cleanup(NULL);]])],[AC_DEFINE(HAVE_EVP_MD_CTX_CLEANUP, 1,
                [Define to 1 if function EVP_MD_CTX_cleanup exists.])],[])
+  else
+    SSL_LIBS=""
+    AC_MSG_WARN([Could not find working OpenSSL library])
+  fi
   
   LIBS="$saved_LIBS"
   CPPFLAGS="$saved_CPPFLAGS"
diff --git a/config.h.in b/config.h.in
index a9bb420bc0ba4ba2966f11068789ed3d33271b53..a132636995950c59a6c1610e0f02d6c7dbd872d0 100644
--- a/config.h.in
+++ b/config.h.in
@@ -98,6 +98,9 @@
 /* Define to 1 if you have the `mtrace' function. */
 #undef HAVE_MTRACE
 
+/* Define to 1 if using MySQL libaries */
+#undef HAVE_MYSQL
+
 /* Define to 1 if you have the <ncurses.h> header file. */
 #undef HAVE_NCURSES_H
 
@@ -107,12 +110,18 @@
 /* define if numa library installed */
 #undef HAVE_NUMA
 
+/* define if you have openssl. */
+#undef HAVE_OPENSSL
+
 /* define if you have the PAM library */
 #undef HAVE_PAM
 
 /* Define to 1 if you have the <pam/pam_appl.h> header file. */
 #undef HAVE_PAM_PAM_APPL_H
 
+/* Define to 1 if using PostgreSQL libaries */
+#undef HAVE_PGSQL
+
 /* define if plpa library installed */
 #undef HAVE_PLPA
 
@@ -134,6 +143,9 @@
 /* Define to 1 if you have the `ptrace64' function. */
 #undef HAVE_PTRACE64
 
+/* Define to 1 if you have the <pty.h> header file. */
+#undef HAVE_PTY_H
+
 /* Define if you are compiling with readline. */
 #undef HAVE_READLINE
 
@@ -233,6 +245,9 @@
 /* Define to 1 if you have the `unsetenv' function. */
 #undef HAVE_UNSETENV
 
+/* Define to 1 if you have the <utmp.h> header file. */
+#undef HAVE_UTMP_H
+
 /* Define to 1 if you have the <values.h> header file. */
 #undef HAVE_VALUES_H
 
@@ -310,6 +325,9 @@
 /* Define the default port number for slurmctld */
 #undef SLURMCTLD_PORT
 
+/* Define the default port number for slurmdbd */
+#undef SLURMDBD_PORT
+
 /* Define the default port number for slurmd */
 #undef SLURMD_PORT
 
diff --git a/configure b/configure
index f2a95f05732f70bdee8560158c7389866f8c063b..e0ef76114189c9580c0afc18dbbb56f3558a5ba7 100755
--- a/configure
+++ b/configure
@@ -891,6 +891,8 @@ LN_S
 ECHO
 AR
 RANLIB
+DSYMUTIL
+NMEDIT
 CXXCPP
 F77
 FFLAGS
@@ -925,10 +927,17 @@ GTK2_CFLAGS
 GTK2_LIBS
 HAVE_GTK_TRUE
 HAVE_GTK_FALSE
+HAVEMYSQLCONFIG
+MYSQL_LIBS
+MYSQL_CFLAGS
+HAVEPGCONFIG
+PGSQL_LIBS
+PGSQL_CFLAGS
 DEBUG_MODULES_TRUE
 DEBUG_MODULES_FALSE
 SLURMCTLD_PORT
 SLURMD_PORT
+SLURMDBD_PORT
 ELAN_LIBS
 HAVE_ELAN_TRUE
 HAVE_ELAN_FALSE
@@ -943,6 +952,9 @@ READLINE_LIBS
 SSL_LDFLAGS
 SSL_LIBS
 SSL_CPPFLAGS
+HAVE_OPENSSL_TRUE
+HAVE_OPENSSL_FALSE
+HAVE_OPENSSL
 MUNGE_LIBS
 MUNGE_CPPFLAGS
 MUNGE_LDFLAGS
@@ -952,6 +964,7 @@ AUTHD_LIBS
 AUTHD_CFLAGS
 WITH_AUTHD_TRUE
 WITH_AUTHD_FALSE
+UTIL_LIBS
 LTLIBOBJS'
 ac_subst_files=''
       ac_precious_vars='build_alias
@@ -1583,6 +1596,7 @@ Optional Packages:
   --with-xcpu=PATH        specify path to XCPU directory
   --with-slurmctld-port=N set slurmctld default port 6817
   --with-slurmd-port=N    set slurmd default port 6818
+  --with-slurmdbd-port=N  set slurmdbd default port 6819
   --without-readline      compile without readline support
   --with-ssl=PATH         Specify path to OpenSSL installation
   --with-munge=PATH       Specify path to munge installation
@@ -6886,7 +6900,7 @@ lt_cv_deplibs_check_method='unknown'
 # whether `pass_all' will *always* work, you probably want this one.
 
 case $host_os in
-aix4* | aix5*)
+aix[4-9]*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -7101,7 +7115,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 7104 "configure"' > conftest.$ac_ext
+  echo '#line 7118 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7273,7 +7287,11 @@ sparc*-*solaris*)
     *64-bit*)
       case $lt_cv_prog_gnu_ld in
       yes*) LD="${LD-ld} -m elf64_sparc" ;;
-      *)    LD="${LD-ld} -64" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
       esac
       ;;
     esac
@@ -7924,7 +7942,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 # Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-
 # find the maximum length of command line arguments
 { echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
 echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6; }
@@ -8239,7 +8256,7 @@ EOF
     echo "$progname: failed program was:" >&5
     cat conftest.$ac_ext >&5
   fi
-  rm -f conftest* conftst*
+  rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
   if test "$pipe_works" = yes; then
@@ -8799,6 +8816,318 @@ fi
   ;;
 esac
 
+
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_DSYMUTIL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { echo "$as_me:$LINENO: result: $DSYMUTIL" >&5
+echo "${ECHO_T}$DSYMUTIL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5
+echo "${ECHO_T}$ac_ct_DSYMUTIL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_NMEDIT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { echo "$as_me:$LINENO: result: $NMEDIT" >&5
+echo "${ECHO_T}$NMEDIT" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5
+echo "${ECHO_T}$ac_ct_NMEDIT" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+
+    { echo "$as_me:$LINENO: checking for -single_module linker flag" >&5
+echo $ECHO_N "checking for -single_module linker flag... $ECHO_C" >&6; }
+if test "${lt_cv_apple_cc_single_mod+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5
+echo "${ECHO_T}$lt_cv_apple_cc_single_mod" >&6; }
+    { echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5
+echo $ECHO_N "checking for -exported_symbols_list linker flag... $ECHO_C" >&6; }
+if test "${lt_cv_ld_exported_symbols_list+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  lt_cv_ld_exported_symbols_list=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	lt_cv_ld_exported_symbols_list=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5
+echo "${ECHO_T}$lt_cv_ld_exported_symbols_list" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[0123])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[012]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+
 enable_dlopen=no
 enable_win32_dll=no
 
@@ -8864,7 +9193,7 @@ ac_outfile=conftest.$ac_objext
 echo "$lt_simple_link_test_code" >conftest.$ac_ext
 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 
 
 
@@ -8892,11 +9221,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8895: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9224: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8899: \$? = $ac_status" >&5
+   echo "$as_me:9228: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9166,10 +9495,10 @@ if test -n "$lt_prog_compiler_pic"; then
 
 { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_pic_works+set}" = set; then
+if test "${lt_cv_prog_compiler_pic_works+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_pic_works=no
+  lt_cv_prog_compiler_pic_works=no
   ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
@@ -9182,27 +9511,27 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9185: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9514: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:9189: \$? = $ac_status" >&5
+   echo "$as_me:9518: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
      $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
      $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
      if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works=yes
+       lt_cv_prog_compiler_pic_works=yes
      fi
    fi
    $rm conftest*
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works" >&6; }
 
-if test x"$lt_prog_compiler_pic_works" = xyes; then
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
     case $lt_prog_compiler_pic in
      "" | " "*) ;;
      *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
@@ -9229,10 +9558,10 @@ esac
 wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
 { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_static_works+set}" = set; then
+if test "${lt_cv_prog_compiler_static_works+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_static_works=no
+  lt_cv_prog_compiler_static_works=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
@@ -9245,20 +9574,20 @@ else
        $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
        $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
        if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works=yes
+         lt_cv_prog_compiler_static_works=yes
        fi
      else
-       lt_prog_compiler_static_works=yes
+       lt_cv_prog_compiler_static_works=yes
      fi
    fi
-   $rm conftest*
+   $rm -r conftest*
    LDFLAGS="$save_LDFLAGS"
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works" >&6; }
 
-if test x"$lt_prog_compiler_static_works" = xyes; then
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
     :
 else
     lt_prog_compiler_static=
@@ -9286,11 +9615,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9289: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9618: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:9293: \$? = $ac_status" >&5
+   echo "$as_me:9622: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -9370,12 +9699,13 @@ echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared librar
   # it will be wrapped by ` (' and `)$', so one must not match beginning or
   # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
   # as well as any symbol that contains `d'.
-  exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
   # the symbol is explicitly referenced.  Since portable code cannot
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
   extract_expsyms_cmds=
   # Just being paranoid about ensuring that cc_basename is set.
   for cc_temp in $compiler""; do
@@ -9434,7 +9764,7 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
     # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
+    aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
       if test "$host_cpu" != ia64; then
 	ld_shlibs=no
@@ -9654,7 +9984,7 @@ _LT_EOF
       fi
       ;;
 
-    aix4* | aix5*)
+    aix[4-9]*)
       if test "$host_cpu" = ia64; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
@@ -9674,7 +10004,7 @@ _LT_EOF
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
   	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
   	    aix_use_runtimelinking=yes
@@ -9946,11 +10276,10 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       link_all_deplibs=yes
     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
-        archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
     else
       case $cc_basename in
         xlc*)
@@ -10470,7 +10799,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -11004,6 +11333,21 @@ esac
 echo "${ECHO_T}$dynamic_linker" >&6; }
 test "$dynamic_linker" = no && can_build_shared=no
 
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
 if test "$GCC" = yes; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
@@ -11323,7 +11667,7 @@ fi
 { echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6; }
 if test $ac_cv_lib_dld_shl_load = yes; then
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
 else
   { echo "$as_me:$LINENO: checking for dlopen" >&5
 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; }
@@ -11599,7 +11943,7 @@ fi
 { echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6; }
 if test $ac_cv_lib_dld_dld_link = yes; then
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
 fi
 
 
@@ -11648,7 +11992,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 11651 "configure"
+#line 11995 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11748,7 +12092,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 11751 "configure"
+#line 12095 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11875,7 +12219,7 @@ aix3*)
   fi
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
@@ -11931,6 +12275,7 @@ if test -f "$ltmain"; then
     predeps \
     postdeps \
     compiler_lib_search_path \
+    compiler_lib_search_dirs \
     archive_cmds \
     archive_expsym_cmds \
     postinstall_cmds \
@@ -11991,7 +12336,7 @@ echo "$as_me: creating $ofile" >&6;}
 # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 # Free Software Foundation, Inc.
 #
 # This file is part of GNU Libtool:
@@ -12227,6 +12572,10 @@ predeps=$lt_predeps
 # shared library.
 postdeps=$lt_postdeps
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_compiler_lib_search_path
@@ -12475,6 +12824,7 @@ postdep_objects_CXX=
 predeps_CXX=
 postdeps_CXX=
 compiler_lib_search_path_CXX=
+compiler_lib_search_dirs_CXX=
 
 # Source file extension for C++ test sources.
 ac_ext=cpp
@@ -12512,7 +12862,7 @@ ac_outfile=conftest.$ac_objext
 echo "$lt_simple_link_test_code" >conftest.$ac_ext
 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 
 
 # Allow CC to be a program name with arguments.
@@ -12719,7 +13069,7 @@ case $host_os in
     # FIXME: insert proper C++ library support
     ld_shlibs_CXX=no
     ;;
-  aix4* | aix5*)
+  aix[4-9]*)
     if test "$host_cpu" = ia64; then
       # On IA64, the linker does run time linking by default, so we don't
       # have to do anything special.
@@ -12732,7 +13082,7 @@ case $host_os in
       # Test if we are trying to use run time linking or normal
       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
       # need to do runtime linking.
-      case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+      case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	for ld_flag in $LDFLAGS; do
 	  case $ld_flag in
 	  *-brtl*)
@@ -12990,51 +13340,23 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
     fi
   ;;
       darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
       archive_cmds_need_lc_CXX=no
       hardcode_direct_CXX=no
       hardcode_automatic_CXX=yes
       hardcode_shlibpath_var_CXX=unsupported
       whole_archive_flag_spec_CXX=''
       link_all_deplibs_CXX=yes
-
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
+      allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
       output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
       fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       else
       case $cc_basename in
         xlc*)
@@ -13285,7 +13607,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 	whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
+      pgCC* | pgcpp*)
         # Portland Group C++ compiler
 	archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
   	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
@@ -13692,7 +14014,6 @@ test "$ld_shlibs_CXX" = no && can_build_shared=no
 GCC_CXX="$GXX"
 LD_CXX="$LD"
 
-
 cat > conftest.$ac_ext <<EOF
 class Foo
 {
@@ -13794,6 +14115,11 @@ fi
 
 $rm -f confest.$objext
 
+compiler_lib_search_dirs_CXX=
+if test -n "$compiler_lib_search_path_CXX"; then
+  compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
 # PORTME: override above test on systems where it is broken
 case $host_os in
 interix[3-9]*)
@@ -13849,7 +14175,6 @@ solaris*)
   ;;
 esac
 
-
 case " $postdeps_CXX " in
 *" -lc "*) archive_cmds_need_lc_CXX=no ;;
 esac
@@ -13925,7 +14250,7 @@ echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
     esac
   else
     case $host_os in
-      aix4* | aix5*)
+      aix[4-9]*)
 	# All AIX code is PIC.
 	if test "$host_cpu" = ia64; then
 	  # AIX 5 now supports IA64 processor
@@ -14021,7 +14346,7 @@ echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
 	    ;;
-	  pgCC*)
+	  pgCC* | pgcpp*)
 	    # Portland Group C++ compiler.
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-fpic'
@@ -14152,10 +14477,10 @@ if test -n "$lt_prog_compiler_pic_CXX"; then
 
 { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then
+if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_pic_works_CXX=no
+  lt_cv_prog_compiler_pic_works_CXX=no
   ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
@@ -14168,27 +14493,27 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14171: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14496: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:14175: \$? = $ac_status" >&5
+   echo "$as_me:14500: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
      $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
      $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
      if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_CXX=yes
+       lt_cv_prog_compiler_pic_works_CXX=yes
      fi
    fi
    $rm conftest*
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_CXX" >&6; }
 
-if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
     case $lt_prog_compiler_pic_CXX in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
@@ -14215,10 +14540,10 @@ esac
 wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
 { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_static_works_CXX+set}" = set; then
+if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_static_works_CXX=no
+  lt_cv_prog_compiler_static_works_CXX=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
@@ -14231,20 +14556,20 @@ else
        $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
        $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
        if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_CXX=yes
+         lt_cv_prog_compiler_static_works_CXX=yes
        fi
      else
-       lt_prog_compiler_static_works_CXX=yes
+       lt_cv_prog_compiler_static_works_CXX=yes
      fi
    fi
-   $rm conftest*
+   $rm -r conftest*
    LDFLAGS="$save_LDFLAGS"
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works_CXX" >&6; }
 
-if test x"$lt_prog_compiler_static_works_CXX" = xyes; then
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
     :
 else
     lt_prog_compiler_static_CXX=
@@ -14272,11 +14597,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14275: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14600: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14279: \$? = $ac_status" >&5
+   echo "$as_me:14604: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -14329,7 +14654,7 @@ echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared librar
 
   export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   case $host_os in
-  aix4* | aix5*)
+  aix[4-9]*)
     # If we're using GNU nm, then we don't want the "-C" option.
     # -C means demangle to AIX nm, but means don't demangle with GNU nm
     if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
@@ -14351,6 +14676,7 @@ echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared librar
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   esac
+  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
 
 { echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
 echo "${ECHO_T}$ld_shlibs_CXX" >&6; }
@@ -14452,7 +14778,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -14985,6 +15311,21 @@ esac
 echo "${ECHO_T}$dynamic_linker" >&6; }
 test "$dynamic_linker" = no && can_build_shared=no
 
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
 if test "$GCC" = yes; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
@@ -15068,6 +15409,7 @@ if test -f "$ltmain"; then
     predeps_CXX \
     postdeps_CXX \
     compiler_lib_search_path_CXX \
+    compiler_lib_search_dirs_CXX \
     archive_cmds_CXX \
     archive_expsym_cmds_CXX \
     postinstall_cmds_CXX \
@@ -15316,6 +15658,10 @@ predeps=$lt_predeps_CXX
 # shared library.
 postdeps=$lt_postdeps_CXX
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
@@ -15530,7 +15876,7 @@ ac_outfile=conftest.$ac_objext
 echo "$lt_simple_link_test_code" >conftest.$ac_ext
 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 
 
 # Allow CC to be a program name with arguments.
@@ -15568,7 +15914,7 @@ aix3*)
     postinstall_cmds='$RANLIB $lib'
   fi
   ;;
-aix4* | aix5*)
+aix[4-9]*)
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
@@ -15833,10 +16179,10 @@ if test -n "$lt_prog_compiler_pic_F77"; then
 
 { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
+if test "${lt_cv_prog_compiler_pic_works_F77+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_pic_works_F77=no
+  lt_cv_prog_compiler_pic_works_F77=no
   ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$lt_prog_compiler_pic_F77"
@@ -15849,27 +16195,27 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15852: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16198: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15856: \$? = $ac_status" >&5
+   echo "$as_me:16202: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
      $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
      $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
      if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_F77=yes
+       lt_cv_prog_compiler_pic_works_F77=yes
      fi
    fi
    $rm conftest*
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_F77" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_F77" >&6; }
 
-if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
+if test x"$lt_cv_prog_compiler_pic_works_F77" = xyes; then
     case $lt_prog_compiler_pic_F77 in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
@@ -15896,10 +16242,10 @@ esac
 wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
 { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_static_works_F77+set}" = set; then
+if test "${lt_cv_prog_compiler_static_works_F77+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_static_works_F77=no
+  lt_cv_prog_compiler_static_works_F77=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
@@ -15912,20 +16258,20 @@ else
        $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
        $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
        if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_F77=yes
+         lt_cv_prog_compiler_static_works_F77=yes
        fi
      else
-       lt_prog_compiler_static_works_F77=yes
+       lt_cv_prog_compiler_static_works_F77=yes
      fi
    fi
-   $rm conftest*
+   $rm -r conftest*
    LDFLAGS="$save_LDFLAGS"
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_F77" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works_F77" >&6; }
 
-if test x"$lt_prog_compiler_static_works_F77" = xyes; then
+if test x"$lt_cv_prog_compiler_static_works_F77" = xyes; then
     :
 else
     lt_prog_compiler_static_F77=
@@ -15953,11 +16299,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15956: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16302: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:15960: \$? = $ac_status" >&5
+   echo "$as_me:16306: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -16037,12 +16383,13 @@ echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared librar
   # it will be wrapped by ` (' and `)$', so one must not match beginning or
   # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
   # as well as any symbol that contains `d'.
-  exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
+  exclude_expsyms_F77='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
   # the symbol is explicitly referenced.  Since portable code cannot
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
   extract_expsyms_cmds=
   # Just being paranoid about ensuring that cc_basename is set.
   for cc_temp in $compiler""; do
@@ -16101,7 +16448,7 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
     # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
+    aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
       if test "$host_cpu" != ia64; then
 	ld_shlibs_F77=no
@@ -16321,7 +16668,7 @@ _LT_EOF
       fi
       ;;
 
-    aix4* | aix5*)
+    aix[4-9]*)
       if test "$host_cpu" = ia64; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
@@ -16341,7 +16688,7 @@ _LT_EOF
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
   	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
   	    aix_use_runtimelinking=yes
@@ -16593,11 +16940,10 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       link_all_deplibs_F77=yes
     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
-        archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        archive_cmds_F77="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        module_cmds_F77="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        archive_expsym_cmds_F77="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        module_expsym_cmds_F77="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
     else
       case $cc_basename in
         xlc*)
@@ -17066,7 +17412,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -17599,6 +17945,21 @@ esac
 echo "${ECHO_T}$dynamic_linker" >&6; }
 test "$dynamic_linker" = no && can_build_shared=no
 
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
 if test "$GCC" = yes; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
@@ -17682,6 +18043,7 @@ if test -f "$ltmain"; then
     predeps_F77 \
     postdeps_F77 \
     compiler_lib_search_path_F77 \
+    compiler_lib_search_dirs_F77 \
     archive_cmds_F77 \
     archive_expsym_cmds_F77 \
     postinstall_cmds_F77 \
@@ -17930,6 +18292,10 @@ predeps=$lt_predeps_F77
 # shared library.
 postdeps=$lt_postdeps_F77
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_F77
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_compiler_lib_search_path_F77
@@ -18104,7 +18470,7 @@ ac_outfile=conftest.$ac_objext
 echo "$lt_simple_link_test_code" >conftest.$ac_ext
 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 
 
 # Allow CC to be a program name with arguments.
@@ -18153,11 +18519,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18156: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18522: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:18160: \$? = $ac_status" >&5
+   echo "$as_me:18526: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -18217,7 +18583,7 @@ echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
       # built for inclusion in a dll (and should export symbols for example).
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
-      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+
       ;;
 
     darwin* | rhapsody*)
@@ -18287,7 +18653,7 @@ echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
     mingw* | cygwin* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -18427,10 +18793,10 @@ if test -n "$lt_prog_compiler_pic_GCJ"; then
 
 { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
+if test "${lt_cv_prog_compiler_pic_works_GCJ+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_pic_works_GCJ=no
+  lt_cv_prog_compiler_pic_works_GCJ=no
   ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
    lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
@@ -18443,27 +18809,27 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18446: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18812: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:18450: \$? = $ac_status" >&5
+   echo "$as_me:18816: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
      $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
      $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
      if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_GCJ=yes
+       lt_cv_prog_compiler_pic_works_GCJ=yes
      fi
    fi
    $rm conftest*
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_GCJ" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_GCJ" >&6; }
 
-if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
+if test x"$lt_cv_prog_compiler_pic_works_GCJ" = xyes; then
     case $lt_prog_compiler_pic_GCJ in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
@@ -18490,10 +18856,10 @@ esac
 wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\"
 { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
-if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then
+if test "${lt_cv_prog_compiler_static_works_GCJ+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_prog_compiler_static_works_GCJ=no
+  lt_cv_prog_compiler_static_works_GCJ=no
    save_LDFLAGS="$LDFLAGS"
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
@@ -18506,20 +18872,20 @@ else
        $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
        $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
        if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_GCJ=yes
+         lt_cv_prog_compiler_static_works_GCJ=yes
        fi
      else
-       lt_prog_compiler_static_works_GCJ=yes
+       lt_cv_prog_compiler_static_works_GCJ=yes
      fi
    fi
-   $rm conftest*
+   $rm -r conftest*
    LDFLAGS="$save_LDFLAGS"
 
 fi
-{ echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6; }
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_GCJ" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works_GCJ" >&6; }
 
-if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then
+if test x"$lt_cv_prog_compiler_static_works_GCJ" = xyes; then
     :
 else
     lt_prog_compiler_static_GCJ=
@@ -18547,11 +18913,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18550: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:18916: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:18554: \$? = $ac_status" >&5
+   echo "$as_me:18920: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -18631,12 +18997,13 @@ echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared librar
   # it will be wrapped by ` (' and `)$', so one must not match beginning or
   # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
   # as well as any symbol that contains `d'.
-  exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
+  exclude_expsyms_GCJ='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
   # the symbol is explicitly referenced.  Since portable code cannot
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
   extract_expsyms_cmds=
   # Just being paranoid about ensuring that cc_basename is set.
   for cc_temp in $compiler""; do
@@ -18695,7 +19062,7 @@ cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
     # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
+    aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
       if test "$host_cpu" != ia64; then
 	ld_shlibs_GCJ=no
@@ -18915,7 +19282,7 @@ _LT_EOF
       fi
       ;;
 
-    aix4* | aix5*)
+    aix[4-9]*)
       if test "$host_cpu" = ia64; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
@@ -18935,7 +19302,7 @@ _LT_EOF
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
 	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
   	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
   	    aix_use_runtimelinking=yes
@@ -19207,11 +19574,10 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
       link_all_deplibs_GCJ=yes
     if test "$GCC" = yes ; then
     	output_verbose_link_cmd='echo'
-        archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        archive_cmds_GCJ="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        module_cmds_GCJ="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        archive_expsym_cmds_GCJ="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        module_expsym_cmds_GCJ="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
     else
       case $cc_basename in
         xlc*)
@@ -19680,7 +20046,7 @@ aix3*)
   soname_spec='${libname}${release}${shared_ext}$major'
   ;;
 
-aix4* | aix5*)
+aix[4-9]*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -20213,6 +20579,21 @@ esac
 echo "${ECHO_T}$dynamic_linker" >&6; }
 test "$dynamic_linker" = no && can_build_shared=no
 
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
 if test "$GCC" = yes; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
@@ -20296,6 +20677,7 @@ if test -f "$ltmain"; then
     predeps_GCJ \
     postdeps_GCJ \
     compiler_lib_search_path_GCJ \
+    compiler_lib_search_dirs_GCJ \
     archive_cmds_GCJ \
     archive_expsym_cmds_GCJ \
     postinstall_cmds_GCJ \
@@ -20544,6 +20926,10 @@ predeps=$lt_predeps_GCJ
 # shared library.
 postdeps=$lt_postdeps_GCJ
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_GCJ
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
@@ -20717,7 +21103,7 @@ ac_outfile=conftest.$ac_objext
 echo "$lt_simple_link_test_code" >conftest.$ac_ext
 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
 _lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+$rm -r conftest*
 
 
 # Allow CC to be a program name with arguments.
@@ -20777,6 +21163,7 @@ if test -f "$ltmain"; then
     predeps_RC \
     postdeps_RC \
     compiler_lib_search_path_RC \
+    compiler_lib_search_dirs_RC \
     archive_cmds_RC \
     archive_expsym_cmds_RC \
     postinstall_cmds_RC \
@@ -21025,6 +21412,10 @@ predeps=$lt_predeps_RC
 # shared library.
 postdeps=$lt_postdeps_RC
 
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_RC
+
 # The library search path used internally by the compiler when linking
 # a shared library.
 compiler_lib_search_path=$lt_compiler_lib_search_path_RC
@@ -21248,6 +21639,8 @@ fi
 
 
 
+
+
 
 
 
@@ -21256,7 +21649,8 @@ for ac_header in mcheck.h values.h socket.h sys/socket.h  \
                  stdlib.h dirent.h pthread.h sys/prctl.h \
                  sysint.h inttypes.h termcap.h netdb.h sys/socket.h  \
                  sys/systemcfg.h ncurses.h curses.h sys/dr.h sys/vfs.h \
-		 pam/pam_appl.h security/pam_appl.h sys/sysctl.h \
+                 pam/pam_appl.h security/pam_appl.h sys/sysctl.h \
+                 pty.h utmp.h \
 		 sys/syslog.h \
 
 do
@@ -24298,14 +24692,14 @@ echo "$as_me: Running in bluegene emulation mode" >&6;}
          		have_bg_ar=yes
 			bg_bridge_so="$bg_dir/lib64/libbglbridge.so"
        	 		bg_ldflags="$bg_ldflags -L$bg_dir/lib64 -L/usr/lib64 -Wl,--unresolved-symbols=ignore-in-shared-libs -lbglbridge -lbgldb -ltableapi -lbglmachine -lexpat -lsaymessage"
-      		fi
+        	fi
 
       		# Search for required DB2 library in the directory
       		if test -z "$have_db2" -a -f "$bg_dir/lib64/libdb2.so" ; then
          		have_db2=yes
 	 	 	bg_db2_so="$bg_dir/lib64/libdb2.so"
        	 		bg_ldflags="$bg_ldflags -L$bg_dir/lib64 -ldb2"
-      		fi
+       		fi
 
       		# Search for headers in the directory
       		if test -z "$have_bg_hdr" -a -f "$bg_dir/include/rm_api.h" ; then
@@ -24417,6 +24811,15 @@ _ACEOF
 
 
 
+	# This is here to avoid a bug in the gcc compiler 3.4.6
+	# Without this flag there is a bug when pointing to other functions
+	# and then using them.  It is also advised to set the flag if there
+	# are goto statements you may get better performance.
+	if test "$GCC" == "yes"; then
+		CFLAGS="$CFLAGS -fno-gcse"
+	fi
+
+
    { echo "$as_me:$LINENO: checking whether XCPU is enabled" >&5
 echo $ECHO_N "checking whether XCPU is enabled... $ECHO_C" >&6; }
 
@@ -24781,7 +25184,7 @@ done
 done
 IFS=$as_save_IFS
 
-  test -z "$ac_cv_path_HAVEPKGCONFIG" && ac_cv_path_HAVEPKGCONFIG="$PATH"
+  test -z "$ac_cv_path_HAVEPKGCONFIG" && ac_cv_path_HAVEPKGCONFIG="no"
   ;;
 esac
 fi
@@ -24795,7 +25198,7 @@ echo "${ECHO_T}no" >&6; }
 fi
 
 
-    if test -z "$HAVEPKGCONFIG"; then
+    if test x$HAVEPKGCONFIG = xno; then
         { echo "$as_me:$LINENO: WARNING: *** pkg-config not found. Cannot probe for libglade-2.0 or gtk+-2.0." >&5
 echo "$as_me: WARNING: *** pkg-config not found. Cannot probe for libglade-2.0 or gtk+-2.0." >&2;}
         ac_have_gtk="no"
@@ -24922,6 +25325,279 @@ fi
 
 
 
+	#Check for MySQL
+	ac_have_mysql="no"
+	### Check for mysql_config program
+    	# Extract the first word of "mysql_config", so it can be a program name with args.
+set dummy mysql_config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_HAVEMYSQLCONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $HAVEMYSQLCONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_HAVEMYSQLCONFIG="$HAVEMYSQLCONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_HAVEMYSQLCONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_HAVEMYSQLCONFIG" && ac_cv_path_HAVEMYSQLCONFIG="no"
+  ;;
+esac
+fi
+HAVEMYSQLCONFIG=$ac_cv_path_HAVEMYSQLCONFIG
+if test -n "$HAVEMYSQLCONFIG"; then
+  { echo "$as_me:$LINENO: result: $HAVEMYSQLCONFIG" >&5
+echo "${ECHO_T}$HAVEMYSQLCONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+	if test x$HAVEMYSQLCONFIG = xno; then
+        	{ echo "$as_me:$LINENO: WARNING: *** mysql_config not found. Evidently no MySQL install on system." >&5
+echo "$as_me: WARNING: *** mysql_config not found. Evidently no MySQL install on system." >&2;}
+	else
+		# check for mysql-5.0.0+
+		mysql_config_major_version=`$HAVEMYSQLCONFIG --version | \
+			sed 's/\([0-9]*\).\([0-9]*\).\([a-zA-Z0-9]*\)/\1/'`
+    		mysql_config_minor_version=`$HAVEMYSQLCONFIG --version | \
+			sed 's/\([0-9]*\).\([0-9]*\).\([a-zA-Z0-9]*\)/\2/'`
+    		mysql_config_micro_version=`$HAVEMYSQLCONFIG --version | \
+			sed 's/\([0-9]*\).\([0-9]*\).\([a-zA-Z0-9]*\)/\3/'`
+
+		if test $mysql_config_major_version -lt 5; then
+	   		{ echo "$as_me:$LINENO: WARNING: *** mysql-$mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version available, we need >= mysql-5.0.0 installed for the mysql interface." >&5
+echo "$as_me: WARNING: *** mysql-$mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version available, we need >= mysql-5.0.0 installed for the mysql interface." >&2;}
+            		ac_have_mysql="no"
+		else
+		# mysql_config puts -I on the front of the dir.  We don't
+		# want that so we remove it.
+			MYSQL_CFLAGS=`$HAVEMYSQLCONFIG --cflags`
+			MYSQL_LIBS=`$HAVEMYSQLCONFIG --libs_r`
+			if test -z "$MYSQL_LIBS"; then
+				MYSQL_LIBS=`$HAVEMYSQLCONFIG --libs`
+			fi
+			save_CFLAGS="$CFLAGS"
+			save_LIBS="$LIBS"
+       			CFLAGS="$MYSQL_CFLAGS $save_CFLAGS"
+			LIBS="$MYSQL_LIBS $save_LIBS"
+			cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <mysql.h>
+int
+main ()
+{
+
+          				int main()
+          				{
+						MYSQL mysql;
+            					(void) mysql_init(&mysql);
+						(void) mysql_close(&mysql);
+            				}
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_have_mysql="yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_have_mysql="no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+			CFLAGS="$save_CFLAGS"
+			LIBS="$save_LIBS"
+       			if test "$ac_have_mysql" == "yes"; then
+            			{ echo "$as_me:$LINENO: result: MySQL test program built properly." >&5
+echo "${ECHO_T}MySQL test program built properly." >&6; }
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MYSQL 1
+_ACEOF
+
+			else
+ 				MYSQL_CFLAGS=""
+				MYSQL_LIBS=""
+       				{ echo "$as_me:$LINENO: WARNING: *** MySQL test program execution failed." >&5
+echo "$as_me: WARNING: *** MySQL test program execution failed." >&2;}
+			fi
+		fi
+      	fi
+
+
+	#Check for PostgreSQL
+	ac_have_postgres="no"
+	### Check for pg_config program
+    	# Extract the first word of "pg_config", so it can be a program name with args.
+set dummy pg_config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_HAVEPGCONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $HAVEPGCONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_HAVEPGCONFIG="$HAVEPGCONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_HAVEPGCONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_HAVEPGCONFIG" && ac_cv_path_HAVEPGCONFIG="no"
+  ;;
+esac
+fi
+HAVEPGCONFIG=$ac_cv_path_HAVEPGCONFIG
+if test -n "$HAVEPGCONFIG"; then
+  { echo "$as_me:$LINENO: result: $HAVEPGCONFIG" >&5
+echo "${ECHO_T}$HAVEPGCONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+	if test x$HAVEPGCONFIG = xno; then
+        	{ echo "$as_me:$LINENO: WARNING: *** pg_config not found. Evidently no PostgreSQL install on system." >&5
+echo "$as_me: WARNING: *** pg_config not found. Evidently no PostgreSQL install on system." >&2;}
+	else
+		PGSQL_INCLUDEDIR=`$HAVEPGCONFIG --includedir`
+		PGSQL_LIBDIR=`$HAVEPGCONFIG --libdir`
+		PGSQL_CFLAGS="-I$PGSQL_INCLUDEDIR -L$PGSQL_LIBDIR"
+		save_CFLAGS="$CFLAGS"
+        	CFLAGS="$PGSQL_CFLAGS $save_CFLAGS"
+
+		PGSQL_LIBS=" -lpq"
+	       	save_LIBS="$LIBS"
+        	LIBS="$PGSQL_LIBS $save_LIBS"
+       		cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <libpq-fe.h>
+int
+main ()
+{
+
+          			int main()
+       	  			{
+					PGconn     *conn;
+					conn = PQconnectdb("dbname = postgres");
+       					(void) PQfinish(conn);
+            			}
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_have_pgsql="yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_have_pgsql="no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+		LIBS="$save_LIBS"
+       		CFLAGS="$save_CFLAGS"
+		if test "$ac_have_pgsql" == "yes"; then
+    			{ echo "$as_me:$LINENO: result: PostgreSQL test program built properly." >&5
+echo "${ECHO_T}PostgreSQL test program built properly." >&6; }
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PGSQL 1
+_ACEOF
+
+		else
+			PGSQL_CFLAGS=""
+			PGSQL_LIBS=""
+       			{ echo "$as_me:$LINENO: WARNING: *** PostgreSQL test program execution failed." >&5
+echo "$as_me: WARNING: *** PostgreSQL test program execution failed." >&2;}
+		fi
+      	fi
+
+
+
 
 
 
@@ -25098,7 +25774,6 @@ fi
   { echo "$as_me:$LINENO: checking for slurmctld default port" >&5
 echo $ECHO_N "checking for slurmctld default port... $ECHO_C" >&6; }
 
-
 # Check whether --with-slurmctld-port was given.
 if test "${with_slurmctld_port+set}" = set; then
   withval=$with_slurmctld_port;  if test `expr match "$withval" '[0-9]*$'` -gt 0; then
@@ -25111,13 +25786,13 @@ fi
   { echo "$as_me:$LINENO: result: ${slurmctldport=6817}" >&5
 echo "${ECHO_T}${slurmctldport=6817}" >&6; }
 
-
 cat >>confdefs.h <<_ACEOF
 #define SLURMCTLD_PORT $slurmctldport
 _ACEOF
 
 
 
+
   { echo "$as_me:$LINENO: checking for slurmd default port" >&5
 echo $ECHO_N "checking for slurmd default port... $ECHO_C" >&6; }
 
@@ -25133,7 +25808,6 @@ fi
   { echo "$as_me:$LINENO: result: ${slurmdport=6818}" >&5
 echo "${ECHO_T}${slurmdport=6818}" >&6; }
 
-
 cat >>confdefs.h <<_ACEOF
 #define SLURMD_PORT $slurmdport
 _ACEOF
@@ -25141,6 +25815,26 @@ _ACEOF
 
 
 
+  { echo "$as_me:$LINENO: checking for slurmdbd default port" >&5
+echo $ECHO_N "checking for slurmdbd default port... $ECHO_C" >&6; }
+
+# Check whether --with-slurmdbd-port was given.
+if test "${with_slurmdbd_port+set}" = set; then
+  withval=$with_slurmdbd_port;  if test `expr match "$withval" '[0-9]*$'` -gt 0; then
+            slurmdbdport="$withval"
+          fi
+
+
+fi
+
+  { echo "$as_me:$LINENO: result: ${slurmdbdport=6819}" >&5
+echo "${ECHO_T}${slurmdbdport=6819}" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define SLURMDBD_PORT $slurmdbdport
+_ACEOF
+
+
 
 
 
@@ -25681,16 +26375,15 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 
 
 
-  ac_slurm_with_ssl=no
   ssl_default_dirs="/usr/local/openssl64 /usr/local/openssl /usr/lib/openssl    \
                     /usr/local/ssl /usr/lib/ssl /usr/local \
-                    /usr/pkg /opt /opt/openssl"
+                    /usr/pkg /opt /opt/openssl /usr"
 
 
 
 
 
-  SSL_LIBS="-lcrypto"
+  SSL_LIB_TEST="-lcrypto"
 
 
 # Check whether --with-ssl was given.
@@ -25703,7 +26396,7 @@ if test "${with_ssl+set}" = set; then
   	# which is specified with --with-ssl), and libtool is not setting
   	# the correct runtime library path in the binaries.
   	if test "x$ac_have_aix" = "xyes"; then
-  		SSL_LIBS="-lcrypto-static"
+  		SSL_LIB_TEST="-lcrypto-static"
   	fi
 
 fi
@@ -25715,13 +26408,9 @@ fi
   if test "x$prefix" != "xNONE" ; then
   	tryssldir="$tryssldir $prefix"
   fi
-  if test "x$tryssldir" == "xno" ; then
-     { { echo "$as_me:$LINENO: error: OpenSSL libary is required for SLURM operation, download from www.openssl.org" >&5
-echo "$as_me: error: OpenSSL libary is required for SLURM operation, download from www.openssl.org" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
 
-  { echo "$as_me:$LINENO: checking for OpenSSL directory" >&5
+  if test "x$tryssldir" != "xno" ; then
+    { echo "$as_me:$LINENO: checking for OpenSSL directory" >&5
 echo $ECHO_N "checking for OpenSSL directory... $ECHO_C" >&6; }
 if test "${ac_cv_openssldir+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -25730,13 +26419,14 @@ else
   	for ssldir in $tryssldir "" $ssl_default_dirs; do
   		CPPFLAGS="$saved_CPPFLAGS"
   		LDFLAGS="$saved_LDFLAGS"
-  		LIBS="$saved_LIBS $SSL_LIBS"
+  		LIBS="$saved_LIBS $SSL_LIB_TEST"
 
   		# Skip directories if they don't exist
   		if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
   			continue;
   		fi
-  		if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
+  		sslincludedir="$ssldir"
+  		if test ! -z "$ssldir"; then
   			# Try to use $ssldir/lib if it exists, otherwise
   			# $ssldir
   			if test -d "$ssldir/lib" ; then
@@ -25753,11 +26443,15 @@ else
   			# Try to use $ssldir/include if it exists, otherwise
   			# $ssldir
   			if test -d "$ssldir/include" ; then
+				sslincludedir="$ssldir/include"
   				CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
   			else
   				CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
   			fi
   		fi
+		test -f "$sslincludedir/openssl/rand.h" || continue
+		test -f "$sslincludedir/openssl/hmac.h" || continue
+		test -f "$sslincludedir/openssl/sha.h" || continue
 
   		# Basic test to check for compatible version and correct linking
   		if test "$cross_compiling" = yes; then
@@ -25810,7 +26504,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-  				found_crypto=1
+  				ac_have_openssl="yes"
   				break;
 
 else
@@ -25827,27 +26521,28 @@ fi
 
 
 
-  		if test ! -z "$found_crypto" ; then
+  		if test ! -z "$ac_have_openssl" ; then
   			break;
   		fi
   	done
 
-  	if test -z "$found_crypto" ; then
-  		{ { echo "$as_me:$LINENO: error: Could not find working OpenSSL library, download from www.openssl.org" >&5
-echo "$as_me: error: Could not find working OpenSSL library, download from www.openssl.org" >&2;}
-   { (exit 1); exit 1; }; }
-  	fi
-  	if test -z "$ssldir" ; then
-  		ssldir="(system)"
-  	fi
-
-  	ac_cv_openssldir=$ssldir
+	if test ! -z "$ac_have_openssl" ; then
+		ac_cv_openssldir=$ssldir
+	fi
 
 fi
 { echo "$as_me:$LINENO: result: $ac_cv_openssldir" >&5
 echo "${ECHO_T}$ac_cv_openssldir" >&6; }
+  fi
+
+  if test ! -z "$ac_have_openssl" ; then
+    SSL_LIBS="$SSL_LIB_TEST"
 
-  if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; then
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_OPENSSL 1
+_ACEOF
+
+    if (test ! -z "$ac_cv_openssldir") ; then
   	  	ssldir=$ac_cv_openssldir
   	if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
   		# Try to use $ssldir/lib if it exists, otherwise
@@ -25865,9 +26560,9 @@ echo "${ECHO_T}$ac_cv_openssldir" >&6; }
   			SSL_CPPFLAGS="-I$ssldir"
   		fi
   	fi
-  fi
+    fi
 
-  cat >conftest.$ac_ext <<_ACEOF
+    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -25914,12 +26609,25 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
+  else
+    SSL_LIBS=""
+    { echo "$as_me:$LINENO: WARNING: Could not find working OpenSSL library" >&5
+echo "$as_me: WARNING: Could not find working OpenSSL library" >&2;}
+  fi
 
   LIBS="$saved_LIBS"
   CPPFLAGS="$saved_CPPFLAGS"
   LDFLAGS="$saved_LDFLAGS"
 
 
+ if test "x$ac_have_openssl" = "xyes"; then
+  HAVE_OPENSSL_TRUE=
+  HAVE_OPENSSL_FALSE='#'
+else
+  HAVE_OPENSSL_TRUE='#'
+  HAVE_OPENSSL_FALSE=
+fi
+
 
 
 
@@ -26055,6 +26763,11 @@ cat >>confdefs.h <<\_ACEOF
 #define LOAD_ENV_NO_LOGIN 1
 _ACEOF
 
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
 { echo "$as_me:$LINENO: checking whether to enable multiple-slurmd support" >&5
@@ -26170,6 +26883,76 @@ fi
 LIBS="$savedLIBS"
 CFLAGS="$savedCFLAGS"
 
+savedLIBS="$LIBS"
+LIBS="-lutil $LIBS"
+{ echo "$as_me:$LINENO: checking for openpty in -lutil" >&5
+echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6; }
+if test "${ac_cv_lib_util_openpty+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lutil  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char openpty ();
+int
+main ()
+{
+return openpty ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_util_openpty=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_util_openpty=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_util_openpty" >&5
+echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6; }
+if test $ac_cv_lib_util_openpty = yes; then
+  UTIL_LIBS="-lutil"
+fi
+
+
+LIBS="$savedLIBS"
+
 
 cat >>confdefs.h <<\_ACEOF
 #define WITH_LSD_FATAL_ERROR_FUNC 1
@@ -26182,7 +26965,7 @@ _ACEOF
 
 
 
-ac_config_files="$ac_config_files Makefile config.xml auxdir/Makefile contribs/Makefile contribs/perlapi/Makefile contribs/perlapi/libslurm-perl/Makefile.PL contribs/torque/Makefile src/Makefile src/api/Makefile src/common/Makefile src/sacct/Makefile src/salloc/Makefile src/sbatch/Makefile src/sattach/Makefile src/srun/Makefile src/slaunch/Makefile src/slurmd/Makefile src/slurmd/slurmd/Makefile src/slurmd/slurmstepd/Makefile src/slurmctld/Makefile src/sbcast/Makefile src/scontrol/Makefile src/scancel/Makefile src/squeue/Makefile src/sinfo/Makefile src/smap/Makefile src/strigger/Makefile src/sview/Makefile src/plugins/Makefile src/plugins/auth/Makefile src/plugins/auth/authd/Makefile src/plugins/auth/munge/Makefile src/plugins/auth/none/Makefile src/plugins/checkpoint/Makefile src/plugins/checkpoint/aix/Makefile src/plugins/checkpoint/none/Makefile src/plugins/checkpoint/ompi/Makefile src/plugins/jobacct/Makefile src/plugins/jobacct/linux/Makefile src/plugins/jobacct/aix/Makefile src/plugins/jobacct/none/Makefile src/plugins/jobacct/gold/Makefile src/plugins/jobcomp/Makefile src/plugins/jobcomp/filetxt/Makefile src/plugins/jobcomp/none/Makefile src/plugins/jobcomp/script/Makefile src/plugins/proctrack/Makefile src/plugins/proctrack/aix/Makefile src/plugins/proctrack/pgid/Makefile src/plugins/proctrack/linuxproc/Makefile src/plugins/proctrack/rms/Makefile src/plugins/proctrack/sgi_job/Makefile src/plugins/sched/Makefile src/plugins/sched/backfill/Makefile src/plugins/sched/builtin/Makefile src/plugins/sched/gang/Makefile src/plugins/sched/hold/Makefile src/plugins/sched/wiki/Makefile src/plugins/sched/wiki2/Makefile src/plugins/select/Makefile src/plugins/select/bluegene/Makefile src/plugins/select/bluegene/block_allocator/Makefile src/plugins/select/bluegene/plugin/Makefile src/plugins/select/linear/Makefile src/plugins/select/cons_res/Makefile src/plugins/switch/Makefile src/plugins/switch/elan/Makefile src/plugins/switch/none/Makefile src/plugins/switch/federation/Makefile src/plugins/mpi/Makefile src/plugins/mpi/mpich1_p4/Makefile src/plugins/mpi/mpich1_shmem/Makefile src/plugins/mpi/mpichgm/Makefile src/plugins/mpi/mpichmx/Makefile src/plugins/mpi/mvapich/Makefile src/plugins/mpi/lam/Makefile src/plugins/mpi/none/Makefile src/plugins/mpi/openmpi/Makefile src/plugins/task/Makefile src/plugins/task/affinity/Makefile src/plugins/task/none/Makefile doc/Makefile doc/man/Makefile doc/html/Makefile doc/html/configurator.html testsuite/Makefile testsuite/expect/Makefile testsuite/slurm_unit/Makefile testsuite/slurm_unit/common/Makefile testsuite/slurm_unit/slurmctld/Makefile testsuite/slurm_unit/slurmd/Makefile testsuite/slurm_unit/api/Makefile testsuite/slurm_unit/api/manual/Makefile"
+ac_config_files="$ac_config_files Makefile config.xml auxdir/Makefile contribs/Makefile contribs/perlapi/Makefile contribs/perlapi/libslurm-perl/Makefile.PL contribs/torque/Makefile contribs/phpext/Makefile contribs/phpext/slurm_php/config.m4 src/Makefile src/api/Makefile src/common/Makefile src/database/Makefile src/sacct/Makefile src/sacctmgr/Makefile src/sreport/Makefile src/sstat/Makefile src/salloc/Makefile src/sbatch/Makefile src/sattach/Makefile src/srun/Makefile src/slurmd/Makefile src/slurmd/slurmd/Makefile src/slurmd/slurmstepd/Makefile src/slurmdbd/Makefile src/slurmctld/Makefile src/sbcast/Makefile src/scontrol/Makefile src/scancel/Makefile src/squeue/Makefile src/sinfo/Makefile src/smap/Makefile src/strigger/Makefile src/sview/Makefile src/plugins/Makefile src/plugins/accounting_storage/Makefile src/plugins/accounting_storage/filetxt/Makefile src/plugins/accounting_storage/gold/Makefile src/plugins/accounting_storage/mysql/Makefile src/plugins/accounting_storage/pgsql/Makefile src/plugins/accounting_storage/none/Makefile src/plugins/accounting_storage/slurmdbd/Makefile src/plugins/auth/Makefile src/plugins/auth/authd/Makefile src/plugins/auth/munge/Makefile src/plugins/auth/none/Makefile src/plugins/checkpoint/Makefile src/plugins/checkpoint/aix/Makefile src/plugins/checkpoint/none/Makefile src/plugins/checkpoint/ompi/Makefile src/plugins/checkpoint/xlch/Makefile src/plugins/crypto/Makefile src/plugins/crypto/munge/Makefile src/plugins/crypto/openssl/Makefile src/plugins/jobacct_gather/Makefile src/plugins/jobacct_gather/linux/Makefile src/plugins/jobacct_gather/aix/Makefile src/plugins/jobacct_gather/none/Makefile src/plugins/jobcomp/Makefile src/plugins/jobcomp/filetxt/Makefile src/plugins/jobcomp/none/Makefile src/plugins/jobcomp/script/Makefile src/plugins/jobcomp/mysql/Makefile src/plugins/jobcomp/pgsql/Makefile src/plugins/jobcomp/slurmdbd/Makefile src/plugins/proctrack/Makefile src/plugins/proctrack/aix/Makefile src/plugins/proctrack/pgid/Makefile src/plugins/proctrack/linuxproc/Makefile src/plugins/proctrack/rms/Makefile src/plugins/proctrack/sgi_job/Makefile src/plugins/sched/Makefile src/plugins/sched/backfill/Makefile src/plugins/sched/builtin/Makefile src/plugins/sched/gang/Makefile src/plugins/sched/hold/Makefile src/plugins/sched/wiki/Makefile src/plugins/sched/wiki2/Makefile src/plugins/select/Makefile src/plugins/select/bluegene/Makefile src/plugins/select/bluegene/block_allocator/Makefile src/plugins/select/bluegene/plugin/Makefile src/plugins/select/linear/Makefile src/plugins/select/cons_res/Makefile src/plugins/switch/Makefile src/plugins/switch/elan/Makefile src/plugins/switch/none/Makefile src/plugins/switch/federation/Makefile src/plugins/mpi/Makefile src/plugins/mpi/mpich1_p4/Makefile src/plugins/mpi/mpich1_shmem/Makefile src/plugins/mpi/mpichgm/Makefile src/plugins/mpi/mpichmx/Makefile src/plugins/mpi/mvapich/Makefile src/plugins/mpi/lam/Makefile src/plugins/mpi/none/Makefile src/plugins/mpi/openmpi/Makefile src/plugins/task/Makefile src/plugins/task/affinity/Makefile src/plugins/task/none/Makefile doc/Makefile doc/man/Makefile doc/html/Makefile doc/html/configurator.html testsuite/Makefile testsuite/expect/Makefile testsuite/slurm_unit/Makefile testsuite/slurm_unit/common/Makefile testsuite/slurm_unit/slurmctld/Makefile testsuite/slurm_unit/slurmd/Makefile testsuite/slurm_unit/api/Makefile testsuite/slurm_unit/api/manual/Makefile"
 
 
 cat >confcache <<\_ACEOF
@@ -26407,6 +27190,13 @@ echo "$as_me: error: conditional \"HAVE_SGI_JOB\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${HAVE_OPENSSL_TRUE}" && test -z "${HAVE_OPENSSL_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"HAVE_OPENSSL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"HAVE_OPENSSL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${WITH_MUNGE_TRUE}" && test -z "${WITH_MUNGE_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"WITH_MUNGE\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -26898,18 +27688,24 @@ do
     "contribs/perlapi/Makefile") CONFIG_FILES="$CONFIG_FILES contribs/perlapi/Makefile" ;;
     "contribs/perlapi/libslurm-perl/Makefile.PL") CONFIG_FILES="$CONFIG_FILES contribs/perlapi/libslurm-perl/Makefile.PL" ;;
     "contribs/torque/Makefile") CONFIG_FILES="$CONFIG_FILES contribs/torque/Makefile" ;;
+    "contribs/phpext/Makefile") CONFIG_FILES="$CONFIG_FILES contribs/phpext/Makefile" ;;
+    "contribs/phpext/slurm_php/config.m4") CONFIG_FILES="$CONFIG_FILES contribs/phpext/slurm_php/config.m4" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "src/api/Makefile") CONFIG_FILES="$CONFIG_FILES src/api/Makefile" ;;
     "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;;
+    "src/database/Makefile") CONFIG_FILES="$CONFIG_FILES src/database/Makefile" ;;
     "src/sacct/Makefile") CONFIG_FILES="$CONFIG_FILES src/sacct/Makefile" ;;
+    "src/sacctmgr/Makefile") CONFIG_FILES="$CONFIG_FILES src/sacctmgr/Makefile" ;;
+    "src/sreport/Makefile") CONFIG_FILES="$CONFIG_FILES src/sreport/Makefile" ;;
+    "src/sstat/Makefile") CONFIG_FILES="$CONFIG_FILES src/sstat/Makefile" ;;
     "src/salloc/Makefile") CONFIG_FILES="$CONFIG_FILES src/salloc/Makefile" ;;
     "src/sbatch/Makefile") CONFIG_FILES="$CONFIG_FILES src/sbatch/Makefile" ;;
     "src/sattach/Makefile") CONFIG_FILES="$CONFIG_FILES src/sattach/Makefile" ;;
     "src/srun/Makefile") CONFIG_FILES="$CONFIG_FILES src/srun/Makefile" ;;
-    "src/slaunch/Makefile") CONFIG_FILES="$CONFIG_FILES src/slaunch/Makefile" ;;
     "src/slurmd/Makefile") CONFIG_FILES="$CONFIG_FILES src/slurmd/Makefile" ;;
     "src/slurmd/slurmd/Makefile") CONFIG_FILES="$CONFIG_FILES src/slurmd/slurmd/Makefile" ;;
     "src/slurmd/slurmstepd/Makefile") CONFIG_FILES="$CONFIG_FILES src/slurmd/slurmstepd/Makefile" ;;
+    "src/slurmdbd/Makefile") CONFIG_FILES="$CONFIG_FILES src/slurmdbd/Makefile" ;;
     "src/slurmctld/Makefile") CONFIG_FILES="$CONFIG_FILES src/slurmctld/Makefile" ;;
     "src/sbcast/Makefile") CONFIG_FILES="$CONFIG_FILES src/sbcast/Makefile" ;;
     "src/scontrol/Makefile") CONFIG_FILES="$CONFIG_FILES src/scontrol/Makefile" ;;
@@ -26920,6 +27716,13 @@ do
     "src/strigger/Makefile") CONFIG_FILES="$CONFIG_FILES src/strigger/Makefile" ;;
     "src/sview/Makefile") CONFIG_FILES="$CONFIG_FILES src/sview/Makefile" ;;
     "src/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;;
+    "src/plugins/accounting_storage/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/accounting_storage/Makefile" ;;
+    "src/plugins/accounting_storage/filetxt/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/accounting_storage/filetxt/Makefile" ;;
+    "src/plugins/accounting_storage/gold/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/accounting_storage/gold/Makefile" ;;
+    "src/plugins/accounting_storage/mysql/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/accounting_storage/mysql/Makefile" ;;
+    "src/plugins/accounting_storage/pgsql/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/accounting_storage/pgsql/Makefile" ;;
+    "src/plugins/accounting_storage/none/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/accounting_storage/none/Makefile" ;;
+    "src/plugins/accounting_storage/slurmdbd/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/accounting_storage/slurmdbd/Makefile" ;;
     "src/plugins/auth/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/auth/Makefile" ;;
     "src/plugins/auth/authd/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/auth/authd/Makefile" ;;
     "src/plugins/auth/munge/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/auth/munge/Makefile" ;;
@@ -26928,15 +27731,21 @@ do
     "src/plugins/checkpoint/aix/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/checkpoint/aix/Makefile" ;;
     "src/plugins/checkpoint/none/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/checkpoint/none/Makefile" ;;
     "src/plugins/checkpoint/ompi/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/checkpoint/ompi/Makefile" ;;
-    "src/plugins/jobacct/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct/Makefile" ;;
-    "src/plugins/jobacct/linux/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct/linux/Makefile" ;;
-    "src/plugins/jobacct/aix/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct/aix/Makefile" ;;
-    "src/plugins/jobacct/none/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct/none/Makefile" ;;
-    "src/plugins/jobacct/gold/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct/gold/Makefile" ;;
+    "src/plugins/checkpoint/xlch/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/checkpoint/xlch/Makefile" ;;
+    "src/plugins/crypto/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/crypto/Makefile" ;;
+    "src/plugins/crypto/munge/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/crypto/munge/Makefile" ;;
+    "src/plugins/crypto/openssl/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/crypto/openssl/Makefile" ;;
+    "src/plugins/jobacct_gather/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct_gather/Makefile" ;;
+    "src/plugins/jobacct_gather/linux/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct_gather/linux/Makefile" ;;
+    "src/plugins/jobacct_gather/aix/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct_gather/aix/Makefile" ;;
+    "src/plugins/jobacct_gather/none/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobacct_gather/none/Makefile" ;;
     "src/plugins/jobcomp/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/Makefile" ;;
     "src/plugins/jobcomp/filetxt/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/filetxt/Makefile" ;;
     "src/plugins/jobcomp/none/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/none/Makefile" ;;
     "src/plugins/jobcomp/script/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/script/Makefile" ;;
+    "src/plugins/jobcomp/mysql/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/mysql/Makefile" ;;
+    "src/plugins/jobcomp/pgsql/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/pgsql/Makefile" ;;
+    "src/plugins/jobcomp/slurmdbd/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/jobcomp/slurmdbd/Makefile" ;;
     "src/plugins/proctrack/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/proctrack/Makefile" ;;
     "src/plugins/proctrack/aix/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/proctrack/aix/Makefile" ;;
     "src/plugins/proctrack/pgid/Makefile") CONFIG_FILES="$CONFIG_FILES src/plugins/proctrack/pgid/Makefile" ;;
@@ -27211,6 +28020,8 @@ LN_S!$LN_S$ac_delim
 ECHO!$ECHO$ac_delim
 AR!$AR$ac_delim
 RANLIB!$RANLIB$ac_delim
+DSYMUTIL!$DSYMUTIL$ac_delim
+NMEDIT!$NMEDIT$ac_delim
 CXXCPP!$CXXCPP$ac_delim
 F77!$F77$ac_delim
 FFLAGS!$FFLAGS$ac_delim
@@ -27245,10 +28056,17 @@ GTK2_CFLAGS!$GTK2_CFLAGS$ac_delim
 GTK2_LIBS!$GTK2_LIBS$ac_delim
 HAVE_GTK_TRUE!$HAVE_GTK_TRUE$ac_delim
 HAVE_GTK_FALSE!$HAVE_GTK_FALSE$ac_delim
+HAVEMYSQLCONFIG!$HAVEMYSQLCONFIG$ac_delim
+MYSQL_LIBS!$MYSQL_LIBS$ac_delim
+MYSQL_CFLAGS!$MYSQL_CFLAGS$ac_delim
+HAVEPGCONFIG!$HAVEPGCONFIG$ac_delim
+PGSQL_LIBS!$PGSQL_LIBS$ac_delim
+PGSQL_CFLAGS!$PGSQL_CFLAGS$ac_delim
 DEBUG_MODULES_TRUE!$DEBUG_MODULES_TRUE$ac_delim
 DEBUG_MODULES_FALSE!$DEBUG_MODULES_FALSE$ac_delim
 SLURMCTLD_PORT!$SLURMCTLD_PORT$ac_delim
 SLURMD_PORT!$SLURMD_PORT$ac_delim
+SLURMDBD_PORT!$SLURMDBD_PORT$ac_delim
 ELAN_LIBS!$ELAN_LIBS$ac_delim
 HAVE_ELAN_TRUE!$HAVE_ELAN_TRUE$ac_delim
 HAVE_ELAN_FALSE!$HAVE_ELAN_FALSE$ac_delim
@@ -27263,19 +28081,64 @@ READLINE_LIBS!$READLINE_LIBS$ac_delim
 SSL_LDFLAGS!$SSL_LDFLAGS$ac_delim
 SSL_LIBS!$SSL_LIBS$ac_delim
 SSL_CPPFLAGS!$SSL_CPPFLAGS$ac_delim
+HAVE_OPENSSL_TRUE!$HAVE_OPENSSL_TRUE$ac_delim
+HAVE_OPENSSL_FALSE!$HAVE_OPENSSL_FALSE$ac_delim
+HAVE_OPENSSL!$HAVE_OPENSSL$ac_delim
 MUNGE_LIBS!$MUNGE_LIBS$ac_delim
 MUNGE_CPPFLAGS!$MUNGE_CPPFLAGS$ac_delim
 MUNGE_LDFLAGS!$MUNGE_LDFLAGS$ac_delim
 WITH_MUNGE_TRUE!$WITH_MUNGE_TRUE$ac_delim
 WITH_MUNGE_FALSE!$WITH_MUNGE_FALSE$ac_delim
 AUTHD_LIBS!$AUTHD_LIBS$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+CEOF$ac_eof
+_ACEOF
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
 AUTHD_CFLAGS!$AUTHD_CFLAGS$ac_delim
 WITH_AUTHD_TRUE!$WITH_AUTHD_TRUE$ac_delim
 WITH_AUTHD_FALSE!$WITH_AUTHD_FALSE$ac_delim
+UTIL_LIBS!$UTIL_LIBS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 5; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -27293,7 +28156,7 @@ if test -n "$ac_eof"; then
 fi
 
 cat >>$CONFIG_STATUS <<_ACEOF
-cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof
+cat >"\$tmp/subs-3.sed" <<\CEOF$ac_eof
 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
 _ACEOF
 sed '
@@ -27562,7 +28425,7 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
 s&@INSTALL@&$ac_INSTALL&;t t
 s&@MKDIR_P@&$ac_MKDIR_P&;t t
 $ac_datarootdir_hack
-" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" | sed -f "$tmp/subs-3.sed" >$tmp/out
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
@@ -27676,21 +28539,22 @@ echo "$as_me: $ac_file is unchanged" >&6;}
   fi
   rm -f "$tmp/out12"
 # Compute $ac_file's index in $config_headers.
+_am_arg=$ac_file
 _am_stamp_count=1
 for _am_header in $config_headers :; do
   case $_am_header in
-    $ac_file | $ac_file:* )
+    $_am_arg | $_am_arg:* )
       break ;;
     * )
       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
   esac
 done
-echo "timestamp for $ac_file" >`$as_dirname -- $ac_file ||
-$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X$ac_file : 'X\(//\)[^/]' \| \
-	 X$ac_file : 'X\(//\)$' \| \
-	 X$ac_file : 'X\(/\)' \| . 2>/dev/null ||
-echo X$ac_file |
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$_am_arg" : 'X\(//\)[^/]' \| \
+	 X"$_am_arg" : 'X\(//\)$' \| \
+	 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$_am_arg" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
 	    s//\1/
 	    q
@@ -27727,7 +28591,7 @@ echo "$as_me: executing $ac_file commands" >&6;}
   # each Makefile.in and add a new line on top of each file to say so.
   # Grep'ing the whole file is not good either: AIX grep has a line
   # limit of 2048, but all sed's we know have understand at least 4000.
-  if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
+  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
     dirpart=`$as_dirname -- "$mf" ||
 $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$mf" : 'X\(//\)[^/]' \| \
diff --git a/configure.ac b/configure.ac
index e452a5336961f157a4822682dd62897415b082b1..56782ee48f9a50d5de344517387a6da9616e91fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# $Id: configure.ac 12827 2007-12-14 22:29:30Z da $
+# $Id: configure.ac 14147 2008-05-28 22:46:41Z da $
 # This file is to be processed with autoconf to generate a configure script
 
 dnl Prologue
@@ -59,7 +59,8 @@ AC_CHECK_HEADERS(mcheck.h values.h socket.h sys/socket.h  \
                  stdlib.h dirent.h pthread.h sys/prctl.h \
                  sysint.h inttypes.h termcap.h netdb.h sys/socket.h  \
                  sys/systemcfg.h ncurses.h curses.h sys/dr.h sys/vfs.h \
-		 pam/pam_appl.h security/pam_appl.h sys/sysctl.h \
+                 pam/pam_appl.h security/pam_appl.h sys/sysctl.h \
+                 pty.h utmp.h \
 		 sys/syslog.h \
 		)
 AC_HEADER_SYS_WAIT
@@ -133,6 +134,7 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 LIBS="$PTHREAD_LIBS $LIBS"
 
 X_AC_BLUEGENE
+X_AC_CFLAGS
 X_AC_XCPU
 X_AC_SLURM_SEMAPHORE
 
@@ -143,6 +145,8 @@ AC_SUBST(HAVE_SOME_CURSES)
 X_AC_GTK
 AM_CONDITIONAL(HAVE_GTK, test "x$ac_have_gtk" = "xyes")
 
+X_AC_DATABASES
+
 dnl checks for system services.
 dnl
 
@@ -160,9 +164,9 @@ X_AC_DEBUG
 AM_CONDITIONAL(DEBUG_MODULES, test "x$ac_debug" = "xtrue")
 
 
-dnl check for slurmd and slurmctld default ports
+dnl check for slurmctld, slurmd and slurmdbd default ports
 dnl
-X_AC_SLURM_PORTS([6817], [6818])
+X_AC_SLURM_PORTS([6817], [6818], [6819])
 
 
 dnl check for whether to include Elan support
@@ -188,7 +192,8 @@ X_AC_READLINE
 dnl 
 dnl
 X_AC_SLURM_WITH_SSL
-
+AM_CONDITIONAL(HAVE_OPENSSL, test "x$ac_have_openssl" = "xyes")
+AC_SUBST(HAVE_OPENSSL)
 
 dnl
 dnl Check for compilation of SLURM auth modules:
@@ -214,6 +219,9 @@ AC_ARG_ENABLE(
 if test "$x_ac_load_env_no_login" = yes; then
   AC_DEFINE(LOAD_ENV_NO_LOGIN, 1, 
             [Define to 1 for --get-user-env to load user environment without login.])
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_RESULT([no])
 fi
 
 dnl
@@ -249,6 +257,12 @@ AM_CONDITIONAL(WITH_AUTHD, test "x$have_authd" = "xyes")
 LIBS="$savedLIBS"
 CFLAGS="$savedCFLAGS"
 
+savedLIBS="$LIBS"
+LIBS="-lutil $LIBS"
+AC_CHECK_LIB(util, openpty, [UTIL_LIBS="-lutil"], [])
+AC_SUBST(UTIL_LIBS)
+LIBS="$savedLIBS"
+
 dnl Add LSD-Tools defines:
 AC_DEFINE(WITH_LSD_FATAL_ERROR_FUNC, 1, [Have definition of lsd_fatal_error()])
 AC_DEFINE(WITH_LSD_NOMEM_ERROR_FUNC, 1, [Have definition of lsd_nomem_error()])
@@ -262,18 +276,24 @@ AC_CONFIG_FILES([Makefile
 		 contribs/perlapi/Makefile
 		 contribs/perlapi/libslurm-perl/Makefile.PL
 		 contribs/torque/Makefile
+		 contribs/phpext/Makefile
+		 contribs/phpext/slurm_php/config.m4
 		 src/Makefile 
 		 src/api/Makefile 
 		 src/common/Makefile
+		 src/database/Makefile
 		 src/sacct/Makefile
+		 src/sacctmgr/Makefile
+		 src/sreport/Makefile
+		 src/sstat/Makefile
 		 src/salloc/Makefile 
 		 src/sbatch/Makefile 
 		 src/sattach/Makefile
 		 src/srun/Makefile 
-		 src/slaunch/Makefile 
 		 src/slurmd/Makefile 
 		 src/slurmd/slurmd/Makefile 
 		 src/slurmd/slurmstepd/Makefile 
+		 src/slurmdbd/Makefile
 		 src/slurmctld/Makefile
 		 src/sbcast/Makefile 
 		 src/scontrol/Makefile
@@ -284,6 +304,13 @@ AC_CONFIG_FILES([Makefile
 		 src/strigger/Makefile
 		 src/sview/Makefile
 		 src/plugins/Makefile
+		 src/plugins/accounting_storage/Makefile
+		 src/plugins/accounting_storage/filetxt/Makefile
+		 src/plugins/accounting_storage/gold/Makefile
+		 src/plugins/accounting_storage/mysql/Makefile
+		 src/plugins/accounting_storage/pgsql/Makefile
+		 src/plugins/accounting_storage/none/Makefile
+		 src/plugins/accounting_storage/slurmdbd/Makefile
 		 src/plugins/auth/Makefile
 		 src/plugins/auth/authd/Makefile
 		 src/plugins/auth/munge/Makefile
@@ -292,15 +319,21 @@ AC_CONFIG_FILES([Makefile
 		 src/plugins/checkpoint/aix/Makefile
 		 src/plugins/checkpoint/none/Makefile
 		 src/plugins/checkpoint/ompi/Makefile
-		 src/plugins/jobacct/Makefile
-		 src/plugins/jobacct/linux/Makefile
-		 src/plugins/jobacct/aix/Makefile
-		 src/plugins/jobacct/none/Makefile
-		 src/plugins/jobacct/gold/Makefile
+		 src/plugins/checkpoint/xlch/Makefile
+		 src/plugins/crypto/Makefile
+		 src/plugins/crypto/munge/Makefile
+		 src/plugins/crypto/openssl/Makefile
+		 src/plugins/jobacct_gather/Makefile
+		 src/plugins/jobacct_gather/linux/Makefile
+		 src/plugins/jobacct_gather/aix/Makefile
+		 src/plugins/jobacct_gather/none/Makefile
 		 src/plugins/jobcomp/Makefile
 		 src/plugins/jobcomp/filetxt/Makefile
 		 src/plugins/jobcomp/none/Makefile
 		 src/plugins/jobcomp/script/Makefile
+		 src/plugins/jobcomp/mysql/Makefile
+		 src/plugins/jobcomp/pgsql/Makefile
+		 src/plugins/jobcomp/slurmdbd/Makefile
 		 src/plugins/proctrack/Makefile
 		 src/plugins/proctrack/aix/Makefile
 		 src/plugins/proctrack/pgid/Makefile
diff --git a/contribs/Makefile.am b/contribs/Makefile.am
index bd2f2097f47c3dcf947abdfb70281ad7c943ac29..77afcd59aac66e5b969cbc10a28d387b048fb3cd 100644
--- a/contribs/Makefile.am
+++ b/contribs/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = perlapi torque
+SUBDIRS = perlapi phpext torque 
 
 EXTRA_DIST = \
 	env_cache_builder.c	\
diff --git a/contribs/Makefile.in b/contribs/Makefile.in
index 60186dd7935fd99003a71a496d36ffdb2a2bc724..dffadf88374f2f6a320014b061c945b450afe30f 100644
--- a/contribs/Makefile.in
+++ b/contribs/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -99,6 +101,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -112,10 +115,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -135,7 +141,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -146,6 +155,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -161,6 +172,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -176,6 +188,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -232,7 +245,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = perlapi torque
+SUBDIRS = perlapi phpext torque 
 EXTRA_DIST = \
 	env_cache_builder.c	\
 	make.slurm.patch	\
@@ -355,8 +368,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -381,8 +394,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -392,13 +405,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/contribs/env_cache_builder.c b/contribs/env_cache_builder.c
index f13d7f8e799a3e1e9c121125f8a42b7c26b782ed..d8560d104ee6e01c60d499a21b3f7711db8d976a 100644
--- a/contribs/env_cache_builder.c
+++ b/contribs/env_cache_builder.c
@@ -1,23 +1,33 @@
 /*****************************************************************************\
+ *  On the cluster's control host as user root, execute:
+ *    make -f /dev/null env_cache_builder
+ *    ./env_cache_builder
+ *****************************************************************************
  *  This program is used to build an environment variable cache file for use
  *  with the srun/sbatch --get-user-env option, which is used by Moab to launch
  *  user jobs. srun/sbatch will first attempt to load the user's current 
  *  environment by executing "su - <user> -c env". If that fails to complete
- *  in a relatively short period of time (currently 8 seconds), srun/sbatch
+ *  in a relatively short period of time (currently 3 seconds), srun/sbatch
  *  will attempt to load the user's environment from a cache file located 
  *  in the directory StateSaveLocation with a name of the sort "env_<user>".
  *  If that fails, then abort the job request.
  *
  *  This program can accept a space delimited list of individual users to have
  *  cache files created (e.g. "cache_build alice bob chuck"). If no argument
- *  is given, cache files will be created for all users.
- *
- *  This program must execute as user root. 
+ *  is given, cache files will be created for all users in the "/etc/passwd"
+ *  file. If you see "ERROR" in the output, it means that the user's 
+ *  environment could not be loaded automatically, typically because their
+ *  dot files spawn some other shell. You must explicitly login as the user,
+ *  execute "env" and write the output to a file having the same name as the
+ *  user in a subdirectory of the configured StateSaveLocation named "env_cache"
+ *  (e.g. "/tmp/slurm/env_cache/alice"). The file is only needed on the node
+ *  where the Moab daemon executes, typically the control host.
  *****************************************************************************
- *  Copyright (C) 2007-2008 The Regents of the University of California.
+ *  Copyright (C) 2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -64,16 +74,20 @@
 
 static long int	_build_cache(char *user_name, char *cache_dir);
 static int	_get_cache_dir(char *buffer, int buf_size);
+static void	_log_failures(int failures, char *cache_dir);
 static int	_parse_line(char *in_line, char **user_name, int *user_id);
 
+char *env_loc = NULL;
+
 main (int argc, char **argv)
 {
 	FILE *passwd_fd;
 	char cache_dir[256], in_line[256], *user_name;
-	int i, user_id;
+	int i, failures = 0, user_cnt = 0, user_id;
 	long int delta_t;
+	struct stat buf;
 
-	if (geteuid() != (uid_t)0) {
+	if (geteuid() != (uid_t) 0) {
 		printf("Need to run as user root\n");
 		exit(1);
 	}
@@ -86,16 +100,45 @@ main (int argc, char **argv)
 			strerror(errno));
 		exit(1);
 	}
-	printf("cache_dir=%s\n", cache_dir);
+
+	if (stat("/bgl", &buf) == 0) {
+		printf("BlueGene Note: Execute only a a front-end node, "
+			"not the service node\n");
+		printf("               User logins to the service node are "
+			"disabled\n\n");
+	}
+	if (stat("/bin/su", &buf)) {
+		printf("Could not locate command: /bin/su\n");
+		exit(1);
+	}
+	if (stat("/bin/echo", &buf)) {
+		printf("Could not locate command: /bin/echo\n");
+		exit(1);
+	}
+	if (stat("/bin/env", &buf) == 0)
+		env_loc = "/bin/env";
+	else if (stat("/usr/bin/env", &buf) == 0)
+		env_loc = "/usr/bin/env";
+	else {
+		printf("Could not location command: env\n");
+		exit(1);
+	}
+
+	printf("Building user environment cache files for Moab/Slurm.\n");
+	printf("This will take a while.\n\n");
 
 	for (i=1; i<argc; i++) {
 		delta_t = _build_cache(argv[i], cache_dir);
+		if (delta_t == -1)
+			failures++;
 		if (delta_t < ((SU_WAIT_MSEC * 0.8) * 1000))
 			continue;
 		printf("WARNING: user %-8s time %ld usec\n", argv[i], delta_t);
 	}
-	if (i > 1)
+	if (i > 1) {
+		_log_failures(failures, cache_dir);
 		exit(0);
+	}
 
 	passwd_fd = fopen("/etc/passwd", "r");
 	if (!passwd_fd) {
@@ -109,11 +152,33 @@ main (int argc, char **argv)
 		if (user_id <= 100)
 			continue;
 		delta_t = _build_cache(user_name, cache_dir);
+		if (delta_t == -1)
+			failures++;
+		user_cnt++;
+		if ((user_cnt % 100) == 0)
+			printf("Processed %d users...\n", user_cnt);
 		if (delta_t < ((SU_WAIT_MSEC * 0.8) * 1000))
 			continue;
 		printf("WARNING: user %-8s time %ld usec\n", user_name, delta_t);
 	}
 	fclose(passwd_fd);
+	_log_failures(failures, cache_dir);
+}
+
+static void _log_failures(int failures, char *cache_dir)
+{
+	if (failures) {
+		printf("\n");
+		printf("Some user environments could not be loaded.\n");
+		printf("Manually run 'env' for those %d users.\n",
+			failures);
+		printf("Write the output to a file with the same name as "
+			"the user in the\n %s directory\n", cache_dir);
+	} else {
+		printf("\n");
+		printf("All user environments successfully loaded.\n");
+		printf("Files written to the %s directory\n", cache_dir);
+	}
 }
 
 /* Given a line from /etc/passwd, sets the user_name and user_id
@@ -192,8 +257,8 @@ static long int _build_cache(char *user_name, char *cache_dir)
 		open("/dev/null", O_WRONLY);
 		snprintf(buffer, sizeof(buffer),
 			 "/bin/echo; /bin/echo; /bin/echo; "
-			 "/bin/echo %s; /bin/env; /bin/echo %s",
-			 starttoken, stoptoken);
+			 "/bin/echo %s; %s; /bin/echo %s",
+			 starttoken, env_loc, stoptoken);
 #ifdef LOAD_ENV_NO_LOGIN
 		execl("/bin/su", "su", user_name, "-c", buffer, NULL);
 #else
@@ -272,7 +337,7 @@ static long int _build_cache(char *user_name, char *cache_dir)
 	}
 	close(fildes[0]);
 	if (!found) {
-		printf("ERROR: Failed to load current user environment "
+		printf("***ERROR: Failed to load current user environment "
 			"variables for %s\n", user_name);
 		return -1;
 	}
@@ -289,7 +354,7 @@ static long int _build_cache(char *user_name, char *cache_dir)
 		line = strtok_r(NULL, "\n", &last);
 	}
 	if (!found) {
-		printf("ERROR: Failed to get current user environment "
+		printf("***ERROR: Failed to get current user environment "
 			"variables for %s\n", user_name);
 		return -1;
 	}
@@ -327,7 +392,7 @@ static long int _build_cache(char *user_name, char *cache_dir)
 	delta_t  = (now.tv_sec  - begin.tv_sec)  * 1000000;
 	delta_t +=  now.tv_usec - begin.tv_usec;
 	if (!found) {
-		printf("ERROR: Failed to write all user environment "
+		printf("***ERROR: Failed to write all user environment "
 			"variables for %s\n", user_name);
 		if (delta_t < (SU_WAIT_MSEC * 1000))
 			return (SU_WAIT_MSEC * 1000);
diff --git a/contribs/perlapi/Makefile.in b/contribs/perlapi/Makefile.in
index c11e027f830e6ff47d4f46d9121a28d0867d9496..b8783c52163c232bd8153a9be636def94b78eb7e 100644
--- a/contribs/perlapi/Makefile.in
+++ b/contribs/perlapi/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -87,6 +89,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -100,10 +103,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -123,7 +129,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -134,6 +143,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -149,6 +160,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -164,6 +176,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
diff --git a/contribs/perlapi/libslurm-perl/Slurm.xs b/contribs/perlapi/libslurm-perl/Slurm.xs
index 3f7a91f524aac79295ba8e0d202d0527df336744..b92833d1f00ebe08e41e4970365180e4643dad73 100644
--- a/contribs/perlapi/libslurm-perl/Slurm.xs
+++ b/contribs/perlapi/libslurm-perl/Slurm.xs
@@ -6,6 +6,8 @@
 
 #include <slurm/slurm.h>
 #include <signal.h>
+#include <string.h>
+#include <unistd.h>
 #include "msg.h"
 
 #include "const-c.inc"
@@ -999,7 +1001,13 @@ slurm_step_launch(slurm_step_ctx ctx = NULL, HV* hv = NULL, SV* start_cb = NULL,
 		if(hv_to_slurm_step_launch_params(hv, &params) < 0) {
 			RETVAL = SLURM_ERROR;
 		} else {
-			RETVAL = slurm_step_launch(ctx, &params, &callbacks);
+			char *dot_ptr, launcher_host[1024];
+			gethostname(launcher_host, sizeof(launcher_host));
+			dot_ptr = strchr(launcher_host, '.');
+			if (dot_ptr)
+				dot_ptr[0] = '\0';
+			RETVAL = slurm_step_launch(ctx, launcher_host,
+						   &params, &callbacks);
 		}
 	OUTPUT:
 		RETVAL
diff --git a/contribs/perlapi/libslurm-perl/alloc.c b/contribs/perlapi/libslurm-perl/alloc.c
index 944e25429e4b4e5943753f3e9c3bf83fb90bda99..0ca22566ad8507b8a9e043ba5038d444e7795726 100644
--- a/contribs/perlapi/libslurm-perl/alloc.c
+++ b/contribs/perlapi/libslurm-perl/alloc.c
@@ -61,7 +61,6 @@ hv_to_job_desc_msg(HV* hv, job_desc_msg_t* job_desc_msg)
 	FETCH_FIELD(hv, job_desc_msg, job_min_cores, uint16_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, job_min_threads, uint16_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, job_min_memory, uint16_t, FALSE);
-	FETCH_FIELD(hv, job_desc_msg, job_max_memory, uint16_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, job_min_tmp_disk, uint16_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, partition, charp, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, priority, uint32_t, FALSE);
@@ -89,7 +88,7 @@ hv_to_job_desc_msg(HV* hv, job_desc_msg_t* job_desc_msg)
 			argv_av = (AV*)SvRV(*svp);
 			job_desc_msg->argc = av_len(argv_av) + 1;
 			if (job_desc_msg->argc > 0) {
-				Newz(0, job_desc_msg->argv, job_desc_msg->argc + 1, char*);
+				Newz(0, job_desc_msg->argv, (int32_t)(job_desc_msg->argc + 1), char*);
 				for(i = 0; i < job_desc_msg->argc; i ++) {
 					if((svp = av_fetch(argv_av, i, FALSE)))
 						*(job_desc_msg->argv + i) = (char*) SvPV_nolen(*svp);
@@ -112,11 +111,10 @@ hv_to_job_desc_msg(HV* hv, job_desc_msg_t* job_desc_msg)
 	FETCH_FIELD(hv, job_desc_msg, work_dir, charp, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, alloc_node, charp, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, alloc_sid, uint32_t, FALSE);
-	FETCH_FIELD(hv, job_desc_msg, alloc_resp_hostname, charp, FALSE);
+	FETCH_FIELD(hv, job_desc_msg, resp_host, charp, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, alloc_resp_port, uint16_t, FALSE);
-	FETCH_FIELD(hv, job_desc_msg, other_hostname, charp, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, other_port, uint16_t, FALSE);
-	FETCH_FIELD(hv, job_desc_msg, dependency, uint32_t, FALSE);
+	FETCH_FIELD(hv, job_desc_msg, dependency, charp, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, overcommit, uint16_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, num_tasks, uint32_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, nice, uint16_t, FALSE);
@@ -128,7 +126,7 @@ hv_to_job_desc_msg(HV* hv, job_desc_msg_t* job_desc_msg)
 	FETCH_FIELD(hv, job_desc_msg, begin_time, time_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, mail_type, uint16_t, FALSE);
 	FETCH_FIELD(hv, job_desc_msg, mail_user, charp, FALSE);
-	FETCH_FIELD(hv, job_desc_msg, no_requeue, uint16_t, FALSE);
+	FETCH_FIELD(hv, job_desc_msg, requeue, uint16_t, FALSE);
 	/* geometry */
 #if SYSTEM_DIMENSIONS
 	if((svp = hv_fetch(hv, "geometry", 8, FALSE))) {
diff --git a/contribs/perlapi/libslurm-perl/conf.c b/contribs/perlapi/libslurm-perl/conf.c
index 12d4a4e6b9131b7776ead46aa989a1e288292b58..a4a2e91ea29fc7203ab9eaf5ce5a825505726c1f 100644
--- a/contribs/perlapi/libslurm-perl/conf.c
+++ b/contribs/perlapi/libslurm-perl/conf.c
@@ -23,6 +23,7 @@ slurm_ctl_conf_to_hv(slurm_ctl_conf_t* conf, HV* hv)
 		STORE_FIELD(hv, conf, backup_addr, charp);
 	if(conf->backup_controller)
 		STORE_FIELD(hv, conf, backup_controller, charp);
+	STORE_FIELD(hv, conf, boot_time, time_t);
 	STORE_FIELD(hv, conf, cache_groups, uint16_t);
 	if(conf->checkpoint_type)
 		STORE_FIELD(hv, conf, checkpoint_type, charp);
@@ -30,21 +31,40 @@ slurm_ctl_conf_to_hv(slurm_ctl_conf_t* conf, HV* hv)
 		STORE_FIELD(hv, conf, control_addr, charp);
 	if(conf->control_machine)
 		STORE_FIELD(hv, conf, control_machine, charp);
+	if(conf->crypto_type)
+		STORE_FIELD(hv, conf, crypto_type, charp);
 	if(conf->epilog)
 		STORE_FIELD(hv, conf, epilog, charp);
 	STORE_FIELD(hv, conf, first_job_id, uint32_t);
 	STORE_FIELD(hv, conf, next_job_id, uint32_t);
 	STORE_FIELD(hv, conf, fast_schedule, uint16_t);
 	STORE_FIELD(hv, conf, inactive_limit, uint16_t);
-	if(conf->job_acct_logfile)
-		STORE_FIELD(hv, conf, job_acct_logfile, charp);
-	STORE_FIELD(hv, conf, job_acct_freq, uint16_t);
-	if(conf->job_acct_type)
-		STORE_FIELD(hv, conf, job_acct_type, charp);
-	if(conf->job_comp_type)
-		STORE_FIELD(hv, conf, job_comp_type, charp);
+	if(conf->job_acct_gather_type)
+		STORE_FIELD(hv, conf, job_acct_gather_type, charp);
+	STORE_FIELD(hv, conf, job_acct_gather_freq, uint16_t);
+	if(conf->accounting_storage_loc)
+		STORE_FIELD(hv, conf, accounting_storage_loc, charp);
+	if(conf->accounting_storage_type)
+		STORE_FIELD(hv, conf, accounting_storage_type, charp);
+	if(conf->accounting_storage_user)
+		STORE_FIELD(hv, conf, accounting_storage_user, charp);
+	if(conf->accounting_storage_host)
+		STORE_FIELD(hv, conf, accounting_storage_host, charp);
+	if(conf->accounting_storage_pass)
+		STORE_FIELD(hv, conf, accounting_storage_pass, charp);
+	STORE_FIELD(hv, conf, accounting_storage_port, uint32_t);
 	if(conf->job_comp_loc)
 		STORE_FIELD(hv, conf, job_comp_loc, charp);
+	if(conf->job_comp_type)
+		STORE_FIELD(hv, conf, job_comp_type, charp);
+	if(conf->job_comp_user)
+		STORE_FIELD(hv, conf, job_comp_user, charp);
+	if(conf->job_comp_host)
+		STORE_FIELD(hv, conf, job_comp_host, charp);
+	if(conf->job_comp_pass)
+		STORE_FIELD(hv, conf, job_comp_pass, charp);
+	STORE_FIELD(hv, conf, job_comp_port, uint32_t);
+	STORE_FIELD(hv, conf, job_file_append, uint16_t); 
 	STORE_FIELD(hv, conf, kill_wait, uint16_t);
 	if(conf->mail_prog)
 		STORE_FIELD(hv, conf, mail_prog, charp);
@@ -57,6 +77,7 @@ slurm_ctl_conf_to_hv(slurm_ctl_conf_t* conf, HV* hv)
 		STORE_FIELD(hv, conf, plugindir, charp);
 	if(conf->plugstack)
 		STORE_FIELD(hv, conf, plugstack, charp);
+	STORE_FIELD(hv, conf, private_data, uint16_t);
 	if(conf->proctrack_type)
 		STORE_FIELD(hv, conf, proctrack_type, charp);
 	if(conf->prolog)
@@ -67,6 +88,9 @@ slurm_ctl_conf_to_hv(slurm_ctl_conf_t* conf, HV* hv)
 	if(conf->propagate_rlimits_except)
 		STORE_FIELD(hv, conf, propagate_rlimits_except, charp);
 	STORE_FIELD(hv, conf, ret2service, uint16_t);
+	STORE_FIELD(hv, conf, resume_rate, uint16_t);
+	if(conf->resume_program)
+		STORE_FIELD(hv, conf, resume_program, charp);
 	if(conf->schedtype)
 		STORE_FIELD(hv, conf, schedtype, charp);
 	STORE_FIELD(hv, conf, schedport, uint16_t);
@@ -97,6 +121,14 @@ slurm_ctl_conf_to_hv(slurm_ctl_conf_t* conf, HV* hv)
 		STORE_FIELD(hv, conf, slurm_conf, charp);
 	if(conf->state_save_location)
 		STORE_FIELD(hv, conf, state_save_location, charp);
+	if(conf->suspend_exc_nodes)
+		STORE_FIELD(hv, conf, suspend_exc_nodes, charp);
+	if(conf->suspend_exc_parts)
+		STORE_FIELD(hv, conf, suspend_exc_parts, charp);
+	if(conf->suspend_program)
+		STORE_FIELD(hv, conf, suspend_program, charp);
+	STORE_FIELD(hv, conf, suspend_rate, uint16_t);
+	STORE_FIELD(hv, conf, suspend_time, uint16_t);
 	if(conf->switch_type)
 		STORE_FIELD(hv, conf, switch_type, charp);
 	if(conf->task_epilog)
@@ -121,6 +153,9 @@ slurm_ctl_conf_to_hv(slurm_ctl_conf_t* conf, HV* hv)
 		STORE_FIELD(hv, conf, node_prefix, charp);
 	STORE_FIELD(hv, conf, tree_width, uint16_t);
 	STORE_FIELD(hv, conf, use_pam, uint16_t);
+	if(conf->unkillable_program)
+		STORE_FIELD(hv, conf, unkillable_program, charp);
+	STORE_FIELD(hv, conf, unkillable_timeout, uint16_t);
 	return 0;
 }
 
diff --git a/contribs/perlapi/libslurm-perl/job.c b/contribs/perlapi/libslurm-perl/job.c
index b84d60e303eeeb0c60e48b5abab78aaf7fa67694..f08d76db91dfd6d5bd6490817c502c7ce40aad85 100644
--- a/contribs/perlapi/libslurm-perl/job.c
+++ b/contribs/perlapi/libslurm-perl/job.c
@@ -78,7 +78,6 @@ job_info_to_hv(job_info_t* job_info, HV* hv)
 	STORE_FIELD(hv, job_info, job_min_cores, uint16_t);
 	STORE_FIELD(hv, job_info, job_min_threads, uint16_t);
 	STORE_FIELD(hv, job_info, job_min_memory, uint32_t);
-	STORE_FIELD(hv, job_info, job_max_memory, uint32_t);
 	STORE_FIELD(hv, job_info, job_min_tmp_disk, uint32_t);
 	if(job_info->req_nodes)
 		STORE_FIELD(hv, job_info, req_nodes, charp);
@@ -88,7 +87,7 @@ job_info_to_hv(job_info_t* job_info, HV* hv)
 	/* TODO: exc_node_inx */
 	if(job_info->features)
 		STORE_FIELD(hv, job_info, features, charp);
-	STORE_FIELD(hv, job_info, dependency, uint32_t);
+	STORE_FIELD(hv, job_info, dependency, charp);
 	STORE_FIELD(hv, job_info, exit_code, uint32_t);
 	if(job_info->account)
 		STORE_FIELD(hv, job_info, account, charp);
diff --git a/contribs/perlapi/libslurm-perl/launch.c b/contribs/perlapi/libslurm-perl/launch.c
index f17beae5475be5e2e6cff79a9e2ffca2d9bf9b8d..e5901cb97b8561fc33a22938931a73627ab818c5 100644
--- a/contribs/perlapi/libslurm-perl/launch.c
+++ b/contribs/perlapi/libslurm-perl/launch.c
@@ -29,6 +29,7 @@ hv_to_slurm_step_ctx_params(HV* hv, slurm_step_ctx_params_t* params)
 	FETCH_FIELD(hv, params, node_list, charp, FALSE);
 	FETCH_FIELD(hv, params, network, charp, FALSE);
 	FETCH_FIELD(hv, params, overcommit, bool, FALSE);
+	FETCH_FIELD(hv, params, mem_per_task, uint16_t, FALSE);
 	return 0;
 }
 
@@ -54,7 +55,7 @@ hv_to_slurm_step_launch_params(HV* hv, slurm_step_launch_params_t* params)
 			argv_av = (AV*)SvRV(*svp);
 			params->argc = av_len(argv_av) + 1;
 			if (params->argc > 0) {
-				Newz(0, params->argv, params->argc + 1, char*);
+				Newz(0, params->argv, (int32_t)(params->argc + 1), char*);
 				for(i = 0; i < params->argc; i ++) {
 					if((svp = av_fetch(argv_av, i, FALSE)))
 						*(params->argv + i) = (char*) SvPV_nolen(*svp);
@@ -95,6 +96,7 @@ hv_to_slurm_step_launch_params(HV* hv, slurm_step_launch_params_t* params)
 	}
 	FETCH_FIELD(hv, params, cwd, charp, FALSE);
 	FETCH_FIELD(hv, params, user_managed_io, bool, FALSE);
+	FETCH_FIELD(hv, params, msg_timeout, uint32_t, FALSE);
 	FETCH_FIELD(hv, params, buffered_stdio, bool, FALSE);
 	FETCH_FIELD(hv, params, labelio, bool, FALSE);
 	FETCH_FIELD(hv, params, remote_output_filename, charp, FALSE);
diff --git a/contribs/perlapi/libslurm-perl/partition.c b/contribs/perlapi/libslurm-perl/partition.c
index 9dd8ea1026271592ebc348a28c986e7760890e95..f0f2b30deb24a6645a93bff3e616b7c5094a1f8b 100644
--- a/contribs/perlapi/libslurm-perl/partition.c
+++ b/contribs/perlapi/libslurm-perl/partition.c
@@ -30,7 +30,7 @@ part_info_to_hv(partition_info_t* part_info, HV* hv)
 	STORE_FIELD(hv, part_info, default_part, uint16_t);
 	STORE_FIELD(hv, part_info, hidden, uint16_t);
 	STORE_FIELD(hv, part_info, root_only, uint16_t);
-	STORE_FIELD(hv, part_info, shared, uint16_t);
+	STORE_FIELD(hv, part_info, max_share, uint16_t);
 	STORE_FIELD(hv, part_info, state_up, uint16_t);
 	if (part_info->nodes)
 		STORE_FIELD(hv, part_info, nodes, charp);
@@ -81,7 +81,7 @@ hv_to_update_part_msg(HV* hv, update_part_msg_t* part_msg)
 	FETCH_FIELD(hv, part_msg, default_part, uint16_t, FALSE);
 	FETCH_FIELD(hv, part_msg, hidden, uint16_t, FALSE);
 	FETCH_FIELD(hv, part_msg, root_only, uint16_t, FALSE);
-	FETCH_FIELD(hv, part_msg, shared, uint16_t, FALSE);
+	FETCH_FIELD(hv, part_msg, max_share, uint16_t, FALSE);
 	FETCH_FIELD(hv, part_msg, state_up, uint16_t, FALSE);
 	FETCH_FIELD(hv, part_msg, nodes, charp, FALSE);
 	/* node_inx not used */
diff --git a/contribs/perlapi/libslurm-perl/trigger.c b/contribs/perlapi/libslurm-perl/trigger.c
index 29dae41192a828bc8328f86d7630fc3040a56e08..56f65162a483db281d6512a4170e897dff23e157 100644
--- a/contribs/perlapi/libslurm-perl/trigger.c
+++ b/contribs/perlapi/libslurm-perl/trigger.c
@@ -16,7 +16,7 @@ int
 trigger_info_to_hv(trigger_info_t* trigger_info, HV* hv)
 {
 	STORE_FIELD(hv, trigger_info, trig_id, uint32_t);
-	STORE_FIELD(hv, trigger_info, res_type, uint8_t);
+	STORE_FIELD(hv, trigger_info, res_type, uint16_t);
 	if(trigger_info->res_id)
 		STORE_FIELD(hv, trigger_info, res_id, charp);
 	STORE_FIELD(hv, trigger_info, trig_type, uint16_t);
diff --git a/contribs/phpext/Makefile.am b/contribs/phpext/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..365ea0c5e3eaa3171bc7f72d160db1766b71a173
--- /dev/null
+++ b/contribs/phpext/Makefile.am
@@ -0,0 +1,48 @@
+AUTOMAKE_OPTIONS = foreign
+php_dir = slurm_php
+phpize = /usr/bin/phpize
+
+if HAVE_AIX
+	add_flags = "CC=\"$(CC)\" CCFLAGS=\"-g -static $(CFLAGS)\""
+else
+	add_flags = "CC=\"$(CC)\" LD=\"$(CC) $(CFLAGS)\" CCFLAGS=\"-g -static $(CFLAGS)\""
+endif
+
+all-local:
+	@cd $(php_dir) && \
+	if [ ! -f Makefile ]; then \
+		if [ ! -f configure ]; then \
+			$(phpize); \
+		fi && \
+		./configure ; \
+		if [ ! -f Makefile ]; then \
+			exit 0;\
+		fi \
+	fi && \
+	$(MAKE) $(add_flags); \
+	cd ..;	
+
+install-exec-local:
+	@cd $(php_dir) && \
+	if [ ! -f Makefile ]; then \
+		exit 0;\
+	fi && \
+	$(MAKE) INSTALL_ROOT=$(DESTDIR) $(add_flags) install && \
+	cd ..;
+
+clean-generic:
+	@cd $(php_dir); \
+	if [ ! -f Makefile ]; then \
+		exit 0;\
+	fi && \
+	$(MAKE) clean; \
+	cd ..;
+
+distclean-generic:
+	@cd $(php_dir); \
+	if [ ! -f Makefile ]; then \
+		exit 0;\
+	fi && \
+	$(MAKE) clean; \
+	$(phpize) --clean; \
+	cd ..;
diff --git a/contribs/phpext/Makefile.in b/contribs/phpext/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..6f94c4de3981f15d1d4aca427ac1e1fc9aa7d52c
--- /dev/null
+++ b/contribs/phpext/Makefile.in
@@ -0,0 +1,445 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = contribs/phpext
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+php_dir = slurm_php
+phpize = /usr/bin/phpize
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  contribs/phpext/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  contribs/phpext/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile all-local
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-exec-local
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am all-local check check-am clean clean-generic \
+	clean-libtool distclean distclean-generic distclean-libtool \
+	distdir dvi dvi-am html html-am info info-am install \
+	install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-exec-local \
+	install-html install-html-am install-info install-info-am \
+	install-man install-pdf install-pdf-am install-ps \
+	install-ps-am install-strip installcheck installcheck-am \
+	installdirs maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+	ps ps-am uninstall uninstall-am
+
+
+@HAVE_AIX_TRUE@	add_flags = "CC=\"$(CC)\" CCFLAGS=\"-g -static $(CFLAGS)\""
+@HAVE_AIX_FALSE@	add_flags = "CC=\"$(CC)\" LD=\"$(CC) $(CFLAGS)\" CCFLAGS=\"-g -static $(CFLAGS)\""
+
+all-local:
+	@cd $(php_dir) && \
+	if [ ! -f Makefile ]; then \
+		if [ ! -f configure ]; then \
+			$(phpize); \
+		fi && \
+		./configure ; \
+		if [ ! -f Makefile ]; then \
+			exit 0;\
+		fi \
+	fi && \
+	$(MAKE) $(add_flags); \
+	cd ..;	
+
+install-exec-local:
+	@cd $(php_dir) && \
+	if [ ! -f Makefile ]; then \
+		exit 0;\
+	fi && \
+	$(MAKE) INSTALL_ROOT=$(DESTDIR) $(add_flags) install && \
+	cd ..;
+
+clean-generic:
+	@cd $(php_dir); \
+	if [ ! -f Makefile ]; then \
+		exit 0;\
+	fi && \
+	$(MAKE) clean; \
+	cd ..;
+
+distclean-generic:
+	@cd $(php_dir); \
+	if [ ! -f Makefile ]; then \
+		exit 0;\
+	fi && \
+	$(MAKE) clean; \
+	$(phpize) --clean; \
+	cd ..;
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/contribs/phpext/README b/contribs/phpext/README
new file mode 100644
index 0000000000000000000000000000000000000000..30b88ccf7480d83c664c18795aa811bd88fd97be
--- /dev/null
+++ b/contribs/phpext/README
@@ -0,0 +1,21 @@
+README for the php extension for SLURM.
+
+This was made primarily for SLURMWEB to connect to slurm.  Any extra
+interactions are welcome.
+
+to compile...
+
+phpize
+./configure
+make
+
+this should make modules/slurm_php.so
+
+make install as root
+should install this where your extensions are in your php install
+
+in your php.ini file add the line
+
+extension=slurm.so
+
+and you should be able to use the functions here.
diff --git a/contribs/phpext/slurm_php/config.m4.in b/contribs/phpext/slurm_php/config.m4.in
new file mode 100644
index 0000000000000000000000000000000000000000..51f80485749812264ca4f1cbebfdfca15b64359a
--- /dev/null
+++ b/contribs/phpext/slurm_php/config.m4.in
@@ -0,0 +1,59 @@
+##*****************************************************************************
+## $Id: config.m4 8863 2006-08-10 18:47:55Z da $
+##*****************************************************************************
+#  AUTHOR:
+#    Danny Auble <da@llnl.gov>
+#
+#  DESCRIPTION:
+#    Use to make the php slurm extension
+##*****************************************************************************
+PHP_ARG_WITH(slurm, whether to use slurm,
+[ --with-slurm SLURM install dir])
+	
+if test "$PHP_SLURM" != "no"; then
+	SLURMLIB_PATH="@prefix@/lib @top_builddir@/src/api/.libs"
+	SLURMINCLUDE_PATH="@prefix@/include"
+	SEARCH_FOR="libslurm.so"
+    	
+        # --with-libslurm -> check with-path
+	
+	if test -r $PHP_SLURM/; then # path given as parameter
+		SLURM_DIR=$PHP_SLURM
+		SLURMLIB_PATH="$SLURM_DIR/lib"
+	else # search default path list
+		AC_MSG_CHECKING([for libslurm.so in default paths])
+		for i in $SLURMLIB_PATH ; do
+			if test -r $i/$SEARCH_FOR; then
+				SLURM_DIR=$i
+				PHP_ADD_LIBPATH($i, SLURM_PHP_SHARED_LIBADD)
+    
+				AC_MSG_RESULT([found in $i])
+				
+			fi
+		done
+	fi
+	
+	if test -z "$SLURM_DIR"; then
+		AC_MSG_RESULT([not found])
+		AC_MSG_ERROR([Please reinstall the slurm distribution])
+	fi
+	
+	PHP_ADD_INCLUDE($SLURMINCLUDE_PATH)
+	PHP_ADD_INCLUDE(@top_srcdir@)
+	
+	LIBNAME=slurm
+	LIBSYMBOL=slurm_acct_storage_init
+	
+	PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
+		[PHP_ADD_LIBRARY($LIBNAME, , SLURM_PHP_SHARED_LIBADD)
+    			AC_DEFINE(HAVE_SLURMLIB,1,[ ])],
+		[AC_MSG_ERROR([wrong libslurm version or lib not found])],
+		[-L$SLURM_DIR -lslurm])
+	
+	
+	PHP_SUBST(SLURM_PHP_SHARED_LIBADD)
+	
+	AC_DEFINE(HAVE_SLURM_PHP, 1, [Whether you have SLURM])
+	#PHP_EXTENSION(slurm_php, $ext_shared)
+	PHP_NEW_EXTENSION(slurm_php, @top_srcdir@/contribs/phpext/slurm_php/slurm_php.c, $ext_shared)
+fi
diff --git a/contribs/phpext/slurm_php/slurm_php.c b/contribs/phpext/slurm_php/slurm_php.c
new file mode 100644
index 0000000000000000000000000000000000000000..14e9690bdb3b08fc2f2ca0dbe6eac5098618dda4
--- /dev/null
+++ b/contribs/phpext/slurm_php/slurm_php.c
@@ -0,0 +1,100 @@
+/*****************************************************************************\
+ *  slurm_php.c - php interface to slurm.
+ *
+ *  $Id: account_gold.c 13061 2008-01-22 21:23:56Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "slurm_php.h"
+#include "slurm/slurm.h"
+#include "src/common/list.h"
+
+static function_entry slurm_functions[] = {
+    PHP_FE(hello_world, NULL)
+    PHP_FE(print_partitions, NULL)
+    {NULL, NULL, NULL}
+};
+
+zend_module_entry slurm_php_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+    STANDARD_MODULE_HEADER,
+#endif
+    SLURM_PHP_EXTNAME,
+    slurm_functions,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+#if ZEND_MODULE_API_NO >= 20010901
+    SLURM_PHP_VERSION,
+#endif
+    STANDARD_MODULE_PROPERTIES
+};
+
+#ifdef COMPILE_DL_SLURM_PHP
+ZEND_GET_MODULE(slurm_php)
+#endif
+
+PHP_FUNCTION(hello_world)
+{
+    RETURN_STRING("Hello World\n", 1);
+}
+
+PHP_FUNCTION(print_partitions)
+{
+	List sinfo_list = NULL;
+	int error_code = SLURM_SUCCESS;
+	uint16_t show_flags = 0;
+	static partition_info_msg_t *new_part_ptr;
+	printf("hey\n");
+	slurm_info("got here!");
+	printf("hey\n");
+	error_code = slurm_load_partitions((time_t) NULL, &new_part_ptr,
+					   show_flags);
+	if (error_code) {
+		error("slurm_load_part");
+		RETURN_INT(error_code);
+	}
+
+//	sinfo_list = list_create(_sinfo_list_delete);
+			
+	RETURN_INT(error_code);
+}
diff --git a/src/srun/sigstr.c b/contribs/phpext/slurm_php/slurm_php.h
similarity index 74%
rename from src/srun/sigstr.c
rename to contribs/phpext/slurm_php/slurm_php.h
index f0e2418fc30fd6d6ab06715c0e81799fbc895910..d857934aef413efe655d502d2615113217df5e84 100644
--- a/src/srun/sigstr.c
+++ b/contribs/phpext/slurm_php/slurm_php.h
@@ -1,10 +1,12 @@
 /*****************************************************************************\
- * src/srun/sigstr.c - Function to convert signal to description
+ *  slurm_php.h - php interface to slurm.
+ *
+ *  $Id: slurm_php.h 13061 2008-01-22 21:23:56Z da $
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by AUTHOR <AUTHOR@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Danny Auble <da@llnl.gov>
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -15,7 +17,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -34,32 +36,16 @@
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
+#ifndef SLURM_PHP_H
+#define SLURM_PHP_H 1
 
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <string.h>
-#include <sys/wait.h>
-
-#include "src/common/xassert.h"
-
-/*
- * Get a definition for strsignal :
- */
-#if defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL
-#  ifndef strsignal
- extern char *strsignal(int);
-#  endif
-#endif /* defined HAVE_DECL_STRSIGNAL && !HAVE_DECL_STRSIGNAL */
-
-char *
-sigstr(int status)
-{
-	xassert(WIFSIGNALED(status));
-
-	return strsignal(WTERMSIG(status));
-}
+#define SLURM_PHP_VERSION "1.0"
+#define SLURM_PHP_EXTNAME "slurm"
 
+PHP_FUNCTION(hello_world);
+PHP_FUNCTION(print_partitions);
 
+extern zend_module_entry slurm_php_module_entry;
+#define phpext_slurm_php_ptr &slurm_php_module_entry
 
+#endif
diff --git a/contribs/time_login.c b/contribs/time_login.c
index 27261599b81260cb2ed479628f9fae6784794e9d..4c44f8d8228455ce10b823534fc1421fec5e1fa7 100644
--- a/contribs/time_login.c
+++ b/contribs/time_login.c
@@ -14,7 +14,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/contribs/torque/Makefile.in b/contribs/torque/Makefile.in
index e4e159f446a30859ef50a383e0a4d3f25ca16f71..048d4a63010d4552b2352d2b6e7c48c710e1dedc 100644
--- a/contribs/torque/Makefile.in
+++ b/contribs/torque/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -94,6 +96,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -107,10 +110,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -130,7 +136,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -141,6 +150,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -156,6 +167,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -171,6 +183,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
diff --git a/contribs/torque/mpiexec.pl b/contribs/torque/mpiexec.pl
index 622a1a496d498ab41e9c9e82a03b9c62572736f8..37614a7fab0aa263f5ae9c1a3f332ba68453d558 100755
--- a/contribs/torque/mpiexec.pl
+++ b/contribs/torque/mpiexec.pl
@@ -8,7 +8,7 @@
 #  Copyright (C) 2007 The Regents of the University of California.
 #  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 #  Written by Danny Auble <auble1@llnl.gov>.
-#  UCRL-CODE-226842.
+#  LLNL-CODE-402394.
 #  
 #  This file is part of SLURM, a resource management program.
 #  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/contribs/torque/pbsnodes.pl b/contribs/torque/pbsnodes.pl
index 3b2a3b307eccf7b46b0881dcbeaac288d6c75da8..f02637f060555339bf3a633b26c08c4223197068 100755
--- a/contribs/torque/pbsnodes.pl
+++ b/contribs/torque/pbsnodes.pl
@@ -8,7 +8,7 @@
 #  Copyright (C) 2007 The Regents of the University of California.
 #  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 #  Written by Danny Auble <auble1@llnl.gov>.
-#  UCRL-CODE-226842.
+#  LLNL-CODE-402394.
 #  
 #  This file is part of SLURM, a resource management program.
 #  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/contribs/torque/qdel.pl b/contribs/torque/qdel.pl
index 0d0649e14f304878d45e419ad1c85ae9d1a3d356..79d248706d995dddc36f9ac81a6a1a0686375994 100755
--- a/contribs/torque/qdel.pl
+++ b/contribs/torque/qdel.pl
@@ -8,7 +8,7 @@
 #  Copyright (C) 2007 The Regents of the University of California.
 #  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 #  Written by Danny Auble <auble1@llnl.gov>.
-#  UCRL-CODE-226842.
+#  LLNL-CODE-402394.
 #  
 #  This file is part of SLURM, a resource management program.
 #  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/contribs/torque/qhold.pl b/contribs/torque/qhold.pl
index 2b33a714e3e9e505a2a532fec9b80d0b5a022a56..731a7c0c528292435460ad1405adc7b19e718185 100755
--- a/contribs/torque/qhold.pl
+++ b/contribs/torque/qhold.pl
@@ -9,7 +9,7 @@
 #  Copyright (C) 2007 The Regents of the University of California.
 #  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 #  Written by Danny Auble <auble1@llnl.gov>.
-#  UCRL-CODE-226842.
+#  LLNL-CODE-402394.
 #  
 #  This file is part of SLURM, a resource management program.
 #  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/contribs/torque/qrls.pl b/contribs/torque/qrls.pl
index bad8a2e949781cf7777c68e2f5ebea0dfbe7644d..fd24b29fb170e9cb5de82dc888409aa3557e8544 100755
--- a/contribs/torque/qrls.pl
+++ b/contribs/torque/qrls.pl
@@ -8,7 +8,7 @@
 #  Copyright (C) 2007 The Regents of the University of California.
 #  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 #  Written by Danny Auble <auble1@llnl.gov>.
-#  UCRL-CODE-226842.
+#  LLNL-CODE-402394.
 #  
 #  This file is part of SLURM, a resource management program.
 #  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/contribs/torque/qstat.pl b/contribs/torque/qstat.pl
index 20f457576ac3fbb5b3bffe9544434b14a8f4dd10..7e302cba487c178a35b88bfa472762d8082551aa 100755
--- a/contribs/torque/qstat.pl
+++ b/contribs/torque/qstat.pl
@@ -8,7 +8,7 @@
 #  Copyright (C) 2007 The Regents of the University of California.
 #  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 #  Written by Danny Auble <auble1@llnl.gov>.
-#  UCRL-CODE-226842.
+#  LLNL-CODE-402394.
 #  
 #  This file is part of SLURM, a resource management program.
 #  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/contribs/torque/qsub.pl b/contribs/torque/qsub.pl
index 52d332a433cf153c5f89ab5d009dafd379482c4d..cee2d06d961f040f259f46290b6906f76ba9a7cb 100755
--- a/contribs/torque/qsub.pl
+++ b/contribs/torque/qsub.pl
@@ -8,7 +8,7 @@
 #  Copyright (C) 2007 The Regents of the University of California.
 #  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 #  Written by Danny Auble <auble1@llnl.gov>.
-#  UCRL-CODE-226842.
+#  LLNL-CODE-402394.
 #  
 #  This file is part of SLURM, a resource management program.
 #  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/doc/Makefile.in b/doc/Makefile.in
index cb6d6cca85b17f9277be311e2f72b5d8d5de7c6e..73ab4da8b6c7036b75d5ba72b85f3521964a5d3f 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -99,6 +101,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -112,10 +115,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -135,7 +141,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -146,6 +155,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -161,6 +172,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -176,6 +188,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -354,8 +367,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -380,8 +393,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -391,13 +404,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/doc/html/Makefile.am b/doc/html/Makefile.am
index c7b713fd7abfc6ae63c4a556fd3f49105de5fc89..6b9fae58332792910c40da3ba400c8840f230746 100644
--- a/doc/html/Makefile.am
+++ b/doc/html/Makefile.am
@@ -2,19 +2,24 @@
 htmldir = ${prefix}/share/doc/@PACKAGE@-@VERSION@/html
 
 generated_html = \
+	accounting.html \
 	api.html \
 	authplugins.html \
 	big_sys.html \
 	bluegene.html \
 	checkpoint_plugins.html \
 	cons_res.html \
+	cons_res_share.html \
+	crypto_plugins.html \
 	dist_plane.html \
 	documentation.html \
 	download.html \
 	faq.html \
+	gang_scheduling.html \
 	help.html \
 	ibm.html \
-	jobacctplugins.html \
+	jobacct_gatherplugins.html \
+	jobacct_storageplugins.html \
 	jobcompplugins.html \
 	mail.html \
 	maui.html \
@@ -26,6 +31,7 @@ generated_html = \
 	platforms.html \
 	plugins.html \
 	power_save.html \
+	preempt.html \
 	proctrack_plugins.html \
 	programmer_guide.html \
 	publications.html \
diff --git a/doc/html/Makefile.in b/doc/html/Makefile.in
index 14562fb459df6359e5b4d2047f4052e904e68c9f..54b78c500890d456d4d3d94ca9535c82007c12e7 100644
--- a/doc/html/Makefile.in
+++ b/doc/html/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -98,6 +100,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -111,10 +114,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -134,7 +140,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -145,6 +154,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -160,6 +171,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -175,6 +187,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -232,19 +245,24 @@ target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 generated_html = \
+	accounting.html \
 	api.html \
 	authplugins.html \
 	big_sys.html \
 	bluegene.html \
 	checkpoint_plugins.html \
 	cons_res.html \
+	cons_res_share.html \
+	crypto_plugins.html \
 	dist_plane.html \
 	documentation.html \
 	download.html \
 	faq.html \
+	gang_scheduling.html \
 	help.html \
 	ibm.html \
-	jobacctplugins.html \
+	jobacct_gatherplugins.html \
+	jobacct_storageplugins.html \
 	jobcompplugins.html \
 	mail.html \
 	maui.html \
@@ -256,6 +274,7 @@ generated_html = \
 	platforms.html \
 	plugins.html \
 	power_save.html \
+	preempt.html \
 	proctrack_plugins.html \
 	programmer_guide.html \
 	publications.html \
diff --git a/doc/html/accounting.shtml b/doc/html/accounting.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..af84b48ddf47800843851256a23686314d069452
--- /dev/null
+++ b/doc/html/accounting.shtml
@@ -0,0 +1,478 @@
+<!--#include virtual="header.txt"-->
+
+<h1>Accounting</h1>
+<p>SLURM collects accounting information for every job and job step 
+executed. 
+Information is available about both currently executing jobs and 
+jobs which have already terminated and can be viewed using the 
+<b>sacct</b> command. 
+Resource usage is reported for each task and this can be useful to 
+detect load imbalance between the tasks. 
+SLURM version 1.2 and earlier supported the storage of accounting 
+records to a text file.
+Beginning in SLURM version 1.3 accounting records can be written to 
+a database. </p>
+
+<p>There are three distinct plugin types associated with resource accounting.
+The configuration parameters associated with these plugins include:
+</p><ul>
+<li><b>JobCompType</b> controls how job completion information is 
+recorded. This can be used to record basic job information such
+as job name, user name, allocated nodes, start time, completion 
+time, exit status, etc. If the preservation of only basic job 
+information is required, this plugin should satisfy your needs
+with minimal overhead. You can store this information in a 
+text file, <a href="http://www.mysql.com/">MySQL</a> or 
+<a href="http://www.postgresql.org/">PostgreSQL</a> 
+database optionally using either 
+<a href="http://www.clusterresources.com/pages/products/gold-allocation-manager.php">Gold</a>
+or SlurmDBD for added database security.</li>
+<li><b>JobAcctGatherType</b> is operating system dependent and 
+controls what mechanisms are used to collect accounting information.
+Supported values are <i>jobacct_gather/aix</i>, <i>jobacct_gather/linux</i>
+and <i>jobacct_gather/none</i> (no information collected).</li>
+<li><b>AccountingStorageType</b> controls how detailed job and job 
+step information is recorded. You can store this information in a 
+text file, <a href="http://www.mysql.com/">MySQL</a> or 
+<a href="http://www.postgresql.org/">PostgreSQL</a> 
+database optionally using either 
+<a href="http://www.clusterresources.com/pages/products/gold-allocation-manager.php">Gold</a>
+or SlurmDBD for added security.</li>
+</ul>
+
+<p>Storing the information into text files is very simple. 
+Just configure the appropriate plugin (e.g. 
+<i>AccountingStorageType=accounting_storage/filetxt</i> and/or 
+<i>JobCompType=jobcomp/filetxt</i>) and then specify the 
+pathname of the file (e.g.
+<i>AccountingStorageLoc=/var/log/slurm/accounting</i> and/or 
+<i>JobCompLoc=/var/log/slurm/job_completions</i>).
+Use the <i>logrotate</i> or similar tool to prevent the 
+log files from getting too large.
+Send a SIGHUP signal to the <i>slurmctld</i> deaemon 
+after moving the files, but before compressing them so
+that new log files will be created.</p>
+
+<p>Storing the data directly into a database from SLURM may seem 
+attractive, but that requires the availability of user name and 
+password data not only for the SLURM control daemon (slurmctld), 
+but also user commands which need to access the data (sacct and
+sacctmgr). 
+Making information available to all users makes database security 
+more difficult to provide, sending the data through an intermediate
+daemon can provide better security. 
+Gold and SlurmDBD are two such services. 
+Our initial implementation relied upon Gold, but we found its
+performance to be inadequate for our needs and developed SlurmDBD.
+SlurmDBD (SLURM Database Daemon) is written in C, multi-threaded, 
+secure, and considerably faster than Gold.
+The configuration required to use SlurmDBD will be described below.
+Direct database or Gold use would be similar.</p>
+
+<p>Note that SlurmDBD relies upon existing SLURM plugins
+for authentication and database use, but the other SLURM 
+commands and daemons are not required on the host where
+SlurmDBD is installed. Install the <i>slurmdbd</i> and 
+<i>slurm-plugins</i> RPMs on the computer when SlurmDBD
+is to execute.</p>
+
+<h2>Infrastructure</h2>
+
+<p>If the SlurmDBD is executed on a different cluster than the 
+one managed by SLURM, possibly to collect data from multiple 
+clusters in a single location, there are some constraints on 
+the user space.
+The user ID associated with <i>SlurmUser</i> must be uniform 
+across all clusters. 
+Accounting is maintained by user name (not user ID), but a
+given user name should refer to the same person across all 
+of the computers.</p>
+
+<p>The best way to insure security of the data is by authenticating 
+communications to the SlurmDBD and we recommend 
+<a href="http://home.gna.org/munge/">Munge</a> for that purpose.
+Munge was designed to support authentication within a cluster.
+If you have one cluster managed by SLURM and execute the SlurmDBD 
+on that one cluster, the normal Munge configuration will suffice.
+Otherwise Munge should then be installed on all nodes of all 
+SLURM managed clusters plus the machine where SlurmDBD executes.
+You then have a choice of either having a single Munge key for 
+all of these computers or maintaining a unique key for each of the 
+clusters plus a second key for communications between the clusters
+for better security.
+Munge enhancements are planned to support two keys within a single 
+configuration file, but presently two different daemons must be 
+started with different configuration files to support two different 
+keys. 
+If a Munge separate daemon configured to provide enterprise-wide 
+authentication, it will have a unique named pipe configured for 
+communications. 
+The pathname of this pipe will be needed in the SLURM and SlurmDBD
+configuration files (slurm.conf and slurmdbd.conf respectively, 
+more details are provided below).</p>
+
+<h2>SLURM Configuration</h2>
+
+<p>Several SLURM configuration parameters must be set to support
+archiving information in SlurmDBD. SlurmDBD has a separate configuration
+file which is documented in a separate section.
+Note that you can write accounting information to SlurmDBD
+while job completion records are written to a text file or 
+not maintained at all. 
+If you don't set the configuration parameters that begin 
+with "JobComp" then job completion records will not be recorded.</p>
+
+<ul>
+<li><b>AccountingStorageEnforce</b>:
+If you want to prevent users from running jobs if their <i>association</i>
+(a combination of cluster, account, and user names. For more
+flexibility in accounting the association can also include a partition
+name, but it is not necissary.) is not in the database, then set this
+to "1". Otherwise jobs will be executed based upon policies configured
+in SLURM on each cluster. </li>
+
+<li><b>AccountingStorageHost</b>: The name or address of the host where SlurmDBD executes
+      </li>
+
+<li><b>AccountingStoragePass</b>: If using SlurmDBD with a second Munge
+daemon, store the pathname of the named socket used by Munge to provide
+enterprise-wide. Otherwise the default Munge daemon will be used. . </li>
+
+<li><b>AccountingStoragePort</b>:
+The network port that SlurmDBD accepts communication on.</li>
+
+<li><b>AccountingStorageType</b>:
+Set to "accounting_storage/slurmdbd".</li>
+
+<li><b>ClusterName</b>:
+Set to a unique name for each Slurm-managed cluster so that 
+accounting records from each can be identified.</li>
+
+<li><b>JobCompHost</b>:
+The name or address of the host where SlurmDBD executes.</li>
+
+<li><b>JobCompPass</b>:
+If using SlurmDBD with a second Munge daemon, store the pathname of 
+the named socket used by Munge to provide enterprise-wide.
+Otherwise the default Munge daemon will be used.</li>
+
+<li><b>JobCompPort</b>:
+The network port that SlurmDBD accepts communication on.</li>
+
+<li><b>JobCompType</b>:
+Set to "jobcomp/slurmdbd".</li>
+</ul>
+
+<h2>SlurmDBD Configuration</h2>
+
+<p>SlurmDBD requires its own configuration file called "slurmdbd.conf". 
+This file should be only on the computer where SlurmDBD executes and 
+should only be readable by the user which executes SlurmDBD (e.g. "slurm").
+This file should be protected from unauthorized access since it
+contains a database login name and password.
+See "man slurmdbd.conf" for a more complete description of the 
+configuration parameters. 
+Some of the more important parameters include:</p>
+
+<ul>
+<li><b>AuthInfo</b>:
+If using SlurmDBD with a second Munge daemon, store the pathname of 
+the named socket used by Munge to provide enterprise-wide.
+Otherwise the default Munge daemon will be used.</li>
+
+<li><b>AuthType</b>:
+Define the authentication method for communications between SLURM 
+components. A value of "auth/munge" is recommended.</li>
+
+<li><b>DbdHost</b>:
+The name of the machine where the Slurm Database Daemon is executed. 
+This should be a node name without the full domain name (e.g. "lx0001"). 
+This value must be specified.</li>
+
+<li><b>DbdPort</b>:
+The port number that the Slurm Database Daemon (slurmdbd) listens 
+to for work. The default value is SLURMDBD_PORT as established at system 
+build time. If none is explicitly specified, it will be set to 6819.
+This value must be equal to the <i>SlurmDbdPort</i> parameter in the
+slurm.conf file.</li>
+
+<li><b>LogFile</b>:
+Fully qualified pathname of a file into which the Slurm Database Daemon's 
+logs are written.
+The default value is none (performs logging via syslog).</li>
+
+<li><b>PluginDir</b>:
+Identifies the places in which to look for SLURM plugins. 
+This is a colon-separated list of directories, like the PATH 
+environment variable. 
+The default value is "/usr/local/lib/slurm".</li>
+
+<li><b>SlurmUser</b>:
+The name of the user that the <i>slurmctld</i> daemon executes as. 
+This user must exist on the machine executing the Slurm Database Daemon
+and have the same user ID as the hosts on which <i>slurmctld</i> execute.
+For security purposes, a user other than "root" is recommended.
+The default value is "root". </li>
+
+<li><b>StorageHost</b>:
+Define the name of the host the database is running where we are going
+to store the data.
+Ideally this should be the host on which slurmdbd executes.</li>
+
+<li><b>StorageLoc</b>:
+Specifies the name of the database where accounting 
+records are written, for databases the default database is
+slurm_acct_db.  Note the name can not have a '/' in it or the
+default will be used.</li>
+
+<li><b>StoragePass</b>:
+Define the password used to gain access to the database to store 
+the job accounting data.</li>
+
+<li><b>StoragePort</b>:
+Define the port on which the database is listening.</li>
+
+<li><b>StorageType</b>:
+Define the accounting storage mechanism type.
+Acceptable values at present include 
+"accounting_storage/gold", "accounting_storage/mysql", and
+"accounting_storage/pgsql".
+The value "accounting_storage/gold" indicates that account records
+will be written to Gold, which maintains its own database.
+Use of Gold is not recommended due to reduced performance without 
+providing any additional security.
+The value "accounting_storage/mysql" indicates that accounting records
+should be written to a MySQL database specified by the 
+<i>StorageLoc</i> parameter.
+The value "accounting_storage/pgsql" indicates that accounting records
+should be written to a PostgreSQL database specified by the 
+<i>StorageLoc</i> parameter.
+This value must be specified.</li>
+
+<li><b>StorageUser</b>:
+Define the name of the user we are going to connect to the database
+with to store the job accounting data.</li>
+</ul>
+
+<h2>Tools</h2>
+
+<p>There are two tools available to work with accounting data,
+<b>sacct</b> and <b>sacctmgr</b>. 
+Both of these tools will get or set data through the SlurmDBD daemon. 
+Sacct is used to generate accounting report for both running and 
+completed jobs.
+Sacctmgr is used to manage associations in the database: 
+add or remove clusters, add or remove users, etc.
+See the man pages for each command for more information.</p>
+
+<p>Web interfaces with graphical output is currently under
+development and should be available in the summer of 2008.
+A tool to report node state information is also under development.</p>
+
+<h2>Database Configuration</h2>
+
+<p>Accounting records are maintained based upon what we refer 
+to as an <i>Association</i>,
+which consists of four elements: cluster, account, and user names. For
+more flexibility in accounting the association can also include a
+partition name, but it is not necessary. Use the <i>sacctmgr</i>
+command to create and manage these records. There is an order to set up
+accounting associations. You must define clusters before you add
+accounts and you must add accounts before you can add users. </p>
+
+<p>For example, to add a cluster named "snowflake" to the database
+execute this line:</p>
+<pre>
+sacctmgr add cluster snowflake
+</pre>
+
+<p>Add accounts "none" and "test" to cluster "snowflake" with an execute 
+line of this sort:</p>
+<pre>
+sacctmgr add account none,test Cluster=snowflake \
+  Description="none" Organization="none" 
+</pre>
+
+<p>If you have more clusters you want to add these accounts to you
+can either not specify a cluster, which will add the accounts to all
+clusters in the system, or comma separate the cluster names you want
+to add to in the cluster option.
+Note that multiple accounts can be added at the same time 
+by comma separating the names. 
+Some Description of the account and the organization which it belongs
+must be specified. 
+These terms can be used later to generated accounting reports.
+Accounts may be arranged in a hierarchical fashion, for example accounts 
+<i>chemistry</i> and <i>physics</i> may be children of the account <i>science</i>. 
+The hierarchy may have an arbitrary depth. 
+To do this one only needs to specify the <i>parent='' </i>option in the add 
+account line.
+For the example above execute</p>
+<pre>
+sacctmgr add account science \
+   Description="science accounts" Organization=science
+sacctmgr add account chemistry,physics parent=science \
+   Description="physical sciences" Organization=science
+</pre>
+
+<p>Add users to accounts using similar syntax.
+For example, to permit user <i>da</i> to execute jobs on all clusters
+with a default account of <i>test</i> execute:</p>
+<pre>
+sacctmgr add user da default=test
+</pre>
+<p>If <b>AccountingStorageEnforce=1</b> is configured in the slurm.conf of 
+the cluster <i>snowflake</i> then user <i>da</i> would be
+allowed to run in account <i>test</i> and any other accounts added
+in the future.
+Any attempt to use other accounts will result in the job being 
+aborted. 
+Account <i>test</i> will be the default if he doesn't specify one in a 
+srun line.</p>
+
+<p>Partition names can also be added to an "add user" command with the
+Partition='partitionname' option to specify an association specific to
+a slurm partition.</p>
+
+<!-- For future use
+<h2>Cluster Options</h2>
+
+<p>When either adding or modifying a cluster, these are the options 
+available with sacctmgr:
+<ul>
+<li><b>Name=</b> Cluster name</li>
+
+<li><b>Fairshare=</b> Used for determining priority</li>
+
+<li><b>MaxJobs=</b> Limit number of jobs a user can run in this account</li>
+
+<li><b>MaxNodes=</b>Limit number of nodes a user can allocate in this 
+account</li>
+
+<li><b>MaxWall=</b>Limit wall clock time a job can run</li>
+
+<li><b>MaxCPUSecs=</b> Limit cpu seconds a job can run</li>
+</ul>
+!-->
+
+<h2>Account Options</h2>
+
+<p>When either adding or modifying an account, the following sacctmgr 
+options are available:
+<ul>
+<li><b>Description=</b> Description of the account. (Required on creation)</li>
+
+<li><b>Organization=</b>Organization of the account. (Required on creation)</li>
+
+<li><b>Name=</b> Name of account</li>
+
+<li><b>Cluster=</b> Only add this account to these clusters.
+The account is added to all defined clusters by default.</li>
+
+<li><b>Parent=</b> Make this account a child of this other account.</li>
+
+<!-- For future use
+<li><b>QOS=</b> Quality of Service</li>
+
+<li><b>Fairshare=</b> Used for determining priority</li>
+
+<li><b>MaxJobs=</b> Limit number of jobs a user can run in this account</li>
+
+<li><b>MaxNodes=</b>Limit number of nodes a user can allocate in this account</li>
+
+<li><b>MaxWall=</b>Limit wall time a job can run</li>
+
+<li><b>MaxCPUSecs=</b> Limit cpu seconds a job can run</li>
+!-->
+</ul>
+
+<h2>User Options</h2>
+
+<p>When either adding or modifying a user, the following sacctmgr 
+options are available:
+
+<ul>
+<li><b>Name=</b> User name</li>
+
+<li><b>DefaultAccount=</b> Default account for the user, used when no account 
+is specified when a job is sumbitted. (Required on creation)</li>
+
+<li><b>AdminLevel=</b> This field is used to allow a user to add accounting 
+privileges to this user. Valid options are 
+<ul>
+<li>None</li>
+<li>Operator: can add, modify,and remove users, and add other operators)</li>
+<li>Admin: In addition to operator privileges these users can add, modify, 
+and remove accounts and clusters</li>
+</ul>
+
+<li><b>Account=</b> Account(s) to add user to</li>
+
+<li><b>Cluster=</b> Only add to accounts on these clusters (default is all clusters)</li>
+
+<li><b>Partition=</b> Name of Slurm partition this association applies to</li>
+
+<!-- For future use
+<li><b>QOS=</b> Quality of Service</li>
+
+<li><b>Fairshare=</b> Used for determining priority</li>
+
+<li><b>MaxJobs=</b> Limit number of jobs a user can run in this account</li>
+
+<li><b>MaxNodes=</b> Limit number of nodes a user can allocate in this account</li>
+
+<li><b>MaxWall=</b> Limit wall time a job can run</li>
+
+<li><b>MaxCPUSecs=</b> Limit cpu seconds a job can run</li>
+!-->
+</ul>
+
+<!-- For future use
+<h2>Limit enforcement</h2>
+
+<p>When limits are developed they will work in this order...
+If a user has a limit set SLURM will read in those, 
+if not we will refer to the account associated with the job. 
+If the account doesn't have the limit set we will refer to 
+the cluster's limits. 
+If the cluster doesn't have the limit set no limit will be enforced.
+!-->
+
+<h2>Modifying Entities</h2>
+
+<p>When modifying entities, you can specify many different options in 
+SQL-like fashion, using key words like <i>where</i> and <i>set</i>.
+A typical execute line has the following form:
+<pre>
+sacctmgr modify &lt;entity&gt; set &lt;options&gt; where &lt;options&gt;
+</pre>
+
+<p>For example:</p>
+<pre>
+sacctmgr modify user set default=none where default=test
+</pre>
+<p>will change all users with a default account of "test" to account "none".
+Once an entity has been added, modified or removed, the change is 
+sent to the appropriate SLURM daemons and will be available for use 
+instantly.</p>
+
+<h2>Removing Entities</h2>
+
+<p>Removing entities using an execute line similar to the modify example above,
+but without the set options.
+For example, remove all users with a default account "test" using the following 
+execute line:</p>
+<pre>
+sacctmgr remove user where default=test
+</pre>
+
+<h2>Node State Information</h2>
+
+<p>Node state information is also recorded in the database. 
+Whenever a node goes DOWN or becomes DRAINED that event is 
+logged along with the node's <i>Reason</i> field. 
+This can be used to generate various reports.
+
+<p style="text-align: center;">Last modified 25 March 2008</p>
+
+</ul></body></html>
diff --git a/doc/html/arch.gif b/doc/html/arch.gif
index f605a1c5cc6ddbd4390fdeff5b500e2217abb0cc..1cae914e0d1a81f6f990484f1ca172b71e6fc669 100644
Binary files a/doc/html/arch.gif and b/doc/html/arch.gif differ
diff --git a/doc/html/big_sys.shtml b/doc/html/big_sys.shtml
index 57292a5172951ade7ca96eb7afb2d65b09c92f8c..b33a9e915e4b273cfedb918ee5d1a9c931b68515 100644
--- a/doc/html/big_sys.shtml
+++ b/doc/html/big_sys.shtml
@@ -5,21 +5,51 @@
 <p>This document contains SLURM administrator information specifically 
 for clusters containing 1,024 nodes or more. 
 Virtually all SLURM components have been validated (through emulation) 
-for clusters containing up to 16,384 compute nodes. 
-Getting good performance at that scale does require some tuning and 
+for clusters containing up to 65,536 compute nodes. 
+Getting optimal performance at that scale does require some tuning and 
 this document should help you off to a good start.
 A working knowledge of SLURM should be considered a prerequisite 
 for this material.</p>
 
+<h2>Performance Results</h2>
+
+<p>SLURM has acutally been used on clusters containing up to 4,184 nodes. 
+At that scale, the total time to execute a simple program (resource 
+allocation, task launch, I/O processing, and cleanup, e.g. 
+"time srun -N4184 -n8368 uname") at 8,368 tasks 
+across the 4,184 nodes was under 57 seconds. The table below shows
+total execution times for several large clusters with different architectures.</p>
+<table border>
+<caption>SLURM Total Job Execution Time</caption>
+<tr>
+<th>Nodes</th><th>Tasks</th><th>Seconds</th>
+</tr>
+<tr>
+<th>256</th><th>512</th><th>1.0</th>
+</tr>
+<tr>
+<th>512</th><th>1024</th><th>2.2</th>
+</tr>
+<tr>
+<th>1024</th><th>2048</th><th>3.7</th>
+</tr>
+<tr>
+<th>2123</th><th>4246</th><th>19.5</th>
+</tr>
+<tr>
+<th>4184</th><th>8368</th><th>56.6</th>
+</tr>
+</table>
+
 <h2>Node Selection Plugin (SelectType)</h2>
 
 <p>While allocating individual processors within a node is great 
 for smaller clusters, the overhead of keeping track of the individual 
 processors and memory within each node adds significant overhead. 
-For best scalability, the consumable resource plugin (<i>select/cons_res</i>)
-is best avoided.</p>
+For best scalability, allocate whole nodes using <i>select/linear</i>
+or <i>select/bluegene</i> and avoid <i>select/cons_res</i>.</p>
 
-<h2>Job Accounting Plugin (JobAcctType)</h2>
+<h2>Job Accounting Gather Plugin (JobAcctGatherType)</h2>
 
 <p>Job accounting relies upon the <i>slurmstepd</i> daemon on each compute 
 node periodically sampling data.
@@ -28,11 +58,11 @@ inducing what is known as <i>system noise</i>.
 For large parallel applications, this system noise can detract for 
 application scalability.
 For optimal application performance, disabling job accounting 
-is best (<i>jobacct/none</i>).
+is best (<i>jobacct_gather/none</i>).
 Consider use of job completion records (<i>JobCompType</i>) for accounting 
 purposes as this entails far less overhead.
 If job accounting is required, configure the sampling interval 
-to a relatively large size (e.g. <i>JobAcctFrequency=300</i>).
+to a relatively large size (e.g. <i>JobAcctGatherFrequency=300</i>).
 Some experimentation may also be required to deal with collisions 
 on data transmission.</p>
 
@@ -61,9 +91,48 @@ and thus should not be allocated work.
 Longer intervals decrease system noise on compute nodes (we do 
 synchronize these requests across the cluster, but there will 
 be some impact upon applications).
-For really large clusters, <i>SlurmdTimeoutl</i> values of 
+For really large clusters, <i>SlurmdTimeout</i> values of 
 120 seconds or more are reasonable.</p> 
 
-<p style="text-align:center;">Last modified 28 January 2006</p>
+<p>If MPICH-2 is used, the srun command will manage the key-pairs
+used to bootstrap the application. 
+Depending upon the processor speed and architecture, the communication 
+of key-pair information may require extra time. 
+This can be done by setting an environment variable PMI_TIME before 
+executing srun to launch the tasks. 
+The default value of PMI_TIME is 500 and this is the number of 
+microseconds alloted to transmit each key-pair. 
+We have executed up to 16,000 tasks with a value of PMI_TIME=4000.</p>
+
+<p>The individual slurmd daemons on compute nodes will initiate messages
+to the slurmctld daemon only when they start up or when the epilog 
+completes for a job. When a job allocated a large number of nodes 
+completes, it can cause a very large number of messages to be sent 
+by the slurmd daemons on these nodes to the slurmctld daemon all at
+the same time. In order to spread this message traffic out over time
+and avoid message loss, The <i>EpilogMsgTime</i> parameter may be 
+used. Note that even if messages are lost, they will be retransmitted, 
+but this will result in a delay for reallocating resources to new jobs.</p>
+
+<h2>Other</h2>
+
+<p>SLURM uses hierarchical communications between the slurmd daemons
+in order to increase parallelism and improve performance. The 
+<i>TreeWidth</i> configuration parameter controls the fanout of messages.
+The default value is 50, meaning each slurmd daemon can communicate
+with up to 50 other slurmd daemons and over 2500 nodes can be contacted
+with two message hops.
+The default value will work well for most clusters.
+Optimal system performance can typically be achieved if <i>TreeWidth</i>
+is set to the square root of the number of nodes in the cluster for
+systems having no more than 2500 nodes or the cube root for larger
+systems.</p>
+ 
+<p>The srun command automatically increases its open file limit to 
+the hard limit in order to process all of the standard input and output
+connections to the launched tasks. It is recommended that you set the
+open file hard limit to 8192 across the cluster.</p>
+
+<p style="text-align:center;">Last modified 11 March 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/bluegene.shtml b/doc/html/bluegene.shtml
index 8a4d01db2f3301ea0f98ae8eb645d9781c346e28..8a5cc31667299a1bf20c4d61079aa0e3780912cd 100644
--- a/doc/html/bluegene.shtml
+++ b/doc/html/bluegene.shtml
@@ -5,7 +5,7 @@
 <h2>Overview</h2>
 
 <p>This document describes the unique features of SLURM on the
-<a href="http://www.research.ibm.com/bluegene">IBM BlueGene</a> systems. 
+<a href="http://www.research.ibm.com/bluegene/">IBM BlueGene</a> systems. 
 You should be familiar with the SLURM's mode of operation on Linux clusters 
 before studying the relatively few differences in BlueGene operation 
 described in this document.</p>
@@ -36,12 +36,11 @@ to represent multiples of 1024 (e.g. "2k" is equivalent to "2048").</p>
 
 <h2>User Tools</h2>
 
-<p>The normal set of SLURM user tools: srun, sbatch, scancel, sinfo, squeue,
-and scontrol 
+<p>The normal set of SLURM user tools: sbatch, scancel, sinfo, squeue, and scontrol 
 provide all of the expected services except support for job steps. 
 SLURM performs resource allocation for the job, but initiation of tasks is performed 
 using the <i>mpirun</i> command. SLURM has no concept of a job step on BlueGene.
-Seven new srun, sbatch options are available: 
+Seven new sbatch options are available: 
 <i>--geometry</i> (specify job size in each dimension),
 <i>--no-rotate</i> (disable rotation of geometry), 
 <i>--conn-type</i> (specify interconnect type between base partitions, mesh or torus).
@@ -54,15 +53,15 @@ to be available.
 
 Note that this is a c-node count.</p>
 
-<p>To reiterate: srun is used to submit a job script, but mpirun is used to launch the parallel tasks. 
-<b>It is highly recommended that the srun <i>--batch</i> option be used to submit a script.</b> 
+<p>To reiterate: sbatch is used to submit a job script, 
+but mpirun is used to launch the parallel tasks. 
 Note that a SLURM batch job's default stdout and stderr file names are generated 
 using the SLURM job ID. 
 When the SLURM control daemon is restarted, SLURM job ID values can be repeated, 
 therefore it is recommended that batch jobs explicitly specify unique names for 
 stdout and stderr files using the srun options <i>--output</i> and <i>--error</i>
 respectively.
-While the srun <i>--allocate</i> option may be used to create an interactive SLURM job, 
+While the salloc command may be used to create an interactive SLURM job, 
 it will be the responsibility of the user to insure that the <i>bgblock</i> 
 is ready for use before initiating any mpirun commands. 
 SLURM will assume this responsibility for batch jobs. 
@@ -407,7 +406,10 @@ and <i>NodeCardNodeCnt=NODE_COUNT</i> respectively in the <i>bluegene.conf</i>
 file (i.e. <i>BasePartitionNodeCnt=512</i> and <i>NodeCardNodeCnt=32</i>).</p>
 
 <p>Note that the <i>Numpsets</i> values defined in 
-<i>bluegene.conf</i> are used only when SLURM creates bgblocks.
+<i>bluegene.conf</i> is used only when SLURM creates bgblocks this
+determines if the system is IO rich or not.  For most bluegene/L
+systems this value is either 8 (for IO poor systems) or 64 (for IO rich
+systems).
 <p>The <i>Images</i> can change during job start based on input from
 the user.
 If you change the bgblock layout, then slurmctld and slurmd should 
@@ -491,7 +493,7 @@ AltRamDiskImage=*  Groups=da,adamb
 LayoutMode=STATIC
 BasePartitionNodeCnt=512
 NodeCardNodeCnt=32
-Numpsets=8
+NumPsets=64	# An I/O rich environment
 BridgeAPILogFile=/var/log/slurm/bridgeapi.log
 BridgeAPIVerbose=0
 
@@ -629,6 +631,6 @@ scheduling logic, etc. </p>
  
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 23 January 2007</p>
+<p style="text-align:center;">Last modified 23 April 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/checkpoint_plugins.shtml b/doc/html/checkpoint_plugins.shtml
index 7b1baf6a6a3111c7b353bca2c96eb4698356cdc5..286b631b6134542c00f42781d48ba5ea5925c0c6 100644
--- a/doc/html/checkpoint_plugins.shtml
+++ b/doc/html/checkpoint_plugins.shtml
@@ -1,6 +1,6 @@
 <!--#include virtual="header.txt"-->
 
-<h1><a name="top">SLURM Job Checkpoint Plugin API</a></h1>
+<h1><a name="top">SLURM Job Checkpoint Plugin Programmer Guide</a></h1>
 
 <h2> Overview</h2>
 <p> This document describes SLURM job checkpoint plugins and the API that defines 
@@ -13,7 +13,8 @@ The plugins must conform to the SLURM Plugin API with the following specificatio
 
 <p><span class="commandline">const char plugin_type[]</span><br>
 The major type must be &quot;checkpoint.&quot; The minor type can be any recognizable 
-abbreviation for the type of scheduler. We recommend, for example:</p>
+abbreviation for the type of checkpoint mechanism. 
+We recommend, for example:</p>
 <ul>
 <li><b>aix</b>&#151;AIX system checkpoint.</li>
 <li><b>none</b>&#151;No job checkpoint.</li>
@@ -136,9 +137,10 @@ appropriate value to indicate the reason for failure.</p>
                                                                                                                        
 
 <h2>Versioning</h2>
-<p> This document describes version 0 of the SLURM checkpoint API. Future 
-releases of SLURM may revise this API. A scheduler plugin conveys its ability 
-to implement a particular API version using the mechanism outlined for SLURM plugins.</p>
+<p> This document describes version 0 of the SLURM checkpoint API. 
+Future releases of SLURM may revise this API. 
+A checkpoint plugin conveys its ability to implement a particular API 
+version using the mechanism outlined for SLURM plugins.</p>
 <p class="footer"><a href="#top">top</a></p>
 
 <p style="text-align:center;">Last modified 21 August 2007</p>
diff --git a/doc/html/configurator.html.in b/doc/html/configurator.html.in
index 9e04a16f490e49bdd50f8a25e962282909918c14..7239c2fa32ca441fb813803cbb98a0a79989fb43 100644
--- a/doc/html/configurator.html.in
+++ b/doc/html/configurator.html.in
@@ -1,10 +1,11 @@
 <!--
 Copyright (C) 2005-2007 The Regents of the University of California.
+Copyright (C) 2008 Lawrence Livermore National Security.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 Written by Morris Jette <jette1@llnl.gov> and Danny Auble <da@llnl.gov>
 
 This file is part of SLURM, a resource management program.
-For details, see <http://www.llnl.gov/linux/slurm/>.
+For details, see <https://computing.llnl.gov/linux/slurm/>.
 
 SLURM is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -19,8 +20,6 @@ details.
 You should have received a copy of the GNU General Public License along
 with SLURM; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-
-$Id$
 -->
 <HTML>
 <HEAD><TITLE>SLURM System Configuration Tool</TITLE>
@@ -40,6 +39,27 @@ function get_field2(name,form)
   return ""
 }
 
+function get_accounting_storage_type_field(gather, form_storage)
+{
+  for (var i=0; i < form_storage.length; i++)
+  {
+    if (form_storage[i].checked)
+    {
+      if(form_storage[i].value == "none" && !(gather == "none")) 
+      {
+	return "filetxt"
+      }
+      else if(!(form_storage[i].value == "none") && gather == "none")   
+      {
+	return "none"
+      }
+      else {
+	return form_storage[i].value
+      }
+    }
+  }
+}
+
 function get_radio_field_skipfirst(name,form)
 {
   for (var i=1; i < form.length; i++)
@@ -105,10 +125,17 @@ function get_task_plugin_param()
   return "#TaskPluginParam="
 }
 
+function hide_box()
+{
+   var popup = document.getElementById('out_box');
+   popup.style.visibility = 'hidden';
+    
+}
 
 function displayfile()
 {
   var printme = "# slurm.conf file generated by configurator.html.<br>" +
+   "# Put this file on all nodes of your cluster.<br>" +
    "# See the slurm.conf man page for more information.<br>" +
    "#<br>" +
    "ControlMachine=" + document.config.control_machine.value + "<br>" +
@@ -116,73 +143,111 @@ function displayfile()
    get_field("BackupController",document.config.backup_controller) + "<br>" +
    get_field("BackupAddr",document.config.backup_addr) + "<br>" +
    "# <br>" +
-   "#DisableRootJobs=0 <br>" +
-   "#JobFileAppend=0 <br>" +
-   "SlurmUser=" + document.config.slurm_user.value + "<br>" +
-   "SlurmctldPort=" + document.config.slurmctld_port.value + "<br>" +
-   "SlurmdPort=" + document.config.slurmd_port.value + "<br>" +
    "AuthType=auth/" + get_radio_value(document.config.auth_type) + "<br>" +
+   "CacheGroups=" + get_radio_value(document.config.cache_groups) + "<br>" +
+   "#CheckpointType=checkpoint/none <br>" +
+   "CryptoType=crypto/" + get_radio_value(document.config.crypto_type) + "<br>" +
+   "#DisableRootJobs=NO <br>" +
+   get_field("Epilog",document.config.epilog) + "<br>" +
+   "#FirstJobId=1 <br>" +
    get_field("JobCredentialPrivateKey", document.config.private_key) + "<br>" +
    get_field("JobCredentialPublicCertificate", document.config.public_key) + "<br>" +
-   "StateSaveLocation=" + document.config.state_save_location.value + "<br>" +
-   "SlurmdSpoolDir=" + document.config.slurmd_spool_dir.value + "<br>" +
-   "SwitchType=switch/" + get_radio_value(document.config.switch_type) + "<br>" +
+   "#JobFileAppend=0 <br>" +
+   "#JobRequeue=1 <br>" +
+   "#Licenses=foo*4,bar <br>" +
    "#MailProg=/bin/mail <br>" +
+   "#MaxJobCount=5000 <br>" +
    "MpiDefault=" + get_radio_value(document.config.mpi_default) + "<br>" +
-   "#MessageTimeout=10 <br>" +
-   "SlurmctldPidFile=" + document.config.slurmctld_pid_file.value + "<br>" +
-   "SlurmdPidFile=" + document.config.slurmd_pid_file.value + "<br>" +
-   "ProctrackType=proctrack/" + get_radio_value(document.config.proctrack_type) + "<br>" +
    "#PluginDir= <br>" +
-   "CacheGroups=" + get_radio_value(document.config.cache_groups) + "<br>" +
-   "#CheckpointType=checkpoint/none <br>" +
-   "#FirstJobId=1 <br>" +
-   "ReturnToService=" + get_radio_value(document.config.return_to_service) + "<br>" +
-   "#MaxJobCount=2000 <br>" +
    "#PlugStackConfig= <br>" +
-   "#PropagatePrioProcess= <br>" +
+   "#PrivateData=0 <br>" +
+   "ProctrackType=proctrack/" + get_radio_value(document.config.proctrack_type) + "<br>" +
+   get_field("Prolog",document.config.prolog) + "<br>" +
+   "#PropagatePrioProcess=0 <br>" +
    "#PropagateResourceLimits= <br>" +
    "#PropagateResourceLimitsExcept= <br>" +
-   get_field("Prolog",document.config.prolog) + "<br>" +
-   get_field("Epilog",document.config.epilog) + "<br>" +
-   get_field("SrunProlog",document.config.srun_prolog) + "<br>" +
+   "ReturnToService=" + get_radio_value(document.config.return_to_service) + "<br>" +
+   "SlurmctldPidFile=" + document.config.slurmctld_pid_file.value + "<br>" +
+   "SlurmctldPort=" + document.config.slurmctld_port.value + "<br>" +
+   "SlurmdPidFile=" + document.config.slurmd_pid_file.value + "<br>" +
+   "SlurmdPort=" + document.config.slurmd_port.value + "<br>" +
+   "SlurmdSpoolDir=" + document.config.slurmd_spool_dir.value + "<br>" +
+   "SlurmUser=" + document.config.slurm_user.value + "<br>" +
    get_field("SrunEpilog",document.config.srun_epilog) + "<br>" +
-   get_field("TaskProlog",document.config.task_prolog) + "<br>" +
+   get_field("SrunProlog",document.config.srun_prolog) + "<br>" +
+   "StateSaveLocation=" + document.config.state_save_location.value + "<br>" +
+   "SwitchType=switch/" + get_radio_value(document.config.switch_type) + "<br>" +
    get_field("TaskEpilog",document.config.task_epilog) + "<br>" +
    "TaskPlugin=task/" + get_radio_value(document.config.task_plugin) + "<br>" +
    get_task_plugin_param() + "<br>" +
+   get_field("TaskProlog",document.config.task_prolog) + "<br>" +
    "#TmpFs=/tmp <br>" +
-   "#UsePAM= <br>" +
+   "#TreeWidth= <br>" +
+   "#UnkillableStepProgram= <br>" +
+   "#UnkillableStepTimeout= <br>" +
+   "#UsePAM=0 <br>" +
+   "# <br>" +
    "# <br>" +
    "# TIMERS <br>" +
-   "SlurmctldTimeout=" + document.config.slurmctld_timeout.value + "<br>" +
-   "SlurmdTimeout=" + document.config.slurmd_timeout.value + "<br>" +
+   "#EpilogMsgTime=2000 <br>" +
+   "#GetEnvTimeout=2 <br>" +
+   "#HealthCheckInterval=0 <br>" +
+   "#HealthCheckProgram= <br>" +
    "InactiveLimit=" + document.config.inactive_limit.value + "<br>" +
    "MinJobAge=" + document.config.min_job_age.value + "<br>" +
    "KillWait=" + document.config.kill_wait.value + "<br>" +
-   "#GetEnvTimeout=2 <br>" +
+   "#MessageTimeout=10 <br>" +
+   "SlurmctldTimeout=" + document.config.slurmctld_timeout.value + "<br>" +
+   "SlurmdTimeout=" + document.config.slurmd_timeout.value + "<br>" +
    "#UnkillableStepProgram= <br>" +
    "#UnkillableStepTimeout=60 <br>" +
    "Waittime=" + document.config.wait_time.value + "<br>" +
    "# <br>" +
-   "# SCHEDULING<br>" +
+   "# <br>" +
+   "# SCHEDULING <br>" +
+   "#DefMemPerTask=0 <br>" +
+   "FastSchedule=" + get_radio_value(document.config.fast_schedule) + "<br>" +
+   "#MaxMemPerTask=0 <br>" +
+   "#SchedulerRootFilter=1 <br>" +
+   "#SchedulerTimeSlice=30 <br>" +
    "SchedulerType=sched/" + get_radio_value(document.config.sched_type) + "<br>" +
    get_field("SchedulerPort",document.config.scheduler_port) + "<br>" +
-   "#SchedulerRootFilter= <br>" +
    "SelectType=select/" + get_radio_value(document.config.select_type) + "<br>" +
    get_select_type_params() + "<br>" +
-   "FastSchedule=" + get_radio_value(document.config.fast_schedule) + "<br>" +
    "# <br>" +
-   "# LOGGING <br>" +
+   "# <br>" +
+   "# LOGGING AND ACCOUNTING <br>" +
+   "#AccountingStorageEnforce=0 <br>" +
+   get_field("AccountingStorageHost",document.config.accounting_storage_host) + "<br>" +
+   get_field("AccountingStorageLoc",document.config.accounting_storage_loc) + "<br>" +
+   get_field("AccountingStoragePass",document.config.accounting_storage_pass) + "<br>" +
+   get_field("AccountingStoragePort",document.config.accounting_storage_port) + "<br>" +
+   "AccountingStorageType=accounting_storage/" + get_accounting_storage_type_field(get_radio_value(document.config.job_acct_gather_type), document.config.accounting_storage_type) + "<br>" +
+   get_field("AccountingStorageUser",document.config.accounting_storage_user) + "<br>" +
+   get_field("ClusterName",document.config.cluster_name) + "<br>" +
+   get_field("JobCompHost",document.config.job_comp_host) + "<br>" +
+   get_field("JobCompLoc",document.config.job_comp_loc) + "<br>" +
+   get_field("JobCompPass",document.config.job_comp_pass) + "<br>" +
+   get_field("JobCompPort",document.config.job_comp_port) + "<br>" +
+   "JobCompType=jobcomp/" + get_radio_value(document.config.job_comp_type) + "<br>" +
+   get_field("JobCompUser",document.config.job_comp_user) + "<br>" +
+   get_field("JobAcctGatherFrequency",document.config.job_acct_gather_frequency) + "<br>" +
+   "JobAcctGatherType=jobacct_gather/" + get_radio_value(document.config.job_acct_gather_type) + "<br>" +
    "SlurmctldDebug=" + document.config.slurmctld_debug.value + "<br>" +
    get_field("SlurmctldLogFile",document.config.slurmctld_logfile) + "<br>" +
    "SlurmdDebug=" + document.config.slurmd_debug.value + "<br>" +
    get_field("SlurmdLogFile",document.config.slurmd_logfile) + "<br>" +
-   "JobCompType=jobcomp/" + get_radio_value(document.config.job_comp_type) + "<br>" +
-   get_field("JobCompLoc",document.config.job_comp_loc) + "<br>" +
-   "JobAcctType=jobacct/" + get_radio_value(document.config.job_acct_type) + "<br>" +
-   get_field("JobAcctLogfile",document.config.job_acct_logfile) + "<br>" +
-   get_field("JobAcctFrequency",document.config.job_acct_frequency) + "<br>" +
+   "# <br>" +
+   "# <br>" +
+   "# POWER SAVE SUPPORT FOR IDLE NODES (optional) <br>" +
+   "#SuspendProgram= <br>" +
+   "#ResumeProgram= <br>" +
+   "#ResumeRate= <br>" +
+   "#SuspendExcNodes= <br>" +
+   "#SuspendExcParts= <br>" +
+   "#SuspendRate= <br>" +
+   "#SuspendTime= <br>" +
+   "# <br>" +
    "# <br>" +
    "# COMPUTE NODES <br>" +
    "NodeName=" + document.config.node_name.value +
@@ -198,25 +263,50 @@ function displayfile()
    " Default=YES"+
    " MaxTime=" + document.config.max_time.value +
    " State=UP"
-    
-    document.write(printme);
+
+   //scroll(0,0);
+   //var popup = document.getElementById('out_box');
+   
+   //popup.innerHTML = "<a href='javascript:hide_box();'>close</a><br>";
+   //popup.innerHTML += "#BEGIN SLURM.CONF FILE<br><br>";
+   //popup.innerHTML += printme;
+   //popup.innerHTML += "<br><br>#END SLURM.CONF FILE<br>";
+   //popup.innerHTML += "<a href='javascript:hide_box();'>close</a>";
+   
+   //popup.style.visibility = 'visible';
+
+   // OLD CODE
+   document.open();
+   document.write(printme);
+   document.close();
 }
 
 -->
 </SCRIPT>
+<!-- <div style='visibility:hidden;text-align:left;background:#ccc;border:1px solid black;position: absolute;left:100;z-index:1;padding:5;' id='out_box'></div> -->
 </HEAD>
 <BODY>
 <FORM name=config>
-<H1>SLURM Configration Tool, Version @SLURM_MAJOR@.@SLURM_MINOR@</H1>
+<H1>SLURM Version @SLURM_MAJOR@.@SLURM_MINOR@ Configration Tool</H1>
 <P>This form can be used to create a SLURM configuration file with 
-you controlling many of the important configuration parameters.
-This tool supports SLURM version @SLURM_MAJOR@.@SLURM_MINOR@.
+you controlling many of the important configuration parameters.</P>
+
+<P><B>This tool supports SLURM version @SLURM_MAJOR@.@SLURM_MINOR@ only.</B>
 Configuration files for other versions of SLURM should be built 
 using the tool distributed with it in <i>doc/html/configurator.html</i>.
 Some parameters will be set to default values, but you can
 manually edit the resulting <I>slurm.conf</I> as desired
 for greater flexibiilty. See <I>man slurm.conf</I> for more
-details about the configuration parameters.
+details about the configuration parameters.</P>
+
+<P>Note the while SLURM daemons create log files and other files as needed, 
+it treats the lack of parent directories as a fatal error. 
+This prevents the daemons from running if critical file systems are
+not mounted and will minimize the risk of cold-starting (starting 
+without preserving jobs).</P>
+
+<P>Note that this configuration file must be installed on all nodes 
+in your cluster.</P>
 
 <P>After you have filled in the fields of interest, use the 
 "Submit" button on the bottom of the page to build the <I>slurm.conf</I>
@@ -224,9 +314,9 @@ file. It will appear on your web browser. Save the file in text format
 as <I>slurm.conf</I> for use by SLURM.
 
 <P>For more information about SLURM, see
-<A HREF="http://www.llnl.gov/linux/slurm">http://www.llnl.gov/linux/slurm</A>
+<A HREF="https://computing.llnl.gov/linux/slurm/">https://computing.llnl.gov/linux/slurm/</A>
 <P>
-<A HREF="http://www.llnl.gov/disclaimer.html"><B>Privacy and legal notice</B></A>
+<A HREF="https://www.llnl.gov/disclaimer.html"><B>Privacy and legal notice</B></A>
 
 <H2>Control Machines</H2>
 Define the hostname of the computer on which the SLURM controller and
@@ -343,17 +433,28 @@ fails by using an interal default set at SLURM build time.
 <input type="text" name="slurmd_port" value="6818"> <B>SlurmdPort</B>
 <P>
 
-<H2>Authentication</H2>
+<H2>Authentication and Security</H2>
 Define the method used for authenticating communicating between SLURM components.<BR>
 Select one value for <B>AuthType</B>:<BR>
 <input type="radio" name="auth_type" value="none"> <B>None</B>: No authentication, 
 not recommended production use<br>
-<input type="radio" name="auth_type" value="authd"> <B>Authd</B>: Brent Chun's authd<BR>
-<input type="radio" name="auth_type" value="munge" checked> <B>Munge</B>: LLNL's Munge<BR>
-<P>
-Define the location of public and private SSL keys used by SLURM. 
-These need to be generated by the SLURM administrator.
-Specify fully qualified pathnames. Both values are required.
+<input type="radio" name="auth_type" value="authd"> <B>Authd</B>: Brent Chun's 
+<A href="http://www.theether.org/authd/">authd</A><BR>
+<input type="radio" name="auth_type" value="munge" checked> <B>Munge</B>: LLNL's 
+<A href="http://home.gna.org/munge/">Munge</A><BR>
+<P>
+Library used for job step cryptographic signature generation.<BR>
+Select one value for <B>CryptoType</B>:<BR>
+<input type="radio" name="crypto_type" value="munge"><B>Munge</B>: LLNL's 
+<A href="http://home.gna.org/munge/">Munge</A> (has Gnu Public License)<BR>
+<input type="radio" name="crypto_type" value="openssl" checked> <B>OpenSSL</B>:
+<A href="http://www.openssl.org/">OpenSSL</A> (has better performance for signature generation)
+<P>
+Define the location of public and private keys used by SLURM's 
+cryptographic signature generation plugin (CryptoType).
+These values are only used if CryptoType=OpenSSL.
+These files need to be generated by the SLURM administrator.
+Specify fully qualified pathnames.
 <P>
 <input type="text" name="private_key"> <B>JobCredentialPrivateKey</B>
 <P>
@@ -366,6 +467,7 @@ This should be a fully qualified pathname which can be read and written to
 by the SLURM user on both the control machine and backup controller (if configured).
 The location of a directory where slurmd saves state should also be defined.
 This must be a unique directory on each compute server (local disk).
+The use of a highly reliable file system (e.g. RAID) is recommended.
 <P>
 <input type="text" name="state_save_location" value="/tmp"> <B>StateSaveLocation</B>:
 Slurmctld state save directory <B>Must be writable by both ControlMachine and BackupController</B>
@@ -388,8 +490,12 @@ Select one value for <B>SchedulerType</B>:<BR>
 First-Out (FIFO)<BR>
 <input type="radio" name="sched_type" value="backfill" checked> <B>Backfill</B>: 
 FIFO with backfill<BR>
-<input type="radio" name="sched_type" value="wiki"> <B>Wiki</B>: Wiki interface to Maui 
-(configuration parameters SchedulerAuth and SchedulerPort must specified)<BR>
+<input type="radio" name="sched_type" value="gang">  <B>Gang</B>: Gang scheduling 
+(time-slicing for parallel jobs)<BR>
+<input type="radio" name="sched_type" value="wiki"> <B>Wiki</B>: Wiki interface 
+to Maui (configuration parameter <B>SchedulerPort</B> must specified)<BR>
+<input type="radio" name="sched_type" value="wiki2"> <B>Wiki2</B>: Wiki interface 
+to Moab (configuration parameter <B>SchedulerPort</B> must specified)<BR>
 <P>
 <input type="text" name="scheduler_port" value="7321"> <B>SchedulerPort</B>: scheduler 
 communcations port (used by Wiki only)
@@ -417,10 +523,14 @@ handling required (InfiniBand, Myrinet, Ethernet, etc.)<BR>
 Specify the type of MPI to be used by default. SLURM will configure environment 
 variables accordingly. Users can over-ride this specification with an srun option.<BR>
 Select one value for <B>MpiDefault</B>:<BR>
-<input type="radio" name="mpi_default" value="mpichgm"> <B>Mpich-Gm</B><BR>
+<input type="radio" name="mpi_default" value="mpichgm"> <B>MPICH-GM</B><BR>
+<input type="radio" name="mpi_default" value="mpichmx"> <B>MPICH-MX</B><BR>
+<input type="radio" name="mpi_default" value="mpich1_p4"> <B>MPICH1-P4</B><BR>
+<input type="radio" name="mpi_default" value="mpich1_shmem"> <B>MPICH1-SHMEM</B>: 
+This also works for MVAPICH-SHMEM.<BR>
 <input type="radio" name="mpi_default" value="mvapich"> <B>MVAPICH</B><BR>
 <input type="radio" name="mpi_default" value="none" checked> <B>None</B>: 
-This works for most other MPI types including LAM MPI and Open MPI.<BR>
++This works for most other MPI types including MPICH2, LAM MPI and Open MPI.<BR>
 <P>
 
 <H2>Process Tracking</H2>
@@ -447,8 +557,7 @@ Aggregates (PAGG) kernel module</A>, recommended where available<BR>
 Define resource (node) selection algorithm to be used.<BR>
 Select one value for <B>SelectType</B>:<BR>
 <input type="radio" name="select_type" value="cons_res">
-<B>Cons_res</B>: Allocate 
-individual processors and memory<BR>
+<B>Cons_res</B>: Allocate individual processors and memory<BR>
 <DL>
 <DL>
 <DT><B>SelectTypeParameters</B> (As used by <I>SelectType=Cons_res</I> only):
@@ -457,7 +566,7 @@ individual processors and memory<BR>
 	when CR_CPU or CR_CPU_MEMORY is selected. 
 	They are considered to compute the total number of 
 	tasks when -n is not specified
-    <DD> Note: CR_MEMORY assumes Shared=Yes
+    <DD> Note: CR_MEMORY assumes MaxShare value of one of higher
 <DT> <input type="radio" name="cons_res_params" value="CR_CPU" checked
 	    onClick="javascript:set_select_type(this, 'cons_res')">
     <B>CR_CPU</B>: (default)
@@ -475,7 +584,7 @@ individual processors and memory<BR>
 <DT> <input type="radio" name="cons_res_params" value="CR_Memory"
 	    onClick="javascript:set_select_type(this)">
     <B>CR_Memory</B>: Memory as a consumable resource. 
-    <DD> Note: CR_Memory assumes Shared=Yes
+    <DD> Note: CR_Memory assumes MaxShare value of one of higher
 <DT> <input type="radio" name="cons_res_params" value="CR_CPU_Memory"
 	    onClick="javascript:set_select_type(this)">
     <B>CR_CPU_Memory</B>:
@@ -566,34 +675,87 @@ log goes to syslog, string "%h" in name gets replaced with hostname)
 <H2>Job Completion Logging</H2>
 Define the job completion logging mechanism to be used.<BR> 
 Select one value for <B>JobCompType</B>:<BR>
-<input type="radio" name="job_comp_type" value="none" checked> <B>None</B>: No job 
-completion logging<BR>
-<input type="radio" name="job_comp_type" value="filetxt"> <B>FileTxt</B>: Write job 
-completion status to a text file<BR>
-<input type="radio" name="job_comp_type" value="script"> <B>Script</B>: Use an 
-arbitrary script to log job completion<BR>
-<P>
-<input type="text" name="job_comp_loc" value=""> <B>JobCompLoc</B>: Location specification. 
-This is the location of the text file to be written to or the script to be run (depends
-upon logging mode). Use a fully qualified pathname.
-<P>
-
-<H2>Job Accounting</H2>
+<input type="radio" name="job_comp_type" value="none" checked> <B>None</B>: 
+No job completion logging<BR>
+<input type="radio" name="job_comp_type" value="filetxt"> <B>FileTxt</B>: 
+Write job completion status to a text file<BR>
+<input type="radio" name="job_comp_type" value="script"> <B>Script</B>: 
+Use an arbitrary script to log job completion<BR>
+<input type="radio" name="job_comp_type" value="mysql"> <B>MySQL</B>: 
+Write completion status to a MySQL database<BR>
+<input type="radio" name="job_comp_type" value="pgsql"> <B>PGSQL</B>: 
+Write completion status to a PostreSQL database<BR>
+<input type="radio" name="job_comp_type" value="slurmdbd"> <B>SlurmDBD</B>: 
+Write completion status to Slurm adatabase daemon (serving multiple Slurm clusters) 
+which will write to some database<BR>
+<P>
+<input type="text" name="job_comp_loc" value=""> <B>JobCompLoc</B>: 
+This is the location of the text file to be written to (if JobCompType=filetst)
+or the script to be run (if JobCompType=script) or database name (for other values
+of JobCompType).
+<p><b>Options below are for use with a database to specify where the database is running and how to connect to it</b><br>
+<input type="text" name="job_comp_host" value=""> <B>JobCompHost</B>: 
+Host the database is running on for Job completion<br>
+<input type="text" name="job_comp_port" value=""> <B>JobCompPort</B>: 
+Port the database server is listening on for Job completion<br>
+<input type="text" name="job_comp_user" value=""> <B>JobCompUser</B>: 
+User we are to use to talk to the database for Job completion<br>
+<input type="text" name="job_comp_pass" value=""> <B>JobCompPass</B>: 
+Password we are to use to talk to the database for Job completion<br>
+<P>
+
+<H2>Job Accounting Gather</H2>
 SLURM accounts for resource use per job.  System specifics can be polled 
 determined by system type<BR>
-Select one value for <B>JobAcctType</B>:<BR>
-<input type="radio" name="job_acct_type" value="none" checked> <B>None</B>: No 
+Select one value for <B>JobAcctGatherType</B>:<BR>
+<input type="radio" name="job_acct_gather_type" value="none" checked> <B>None</B>: No 
 job accounting<BR>
-<input type="radio" name="job_acct_type" value="aix"> <B>AIX</B>: Specifc
+<input type="radio" name="job_acct_gather_type" value="aix"> <B>AIX</B>: Specifc
 AIX process table information gathered, use with AIX systems only<BR>
-<input type="radio" name="job_acct_type" value="linux"> <B>Linux</B>: Specifc
+<input type="radio" name="job_acct_gather_type" value="linux"> <B>Linux</B>: Specifc
 Linux process table information gathered, use with Linux systems only<BR>
-<input type="text" name="job_acct_frequency" value=""> <B>JobAcctFrequency</B>:
-polling interval in seconds.<BR>
-<input type="text" name="job_acct_logfile" value=""> <B>JobAcctLogFile</B>:
-Location specification.
+<input type="text" name="job_acct_gather_frequency" value="30"> <B>JobAcctGatherFrequency</B>:
+polling interval in seconds. Zero disables periodic sampling.<BR>
+<P>
+
+<H2>Job Accounting Storage</H2>
+Used with the Job Accounting Gather SLURM can store the accounting information in many different fashions.  Fill in your systems choice here<BR>
+Select one value for <B>AccountingStorageType</B>:<BR>
+<input type="radio" name="accounting_storage_type" value="none" checked> <B>None</B>: 
+No job accounting storage<BR>
+<input type="radio" name="accounting_storage_type" value="filetxt"> <B>FileTxt</B>: 
+Write job accounting to a text file<BR>
+<input type="radio" name="accounting_storage_type" value="gold"> <B>Gold</B>: 
+Write completion status to Gold database daemon which can securely 
+save the data from many Slurm managed clusters into a common database<BR>
+<input type="radio" name="accounting_storage_type" value="mysql"> <B>MySQL</B>: 
+Write job accounting to a MySQL database<BR>
+<input type="radio" name="accounting_storage_type" value="pgsql"> <B>PGSQL</B>: 
+Write job accounting to a PostreSQL database<BR>
+<input type="radio" name="accounting_storage_type" value="slurmdbd"> <B>SlurmDBD</B>: 
+Write job accounting to Slurm DBD (database daemon) which can securely 
+save the data from many Slurm managed clusters into a common database<BR>
+<input type="text" name="accounting_storage_loc" value=""> <B>AccountingStorageLoc</B>:
+Location specification or database name.
 This is the location of the text file to be written to (used by Log only).
-Use a fully qualified pathname.
+Use a fully qualified pathname. If using a database it is the name of the database you will use or create for the stored data.<br>
+<p><b>Options below are for use with a database to specify where the database is running and how to connect to it</b><br>
+<input type="text" name="accounting_storage_host" value=""> <B>AccountingStorageHost</B>: 
+Host the database is running on for Job Accounting<br>
+<input type="text" name="accounting_storage_port" value=""> <B>AccountingStoragePort</B>: 
+Port the database server is listening on for Job Accounting<br>
+<input type="text" name="accounting_storage_user" value=""> <B>AccountingStorageUser</B>: 
+User we are to use to talk to the database for Job Accounting<br>
+<input type="text" name="accounting_storage_pass" value=""> <B>AccountingStoragePass</B>: 
+Password we are to use to talk to the database for Job Accounting. 
+In the case of SlurmDBD, this will be an alternate socket name for use with a Munge
+daemon providing enterprise-wide authentication (while the default Munge socket
+would provide cluster-wide authentication only).<br>
+<input type="text" name="cluster_name" value="cluster"> <B>ClusterName</B>: 
+Name to be recorded in database for jobs from this cluster. 
+This is important if a single database is used to record information 
+from multiple Slurm-managed clusters.<br>
+
 <P>
 
 <H2>Process ID Logging</H2>
@@ -643,12 +805,12 @@ before terminating all remaining tasks. A value of zero indicates unlimited wait
 
 <BR> 
 <BR>
-<input type=submit value="Submit" onClick="javascript:displayfile()">
+<input type=button value="Submit" onClick="javascript:displayfile()">
 <input type=reset value="Reset Form">
 <P>
 </FORM>
 <HR>
-<p class="footer">UCRL-WEB-225274<br>
-Last modified 2 July 2007</p>
+<P class="footer">LLNL-WEB-402631<BR>
+Last modified 1 April 2008</P>
 </BODY>
 
diff --git a/doc/html/cons_res.shtml b/doc/html/cons_res.shtml
index 878f9fe666edb0dad300b0ba1181d6294295083e..ae4f0229330198d13b00876d6f270a0dad6f8747 100644
--- a/doc/html/cons_res.shtml
+++ b/doc/html/cons_res.shtml
@@ -203,6 +203,7 @@ Please send comments and requests about the consumable resources to
       hold until hydra12 becomes available or if backfill is enabled
       until hydra12's remaining CPU gets allocated to another job
       which will allow the 4th job to get two dedicated nodes</li>
+      <li><b>Note!</b> This problem is fixed in SLURM version 1.3.</li>
       <li><b>Note!</b> If you want to specify <i>--max_????</i> this
       problem can be solved in the current implementation by asking
       for the nodes in dedicated mode using <i>--exclusive</i></li>.
diff --git a/doc/html/cons_res_share.shtml b/doc/html/cons_res_share.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..66715e41d32a2979600373c4077ec757818e4976
--- /dev/null
+++ b/doc/html/cons_res_share.shtml
@@ -0,0 +1,222 @@
+<!--#include virtual="header.txt"-->
+
+<h1><a name="top">Sharing Consumable Resources</a></h1>
+
+<H3>CPU Management</H3>
+<P>
+(Disclaimer: In this "CPU Management" section, the term "consumable resource"
+does not include memory. The management of memory as a consumable resource is
+discussed in it's own section below.)
+</P><P>
+As of SLURM version 1.3, the <CODE>select/cons_res</CODE> plugin
+supports sharing consumable resources via the per-partition <CODE>Shared</CODE>
+setting. Previously the <CODE>select/cons_res</CODE> plugin ignored this
+setting, since it was technically already "sharing" the nodes when it scheduled
+the resources of each node to different jobs.
+</P>
+<P>
+Now the per-partition <CODE>Shared</CODE> setting applies to the <U>entity
+being selected for scheduling</U>:
+<UL><LI><P>
+When the default <CODE>select/linear</CODE> plugin is enabled, the
+per-partition <CODE>Shared</CODE> setting controls whether or not the
+<B>nodes</B> are shared among jobs.
+</P></LI><LI><P>
+When the <CODE>select/cons_res</CODE> plugin is enabled, the per-partition
+<CODE>Shared</CODE> setting controls whether or not the <B>configured consumable
+resources</B> are shared among jobs. When a consumable resource such as a core,
+socket, or CPU is shared, it means that more than one job can be assigned to it.
+</P></LI></UL>
+</P>
+<P>
+The following table describes this new functionality in more detail:
+</P>
+<TABLE CELLPADDING=3 CELLSPACING=1 BORDER=1>
+<TR><TH>Selection Setting</TH>
+<TH>Per-partition <CODE>Shared</CODE> Setting</TH>
+<TH>Resulting Behavior</TH>
+</TR><TR>
+<TD ROWSPAN=3>SelectType=<B>select/linear</B></TD>
+<TD>Shared=NO</TD>
+<TD>Whole nodes are allocated to jobs. No node will run more than one job.</TD>
+</TR><TR>
+<TD>Shared=YES</TD>
+<TD>Same as Shared=FORCE if job request specifies --shared option.
+Otherwise same as Shared=NO.</TD>
+</TR><TR>
+<TD>Shared=FORCE</TD>
+<TD>Whole nodes are allocated to jobs. A node may run more than one job.</TD>
+</TR><TR>
+<TD ROWSPAN=3>SelectType=<B>select/cons_res</B><BR>
+Plus one of the following:<BR>
+SelectTypeParameters=<B>CR_Core</B><BR>
+SelectTypeParameters=<B>CR_Core_Memory</B></TD>
+<TD>Shared=NO</TD>
+<TD>Cores are allocated to jobs. No core will run more than one job.</TD>
+</TR><TR>
+<TD>Shared=YES</TD>
+<TD>Allocate whole nodes if job request specifies --exclusive option.
+Otherwise same as Shared=FORCE.</TD>
+</TR><TR>
+<TD>Shared=FORCE</TD>
+<TD>Cores are allocated to jobs. A core may run more than one job.</TD>
+</TR><TR>
+<TD ROWSPAN=3>SelectType=<B>select/cons_res</B><BR>
+Plus one of the following:<BR>
+SelectTypeParameters=<B>CR_CPU</B><BR>
+SelectTypeParameters=<B>CR_CPU_Memory</B></TD>
+<TD>Shared=NO</TD>
+<TD>CPUs are allocated to jobs. No CPU will run more than one job.</TD>
+</TR><TR>
+<TD>Shared=YES</TD>
+<TD>Allocate whole nodes if job request specifies --exclusive option.
+Otherwise same as Shared=FORCE.</TD>
+</TR><TR>
+<TD>Shared=FORCE</TD>
+<TD>CPUs are allocated to jobs. A CPU may run more than one job.</TD>
+</TR><TR>
+<TD ROWSPAN=3>SelectType=<B>select/cons_res</B><BR>
+Plus one of the following:<BR>
+SelectTypeParameters=<B>CR_Socket</B><BR>
+SelectTypeParameters=<B>CR_Socket_Memory</B></TD>
+<TD>Shared=NO</TD>
+<TD>Sockets are allocated to jobs. No socket will run more than one job.</TD>
+</TR><TR>
+<TD>Shared=YES</TD>
+<TD>Allocate whole nodes if job request specifies --exclusive option.
+Otherwise same as Shared=FORCE.</TD>
+</TR><TR>
+<TD>Shared=FORCE</TD>
+<TD>Sockets are allocated to jobs. A socket may run more than one job.</TD>
+</TR>
+</TABLE>
+<P>When <CODE>Shared=FORCE</CODE> is configured, the consumable resources are
+scheduled for jobs using a <B>least-loaded</B> algorithm. Thus, idle
+CPUs|cores|sockets will be allocated to a job before busy ones, and
+CPUs|cores|sockets running one job will be allocated to a job before ones
+running two or more jobs. This is the same approach that the
+<CODE>select/linear</CODE> plugin uses when allocating "shared" nodes.
+</P>
+<P>
+Note that the <B>granularity</B> of the "least-loaded" algorithm is what
+distinguishes the two selection plugins (<CODE>cons_res</CODE> and
+<CODE>linear</CODE>) when <CODE>Shared=FORCE</CODE> is configured. With the
+<CODE>select/cons_res</CODE> plugin enabled, the CPUs of a node are not
+overcommitted until <B>all</B> of the rest of the CPUs are overcommitted on the
+other nodes. Thus if one job allocates half of the CPUs on a node and then a
+second job is submitted that requires more than half of the CPUs, the
+<CODE>select/cons_res</CODE> plugin will attempt to place this new job on other
+busy nodes that have more than half of the CPUs available for use. The
+<CODE>select/linear</CODE> plugin simply counts jobs on nodes, and does not
+track the CPU usage on each node.
+</P><P>
+This new functionality also supports the new
+<CODE>Shared=FORCE:&lt;num&gt;</CODE> syntax. If <CODE>Shared=FORCE:3</CODE> is
+configured with <CODE>select/cons_res</CODE> and <CODE>CR_Core</CODE> or
+<CODE>CR_Core_Memory</CODE>, then the <CODE>select/cons_res</CODE> plugin will
+run up to 3 jobs on each <U>core</U> of each node in the partition. If
+<CODE>CR_Socket</CODE> or <CODE>CR_Socket_Memory</CODE> is configured, then the
+<CODE>select/cons_res</CODE> plugin will run up to 3 jobs on each <U>socket</U>
+of each node in the partition.
+</P>
+<H3>Nodes in Multiple Partitions</H3>
+<P>
+SLURM has supported configuring nodes in more than one partition since version
+0.7.0. The <CODE>Shared=FORCE</CODE> support in the <CODE>select/cons_res</CODE>
+plugin accounts for this "multiple partition" support. Here are several
+scenarios with the <CODE>select/cons_res</CODE> plugin enabled to help
+understand how all of this works together:
+</P>
+<TABLE CELLPADDING=3 CELLSPACING=1 BORDER=1>
+<TR><TH>SLURM configuration</TH>
+<TH>Resulting Behavior</TH>
+</TR><TR>
+<TD>Two <CODE>Shared=NO</CODE> partitions assigned the same set of nodes</TD>
+<TD>Jobs from either partition will be assigned to all available consumable
+resources. No consumable resource will be shared. One node could have 2 jobs
+running on it, and each job could be from a different partition.</TD>
+</TR><TR>
+<TD>Two partitions assigned the same set of nodes: one partition is
+<CODE>Shared=FORCE</CODE>, and the other is <CODE>Shared=NO</CODE></TD>
+<TD>A node will only run jobs from one partition at a time. If a node is
+running jobs from the <CODE>Shared=NO</CODE> partition, then none of it's
+consumable resources will be shared. If a node is running jobs from the
+<CODE>Shared=FORCE</CODE> partition, then it's consumable resources can be
+shared.</TD>
+</TR><TR>
+<TD>Two <CODE>Shared=FORCE</CODE> partitions assigned the same set of nodes</TD>
+<TD>Jobs from either partition will be assigned consumable resources. All
+consumable resources can be shared. One node could have 2 jobs running on it,
+and each job could be from a different partition.</TD>
+</TR><TR>
+<TD>Two partitions assigned the same set of nodes: one partition is
+<CODE>Shared=FORCE:3</CODE>, and the other is <CODE>Shared=FORCE:5</CODE></TD>
+<TD>Generally the same behavior as above. However no consumable resource will
+ever run more than 3 jobs from the first partition, and no consumable resource
+will ever run more than 5 jobs from the second partition. A consumable resource
+could have up to 8 jobs running on it at one time.</TD>
+</TR>
+</TABLE>
+<P>
+Note that the "mixed shared setting" configuration (row #2 above) introduces the
+possibility of <B>starvation</B> between jobs in each partition. If a set of
+nodes are running jobs from the <CODE>Shared=NO</CODE> partition, then these
+nodes will continue to only be available to jobs from that partition, even if
+jobs submitted to the <CODE>Shared=FORCE</CODE> partition have a higher
+priority. This works in reverse also, and in fact it's easier for jobs from the
+<CODE>Shared=FORCE</CODE> partition to hold onto the nodes longer because the
+consumable resource "sharing" provides more resource availability for new jobs
+to begin running "on top of" the existing jobs. This happens with the
+<CODE>select/linear</CODE> plugin also, so it's not specific to the
+<CODE>select/cons_res</CODE> plugin.
+</P>
+
+<H3>Memory Management</H3>
+<P>
+The management of memory as a consumable resource remains unchanged:
+</P>
+<TABLE CELLPADDING=3 CELLSPACING=1 BORDER=1>
+<TR><TH>Selection Setting</TH>
+<TH>Resulting Behavior</TH>
+</TR><TR>
+<TD>SelectType=<B>select/linear</B></TD>
+<TD>Memory allocation is not tracked. Jobs are allocated to nodes without
+considering if there is enough free memory. Swapping could occur!</TD>
+</TR><TR>
+<TD>SelectType=<B>select/cons_res</B><BR>
+Plus one of the following:<BR>
+SelectTypeParameters=<B>CR_Core</B><BR>
+SelectTypeParameters=<B>CR_CPU</B><BR>
+SelectTypeParameters=<B>CR_Socket</B></TD>
+<TD>Memory allocation is not tracked. Jobs are allocated to consumable resources
+without considering if there is enough free memory. Swapping could occur!</TD>
+</TR><TR>
+<TD>SelectType=<B>select/cons_res</B><BR>
+Plus one of the following:<BR>
+SelectTypeParameters=<B>CR_Memory</B><BR>
+SelectTypeParameters=<B>CR_Core_Memory</B><BR>
+SelectTypeParameters=<B>CR_CPU_Memory</B><BR>
+SelectTypeParameters=<B>CR_Socket_Memory</B></TD>
+<TD>Memory allocation for all jobs are tracked. Nodes that do not have enough
+available memory to meet the job's memory requirement will not be allocated to
+the job.</TD>
+</TR>
+</TABLE>
+<P>Note that the <CODE>srun --mem=&lt;num&gt;</CODE> option is only used to
+request nodes that have &lt;num&gt; amount of real memory. This option does not
+compute memory that is currently available.
+</P><P>
+The <CODE>srun --job-mem=&lt;num&gt;</CODE> option is used with the
+<CODE>select/cons_res</CODE> plugin to request available memory from each node.
+</P><P>
+The <CODE>select/cons_res</CODE> plugin tracks memory usage by each job on each
+node regardless of the number partitions a node may be assigned to. The primary
+purpose of tracking memory as a consumable resource is to protect jobs from
+having their memory pages swapped out because the memory has been overcommitted.
+</P>
+
+<p class="footer"><a href="#top">top</a></p>
+
+<p style="text-align:center;">Last modified 27 May 2008</p>
+
+<!--#include virtual="footer.txt"-->
diff --git a/doc/html/crypto_plugins.shtml b/doc/html/crypto_plugins.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..6de9f151245acbf652d8fd2232b788e687b66b66
--- /dev/null
+++ b/doc/html/crypto_plugins.shtml
@@ -0,0 +1,151 @@
+<!--#include virtual="header.txt"-->
+
+<h1><a name="top">SLURM Cryptographic Plugin Programmer Guide</a></h1>
+
+<h2> Overview</h2>
+<p> This document describes SLURM cryptographic plugins and the API that 
+defines them. 
+It is intended as a resource to programmers wishing to write their own 
+SLURM cryptographic plugins. 
+This is version 0 of the API.</p>
+
+<p>SLURM cryptographic plugins are SLURM plugins that implement 
+a digital signature mechanism. 
+The slurmctld daemon generates a job step credential, signs it, 
+and tranmits it to an srun program. 
+The srun program then transmits it to the slurmd daemons directly. 
+The slurmctld daemon does not communicate directly with the slurmd 
+daemons at this time for performance reasons, but the job step 
+credential must be validated by the slurmd daemon as being 
+generated by the slurmctld daemon. 
+Digital signatures provide this validation mechanism.
+The plugins must conform to the SLURM Plugin API with the following 
+specifications:</p>
+
+<p><span class="commandline">const char plugin_type[]</span><br>
+The major type must be &quot;crypto.&quot; 
+The minor type can be any recognizable abbreviation for the type of 
+cryptographic mechanism. 
+We recommend, for example:</p>
+<ul>
+<li><b>munge</b>&#151;LLNL's Munge system.</li>
+<li><b>openssl</b>&#151;Open SSL.</li>
+</ul></p>
+
+<p>The <span class="commandline">plugin_name</span> and 
+<span class="commandline">plugin_version</span> 
+symbols required by the SLURM Plugin API require no specialization for 
+cryptographic support. 
+Note carefully, however, the versioning discussion below.</p>
+
+<h2>Data Objects</h2>
+<p>The implementation must maintain (though not necessarily directly export) an 
+enumerated <span class="commandline">errno</span> to allow SLURM to discover 
+as practically as possible the reason for any failed API call. 
+Plugin-specific enumerated integer values may be used when appropriate.
+
+<p>These values must not be used as return values in integer-valued 
+functions in the API. 
+The proper error return value from integer-valued functions is SLURM_ERROR. 
+The implementation should endeavor to provide useful and pertinent 
+information by whatever means is practical. 
+Successful API calls are not required to reset any errno to a known value. 
+However, the initial value of any errno, prior to any error condition 
+arising, should be SLURM_SUCCESS. </p>
+<p class="footer"><a href="#top">top</a></p>
+
+<h2>API Functions</h2>
+<p>The following functions must appear. 
+Functions which are not implemented should be stubbed.</p>
+
+
+<p class="commandline">void * crypto_read_private_key (const char *path);</p>
+<p style="margin-left:.2in"><b>Description</b>: Generate a private key
+based upon the contents of the supplied file.</p>
+<p style="margin-left:.2in"><b>Argument</b>:<span class="commandline">path</span>&nbsp; 
+&nbsp;&nbsp;(input) fully-qualified pathname to the private key
+as specified by the <b>JobCredentialPrivateKey</b> configuration parameter.</p>
+<p style="margin-left:.2in"><b>Returns</b>: The pointer to a key on 
+success or NULL on failure.
+Call crypto_destroy_key() to release memory associated with this key.</p>
+
+
+<p class="commandline">void * crypto_read_public_key (const char *path);</p>
+<p style="margin-left:.2in"><b>Description</b>: Generate a public key
+based upon the contents of the supplied file.</p>
+<p style="margin-left:.2in"><b>Argument</b>:<span class="commandline">path</span>&nbsp;     
+&nbsp;&nbsp;(input) fully-qualified pathname to the public key
+as specified by the <b>JobCredentialPublicCertificate</b> configuration 
+parameter.</p>
+<p style="margin-left:.2in"><b>Returns</b>: The pointer to a key on 
+success or NULL on failure.
+Call crypto_destroy_key() to release memory associated with this key.</p>
+
+
+<p class="commandline">void crypto_destroy_key (void *key);</p>
+<p style="margin-left:.2in"><b>Description</b>: Release storage for 
+a public or private key.</p>
+<p style="margin-left:.2in"><b>Argument</b>:<span class="commandline"> key</span>&nbsp;
+&nbsp;&nbsp;(input/output) pointer to the key previously allocated 
+by crypto_read_private_key() or crypto_read_public_key().</p> 
+
+
+<p class="commandline">char *crypto_str_error(void);</p>
+<p style="margin-left:.2in"><b>Description</b>: Return a string 
+describing the last error generated by the the cryptographic software.</p>
+<p style="margin-left:.2in"><b>Returns</b>: A pointer to a string.</p>
+                                                                                                                       
+<p class="commandline">int crypto_sign (void *key, char *buffer, int buf_size,
+char **sig_pp, unsigned int *sig_size_p);</p>
+<p style="margin-left:.2in"><b>Description</b>: Generate a signature for 
+the supplied buffer.</p>
+<p style="margin-left:.2in"><b>Arguments</b>:</br>
+<span class="commandline"> key</span>&nbsp;
+&nbsp;&nbsp;(input) pointer to the key previously generated by 
+crypto_read_private_key() or crypto_read_public_key().<br>
+<span class="commandline"> buffer</span>&nbsp; &nbsp;&nbsp;(input) data to 
+be signed.<br>
+<span class="commandline"> buf_size</span>&nbsp; &nbsp;&nbsp;(input) 
+size of buffer, in bytes.<br>
+<span class="commandline"> sig_pp</span>&nbsp; &nbsp;&nbsp;(input/output)
+Location in which to store the signature. NOTE: The storage for 
+sig_pp should be allocated using xmalloc() and will be freed by 
+the caller using xfree().<br>
+<span class="commandline"> sig_size_p</span>&nbsp; &nbsp;&nbsp;(input/output)
+Location in which to store the size of the signature (sig_pp).</p>
+<p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful. 
+On failure, the plugin should return SLURM_ERROR and set the errno to an 
+appropriate value to indicate the reason for failure.</p>
+
+<p class="commandline">int crypto_verify_sign (void *key, char *buffer, 
+int buf_size, char *signature, unsigned int sig_size);</p>
+<p style="margin-left:.2in"><b>Description</b>: Generate a signature for
+the supplied buffer.</p>
+<p style="margin-left:.2in"><b>Arguments</b>:</br>
+<span class="commandline"> key</span>&nbsp;
+&nbsp;&nbsp;(input) pointer to the key previously generated by
+crypto_read_private_key() or crypto_read_public_key().<br>
+<span class="commandline"> buffer</span>&nbsp; &nbsp;&nbsp;(input) data 
+previously signed by crypto_sign().<br>
+<span class="commandline"> buf_size</span>&nbsp; &nbsp;&nbsp;(input)
+size of buffer, in bytes.<br>
+<span class="commandline"> signature</span>&nbsp; &nbsp;&nbsp;(input)
+Signature as returned in sig_pp by the crypto_sign() function and 
+to be confirmed.</br>
+<span class="commandline"> sig_size</span>&nbsp; &nbsp;&nbsp;(input)
+Size of the signature as returned in sig_size_p by crypto_sign().</p>
+<p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful.
+On failure, the plugin should return SLURM_ERROR and set the errno to an
+appropriate value to indicate the reason for failure.</p>
+
+
+<h2>Versioning</h2>
+<p> This document describes version 0 of the SLURM cryptographic API. 
+Future releases of SLURM may revise this API. 
+A cryptographic plugin conveys its ability to implement a particular 
+API version using the mechanism outlined for SLURM plugins.</p>
+<p class="footer"><a href="#top">top</a></p>
+
+<p style="text-align:center;">Last modified 24 July 2007</p>
+
+<!--#include virtual="footer.txt"-->
diff --git a/doc/html/documentation.shtml b/doc/html/documentation.shtml
index f386b731a700f426a59a5340f40abc7b473b1d34..de8b51111092b9b2449362efaf09b6cd49e20186 100644
--- a/doc/html/documentation.shtml
+++ b/doc/html/documentation.shtml
@@ -2,14 +2,12 @@
 
 <h1> Documentation</h1>
 
+Also see <a href="publications.html">Publications and Presentations</a>.
+
 <h2>SLURM Users</h2>
 <ul>
 <li><a href="quickstart.shtml">Quick Start User Guide</a></li>
-<li><a href="lci.7.tutorial.pdf">Resource Management Using SLURM,
-(Tutorial, The 7th International Conference on Linux Clusters, May 2006)</li>
-<li><a href="slurm_v1.2.pdf">Resource Management at LLNL, SLURM Version 1.2
-(April 2007)</li>
-<li><a href="http://www.llnl.gov/LCdocs/slurm">SLURM Reference Manual</a></li>
+<li><a href="https://computing.llnl.gov/LCdocs/slurm/">SLURM Reference Manual</a></li>
 <li><a href="mc_support.shtml">Support for Multi-core/Multi-threaded Architectures</a></li>
 <li><a href="quickstart.shtml#mpi">Guide to MPI Use</a></li>
 <li><a href="bluegene.shtml">Blue Gene User and Administrator Guide</a></li>
@@ -19,19 +17,20 @@
 <h2>SLURM Administrators</h2>
 <ul>
 <li><a href="quickstart_admin.shtml">Quick Start Administrator Guide</a></li>
+<li><a href="configurator.html">Configuration Tool</a></li>
 <li><a href="troubleshoot.shtml">Troubleshooting Guide</a></li>
-<li><a href="lci.7.tutorial.pdf">Resource Management Using SLURM, 
-(Tutorial, The 7th International Conference on Linux Clusters, May 2006)</li>
 <li><a href="big_sys.shtml">Large Cluster Administration Guide</a></li>
-<li><a href="power_save.shtml">Power Saving Guide</a></li>
 <li><a href="cons_res.shtml">Consumable Resources Guide</a></li>
-<li><a href="bluegene.shtml">Blue Gene User and Administrator Guide</a></li>
-<li><a href="ibm.shtml">IBM AIX User and Administrator Guide</a></li>
-<li><a href="configurator.html">Configuration Tool</a></li>
+<li><a href="cons_res_share.shtml">Sharing Consumable Resources</a></li>
+<li><a href="accounting.shtml">Accounting</a></li>
+<li><a href="gang_scheduling.shtml">Gang Scheduling</a></li>
+<li><a href="preempt.shtml">Preemption</a></li>
 <li><a href="maui.shtml">Maui Scheduler Integration Guide</a></li>
 <li><a href="moab.shtml">Moab Cluster Suite Integration Guide</a></li>
-<li><a href="http://docs.hp.com/en/5991-4847/ch09s02.html">Submitting 
-Jobs throuh LSF</a></li>
+<li><a href="http://docs.hp.com/en/5991-4847/ch09s02.html">Submitting Jobs throuh LSF</a></li>
+<li><a href="bluegene.shtml">Blue Gene User and Administrator Guide</a></li>
+<li><a href="ibm.shtml">IBM AIX User and Administrator Guide</a></li>
+<li><a href="power_save.shtml">Power Saving Guide</a></li>
 </ul>
 
 <h2>SLURM Developers</h2>
@@ -40,17 +39,19 @@ Jobs throuh LSF</a></li>
 <li><a href="api.shtml">Application Programmer Interface (API) Guide</a></li>
 <li><a href="plugins.shtml">Plugin Programmer Guide</a></li>
 <li><a href="authplugins.shtml">Authentication Plugin Programmer Guide</a></li>
-<li><a href="jobacctplugins.shtml">Job Accounting Plugin Programmer Guide</a></li>
+<li><a href="crypto_plugins.shtml">Cryptographic Plugin Programmer Guild</a></li>
+<li><a href="jobacct_gatherplugins.shtml">Job Accounting Gather Plugin Programmer Guide</a></li>
+<li><a href="jobacct_storageplugins.shtml">Job Accounting Storage Plugin Programmer Guide</a></li>
 <li><a href="checkpoint_plugins.shtml">Job Checkpoint Plugin Programmer Guide</a></li>
 <li><a href="jobcompplugins.shtml">Job Completion Logging Plugin Programmer Guide</a></li>
+<li><a href="mpiplugins.shtml">MPI Plugin Programmer Guide</a></li>
 <li><a href="proctrack_plugins.shtml">Process Tracking Plugin Programmer Guide</a></li>
-<li><a href="selectplugins.shtml">Node Selection Plugin Programmer Guide</a></li>
 <li><a href="schedplugins.shtml">Scheduler Plugin Programmer Guide</a></li>
+<li><a href="selectplugins.shtml">Node Selection Plugin Programmer Guide</a></li>
 <li><a href="switchplugins.shtml">Switch (Interconnect) Plugin Programmer Guide</a></li>
 <li><a href="taskplugins.shtml">Task Plugin Programmer Guide</a></li>
-<li><a href="mpiplugins.shtml">MPI Plugin Programmer Guide</a></li>
 </ul>
 
-<p style="text-align:center;">Last modified 12 June 2007</p>
+<p style="text-align:center;">Last modified 28 April 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/download.shtml b/doc/html/download.shtml
index 2b5684af8f41deb10e7240ac7eed8daeef190b33..8c7208c189b627eb04f2ba20d244810534c2ba27 100644
--- a/doc/html/download.shtml
+++ b/doc/html/download.shtml
@@ -3,25 +3,11 @@
 <h1>Download</h1>
 <p>
 SLURM source can be downloaded from <br>
-<a href="ftp://ftp.llnl.gov/pub/linux/slurm/">
-ftp://ftp.llnl.gov/pub/linux/slurm</a> and <br>
 <a href="https://sourceforge.net/projects/slurm/">
 https://sourceforge.net/projects/slurm/</a><br>
-There is also a Debian package repository at <br>
-<a href="http://www.na.icar.cnr.it/~oliva/debs/slurm-llnl/">
-http://www.na.icar.cnr.it/~oliva/debs/slurm-llnl/</a><br>
-The latest stable release is version 1.2.</p>
-
-<p><b>NOTE:</b> The LLNL FTP server has strict firewall restrictions.
-Depending upon your firewall configuration, the use
-of ftp passive mode may be required (use the "-p" option for the
-ftp command, e.g. "ftp -p ftp.llnl.gov"; web browsers may also
-require setting the ftp preference to passive mode).<br>
-<b>NOTE:</b> This server will only download files to computers 
-on which it can perform a reverse DNS lookup for the IP address 
-issuing the request.<br>
-These requirement are part of a LLNL site-wide policy for security 
-purposes that we have no control over.</p> 
+There is also a Debian package named <i>slurm-llnl</i> available at <br>
+<a href="http://www.debian.org/">http://www.debian.org/</a><br>
+The latest stable release of SLURM is version 1.3.</p>
 
 <p> Other software available for download includes
 <ul>
@@ -30,22 +16,17 @@ Pluggable Authentication Module (PAM) for restricting access to compute nodes
 where SLURM performs resource management. Access to the node is restricted to 
 user root and users who have been allocated resources on that node. <br>
 pam_slurm is available for download from <br>
-<a href="ftp://ftp.llnl.gov/pub/linux/pam_slurm/">
-ftp://ftp.llnl.gov/pub/linux/pam_slurm</a> and <br>
 <a href="https://sourceforge.net/projects/slurm/">
-https://sourceforge.net/projects/slurm/</a><br>
+https://sourceforge.net/projects/slurm/</a><br> or use the 
+<a href="http://www.debian.org/">Debian</a> package 
+named <i>libpam-slurm</i>.<br>
 The latest stable release is version 1.4.</p>
 
 </ul>
 <h1>Related Software</h1>
 <ul>
 
-<li><b>OpenSSL</b> is required for secure communications between SLURM 
-components. Download it from 
-<a href="http://www.openssl.org/">http://www.openssl.org/</a>.
-</li>
-
-<li>Authentication plugins</li>
+<li>Authentication plugins identifies the user originating a message.</li>
 <ul>
 <li><b>Munge</b><br>
 In order to compile the "auth/munge" authentication plugin for SLURM, you will need
@@ -54,7 +35,27 @@ to build and install Munge, available from
 </li>
 </ul>
 
-<li>Interconnect plugins</li>
+<li>Databases can be used to store accounting information.
+See our <a href="accounting.html">Accounting</a> web page for more information.</li>
+<ul>
+<li><a href="http://www.clusterresources.com/pages/products/gold-allocation-manager.php">Gold</a></li>
+<li><a href="http://www.mysql.com/">MySQL</a></li>
+<li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
+</ul>
+
+<li>Digital signatures (Cypto plugin) are used to insure message are not altered.</li>
+<ul>
+<li><b>OpenSSL</b><br>
+OpenSSL is recommended for generation of digital signatures.
+Download it from <a href="http://www.openssl.org/">http://www.openssl.org/</a>.</li>
+<li><b>Munge</b><br>
+Munge can be used at an alternative to OpenSSL. 
+Munge is available under the Gnu General Public License, but is slower than OpenSSL 
+for the generation of digital signatures. Munge is available from 
+<a href="http://home.gna.org/munge/">http://home.gna.org/munge/</a>.</li>
+</ul> 
+
+<li>Interconnect plugins (Switch plugin)</li>
 <ul>
 <li><b>QsNet</b><br>
 In order to build the "switch/elan" plugin for SLURM, you will need
@@ -63,7 +64,8 @@ the <b>qsnetlibs</b> development libraries from
 plugin also requires the <b>libelanhosts</b> library and
 a corresponding /etc/elanhosts configuration file, used to map
 hostnames to Elan IDs. The libelanhosts source is available from
-<a href="ftp://ftp.llnl.gov/pub/linux/libelanhosts/">ftp://ftp.llnl.gov/pub/linux/libelanhosts</a>.
+<a href="https://sourceforge.net/projects/slurm/">
+https://sourceforge.net/projects/slurm/</a>.
 </ul>
 
 <li>MPI versions supported</li>
@@ -72,16 +74,16 @@ hostnames to Elan IDs. The libelanhosts source is available from
 <li><a href="http://www.hp.com/go/mpi">HP-MPI</a></li>
 <li><a href="http://www.lam-mpi.org/">LAM/MPI</a></li>
 <li><a href="http://www-unix.mcs.anl.gov/mpi/mpich1/">MPICH1</a></li>
-<li><a href="http://www-unix.mcs.anl.gov/mpi/mpich2/">MPICH2</a></li>
+<li><a href="http://www.mcs.anl.gov/research/projects/mpich2/">MPICH2</a></li>
 <li><a href="http://www.myri.com/scs/download-mpichgm.html">MPICH-GM</a></li>
 <li><a href="http://www.myri.com/scs/download-mpichmx.html">MPICH-MX</a></li>
-<li><a href="http://nowlab.cse.ohio-state.edu/projects/mpi-iba">MVAPICH</a></li>
+<li><a href="http://mvapich.cse.ohio-state.edu/">MVAPICH</a></li>
 <li><a href="http://nowlab.cse.ohio-state.edu/projects/mpi-iba">MVAPICH2</a></li>
 <li><a href="http://www.open-mpi.org">Open MPI</a></li>
 <li><a href="http://www.quadrics.com/">Quadrics MPI</a></li>
 </ul>
 
-<li>Schedulers</li>
+<li>Schedulers offering greater control over the workload</li>
 <ul>
 <li><a href="http://www.platform.com/">Load Sharing Facility (LSF)</a></li>
 <li><a href="http://www.clusterresources.com/pages/products/maui-cluster-scheduler.php">
@@ -92,12 +94,12 @@ Moab Cluster Suite</a></li>
 
 <li>Task Affinity plugins</li>
 <ul>
-<li><a href="http://www.open-mpi.org/software/plpa">
+<li><a href="http://www.open-mpi.org/software/plpa/">
 Portable Linux Processor Affinity (PLPA)</a></li>
 </ul> 
 
 </ul>
 
-<p style="text-align:center;">Last modified 15 June 2007</p>
+<p style="text-align:center;">Last modified 28 March 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/faq.shtml b/doc/html/faq.shtml
index 0b931757b58c61453a4310664011595caa3e5b17..ac6d62e6f42edef04d00c0d1df8eec6fb4958651 100644
--- a/doc/html/faq.shtml
+++ b/doc/html/faq.shtml
@@ -10,7 +10,6 @@
 to run on nodes?</a></li>
 <li><a href="#purge">Why is my job killed prematurely?</a></li>
 <li><a href="#opts">Why are my srun options ignored?</a></li>
-<li><a href="#cred">Why are &quot;Invalid job credential&quot; errors generated?</a></li>
 <li><a href="#backfill">Why is the SLURM backfill scheduler not starting my 
 job?</a></li>
 <li><a href="#steps">How can I run multiple jobs from within a single script?</a></li>
@@ -23,6 +22,9 @@ name for a batch job?</a></li>
 <li><a href="#parallel_make">Can the <i>make</i> command utilize the resources 
 allocated to a SLURM job?</a></li>
 <li><a href="#terminal">Can tasks be launched with a remote terminal?</a></li>
+<li><a href="#force">What does &quot;srun: Force Terminated job&quot; indicate?</a></li>
+<li><a href="#early_exit">What does this mean: &quot;srun: First task exited 30s ago&quot;
+followed by &quot;srun Job Failed&quot;?</a></li>
 </ol>
 <h2>For Administrators</h2>
 <ol>
@@ -53,14 +55,33 @@ parallel for testing purposes?</a></li>
 <li><a href="#multi_slurmd">Can slurm emulate a larger cluster?</a></li>
 <li><a href="#extra_procs">Can SLURM emulate nodes with more 
 resources than physically exist on the node?</a></li>
-<li><a href="#credential_replayed">What does a "credential
-replayed" error in the <i>SlurmdLogFile</i> indicate?</a></li>
-<li><a href="#large_time">What does a "Warning: Note very large
-processing time" in the <i>SlurmctldLogFile</i> indicate?</a></li>
+<li><a href="#credential_replayed">What does a 
+&quot;credential replayed&quot; error in the <i>SlurmdLogFile</i> 
+indicate?</a></li>
+<li><a href="#large_time">What does 
+&quot;Warning: Note very large processing time&quot; 
+in the <i>SlurmctldLogFile</i> indicate?</a></li>
 <li><a href="#lightweight_core">How can I add support for lightweight
 core files?</a></li>
 <li><a href="#limit_propagation">Is resource limit propagation
 useful on a homogeneous cluster?</a></li>
+<li<a href="#clock">Do I need to maintain synchronized clocks 
+on the cluster?</a></li>
+<li><a href="#cred_invalid">Why are &quot;Invalid job credential&quot; errors 
+generated?</a></li>
+<li><a href="#cred_replay">Why are 
+&quot;Task launch failed on node ... Job credential replayed&quot; 
+errors generated?</a></li>
+<li><a href="#globus">Can SLURM be used with Globus?</li>
+<li><a href="#time_format">Can SLURM time output format include the year?</li>
+<li><a href="#file_limit">What causes the error 
+&quot;Unable to accept new connection: Too many open files&quot;?</li>
+<li><a href="#slurmd_log">Why does the setting of <i>SlurmdDebug</i> fail 
+to log job step information at the appropriate level?</li>
+<li><a href="#rpm">Why isn't the auth_none.so (or other file) in a 
+SLURM RPM?</li>
+<li><a href="#slurmdbd">Why should I use the slurmdbd instead of the
+regular database plugins?</li>
 </ol>
 
 <h2>For Users</h2>
@@ -198,14 +219,7 @@ hostname command. Which will change the name of the computer
 on which SLURM executes the command - Very bad, <b>Don't run 
 this command as user root!</b></p>
 
-<p><a name="cred"><b>7. Why are &quot;Invalid job credential&quot; errors generated?
-</b></a><br>
-This error is indicative of SLURM's job credential files being inconsistent across 
-the cluster. All nodes in the cluster must have the matching public and private 
-keys as defined by <b>JobCredPrivateKey</b> and <b>JobCredPublicKey</b> in the 
-slurm configuration file <b>slurm.conf</b>.
-
-<p><a name="backfill"><b>8. Why is the SLURM backfill scheduler not starting my job?
+<p><a name="backfill"><b>7. Why is the SLURM backfill scheduler not starting my job?
 </b></a><br>
 There are significant limitations in the current backfill scheduler plugin. 
 It was designed to perform backfill node scheduling for a homogeneous cluster.
@@ -214,23 +228,27 @@ resources). It also does not update the required or excluded node list of
 individual jobs. These are the current limiations. You can use the 
 scontrol show command to check if these conditions apply.</p> 
 <ul>
-<li>partition: State=UP</li>
-<li>partition: RootOnly=NO</li>
-<li>partition: Shared=NO</li>
-<li>job: ReqNodeList=NULL</li>
-<li>job: ExcNodeList=NULL</li>
-<li>job: Contiguous=0</li>
-<li>job: Features=NULL</li>
-<li>job: MinProcs, MinMemory, and MinTmpDisk satisfied by all nodes in 
+<li>Partition: State=UP</li>
+<li>Partition: RootOnly=NO</li>
+<li>Partition: Shared=NO</li>
+<li>Job: ReqNodeList=NULL</li>
+<li>Job: ExcNodeList=NULL</li>
+<li>Job: Contiguous=0</li>
+<li>Job: Features=NULL</li>
+<li>Job: MinProcs, MinMemory, and MinTmpDisk satisfied by all nodes in 
 the partition</li>
-<li>job: MinProcs or MinNodes not to exceed partition's MaxNodes</li>
+<li>Job: MinProcs or MinNodes not to exceed partition's MaxNodes</li>
 </ul>
-<p>As soon as any priority-ordered job in the partition's queue fail to 
-satisfy the request, no lower priority job in that partition's queue 
-will be considered as a backfill candidate. Any programmer wishing 
-to augment the existing code is welcome to do so. 
-
-<p><a name="steps"><b>9. How can I run multiple jobs from within a 
+<p>If the partitions specifications differ from those listed above, 
+no jobs in that partition will be scheduled by the backfills scheduler. 
+Their jobs will only be scheduled on a First-In-First-Out (FIFO) basis.</p>
+<p>Jobs failing to satisfy the requirements above (i.e. with specific 
+node requirements) will not be considered candidates for backfill 
+scheduling and other jobs may be scheduled ahead of these jobs. 
+These jobs are subject to starvation, but will not block other 
+jobs from running when sufficient resources are available for them.</p>
+
+<p><a name="steps"><b>8. How can I run multiple jobs from within a 
 single script?</b></a><br>
 A SLURM job is just a resource allocation. You can execute many 
 job steps within that allocation, either in parallel or sequentially. 
@@ -239,7 +257,7 @@ steps will be allocated nodes that are not already allocated to
 other job steps. This essential provides a second level of resource 
 management within the job for the job steps.</p>
 
-<p><a name="orphan"><b>10. Why do I have job steps when my job has 
+<p><a name="orphan"><b>9. Why do I have job steps when my job has 
 already COMPLETED?</b></a><br>
 NOTE: This only applies to systems configured with 
 <i>SwitchType=switch/elan</i> or <i>SwitchType=switch/federation</i>.
@@ -256,7 +274,7 @@ This enables SLURM to purge job information in a timely fashion
 even when there are many failing nodes.
 Unfortunately the job step information may persist longer.</p>
 
-<p><a name="multi_batch"><b>11. How can I run a job within an existing
+<p><a name="multi_batch"><b>10. How can I run a job within an existing
 job allocation?</b></a><br>
 There is a srun option <i>--jobid</i> that can be used to specify 
 a job's ID. 
@@ -272,7 +290,7 @@ If you specify that a batch job should use an existing allocation,
 that job allocation will be released upon the termination of 
 that batch job.</p>
 
-<p><a name="user_env"><b>12. How does SLURM establish the environment 
+<p><a name="user_env"><b>11. How does SLURM establish the environment 
 for my job?</b></a><br>
 SLURM processes are not run under a shell, but directly exec'ed 
 by the <i>slurmd</i> daemon (assuming <i>srun</i> is used to launch 
@@ -282,26 +300,16 @@ is executed are propagated to the spawned processes.
 The <i>~/.profile</i> and <i>~/.bashrc</i> scripts are not executed 
 as part of the process launch.</p>
 
-<p><a name="prompt"><b>13. How can I get shell prompts in interactive 
+<p><a name="prompt"><b>12. How can I get shell prompts in interactive 
 mode?</b></a><br>
 <i>srun -u bash -i</i><br>
 Srun's <i>-u</i> option turns off buffering of stdout.
 Bash's <i>-i</i> option tells it to run in interactive mode (with prompts).
 
-<p><a name="batch_out"><b>14. How can I get the task ID in the output 
+<p><a name="batch_out"><b>13. How can I get the task ID in the output 
 or error file name for a batch job?</b></a><br>
-The <i>srun -b</i> or <i>sbatch</i> commands are meant to accept a 
-script rather than a command line. If you specify a command line 
-rather than a script, it gets translated to a simple script of this
-sort:</p>
-<pre>
-#!/bin/sh
-srun hostname
-</pre>
-<p>You will note that the srun command lacks the output file specification.
-It's output (for all tasks) becomes the output of the job. If you
-want separate output by task, you will need to build a script containing
-this specification. For example:</p>
+<p>If you want separate output by task, you will need to build a script 
+containing this specification. For example:</p>
 <pre>
 $ cat test
 #!/bin/sh
@@ -328,7 +336,7 @@ $ cat out_65541_2
 tdev2
 </pre>
 
-<p><a name="parallel_make"><b>15. Can the <i>make</i> command
+<p><a name="parallel_make"><b>14. Can the <i>make</i> command
 utilize the resources allocated to a SLURM job?</b></a><br>
 Yes. There is a patch available for GNU make version 3.81 
 available as part of the SLURM distribution in the file 
@@ -341,15 +349,13 @@ overhead of SLURM's task launch. Use with make's <i>-j</i> option within an
 existing SLURM allocation. Outside of a SLURM allocation, make's behavior
 will be unchanged.</p>
 
-<p><a name="terminal"><b>16. Can tasks be launched with a remote 
+<p><a name="terminal"><b>15. Can tasks be launched with a remote 
 terminal?</b></a><br>
-SLURM does not directly support a remote pseudo terminal for spawned 
-tasks. 
-We intend to remedy this in Slurm version 1.3. 
+In SLURM version 1.3 or higher, use srun's <i>--pty</i> option.
 Until then, you can accomplish this by starting an appropriate program 
 or script. In the simplest case (X11 over TCP with the DISPLAY 
-environment already set), <i>srun xterm</i> may suffice. In the more 
-general case, the following scripts should work. 
+environment already set), executing <i>srun xterm</i> may suffice. 
+In the more general case, the following scripts should work. 
 <b>NOTE: The pathname to the additional scripts are included in the 
 variables BS and IS of the first script. You must change this in the 
 first script.</b>
@@ -409,7 +415,7 @@ ssh -X -t $NODE $IS slurm$JOB
 </pre>
 
 <p>NOTE: The above script executes the script below, 
-named <i>_interactive<i>.</p>
+named <i>_interactive</i>.</p>
 <pre>
 #!/bin/sh
 # -*- coding: utf-8 -*-
@@ -443,6 +449,33 @@ fi
 exec screen -S $SCREENSESSION -rd
 </pre>
 
+<p><a name="force"><b>16. What does &quot;srun: Force Terminated job&quot; 
+indicate?</b></a><br>
+The srun command normally terminates when the standard output and 
+error I/O from the spawned tasks end. This does not necessarily 
+happen at the same time that a job step is terminated. For example, 
+a file system problem could render a spawned tasks non-killable 
+at the same time that I/O to srun is pending. Alternately a network 
+problem could prevent the I/O from being transmitted to srun.
+In any event, the srun command is notified when a job step is 
+terminated, either upon reaching its time limit or being explicitly 
+killed. If the srun has not already terminated, the message 
+&quot;srun: Force Terminated job&quot; is printed. 
+If the job step's I/O does not terminate in a timely fashion
+thereafter, pending I/O is abandoned and the srun command 
+exits.</p>
+
+<p><a name="early_exit"><b>17. What does this mean: 
+&quot;srun: First task exited 30s ago&quot;
+followed by &quot;srun Job Failed&quot;?</b></a><br>
+The srun command monitors when tasks exit. By default, 30 seconds 
+after the first task exists, the job is killed. 
+This typically indicates some type of job failure and continuing
+to execute a parallel job when one of the tasks has exited is
+not normally productive. This behavior can be changed using srun's
+<i>--wait=&lt;time&gt;</i> option to either change the timeout
+period or disable the timeout altogether. See srun's man page
+for details.
 
 <p class="footer"><a href="#top">top</a></p>
 
@@ -571,7 +604,10 @@ limit from being propagated:<i>PropagateResourceLimitsExcept=MEMLOCK</i>.</p>
 <p>We also have a PAM module for SLURM that prevents users from 
 logging into nodes that they have not been allocated (except for user 
 root, which can always login. pam_slurm is available for download from
-<a href="ftp://ftp.llnl.gov/pub/linux/pam_slurm/">ftp://ftp.llnl.gov/pub/linux/pam_slurm</a>
+<a href="https://sourceforge.net/projects/slurm/">
+https://sourceforge.net/projects/slurm/</a> or use the
+<a href="http://www.debian.org/">Debian</a> package
+named <i>libpam-slurm</i>.
 The use of pam_slurm does not require <i>UsePAM</i> being set. The 
 two uses of PAM are independent.
 
@@ -665,6 +701,24 @@ for this due to it's improved support for multiple slurmd daemons.
 See the
 <a href="programmer_guide.shtml#multiple_slurmd_support">Programmers Guide</a>
 for more details about configuring multiple slurmd support.
+<p>In order to emulate a really large cluster, it can be more 
+convenient to use a single <i>slurmd</i> daemon. 
+That daemon will not be able to launch many tasks, but can 
+suffice for developing or testing scheduling software.
+<ol>
+<li>Execute the <i>configure</i> program with your normal options.</li>
+<li>Add the line "<i>#define HAVE_FRONT_END 1</i>" to the resulting
+<i>config.h</i> file.</li>
+<li>Build and install SLURM in the usual manner.</li>
+<li>In <i>slurm.conf</i> define the desired node names (arbitrary
+names used only by SLURM) as <i>NodeName</i> along with the actual
+address of the <b>one</b> physical node in <i>NodeHostname</i>.
+Up to 64k nodes can be configured in this virtual cluster.</li>
+<li>Start your <i>slurmctld</i> and one <i>slurmd</i> daemon.</li>
+<li>Create job allocations as desired, but <b>do not run job steps
+with more than a couple of tasks.</b> Doing so may result in the 
+<i>slurmd</i> daemon exhausting its memory and failing.</li>
+</ol>
 
 <p>In order to emulate a really large cluster, it can be more 
 convenient to use a single <i>slurmd</i> daemon. 
@@ -729,8 +783,9 @@ SLURM will use the resource specification for each node that is
 given in <i>slurm.conf</i> and will not check these specifications 
 against those actaully found on the node.
 
-<p><a name="credential_replayed"><b>16. What does a "credential 
-replayed" error in the <i>SlurmdLogFile</i> indicate?</b></a><br>
+<p><a name="credential_replayed"><b>16. What does a 
+&quot;credential replayed&quot; 
+error in the <i>SlurmdLogFile</i> indicate?</b></a><br>
 This error is indicative of the <i>slurmd</i> daemon not being able 
 to respond to job initiation requests from the <i>srun</i> command
 in a timely fashion (a few seconds).
@@ -754,8 +809,9 @@ value higher than the default 5 seconds.
 In earlier versions of Slurm, the <i>--msg-timeout</i> option 
 of <i>srun</i> serves a similar purpose.
 
-<p><a name="large_time"><b>17. What does a "Warning: Note very large
-processing time" in the <i>SlurmctldLogFile</i> indicate?</b></a><br>
+<p><a name="large_time"><b>17. What does 
+&quot;Warning: Note very large processing time&quot; 
+in the <i>SlurmctldLogFile</i> indicate?</b></a><br>
 This error is indicative of some operation taking an unexpectedly
 long time to complete, over one second to be specific.
 Setting the value of <i>SlurmctldDebug</i> configuration parameter 
@@ -795,8 +851,102 @@ option.
 See <i>"man slurm.conf"</i> and <i>"man srun"</i> for more information 
 about these options.
 
+<p><a name="clock"><b>20. Do I need to maintain synchronized 
+clocks on the cluster?</b></a><br>
+In general, yes. Having inconsistent clocks may cause nodes to 
+be unusable. SLURM log files should contain references to 
+expired credentials.
+
+<p><a name="cred_invalid"><b>21. Why are &quot;Invalid job credential&quot; 
+errors generated?</b></a><br>
+This error is indicative of SLURM's job credential files being inconsistent across 
+the cluster. All nodes in the cluster must have the matching public and private 
+keys as defined by <b>JobCredPrivateKey</b> and <b>JobCredPublicKey</b> in the 
+slurm configuration file <b>slurm.conf</b>.
+
+<p><a name="cred_replay"><b>22. Why are 
+&quot;Task launch failed on node ... Job credential replayed&quot; 
+errors generated?</b></a><br>
+This error indicates that a job credential generated by the slurmctld daemon 
+corresponds to a job that the slurmd daemon has already revoked. 
+The slurmctld daemon selects job ID values based upon the configured 
+value of <b>FirstJobId</b> (the default value is 1) and each job gets 
+an value one large than the previous job. 
+On job termination, the slurmctld daemon notifies the slurmd on each 
+allocated node that all processes associated with that job should be 
+terminated. 
+The slurmd daemon maintains a list of the jobs which have already been 
+terminated to avoid replay of task launch requests. 
+If the slurmctld daemon is cold-started (with the &quot;-c&quot; option 
+or &quot;/etc/init.d/slurm startclean&quot;), it starts job ID values 
+over based upon <b>FirstJobId</b>.
+If the slurmd is not also cold-started, it will reject job launch requests 
+for jobs that it considers terminated. 
+This solution to this problem is to cold-start all slurmd daemons whenever
+the slurmctld daemon is cold-started.
+
+<p><a name="globus"><b>23. Can SLURM be used with Globus?</b><br>
+Yes. Build and install SLURM's Torque/PBS command wrappers along with 
+the Perl APIs from SLURM's <i>contribs</i> directory and configure 
+<a href="http://www-unix.globus.org/">Globus</a> to use those PBS commands.
+Note there are RPMs available for both of these packages, named 
+<i>torque</i> and <i>perlapi</i> respectively.
+
+<p><a name="time_format"><b>24. Can SLURM time output format include the 
+year?</b><br>
+The default SLURM time format output is <i>MM/DD-HH:MM:SS</i>. 
+Define &quot;ISO8601&quot; at SLURM build time to get the time format
+<i>YYYY-MM-DDTHH:MM:SS</i>.
+Note that this change in format will break anything that parses 
+SLURM output expecting the old format (e.g. LSF, Maui or Moab).
+
+<p><a name="file_limit"><b>25. What causes the error 
+&quot;Unable to accept new connection: Too many open files&quot;?</b><br>
+The srun command automatically increases its open file limit to 
+the hard limit in order to process all of the standard input and output
+connections to the launched tasks. It is recommended that you set the
+open file hard limit to 8192 across the cluster.
+
+<p><a name="slurmd_log"><b>26. Why does the setting of <i>SlurmdDebug</i> 
+fail to log job step information at the appropriate level?</b><br>
+There are two programs involved here. One is <b>slurmd</b>, which is 
+a persistent daemon running at the desired debug level. The second 
+program is <b>slurmstep</b>, which executed the user job and its
+debug level is controlled by the user. Submitting the job with 
+an option of <i>--debug=#</i> will result in the desired level of 
+detail being logged in the <i>SlurmdLogFile</i> plus the output 
+of the program.
+
+<p><a name="rpm"><b>27. Why isn't the auth_none.so (or other file) in a 
+SLURM RPM?</b><br>
+The auth_none plugin is in a separete RPM and not built by default.
+Using the auth_none plugin means that SLURM communications are not 
+authenticated, so you probably do not want to run in this mode of operation 
+except for testing purposes. If you want to build the auth_none RPM then 
+add <i>--with auth_none</i> on the rpmbuild command line or add 
+<i>%_with_auth_none</i> to your ~/rpmmacros file. See the file slurm.spec 
+in the SLURM distribution for a list of other options.
+
+<p><a name="slurmdbd"><b>28. Why should I use the slurmdbd instead of the
+regular database plugins?</b><br>
+While the normal storage plugins will work fine without the added
+layer of the slurmdbd there are some great benifits to using the
+slurmdbd.
+
+1. Added security.  Using the slurmdbd you can have an authenticated
+   connection to the database.
+2. Off loading processing from the controller.  With the slurmdbd there is no
+   slow down to the controller due to a slow or overloaded database.
+3. Keeping enterprise wide accounting from all slurm clusters in one database.
+   The slurmdbd is multi-threaded and designed to handle all the
+   accounting for the entire enterprise.
+4. With the new database plugins 1.3+ you can query with sacct
+   accounting stats from any node slurm is installed on.  With the
+   slurmdbd you can also query any cluster using the slurmdbd from any
+   other cluster's nodes.
+
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 30 July 2007</p>
+<p style="text-align:center;">Last modified 13 May 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/footer.txt b/doc/html/footer.txt
index af8ad069c6e333c1a5a04e8a5d3b4e09bc5c5e84..49b3c490e0a24b72b7a456525f653d689750aeb4 100644
--- a/doc/html/footer.txt
+++ b/doc/html/footer.txt
@@ -1,13 +1,13 @@
 </div> <!-- closes "content" -->
 
 <div id="footer">
-<div id="left">&nbsp;&nbsp;<span class="ucrlnum">UCRL-WEB-225274 |</span> <a href="http://www.llnl.gov/disclaimer.html" target="_blank" class="privacy">Privacy &amp; Legal Notice</a></div>
-<div id="right"><span class="ucrlnum">November 28, 2006&nbsp;&nbsp;</span></div>
+<div id="left">&nbsp;&nbsp;<span class="ucrlnum">LLNL-WEB-402631 |</span> <a href="https://www.llnl.gov/disclaimer.html" target="_blank" class="privacy">Privacy &amp; Legal Notice</a></div>
+<div id="right"><span class="ucrlnum">12 March 2008&nbsp;&nbsp;</span></div>
 </div>
 
 <div id="footer2">
 <div id="left2"><img src="sponsors.gif" width="129" height="30" border="0" usemap="#Map2"></div>
-<div id="center2"><a href="http://www.llnl.gov/" target="_blank" class="footer">Lawrence Livermore National Laboratory</a><br />
+<div id="center2"><a href="https://www.llnl.gov/" target="_blank" class="footer">Lawrence Livermore National Laboratory</a><br />
 <span class="smalltextblue">7000 East Avenue &#8226; Livermore, CA 94550</span></div>
 <div id="right2"><span class="smalltextblue">Operated by
 Lawrence Livermore National Security, LLC, for the</span> 
@@ -21,7 +21,7 @@ National Nuclear Security Administration</a></div>
 </div> <!-- closes "container" -->
 
 <map name="Map">
-<area shape="rect" coords="571,1,799,15" href="http://www.llnl.gov/">
+<area shape="rect" coords="571,1,799,15" href="https://www.llnl.gov/">
 </map>
 <map name="Map2">
 <area shape="rect" coords="1,1,92,30" href="http://www.nnsa.doe.gov/" target="_blank" alt="NNSA logo links to the NNSA Web site">
diff --git a/doc/html/gang_scheduling.shtml b/doc/html/gang_scheduling.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..66c0b7cf690a86d02f163c293690400f21297874
--- /dev/null
+++ b/doc/html/gang_scheduling.shtml
@@ -0,0 +1,472 @@
+<!--#include virtual="header.txt"-->
+
+<H1>Gang Scheduling</H1>
+
+<P>
+SLURM version 1.2 and earlier supported dedication of resources
+to jobs.
+Beginning in SLURM version 1.3, gang scheduling is supported. 
+Gang scheduling is when two or more jobs are allocated to the same resources 
+and these jobs are alternately suspended to let all of the tasks of each 
+job have full access to the shared resources for a period of time.
+</P>
+<P>
+A resource manager that supports timeslicing can improve it's responsiveness
+and utilization by allowing more jobs to begin running sooner. Shorter-running 
+jobs no longer have to wait in a queue behind longer-running jobs. Instead they 
+can be run "in parallel" with the longer-running jobs, which will allow them 
+to finish quicker. Throughput is also improved because overcommitting the 
+resources provides opportunities for "local backfilling" to occur (see example 
+below).
+</P>
+<P>
+The SLURM 1.3.0 the <I>sched/gang</I> plugin provides timeslicing. When enabled, 
+it monitors each of the partitions in SLURM. If a new job has been allocated to
+resources in a partition that have already been allocated to an existing job,
+then the plugin will suspend the new job until the configured
+<I>SchedulerTimeslice</I> interval has elapsed. Then it will suspend the
+running job and let the new job make use of the resources for a 
+<I>SchedulerTimeslice</I> interval. This will continue until one of the
+jobs terminates.
+</P>
+
+<H2>Configuration</H2>
+<P>
+There are several important configuration parameters relating to 
+gang scheduling:
+</P>
+<UL>
+<LI>
+<B>SelectType</B>: The SLURM <I>sched/gang</I> plugin supports nodes 
+allocated by the <I>select/linear</I> plugin and socket/core/CPU resources 
+allocated by the <I>select/cons_res</I> plugin.
+</LI>
+<LI>
+<B>SelectTypeParameter</B>: Since resources will be getting overallocated 
+with jobs, the resource selection plugin should be configured to track the 
+amount of memory used by each job to ensure that memory page swapping does 
+not occur. When <I>select/linear</I> is chosen, we recommend setting 
+<I>SelectTypeParameter=CR_Memory</I>. When <I>select/cons_res</I> is
+chosen, we recommend including Memory as a resource (ex.
+<I>SelectTypeParameter=CR_Core_Memory</I>).
+</LI>
+<LI>
+<B>DefMemPerTask</B>: Since job requests may not explicitly specify 
+a memory requirement, we also recommend configuring <I>DefMemPerTask</I> 
+(default memory per task). It may also be desirable to configure 
+<I>MaxMemPerTask</I> (maximum memory per task) in <I>slurm.conf</I>.
+</LI>
+<LI>
+<B>JobAcctGatherType and JobAcctGatherFrequency</B>:
+If you wish to enforce memory limits, accounting must be enabled
+using the <I>JobAcctGatherType</I> and <I>JobAcctGatherFrequency</I>
+parameters. If accounting is enabled and a job exceeds its configured
+memory limits, it will be canceled in order to prevent it from 
+adversely effecting other jobs sharing the same resources.
+</LI>
+<LI>
+<B>SchedulerType</B>: Configure the <I>sched/gang</I> plugin by setting
+<I>SchedulerType=sched/gang</I> in <I>slurm.conf</I>.
+</LI>
+<LI>
+<B>SchedulerTimeSlice</B>: The default timeslice interval is 30 seconds. 
+To change this duration, set <I>SchedulerTimeSlice</I> to the desired interval 
+(in seconds) in <I>slurm.conf</I>. For example, to set the timeslice interval 
+to one minute, set <I>SchedulerTimeSlice=60</I>. Short values can increase 
+the overhead of gang scheduling.
+</LI>
+<LI>
+<B>Shared</B>: Configure the partitions <I>Shared</I> setting to 
+<I>FORCE</I> for all partitions in which timeslicing is to take place. 
+The <I>FORCE</I> option now supports an additional parameter that controls 
+how many jobs can share a resource (FORCE[:max_share]). By default the 
+max_share value is 4. To allow up to 6 jobs from this partition to be 
+allocated to a common resource, set <I>Shared=FORCE:6</I>.
+</LI>
+</UL>
+<P>
+In order to enable gang scheduling after making the configuration changes 
+described above, restart SLURM if it is already running. Any change to the 
+plugin settings in SLURM requires a full restart of the daemons. If you 
+just change the partition <I>Shared</I> setting, this can be updated with
+<I>scontrol reconfig</I>.
+</P>
+<P>
+For an advanced topic discussion on the potential use of swap space, 
+see "Making use of swap space" in the "Future Work" section below.
+</P>
+
+<H2>Timeslicer Design and Operation</H2>
+
+<P>
+When enabled, the <I>sched/gang</I> plugin keeps track of the resources
+allocated to all jobs. For each partition an "active bitmap" is maintained that
+tracks all concurrently running jobs in the SLURM cluster. Each time a new
+job is allocated to resources in a partition, the <I>sched/gang</I> plugin
+compares these newly allocated resources with the resources already maintained
+in the "active bitmap". If these two sets of resources are disjoint then the new
+job is added to the "active bitmap". If these two sets of resources overlap then
+the new job is suspended. All jobs are tracked in a per-partition job queue
+within the <I>sched/gang</I> plugin.
+</P>
+<P>
+A separate <I>timeslicer thread</I> is spawned by the <I>sched/gang</I> plugin
+on startup. This thread sleeps for the configured <I>SchedulerTimeSlice</I>
+interval. When it wakes up, it checks each partition for suspended jobs. If
+suspended jobs are found then the <I>timeslicer thread</I> moves all running
+jobs to the end of the job queue. It then reconstructs the "active bitmap" for
+this partition beginning with the suspended job that has waited the longest to
+run (this will be the first suspended job in the run queue). Each following job
+is then compared with the new "active bitmap", and if the job can be run
+concurrently with the other "active" jobs then the job is added. Once this is
+complete then the <I>timeslicer thread</I> suspends any currently running jobs
+that are no longer part of the "active bitmap", and resumes jobs that are new to
+the "active bitmap".
+</P>
+<P>
+This <I>timeslicer thread</I> algorithm for rotating jobs is designed to prevent
+jobs from starving (remaining in the suspended state indefinitly) and to be as
+fair as possible in the distribution of runtime while still keeping all of the
+resources as busy as possible.
+</P>
+<P>
+The <I>sched/gang</I> plugin suspends jobs via the same internal functions that
+support <I>scontrol suspend</I> and <I>scontrol resume</I>. A good way to
+observe the operation of the timeslicer is by running <I>watch squeue</I> in a
+terminal window.
+</P>
+
+<H2>A Simple Example</H2>
+
+<P>
+The following example is configured with <I>select/linear</I>,
+<I>sched/gang</I>, and <I>Shared=FORCE</I>. This example takes place on a small
+cluster of 5 nodes:
+</P>
+<PRE>
+[user@n16 load]$ <B>sinfo</B>
+PARTITION AVAIL  TIMELIMIT NODES  STATE NODELIST
+active*      up   infinite     5   idle n[12-16]
+</PRE>
+<P>
+Here are the Scheduler settings (the last two settings are the relevant ones):
+</P>
+<PRE>
+[user@n16 load]$ <B>scontrol show config | grep Sched</B>
+FastSchedule            = 1
+SchedulerPort           = 7321
+SchedulerRootFilter     = 1
+SchedulerTimeSlice      = 30
+SchedulerType           = sched/gang
+[user@n16 load]$
+</PRE>
+<P>
+The <I>myload</I> script launches a simple load-generating app that runs
+for the given number of seconds. Submit <I>myload</I> to run on all nodes:
+</P>
+<PRE>
+[user@n16 load]$ <B>sbatch -N5 ./myload 300</B>
+sbatch: Submitted batch job 3
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+    3    active  myload  user     0:05     5 n[12-16]
+</PRE>
+<P>
+Submit it again and watch the <I>sched/gang</I> plugin suspend it:
+</P>
+<PRE>
+[user@n16 load]$ <B>sbatch -N5 ./myload 300</B>
+sbatch: Submitted batch job 4
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+    3    active  myload  user  R  0:13     5 n[12-16]
+    4    active  myload  user  S  0:00     5 n[12-16]
+</PRE>
+<P>
+After 30 seconds the <I>sched/gang</I> plugin swaps jobs, and now job 4 is the
+active one:
+</P>
+<PRE>
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+    4    active  myload  user  R  0:08     5 n[12-16]
+    3    active  myload  user  S  0:41     5 n[12-16]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+    4    active  myload  user  R  0:21     5 n[12-16]
+    3    active  myload  user  S  0:41     5 n[12-16]
+</PRE>
+<P>
After another 30 seconds the <I>sched/gang</I> plugin sets job 3 running again:
+</P>
+<PRE>
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+    3    active  myload  user  R  0:50     5 n[12-16]
+    4    active  myload  user  S  0:30     5 n[12-16]
+</PRE>
+<P>
+<B>A possible side effect of timeslicing</B>: Note that jobs that are
+immediately suspended may cause their srun commands to produce the following
+output:
+</P>
+<PRE>
+[user@n16 load]$ <B>cat slurm-4.out</B>
+srun: Job step creation temporarily disabled, retrying
+srun: Job step creation still disabled, retrying
+srun: Job step creation still disabled, retrying
+srun: Job step creation still disabled, retrying
+srun: Job step created
+</PRE>
+<P>
+This occurs because <I>srun</I> is attempting to launch a jobstep in an
+allocation that has been suspended. The <I>srun</I> process will continue in a
+retry loop to launch the jobstep until the allocation has been resumed and the
+jobstep can be launched.
+</P>
+<P>
+When the <I>sched/gang</I> plugin is enabled, this type of output in the user
+jobs should be considered benign.
+</P>
+
+<H2>More examples</H2>
+<P>
+The following example shows how the timeslicer algorithm keeps the resources
+busy. Job 10 runs continually, while jobs 9 and 11 are timesliced:
+</P>
+<PRE>
+[user@n16 load]$ <B>sbatch -N3 ./myload 300</B>
+sbatch: Submitted batch job 9
+[user@n16 load]$ <B>sbatch -N2 ./myload 300</B>
+sbatch: Submitted batch job 10
+[user@n16 load]$ <B>sbatch -N3 ./myload 300</B>
+sbatch: Submitted batch job 11
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+    9    active  myload  user  R  0:11     3 n[12-14]
+   10    active  myload  user  R  0:08     2 n[15-16]
+   11    active  myload  user  S  0:00     3 n[12-14]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   10    active  myload  user  R  0:50     2 n[15-16]
+   11    active  myload  user  R  0:12     3 n[12-14]
+    9    active  myload  user  S  0:41     3 n[12-14]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   10    active  myload  user  R  1:04     2 n[15-16]
+   11    active  myload  user  R  0:26     3 n[12-14]
+    9    active  myload  user  S  0:41     3 n[12-14]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+    9    active  myload  user  R  0:46     3 n[12-14]
+   10    active  myload  user  R  1:13     2 n[15-16]
+   11    active  myload  user  S  0:30     3 n[12-14]
+[user@n16 load]$
+</PRE>
+</P>
+<P>
+The next example displays "local backfilling":
+</P>
+<PRE>
+[user@n16 load]$ <B>sbatch -N3 ./myload 300</B>
+sbatch: Submitted batch job 12
+[user@n16 load]$ <B>sbatch -N5 ./myload 300</B>
+sbatch: Submitted batch job 13
+[user@n16 load]$ <B>sbatch -N2 ./myload 300</B>
+sbatch: Submitted batch job 14
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   12    active  myload  user  R  0:14     3 n[12-14]
+   14    active  myload  user  R  0:06     2 n[15-16]
+   13    active  myload  user  S  0:00     5 n[12-16]
+[user@n16 load]$
+</PRE>
+<P>
+Without timeslicing and without the backfill scheduler enabled, job 14 has to
+wait for job 13 to finish.
+</P><P>
+This is called "local" backfilling because the backfilling only occurs with jobs
+close enough in the queue to get allocated by the scheduler as part of
+oversubscribing the resources. Recall that the number of jobs that can
+overcommit a resource is controlled by the <I>Shared=FORCE:max_share</I> value,
+so this value effectively controls the scope of "local backfilling".
+</P><P>
+Normal backfill algorithms check <U>all</U> jobs in the wait queue.
+</P>
+
+<H2>Consumable Resource Examples</H2>
+<P>
+The following two examples illustrate the primary difference between
+<I>CR_CPU</I> and <I>CR_Core</I> when consumable resource selection is enabled
+(<I>select/cons_res</I>).
+</P>
+<P>
+When <I>CR_CPU</I> (or <I>CR_CPU_Memory</I>) is configured then the selector
+treats the CPUs as simple, <I>interchangeable</I> computing resources. However
+when <I>CR_Core</I> (or <I>CR_Core_Memory</I>) is enabled the selector treats
+the CPUs as individual resources that are <U>specifically</U> allocated to jobs.
+This subtle difference is highlighted when timeslicing is enabled.
+</P>
+<P>
+In both examples 6 jobs are submitted. Each job requests 2 CPUs per node, and
+all of the nodes contain two quad-core processors. The timeslicer will initially
+let the first 4 jobs run and suspend the last 2 jobs. The manner in which these
+jobs are timesliced depends upon the configured <I>SelectTypeParameter</I>.
+</P>
+<P>
+In the first example <I>CR_Core_Memory</I> is configured. Note that jobs 46 and
+47 don't <U>ever</U> get suspended. This is because they are not sharing their
+cores with any other job. Jobs 48 and 49 were allocated to the same cores as
+jobs 45 and 46. The timeslicer recognizes this and timeslices only those jobs: 
+</P>
+<PRE>
+[user@n16 load]$ <B>sinfo</B>
+PARTITION AVAIL  TIMELIMIT NODES  STATE NODELIST
+active*      up   infinite     5   idle n[12-16]
+[user@n16 load]$ <B>scontrol show config | grep Select</B>
+SelectType              = select/cons_res
+SelectTypeParameters    = CR_CORE_MEMORY
+[user@n16 load]$ <B>sinfo -o "%20N %5D %5c %5z"</B>
+NODELIST             NODES CPUS  S:C:T
+n[12-16]             5     8     2:4:1
+[user@n16 load]$
+[user@n16 load]$
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 44
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 45
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 46
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 47
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 48
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 49
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   44    active  myload  user  R  0:09     5 n[12-16]
+   45    active  myload  user  R  0:08     5 n[12-16]
+   46    active  myload  user  R  0:08     5 n[12-16]
+   47    active  myload  user  R  0:07     5 n[12-16]
+   48    active  myload  user  S  0:00     5 n[12-16]
+   49    active  myload  user  S  0:00     5 n[12-16]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   46    active  myload  user  R  0:49     5 n[12-16]
+   47    active  myload  user  R  0:48     5 n[12-16]
+   48    active  myload  user  R  0:06     5 n[12-16]
+   49    active  myload  user  R  0:06     5 n[12-16]
+   44    active  myload  user  S  0:44     5 n[12-16]
+   45    active  myload  user  S  0:43     5 n[12-16]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   44    active  myload  user  R  1:23     5 n[12-16]
+   45    active  myload  user  R  1:22     5 n[12-16]
+   46    active  myload  user  R  2:22     5 n[12-16]
+   47    active  myload  user  R  2:21     5 n[12-16]
+   48    active  myload  user  S  1:00     5 n[12-16]
+   49    active  myload  user  S  1:00     5 n[12-16]
+[user@n16 load]$
+</PRE>
+<P>
+Note the runtime of all 6 jobs in the output of the last <I>squeue</I> command.
+Jobs 46 and 47 have been running continuously, while jobs 45 and 46 are
+splitting their runtime with jobs 48 and 49.
+</P><P>
+The next example has <I>CR_CPU_Memory</I> configured and the same 6 jobs are
+submitted. Here the selector and the timeslicer treat the CPUs as countable
+resources which results in all 6 jobs sharing time on the CPUs:
+</P>
+<PRE>
+[user@n16 load]$ <B>sinfo</B>
+PARTITION AVAIL  TIMELIMIT NODES  STATE NODELIST
+active*      up   infinite     5   idle n[12-16]
+[user@n16 load]$ <B>scontrol show config | grep Select</B>
+SelectType              = select/cons_res
+SelectTypeParameters    = CR_CPU_MEMORY
+[user@n16 load]$ <B>sinfo -o "%20N %5D %5c %5z"</B>
+NODELIST             NODES CPUS  S:C:T
+n[12-16]             5     8     2:4:1
+[user@n16 load]$
+[user@n16 load]$
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 51
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 52
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 53
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 54
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 55
+[user@n16 load]$ <B>sbatch -n10 -N5 ./myload 300</B>
+sbatch: Submitted batch job 56
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   51    active  myload  user  R  0:11     5 n[12-16]
+   52    active  myload  user  R  0:11     5 n[12-16]
+   53    active  myload  user  R  0:10     5 n[12-16]
+   54    active  myload  user  R  0:09     5 n[12-16]
+   55    active  myload  user  S  0:00     5 n[12-16]
+   56    active  myload  user  S  0:00     5 n[12-16]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   51    active  myload  user  R  1:09     5 n[12-16]
+   52    active  myload  user  R  1:09     5 n[12-16]
+   55    active  myload  user  R  0:23     5 n[12-16]
+   56    active  myload  user  R  0:23     5 n[12-16]
+   53    active  myload  user  S  0:45     5 n[12-16]
+   54    active  myload  user  S  0:44     5 n[12-16]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   53    active  myload  user  R  0:55     5 n[12-16]
+   54    active  myload  user  R  0:54     5 n[12-16]
+   55    active  myload  user  R  0:40     5 n[12-16]
+   56    active  myload  user  R  0:40     5 n[12-16]
+   51    active  myload  user  S  1:16     5 n[12-16]
+   52    active  myload  user  S  1:16     5 n[12-16]
+[user@n16 load]$ <B>squeue</B>
+JOBID PARTITION    NAME  USER ST  TIME NODES NODELIST
+   51    active  myload  user  R  3:18     5 n[12-16]
+   52    active  myload  user  R  3:18     5 n[12-16]
+   53    active  myload  user  R  3:17     5 n[12-16]
+   54    active  myload  user  R  3:16     5 n[12-16]
+   55    active  myload  user  S  3:00     5 n[12-16]
+   56    active  myload  user  S  3:00     5 n[12-16]
+[user@n16 load]$
+</PRE>
+<P>
+Note that the runtime of all 6 jobs is roughly equal. Jobs 51-54 ran first so
+they're slightly ahead, but so far all jobs have run for at least 3 minutes.
+</P><P>
+At the core level this means that SLURM relies on the linux kernel to move jobs
+around on the cores to maximize performance. This is different than when
+<I>CR_Core_Memory</I> was configured and the jobs would effectively remain
+"pinned" to their specific cores for the duration of the job. Note that
+<I>CR_Core_Memory</I> supports CPU binding, while <I>CR_CPU_Memory</I> does not.
+</P>
+
+<H2>Future Work</H2>
+
+<P>
+Priority scheduling and preemptive scheduling are other forms of gang
+scheduling that are currently under development for SLURM.
+</P>
+<P>
+<B>Making use of swap space</B>: (note that this topic is not currently
+scheduled for development, unless someone would like to pursue this) It should
+be noted that timeslicing does provide an interesting mechanism for high
+performance jobs to make use of swap space. The optimal scenario is one in which
+suspended jobs are "swapped out" and active jobs are "swapped in". The swapping
+activity would only occur once every  <I>SchedulerTimeslice</I> interval.
+</P>
+<P>
+However, SLURM should first be modified to include support for scheduling jobs
+into swap space and to provide controls to prevent overcommitting swap space.
+For now this idea could be experimented with by disabling memory support in the
+selector and submitting appropriately sized jobs.
+</P>
+
+<p style="text-align:center;">Last modified 17 March 2008</p>
+
+<!--#include virtual="footer.txt"-->
diff --git a/doc/html/header.txt b/doc/html/header.txt
index 097af4411c7c4a2c19dd0511fd4d1381be0d06de..2f84c37a8589cdd4bb81c0de6460d78f80c7c596 100644
--- a/doc/html/header.txt
+++ b/doc/html/header.txt
@@ -8,7 +8,7 @@
 <meta http-equiv="Pragma" content="no-cache">
 <meta http-equiv="keywords" content="Simple Linux Utility for Resource Management, SLURM, resource management, 
 Linux clusters, high-performance computing, Livermore Computing">
-<meta name="LLNLRandR" content="UCRL-WEB-225274">
+<meta name="LLNLRandR" content="LLNL-WEB-402631">
 <meta name="LLNLRandRdate" content="18 December 2006">
 <meta name="distribution" content="global">
 <meta name="description" content="Simple Linux Utility for Resource Management">
diff --git a/doc/html/jobacct_gatherplugins.shtml b/doc/html/jobacct_gatherplugins.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..1dc934d314bdee436329f41a3ea7da2689833b5d
--- /dev/null
+++ b/doc/html/jobacct_gatherplugins.shtml
@@ -0,0 +1,262 @@
+<!--#include virtual="header.txt"-->
+
+<h1><a name="top">SLURM Job Accounting Gather Plugin API</a></h1>
+
+<h2> Overview</h2>
+<p> This document describes SLURM job accounting gather plugins and the API that
+defines them. It is intended as a resource to programmers wishing to write
+their own SLURM job accounting gather plugins. This is version 1 of the API.
+
+
+<p>SLURM job accounting gather plugins must conform to the
+SLURM Plugin API with the following specifications:
+
+<p><span class="commandline">const char
+plugin_name[]="<i>full&nbsp;text&nbsp;name</i>"
+<p style="margin-left:.2in">
+A free-formatted ASCII text string that identifies the plugin.
+
+<p><span class="commandline">const char
+plugin_type[]="<i>major/minor</i>"</span><br>
+<p style="margin-left:.2in">
+The major type must be &quot;jobacct_gather.&quot;
+The minor type can be any suitable name
+for the type of accounting package. We currently use
+<ul>
+<li><b>aix</b>&#151; Gathers information from AIX /proc table and adds this
+information to the standard rusage information also gathered for each job.
+<li><b>linux</b>&#151;Gathers information from Linux /proc table and adds this
+information to the standard rusage information also gathered for each job.
+<li><b>none</b>&#151;No information gathered.
+</ul>
+The <b>sacct</b> program can be used to display gathered data from regular
+accounting and from these plugins.
+<p>The programmer is urged to study 
+<span class="commandline">src/plugins/jobacct_gather/linux</span> and 
+<span class="commandline">src/common/jobacct_common.c/.h</span>
+for a sample implementation of a SLURM job accounting gather plugin.
+<p class="footer"><a href="#top">top</a>
+
+
+<h2>API Functions</h2>
+<p>All of the following functions are required. Functions which are not
+implemented must be stubbed.
+
+<p class="commandline">jobacctinfo_t *jobacct_gather_p_create(jobacct_id_t *jobacct_id) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_alloc() used to alloc a pointer to and initialize a 
+new jobacctinfo structure.<br><br>
+You will need to free the information returned by this function!
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">tid</span> 
+(input) id of the task send in (uint16_t)NO_VAL if no specfic task.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">jobacctinfo structure pointer</span> on success, or<br>
+<span class="commandline">NULL</span> on failure.
+
+<p class="commandline">void jobacct_gather_p_destroy(jobacctinfo_t *jobacct) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_free() used to free the allocation made by jobacct_gather_p_alloc().
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">jobacct</span> 
+(input) structure to be freed.<br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span>
+
+<p class="commandline">
+int jobacct_gather_p_setinfo(jobacctinfo_t *jobacct, 
+                      enum jobacct_data_type type, void *data) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_setinfo() is called to set the values of a jobacctinfo_t to
+specific values based on inputs.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">jobacct</span> 
+(input/output) structure to be altered.<br>
+<span class="commandline">type</span> 
+(input) enum of specific part of jobacct to alter.<br>
+<span class="commandline">data</span> 
+(input) corresponding data to set jobacct part to.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int jobacct_gather_p_getinfo(jobacctinfo_t *jobacct, 
+                      enum jobacct_data_type type, void *data) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_getinfo() is called to get the values of a jobacctinfo_t
+specific values based on inputs.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">jobacct</span> 
+(input) structure to be queried.<br>
+<span class="commandline">type</span> 
+(input) enum of specific part of jobacct to get.<br>
+<span class="commandline">data</span> 
+(output) corresponding data to from jobacct part.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+void jobacct_gather_p_pack(jobacctinfo_t *jobacct, Buf buffer) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_pack() pack jobacctinfo_t in a buffer to send across the network.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">jobacct</span> 
+(input) structure to pack.<br>
+<span class="commandline">buffer</span> 
+(input/output) buffer to pack structure into.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span>
+
+<p class="commandline">
+void jobacct_gather_p_unpack(jobacctinfo_t *jobacct, Buf buffer) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_unpack() unpack jobacctinfo_t from a buffer received from 
+the network.
+You will need to free the jobacctinfo_t returned by this function!
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">jobacct</span> 
+(input/output) structure to fill.<br>
+<span class="commandline">buffer</span> 
+(input) buffer to unpack structure from.<br>
+<p style="margin-left:.2in"><b>Returns</b>: 
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+void jobacct_gather_p_aggregate(jobacctinfo_t *dest, jobacctinfo_t *from) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_aggregate() is called to aggregate and get max values from two 
+different jobacctinfo structures.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">dest</span> 
+(input/output) initial structure to be applied to.<br>
+<span class="commandline">from</span> 
+(input) new info to apply to dest.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span>
+
+<p class="footer"><a href="#top">top</a>
+
+<p class="commandline">int jobacct_gather_p_startpoll(int frequency) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_startpoll() is called at the start of the slurmstepd, 
+this starts a thread that should poll information to be queried at any time
+during throughout the end of the process.  
+Put global initialization here.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">frequency</span> (input) poll frequency for polling
+thread.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">int jobacct_gather_p_endpoll() 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_endpoll() is called when the process is finished to stop the 
+polling thread.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">void jobacct_gather_p_suspend_poll() 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_suspend_poll() is called when the process is suspended.
+This causes the polling thread to halt until the process is resumed.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span>
+
+<p class="commandline">void jobacct_gather_p_resume_poll()
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_resume_poll() is called when the process is resumed.
+This causes the polling thread to resume operation.
+<p style="margin-left:.2in"><b>Arguments</b>:<br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>:<br>
+<span class="commandline">none</span>
+
+<p class="commandline">int jobacct_gather_p_set_proctrack_container_id(uint32_t id) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_set_proctrack_container_id() is called after the
+proctrack container id is known at the start of the slurmstepd, 
+if using a proctrack plugin to track processes this will set the head
+of the process tree in the plugin.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">id</span> (input) procktrack container id.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">int jobacct_gather_p_add_task(pid_t pid, uint16_t tid) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_add_task() used to add a task to the poller.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline"> pid</span> (input) Process id <br> 
+<span class="commandline"> tid</span> (input) slurm global task id
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">jobacctinfo_t *jobacct_gather_p_stat_task(pid_t pid) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_stat_task() used to get most recent information about task.
+You need to FREE the information returned by this function!
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline"> pid</span> (input) Process id  
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">jobacctinfo structure pointer</span> on success, or<br>
+<span class="commandline">NULL</span> on failure.
+
+<p class="commandline">jobacctinfo_t *jobacct_gather_p_remove_task(pid_t pid) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_remove_task() used to remove a task from the poller.
+You need to FREE the information returned by this function!
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline"> pid</span> (input) Process id  
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">Pointer to removed jobacctinfo_t structure</span> 
+on success, or <br>
+<span class="commandline">NULL</span> on failure.
+
+<p class="commandline">
+void jobacct_gather_p_2_sacct(sacct_t *sacct, jobacctinfo_t *jobacct) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_gather_p_2_sacct() is called to transfer information from data structure 
+jobacct to structure sacct.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">sacct</span> 
+(input/output) initial structure to be applied to.<br>
+<span class="commandline">jobacct</span> 
+(input) jobacctinfo_t structure containing information to apply to sacct.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span>
+
+<p class="footer"><a href="#top">top</a>
+
+
+<h2>Parameters</h2>
+<p>These parameters can be used in the slurm.conf to set up type of
+plugin and the frequency at which to gather information about running jobs.
+<dl>
+<dt><span class="commandline">JobAcctGatherType</span>
+<dd>Specifies which plugin should be used.
+<dt><span class="commandline">JobAcctGatherFrequency</span>
+<dd>Let the plugin know how long between pollings.
+</dl>
+
+<h2>Versioning</h2>
+<p> This document describes version 1 of the SLURM Job Accounting Gather API. Future 
+releases of SLURM may revise this API. A job accounting gather plugin conveys its
+ability to implement a particular API version using the mechanism outlined
+for SLURM plugins.
+<p class="footer"><a href="#top">top</a>
+
+<p style="text-align:center;">Last modified 11 Sep 2007</p>
+
+<!--#include virtual="footer.txt"-->
diff --git a/doc/html/jobacct_storageplugins.shtml b/doc/html/jobacct_storageplugins.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..107c16221643762f2f940bb493be3940d9f77aa5
--- /dev/null
+++ b/doc/html/jobacct_storageplugins.shtml
@@ -0,0 +1,204 @@
+<!--#include virtual="header.txt"-->
+
+<h1><a name="top">SLURM Job Accounting Storage Plugin API</a></h1>
+
+<h2> Overview</h2>
+<p> This document describes SLURM Job Accounting Storage plugins and the API that
+defines them. It is intended as a resource to programmers wishing to write
+their own SLURM Job Accounting Storage plugins. This is version 1 of the API.
+
+<p>SLURM Job Accounting Storage plugins must conform to the
+SLURM Plugin API with the following specifications:
+
+<p><span class="commandline">const char
+plugin_name[]="<i>full&nbsp;text&nbsp;name</i>"
+<p style="margin-left:.2in">
+A free-formatted ASCII text string that identifies the plugin.
+
+<p><span class="commandline">const char
+plugin_type[]="<i>major/minor</i>"</span><br>
+<p style="margin-left:.2in">
+The major type must be &quot;jobacct_storage.&quot;
+The minor type can be any suitable name
+for the type of accounting package. We currently use
+<ul>
+<li><b>filetxt</b>&#151;Information written to a text file.
+<li><b>mysql</b>&#151; Store information in a mysql database.
+<li><b>pgsql</b>&#151; Store information in a postgresql database.
+<li><b>none</b>&#151; Information is not stored anywhere.
+</ul>
+<p>The programmer is urged to study 
+<span class="commandline">src/plugins/jobacct_storage/mysql</span>
+for a sample implementation of a SLURM Job Accounting Storage plugin.
+<p> The Job Accounting Storage plugin was written to be a interface
+to storage data collected by the Job Accounting Gather plugin.  When
+adding a new database you may want to add common functions in a common
+file in the src/common dir.  Refer to src/common/mysql_common.c/.h for an
+example so other plugins can also use that database type to write out
+information. 
+<p class="footer"><a href="#top">top</a>
+
+
+<h2>API Functions</h2>
+
+The Job Accounting Storage API uses hooks in the slurmctld.
+
+<p>All of the following functions are required. Functions which are not
+implemented must be stubbed. 
+
+<h4>Functions called by the jobacct_storage plugin</h4>
+
+<p class="commandline">int jobacct_storage_p_init(char *location) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_init() is called to initiate a connection to the
+database server and check the state of the database table to make sure
+they are in sync with the table definitions in the plugin.  
+Put global initialization here. Or open file or anything to initialize
+the plugin.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">location</span> (input) database name or log
+file location.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">int jobacct_storage_p_fini() 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_fini() is called at the end of the program that has
+called jobacct_storage_p_init this function closes the connection to
+the database or logfile.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">none</span>
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int jobacct_storage_p_job_start(struct job_record *job_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_job_start() is called in the jobacct plugin when a
+job starts, inserting information into the database about the new job.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">job_ptr</span> (input) information about the job in 
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int jobacct_storage_p_job_complete(struct job_record *job_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_job_complete() is called in the jobacct plugin when
+a job completes, this updates info about end of a job.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">job_ptr</span> (input) information about the job in 
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int jobacct_storage_p_step_start(struct step_record *step_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_step_start() is called in the jobacct plugin at the
+allocation of a new step in the slurmctld, this inserts info about the
+beginning of a step.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">step_ptr</span> (input) information about the step in
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int jobacct_storage_p_step_complete(struct step_record *step_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_step_complete() is called in the jobacct plugin at
+the end of a step in the slurmctld, this updates the ending
+information about a step.
+<p style="margin-left:.2in"><b>Arguments</b>:<br> 
+<span class="commandline">step_ptr</span> (input) information about the step in
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">SLURM_SUCCESS</span> on success, or<br>
+<span class="commandline">SLURM_ERROR</span> on failure.
+
+<p class="commandline">
+int jobacct_storage_p_suspend(struct job_record *job_ptr) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_suspend() is called in the jobacct plugin when a
+job is suspended or resumed in the slurmctld, this updates the
+database about the suspended time of the job. 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">job_ptr</span> (input) information about the job in 
+slurmctld.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span>
+
+<p class="commandline">
+void jobacct_storage_p_get_jobs(List job_list, List selected_steps,
+List selected_parts, void *params) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+jobacct_storage_p_get_jobs() is called to get a list of jobs from the
+database given the specific inputs. 
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">List job_list </span> (input/output) list to
+be filled with jobacct_job_rec_t.<br>
+<span class="commandline">List selected_steps </span>
+(input) list containing type jobacct_select_step_t to query against.<br>
+<span class="commandline">List selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">void *params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+
+<p style="margin-left:.2in">jobacct_job_rec_t, jobacct_select_step_t,
+and sacct_parameters_t are
+all defined in common/slurm_jobacct.h
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span> 
+
+<p class="commandline">
+void jobacct_storage_p_archive(List selected_parts, void *params) 
+<p style="margin-left:.2in"><b>Description</b>:<br>
+database_p_jobcomp_archive() used to archive old data.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">List selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">void *params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+<p style="margin-left:.2in"><b>Returns</b>: <br>
+<span class="commandline">none</span> 
+
+<p class="footer"><a href="#top">top</a>
+
+
+<h2>Parameters</h2>
+<p>These parameters can be used in the slurm.conf to set up
+connections to the database all have defaults based on the plugin type
+used.
+<dl>
+<dt><span class="commandline">JobAcctStorageType</span>
+<dd>Specifies which plugin should be used.
+<dt><span class="commandline">JobAcctStorageLoc</span>
+<dd>Let the plugin the name of the logfile/database name to use.
+<dt><span class="commandline">JobAcctStorageHost</span>
+<dd>Let the plugin know the host where the database is.
+<dt><span class="commandline">JobAcctStoragePort</span>
+<dd>Let the plugin know the port to connect to.
+<dt><span class="commandline">JobAcctStorageUser</span>
+<dd>Let the plugin know the name of the user to connect to the
+database with.
+<dt><span class="commandline">JobAcctStoragePass</span>
+<dd>Let the plugin know the password of the user connecting to the database.
+</dl>
+
+<h2>Versioning</h2>
+<p> This document describes version 1 of the SLURM Job Accounting Storage API. Future 
+releases of SLURM may revise this API. A Job Accounting Storage plugin conveys its
+ability to implement a particular API version using the mechanism outlined
+for SLURM plugins.
+<p class="footer"><a href="#top">top</a>
+
+<p style="text-align:center;">Last modified 23 May 2007</p>
+
+<!--#include virtual="footer.txt"-->
diff --git a/doc/html/jobacctplugins.shtml b/doc/html/jobacctplugins.shtml
deleted file mode 100644
index fc1cdff64462b6e800c088f7b47129a6cda582ca..0000000000000000000000000000000000000000
--- a/doc/html/jobacctplugins.shtml
+++ /dev/null
@@ -1,359 +0,0 @@
-<!--#include virtual="header.txt"-->
-
-<h1><a name="top">SLURM Job Accounting Plugin API</a></h1>
-
-<h2> Overview</h2>
-<p> This document describes SLURM job accounting plugins and the API that
-defines them. It is intended as a resource to programmers wishing to write
-their own SLURM job accounting plugins. This is version 1 of the API.
-
-
-<p>SLURM job accounting plugins must conform to the
-SLURM Plugin API with the following specifications:
-
-<p><span class="commandline">const char
-plugin_name[]="<i>full&nbsp;text&nbsp;name</i>"
-<p style="margin-left:.2in">
-A free-formatted ASCII text string that identifies the plugin.
-
-<p><span class="commandline">const char
-plugin_type[]="<i>major/minor</i>"</span><br>
-<p style="margin-left:.2in">
-The major type must be &quot;jobacct.&quot;
-The minor type can be any suitable name
-for the type of accounting package. We currently use
-<ul>
-<li><b>aix</b>&#151; Gathers information from AIX /proc table and adds this
-information to the standard rusage information also gathered for each job.
-<li><b>linux</b>&#151;Gathers information from Linux /proc table and adds this
-information to the standard rusage information also gathered for each job.
-<li><b>none</b>&#151;No information gathered.
-</ul>
-The <b>sacct</b> program can be used to display gathered data from regular
-accounting and from these plugins.
-<p>The programmer is urged to study 
-<span class="commandline">src/plugins/jobacct/linux</span> and 
-<span class="commandline">src/plugins/jobacct/common</span>
-for a sample implementation of a SLURM job accounting plugin.
-<p class="footer"><a href="#top">top</a>
-
-
-<h2>API Functions</h2>
-
-The job accounting API uses hooks in the slurmctld, slurmd, and slurmstepd.
-
-<p>All of the following functions are required. Functions which are not
-implemented must be stubbed.
-
-<h4>Functions called by all slurmstepd processes</h4>
-
-<p class="commandline">int jobacct_p_startpoll(int frequency) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_startpoll() is called at the start of the slurmstepd, 
-this starts a thread that should poll information to be queried at any time
-during throughout the end of the process.  
-Put global initialization here.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">frequency</span> (input) poll frequency for polling
-thread.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">int jobacct_p_endpoll() 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_endpoll() is called when the process is finished to stop the 
-polling thread.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">void jobacct_p_suspend_poll() 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_suspend_poll() is called when the process is suspended.
-This causes the polling thread to halt until the process is resumed.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">none</span>
-
-<p class="commandline">void jobacct_p_resume_poll()
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_resume_poll() is called when the process is resumed.
-This causes the polling thread to resume operation.
-<p style="margin-left:.2in"><b>Arguments</b>:
-<span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>:
-<span class="commandline">none</span>
-
-
-<p class="commandline">int jobacct_p_add_task(pid_t pid, uint16_t tid) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_add_task() used to add a task to the poller.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline"> pid</span> (input) Process id  
-<span class="commandline"> tid</span> (input) slurm global task id
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">jobacctinfo_t *jobacct_p_stat_task(pid_t pid) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_stat_task() used to get most recent information about task.
-You need to FREE the information returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline"> pid</span> (input) Process id  
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">jobacctinfo structure pointer</span> on success, or
-<span class="commandline">NULL</span> on failure.
-
-<p class="commandline">jobacctinfo_t *jobacct_p_remove_task(pid_t pid) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_remove_task() used to remove a task from the poller.
-You need to FREE the information returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline"> pid</span> (input) Process id  
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">Pointer to removed jobacctinfo_t structure</span> 
-on success, or 
-<span class="commandline">NULL</span> on failure.
-
-<p class="footer"><a href="#top">top</a>
-
-<h4>Functions called by the slurmctld process</h4>
-
-<p class="commandline">int jobacct_p_init_slurmctld(char *job_acct_log) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_init_slurmctld() is called at the start of the slurmctld, 
-this opens the logfile to be written to.  
-Put global initialization here.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">job_acct_log</span> (input) logfile name.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">int jobacct_p_fini_slurmctld() 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_fini_slurmctld() is called at the end of the slurmctld, 
-this closes the logfile.  
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">
-int jobacct_p_job_start_slurmctld(struct job_record *job_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_job_start_slurmctld() is called at the allocation of a new job in 
-the slurmctld, this prints out beginning information about a job.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">job_ptr</span> (input) information about the job in 
-slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">
-int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_job_complete_slurmctld() is called at the end of a job in 
-the slurmctld, this prints out ending information about a job.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">job_ptr</span> (input) information about the job in 
-slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">
-int jobacct_p_step_start_slurmctld(struct step_record *step_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_step_start_slurmctld() is called at the allocation of a new step in 
-the slurmctld, this prints out beginning information about a step.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">step_ptr</span> (input) information about the step in
-slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">
-int jobacct_p_step_complete_slurmctld(struct step_record *step_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_step_complete_slurmctld() is called at the end of a step in 
-the slurmctld, this prints out ending information about a step.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">step_ptr</span> (input) information about the step in
-slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">
-int jobacct_p_suspend_slurmctld(struct job_record *job_ptr) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_suspend_slurmctld() is called when a job is suspended or resumed in 
-the slurmctld, this prints out information about the suspension of the job 
-to the logfile.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">job_ptr</span> (input) information about the job in 
-slurmctld.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="footer"><a href="#top">top</a>
-
-<h4>Functions common to all processes</h4>
-
-<p class="commandline">
-int jobacct_p_init_struct(jobacctinfo_t *jobacct, uint16_t tid) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_init_struct() is called to set the values of a jobacctinfo_t to
-initial values.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">jobacct</span> 
-(input/output) structure to be altered.
-<span class="commandline">tid</span> 
-(input) id of the task send in (uint16_t)NO_VAL if no specfic task.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">jobacctinfo_t *jobacct_p_alloc(uint16_t tid) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_alloc() used to alloc a pointer to and initialize a 
-new jobacctinfo structure.<br>
-You will need to free the information returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">tid</span> 
-(input) id of the task send in (uint16_t)NO_VAL if no specfic task.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">jobacctinfo structure pointer</span> on success, or
-<span class="commandline">NULL</span> on failure.
-
-<p class="commandline">void jobacct_p_free(jobacctinfo_t *jobacct) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_free() used to free the allocation made by jobacct_p_alloc().
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">jobacct</span> 
-(input) structure to be freed.
-<span class="commandline">none</span>
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">none</span>
-
-<p class="commandline">
-int jobacct_p_setinfo(jobacctinfo_t *jobacct, 
-                      enum jobacct_data_type type, void *data) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_setinfo() is called to set the values of a jobacctinfo_t to
-specific values based on inputs.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">jobacct</span> 
-(input/output) structure to be altered.
-<span class="commandline">type</span> 
-(input) enum of specific part of jobacct to alter.
-<span class="commandline">data</span> 
-(input) corresponding data to set jobacct part to.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">
-int jobacct_p_getinfo(jobacctinfo_t *jobacct, 
-                      enum jobacct_data_type type, void *data) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_getinfo() is called to get the values of a jobacctinfo_t
-specific values based on inputs.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">jobacct</span> 
-(input) structure to be queried.
-<span class="commandline">type</span> 
-(input) enum of specific part of jobacct to get.
-<span class="commandline">data</span> 
-(output) corresponding data to from jobacct part.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="commandline">
-void jobacct_p_aggregate(jobacctinfo_t *dest, jobacctinfo_t *from) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_aggregate() is called to aggregate and get max values from two 
-different jobacctinfo structures.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">dest</span> 
-(input/output) initial structure to be applied to.
-<span class="commandline">from</span> 
-(input) new info to apply to dest.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">none</span>
-
-<p class="commandline">
-void jobacct_p_2_sacct(sacct_t *sacct, jobacctinfo_t *jobacct) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_2_sacct() is called to transfer information from data structure 
-jobacct to structure sacct.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">sacct</span> 
-(input/output) initial structure to be applied to.
-<span class="commandline">jobacct</span> 
-(input) jobacctinfo_t structure containing information to apply to sacct.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">none</span>
-
-<p class="commandline">
-void jobacct_p_pack(jobacctinfo_t *jobacct, Buf buffer) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_pack() pack jobacctinfo_t in a buffer to send across the network.
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">jobacct</span> 
-(input) structure to pack.
-<span class="commandline">buffer</span> 
-(input/output) buffer to pack structure into.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">none</span>
-
-<p class="commandline">
-void jobacct_p_unpack(jobacctinfo_t *jobacct, Buf buffer) 
-<p style="margin-left:.2in"><b>Description</b>:
-jobacct_p_unpack() unpack jobacctinfo_t from a buffer received from 
-the network.
-You will need to free the jobacctinfo_t returned by this function!
-<p style="margin-left:.2in"><b>Arguments</b>: 
-<span class="commandline">jobacct</span> 
-(input/output) structure to fill.
-<span class="commandline">buffer</span> 
-(input) buffer to unpack structure from.
-<p style="margin-left:.2in"><b>Returns</b>: 
-<span class="commandline">SLURM_SUCCESS</span> on success, or
-<span class="commandline">SLURM_FAILURE</span> on failure.
-
-<p class="footer"><a href="#top">top</a>
-
-<h2>Parameters</h2>
-<p>Rather than proliferate slurm.conf parameters for new or evolved
-plugins, the job accounting API counts on three parameters:
-<dl>
-<dt><span class="commandline">JobAcctType</span>
-<dd>Specifies which plugin should be used.
-<dt><span class="commandline">JobAcctFrequency</span>
-<dd>Let the plugin know how long between pollings.
-<dt><span class="commandline">JobAcctLogFile</span>
-<dd>Let the plugin the name of the logfile to use.
-</dl>
-
-<h2>Versioning</h2>
-<p> This document describes version 1 of the SLURM Job Accounting API. Future 
-releases of SLURM may revise this API. A job accounting plugin conveys its
-ability to implement a particular API version using the mechanism outlined
-for SLURM plugins.
-<p class="footer"><a href="#top">top</a>
-
-<p style="text-align:center;">Last modified 31 January 2007</p>
-
-<!--#include virtual="footer.txt"-->
diff --git a/doc/html/jobcompplugins.shtml b/doc/html/jobcompplugins.shtml
index 93f21b5bc070e429d4f43c35431cc23f64301048..e208eb51195aa37294ac1b8df30598aec011fcf9 100644
--- a/doc/html/jobcompplugins.shtml
+++ b/doc/html/jobcompplugins.shtml
@@ -16,16 +16,20 @@ abbreviation for the type of scheduler. We recommend, for example:</p>
 <ul>
 <li><b>none</b>&#151;No job logging.</li>
 <li><b>filetxt</b>&#151;Log job information to a text file.</li>
+<li><b>mysql</b>&#151;Job completion is written to a mysql database.</li>
+<li><b>pgsql</b>&#151;Job completion is written to a pgsql database.</li>
 <li><b>script</b>&#151;Execute a script passing in job information in environment variables.</li>
 </ul>
+The <b>sacct</b> program with option <b>-c</b> can be used to display
+gathered data from database and filetxt plugins.
 <p>The <span class="commandline">plugin_name</span> and 
 <span class="commandline">plugin_version</span> 
 symbols required by the SLURM Plugin API require no specialization for 
 job completion logging support. 
 Note carefully, however, the versioning discussion below.</p>
 <p>The programmer is urged to study 
-<span class="commandline">src/plugins/jobcomp/jobcomp_filetxt.c</span> and
-<span class="commandline">src/plugins/jobcomp/jobcomp_none.c</span> 
+<span class="commandline">src/plugins/jobcomp/filetxt/jobcomp_filetxt.c</span> and
+<span class="commandline">src/plugins/jobcomp/none/jobcomp_none.c</span> 
 for sample implementations of a SLURM job completion logging plugin.</p>
 <p class="footer"><a href="#top">top</a></p>
 
@@ -52,8 +56,7 @@ SLURM_SUCCESS. </p>
 <p class="footer"><a href="#top">top</a></p>
 
 <h2>API Functions</h2>
-<p>The following functions must appear. Functions which are not implemented should 
-be stubbed.</p>
+<p>The following functions must appear. Functions which are not implemented should be stubbed.</p>
 
 <p class="commandline">int slurm_jobcomp_set_location (char * location);</p>
 <p style="margin-left:.2in"><b>Description</b>: Specify the location to be used for job logging.</p>
@@ -63,8 +66,9 @@ this string is at the discression of the plugin implementation.</p>
 <p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful. On failure, 
 the plugin should return SLURM_ERROR and set the errno to an appropriate value 
 to indicate the reason for failure.</p>
+<p class="footer"><a href="#top">top</a></p>
 
-<p class="commandline">int slurm_jobcomp_log_record ( struct job_record *job_ptr);</p>
+<p class="commandline">int slurm_jobcomp_log_record (struct job_record *job_ptr);</p>
 <p style="margin-left:.2in"><b>Description</b>: Note termation of a job with the specified 
 characteristics.</p>
 <p style="margin-left:.2in"><b>Argument</b>: <br>
@@ -76,15 +80,14 @@ to indicate the reason for failure.</p>
 <p class="footer"><a href="#top">top</a></p>
 
 <a name="get_errno"><p class="commandline">int slurm_jobcomp_get_errno (void);</p></a>
-<p style="margin-left:.2in"><b>Description</b>: Return the number of a job completion
-logger specific error.</p>
+<p style="margin-left:.2in"><b>Description</b>: Return the number of a
+job completion logger specific error.</p>
 <p style="margin-left:.2in"><b>Arguments</b>: None</p>
-<p style="margin-left:.2in"><b>Returns</b>: Error number for the last failure encountered by 
-the job completion logging plugin.</p>
+<p style="margin-left:.2in"><b>Returns</b>: Error number for the last failure encountered by the job completion logging plugin.</p>
+<p class="footer"><a href="#top">top</a></p>
 
 <p class="commandline"><a name="strerror">const char *slurm_jobcomp_strerror(int errnum);</a></p>
-<p style="margin-left:.2in"><b>Description</b>: Return a string description of a job completion 
-logger specific error code.</p>
+<p style="margin-left:.2in"><b>Description</b>: Return a string description of a job completion logger specific error code.</p>
 <p style="margin-left:.2in"><b>Arguments</b>:
 <span class="commandline"> errnum</span>&nbsp; &nbsp;&nbsp;(input) a job completion logger
 specific error code.</p>
@@ -92,12 +95,40 @@ specific error code.</p>
 or NULL if no description found in this plugin.</p>
 <p class="footer"><a href="#top">top</a></p>
 
+<p class="commandline">
+void slurm_jobcomp_get_jobs(List job_list, List selected_steps, List selected_parts, void *paramsint errnum);</a></p>
+<p style="margin-left:.2in"><b>Description</b>: Get completed job info from the storage.</p>
+<p style="margin-left:.2in"><b>Arguments</b>:<br>
+<span class="commandline"> job_list</span>
+(input/output) List of job_rec_t pointers of requested jobs.<br>
+<span class="commandline">selected_steps </span>
+(input) list containing type jobacct_select_step_t to query against.<br>
+<span class="commandline">selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+<p style="margin-left:.2in">jobcomp_job_rec_t is defined in common/slurm_jobcomp.h
+<p style="margin-left:.2in"><b>Returns</b>: None</p>
+<p class="footer"><a href="#top">top</a></p>
+
+<p class="commandline">
+void slurm_jobcomp_archive(List selected_parts, void *params) 
+<p style="margin-left:.2in"><b>Description</b>: used to archive old data.
+<p style="margin-left:.2in"><b>Arguments</b>: <br>
+<span class="commandline">List selected_parts </span>
+(input) list containing char *'s of names of partitions to query against.<br>
+<span class="commandline">void *params </span>
+(input) to be cast as sacct_parameters_t in the plugin.
+<p style="margin-left:.2in"><b>Returns</b>: None</p>
+<p class="footer"><a href="#top">top</a></p>
+
+
 <h2>Versioning</h2>
-<p> This document describes version 0 of the SLURM job completion API. Future 
+<p> This document describes version 1 of the SLURM job completion API. Future 
 releases of SLURM may revise this API. A job completion plugin conveys its ability 
 to implement a particular API version using the mechanism outlined for SLURM plugins.</p>
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 10 July 2005</p>
+<p style="text-align:center;">Last modified 10 Sep 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/maui.shtml b/doc/html/maui.shtml
index f630980dc64b6e8e8a7040b7a6737e7882af9ea3..7debca57e3c4432e128e37c8e360908a6d6c628f 100644
--- a/doc/html/maui.shtml
+++ b/doc/html/maui.shtml
@@ -30,7 +30,9 @@ Then build Maui from its source distribution. This is a two step process:</p>
 <li>gmake
 </ol>
 <p>The key of 42 is arbitrary. You can use any value, but will need to 
-specify the same value as a SLURM configuration parameter.</p>
+specify the same value as a SLURM configuration parameter.
+Maui developers have assured us the authenticaion key will eventually be 
+set in a configuration file rather than at build time.</p>
 
 <p>Update the Maui configuration file <i>maui.conf</i> (Copy the file
 maui-3.2.6p9/maui.cfg.dist to maui.conf). Add the following configuration 
@@ -90,10 +92,9 @@ SchedulerType=sched/wiki
 SchedulerPort=7321
 SchedulerAuth=42 (for Slurm version 1.1 and earlier only)
 </pre>
-<p>In this case, "SchedulerAuth" has been set to 42, which was the key 
-specified when Maui was configured above. Just make sure the numbers match.  
-The Maui folks have assured us that the key won't always be a compiled-in 
-feature.</p>
+<p>In this case, "SchedulerAuth" has been set to 42, which was the 
+authenticaiton key specified when Maui was configured above. 
+Just make sure the numbers match.</p>
 
 <p>For Slurm version 1.2 or higher, the authentication key 
 is stored in a file specific to the wiki-plugin named 
@@ -160,6 +161,6 @@ HidePartitionJobs=debug
 
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 17 September 2007</p>
+<p style="text-align:center;">Last modified 19 September 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/moab.shtml b/doc/html/moab.shtml
index 30f40b30a524a00d0ffe0e752025d28565dc01cd..247b3f7346c81e2ba873f1dc934d8ed9dd6506b5 100644
--- a/doc/html/moab.shtml
+++ b/doc/html/moab.shtml
@@ -175,8 +175,78 @@ CLIENTCFG[RM:slurm] KEY=123456789
 </pre>
 <p>Insure that this file is protected from viewing by users. </p>
 
+<h3>Job Submission</h3>
+
+<p>Jobs can either be submitted to Moab or directly to SLURM.
+Moab's <i>msub</i> command has a <i>--slurm</i> option that can 
+be placed at the <b>end</b> of the command line and those options 
+will be passed to SLURM. This can be used to invoke SLURM 
+options which are not directly supported by Moab (e.g.
+system images to boot, task distribution specification across 
+sockets, cores, and hyperthreads, etc.).
+For example:
+<pre>
+msub my.script -l walltime=600,nodes=2 \
+     --slurm --linux-image=/bgl/linux_image2
+</pre>
+
+<h3>User Environment</h3>
+
+<p>When a user submits a job to Moab, that job could potentially 
+execute on a variety of computers, so it is typically necessary 
+that the user's environment on the execution host be loaded. 
+Moab relies upon SLURM to perform this action, using the 
+<i>--get-user-env</i> option for the salloc, sbatch and srun commands.
+The SLURM command then executes as user root a command of this sort
+as user root:
+<pre>
+/bin/su - &lt;user&gt; -c \
+        "/bin/echo BEGIN; /bin/env; /bin/echo FINI"
+</pre>
+While this command is executing within salloc, sbatch or srun, 
+the Moab daemon is completely non-responsive. 
+To insure that Moab remains operational, SLURM will abort the above
+command within a few seconds and look for a cache file with the 
+user's environment and use that if found. 
+Otherwise an error is reported to Moab.
+We have provided a simple program that can be used to build 
+cache files for users. The program can be found in the SLURM
+distribution at <i>contribs/env_cache_builder.c</i>. 
+This program can support a longer timeout than Moab, but 
+will report errors for users for whom the environment file 
+can not be automatically build (typically due to the user's
+"dot" files spawning another shell so the desired command 
+never execution).
+For such user, you can manually build a cache file.
+You may want to execute this program periodically to capture 
+information for new users or changes in existing users'
+environment.
+A sample execution is shown below. 
+Run this on the same host as the Moab daemon and execute it as user root.</p>
+
+<pre>
+bash-3.00# make -f /dev/null env_cache_builder
+cc     env_cache_builder.c   -o env_cache_builder
+bash-3.00# ./env_cache_builder
+Building user environment cache files for Moab/Slurm.
+This will take a while.
+
+Processed 100 users...
+***ERROR: Failed to get current user environment variables for alice
+***ERROR: Failed to get current user environment variables for brian
+Processed 200 users...
+Processed 300 users...
+***ERROR: Failed to get current user environment variables for christine
+***ERROR: Failed to get current user environment variables for david
+
+Some user environments could not be loaded.
+Manually run 'env' for those 4 users.
+Write the output to a file with the same name as the user in the
+  /usr/local/tmp/slurm/atlas/env_cache directory
+</pre>
+
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 17 August 2007</p>
+<p style="text-align:center;">Last modified 23 April 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/news.shtml b/doc/html/news.shtml
index 56b9cd07353a9d2b922e4a05d199ab1e25d45b3b..432b09786f12fc67b5194ef2f0498399ae1e096c 100644
--- a/doc/html/news.shtml
+++ b/doc/html/news.shtml
@@ -6,7 +6,7 @@
 <ul>
 <li><a href="#11">SLURM Version 1.1, May 2006</a></li>
 <li><a href="#12">SLURM Version 1.2, February 2007</a></li>
-<li><a href="#13">SLURM Version 1.3, Winter 2007</a></li>
+<li><a href="#13">SLURM Version 1.3, March 2008</a></li>
 <li><a href="#14">SLURM Version 1.4 and beyond</a></li>
 </ul>
 
@@ -57,20 +57,33 @@ mechanism.</li>
 <a href="power_save.html">power savings</a> on idle nodes.</li>
 <li>Support for MPICH-MX, MPICH1/shmem and MPICH1/p4 added with 
 task launch directly from the <i>srun</i> command.</li>
-<li>Perl APIs and wrappers for mpiexec and the Torque/PBS commands.</li>
+<li>Wrappers available for common Torque/PBS commands 
+(<i>psub</i>, <i>pstat</i>, and <i>pbsnodes</i>).</li>
+<li>Support for <a href="http://www-unix.globus.org/">Globus</a> 
+(using Torque/PBS command wrappers).</li>
+<li>Wrapper available for <i>mpiexec</i> command.</li>
 </ul>
 
 <h2><a name="13">Major Updates in SLURM Version 1.3</a></h2>
-<p>SLURM Version 1.3 is scheduled for release in the Winter of 2007.
+<p>SLURM Version 1.3 was relased in March 2008.
 Major enhancements include:
 <ul>
-<li>Job accounting and completion data stored in a database 
+<li>Job accounting and completion data can be stored in a database 
 (MySQL, PGSQL or simple text file).</li>
-<li>Gang scheduling of jobs (time-slicing of parallel jobs
+<li>SlurmDBD (Slurm Database Deamon) introduced to provide secure
+database support across multiple clusters.</li>
+<li>Gang scheduler plugin added (time-slicing of parallel jobs
 without an external scheduler).</li>
-<li>Support for BlueGene/P systems.</li>
-<li><i>Srun</i>'s --alloc, --attach, and --batch options removed (use 
+<li>Cryptography logic moved to a separate plugin with the 
+option of using OpenSSL (default) or Munge (GPL).</li>
+<li>Improved scheduling of multple job steps within a job's allocation.</li>
+<li>Support for job specification of node features with node counts.</li> 
+<li><i>srun</i>'s --alloc, --attach, and --batch options removed (use 
 <i>salloc</i>, <i>sattach</i> or <i>sbatch</i> commands instead).</li>
+<li><i>srun --pty</i> option added to support remote pseudo terminial for 
+spawned tasks.</li>
+<li>Support added for a much richer job dependency specification
+including testing of exit codes and multiple dependencies.</li>
 </ul>
 
 <h2><a name="14">Major Updates in SLURM Version 1.4 and beyond</a></h2>
@@ -84,6 +97,6 @@ to coordinate activies. Future development plans includes:
 and refresh.</li>
 </ul>
 
-<p style="text-align:center;">Last modified 15 August 2007</p>
+<p style="text-align:center;">Last modified 11 March 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/overview.shtml b/doc/html/overview.shtml
index 126fb45b10848b99b761f01a91ebfdb12422cd2d..5184d84641ec8941889569080cb4479e79b8f2b6 100644
--- a/doc/html/overview.shtml
+++ b/doc/html/overview.shtml
@@ -9,14 +9,13 @@ SLURM has three key functions. First, it allocates exclusive and/or non-exclusiv
 access to resources (compute nodes) to users for some duration of time so they
 can perform work. Second, it provides a framework for starting, executing, and
 monitoring work (normally a parallel job) on the set of allocated nodes. Finally, 
-it arbitrates conflicting requests for resources by managing a queue of pending
-work.</p>
+it arbitrates contention for resources by managing a queue of pending work.</p>
 
 <p>SLURM has been developed through the collaborative efforts of 
-<a href="http://www.llnl.gov/">Lawrence Livermore National Laboratory (LLNL)</a>,
+<a href="https://www.llnl.gov/">Lawrence Livermore National Laboratory (LLNL)</a>,
 <a href="http://www.hp.com/">Hewlett-Packard</a>, 
-<a href="http://www.bull.com/">Bull</a>, and
-<a href="http://www.lnxi.com/">Linux NetworX</a>.
+<a href="http://www.bull.com/">Bull</a>,
+<a href="http://www.lnxi.com/">Linux NetworX</a> and many other contributors.
 HP distributes and supports SLURM as a component in their XC System Software.</p>
 
 <h2>Architecture</h2>
@@ -26,16 +25,20 @@ event of failure. Each compute server (node) has a <b>slurmd</b> daemon, which
 can be compared to a remote shell: it waits for work, executes that work, returns 
 status, and waits for more work. 
 The <b>slurmd</b> daemons provide fault-tolerant hierarchical communciations.
+There is an optional <b>slurmdbd</b> (Slurm DataBase Daemon) which can be used
+to record accounting information for multiple Slurm-managed clusters in a 
+single database.
 User tools include <b>srun</b> to initiate jobs, 
 <b>scancel</b> to terminate queued or running jobs, <b>sinfo</b> to report system 
-status, and <b>squeue</b> to report the status of jobs. 
+status, <b>squeue</b> to report the status of jobs, <b>sacct</b> to get information 
+about jobs and job steps that are running or have completed. 
 The <b>smap</b> and <b>sview</b> commands graphically reports system and 
 job status including network topology. There is also an administrative 
 tool <b>scontrol</b> available to monitor and/or modify configuration and state 
 information. APIs are available for all functions.</p>
 
 <div class="figure">
-  <img src="arch.gif" width="600"><br />
+  <img src="arch.gif" width="550"><br>
   Figure 1. SLURM components
 </div>
 
@@ -47,15 +50,21 @@ building block approach. These plugins presently include:
 <a href="http://www.theether.org/authd/">authd</a>, 
 <a href="http://home.gna.org/munge/">munge</a>, or none (default).</li>
 
-<li><a href="checkpoint_plugins.html">Checkpoint</a>: AIX or none.</li>
+<li><a href="checkpoint_plugins.html">Checkpoint</a>: AIX, OpenMPI, XLCH, or none.</li>
+<li><a href="crypto_plugins.html">Cryptography</a>: Munge or OpenSSL</li>
+<li><a href="jobacct_gatherplugins.html">Job Accounting Gather</a>: AIX, Linux, or none(default)</li>
 
-<li><a href="jobacctplugins.html">Job accounting</a>: AIX, Linux or none</li>
+<li><a href="jobacct_storageplugins.html">Job Accounting Storage</a>: 
+text file (default if jobacct_gather != none), 
+<a href="http://www.clusterresources.com/pages/products/gold-allocation-manager.php">Gold</a>
+MySQL, PGSQL, SlurmDBD (Slurm Database Daemon) or none</li>
 
-<li><a href="jobcompplugins.html">Job completion logging</a>: text file, 
-arbitrary script, or none (default).</li>
+<li><a href="jobcompplugins.html">Job completion logging</a>: 
+text file, arbitrary script, MySQL, PGSQL, SlurmDBD, or none (default).</li>
 
-<li><a href="mpiplugins.html">MPI</a>: LAM, MPICH-GM, MVAPICH, 
-and none (default, for most other versions of MPI.</li>
+<li><a href="mpiplugins.html">MPI</a>: LAM, MPICH1-P4, MPICH1-shmem,
+MPICH-GM, MPICH-MX, MVAPICH, OpenMPI and none (default, for most 
+other versions of MPI including MPICH2 and MVAPICH2).</li>
 
 <li><a href="selectplugins.html">Node selection</a>: 
 Blue Gene (a 3-D torus interconnect), 
@@ -68,10 +77,11 @@ RMS (Quadrics Linux kernel patch),
 and <a href="http://oss.sgi.com/projects/pagg/">SGI's Process Aggregates (PAGG)</a>.</li>
 
 <li><a href="schedplugins.html">Scheduler</a>: 
+FIFO (First In First Out, default), backfill, gang (time-slicing for parallel jobs),
 <a href="http://www.clusterresources.com/pages/products/maui-cluster-scheduler.php">
-The Maui Scheduler</a>, 
+The Maui Scheduler</a>, and  
 <a href="http://www.clusterresources.com/pages/products/moab-cluster-suite.php">
-Moab Cluster Suite</a>, backfill, or FIFO (default).</li>
+Moab Cluster Suite</a>.
 
 <li><a href="switchplugins.html">Switch or interconnect</a>: 
 <a href="http://www.quadrics.com/">Quadrics</a> 
@@ -94,10 +104,13 @@ Priority-ordered jobs are allocated nodes within a partition until the resources
 a job is assigned a set of nodes, the user is able to initiate parallel work in
 the form of job steps in any configuration within the allocation. For instance,
 a single job step may be started that utilizes all nodes allocated to the job,
-or several job steps may independently use a portion of the allocation.</p>
+or several job steps may independently use a portion of the allocation.
+SLURM provides resource management for the processors allocated to a job, 
+so that multiple job steps can be simultaneously submitted and queued until 
+there are available resources within the job's allocation.</p>
 
 <div class="figure">
-  <img src="entities.gif" width="291" height="218"><br />
+  <img src="entities.gif" width="550"><br>
   Figure 2. SLURM entities
 </div>
 
@@ -107,10 +120,14 @@ or several job steps may independently use a portion of the allocation.</p>
 <p>Node state monitored include: count of processors, size of real memory, size 
 of temporary disk space, and state (UP, DOWN, etc.). Additional node information 
 includes weight (preference in being allocated work) and features (arbitrary information 
-such as processor speed or type). Nodes are grouped into disjoint partitions. 
+such as processor speed or type). 
+Nodes are grouped into partitions, which may contain overlapping nodes so they are
+best thought of as job queues.
 Partition information includes: name, list of associated nodes, state (UP or DOWN), 
-maximum job time limit, maximum node count per job, group access list, and shared 
-node access (YES, NO or FORCE). Bit maps are used to represent nodes and scheduling 
+maximum job time limit, maximum node count per job, group access list, 
+priority (important if nodes are in multiple partitions) and shared node access policy
+with optional over-subscription level for gang scheduling (e.g. YES, NO or FORCE:2).  
+Bit maps are used to represent nodes and scheduling 
 decisions can be made by performing a small number of comparisons and a series 
 of fast bit map manipulations. A sample (partial) SLURM configuration file follows.</p>
 <pre>
@@ -135,20 +152,21 @@ TmpFS=/tmp
 #
 # Node Configurations
 #
-NodeName=DEFAULT TmpDisk=16384 State=IDLE
+NodeName=DEFAULT Procs=4 TmpDisk=16384 State=IDLE
 NodeName=lx[0001-0002] State=DRAINED
-NodeName=lx[0003-8000] Procs=16 RealMemory=2048 Weight=16
-NodeName=lx[8001-9999] Procs=32 RealMemory=4096 Weight=40 Feature=1200MHz
+NodeName=lx[0003-8000] RealMemory=2048 Weight=2
+NodeName=lx[8001-9999] RealMemory=4096 Weight=6 Feature=video
 #
 # Partition Configurations
 #
 PartitionName=DEFAULT MaxTime=30 MaxNodes=2
 PartitionName=login Nodes=lx[0001-0002] State=DOWN
-PartitionName=debug Nodes=lx[0003-0030] State=UP    Default=YES
+PartitionName=debug Nodes=lx[0003-0030] State=UP Default=YES
 PartitionName=class Nodes=lx[0031-0040] AllowGroups=students
-PartitionName=batch Nodes=lx[0041-9999] MaxTime=UNLIMITED MaxNodes=4096
+PartitionName=DEFAULT MaxTime=UNLIMITED MaxNodes=4096
+PartitionName=batch Nodes=lx[0041-9999]
 </pre>
 
-<p style="text-align:center;">Last modified 8 November 2006</p>
+<p style="text-align:center;">Last modified 11 March 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/power_save.shtml b/doc/html/power_save.shtml
index 9cc5b367ca5bbf62743bf19ad3ee7357a3def9a4..0f4a8de4867bd5b79588ee298179ca4b7c5147c0 100644
--- a/doc/html/power_save.shtml
+++ b/doc/html/power_save.shtml
@@ -22,51 +22,53 @@ SLURM's support to increase power demands in a gradual fashion.</p>
 
 
 <h2>Configuration</h2>
-<p>Rather than changing SLURM's configuration file (and data 
-structures) after SLURM version 1.2 was released, we decided to 
-temporarily put the configuration parameters directly in the 
-<i>src/slurmctld/power_save.c</i> file.
-These paramters will all be moved into the <i>slurm.conf</i>
-configuration file when SLURM version 1.3 is released.
-Until that time, pleased directly edit the code to use this feature.
+<p>A great deal of flexibility is offered in terms of when and 
+how idle nodes are put into or removed from power save mode.
 The following configuration paramters are available:
 <ul>
-<li><b>IdleTime</b>:
+
+<li><b>SuspendTime</b>:
 Nodes becomes elligible for power saving mode after being idle 
 for this number of seconds. 
 A negative number disables power saving mode.
 The default value is -1 (disabled).</li>
+
 <li><b>SuspendRate</b>:
 Maximum number of nodes to be placed into power saving mode 
 per minute. 
 A value of zero results in no limits being imposed.
 The default value is 60.
 Use this to prevent rapid drops in power requirements.</li>
+
 <li><b>ResumeRate</b>:
 Maximum number of nodes to be placed into power saving mode 
 per minute. 
 A value of zero results in no limits being imposed.
 The default value is 60.
 Use this to prevent rapid increasses in power requirements.</li>
+
 <li><b>SuspendProgram</b>:
 Program to be executed to place nodes into power saving mode.
 The program executes as <i>SlurmUser</i> (as configured in
-<i>slurm.conf</i>. 
+<i>slurm.conf</i>). 
 The argument to the program will be the names of nodes to 
 be placed into power savings mode (using SLURM's hostlist 
 expression format).</li>
+
 <li><b>ResumeProgram</b>:
 Program to be executed to remove nodes from power saving mode.
 The program executes as <i>SlurmUser</i> (as configured in
-<i>slurm.conf</i>. 
+<i>slurm.conf</i>). 
 The argument to the program will be the names of nodes to 
 be removed from power savings mode (using SLURM's hostlist 
 expression format).</li>
-<li><b>ExcludeSuspendNodes</b>:
+
+<li><b>SuspendExcNodes</b>:
 List of nodes to never place in power saving mode. 
 Use SLURM's hostlist expression format.
 By default, no nodes are excluded.</li>
-<li><b>ExcludeSuspendPartitions</b>:
+
+<li><b>SuspendExcParts</b>:
 List of partitions with nodes to never place in power saving mode. 
 Multiple partitions may be specified using a comma separator.
 By default, no nodes are excluded.</li>
@@ -115,6 +117,6 @@ nodes are in power save mode using messages of this sort:
 You can also configure SLURM without SuspendProgram or ResumeProgram values
 to assess the potential impact of power saving mode before enabling it.</p>
 
-<p style="text-align:center;">Last modified 9 May 2007</p>
+<p style="text-align:center;">Last modified 14 May 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/preempt.shtml b/doc/html/preempt.shtml
new file mode 100644
index 0000000000000000000000000000000000000000..d58acf0032483a69c2fc9033c28b17dcb7546a58
--- /dev/null
+++ b/doc/html/preempt.shtml
@@ -0,0 +1,247 @@
+<!--#include virtual="header.txt"-->
+
+<H1>Preemption</H1>
+
+<P>
+SLURM version 1.2 and earlier supported dedication of resources
+to jobs based on a simple "first come, first served" policy with backfill.
+Beginning in SLURM version 1.3, priority-based <I>preemption</I> is supported. 
+Preemption is the act of suspending one or more "low-priority" jobs to let a
+"high-priority" job run uninterrupted until it completes. Preemption provides
+the ability to prioritize the workload on a cluster.
+</P>
+<P>
+The SLURM version 1.3.1 <I>sched/gang</I> plugin supports preemption. 
+When configured, 
+the plugin monitors each of the partitions in SLURM. If a new job in a
+high-priority partition has been allocated to resources that have already been
+allocated to one or more existing jobs from lower priority partitions, the
+plugin respects the partition priority and suspends the low-priority job(s). The
+low-priority job(s) remain suspended until the job from the high-priority
+partition completes. Once the high-priority job completes then the low-priority
+job(s) are resumed.
+</P>
+
+<H2>Configuration</H2>
+<P>
+There are several important configuration parameters relating to preemption:
+</P>
+<UL>
+<LI>
+<B>SelectType</B>: The SLURM <I>sched/gang</I> plugin supports nodes 
+allocated by the <I>select/linear</I> plugin and socket/core/CPU resources 
+allocated by the <I>select/cons_res</I> plugin. 
+See <A HREF="#future_work">Future Work</A> below for more
+information on "preemption with consumable resources".
+</LI>
+<LI>
+<B>SelectTypeParameter</B>: Since resources will be getting overallocated 
+with jobs (the preempted job will remain in memory), the resource selection
+plugin should be configured to track the amount of memory used by each job to
+ensure that memory page swapping does not occur. When <I>select/linear</I> is
+chosen, we recommend setting <I>SelectTypeParameter=CR_Memory</I>. When
+<I>select/cons_res</I> is chosen, we recommend including Memory as a resource
+(ex. <I>SelectTypeParameter=CR_Core_Memory</I>).
+</LI>
+<LI>
+<B>DefMemPerTask</B>: Since job requests may not explicitly specify 
+a memory requirement, we also recommend configuring <I>DefMemPerTask</I> 
+(default memory per task). It may also be desirable to configure 
+<I>MaxMemPerTask</I> (maximum memory per task) in <I>slurm.conf</I>.
+</LI>
+<LI>
+<B>JobAcctGatherType and JobAcctGatherFrequency</B>:
+If you wish to enforce memory limits, accounting must be enabled
+using the <I>JobAcctGatherType</I> and <I>JobAcctGatherFrequency</I>
+parameters. If accounting is enabled and a job exceeds its configured
+memory limits, it will be canceled in order to prevent it from 
+adversely effecting other jobs sharing the same resources.
+</LI>
+<LI>
+<B>SchedulerType</B>: Configure the <I>sched/gang</I> plugin by setting
+<I>SchedulerType=sched/gang</I> in <I>slurm.conf</I>.
+</LI>
+<LI>
+<B>Priority</B>: Configure the partition's <I>Priority</I> setting relative to
+other partitions to control the preemptive behavior. If two jobs from two
+different partitions are allocated to the same resources, the job in the
+partition with the greater <I>Priority</I> value will preempt the job in the
+partition with the lesser <I>Priority</I> value. If the <I>Priority</I> values
+of the two partitions are equal then no preemption will occur, and the two jobs
+will run simultaneously on the same resources. The default <I>Priority</I> value
+is 1.
+</LI>
+<LI>
+<B>Shared</B>: Configure the partitions <I>Shared</I> setting to 
+<I>FORCE</I> for all partitions that will preempt or that will be preempted. The
+<I>FORCE</I> setting is required to enable the select plugins to overallocate
+resources. Jobs submitted to a partition that does not share it's resources will
+not preempt other jobs, nor will those jobs be preempted. Instead those jobs
+will wait until the resources are free for non-shared use by each job.
+<BR>
+The <I>FORCE</I> option now supports an additional parameter that controls 
+how many jobs can share a resource within the partition (FORCE[:max_share]). By
+default the max_share value is 4. To disable timeslicing within a partition but
+enable preemption with other partitions, set <I>Shared=FORCE:1</I>.
+</LI>
+<LI>
+<B>SchedulerTimeSlice</B>: The default timeslice interval is 30 seconds. 
+To change this duration, set <I>SchedulerTimeSlice</I> to the desired interval 
+(in seconds) in <I>slurm.conf</I>. For example, to set the timeslice interval 
+to one minute, set <I>SchedulerTimeSlice=60</I>. Short values can increase 
+the overhead of gang scheduling. This parameter is only relevant if timeslicing
+within a partition will be configured. Preemption and timeslicing can occur at
+the same time.
+</LI>
+</UL>
+<P>
+To enable preemption after making the configuration changes described above,
+restart SLURM if it is already running. Any change to the plugin settings in
+SLURM requires a full restart of the daemons. If you just change the partition
+<I>Priority</I> or <I>Shared</I> setting, this can be updated with

+<I>scontrol reconfig</I>.
+</P>
+
+<H2>Preemption Design and Operation</H2>

+
+<P>
+When enabled, the <I>sched/gang</I> plugin keeps track of the resources
+allocated to all jobs. For each partition an "active bitmap" is maintained that
+tracks all concurrently running jobs in the SLURM cluster. Each partition also
+maintains a job list for that partition, and a list of "shadow" jobs. These
+"shadow" jobs are running jobs from higher priority partitions that "cast
+shadows" on the active bitmaps of the lower priority partitions. 
+</P>
+<P>
+Each time a new job is allocated to resources in a partition and begins running,
+the <I>sched/gang</I> plugin adds a "shadow" of this job to all lower priority
+partitions. The active bitmap of these lower priority partitions are then
+rebuilt, with the shadow jobs added first. Any existing jobs that were replaced
+by one or more "shadow" jobs are suspended (preempted). Conversely, when a 
+high-priority running job completes, it's "shadow" goes away and the active 
+bitmaps of the lower priority partitions are rebuilt to see if any suspended 
+jobs can be resumed.
+</P>
+<P>
+The gang scheduler plugin is primarily designed to be <I>reactive</I> to the
+resource allocation decisions made by the Selector plugins. This is why
+<I>Shared=FORCE</I> is required in each partition. The <I>Shared=FORCE</I>
+setting enables the <I>select/linear</I> and <I>select/cons_res</I> plugins to
+overallocate the resources between partitions. This keeps all of the node
+placement logic in the <I>select</I> plugins, and leaves the gang scheduler in
+charge of controlling which jobs should run on the overallocated resources. 
+</P>
+<P>
+The <I>sched/gang</I> plugin suspends jobs via the same internal functions that
+support <I>scontrol suspend</I> and <I>scontrol resume</I>. A good way to
+observe the act of preemption is by running <I>watch squeue</I> in a terminal
+window.
+</P>
+
+<H2>A Simple Example</H2>
+
+<P>
+The following example is configured with <I>select/linear</I>,
+<I>sched/gang</I>, and <I>Shared=FORCE:1</I>. This example takes place on a
+cluster of 5 nodes:
+</P>
+<PRE>
+[user@n16 ~]$ <B>sinfo</B>
+PARTITION AVAIL  TIMELIMIT NODES  STATE NODELIST
+active*      up   infinite     5   idle n[12-16]
+hipri        up   infinite     5   idle n[12-16]
+</PRE>
+<P>
+Here are the Partition settings:
+</P>
+<PRE>
+[user@n16 ~]$ <B>grep PartitionName /shared/slurm/slurm.conf</B>
+PartitionName=active Priority=1 Default=YES Shared=FORCE:1 Nodes=n[12-16]
+PartitionName=hipri  Priority=2             Shared=FORCE:1 Nodes=n[12-16]
+[user@n16 ~]$ 
+</PRE>
+<P>
+The <I>runit.pl</I> script launches a simple load-generating app that runs
+for the given number of seconds. Submit 5 single-node <I>runit.pl</I> jobs to
+run on all nodes:
+</P>
+<PRE>
+[user@n16 ~]$ <B>sbatch -N1 ./runit.pl 300</B>
+sbatch: Submitted batch job 485
+[user@n16 ~]$ <B>sbatch -N1 ./runit.pl 300</B>
+sbatch: Submitted batch job 486
+[user@n16 ~]$ <B>sbatch -N1 ./runit.pl 300</B>
+sbatch: Submitted batch job 487
+[user@n16 ~]$ <B>sbatch -N1 ./runit.pl 300</B>
+sbatch: Submitted batch job 488
+[user@n16 ~]$ <B>sbatch -N1 ./runit.pl 300</B>
+sbatch: Submitted batch job 489
+[user@n16 ~]$ <B>squeue</B>
+JOBID PARTITION     NAME   USER  ST   TIME  NODES NODELIST
+  485    active runit.pl   user   R   0:06      1 n12
+  486    active runit.pl   user   R   0:06      1 n13
+  487    active runit.pl   user   R   0:05      1 n14
+  488    active runit.pl   user   R   0:05      1 n15
+  489    active runit.pl   user   R   0:04      1 n16
+[user@n16 ~]$
+</PRE>
+<P>
+Now submit a short-running 3-node job to the <I>hipri</I> partition:
+</P>
+<PRE>
+[user@n16 ~]$ <B>sbatch -N3 -p hipri ./runit.pl 30</B>
+sbatch: Submitted batch job 490
+[user@n16 ~]$ <B>squeue</B>
+JOBID PARTITION     NAME   USER  ST   TIME  NODES NODELIST
+  488    active runit.pl   user   R   0:29      1 n15
+  489    active runit.pl   user   R   0:28      1 n16
+  485    active runit.pl   user   S   0:27      1 n12
+  486    active runit.pl   user   S   0:27      1 n13
+  487    active runit.pl   user   S   0:26      1 n14
+  490     hipri runit.pl   user   R   0:03      3 n[12-14]
+[user@n16 ~]$
+</PRE>
+<P>
+Job 490 in the <I>hipri</I> partition preempted jobs 485, 486, and 487 from
+the <I>active</I> partition. Jobs 488 and 489 in the <I>active</I> partition
+remained running.
+</P>
+<P>
+This state persisted until job 490 completed, at which point the preempted jobs
+were resumed:
+</P>
+<PRE>
+[user@n16 ~]$ <B>squeue</B>
+JOBID PARTITION     NAME   USER  ST   TIME  NODES NODELIST
+  485    active runit.pl   user   R   0:30      1 n12
+  486    active runit.pl   user   R   0:30      1 n13
+  487    active runit.pl   user   R   0:29      1 n14
+  488    active runit.pl   user   R   0:59      1 n15
+  489    active runit.pl   user   R   0:58      1 n16
+[user@n16 ~]$
+</PRE>
+
+
+<H2><A NAME="future_work">Future Work</A></H2>
+
+<P>
+<B>Preemption with consumable resources</B>: This implementation of preemption
+relies on intelligent job placement by the <I>select</I> plugins. As of SLURM
+1.3.1 the consumable resource <I>select/cons_res</I> plugin still needs
+additional enhancements to the job placement algorithm before it's preemption
+support can be considered "competent". The mechanics of preemption work, but the
+placement of preemptive jobs relative to any low-priority jobs may not be
+optimal. The work to improve the placement of preemptive jobs relative to
+existing jobs is currently in-progress. 
+</P>
+<P>
+<B>Requeue a preempted job</B>: In some situations is may be desirable to
+requeue a low-priority job rather than suspend it. Suspending a job leaves the
+job in memory. Requeuing a job involves terminating the job and resubmitting it
+again. This will be investigated at some point in the future. Requeuing a
+preempted job may make the most sense with <I>Shared=NO</I> partitions.
+</P>
+
+<p style="text-align:center;">Last modified 11 April 2008</p>
+
+<!--#include virtual="footer.txt"-->
diff --git a/doc/html/programmer_guide.shtml b/doc/html/programmer_guide.shtml
index b1a765a2df1027abdd61db183d373c3e4284f2c1..2ee1d221f641a6519141cb8e059a3a11424b612d 100644
--- a/doc/html/programmer_guide.shtml
+++ b/doc/html/programmer_guide.shtml
@@ -17,9 +17,8 @@ Resource Management</a> [PDF].
 engine. While initially written for Linux, other UNIX-like operating systems should 
 be easy porting targets. Code should adhere to the <a href="coding_style.pdf"> 
 Linux kernel coding style</a>. <i>(Some components of SLURM have been taken from 
-various sources. Some of these components are written in C++ or do not conform 
-to the Linux kernel coding style. However, new code written for SLURM should 
-follow these standards.)</i>
+various sources. Some of these components do not conform to the Linux kernel 
+coding style. However, new code written for SLURM should follow these standards.)</i>
  
 <p>Many of these modules have been built and tested on a variety of Unix computers 
 including Red Hat Linux, IBM's AIX, Sun's Solaris, and Compaq's Tru-64. The only 
@@ -60,14 +59,16 @@ The build process is described in the README file.
 
 <p>Copyright and disclaimer information are in the files COPYING and DISCLAIMER. 
 All of the top-level subdirectories are described below.</p>
+
 <p style="margin-left:.2in"><b>auxdir</b>&#151;Used for building SLURM.<br>
+<b>contribs</b>&#151;Various contributed tools.<br>
 <b>doc</b>&#151;Documentation including man pages. <br>
 <b>etc</b>&#151;Sample configuration files.<br>
 <b>slurm</b>&#151;Header files for API use. These files must be installed. Placing 
 these header files in this location makes for better code portability.<br>
 <b>src</b>&#151;Contains all source code and header files not in the "slurm" subdirectory 
 described above.<br>
-<b>testsuite</b>&#151;DejaGnu is used as a testing framework and all of its files 
+<b>testsuite</b>&#151;DejaGnu and Expect are used for testing all of its files 
 are here.</p>
 
 <p class="footer"><a href="#top">top</a></p>
@@ -95,16 +96,16 @@ SLURM.<br>
 subdirectory is used for each plugin class:<br> 
 <ul>
 <li><b>auth</b> for user authentication,<br> 
-<li><b>checkpoint</b> for system-initiated checkpoint 
-and restart of user jobs,<br>
-<li><b>jobacct</b> for job accounting,<br>
+<li><b>checkpoint</b> for system-initiated checkpoint and restart of user jobs,<br>
+<li><b>crypto</b> for cryptographic functions,<br>
+<li><b>jobacct_gather</b> for job accounting,<br>
+<li><b>jobacct_storage</b> for specifing the type of storage for job accounting,<br>
 <li><b>jobcomp</b> for job completion logging,<br>
 <li><b>mpi</b> for MPI support,<br>
 <li><b>proctrack</b> for process tracking,<br>
 <li><b>sched</b> for job scheduler,<br> 
 <li><b>select</b> for a job's node selection,<br>
-<li><b>switch</b> for switch (interconnect) specific 
-functions,<br>
+<li><b>switch</b> for switch (interconnect) specific functions,<br>
 <li><b>task</b> for task affinity to processors.<br>
 </ul>
 <p style="margin-left:.2in">
@@ -126,6 +127,7 @@ dimension torus topography.<br>
 <b>squeue</b>&#151;User command to get information on SLURM jobs and job steps.<br>
 <b>srun</b>&#151;User command to submit a job, get an allocation, and/or 
 initiation a parallel job step.<br>
+<b>strigger</b>&#151;User and administrator to manage event triggers.<br>
 <b>sview</b>&#151;User command to view and update node, partition, and job 
 job state information.<br>
 
@@ -227,6 +229,6 @@ host1> slurmd -N foo21
 
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 29 September 2006</p>
+<p style="text-align:center;">Last modified 20 May 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/publications.shtml b/doc/html/publications.shtml
index 8d918489e2226573ae6ae8d6a374f1c5972f2df4..75f6da57281554f68b620a656f308f6d08a5c3c6 100644
--- a/doc/html/publications.shtml
+++ b/doc/html/publications.shtml
@@ -1,6 +1,19 @@
 <!--#include virtual="header.txt"-->
 
-<h1>Publications</h1>
+<h1>Publications and Presentations</h1>
+
+<h2>Presentations</h2>
+
+<ul>
+<li><a href="slurm_v1.3.pdf">SLURM Version 1.3</a> (May 2008)</li>
+<li><a href="slurm_moab.pdf">Managing Clusters with Moab and SLURM</a> (May 2008)</li>
+<li><a href="slurm_v1.2.pdf">Resource Management at LLNL, SLURM Version 1.2</a>
+(April 2007)</li>
+<li><a href="lci.7.tutorial.pdf">Resource Management Using SLURM</a>,
+(Tutorial, The 7th International Conference on Linux Clusters, May 2006)</li>
+</ul>
+
+<h2>Publications</h2>
 <b>Enhancing an Open Source Resource Manager with Multi-Core/Multi-threaded Support</b>,
 S. M. Balle and D. Palermo,
 <i>Job Scheduling Strategies for Parallel Processing</i>,
@@ -19,6 +32,6 @@ volume 2862 of <i>Lecture Notes in Computer Science</i>,
 pages 44-60,
 Springer-Verlag, 2003.</p>
 
-<p style="text-align:center;">Last modified 31 August 2007</p>
+<p style="text-align:center;">Last modified 28 April 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/quickstart.shtml b/doc/html/quickstart.shtml
index 7dae93bd5415a8d17799040870c63603dd510783..b9357f81d1a33cab694179f3848000870e097682 100644
--- a/doc/html/quickstart.shtml
+++ b/doc/html/quickstart.shtml
@@ -11,17 +11,17 @@ SLURM has three key functions. First, it allocates exclusive and/or non-exclusiv
 access to resources (compute nodes) to users for some duration of time so they 
 can perform work. Second, it provides a framework for starting, executing, and 
 monitoring work (normally a parallel job) on the set of allocated nodes. Finally, 
-it arbitrates conflicting requests for resources by managing a queue of pending 
-work.</p>
+it arbitrates contention for resources by managing a queue of pending work.</p>
 
 <h2>Architecture</h2>
 <p>As depicted in Figure 1, SLURM consists of a <b>slurmd</b> daemon running on 
 each compute node and a central <b>slurmctld</b> daemon running on a management node 
 (with optional fail-over twin). 
 The <b>slurmd</b> daemons provide fault-tolerant hierarchical communciations.
-The user commands include: <b>salloc</b>, <b>sattach</b>, <b>sbatch</b>, 
-<b>sbcast</b>, <b>scancel</b>, <b>sinfo</b>, <b>srun</b>, 
-<b>smap</b>, <b>squeue</b>, and <b>scontrol</b>.  
+The user commands include: <b>sacct</b>, <b>salloc</b>, <b>sattach</b>,
+<b>sbatch</b>, <b>sbcast</b>, <b>scancel</b>, <b>scontrol</b>,  
+<b>sinfo</b>, <b>smap</b>, <b>squeue</b>, <b>srun</b>, <b>strigger</b> 
+and <b>sview</b>.  
 All of the commands can run anywhere in the cluster.</p>
 
 <div class="figure">
@@ -29,11 +29,12 @@ All of the commands can run anywhere in the cluster.</p>
   Figure 1. SLURM components
 </div>
 
-<p>The entities managed by these SLURM daemons, shown in Figure 2, include <b>nodes</b>, 
-the compute resource in SLURM, <b>partitions</b>, which group nodes into logical 
-sets, <b>jobs</b>, or allocations of resources assigned to a user for 
-a specified amount of time, and <b>job steps</b>, which are sets of (possibly 
-parallel) tasks within a job. 
+<p>The entities managed by these SLURM daemons, shown in Figure 2, include 
+<b>nodes</b>, the compute resource in SLURM, 
+<b>partitions</b>, which group nodes into logical (possibly overlapping) sets, 
+<b>jobs</b>, or allocations of resources assigned to a user for 
+a specified amount of time, and 
+<b>job steps</b>, which are sets of (possibly parallel) tasks within a job. 
 The partitions can be considered job queues, each of which has an assortment of 
 constraints such as job size limit, job time limit, users permitted to use it, etc.
 Priority-ordered jobs are allocated nodes within a partition until the resources 
@@ -55,6 +56,9 @@ or several job steps may independently use a portion of the allocation.</p>
 option <span class="commandline">--help</span> also provides a brief summary of 
 options. Note that the command options are all case insensitive.</p>
 
+<p><span class="commandline"><b>sacct</b></span> is used to report job or job
+step accounting information about active or completed jobs.</p>
+
 <p><span class="commandline"><b>salloc</b></span> is used to allocate resources 
 for a job in real time. Typically this is used to allocate resources and spawn a shell. 
 The shell is then used to execute srun commands to launch parallel tasks.</p>
@@ -68,25 +72,29 @@ for later execution. The script will typically contain one or more srun commands
 to launch parallel tasks.</p>
 
 <p><span class="commandline"><b>sbcast</b></span> is used to transfer a file
-from local disk to local disk on the nodes allocated to a job. This can be 
-used to effectively use diskless compute nodes or provide improved performance 
+from local disk to local disk on the nodes allocated to a job. This can be
+used to effectively use diskless compute nodes or provide improved performance
 relative to a shared file system.</p>
 
-<p><span class="commandline"><b>scancel</b></span> is used to cancel a pending 
-or running job or job step. It can also be used to send an arbitrary signal to 
+<p><span class="commandline"><b>scancel</b></span> is used to cancel a pending
+or running job or job step. It can also be used to send an arbitrary signal to
 all processes associated with a running job or job step.</p>
 
-<p><span class="commandline"><b>scontrol</b></span> is the administrative tool 
-used to view and/or modify SLURM state. Note that many <span class="commandline">scontrol</span> 
+<p><span class="commandline"><b>scontrol</b></span> is the administrative tool
+used to view and/or modify SLURM state. Note that many <span class="commandline">scontrol</span>
 commands can only be executed as user root.</p>
 
-<p><span class="commandline"><b>sinfo</b></span> reports the state of partitions 
-and nodes managed by SLURM. It has a wide variety of filtering, sorting, and formatting 
+<p><span class="commandline"><b>sinfo</b></span> reports the state of partitions
+and nodes managed by SLURM. It has a wide variety of filtering, sorting, and formatting
 options.</p>
 
-<p><span class="commandline"><b>squeue</b></span> reports the state of jobs or 
-job steps. It has a wide variety of filtering, sorting, and formatting options. 
-By default, it reports the running jobs in priority order and then the pending 
+<p><span class="commandline"><b>smap</b></span> reports state information for
+jobs, partitions, and nodes managed by SLURM, but graphically displays the
+information to reflect network topology.</p>
+
+<p><span class="commandline"><b>squeue</b></span> reports the state of jobs or
+job steps. It has a wide variety of filtering, sorting, and formatting options.
+By default, it reports the running jobs in priority order and then the pending
 jobs in priority order.</p>
 
 <p><span class="commandline"><b>srun</b></span> is used to submit a job for
@@ -103,6 +111,10 @@ independent or shared nodes within the job's node allocation.</p>
 jobs, partitions, and nodes managed by SLURM, but graphically displays the 
 information to reflect network topology.</p>
 
+<p><span class="commandline"><b>strigger</b></span> is used to set, get or 
+view event triggers. Event triggers include things such as nodes going down
+or jobs approaching their time limit.</p>
+
 <p><span class="commandline"><b>sview</b></span> is a graphical user interface to 
 get and update state information for jobs, partitions, and nodes managed by SLURM.</p>
 
@@ -278,7 +290,8 @@ option to launch jobs. For example:
 $MPI_ROOT/bin/mpirun -TCP -srun -N8 ./a.out
 </pre></p>
 
-<p><a href="http://www-unix.mcs.anl.gov/mpi/mpich2/"><b>MPICH2</b></a> jobs 
+<p><a href="http://www.mcs.anl.gov/research/projects/mpich2/"><b>
+MPICH2</b></a> jobs 
 are launched using the <b>srun</b> command. Just link your program with 
 SLURM's implementation of the PMI library so that tasks can communicate
 host and port information at startup. (The system administrator can add
@@ -318,7 +331,7 @@ $ mpicc ...
 $ srun -n16 --mpi=mpichmx a.out
 </pre>
 
-<p><a href="http://nowlab.cse.ohio-state.edu/projects/mpi-iba"><b>MVAPICH</b></a>
+<p><a href="http://mvapich.cse.ohio-state.edu/"><b>MVAPICH</b></a>
 jobs can be launched directly by <b>srun</b> command.
 SLURM's <i>mvapich</i> MPI plugin must be used to establish communications 
 between the laucnhed tasks. This can be accomplished either using the SLURM 
@@ -419,6 +432,6 @@ sbatch: Submitted batch job 1234
 tasks. These tasks are not managed by SLURM since they are launched 
 outside of its control.</p>
  
-<p style="text-align:center;">Last modified 14 August 2007</p>
+<p style="text-align:center;">Last modified 19 September 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/quickstart_admin.shtml b/doc/html/quickstart_admin.shtml
index b37d1806bb04d82e51fb0b2ecef02d707877047e..1549621fd092c1faac6a9fb5ddf22afdba34324d 100644
--- a/doc/html/quickstart_admin.shtml
+++ b/doc/html/quickstart_admin.shtml
@@ -7,6 +7,8 @@ overview.
 
 <h2>Super Quick Start</h2>
 <ol>
+<li>Make sure that you have synchronized clocks plus consistent users and groups
+across the cluster.</li>
 <li>bunzip2 the distributed tar-ball and untar the files:<br>
 <i>tar --bzip -x -f slurm*tar.bz2</i></li>
 <li><i>cd</i> to the directory containing the SLURM source and type
@@ -22,15 +24,18 @@ NOTE: The parent directories for SLURM's log files, process ID files,
 state save directories, etc. are not created by SLURM.
 They must be created and made writable by <i>SlurmUser</i> as needed prior to 
 starting SLURM daemons.</li>
-<li>Install the configuration file in <i>&lt;sysconfdir&gt;/slurm.conf</i>.</li>
+<li>Install the configuration file in <i>&lt;sysconfdir&gt;/slurm.conf</i>.<br>
+NOTE: You will need to install this configuration file on all nodes of the cluster.</li>
 <li>Create OpenSSL keys:<br>
 <i>openssl genrsa -out &lt;sysconfdir&gt;/slurm.key 1024</i><br>
 <i>openssl rsa -in  &lt;sysconfdir&gt/slurm.key -pubout -out  &lt;sysconfdir&gt;/slurm.cert</i><br>
-NOTE: You will build the OpenSSL key files on one node and distribute them
-to all of the nodes in the cluster.</li>
+NOTE: You will build the OpenSSL key files on one node and distribute <i>slurm.cert</i>
+to all of the nodes in the cluster. <i>slurm.key</i> must be readable only by
+<i>SlurmUser<i> and is only needed where the <i>slurmctld</i> (SLURM controller
+daemon) executes, typically just a couple of nodes.</li>
 <li>Start the <i>slurmctld</i> and <i>slurmd</i> daemons.</li>
 </ol>
-<p>NOTE: Items 1 through 4 can be replaced with</p>
+<p>NOTE: Items 2 through 5 can be replaced with</p>
 <ol>
 <li><i>rpmbuild -ta slurm*.tar.bz2</i></li>
 <li><i>rpm --install &lt;the rpm files&gt;</i></li>
@@ -118,7 +123,7 @@ Some macro definitions that may be used in building SLURM include:
 <dd>Specify if debugging logic within SLURM is to be enabled
 <dt>_prefix
 <dd>Pathname of directory to contain the SLURM files
-<dt>_sysconfdir
+<dt>slurm_sysconfdir
 <dd>Pathname of directory containing the slurm.conf configuration file
 <dt>with_munge
 <dd>Specifies munge (authentication library) installation location
@@ -132,12 +137,13 @@ Some macro definitions that may be used in building SLURM include:
 # .rpmmacros
 # For AIX at LLNL
 # Override some RPM macros from /usr/lib/rpm/macros
-# Set other SLURM-specific macros for unconventional file locations
+# Set SLURM-specific macros for unconventional file locations
 #
 %_enable_debug     "--with-debug"
 %_prefix           /admin/llnl
-%_sysconfdir       %{_prefix}/etc/slurm
-%with_munge        "--with-munge=/admin/llnl"
+%slurm_sysconfdir  %{_prefix}/etc/slurm
+%_defaultdocdir    %{_prefix}/doc
+%with_munge        "--with-munge=/opt/freeware"
 %with_proctrack    "--with-proctrack=/admin/llnl/include"
 %with_ssl          "--with-ssl=/opt/freeware"
 </pre></p>
@@ -187,7 +193,7 @@ authentication infrastructure is provided by a dynamically loaded
 plugin chosen at runtame via the <b>AuthType</b> keyword in the SLURM 
 configuration file.  Currently available authentication types include
 <a href="http://www.theether.org/authd/">authd</a>, 
-<a href="ftp://ftp.llnl.gov/pub/linux/munge/">munge</a>, and none.
+<a href="http://home.gna.org/munge/">munge</a>, and none.
 The default authentication infrastructure is "none". This permits any user to execute 
 any job as another user. This may be fine for testing purposes, but certainly not for production 
 use. <b>Configure some AuthType value other than "none" if you want any security.</b>
@@ -205,17 +211,26 @@ For more information, see <a href="quickstart.html#mpi">MPI</a>.
 
 <h3>Scheduler support</h3>
 <p>The scheduler used by SLURM is controlled by the <b>SchedType</b> configuration 
-parameter. This is meant to control the relative importance of pending jobs.
-SLURM's default scheduler is FIFO (First-In First-Out). A backfill scheduler 
-plugin is also available. Backfill scheduling will initiate a lower-priority job 
+parameter. This is meant to control the relative importance of pending jobs and 
+several options are available
+SLURM's default scheduler is <u>FIFO (First-In First-Out)</u>. 
+SLURM offers a backfill scheduling plugin.
+<u>Backfill scheduling</u> will initiate a lower-priority jobs
 if doing so does not delay the expected initiation time of higher priority jobs; 
 essentially using smaller jobs to fill holes in the resource allocation plan. 
+Effective backfill scheduling does require users to specify job time limits.
+SLURM offers a <u>gang scheduler</u>, which time-slices jobs in the same partition/queue
+and can be used to preempt jobs from lower-priority queues in order to execute
+jobs in higher priority queues.
 SLURM also supports a plugin for use of 
 <a href="http://www.clusterresources.com/pages/products/maui-cluster-scheduler.php">
 The Maui Scheduler</a> or 
 <a href="http://www.clusterresources.com/pages/products/moab-cluster-suite.php">
-Moab Cluster Suite</a> which offer sophisticated scheduling algorithms. 
-Motivated users can even develop their own scheduler plugin if so desired. </p>
+Moab Cluster Suite</a> which offer sophisticated scheduling algorithms.
+For more information about these options see
+<a href="gang_scheduling.html">Gang Scheduling</a>,
+<a href="preempt.html">Preemption</a> and
+<a href="cons_res_share.html">Sharing Consumable Resources</a>.</p> 
 
 <h3>Node selection</h3>
 <p>The node selection mechanism used by SLURM is controlled by the 
@@ -235,6 +250,12 @@ aware and interacts with the BlueGene bridge API).</p>
 levels for these messages. Be certain that your system's syslog functionality
 is operational. </p>
 
+<h3>Accounting</h3>
+<p>SLURM supports accounting records being written to a simple text file,
+directly to a database (MySQL or PostgreSQL), or to a daemon securely 
+managing accounting data for multiple clusters. For more information 
+see <a href="accounting.html">Accounting</a>. </p>
+
 <h3>Corefile format</h3>
 <p>SLURM is designed to support generating a variety of core file formats for 
 application codes that fail (see the <i>--core</i> option of the <i>srun</i>
@@ -279,7 +300,8 @@ even those allocated to other users.</p>
 
 <h2>Configuration</h2>
 <p>The SLURM configuration file includes a wide variety of parameters. 
-This configuration file must be available on each node of the cluster. A full
+This configuration file must be available on each node of the cluster and 
+must have consistent contents. A full
 description of the parameters is included in the <i>slurm.conf</i> man page. Rather than 
 duplicate that information, a minimal sample configuration file is shown below. 
 Your slurm.conf file should define at least the configuration parameters defined 
@@ -338,7 +360,8 @@ minimum configuration values will be considered DOWN and not scheduled.
 Note that a more extensive sample configuration file is provided in
 <b>etc/slurm.conf.example</b>. We also have a web-based 
 <a href="configurator.html">configuration tool</a> which can 
-be used to build a simple configuration file.</p>
+be used to build a simple configuration file, which can then be
+manually edited for more complex configurations.</p>
 <pre>
 # 
 # Sample /etc/slurm.conf for mcr.llnl.gov
@@ -379,10 +402,26 @@ NodeName=mcr[0-1151] NodeAddr=emcr[0-1151]
 PartitionName=DEFAULT State=UP    
 PartitionName=pdebug Nodes=mcr[0-191] MaxTime=30 MaxNodes=32 Default=YES
 PartitionName=pbatch Nodes=mcr[192-1151]
-</pre> 
+</pre>
+ 
 <h2>Security</h2>
-<p>You will should create unique job credential keys for your site
-using the program <a href="http://www.openssl.org/">openssl</a>. 
+<p>The use of <a href="http://www.openssl.org/">OpenSSL</a> is 
+recommended to provide a digital signature on job step credentials.
+<a href="http://home.gna.org/munge/">Munge</a> can alternately
+be used with somewhat slower performance.
+This signature is used by <i>slurmctld</i> to construct a job step
+credential, which is sent to <i>srun</i> and then forwarded to
+<i>slurmd</i> to initiate job steps.
+This design offers improved performance by removing much of the 
+job step initiation overhead from the <i> slurmctld </i> daemon.
+The mechanism to be used is controlled through the <b>CryptoType</b>
+configuration parameter (newly added in SLURM version 1.3, 
+earlier versions always use OpenSSL).</p>
+
+<h3>OpenSSL</h3>
+<p>If using OpenSSL digital signatures, unique job credential keys 
+must be created for your site using the program 
+<a href="http://www.openssl.org/">openssl</a>. 
 <b>You must use openssl and not ssh-genkey to construct these keys.</b>
 An example of how to do this is shown below. Specify file names that 
 match the values of <b>JobCredentialPrivateKey</b> and 
@@ -391,32 +430,41 @@ The <b>JobCredentialPrivateKey</b> file must be readable only by <b>SlurmUser</b
 The <b>JobCredentialPublicCertificate</b> file must be readable by all users.
 Note that you should build the key files one one node and then distribute 
 them to all nodes in the cluster.
-This insures that all nodes have a consistent set of encryption keys.
-These keys are used by <i>slurmctld</i> to construct a job credential, 
-which is sent to <i>srun</i> and then forwarded to <i>slurmd</i> to 
-initiate job steps.</p>
+This insures that all nodes have a consistent set of digital signature 
+keys.
+These keys are used by <i>slurmctld</i> to construct a job step 
+credential, which is sent to <i>srun</i> and then forwarded to 
+<i>slurmd</i> to initiate job steps.</p>
 
 <p class="commandline" style="margin-left:.2in">
 <i>openssl genrsa -out &lt;sysconfdir&gt;/slurm.key 1024</i><br>
 <i>openssl rsa -in &lt;sysconfdir&gt;/slurm.key -pubout -out  &lt;sysconfdir&gt;/slurm.cert</i> 
 </p>
-<p>Authentication of communications from SLURM commands to the daemons 
-or between the daemons uses a different security mechanism that is configurable.
-You must specify one &quot;auth&quot; plugin for this purpose. 
-Currently, only three 
-authentication plugins are supported: <b>auth/none</b>, <b>auth/authd</b>, and 
-<b>auth/munge</b>. The auth/none plugin is built and used by default, but either 
-Brent Chun's <a href="http://www.theether.org/authd/">authd</a>, or Chris Dunlap's 
-<a href="http://home.gna.org/munge/">munge</a> should be installed in order to 
-get properly authenticated communications. 
+
+<h3>Munge</h3>
+<p>If using Munge digital signatures, no SLURM keys are required.
+This will be address in the installation and configuration of Munge.</p>
+
+<h3>Authentication</h3>
+<p>Authentication of communications (identifying who generated a particular
+message) between SLURM components can use a different security mechanism 
+that is configurable.  
+You must specify one &quot;auth&quot; plugin for this purpose (<b>AuthType</b>. 
+Currently, only three authentication plugins are supported: 
+<b>auth/none</b>, <b>auth/authd</b>, and <b>auth/munge</b>. 
+The auth/none plugin is built and used by default, but either 
+Brent Chun's <a href="http://www.theether.org/authd/">authd</a>, 
+or LLNL's <a href="http://home.gna.org/munge/">munge</a> 
+should be installed in order to get properly authenticated communications. 
 Unless you are experience with authd, we recommend the use of munge.
-The configure script in the top-level directory of this distribution will determine 
-which authentication plugins may be built. The configuration file specifies which 
-of the available plugins will be utilized. </p>
+The configure script in the top-level directory of this distribution will 
+determine which authentication plugins may be built. 
+The configuration file specifies which of the available plugins will be utilized. </p>
 
+<h3>Pluggable Authentication Module (PAM) support</h3>
 <p>A PAM module (Pluggable Authentication Module) is available for SLURM that 
-can prevent a user from accessing a node which he has not been allocated, if that 
-mode of operation is desired.</p>
+can prevent a user from accessing a node which he has not been allocated, 
+if that mode of operation is desired.</p>
 <p class="footer"><a href="#top">top</a></p>
 
 <h2>Starting the Daemons</h2>
@@ -517,45 +565,12 @@ Configuration data as of 03/19-13:04:12
 AuthType          = auth/munge
 BackupAddr        = eadevj
 BackupController  = adevj
+BOOT_TIME         = 01/10-09:19:21
+CacheGroups       = 0
+CheckpointType    = checkpoint/none
 ControlAddr       = eadevi
 ControlMachine    = adevi
-Epilog            = (null)
-FastSchedule      = 1
-FirstJobId        = 1
-InactiveLimit     = 0
-JobCompLoc        = /var/tmp/jette/slurm.job.log
-JobCompType       = jobcomp/filetxt
-JobCredPrivateKey = /etc/slurm/slurm.key
-JobCredPublicKey  = /etc/slurm/slurm.cert
-KillWait          = 30
-MaxJobCnt         = 2000
-MinJobAge         = 300
-PluginDir         = /usr/lib/slurm
-Prolog            = (null)
-ReturnToService   = 1
-SchedulerAuth     = (null)
-SchedulerPort     = 65534
-SchedulerType     = sched/backfill
-SlurmUser         = slurm(97)
-SlurmctldDebug    = 4
-SlurmctldLogFile  = /tmp/slurmctld.log
-SlurmctldPidFile  = /tmp/slurmctld.pid
-SlurmctldPort     = 7002 
-SlurmctldTimeout  = 300
-SlurmdDebug       = 65534
-SlurmdLogFile     = /tmp/slurmd.log
-SlurmdPidFile     = /tmp/slurmd.pid
-SlurmdPort        = 7003
-SlurmdSpoolDir    = /tmp/slurmd
-SlurmdTimeout     = 300
-TreeWidth         = 50
-JobAcctLogFile    = /tmp/jobacct.log
-JobAcctFrequncy   = 5
-JobAcctType       = jobacct/linux
-SLURM_CONFIG_FILE = /etc/slurm/slurm.conf
-StateSaveLocation = /usr/local/tmp/slurm/adev
-SwitchType        = switch/elan
-TmpFS             = /tmp
+...
 WaitTime          = 0
 
 Slurmctld(primary/backup) at adevi/adevj are UP/UP
@@ -568,9 +583,9 @@ adev0: scontrol shutdown
 <p>An extensive test suite is available within the SLURM distribution 
 in <i>testsuite/expect</i>. 
 There are about 250 tests which will execute on the order of 2000 jobs 
-and 4000 job steps. 
+and 5000 job steps. 
 Depending upon your system configuration and performance, this test 
-suite will take roughly 40 minutes to complete.
+suite will take roughly 80 minutes to complete.
 The file <i>testsuite/expect/globals</i> contains default paths and
 procedures for all of the individual tests.  You will need to edit this
 file to specify where SLURM and other tools are installed.
@@ -595,6 +610,6 @@ in the NEWS file.
 
 </pre> <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 26 March 2007</p>
+<p style="text-align:center;">Last modified 28 April 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/review_release.html b/doc/html/review_release.html
index 84bd793370420bf6430f9d9d4630893b6de18dd1..3755b38355287f5958cd85f2214fa1d78c82adbe 100644
--- a/doc/html/review_release.html
+++ b/doc/html/review_release.html
@@ -8,42 +8,48 @@
 <h1>SLURM Web pages for Review and Release</h1>
 <b>NOTE: Do not follow links.</b>
 <ul>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/api.html">api.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/authplugins.html">authplugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/big_sys.html">big_sys.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/bluegene.html">bluegene.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/checkpoint_plugins.html">checkpoint_plugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/configurator.html">configurator.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/cons_res.html">cons_res.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/dist_plane.html">dist_plane.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/documentation.html">documentation.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/download.html">download.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/faq.html">faq.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/help.html">help.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/ibm.html">ibm.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/jobacctplugins.html">jobacctplugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/jobcompplugins.html">jobcompplugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/mail.html">mail.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/maui.html">maui.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/mc_support.html">mc_support.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/moab.html">moab.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/mpiplugins.html">mpiplugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/news.html">news.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/overview.html">overview.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/platforms.html">platforms.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/plugins.html">plugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/proctrack_plugins.html">proctrack_plugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/programmer_guide.html">programmer_guide.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/publications.html">publications.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/quickstart_admin.html">quickstart_admin.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/quickstart.html">quickstart.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/schedplugins.html">schedplugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/selectplugins.html">selectplugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/slurm.html">slurm.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/switchplugins.html">switchplugins.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/team.html">team.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/testimonials.html">testimonials.html</a></li>
-<li><a href="http://cmg-rr.llnl.gov/linux/slurm/troubleshoot.html">troubleshoot.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/accounting.html">accounting.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/api.html">api.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/authplugins.html">authplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/big_sys.html">big_sys.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/bluegene.html">bluegene.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/checkpoint_plugins.html">checkpoint_plugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/configurator.html">configurator.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/cons_res.html">cons_res.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/cons_res_share.html">cons_res_share.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/dist_plane.html">dist_plane.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/documentation.html">documentation.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/download.html">download.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/faq.html">faq.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/gang_scheduling.html">gang_scheduling.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/help.html">help.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/ibm.html">ibm.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/jobacct_gatherplugins.html">jobacct_gatherplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/jobacct_storageplugins.html">jobacct_storageplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/jobcompplugins.html">jobcompplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/mail.html">mail.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/maui.html">maui.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/mc_support.html">mc_support.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/moab.html">moab.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/mpiplugins.html">mpiplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/news.html">news.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/overview.html">overview.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/platforms.html">platforms.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/plugins.html">plugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/power_save.html">power_save.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/proctrack_plugins.html">proctrack_plugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/programmer_guide.html">programmer_guide.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/publications.html">publications.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/quickstart_admin.html">quickstart_admin.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/quickstart.html">quickstart.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/schedplugins.html">schedplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/selectplugins.html">selectplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/slurm.html">slurm.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/switchplugins.html">switchplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/taskplugins.html">taskplugins.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/team.html">team.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/testimonials.html">testimonials.html</a></li>
+<li><a href="https://computing-pre.llnl.gov/linux/slurm/troubleshoot.html">troubleshoot.html</a></li>
 </ul>
 </body>
 </html>
diff --git a/doc/html/schedplugins.shtml b/doc/html/schedplugins.shtml
index fbbe9aaa7387d560bff207303fcd28cc8a118f91..11272733826b511c7a05ba12f3d60750be358de8 100644
--- a/doc/html/schedplugins.shtml
+++ b/doc/html/schedplugins.shtml
@@ -92,6 +92,22 @@ to indicate the reason for failure.</p>
 the plugin should return SLURM_ERROR and set the errno to an appropriate value 
 to indicate the reason for failure.</p>
 
+<p class="commandline">int slurm_sched_plugin_newalloc (void);</p>
+<p style="margin-left:.2in"><b>Description</b>: Note the successful allocation of resources to a job.</p>
+<p style="margin-left:.2in"><b>Arguments</b>: Pointer to the slurmctld job structure. This can be used to
+get partition, allocated resources, time limit, etc.</p>
+<p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful. On failure, 
+the plugin should return SLURM_ERROR and set the errno to an appropriate value 
+to indicate the reason for failure.</p>
+
+<p class="commandline">int slurm_sched_plugin_freealloc (void);</p>
+<p style="margin-left:.2in"><b>Description</b>: Note the successful release of resources for a job.</p>
+<p style="margin-left:.2in"><b>Arguments</b>: Pointer to the slurmctld job structure. This can be used to
+get partition, allocated resources, time limit, etc.</p>
+<p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful. On failure, 
+the plugin should return SLURM_ERROR and set the errno to an appropriate value 
+to indicate the reason for failure.</p>
+
 <p class="commandline">uint32_t slurm_sched_plugin_initial_priority (
 uint32_t last_prio, struct job_record *job_ptr);</p>
 <p style="margin-left:.2in"><b>Description</b>: Establish the initial priority of a new job.</p>
@@ -120,12 +136,19 @@ happened such as time or size limits.</p>
 <p style="margin-left:.2in"><b>Returns</b>: Nothing.</p>
 <p class="footer"><a href="#top">top</a></p>
 
+<p class="commandline">char *slurm_sched_get_conf (void);</p></a>
+<p style="margin-left:.2in"><b>Description</b>: Return scheduler specific 
+configuration information to be reported for the <i>scontrol show configuration</i>
+command.</p>
+<p style="margin-left:.2in"><b>Arguments</b>: None</p>
+<p style="margin-left:.2in"><b>Returns</b>: A string containing configuration 
+information. The return value is released using the <i>xfree()</i> function.</p>
+
 <a name="get_errno"><p class="commandline">int slurm_sched_get_errno (void);</p></a>
 <p style="margin-left:.2in"><b>Description</b>: Return the number of a scheduler
 specific error.</p>
 <p style="margin-left:.2in"><b>Arguments</b>: None</p>
-<p style="margin-left:.2in"><b>Returns</b>: Error number for the last failure encountered by
-the scheduler plugin.</p>
+<p style="margin-left:.2in"><b>Returns</b>: Error number for the last failure encountered by the scheduler plugin.</p>
 
 <p class="commandline"><a name="strerror">const char *slurm_sched_strerror(int errnum);</a></p>
 <p style="margin-left:.2in"><b>Description</b>: Return a string description of a scheduler
@@ -143,6 +166,6 @@ releases of SLURM may revise this API. A scheduler plugin conveys its ability
 to implement a particular API version using the mechanism outlined for SLURM plugins.</p>
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 16 August 2007</p>
+<p style="text-align:center;">Last modified 8 November 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/selectplugins.shtml b/doc/html/selectplugins.shtml
index 074620eb35a28482da6cb87e25c87f69bb77d36e..7ef6a4088b83364dc577c7d5046ddd86c6b1956f 100644
--- a/doc/html/selectplugins.shtml
+++ b/doc/html/selectplugins.shtml
@@ -25,7 +25,7 @@ This plugin is recommended for systems without shared nodes.</li>
 memory, etc. within nodes. This plugin is recommended for systems with 
 many non-parallel programs sharing nodes. For more information see
 <a href=cons_res.html>Consumable Resources in SLURM</a>.</li>
-<li><b>bluegene</b>&#151;<a href="http://www.research.ibm.com/bluegene">IBM Blue Gene</a>  
+<li><b>bluegene</b>&#151;<a href="http://www.research.ibm.com/bluegene/">IBM Blue Gene</a>  
 node selector. Note that this plugin not only selects the nodes for a job, but performs 
 some initialization and termination functions for the job.</li>
 </ul>
@@ -154,9 +154,10 @@ the plugin should return SLURM_ERROR.</p>
 <p class="commandline">int select_p_pack_node_info (time_t last_query_time, Buf *buffer_ptr);</p>
 <p style="margin-left:.2in"><b>Description</b>: pack node specific information into a buffer.</p>
 <p style="margin-left:.2in"><b>Arguments</b>:
-<span class="commandline"> last_query_time</span>&nbsp;&nbsp;&nbsp;(input) time that the data
-was last saved. If it has not changed since this time, return SLURM_NO_CHANGE_IN_DATA. <br>
-<span class="commandline"> buffer_ptre</span>&nbsp;&nbsp;&nbsp;(input/output) buffer into 
+<span class="commandline">
+last_query_time</span>&nbsp;&nbsp;&nbsp;(input) time that the data was
+last saved.<br>
+<span class="commandline"> buffer_ptr</span>&nbsp;&nbsp;&nbsp;(input/output) buffer into 
 which the node data is appended.</p>
 <p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful, 
 SLURM_NO_CHANGE_IN_DATA if data has not changed since last packed, otherwise SLURM_ERROR</p>
@@ -265,6 +266,21 @@ identify the nodes which were selected for this job to use.</p>
 <p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful. On
 failure, the plugin should return a SLURM error code.</p>
 
+<p class="commandline">int select_p_get_job_cores (uint32_t job_id, int
+alloc_index, int s);</p>
+<p style="margin-left:.2in"><b>Description</b>: Get socket-specific core
+information from a job.</p>
+<p style="margin-left:.2in"><b>Arguments</b>:
+<span class="commandline"> job_id</span>&nbsp; &nbsp;&nbsp;(input) ID of the job
+from which to obtain the data.<br>
+<span class="commandline"> alloc_index</span>&nbsp; &nbsp;&nbsp;(input) index of
+the allocated node to the job from which to obtain the data.<br>
+<span class="commandline"> s</span>&nbsp; &nbsp;&nbsp;(input) socket index from
+which to obtain the data.</p>
+<p style="margin-left:.2in"><b>Returns</b>: the number of cores allocated to the
+given socket on the given node for the given job. On failure, the plugin should
+return zero.</p>
+
 <p class="footer"><a href="#top">top</a></p>
 
 <h3>Get/set plugin information</h3>
@@ -338,7 +354,7 @@ state of the node.</p>
 <p class="commandline">int select_p_alter_node_cnt (enum
 select_node_cnt type, void *data);</p>
 <p style="margin-left:.2in"><b>Description</b>: Used for systems like
-a Bluegene system where slurm sees 1 node where many nodes really
+a Bluegene system where SLURM sees 1 node where many nodes really
 exists, in Bluegene's case 1 node reflects 512 nodes in real live, but
 since usually 512 is the smallest allocatable block slurm only handles
 it as 1 node.  This is a function so the user can issue a 'real'
@@ -351,6 +367,13 @@ telling the plug in what the user is really wanting.<br>
 Is a void * so depending on the type sent in argument 1 this should 
 adjust the variable returning what the user is asking for.</p>
 <p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful, otherwise SLURM_ERROR</p>
+
+<p class="commandline">int select_p_reconfigure (void);</p>
+<p style="margin-left:.2in"><b>Description</b>: Used to notify plugin 
+of change in partition configuration or general configuration change.
+The plugin will test global variables for changes as appropriate.</p>
+<p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful, otherwise SLURM_ERROR</p>
+
 <p class="footer"><a href="#top">top</a></p>
 
 <h2>Versioning</h2>
@@ -363,6 +386,6 @@ to maintain data format compatibility across different versions of the plugin.</
 
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 12 October 2006</p>
+<p style="text-align:center;">Last modified 8 October 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/slurm.shtml b/doc/html/slurm.shtml
index f77d304c3964be245349ea448612df6b5703e493..acb1b46fa99dec8fc486cea386d617511b547483 100644
--- a/doc/html/slurm.shtml
+++ b/doc/html/slurm.shtml
@@ -6,8 +6,7 @@ sizes. It provides three key functions. First it allocates exclusive and/or non-
 access to resources (computer nodes) to users for some duration of time so they 
 can perform work. Second, it provides a framework for starting, executing, and 
 monitoring work (typically a parallel job) on a set of allocated nodes. Finally, 
-it arbitrates conflicting requests for resources by managing a queue of pending 
-work. </p>
+it arbitrates contention for resources by managing a queue of pending work. </p>
 
 <p>SLURM is not a sophisticated batch system, but it does provide an Applications 
 Programming Interface (API) for integration with external schedulers such as 
@@ -33,27 +32,23 @@ add functionality.</li>
 <p>SLURM provides resource management on about 1000 computers worldwide,
 including many of the most powerful computers in the world:
 <ul>
-<li><a href="http://www.llnl.gov/asc/computing_resources/bluegenel/bluegene_home.html">BlueGene/L</a> 
-at LLNL with 65,536 dual-processor compute nodes</li>
-<li><a href="http://www.llnl.gov/asc/computing_resources/purple/purple_index.html">ASC Purple</a>
+<li><a href="https://asc.llnl.gov/computing_resources/bluegenel/">BlueGene/L</a> 
+at LLNL with 106,496 dual-core processors</li>
+<li><a href="http://c-r-labs.com/">EKA</a> at Computational Research Laboratories, 
+India with 14,240 Xeon processoers and Infiniband interconnect</li>
+<li><a href="https://asc.llnl.gov/computing_resources/purple/">ASC Purple</a>
 an IBM SP/AIX cluster at LLNL with 12,208 Power5 processors and a Federation switch</li>
 <li><a href="http://www.bsc.es/plantillaA.php?cat_id=5">MareNostrum</a>
 a Linux cluster at Barcelona Supercomputer Center
 with 10,240 PowerPC processors and a Myrinet switch</li>
-<li>Peloton with 1,152 nodes each having four sockets with dual-core Opteron processors and an InfiniBand switch</li>
-<li>An <a href="http://hpc.uky.edu/">IBM HPC Server</a> at the University of Kentucky.
-This is a heterogeneous cluster with 128 Power5+ processors and
-340 HS21 Blades each with dual-socket and dual-core Intel Woodcrest processors 
-for a total of 1,488 cores connected with Infiniband switch</li>
 </ul>
-<p>There are about 200 downloads of SLURM per month from LLNL's FTP server 
-and <a href="https:sourceforge.net">SourceForge.net</a>.
-As of March 2007, SLURM has been downloaded over 5000 times to over 500 
-distinct sites in 41 countries. 
-SLURM is also actively being developed, distributed and supported by 
-<a href="http://www.hp.com">Hewlett-Packard</a> and
-<a href="http://www.bull.com">Bull</a>.</p>
+<p>SLURM is actively being developed, distributed and supported by 
+<a href="https://www.llnl.gov">Lawrence Livermore National Laboratory</a>,
+<a href="http://www.hp.com">Hewlett-Packard</a>,
+<a href="http://www.bull.com">Bull</a>,
+<a href="http://www.clusterresources.com">Cluster Resources</a> and
+<a href="http://www.sicortex.com">SiCortex</a>.</p>
 
-<p style="text-align:center;">Last modified 4 June 2007</p>
+<p style="text-align:center;">Last modified 29 November 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/slurm_moab.pdf b/doc/html/slurm_moab.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..576a8ae0adb60548e3144b41256a8e32a5f5e80f
Binary files /dev/null and b/doc/html/slurm_moab.pdf differ
diff --git a/doc/html/slurm_v1.3.pdf b/doc/html/slurm_v1.3.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..1068bcffac4c388f4398549242e026640892fdff
Binary files /dev/null and b/doc/html/slurm_v1.3.pdf differ
diff --git a/doc/html/taskplugins.shtml b/doc/html/taskplugins.shtml
index 4599bb8beb1fa602fa3875f1f535ab5e22992197..bcc3d0f1eb424426d32d4e7664ae2c62c4a01370 100644
--- a/doc/html/taskplugins.shtml
+++ b/doc/html/taskplugins.shtml
@@ -84,6 +84,28 @@ ID of the node on which the resources are being acquired
 On failure, the plugin should return SLURM_ERROR and set the errno to an
 appropriate value to indicate the reason for failure.</p>
 
+<p class="commandline">int task_slurmd_suspend_job (uint32_t job_id);</p>
+<p style="margin-left:.2in"><b>Description</b>: Temporarily release resources 
+previously reserved for a job. 
+Executed by the <b>slurmd</b> daemon as user root.</p>
+<p style="margin-left:.2in"><b>Arguments</b>: 
+<span class="commandline">job_id</span>&nbsp;&nbsp;&nbsp;(input)
+ID of the job which is being suspended.</p>
+<p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful.
+On failure, the plugin should return SLURM_ERROR and set the errno to an
+appropriate value to indicate the reason for failure.</p>
+
+<p class="commandline">int task_slurmd_resume_job (uint32_t job_id);</p>
+<p style="margin-left:.2in"><b>Description</b>: Reclaim resources which 
+were previously released using the task_slurmd_suspend_job function.
+Executed by the <b>slurmd</b> daemon as user root.</p>
+<p style="margin-left:.2in"><b>Arguments</b>: 
+<span class="commandline">job_id</span>&nbsp;&nbsp;&nbsp;(input)
+ID of the job which is being resumed.</p>
+<p style="margin-left:.2in"><b>Returns</b>: SLURM_SUCCESS if successful.
+On failure, the plugin should return SLURM_ERROR and set the errno to an
+appropriate value to indicate the reason for failure.</p>
+
 <p class="commandline">int task_slurmd_release_resources (uint32_t job_id);</p>
 <p style="margin-left:.2in"><b>Description</b>: Release resources previously 
 reserved for a job. Executed by the <b>slurmd</b> daemon as user root.</p>
@@ -142,6 +164,6 @@ appropriate value to indicate the reason for failure.</p>
 Future releases of SLURM may revise this API.</p>
 <p class="footer"><a href="#top">top</a></p>
 
-<p style="text-align:center;">Last modified 27 March 2007</p>
+<p style="text-align:center;">Last modified 28 May 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/html/team.shtml b/doc/html/team.shtml
index 74035f1e8b1d78d9cd29b82f651ac55075341745..2e5ffd5470067d4f3e4fde636d1960253f8672d4 100644
--- a/doc/html/team.shtml
+++ b/doc/html/team.shtml
@@ -2,7 +2,7 @@
 
 <h1>SLURM Team</h1>
 <p>SLURM development has been a joint effort of 
-<a href="http://www.llnl.gov/">Lawrence Livermore National Laboratory</a> (LLNL),
+<a href="https://www.llnl.gov/">Lawrence Livermore National Laboratory</a> (LLNL),
 <a href="http://www.hp.com/">HP</a>,
 <a href="http://www.bull.com/">Bull</a>,
 <a href="http://www.lnxi.com/">Linux NetworX</a>.
@@ -12,9 +12,7 @@
 <li>Morris Jette (LLNL, Project leader)</li>
 <li>Danny Auble (LLNL)</li>
 <li>Susanne Balle (HP)</li>
-<li>Mark Grondona (LLNL)</li>
-<li>Chris Morrone (LLNL)</li>
-<li>Daniel Palermo (HP)</li>
+<li>Chris Holmes (HP)</li>
 </ul>
 
 <p> SLURM contributers include: </p>
@@ -31,8 +29,9 @@
 <li>Chris Dunlap (LLNL)</li>
 <li>Joey Ekstrom (LLNL/Bringham Young University)</li>
 <li>Jim Garlick (LLNL)</li>
+<li>Mark Grondona (LLNL)</li>
 <li>Takao Hatazaki (HP, Japan)</li>
-<li>Chris Holmes (HP)</li>
+<li>Matthieu Hautreux (CEA, France)</li>
 <li>Nathan Huff (North Dakota State University)</li>
 <li>David Jackson (Cluster Resources)</li>
 <li>Greg Johnson (LANL)</li>
@@ -42,10 +41,12 @@
 <li>Bernard Li (Genome Sciences Centre, Canada)</li>
 <li>Steven McDougall (SiCortex)</li>
 <li>Donna Mecozzi (LLNL)</li>
+<li>Chris Morrone (LLNL)</li>
 <li>Pere Munt (Barcelona Supercomputer Center, Spain)<li>
 <li>Bryan O'Sullivan (Pathscale)</li>
 <li>Gennaro Oliva (Institute of High Performance Computing and 
 Networking, Italy)</li>
+<li>Daniel Palermo (HP)</li>
 <li>Dan Phung (LLNL/Columbia University)</li>
 <li>Ashley Pittman (Quadrics)</li>
 <li>Andy Riebs (HP)</li>
@@ -59,6 +60,6 @@ Networking, Italy)</li>
 <li>Anne-Marie Wunderlin (Bull)</li>
 </ul>
 
-<p style="text-align:center;">Last modified 14 August 2007</p>
+<p style="text-align:center;">Last modified 22 May 2008</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index 5a7def9faed2d6ee8d35908be3225223cd15b742..e8d06ea88aba3a08ac10a5000695c3792cecd588 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -3,6 +3,7 @@ EXTRA_DIST = man1 man3 man5 man8
 
 man1_MANS =            \
 	man1/sacct.1 \
+	man1/sacctmgr.1 \
 	man1/salloc.1 \
 	man1/sattach.1 \
 	man1/sbatch.1 \
@@ -10,11 +11,12 @@ man1_MANS =            \
 	man1/scancel.1 \
 	man1/scontrol.1 \
 	man1/sinfo.1   \
-	man1/slaunch.1 \
 	man1/slurm.1 \
 	man1/smap.1 \
 	man1/squeue.1 \
+	man1/sreport.1 \
 	man1/srun.1 \
+	man1/sstat.1 \
 	man1/strigger.1 \
 	man1/sview.1
 
@@ -92,12 +94,14 @@ man3_MANS = man3/slurm_hostlist_create.3 \
 
 man5_MANS = man5/bluegene.conf.5 \
 	man5/slurm.conf.5 \
+	man5/slurmdbd.conf.5 \
 	man5/wiki.conf.5
 
 man8_MANS = man8/slurmctld.8 \
 	man8/slurmd.8 \
-	man8/spank.8 \
-	man8/slurmstepd.8
+	man8/slurmdbd.8 \
+	man8/slurmstepd.8 \
+	man8/spank.8
 
 dist-hook:
 	-rm -rf `find $(distdir) -name CVS`
diff --git a/doc/man/Makefile.in b/doc/man/Makefile.in
index abc5e9977fb411166aad95b9cedf1338c2c99d26..109e32167ad8f1da5a58855fd74ed050377cd98a 100644
--- a/doc/man/Makefile.in
+++ b/doc/man/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -95,6 +97,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -108,10 +111,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -131,7 +137,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -142,6 +151,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -157,6 +168,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -172,6 +184,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -231,6 +244,7 @@ top_srcdir = @top_srcdir@
 EXTRA_DIST = man1 man3 man5 man8 
 man1_MANS = \
 	man1/sacct.1 \
+	man1/sacctmgr.1 \
 	man1/salloc.1 \
 	man1/sattach.1 \
 	man1/sbatch.1 \
@@ -238,11 +252,12 @@ man1_MANS = \
 	man1/scancel.1 \
 	man1/scontrol.1 \
 	man1/sinfo.1   \
-	man1/slaunch.1 \
 	man1/slurm.1 \
 	man1/smap.1 \
 	man1/squeue.1 \
+	man1/sreport.1 \
 	man1/srun.1 \
+	man1/sstat.1 \
 	man1/strigger.1 \
 	man1/sview.1
 
@@ -320,12 +335,14 @@ man3_MANS = man3/slurm_hostlist_create.3 \
 
 man5_MANS = man5/bluegene.conf.5 \
 	man5/slurm.conf.5 \
+	man5/slurmdbd.conf.5 \
 	man5/wiki.conf.5
 
 man8_MANS = man8/slurmctld.8 \
 	man8/slurmd.8 \
-	man8/spank.8 \
-	man8/slurmstepd.8
+	man8/slurmdbd.8 \
+	man8/slurmstepd.8 \
+	man8/spank.8
 
 all: all-am
 
diff --git a/doc/man/man1/sacctmgr.1 b/doc/man/man1/sacctmgr.1
new file mode 100644
index 0000000000000000000000000000000000000000..74b2b16b526b16307289ef35f9bc47fca9e9bd5b
--- /dev/null
+++ b/doc/man/man1/sacctmgr.1
@@ -0,0 +1,363 @@
+.TH SACCTMGR "1" "May 2008" "sacctmgr 1.3" "Slurm components"
+
+.SH "NAME"
+sacctmgr \- Used to view and modify Slurm account information.
+
+.SH "SYNOPSIS"
+\fBsacctmgr\fR [\fIOPTIONS\fR...] [\fICOMMAND\fR...]
+
+.SH "DESCRIPTION"
+\fBsacctmgr\fR is used to view or modify Slurm account information.
+The account information is maintained within a database with the interface 
+being provided by \fBslurmdbd\fR (Slurm Database daemon).
+This database can serve as a central storehouse of user and 
+computer information for multiple computers at a single site.
+Slurm account information is recorded based upon four parameters
+that form what is refered to as an \fIassociation\fR. 
+These parameters are \fIuser\fR, \fIcluster\fR, \fIpartition\fR, and 
+\fIaccount\fR. \fIuser\fR is the login name.
+\fIcluster\fR is the name of a Slurm managed cluster as specified by 
+the \fIClusterName\fR parameter in the \fIslurm.conf\fR configuration file. 
+\fIpartition\fR is the name of a Slurm partition on that cluster.
+\fIaccount\fR is the bank account for a job.
+The intended mode of operation is to initiate the \fBssacctmgr\fR command, 
+add, delete, modify, and/or list \fIassociation\fR records then 
+commit the changes and exit.
+
+.SH "OPTIONS"
+.TP
+\fB\-a\fR, \fB\-\-all\fR
+Display information about all entities including hidden or deleted ones. 
+This is equivalent to the \fBall\fR command.
+
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Print a help message describing the usage of \fBssacctmgr\fR.
+This is equivalent to the \fBhelp\fR command.
+
+.TP
+\fB\-\-hide\fR
+Do not display information about hidden or deleted entities. 
+This is equivalent to the \fBhide\fR command.
+
+.TP
+\fB\-o\fR, \fB\-\-oneliner\fR
+Print information one line per record.
+This is equivalent to the \fBoneliner\fR command.
+
+.TP
+\fB\-q\fR, \fB\-\-quiet\fR
+Print no warning or informational messages, only error messages.
+This is equivalent to the \fBquiet\fR command.
+
+.TP
+\fB\-s\fR, \fB\-\-associations\fR
+Show an association for entities displayed.
+This is equivalent to the \fBassociations\fR command.
+
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+Print detailed event logging. 
+This is equivalent to the \fBverbose\fR command.
+
+.TP
+\fB\-V\fR , \fB\-\-version\fR
+Print version information and exit.
+This is equivalent to the \fBversion\fR command.
+
+.TP
+\fBCOMMANDS\fR
+
+.TP
+\fBall\fR
+Display information about all entities including hidden or deleted ones. 
+
+.TP
+\fBadd\fR <\fIENTITY\fR> <\fISPECS\fR>
+Add an entity.
+Identical to the \fBcreate\fR command.
+
+.TP
+\fBassociations\fR
+Show associations for entities displayed.
+
+.TP
+\fBcreate\fR <\fIENTITY\fR> <\fISPECS\fR>
+Add an entity.
+Identical to the \fBadd\fR command.
+
+.TP
+\fBdelete\fR \fIENTITY\fR with \fISPECS\fR
+Delete the specified entities.
+
+.TP
+\fBexit\fP
+Terminate the execution of sacctmgr.
+Identical to the \fBquit\fR command.
+
+.TP
+\fBhelp\fP
+Display a description of sacctmgr options and commands.
+
+.TP
+\fBhide\fP
+Do not display information about hidden or deleted entities. 
+
+.TP
+\fBlist\fR <\fIENTITY\fR> [with <\fISPECS\fR>]
+Display information about the specified entities.
+By default, all entities are displayed.
+Identical to the \fBshow\fR command.
+
+.TP
+\fBmodify\fR <\fIENTITY\fR> \fbwith\fR <\fISPECS\fR> \fbset\fR <\fISPECS\fR>
+Modify an entities.
+
+.TP
+\fBoneliner\fP
+Print information one line per record.
+
+.TP
+\fBquiet\fP
+Print no warning or informational messages, only fatal error messages.
+
+.TP
+\fBquit\fP
+Terminate the execution of sacctmgr.
+Identical to the \fBexit\fR command.
+
+.TP
+\fBshow\fR <\fIENTITY\fR> [with <\fISPECS\fR>]
+Display information about the specified entities.
+By default, all entities are displayed.
+Identical to the \fBlist\fR command.
+
+.TP
+\fBverbose\fP
+Print detailed event logging. 
+This includes time\-stamps on data structures, record counts, etc.
+This is an independent command with no options meant for use in interactive mode.
+
+.TP
+\fBversion\fP
+Display the version number of sacctmgr being executed.
+
+.TP
+\fB!!\fP
+Repeat the last command executed.
+
+.TP
+\fBENTITIES\fR
+
+.TP
+\fIaccount\fP
+A bank account, typically specified at job submit time using the 
+\fI--account=\fR option.
+These may be arranged in a hierarchical fashion, for example
+accounts \fIchemistry\fR and \fIphysics\fR may be children of
+the account \fIscience\fR. 
+The hierarchy may have an arbitrary depth.
+
+.TP
+\fIassociation\fP
+The entity used to group information consisting of four parameters:
+\fIaccount\fR, \fIcluster\fR, \fIpartition\fR, and \fIuser\fR.
+
+.TP
+\fIcluster\fP
+The \fIClusterName\fR parameter in the \fIslurm.conf\fR configuration
+file, used to differentiate accounts from on different machines. 
+
+.TP
+\fIuser\fR
+The login name.
+
+.TP
+\fBSPECIFICATIONS FOR ACCOUNTS\fR
+.TP
+\fICluster\fP=<cluster>
+Specific cluster to add account to.  Default is all in system.
+\fIDescription\fP=<description>
+An arbitrary string describing an account.
+.TP
+\fIFairshare\fP=<fairshare>
+Number used in conjunction with other accounts to determine job priority.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxCPUSecs\fP=<max cpu seconds> 
+Maximum number of cpu seconds each job is able to use in this account.
+This is overridden if set directly on a user. 
+Default is the cluster's limit.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxJobs\fP=<max jobs>
+Maximum number of jobs each user is allowed to run at one time in this account.
+This is overridden if set directly on a user. 
+Default is the cluster's limit.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxNodes\fP=<max nodes>
+Maximum number of nodes each job is able to use in this account.
+This is overridden if set directly on a user. 
+Default is the cluster's limit.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxWall\fP=<max wall>
+Maximum wall clock time each job is able to use in this account.
+This is overridden if set directly on a user. 
+Default is the cluster's limit.
+<max wall> format is <min> or <min>:<sec> or <hr>:<min>:<sec> or 
+<days>\-<hr>:<min>:<sec> or <days>\-<hr>.
+The value is recorded in minutes with rounding as needed.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIName\fP=<name>
+The name of a bank account.
+.TP
+\fIOrganization\fP=<org>
+Organization to which the account belongs.
+.TP
+\fIParent\fP=<parent>
+Parent account of this account. Default is no parent, a top level account.
+.TP
+\fIQosLevel\fP=<qos>
+Quality of Service jobs are to run at for this account.  Now consisting
+of Normal, Standby, Expedite, and Exempt.
+This is overridden if set directly on a user. 
+
+.TP
+\fBSPECIFICATIONS FOR CLUSTERS\fR
+.TP
+\fIFairshare\fP=<fairshare>
+Number used in conjunction with other accounts to determine job priority.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIName\fP=<name>
+The name of a cluster.
+This should be equal to the \fIClusterName\fR parameter in the \fIslurm.conf\fR 
+configuration file for some Slurm-managed cluster. 
+.TP
+\fIMaxCPUSecs\fP=<max cpu seconds> 
+Maximum number of cpu seconds each job is able to use in this account.
+This is overridden if set directly on an account or user. 
+Default is no limit.
+To clear a previously set value use the modify command with a new value of \-1.
+\fIMaxJobs\fP=<max jobs>
+Maximum number of jobs each user is allowed to run at one time in this account.
+This is overridden if set directly on an account or user. 
+Default is no limit.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxNodes\fP=<max nodes>
+Maximum number of nodes each job is able to use in this account.
+This is overridden if set directly on an account or user. 
+Default is no limit.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxWall\fP=<max wall>
+Maximum wall clock time each job is able to use in this account.
+This is overridden if set directly on an account or user. 
+Default is no limit.
+<max wall> format is <min> or <min>:<sec> or <hr>:<min>:<sec> or 
+<days>\-<hr>:<min>:<sec> or <days>\-<hr>.
+The value is recorded in minutes with rounding as needed.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIQosLevel\fP=<qos>
+Quality of Service jobs are to run at for this account.  Now consisting
+of Normal, Standby, Expedite, and Exempt.
+This is overridden if set directly on an account or user. 
+
+.TP
+\fBSPECIFICATIONS FOR USERS\fR
+.TP
+\fIAccount\fP=<account>
+Account name to add this user to.
+.TP
+\fIAdminLevel\fP=<level>
+Admin level of user.  Valid levels are None, Operator, and Admin.
+.TP
+\fICluster\fP=<cluster>
+Specific cluster to add user to the account on.  Default is all in system.
+.TP
+\fIDefaultAccount\fP=<account>
+Identify the default bank account name to be used for a job if none is 
+specified at submission time.
+.TP
+\fIFairshare\fP=<fairshare>
+Number used in conjunction with other users in the same account to
+determine job priority.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIName\fP=<name>
+Name of user.
+.TP
+\fIQosLevel\fP=<qos>
+The Quality of Service jobs are to run at for this user using the
+account specified.  Now consisting of Normal, Standby, Expedite, and Exempt.
+.TP
+\fIMaxCPUSecs\fP=<max cpu seconds> 
+Maximum number of cpu seconds this user can use in each job using the
+account specified.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxJobs\fP=<max jobs>
+Maximum number of jobs this user can run at a given time using the
+account specified.
+This is overridden if set directly on a user. 
+Default is the account's limit.
+To clear a previously set value use the modify command with a new value of \-1.
+.TP
+\fIMaxNodes\fP=<max nodes>
+Maximum number of nodes this user can allocate in each job using the
+account specified. 
+Default is the account's limit.
+.TP
+\fIMaxWall\fP=<max wall>
+Maximum wall clock time this user can use in each job using the
+account specified.
+Default is the account's limit.
+<max wall> format is <min> or <min>:<sec> or <hr>:<min>:<sec> or 
+<days>\-<hr>:<min>:<sec> or <days>\-<hr>.
+The is recorded in minutes with rounding as needed.
+To clear a previously set value use the modify command with a new value of \-1.
+
+.SH "EXAMPLES"
+.eo
+.br
+> sacctmgr create cluster=tux
+.br
+> sacctmgr create account name=science fairshare=50
+.br
+> sacctmgr create account name=chemistry parent=science fairshare=30
+.br
+> sacctmgr create account name=physics   parent=science fairshare=20
+.br
+> sacctmgr create user name=adam cluster=tux bank=physics fairshare=10
+.br
+> sacctmgr modify user with name=adam cluster=tux bank=physics \
+.br
+  set maxjobs=2 maxtime=30:00
+.ec
+
+.SH "COPYING"
+Copyright (C) 2008 Lawrence Livermore National Security.
+Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+LLNL\-CODE\-402394.
+.LP
+This file is part of SLURM, a resource management program.
+For details, see <https://computing.llnl.gov/linux/slurm/>.
+.LP
+SLURM is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+.LP
+SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+details.
+
+.SH "SEE ALSO"
+\fBslurm.conf\fR(5)
+\fBslurmdbd\fR(8)
diff --git a/doc/man/man1/salloc.1 b/doc/man/man1/salloc.1
index 15597c13227936bb6468f888f1c9e30e39237b55..07b2eabcefed541a983963c34f52dec6842f4f31 100644
--- a/doc/man/man1/salloc.1
+++ b/doc/man/man1/salloc.1
@@ -1,4 +1,4 @@
-.TH "salloc" "1" "SLURM 1.2" "February 2008" "SLURM Commands"
+.TH "salloc" "1" "SLURM 1.3" "May 2008" "SLURM Commands"
 .SH "NAME"
 .LP 
 salloc \- Obtain a SLURM job allocation (a set of nodes), execute a command, and then release the allocation when the command is finished.
@@ -15,6 +15,42 @@ The command may be any program the user wishes.  Some typical commands are xterm
 .SH "OPTIONS"
 .LP 
 
+.TP
+\fB\-\-acctg\-freq\fR=\fIseconds\fR
+Define the job accounting sampling interval.
+This can be used to override the \fIJobAcctGatherFrequency\fR parameter in SLURM's
+configuration file, \fIslurm.conf\fR.
+A value of zero disables real the periodic job sampling and provides accounting
+information only on job termination (reducing SLURM interference with the job).
+
+.TP
+\fB\-B\fR \fB\-\-extra\-node\-info\fR=\fIsockets\fR[:\fIcores\fR[:\fIthreads\fR]]
+Request a specific allocation of resources with details as to the
+number and type of computational resources within a cluster:
+number of sockets (or physical processors) per node,
+cores per socket, and threads per core.
+The total amount of resources being requested is the product of all of
+the terms.
+As with \-\-nodes, each value can be a single number or a range (e.g. min\-max).
+An asterisk (*) can be used as a placeholder indicating that all available
+resources of that type are to be utilized.
+As with nodes, the individual levels can also be specified in separate
+options if desired:
+.nf
+    \fB\-\-sockets\-per\-node\fR=\fIsockets\fR
+    \fB\-\-cores\-per\-socket\fR=\fIcores\fR
+    \fB\-\-threads\-per\-core\fR=\fIthreads\fR
+.fi
+When the task/affinity plugin is enabled,
+specifying an allocation in this manner also instructs SLURM to use
+a CPU affinity mask to guarantee the request is filled as specified.
+NOTE: Support for these options are configuration dependent. 
+The task/affinity plugin must be configured.
+In addition either select/linear or select/cons_res plugin must be 
+configured.
+If select/cons_res is configured, it must have a parameter of CR_Core, 
+CR_Core_Memory, CR_Socket, or CR_Socket_Memory. 
+
 .TP
 \fB\-\-begin\fR[=]<\fItime\fR>
 Submit the batch script to the SLURM controller immediately, like normal, but
@@ -58,6 +94,12 @@ nodes, then use the OR operator and enclose the options within square brackets.
 For example: "\fB\-\-constraint="[rack1|rack2|rack3|rack4]"\fR might 
 be used to specify that all nodes must be allocated on a single rack of 
 the cluster, but any of those four racks can be used.
+A request can also specify the number of nodes needed with some feature
+by appending an asterisk and count after the feature name. 
+For example "\fBsalloc \-\-nodes=16 \-\-constraint=graphics*4 ..."\fR 
+indicates that the job requires 16 nodes at that at least four of those
+nodes must have the feature "graphics."
+Constraints with node counts may only be combined with AND operators.
 If no nodes have the requested features, then the job will be rejected 
 by the slurm job manager.
 
@@ -88,13 +130,6 @@ of 4 nodes, one for each of the 4 tasks.
 \fB\-D\fR, \fB\-\-chdir\fR=\fIpath\fR
 change directory to \fIpath\fR before beginning execution. 
 
-.TP 
-\fB\-d\fR, \fB\-\-dependency\fR[=]<\fIjobid\fR>
-Defer the start of this job until the specified \fIjobid\fR has completed.
-Many jobs can share the same dependency and these jobs may even belong to
-different  users.   The  value may be changed after job submission using the
-scontrol command.
-
 .TP
 \fB\-\-exclusive\fR
 The job allocation cannot share nodes with other running jobs.  This is
@@ -115,7 +150,7 @@ will be sorted my SLURM.
 This option will load login environment variables for the user specified 
 in the \fB\-\-uid\fR option.
 The environment variables are retrieved by running something of this sort
-"su - <username> -c /usr/bin/env" and parsing the output.  
+"su \- <username> \-c /usr/bin/env" and parsing the output.  
 Be aware that any environment variables already set in salloc's environment 
 will take precedence over any environment variables in the user's 
 login environment.
@@ -142,6 +177,26 @@ may be the group name or the numerical group ID.
 \fB\-h\fR, \fB\-\-help\fR
 Display help information and exit.
 
+.TP
+\fB\-\-hint\fR=\fItype\fR
+Bind tasks according to application hints
+.RS
+.TP
+.B compute_bound
+Select settings for compute bound applications:
+use all cores in each physical CPU
+.TP
+.B memory_bound
+Select settings for memory bound applications:
+use only one core in each physical CPU
+.TP
+.B [no]multithread
+[don't] use extra threads with in-core multi-threading
+which can benefit communication intensive applications
+.B help
+show this help message
+.RE
+
 .TP 
 \fB\-I\fR,\fB\-\-immediate\fR
 Grab the requested resources immediately, or abort if the resources are not
@@ -182,6 +237,60 @@ new job steps on the remaining nodes in their allocation.
 By default SLURM terminates the entire job allocation if any node fails in its
 range of allocated nodes.
 
+.TP
+\fB\-L\fR, \fB\-\-licenses\fR=
+Specification of licenses (or other resources available on all 
+nodes of the cluster) which must be allocated to this job.
+License names can be followed by an asterisk and count 
+(the default count is one).
+Multiple license names should be comma separated (e.g.
+"\-\-licenses=foo*4,bar").
+
+.TP
+\fB\-m\fR, \fB\-\-distribution\fR=
+(\fIblock\fR|\fIcyclic\fR|\fIarbitrary\fR|\fIplane=<options>\fR)
+Specify an alternate distribution method for remote processes.
+.RS
+.TP
+.B block
+The block method of distribution will allocate processes in\-order to
+the cpus on a node. If the number of processes exceeds the number of 
+cpus on all of the nodes in the allocation then all nodes will be 
+utilized. For example, consider an allocation of three nodes each with 
+two cpus. A four\-process block distribution request will distribute 
+those processes to the nodes with processes one and two on the first 
+node, process three on the second node, and process four on the third node.  
+Block distribution is the default behavior if the number of tasks 
+exceeds the number of nodes requested.
+.TP
+.B cyclic
+The cyclic method distributes processes in a round\-robin fashion across
+the allocated nodes. That is, process one will be allocated to the first
+node, process two to the second, and so on. This is the default behavior
+if the number of tasks is no larger than the number of nodes requested.
+.TP
+.B plane
+The tasks are distributed in blocks of a specified size.
+The options include a number representing the size of the task block.
+This is followed by an optional specification of the task distribution 
+scheme within a block of tasks and between the blocks of tasks.
+For more details (including examples and diagrams), please see
+.ad l
+.nh
+https://computing.llnl.gov/linux/slurm/mc_support.html and
+https://computing.llnl.gov/linux/slurm/dist_plane.html.
+.hy
+.ad
+.TP
+.B arbitrary
+The arbitrary method of distribution will allocate processes in\-order as 
+listed in file designated by the environment variable SLURM_HOSTFILE.  If
+this variable is listed it will over ride any other method specified. 
+If not set the method will default to block.  Inside the hostfile must
+contain at minimum the number of hosts requested.  If requesting tasks
+(\-n) your tasks will be laid out on the nodes in the order of the file.
+.RE
+
 .TP
 \fB\-\-mail\-type\fR=\fItype\fR
 Notify user by email when certain event types occur. 
@@ -196,7 +305,13 @@ The default value is the username of the submitting user.
 
 .TP
 \fB\-\-mem\fR[=]<\fIMB\fR>
-Specify a minimum amount of real memory.
+Specify the real memory required per node in MegaBytes.
+If a value is specified, that quantity of memory will be 
+reserved for this job. 
+If no value is specified and real memory is exhausted on 
+any allocated node then the job is subject to cancellation.
+Also see \fB\-\-task\-mem\fR.
+
 
 .TP
 \fB\-\-mincores\fR[=]<\fIn\fR>
@@ -236,13 +351,14 @@ If a job node limit exceeds the number of nodes configured in the
 partition, the job will be rejected.
 
 .TP
-\fB\-n\fR, \fB\-\-tasks\fR[=]<\fInumber\fR>
-salloc does not launch tasks, it requests an allocation of resources and submits
-a batch script.  However this \-\-tasks option advizes the SLURM controller
-that job steps run within this allocation will launch a maximum of \fInumber\fR
-tasks.  This option, possibly with collaboration with the \-\-cpus\-per\-task
-option, will directly impact the number of processors granted to the job
-allocation.
+\fB\-n\fR, \fB\-\-ntasks\fR[=]<\fInumber\fR>
+salloc does not launch tasks, it requests an allocation of resources and 
+executed some command. This option advises the SLURM controller that job 
+steps run within this allocation will launch a maximum of \fInumber\fR
+tasks and sufficient resources are allocated to accomplish this.  
+The default is one task per socket or core (depending upon the value 
+of the \fISelectTypeParameters\fR parameter in slurm.conf), but note 
+that the \fB\-\-cpus\-per\-task\fR option will change this default.
 
 .TP 
 \fB\-\-nice\fR[=]<\fIadjustment\fR>
@@ -254,6 +370,40 @@ a negative adjustment. NOTE: This option is presently
 ignored if \fISchedulerType=sched/wiki\fR or 
 \fISchedulerType=sched/wiki2\fR.
 
+.TP
+\fB\-\-ntasks\-per\-core\fR=\fIntasks\fR
+Request that no more than \fIntasks\fR be invoked on each core.
+Similar to \fB\-\-ntasks\-per\-node\fR except at the core level
+instead of the node level.  Masks will automatically be generated
+to bind the tasks to specific core unless \fB\-\-cpu_bind=none\fR
+is specified.
+NOTE: This option is not supported unless \fISelectType=CR_Core\fR
+or \fISelectType=CR_Core_Memory\fR is configured.
+
+.TP
+\fB\-\-ntasks\-per\-socket\fR=\fIntasks\fR
+Request that no more than \fIntasks\fR be invoked on each socket.
+Similar to \fB\-\-ntasks\-per\-node\fR except at the socket level
+instead of the node level.  Masks will automatically be generated
+to bind the tasks to specific sockets unless \fB\-\-cpu_bind=none\fR
+is specified.
+NOTE: This option is not supported unless \fISelectType=CR_Socket\fR 
+or \fISelectType=CR_Socket_Memory\fR is configured.
+
+.TP
+\fB\-\-ntasks\-per\-node\fR=\fIntasks\fR
+Request that no more than \fIntasks\fR be invoked on each node.
+This is similar to using \fB\-\-cpus\-per\-task\fR=\fIncpus\fR
+but does not require knowledge of the actual number of cpus on
+each node.  In some cases, it is more convenient to be able to
+request that no more than a specific number of ntasks be invoked
+on each node.  Examples of this include submitting
+a hybrid MPI/OpenMP app where only one MPI "task/rank" should be
+assigned to each node while allowing the OpenMP portion to utilize
+all of the parallelism present in the node, or submitting a single
+setup/cleanup/monitoring job to each node of a pre\-existing  
+allocation as one step in a larger job script.
+
 .TP 
 \fB\-\-no\-bell\fR
 Silence salloc's use of the terminal bell. Also see the option \fB\-\-bell\fR.
@@ -276,6 +426,34 @@ Request a specific partition for the resource allocation.  If not specified,
 the default behaviour is to allow the slurm controller to select the default
 partition as designated by the system administrator.
 
+.TP 
+\fB\-P\fR, \fB\-\-dependency\fR[=]<\fIdependency_list\fR>
+Defer the start of this job until the specified dependencies have been
+satisfied completed.
+<\fIdependency_list\fR> is of the form 
+<\fItype:job_id[:job_id][,type:job_id[:job_id]]\fR>.
+Many jobs can share the same dependency and these jobs may even belong to
+different  users. The  value may be changed after job submission using the
+scontrol command.
+.PD
+.RS
+.TP
+\fBafter:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have begun
+execution.
+.TP
+\fBafterany:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have terminated.
+.TP
+\fBafternotok:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have terminated
+in some failed state (non-zero exit code, node failure, timed out, etc).
+.TP
+\fBafterok:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have successfully
+executed (ran to completion with non-zero exit code).
+.RE
+
 .TP
 \fB\-q\fR, \fB\-\-quiet\fR
 Suppress informational messages from salloc. Errors will still be displayed.
@@ -301,6 +479,13 @@ Acceptable time formats include "minutes", "minutes:seconds",
 "hours:minutes:seconds", "days\-hours", "days\-hours:minutes" and 
 "days\-hours:minutes:seconds".
 
+.TP
+\fB\-\-task\-mem\fR[=]<\fIMB\fR>
+Mimimum memory available per task in MegaBytes.
+Default value is \fBDefMemPerTask\fR and the maximum value is
+\fBMaxMemPerTask\fR, both of which can be seen using the
+\fBscontrol show config\fR command.
+
 .TP
 \fB\-\-tmp\fR[=]<\fIMB\fR>
 Specify a minimum amount of temporary disk space.
@@ -374,7 +559,7 @@ SLURM will normally allocate a TORUS if possible for a given geometry.
 Specify the geometry requirements for the job. The three numbers 
 represent the required geometry giving dimensions in the X, Y and 
 Z directions. For example "\-\-geometry=2x3x4", specifies a block 
-of nodes having 2 x 3 x 4 = 24 nodes (actually base partions on 
+of nodes having 2 x 3 x 4 = 24 nodes (actually base partitions on 
 Blue Gene).
 
 .TP
@@ -397,6 +582,9 @@ variables settings.
 \fBSALLOC_ACCOUNT\fR
 Same as \fB\-\-account\fR.
 .TP
+\fBSALLOC_ACCTG_FREQ\fR
+Same as \fB\-\-acctg\-freq\fR.
+.TP
 \fBSALLOC_BELL\fR
 Same as \fB\-\-bell\fR.
 .TP
@@ -481,7 +669,8 @@ The block name on Blue Gene systems only.
 .LP 
 While salloc is waiting for a PENDING job allocation, most signals will cause salloc to revoke the allocation request and exit.
 
-However, if the allocation has been granted and salloc has already started the command speficied in its command line parameters salloc will ignore most signals.  salloc will not exit or release the allocation until the command exits.  The noteable exception is SIGHUP; a HUP signal will cause salloc to release the allocation and exit without waiting for the command to finish.
+However, if the allocation has been granted and salloc has already started the command 
+specified in its command line parameters salloc will ignore most signals.  salloc will not exit or release the allocation until the command exits.  The notable exception is SIGHUP; a HUP signal will cause salloc to release the allocation and exit without waiting for the command to finish.
 
 .SH "EXAMPLES"
 .LP 
@@ -502,7 +691,7 @@ salloc \-N5 srun \-n10 myprogram
 .SH "COPYING"
 Copyright (C) 2006\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/sattach.1 b/doc/man/man1/sattach.1
index 3c8464da7f7e69221be50ba1a2d92d18889a91a3..a13f1da7d366357d5b6f6d97215820ef6ce01b46 100644
--- a/doc/man/man1/sattach.1
+++ b/doc/man/man1/sattach.1
@@ -69,7 +69,7 @@ sattach \-\-output\-filter 5 65386.15
 .SH "COPYING"
 Copyright (C) 2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/sbatch.1 b/doc/man/man1/sbatch.1
index 9971fdfc128d2d11653c6da0b5c1a1db65c01760..18e38369b1a697f9e017a8fc1c8c8c2a497c8b60 100644
--- a/doc/man/man1/sbatch.1
+++ b/doc/man/man1/sbatch.1
@@ -1,4 +1,4 @@
-.TH "sbatch" "1" "SLURM 1.2" "August 2007" "SLURM Commands"
+.TH "sbatch" "1" "SLURM 1.3" "May 2008" "SLURM Commands"
 .SH "NAME"
 .LP 
 sbatch \- Submit a batch script to SLURM.
@@ -10,7 +10,7 @@ sbatch [\fIoptions\fP] \fIscript\fP [\fIargs\fP...]
 sbatch submits a batch script to SLURM.  The batch script may be given to
 sbatch through a file name on the command line, or if no file name is specified,
 sbatch will read in a script from standard input. The batch script may contain
-options preceeded with "#SBATCH" before any executable commands in the script.
+options preceded with "#SBATCH" before any executable commands in the script.
 
 sbatch exits immediately after the script is successfully transferred to the
 SLURM controller and assigned a SLURM job ID.  The batch script is not
@@ -23,6 +23,42 @@ allocated nodes.
 .SH "OPTIONS"
 .LP 
 
+.TP
+\fB\-\-acctg\-freq\fR=\fIseconds\fR
+Define the job accounting sampling interval.
+This can be used to override the \fIJobAcctGatherFrequency\fR parameter in SLURM's
+configuration file, \fIslurm.conf\fR.
+A value of zero disables real the periodic job sampling and provides accounting
+information only on job termination (reducing SLURM interference with the job).
+
+.TP
+\fB\-B\fR \fB\-\-extra\-node\-info\fR=\fIsockets\fR[:\fIcores\fR[:\fIthreads\fR]]
+Request a specific allocation of resources with details as to the
+number and type of computational resources within a cluster:
+number of sockets (or physical processors) per node,
+cores per socket, and threads per core.
+The total amount of resources being requested is the product of all of
+the terms.
+As with \-\-nodes, each value can be a single number or a range (e.g. min\-max).
+An asterisk (*) can be used as a placeholder indicating that all available
+resources of that type are to be utilized.
+As with nodes, the individual levels can also be specified in separate
+options if desired:
+.nf
+    \fB\-\-sockets\-per\-node\fR=\fIsockets\fR
+    \fB\-\-cores\-per\-socket\fR=\fIcores\fR
+    \fB\-\-threads\-per\-core\fR=\fIthreads\fR
+.fi
+When the task/affinity plugin is enabled,
+specifying an allocation in this manner also instructs SLURM to use
+a CPU affinity mask to guarantee the request is filled as specified.
+NOTE: Support for these options are configuration dependent. 
+The task/affinity plugin must be configured.
+In addition either select/linear or select/cons_res plugin must be 
+configured.
+If select/cons_res is configured, it must have a parameter of CR_Core, 
+CR_Core_Memory, CR_Socket, or CR_Socket_Memory. 
+
 .TP
 \fB\-\-begin\fR[=]<\fItime\fR>
 Submit the batch script to the SLURM controller immediately, like normal, but
@@ -59,6 +95,12 @@ nodes, then use the OR operator and enclose the options within square brackets.
 For example: "\fB\-\-constraint="[rack1|rack2|rack3|rack4]"\fR might 
 be used to specify that all nodes must be allocated on a single rack of 
 the cluster, but any of those four racks can be used.
+A request can also specify the number of nodes needed with some feature
+by appending an asterisk and count after the feature name. 
+For example "\fBsbatch \-\-nodes=16 \-\-constraint=graphics*4 ..."\fR 
+indicates that the job requires 16 nodes at that at least four of those
+nodes must have the feature "graphics."
+Constraints with node counts may only be combined with AND operators.
 If no nodes have the requested features, then the job will be rejected 
 by the slurm job manager.
 
@@ -90,13 +132,6 @@ Demand a contiguous range of nodes. The default is "yes". Specify
 Set the working directory of the batch script to \fIdirectory\fR before
 it it executed.
 
-.TP 
-\fB\-d\fR, \fB\-\-dependency\fR[=]<\fIjobid\fR>
-Defer the start of this job until the specified \fIjobid\fR has completed.
-Many jobs can share the same dependency and these jobs may even belong to
-different  users.   The  value may be changed after job submission using the
-scontrol command.
-
 .TP
 \fB\-e\fR, \fB\-\-error\fR[=]<\fIfilename pattern\fR>
 Instruct SLURM to connect the batch script's standard error directly to the 
@@ -150,6 +185,26 @@ may be the group name or the numerical group ID.
 \fB\-h\fR, \fB\-\-help\fR
 Display help information and exit.
 
+.TP
+\fB\-\-hint\fR=\fItype\fR
+Bind tasks according to application hints
+.RS
+.TP
+.B compute_bound
+Select settings for compute bound applications:
+use all cores in each physical CPU
+.TP
+.B memory_bound
+Select settings for memory bound applications:
+use only one core in each physical CPU
+.TP
+.B [no]multithread
+[don't] use extra threads with in-core multi-threading
+which can benefit communication intensive applications
+.B help
+show this help message
+.RE
+
 .TP 
 \fB\-I\fR,\fB\-\-immediate\fR
 The batch script will only be submitted to the controller if the resources
@@ -206,6 +261,60 @@ new job steps on the remaining nodes in their allocation.
 By default SLURM terminates the entire job allocation if any node fails in its
 range of allocated nodes.
 
+.TP
+\fB\-L\fR, \fB\-\-licenses\fR=
+Specification of licenses (or other resources available on all 
+nodes of the cluster) which must be allocated to this job.
+License names can be followed by an asterisk and count 
+(the default count is one).
+Multiple license names should be comma separated (e.g.
+"\-\-licenses=foo*4,bar").
+
+.TP
+\fB\-m\fR, \fB\-\-distribution\fR=
+(\fIblock\fR|\fIcyclic\fR|\fIarbitrary\fR|\fIplane=<options>\fR)
+Specify an alternate distribution method for remote processes.
+.RS
+.TP
+.B block
+The block method of distribution will allocate processes in\-order to
+the cpus on a node. If the number of processes exceeds the number of 
+cpus on all of the nodes in the allocation then all nodes will be 
+utilized. For example, consider an allocation of three nodes each with 
+two cpus. A four\-process block distribution request will distribute 
+those processes to the nodes with processes one and two on the first 
+node, process three on the second node, and process four on the third node.  
+Block distribution is the default behavior if the number of tasks 
+exceeds the number of nodes requested.
+.TP
+.B cyclic
+The cyclic method distributes processes in a round\-robin fashion across
+the allocated nodes. That is, process one will be allocated to the first
+node, process two to the second, and so on. This is the default behavior
+if the number of tasks is no larger than the number of nodes requested.
+.TP
+.B plane
+The tasks are distributed in blocks of a specified size.
+The options include a number representing the size of the task block.
+This is followed by an optional specification of the task distribution 
+scheme within a block of tasks and between the blocks of tasks.
+For more details (including examples and diagrams), please see
+.ad l
+.nh
+https://computing.llnl.gov/linux/slurm/mc_support.html and
+https://computing.llnl.gov/linux/slurm/dist_plane.html.
+.hy
+.ad
+.TP
+.B arbitrary
+The arbitrary method of distribution will allocate processes in\-order as 
+listed in file designated by the environment variable SLURM_HOSTFILE.  If
+this variable is listed it will over ride any other method specified. 
+If not set the method will default to block.  Inside the hostfile must
+contain at minimum the number of hosts requested.  If requesting tasks
+(\-n) your tasks will be laid out on the nodes in the order of the file.
+.RE
+
 .TP
 \fB\-\-mail\-type\fR=\fItype\fR
 Notify user by email when certain event types occur. 
@@ -220,7 +329,12 @@ The default value is the username of the submitting user.
 
 .TP
 \fB\-\-mem\fR[=]<\fIMB\fR>
-Specify a minimum amount of real memory.
+Specify the real memory required per node in MegaBytes.
+If a value is specified, that quantity of memory will be 
+reserved for this job. 
+If no value is specified and real memory is exhausted on 
+any allocated node then the job is subject to cancellation.
+Also see \fB\-\-task\-mem\fR.
 
 .TP
 \fB\-\-mincores\fR[=]<\fIn\fR>
@@ -260,13 +374,14 @@ If a job node limit exceeds the number of nodes configured in the
 partition, the job will be rejected.
 
 .TP
-\fB\-n\fR, \fB\-\-tasks\fR[=]<\fInumber\fR>
-sbatch does not launch tasks, it requests an allocation of resources and submits
-a batch script.  However this \-\-tasks option advizes the SLURM controller
-that job steps run within this allocation will launch a maximum of \fInumber\fR
-tasks.  This option, possibly with collaboration with the \-\-cpus\-per\-task
-option, will directly impact the number of processors granted to the job
-allocation.
+\fB\-n\fR, \fB\-\-ntasks\fR[=]<\fInumber\fR>
+sbatch does not launch tasks, it requests an allocation of resources and 
+submits a batch script. This option advises the SLURM controller that job 
+steps run within this allocation will launch a maximum of \fInumber\fR
+tasks and sufficient resources are allocated to accomplish this.  
+The default is one task per socket or core (depending upon the value 
+of the \fISelectTypeParameters\fR parameter in slurm.conf), but note 
+that the \fB\-\-cpus\-per\-task\fR option will change this default.
 
 .TP 
 \fB\-\-nice\fR[=]<\fIadjustment\fR>
@@ -280,15 +395,47 @@ ignored if \fISchedulerType=sched/wiki\fR or
 
 .TP
 \fB\-\-no\-requeue\fR
-Specifies that the batch job should not be requeued.
+Specifies that the batch job should not be requeued after node failure.
 Setting this option will prevent system administrators from being able 
 to restart the job (for example, after a scheduled downtime).
 When a job is requeued, the batch script is initiated from its beginning.
-
-.TP
-\fB\-\-ntasks\-per\-node\fR[=]<\fIn\fR>
-Specify the number of tasks to be launched per node.
-Equivalent to \fB\-\-tasks\-per\-node\fR.
+Also see the \fB\-\-requeue\fR option.
+The \fIJobRequeue\fR configuration parameter controls the default 
+behavior on the cluster.
+
+.TP
+\fB\-\-ntasks\-per\-core\fR=\fIntasks\fR
+Request that no more than \fIntasks\fR be invoked on each core.
+Similar to \fB\-\-ntasks\-per\-node\fR except at the core level
+instead of the node level.  Masks will automatically be generated
+to bind the tasks to specific core unless \fB\-\-cpu_bind=none\fR
+is specified.
+NOTE: This option is not supported unless \fISelectType=CR_Core\fR
+or \fISelectType=CR_Core_Memory\fR is configured.
+
+.TP
+\fB\-\-ntasks\-per\-socket\fR=\fIntasks\fR
+Request that no more than \fIntasks\fR be invoked on each socket.
+Similar to \fB\-\-ntasks\-per\-node\fR except at the socket level
+instead of the node level.  Masks will automatically be generated
+to bind the tasks to specific sockets unless \fB\-\-cpu_bind=none\fR
+is specified.
+NOTE: This option is not supported unless \fISelectType=CR_Socket\fR 
+or \fISelectType=CR_Socket_Memory\fR is configured.
+
+.TP
+\fB\-\-ntasks\-per\-node\fR=\fIntasks\fR
+Request that no more than \fIntasks\fR be invoked on each node.
+This is similiar to using \fB\-\-cpus\-per\-task\fR=\fIncpus\fR
+but does not require knowledge of the actual number of cpus on
+each node.  In some cases, it is more convenient to be able to
+request that no more than a specific number of ntasks be invoked
+on each node.  Examples of this include submitting
+a hybrid MPI/OpenMP app where only one MPI "task/rank" should be
+assigned to each node while allowing the OpenMP portion to utilize
+all of the parallelism present in the node, or submitting a single
+setup/cleanup/monitoring job to each node of a pre\-existing  
+allocation as one step in a larger job script.
 
 .TP
 \fB\-O\fR, \fB\-\-overcommit\fR
@@ -303,6 +450,12 @@ Instruct SLURM to connect the batch script's standard output directly to the
 file name specified in the "\fIfilename pattern\fR".
 See the \fB\-\-input\fR option for filename specification options.
 
+.TP
+\fB\-\-open\-mode\fR=append|truncate
+Open the output and error files using append or truncate mode as specified.
+The default value is specified by the system configuration parameter
+\fIJobFileAppend\fR.
+
 .TP 
 \fB\-p\fR, \fB\-\-partition\fR[=]<\fIpartition name\fR>
 Request a specific partition for the resource allocation.  If not specified, the
@@ -353,10 +506,46 @@ The maximum resident set size
 The maximum stack size
 .RE
 
+.TP 
+\fB\-P\fR, \fB\-\-dependency\fR[=]<\fIdependency_list\fR>
+Defer the start of this job until the specified dependencies have been
+satisfied completed.
+<\fIdependency_list\fR> is of the form 
+<\fItype:job_id[:job_id][,type:job_id[:job_id]]\fR>.
+Many jobs can share the same dependency and these jobs may even belong to
+different  users. The  value may be changed after job submission using the
+scontrol command.
+.PD
+.RS
+.TP
+\fBafter:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have begun
+execution.
+.TP
+\fBafterany:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have terminated.
+.TP
+\fBafternotok:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have terminated
+in some failed state (non-zero exit code, node failure, timed out, etc).
+.TP
+\fBafterok:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have successfully
+executed (ran to completion with non-zero exit code).
+.RE
+
 .TP
 \fB\-q\fR, \fB\-\-quiet\fR
 Suppress informational messages from sbatch. Errors will still be displayed.
 
+.TP
+\fB\-\-requeue\fR
+Specifies that the batch job should be requeued after node failure.
+When a job is requeued, the batch script is initiated from its beginning.
+Also see the \fB\-\-no\-requeue\fR option.
+The \fIJobRequeue\fR configuration parameter controls the default 
+behavior on the cluster.
+
 .TP
 \fB\-s\fR, \fB\-\-share\fR
 The job allocation can share nodes with other running jobs.  (The default
@@ -378,6 +567,13 @@ Acceptable time formats include "minutes", "minutes:seconds",
 "hours:minutes:seconds", "days\-hours", "days\-hours:minutes" and 
 "days\-hours:minutes:seconds".
 
+.TP
+\fB\-\-task\-mem\fR[=]<\fIMB\fR>
+Mimimum memory available per task in MegaBytes.
+Default value is \fBDefMemPerTask\fR and the maximum value is
+\fBMaxMemPerTask\fR, both of which can be seen using the
+\fBscontrol show config\fR command.
+
 .TP
 \fB\-\-tasks\-per\-node\fR[=]<\fIn\fR>
 Specify the number of tasks to be launched per node.
@@ -497,6 +693,9 @@ environment variables.
 \fBSBATCH_ACCOUNT\fR
 Same as \fB\-\-account\fR.
 .TP
+\fBSALLOC_ACCTG_FREQ\fR
+Same as \fB\-\-acctg\-freq\fR.
+.TP
 \fBSBATCH_CONN_TYPE\fR
 Same as \fB\-\-conn\-type\fR.
 .TP
@@ -524,6 +723,9 @@ Same as \fB\-\-no\-requeue\fR.
 \fBSBATCH_NO_ROTATE\fR
 Same as \fB\-R\fR or \fB\-\-no\-rotate\fR.
 .TP
+\fBSLURM_OPEN_MODE\fR
+Same as \fB\-\-open\-mode\fR.
+.TP
 \fBSLURM_OVERCOMMIT\fR
 Same as \fB\-O, \-\-overcommit\fR
 .TP
@@ -571,6 +773,18 @@ Do not allocate a block on Blue Gene systems only.
 \fBMPIRUN_NOFREE\fR
 Do not free a block on Blue Gene systems only.
 .TP
+\fBSLURM_NTASKS_PER_CORE\fR
+Number of tasks requested per core.
+Only set if the \fB\-\-ntasks\-per\-core\fR option is specified.
+.TP
+\fBSLURM_NTASKS_PER_NODE\fR
+Number of tasks requested per node.
+Only set if the \fB\-\-ntasks\-per\-node\fR option is specified.
+.TP
+\fBSLURM_NTASKS_PER_SOCKET\fR
+Number of tasks requested per socket.
+Only set if the \fB\-\-ntasks\-per\-socket\fR option is specified.
+.TP
 \fBMPIRUN_PARTITION\fR
 The block name on Blue Gene systems only.
 
@@ -633,7 +847,7 @@ host4
 .SH "COPYING"
 Copyright (C) 2006\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/sbcast.1 b/doc/man/man1/sbcast.1
index 5984ab3940dbb23e81bb9389e8ba7aa05a0dd047..7f76a4ca30ee83b9cbf1ce70728e354df2a9203d 100644
--- a/doc/man/man1/sbcast.1
+++ b/doc/man/man1/sbcast.1
@@ -100,7 +100,7 @@ srun: jobid 12345 submitted
 .SH "COPYING"
 Copyright (C) 2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/scancel.1 b/doc/man/man1/scancel.1
index 28ba0d031e0f06b9070dae1d31297f2f08b3ca2b..773fcecc0e9ded8a464fd1927bfdbdb855b1d27c 100644
--- a/doc/man/man1/scancel.1
+++ b/doc/man/man1/scancel.1
@@ -1,8 +1,11 @@
 .TH SCANCEL "1" "August 2007" "scancel 1.2" "Slurm components"
+
 .SH "NAME"
 scancel \- Used to signal jobs or job steps that are under the control of Slurm.
+
 .SH "SYNOPSIS"
 \fBscancel\fR [\fIOPTIONS\fR...] [\fIjob_id\fR[.\fIstep_id\fR]] [\fIjob_id\fR[.\fIstep_id\fR]...]
+
 .SH "DESCRIPTION"
 \fBscancel\fR is used to signal or cancel jobs or job steps. An arbitrary number 
 of jobs or job steps may be signaled using job specification filters or a
@@ -46,7 +49,8 @@ This option is incompatible with the \fB\-\-verbose\fR option.
 
 .TP
 \fB\-s\fR, \fB\-\-signal\fR=\fIsignal_name\fR
-The name or number of the signal to be send. Default value is "KILL".
+The name or number of the signal to be send. 
+If no signal is specified, the specified job or step will be terminated.
 
 .TP
 \fB\-t\fR, \fB\-\-state\fR=\fIjob_state_name\fR
@@ -81,10 +85,7 @@ The Slurm job ID to be signaled.
 \fIstep_id\fP
 The step ID of the job step to be signaled. 
 If not specified, the operation is performed at the level of a job.
-A "KILL" (the default) signal applied to a job cancels the job and
-all of its steps.
-For other signals, when \fB\-\-batch\fR is used, the batch shell 
-processes will be signalled.
+When \fB\-\-batch\fR is used, the batch shell processes will be signalled.
 Otherwise the processes associated with all job steps, but not the 
 batch script itself, will be signalled.
 
@@ -153,7 +154,7 @@ scancel \-\-state=PENDING \-\-user=bob \-\-partition=debug
 .SH "COPYING"
 Copyright (C) 2002-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/scontrol.1 b/doc/man/man1/scontrol.1
index 9c6c4a7def4de0dc6af8977b394ff71531d48b16..810dba3c9ae11356b1716c2a462eb796bc89a1ef 100644
--- a/doc/man/man1/scontrol.1
+++ b/doc/man/man1/scontrol.1
@@ -1,10 +1,11 @@
-.TH SCONTROL "1" "June 2007" "scontrol 1.2" "Slurm components"
+.TH SCONTROL "1" "December 2007" "scontrol 1.3" "Slurm components"
 
 .SH "NAME"
 scontrol \- Used view and modify Slurm configuration and state.
 
 .SH "SYNOPSIS"
 \fBscontrol\fR [\fIOPTIONS\fR...] [\fICOMMAND\fR...]
+
 .SH "DESCRIPTION"
 \fBscontrol\fR is used to view or modify Slurm configuration including: job, 
 job step, node, partition, and overall system configuration. Most of the 
@@ -52,7 +53,7 @@ Print version information and exit.
 
 .TP
 \fBall\fP
-Show all partitiion, their jobs and jobs steps. This causes information to be 
+Show all partitions, their jobs and jobs steps. This causes information to be 
 displayed about partitions that are configured as hidden and partitions that
 are unavailable to user's group.
 
@@ -106,29 +107,33 @@ Display a description of scontrol options and commands.
 
 .TP
 \fBhide\fP
-Do not display partitiion, job or jobs step information for partitions that are 
+Do not display partition, job or jobs step information for partitions that are 
 configured as hidden or partitions that are unavailable to the user's group. 
 This is the default behavior.
 
+.TP
+\fBnotify\fP \fIjob_id\fP \fImessage\fP
+Send a message to standard output of the srun command associated with the 
+specified \fIjob_id\fP.
+
 .TP
 \fBoneliner\fP
 Print information one line per record.
-This is an independent command with no options meant for use in interactive mode.
 
 .TP
-\fBpidinfo\fP \fIPROC_ID\fP
+\fBpidinfo\fP \fIproc_id\fP
 Print the Slurm job id and scheduled termination time corresponding to the 
-supplied process id, \fIPROC_ID\fP, on the current node.  This will work only
+supplied process id, \fIproc_id\fP, on the current node.  This will work only
 with processes on node on which scontrol is run, and only for those processes
 spawned by SLURM and their descendants.
 
 .TP
-\fBlistpids\fP [JOBID[.STEPID]] [NodeName]
+\fBlistpids\fP [\fIjob_id\fP[.\fIstep_id\fP]] [\fINodeName\fP]
 Print a listing of the process IDs in a job step (if JOBID.STEPID is provided),
-or all of the job steps in a job (if JOBID is provided), or all of the job
-steps in all of the jobs on the local node (if JOBID is not provided or JOBID
-is "*").  This will work only with processes on the node on which
-scontrol is run, and only for those processes spawned by SLURM and
+or all of the job steps in a job (if \fIjob_id\fP is provided), or all of the job
+steps in all of the jobs on the local node (if \fIjob_id\fP is not provided 
+or \fIjob_id\fP is "*").  This will work only with processes on the node on 
+which scontrol is run, and only for those processes spawned by SLURM and
 their descendants. Note that some SLURM configurations
 (\fIProctrackType\fP value of \fIpgid\fP or \fIaix\fP) 
 are unable to identify all processes associated with a job or job step.
@@ -145,12 +150,10 @@ they are responding.
 .TP
 \fBquiet\fP
 Print no warning or informational messages, only fatal error messages.
-This is an independent command with no options meant for use in interactive mode.
 
 .TP
 \fBquit\fP
 Terminate the execution of scontrol.
-This is an independent command with no options meant for use in interactive mode.
 
 .TP
 \fBreconfigure\fP
@@ -176,6 +179,18 @@ Resume a previously suspended job.
 \fBrequeue\fP \fIjob_id\fP
 Requeue a running or pending SLURM batch job.
 
+.TP
+\fBsetdebug\fP \fILEVEL\fP
+Change the debug level of the slurmctld daemon.
+\fILEVEL\fP may be an integer value between zero and nine (using the 
+same values as \fISlurmctldDebug\fP in the \fIslurm.conf\fP file) or 
+the name of the most detailed message type to be printed: 
+"quiet", "fatal", "error", "info", "verbose", "debug", "debug2", "debug3", 
+"debug4", or "debug5".
+This value is temporary and will be overwritten whenever the slurmctld 
+daemon reads the slurm.conf configuration file (e.g. when the daemon 
+is restarted or "scontrol reconfigure" is executed).
+
 .TP
 \fBshow\fP \fIENTITY\fP \fIID\fP
 Display the state of the specified entity with the specified identification.
@@ -235,7 +250,6 @@ the Slurm configuration file and executing the \fIreconfigure\fP command
 \fBverbose\fP
 Print detailed event logging. 
 This includes time\-stamps on data structures, record counts, etc.
-This is an independent command with no options meant for use in interactive mode.
 
 .TP
 \fBversion\fP
@@ -356,9 +370,17 @@ can be \fIminutes\fR, \fIhours\fR, \fIdays\fR, or \fIweeks\fR
 and you can tell SLURM to run the job today with the keyword
 \fItoday\fR and to run the job tomorrow with the keyword
 \fItomorrow\fR.
+
 .TP
-\fITimeLimit\fP=<minutes>
-Set the job's time limit to the specified value.
+\fITimeLimit\fP=<time>
+The job's time limit.
+Output format is [days\-]hours:minutes:seconds or "UNLIMITED".
+Input format (for \fBupdate\fR command) set is minutes, minutes:seconds, 
+hours:minutes:seconds, days\-hours, days\-hours:minutes or 
+days\-hours:minutes:seconds.
+Time resolution is one minute and second values are rounded up to 
+the next minute.
+
 .TP
 \fIConnection\fP=<type>
 Reset the node connection type.
@@ -391,18 +413,21 @@ or reconfiguration.
 Update slurm.conf with any changes meant to be persistent.
 .TP
 \fIReason\fP=<reason>
-Identify the reason the node is in a "DOWN" or "DRAINED" or "DRAINING" state.
+Identify the reason the node is in a "DOWN" or "DRAINED", "DRAINING", 
+"FAILING" or "FAIL" state.
 Use quotes to enclose a reason having more than one word.
 .TP
 \fIState\fP=<state>
 Identify the state to be assigned to the node. Possible values are  "NoResp", 
-"DRAIN" "RESUME", "DOWN", "IDLE", "ALLOC", and "ALLOCATED". 
+"ALLOC", "ALLOCATED", "DOWN", "DRAIN", "FAIL", "FAILING", "IDLE" or "RESUME". 
 "RESUME is not an actual node state, but will return a DRAINED, DRAINING, 
 or DOWN node to service, either IDLE or ALLOCATED state as appropriate.
 Setting a node "DOWN" will cause all running and suspended jobs on that
 node to be terminated.
 If you want to remove a node from service, you typically want to set 
 it's state to "DRAIN". 
+"FAILING" is similar to "DRAIN" except that some applications will  
+seek to relinquish those nodes before the job completes.
 The "NoResp" state will only set the "NoResp" flag for a node without
 changing its underlying state.
 
@@ -426,15 +451,23 @@ Possible values are"YES" and "NO".
 .TP
 \fIMaxNodes\fP=<count>
 Set the maximum number of nodes which will be allocated to any single job 
-in the partition. Specify a number, "INFINITE" or "UNLIMITED".
+in the partition. Specify a number, "INFINITE" or "UNLIMITED".  (On a
+Bluegene type system this represents a c-node count.)
+
 .TP
-\fIMaxTime\fP=<minutes>
-Set the maximum run time for a jobs in minutes. 
-Specify a number, "INFINITE" or "UNLIMITED".
+\fIMaxTime\fP=<time>
+The maximum run time for jobs.
+Output format is [days\-]hours:minutes:seconds or "UNLIMITED".
+Input format (for \fBupdate\fR command) is minutes, minutes:seconds, 
+hours:minutes:seconds, days\-hours, days\-hours:minutes or 
+days\-hours:minutes:seconds.
+Time resolution is one minute and second values are rounded up to 
+the next minute.
+
 .TP
 \fIMinNodes\fP=<count>
 Set the minimum number of nodes which will be allocated to any single job 
-in the partition. 
+in the partition.   (On a Bluegene type system this represents a c-node count.)
 .TP
 \fINodes\fP=<name>
 Identify the node(s) to be associated with this partition. Multiple node names 
@@ -501,17 +534,17 @@ scontrol: show part class
 .br 
 PartitionName=class TotalNodes=10 TotalCPUs=20 RootOnly=NO
 .br 
-   Default=NO Shared=NO State=UP MaxTime=30 Hidden=NO
+   Default=NO Shared=NO State=UP MaxTime=0:30:00 Hidden=NO
 .br
    MinNodes=1 MaxNodes=2 AllowGroups=students
 .br
    Nodes=lx[0031-0040] NodeIndices=31,40,-1
 .br 
-scontrol: update PartitionName=class MaxTime=99 MaxNodes=4
+scontrol: update PartitionName=class MaxTime=60:00 MaxNodes=4
 .br 
 scontrol: show job 65539
 .br 
-JobId=65539 UserId=1500 JobState=PENDING TimeLimit=100
+JobId=65539 UserId=1500 JobState=PENDING TimeLimit=0:20:00
 .br 
    Priority=100 Partition=batch Name=job01 NodeList=(null) 
 .br 
@@ -523,7 +556,7 @@ JobId=65539 UserId=1500 JobState=PENDING TimeLimit=100
 .br
    Features=(null) JobScript=/bin/hostname 
 .br 
-scontrol: update JobId=65539 TimeLimit=200 Priority=500
+scontrol: update JobId=65539 TimeLimit=30:00 Priority=500
 .br 
 scontrol: show hosts tux[1-3]
 .br
@@ -539,7 +572,7 @@ scontrol: quit
 .SH "COPYING"
 Copyright (C) 2002\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/sinfo.1 b/doc/man/man1/sinfo.1
index ae8e1c2eeec8f0e1e3964e5e629bb6b988223608..146b4dec28d25741d2df7a64dfbc948c74b30647 100644
--- a/doc/man/man1/sinfo.1
+++ b/doc/man/man1/sinfo.1
@@ -1,4 +1,4 @@
-.TH SINFO "1" "July 2007" "sinfo 1.2" "Slurm components"
+.TH SINFO "1" "July 2007" "sinfo 1.3" "Slurm components"
 
 .SH "NAME"
 sinfo \- view information about SLURM nodes and partitions.
@@ -166,7 +166,8 @@ Partition name
 Only user root may initiate jobs, "yes" or "no"
 .TP
 \fB%R\fR 
-The reason a node is unavailable (down, drained, or draining states)
+The reason a node is unavailable (down, drained, draining, 
+fail or failing states)
 .TP
 \fB%s\fR 
 Maximum job size in nodes
@@ -209,15 +210,17 @@ If set only report state information for responding nodes.
 
 .TP
 \fB\-R\fR, \fB\-\-list\-reasons\fR
-List reasons nodes are down or drained. When nodes are in
-these states SLURM supports optional inclusion of a "reason"
-string by an administrator. This option will display the first
-35 characters of the reason field and list of nodes with that
-reason for all nodes that are, by default, down, drained, or
-draining. This option may be used with other node filtering
-options (e.g. \fB\-r\fR, \fB\-d\fR, \fB\-t\fR, \fB\-n\fR),
-however, combinations of these options that result in a list of
-nodes that are not down or drained will not produce any output.
+List reasons nodes are in the down, drained, fail or failing state. 
+When nodes are in these states SLURM supports optional inclusion 
+of a "reason" string by an administrator. 
+This option will display the first 35 characters of the reason 
+field and list of nodes with that reason for all nodes that are, 
+by default, down, drained, draining or failing. 
+This option may be used with other node filtering options 
+(e.g. \fB\-r\fR, \fB\-d\fR, \fB\-t\fR, \fB\-n\fR),
+however, combinations of these options that result in a 
+list of nodes that are not down or drained or failing will 
+not produce any output.
 When used with \fB\-l\fR the output additionally includes
 the current node state.
 
@@ -248,11 +251,12 @@ default sort value is "N" (increasing node name).
 List nodes only having the given state(s).  Multiple states
 may be comma separated and the comparison is case insensitive.
 Possible values include (case insensitive): ALLOC, ALLOCATED,
-COMP, COMPLETING, DOWN, DRAIN, DRAINED, DRNG, DRAINING, IDLE, 
-UNK, and UNKNOWN.  By default nodes in the specified state are
-reported whether they are responding or not.  The \fB\-\-dead\fR 
-and \fB\-\-responding\fR options may be used to filtering nodes by 
-the responding flag.
+COMP, COMPLETING, DOWN, DRAIN, DRAINED, DRNG, DRAINING, FAIL, 
+FAILING, IDLE, UNK, and UNKNOWN.  
+By default nodes in the specified state are reported whether 
+they are responding or not.  
+The \fB\-\-dead\fR and \fB\-\-responding\fR options may be 
+used to filtering nodes by the responding flag.
 
 .TP
 \fB\-\-usage\fR
@@ -339,11 +343,13 @@ with shared/cons_res managing individual processors).
 per job's resource allocation.
 .TP
 \fBSTATE\fR
-State of the nodes. Possible states include: down, unknown,
-idle, allocated, drained, draining, completing and their
-abbreviated forms: down, unk, idle, alloc, drain, drng, and
-comp respectively.  Note that the suffix "*" identifies nodes
-that are presently not responding.
+State of the nodes. 
+Possible states include: allocated, completing, down, 
+drained, draining, fail, failing, idle, and unknown plus
+their abbreviated forms: alloc, comp, donw, drain, drng, 
+fail, failg, idle, and unk respectively.
+Note that the suffix "*" identifies nodes that are presently 
+not responding.
 .TP
 \fBTMP_DISK\fR
 Size of temporary disk space in megabytes on these nodes.
@@ -355,7 +361,8 @@ If the node state code is followed by "*", this indicates the
 node is presently not responding and will not be allocated
 any new work.  If the node remains non\-responsive, it will
 be placed in the \fBDOWN\fR state (except in the case of
-\fBDRAINED\fR, \fBDRAINING\fR, or \fBCOMPLETING\fR nodes).
+\fBCOMPLETING\fR, \fBDRAINED\fR, \fBDRAINING\fR,
+\fBFAIL\fR, \fBFAILING\fR nodes).
 If the node state code is followed by "~", this indicates
 the node is presently in a power saving mode (typically
 running at reduced frequency).
@@ -398,6 +405,18 @@ this state per system administrator request. See the \fBupdate
 node\fR command in the \fBscontrol\fR(1) man page or the
 \fBslurm.conf\fR(5) man page for more information.
 .TP
+\fBFAIL\fR
+The node is expected to fail soon and is unavailable for 
+use per system administrator request.  
+See the \fBupdate node\fR command in the \fBscontrol\fR(1) 
+man page or the \fBslurm.conf\fR(5) man page for more information.
+.TP
+\fBFAILING\fR
+The node is currently executing a job, but is expected to fail 
+soon and is unavailable for use per system administrator request.  
+See the \fBupdate node\fR command in the \fBscontrol\fR(1) 
+man page or the \fBslurm.conf\fR(5) man page for more information.
+.TP
 \fBIDLE\fR
 The node is not allocated to any jobs and is available for use.
 .TP
@@ -495,7 +514,7 @@ Not Responding                      dev8
 .SH "COPYING"
 Copyright (C) 2002\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/slaunch.1 b/doc/man/man1/slaunch.1
deleted file mode 100644
index d227eec4a348bb48548afe384bddfe4794a06bc4..0000000000000000000000000000000000000000
--- a/doc/man/man1/slaunch.1
+++ /dev/null
@@ -1,734 +0,0 @@
-.\" $Id: slaunch.1 13559 2008-03-11 22:41:30Z jette $
-.TH "slaunch" "1" "SLURM 1.2" "October 2006" "SLURM Commands"
-.SH "NAME"
-.LP 
-slaunch \- Launch a parallel application under a SLURM job allocation.
-.SH "SYNOPSIS"
-.LP 
-slaunch [\fIoptions\fP] <\fIcommand\fP> [\fIcommand args\fR]
-.SH "DESCRIPTION"
-.LP 
-\fBNOTE: Support of slaunch is expected to be discontinued in the near future.
-Use of slaunch is not recommended.\fR
-.br
-
-.br
-slaunch launches a parallel application (a \fBjob step\fR in SLURM parlance)
-on the nodes, or subset of nodes, in a \fBjob allocation\fR.   A valid job
-allocation is a prerequisite of running slaunch.  The ID of the job allocation
-may be passed to slaunch through either the \fB\-\-jobid\fR command line
-parameter or the \fBSLAUNCH_JOBID\fR environment variable.  The \fBsalloc\fR
-and \fBsbatch\fR commands may be used to request a job allocation, and each
-of those commands automatically set the \fBSLURM_JOB_ID\fR environment variable,
-which is also understood by slaunch.  Users should not set SLURM_JOB_ID on their
-own; use SLAUNCH_JOBID instead.
-
-.SH "OPTIONS"
-.LP 
-
-.TP
-\fB\-C\fR, \fB\-\-overcommit\fR
-Permit the allocation of more tasks to a node than there are available processors.
-Normally SLURM will only allow up to N tasks on a node with N processors, but
-this option will allow more than N tasks to be assigned to a node.
-
-.TP 
-\fB\-c\fR, \fB\-\-cpus\-per\-task\fR[=]<\fIncpus\fR>
-Specify that each task requires \fIncpus\fR number of CPUs.  Useful for applications in which each task will launch multiple threads and can therefore benefit from there being free processors on the node.
-
-.TP
-\fB\-\-comm\-hostname\fR[=]<\fIhostname|address\fR>
-Specify the hostname or address to be used for PMI communications only
-(MPCIH2 communication bootstrapping mechanism).
-Defaults to short hostname of the node on which slaunch is running.
-
-.TP
-\fB\-\-core\fR[=]<\fItype\fR>
-Adjust corefile format for parallel job. If possible, slaunch will set
-up the environment for the job such that a corefile format other than
-full core dumps is enabled. If run with type = "list", slaunch will
-print a list of supported corefile format types to stdout and exit.
-
-.TP
-\fB\-\-cpu_bind\fR=[{\fIquiet,verbose\fR},]\fItype\fR
-Bind tasks to CPUs. Used only when the task/affinity or task/numa 
-plugin is enabled. 
-NOTE: To have SLURM always report on the selected CPU binding for all 
-commands executed in a shell, you can enable verbose mode by setting 
-the SLURM_CPU_BIND environment variable value to "verbose". 
-Supported options include:
-.PD 1
-.RS
-.TP
-.B q[uiet],
-quietly bind before task runs (default)
-.TP
-.B v[erbose],
-verbosely report binding before task runs
-.TP
-.B no[ne]
-don't bind tasks to CPUs (default)
-.TP
-.B rank
-bind by task rank
-.TP
-.B map_cpu:<list>
-bind by mapping CPU IDs to tasks as specified
-where <list> is <cpuid1>,<cpuid2>,...<cpuidN>.
-CPU IDs are interpreted as decimal values unless they are preceded
-with '0x' in which case they interpreted as hexadecimal values.
-.TP
-.B mask_cpu:<list>
-bind by setting CPU masks on tasks as specified
-where <list> is <mask1>,<mask2>,...<maskN>.
-CPU masks are \fBalways\fR interpreted as hexadecimal values but can be
-preceded with an optional '0x'.
-.RE
-
-.TP 
-\fB\-D\fR, \fB\-\-workdir\fR[=]<\fIdirectory\fR>
-Set the working directory of the tasks to \fIdirectory\fR before execution.
-The default task working directory is slaunch's working directory.
-
-.TP
-\fB\-d\fR, \fB\-\-slurmd\-debug\fR[=]<\fIlevel\fR>
-Specify a debug level for slurmd(8). \fIlevel\fR may be an integer value
-between 0 [quiet, only errors are displayed] and 4 [verbose operation]. 
-The slurmd debug information is copied onto the stderr of
-the job.  By default only errors are displayed. 
-
-.TP
-\fB\-E\fR, \fB\-\-task\-error\fR[=]<\fIfilename pattern\fR>
-Instruct SLURM to connect each task's standard error directly to 
-the file name specified in the "\fIfilename pattern\fR".
-See the \fB\-\-task\-input\fR option for filename specification options.
-
-.TP 
-\fB\-e\fR, \fB\-\-slaunch\-error\fR[=]<\fIfilename pattern\fR>
-Instruct SLURM to connect slaunch's standard error directly to the 
-file name specified in the "\fIfilename pattern\fR".
-See the \fB\-\-slaunch\-input\fR option for filename specification options.
-
-.TP
-\fB\-\-epilog\fR[=]<\fIexecutable\fR>
-\fBslaunch\fR will run \fIexecutable\fR just after the job step completes.
-The command line arguments for \fIexecutable\fR will be the command
-and arguments of the job step.  If \fIexecutable\fR is "none", then
-no epilog will be run.  This parameter overrides the SrunEpilog
-parameter in slurm.conf.
-
-.TP 
-\fB\-F\fR, \fB\-\-task\-layout\-file\fR[=]<\fIfilename\fR>
-Request a specific task layout.  This option is much like the
-\-\-task\-layout\-byname option, except that instead of a nodelist you
-supply the name of a file.  The file contains a nodelist that may span
-multiple lines of the file.
-
-NOTE: This option implicitly sets the task distribution method to "arbitrary".
-Some network switch layers do not permit arbitrary task layout.
-
-.TP
-\fB\-\-gid\fR[=]<\fIgroup\fR>
-If \fBslaunch\fR is run as root, and the \fB\-\-gid\fR option is used, 
-submit the job with \fIgroup\fR's group access permissions.  \fIgroup\fR 
-may be the group name or the numerical group ID.
-
-.TP 
-\fB\-h\fR, \fB\-\-help\fR
-Display help information and exit.
-
-.TP
-\fB\-I\fR, \fB\-\-task\-input\fR[=]<\fIfilename pattern\fR>
-Instruct SLURM to connect each task's standard input directly to 
-the file name specified in the "\fIfilename pattern\fR".
-
-By default, the standard IO streams of all tasks are received and transmitted
-over the network to commands like slaunch and sattach.  These options disable
-the networked standard IO streams and instead connect the standard IO streams
-of the tasks directly to files on the local node of each task (although the file
-may, of course, be located on a networked filesystem).
-
-Whether or not the tasks share a file depends on whether or not the file lives
-on a local filesystem or a shared network filesytem, and on whether or not
-the filename pattern expands to the same file name for each task.
-
-The filename pattern may
-contain one or more replacement symbols, which are a percent sign "%" followed 
-by a letter (e.g. %t).
-
-Supported replacement symbols are:
-.PD 0
-.RS 10
-.TP 
-\fB%J\fR
-Job allocation number and job step number in the form "jobid.stepid".  For instance, "128.0".
-.PD 0
-.TP 
-\fB%j\fR
-Job allocation number.
-.PD 0
-.TP 
-\fB%s\fR
-Job step number.
-.PD 0
-.TP 
-\fB%N\fR
-Node name. (Will result in a separate file per node.)
-.PD 0
-.TP 
-\fB%n\fR
-Relative node index number within the job step.  All nodes used by the job step will be number sequentially starting at zero.  (Will result in a separate file per node.)
-.PD 0
-.TP 
-\fB%t\fR
-Task rank number.  (Will result in a separate file per task.)
-.RE
-
-.TP 
-\fB\-i\fR, \fB\-\-slaunch\-input\fR[=]<\fIfilename pattern\fR>
-.PD
-Change slaunch's standard input
-to be a file of name "filename pattern".  These options are similar to using
-shell IO redirection capabilities, but with the additional ability to replace
-certain symbols in the filename with useful SLURM information.  Symbols are
-listed below.
-
-By default, slaunch broadcasts its standard input over the network to the
-standard input of all tasks.  Likewise, standard output and standard error
-from all tasks are collected over the network by slaunch and printed on
-its standard output or standard error, respectively.  If you want to see
-traffic from fewer tasks, see the \-\-slaunch\-[input|output|error]\-filter
-options.
-
-Supported replacement symbols are:
-.PD 0
-.RS 10
-.TP 
-\fB%J\fR
-Job allocation number and job step number in the form "jobid.stepid".  For instance, "128.0".
-.PD 0
-.TP 
-\fB%j\fR
-Job allocation number.
-.PD 0
-.TP 
-\fB%s\fR
-Job step number.
-.RE
-
-.TP
-\fB\-J\fR, \fB\-\-name\fR[=]<\fIname\fR>
-Set the name of the job step.  By default, the job step's name will be the
-name of the executable which slaunch is launching.
-
-.TP 
-\fB\-\-jobid\fR=<\fIJOBID\fP>
-The job allocation under which the parallel application should be launched.  If slaunch is running under salloc or a batch script, slaunch can automatically determint the jobid from the SLURM_JOB_ID environment variable.  Otherwise, you will need to tell slaunch which job allocation to use.
-
-.TP
-\fB\-K\fR, \fB\-\-kill\-on\-bad\-exit\fR
-Terminate the job step if any task exits with a non\-zero exit code.  By default
-slaunch will not terminate a job step because of a task with a non\-zero exit
-code.
-
-.TP 
-\fB\-L\fR, \fB\-\-nodelist\-byid\fR[=]<\fInode index list\fR>
-Request a specific set of nodes in a job alloction on which to run the tasks of the job step.  The list may be specified as a comma\-separated list relative node indices in the job allocation (e.g., "0,2\-5,\-2,8").  Duplicate indices are permitted, but are ignored.  The order of the node indices in the list is not important; the node indices will be sorted my SLURM.
-
-.TP
-\fB\-l\fR, \fB\-\-label\fR
-Prepend each line of task standard output or standard error with the task
-number of its origin.
-
-.TP
-\fB\-m\fR, \fB\-\-distribution\fR=
-(\fIblock\fR|\fIcyclic\fR|\fIhostfile\fR|\fIplane=<options>\fR)
-Specify an alternate distribution method for remote processes.
-.PD 1
-.RS
-.TP
-.B block
-The block method of distribution will allocate processes in\-order to
-the cpus on a node. If the number of processes exceeds the number of
-cpus on all of the nodes in the allocation then all nodes will be
-utilized. For example, consider an allocation of three nodes each with
-two cpus. A four\-process block distribution request will distribute
-those processes to the nodes with processes one and two on the first
-node, process three on the second node, and process four on the third node.
-Block distribution is the default behavior if the number of tasks
-exceeds the number of nodes requested.
-.TP
-.B cyclic
-The cyclic method distributes processes in a round\-robin fashion across
-the allocated nodes. That is, process one will be allocated to the first
-node, process two to the second, and so on. This is the default behavior
-if the number of tasks is no larger than the number of nodes requested.
-.TP
-.B plane
-The tasks are distributed in blocks of a specified size.
-The options include a number representing the size of the task block.
-This is followed by an optional specification of the task distribution
-scheme within a block of tasks and between the blocks of tasks.
-For more details (including examples and diagrams), please see
-.br
-https://computing.llnl.gov/linux/slurm/mc_support.html
-.br
-and
-.br
-https://computing.llnl.gov/linux/slurm/dist_plane.html.
-.TP
-.B hostfile
-The hostfile method of distribution will allocate processes in\-order as
-listed in file designated by the environment variable SLURM_HOSTFILE.  If
-this variable is listed it will over ride any other method specified.
-.RE
-
-.TP
-\fB\-\-mem_bind\fR=[{\fIquiet,verbose\fR},]\fItype\fR
-Bind tasks to memory. 
-Used only when task/affinity plugin is enabled and 
-the NUMA memory functions are available
-\fBNote that the resolution of CPU and memory binding 
-may differ on some architectures.\fR For example, CPU binding may be performed 
-at the level of the cores within a processor while memory binding will 
-be performed at the level of nodes, where the definition of "nodes" 
-may differ from system to system. \fBThe use of any type other than 
-"none" or "local" is not recommended.\fR
-If you want greater control, try running a simple test code with the 
-options "\-\-cpu_bind=verbose,none \-\-mem_bind=verbose,none" to determine 
-the specific configuration.
-Note: To have SLURM always report on the selected memory binding for all 
-commands executed in a shell, you can enable verbose mode by setting the 
-SLURM_MEM_BIND environment variable value to "verbose".
-Supported options include:
-.PD 1
-.RS
-.TP
-.B q[uiet],
-quietly bind before task runs (default)
-.TP
-.B v[erbose],
-verbosely report binding before task runs
-.TP
-.B no[ne]
-don't bind tasks to memory (default)
-.TP
-.B rank
-bind by task rank (not recommended)
-.TP
-.B local
-Use memory local to the processor in use
-.TP
-.B map_mem:<list>
-bind by mapping a node's memory to tasks as specified
-where <list> is <cpuid1>,<cpuid2>,...<cpuidN>.
-CPU IDs are interpreted as decimal values unless they are preceded
-with '0x' in which case they interpreted as hexadecimal values
-(not recommended)
-.TP
-.B mask_mem:<list>
-bind by setting memory masks on tasks as specified
-where <list> is <mask1>,<mask2>,...<maskN>.
-memory masks are \fBalways\fR interpreted as hexadecimal values but can be
-preceded with an optional '0x' (not recommended)
-.RE
-
-.TP 
-\fB\-\-mpi\fR[=]<\fImpi_type\fR>
-Identify the type of MPI to be used. If run with mpi_type = "list", 
-slaunch will print a list of supported MPI types to stdout and exit.
-
-.TP
-\fB\-\-multi\-prog\fR
-This option allows one to launch tasks with different executables within
-the same job step.  When this option is present, slaunch no long accepts
-the name of an executable "command" on the command line, instead it accepts
-the name of a file.  This file specifies which executables and command line
-parameters should be used by each task in the job step.  See the section 
-\fBMULTIPLE PROGRAMS FILE\fR below for an explanation of the multiple program
-file syntax.
-
-.TP 
-\fB\-N\fR, \fB\-\-nodes\fR[=]<\fInumber\fR>
-Specify the number of nodes to be used by this job step.  By default,
-slaunch will use all of the nodes in the specified job allocation.
-
-.TP 
-\fB\-n\fR, \fB\-\-tasks\fR[=]<\fInumber\fR>
-Specify the number of processes to launch.  The default is one process per node.
-
-.TP
-\fB\-\-network\fR[=]<\fIoptions\fR>
-(NOTE: this option is currently only of use on AIX systems.)
-Specify the communication protocol to be used. 
-The interpretation of \fItype\fR is system dependent. 
-For AIX systems with an IBM Federation switch, the following 
-comma\-separated and case insensitive options are recongnized:
-\fBIP\fR (the default is user\-space), \fBSN_ALL\fR, \fBSN_SINGLE\fR, 
-\fBBULK_XFER\fR and adapter names. For more information, on 
-IBM systems see \fIpoe\fR documenation on the environment variables 
-\fBMP_EUIDEVICE\fR and \fBMP_USE_BULK_XFER\fR.
-
-.TP
-\fB\-O\fR, \fB\-\-task\-output\fR[=]<\fIfilename pattern\fR>
-Instruct SLURM to connect each task's standard output directly to 
-the file name specified in the "\fIfilename pattern\fR".
-See the \fB\-\-task\-input\fR option for filename specification options.
-
-.TP
-\fB\-o\fR, \fB\-\-slaunch\-output\fR[=]<\fIfilename pattern\fR>
-Instruct SLURM to connect slaunch's standard output directly to the 
-file name specified in the "\fIfilename pattern\fR".
-See the \fB\-\-slaunch\-input\fR option for filename specification options.
-
-.TP
-\fB\-\-propagate\fR[=\fIrlimits\fR]
-Allows users to specify which of the modifiable (soft) resource limits
-to propagate to the compute nodes and apply to their jobs.  If
-\fIrlimits\fR is not specified, then all resource limits will be
-propagated.
-The following rlimit names are supported by Slurm (although some
-options may not be supported on some systems):
-.RS
-.TP 10
-\fBAS\fR
-The maximum address space for a processes
-.TP
-\fBCORE\fR
-The maximum size of core file
-.TP
-\fBCPU\fR
-The maximum amount of CPU time
-.TP
-\fBDATA\fR
-The maximum size of a process's data segment
-.TP
-\fBFSIZE\fR
-The maximum size of files created
-.TP
-\fBMEMLOCK\fR
-The maximum size that may be locked into memory
-.TP
-\fBNOFILE\fR
-The maximum number of open files
-.TP
-\fBNPROC\fR
-The maximum number of processes available
-.TP
-\fBRSS\fR
-The maximum resident set size
-.TP
-\fBSTACK\fR
-The maximum stack size
-.RE
-
-.TP
-\fB\-\-prolog\fR[=]<\fIexecutable\fR>
-\fBslaunch\fR will run \fIexecutable\fR just before launching the job step.
-The command line arguments for \fIexecutable\fR will be the command
-and arguments of the job step.  If \fIexecutable\fR is "none", then
-no prolog will be run.  This parameter overrides the SrunProlog
-parameter in slurm.conf.
-
-.TP
-\fB\-q\fR, \fB\-\-quiet\fR
-Suppress informational messages from slaunch. Errors will still be displayed.
-
-.TP 
-\fB\-r\fR, \fB\-\-relative\fR[=]<\fInumber\fR>
-Specify the first node in the allocation on which this job step will be launched.  Counting starts at zero, thus the first node in the job allocation is node 0.  The option to \-\-relative may also be a negative number.  \-1 is the last node in the allocation, \-2 is the next to last node, etc.  By default, the controller will select the starting node (assuming that there are no other nodelist or task layout options that specify specific nodes).
-
-.TP 
-\fB\-\-slaunch\-input\-filter\fR[=]<\fItask number\fR>
-.PD 0
-.TP
-\fB\-\-slaunch\-output\-filter\fR[=]<\fItask number\fR>
-.PD 0
-.TP 
-\fB\-\-slaunch\-error\-filter\fR[=]<\fItask number\fR>
-.PD
-Only transmit standard input to a single task, or print the standard output
-or standard error from a single task.  These options perform the filtering
-locally in slaunch.  All tasks are still capable of sending or receiving
-standard IO over the network, so the "sattach" command can still access the
-standard IO streams of the other tasks.  (NOTE: for \-output and \-error,
-the streams from all tasks WILL be transmitted to slaunch, but it will only
-print the streams for the selected task.  If your tasks print a great deal of
-data to standard output or error, this can be performance limiting.)
-
-.TP 
-\fB\-T\fR, \fB\-\-task\-layout\-byid\fR[=]<\fInode index list\fR>
-Request a specific task layout using node indices within the job allocation.  The node index list can contain duplicate indices, and the indices may appear in any order.  The order of indices in the nodelist IS significant.  Each node index in the list represents one task, with the Nth node index in the list designating on which node the Nth task should be launched.
-
-For example, given an allocation of nodes "linux[0\-15]" and a node index list "4,\-1,1\-3" task 0 will run on "linux4", task 1 will run on "linux15", task 2 on "linux1", task 3 on "linux2", and task 4 on "linux3".
-
-NOTE: This option implicitly sets the task distribution method to "arbitrary".  Some network switch layers do not permit arbitrary task layout.
-
-.TP
-\fB\-\-task\-epilog\fR[=]<\fIexecutable\fR>
-The \fBslurmd\fR daemon will run \fIexecutable\fR just after each task
-terminates. This will be before after any TaskEpilog parameter      
-in slurm.conf is executed. This is meant to be a very short\-lived 
-program. If it fails to terminate within a few seconds, it will 
-be killed along with any descendant processes.
-
-.TP
-\fB\-\-task\-prolog\fR[=]<\fIexecutable\fR>
-The \fBslurmd\fR daemon will run \fIexecutable\fR just before launching 
-each task. This will be executed after any TaskProlog parameter 
-in slurm.conf is executed.
-Besides the normal environment variables, this has SLURM_TASK_PID
-available to identify the process ID of the task being started.
-Standard output from this program of the form
-"export NAME=value" will be used to set environment variables
-for the task being spawned.
-
-.TP
-\fB\-u\fR, \fB\-\-unbuffered\fR
-Do not line buffer standard output or standard error from remote tasks.
-This option cannot be used with \-\-label.
-
-.TP
-\fB\-\-uid\fR[=]<\fIuser\fR>
-Attempt to submit and/or run a job as \fIuser\fR instead of the
-invoking user id. The invoking user's credentials will be used
-to check access permissions for the target partition. User root
-may use this option to run jobs as a normal user in a RootOnly
-partition for example. If run as root, \fBslaunch\fR will drop
-its permissions to the uid specified after node allocation is
-successful. \fIuser\fR may be the user name or numerical user ID.
-
-.TP
-\fB\-\-usage\fR
-Display brief usage message and exit.
-
-.TP 
-\fB\-V\fR, \fB\-\-version\fR
-Display version information and exit.
-
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Increase the verbosity of slaunch's informational messages.  Multiple \-v's
-will further increase slaunch's verbosity.
-
-.TP
-\fB\-W\fR, \fB\-\-wait\fR[=]<\fIseconds\fR>
-slaunch will wait the specified number of seconds after the first tasks exits
-before killing all tasks in the job step.  If the value is 0, slaunch will
-wait indefinitely for all tasks to exit.  The default value is give by the
-WaitTime parameter in the slurm configuration file (see \fBslurm.conf(5)\fR).
-
-The \-\-wait option can be used to insure that a job step terminates in a timely
-fashion in the event that one or more tasks terminate prematurely.
-
-.TP 
-\fB\-w\fR, \fB\-\-nodelist\-byname\fR[=]<\fInode name list\fR>
-Request a specific list of node names.  The list may be specified as a comma\-separated list of node names, or a range of node names (e.g. mynode[1\-5,7,...]).  Duplicate node names are not permitted in the list.
-The order of the node names in the list is not important; the node names
-will be sorted my SLURM.
-
-.TP 
-\fB\-Y\fR, \fB\-\-task\-layout\-byname\fR[=]<\fInode name list\fR>
-Request a specific task layout.  The nodelist can contain duplicate node
-names, and node names may appear in any order.  The order of node names in
-the nodelist IS significant.  Each node name in the nodes list represents
-one task, with the Nth node name in the nodelist designating on which node
-the Nth task should be launched.  For example, a nodelist of mynode[4,3,1\-2,4]
-means that tasks 0 and 4 will run on mynode4, task 1 will run on mynode3,
-task 2 will run on mynode1, and task 3 will run on mynode2.
-
-NOTE: This option implicitly sets the task distribution method to "arbitrary".
-Some network switch layers do not permit arbitrary task layout.
- 
-.SH "INPUT ENVIRONMENT VARIABLES"
-.PP
-Some slaunch options may be set via environment variables. 
-These environment variables, along with their corresponding options, 
-are listed below.
-Note: Command line options will always override environment variables settings.
-.TP 25
-\fBSLAUNCH_COMM_HOSTNAME\fR
-Same as \fB\-\-comm\-hostname\fR.
-.TP
-\fBSLAUNCH_CORE_FORMAT\fR
-Same as \fB\-\-core\fR.
-.TP
-\fBSLAUNCH_CPU_BIND\fR
-Same as \fB\-\-cpu_bind\fR.
-.TP
-\fBSLAUNCH_DEBUG\fR
-Same as \fB\-v\fR or \fB\-\-verbose\fR.
-.TP
-\fBSLAUNCH_DISTRIBUTION\fR
-Same as \fB\-m\fR or \fB\-\-distribution\fR.
-.TP
-\fBSLAUNCH_EPILOG\fR
-Same as \fB\-\-epilog\fR=\fIexecutable\fR.
-.TP
-\fBSLAUNCH_JOBID\fR
-Same as \fB\-\-jobid\fR.
-.TP
-\fBSLAUNCH_KILL_BAD_EXIT\fR
-Same as \fB\-K\fR or \fB\-\-kill\-on\-bad\-exit\fR.
-.TP
-\fBSLAUNCH_LABELIO\fR
-Same as \fB\-l\fR or \fB\-\-label\fR.
-.TP
-\fBSLAUNCH_MEM_BIND\fR
-Same as \fB\-\-mem_bind\fR.
-.TP
-\fBSLAUNCH_MPI_TYPE\fR
-Same as \fB\-\-mpi\fR.
-.TP
-\fBSLAUNCH_OVERCOMMIT\fR
-Same as \fB\-C\fR or \fB\-\-overcomit\fR.
-.TP
-\fBSLAUNCH_PROLOG\fR
-Same as \fB\-\-prolog\fR=\fIexecutable\fR.
-.TP
-\fBSLAUNCH_TASK_EPILOG\fR
-Same as \fB\-\-task\-epilog\fR=\fIexecutable\fR.
-.TP
-\fBSLAUNCH_TASK_PROLOG\fR
-Same as \fB\-\-task\-prolog\fR=\fIexecutable\fR.
-.TP
-\fBSLAUNCH_WAIT\fR
-Same as \fB\-W\fR or \fB\-\-wait\fR.
-.TP
-\fBSLURMD_DEBUG\fR
-Same as \fB\-d\fR or \fB\-\-slurmd\-debug\fR
-
-.SH "OUTPUT ENVIRONMENT VARIABLES"
-.PP
-slaunch will set the following environment variables which will
-appear in the environments of all tasks in the job step.  Since slaunch
-sets these variables itself, they will also be available to \-\-prolog
-and \-\-epilog scripts.  (Notice that the "backwards compatibility" environment
-variables clobber some of the variables that were set by salloc or sbatch
-at job allocation time.  The newer SLURM_JOB_* and SLURM_STEP_* names do not
-conflict, so any task in any job step can easily determine the parameters
-of the job allocation.)
-.TP
-\fBSLURM_STEP_ID\fR (and \fBSLURM_STEPID\fR for backwards compatibility)
-The ID of the job step within the job allocation.
-.TP
-\fBSLURM_STEP_NODELIST\fR
-The list of nodes in the job step.
-.TP
-\fBSLURM_STEP_NUM_NODES\fR (and \fBSLURM_NNODES\fR for backwards compatibility)
-The number of nodes used by the job step.
-.TP
-\fBSLURM_STEP_NUM_TASKS\fR (and \fBSLURM_NPROCS\fR for backwards compatibility)
-The number of tasks in the job step.
-.TP
-\fBSLURM_STEP_TASKS_PER_NODE\fR (and \fBSLURM_TASKS_PER_NODE\fR for backwards compatibility)
-The number of tasks on each node in the job step.
-.TP
-\fBSLURM_STEP_LAUNCHER_HOSTNAME\fR (and \fBSLURM_SRUN_COMM_HOST\fR for backwards compatibility)
-.TP
-\fBSLURM_STEP_LAUNCHER_PORT\fR (and \fBSLURM_SRUN_COMM_PORT\fR for backwards compatibility)
-
-.PP
-Additionally, SLURM daemons will ensure that the the following variables are
-set in the environments of all tasks in the job step.  Many of the following
-variables will have different values in each task's environment.  (These
-variables are not available to the slaunch \-\-prolog and \-\-epilog scripts.)
-
-.TP
-\fBSLURM_NODEID\fR
-Node ID relative to other nodes in the job step.  Counting begins at zero.
-.TP
-\fBSLURM_PROCID\fR
-Task ID relative to the other tasks in the job step.  Counting begins at zero.
-.TP
-\fBSLURM_LOCALID\fR
-Task ID relative to the other tasks on the same node which belong to the
-same job step.  Counting begins at zero.
-.TP
-\fBSLURMD_NODENAME\fR
-The SLURM NodeName for the node on which the task is running.  Depending
-on how your system administrator has configured SLURM, the NodeName for a
-node may not be the same as the node's hostname.  When you use commands
-such as \fBsinfo\fR and \fBsqueue\fR, or look at environment variables such
-as SLURM_JOB_NODELIST and SLURM_STEP_NODELIST, you are seeing SLURM NodeNames.
-
-.SH "MULTIPLE PROGRAMS FILE"
-Comments in the configuration file must have a "#" in collumn one.
-The configuration file contains the following fields separated by white
-space:
-.TP
-Task rank
-One or more task ranks to use this configuration.
-Multiple values may be comma separated.
-Ranges may be indicated with two numbers separated with a '\-'.
-To indicate all tasks, specify a rank of '*' (in which case you probably 
-should not be using this option).
-.TP
-Executable
-The name of the program to execute.
-May be fully qualified pathname if desired.
-.TP
-Arguments
-Program arguments.
-The expression "%t" will be replaced with the task's number.
-The expression "%o" will be replaced with the task's offset within
-this range (e.g. a configured task rank value of "1\-5" would
-have offset values of "0\-4").
-Single quotes may be used to avoid having the enclosed values interpretted.
-This field is optional.
-.PP
-For example:
-.nf
-###################################################################
-# srun multiple program configuration file
-#
-# srun \-n8 \-l \-\-multi\-prog silly.conf
-###################################################################
-4\-6       hostname
-1,7       echo  task:%t
-0,2\-3     echo  offset:%o
-
-$ srun \-n8 \-l \-\-multi\-prog silly.conf
-0: offset:0
-1: task:1
-2: offset:1
-3: offset:2
-4: linux15.llnl.gov
-5: linux16.llnl.gov
-6: linux17.llnl.gov
-7: task:7
-
-.fi
-
-.SH "EXAMPLES"
-.LP 
-To launch a job step (parallel program) in an existing job allocation:
-.IP 
-slaunch \-\-jobid 66777 \-N2 \-n8 myprogram
-
-.LP 
-To grab an allocation of nodes and launch a parallel application on one command line (See the \fBsalloc\fR man page for more examples):
-.IP 
-salloc \-N5 slaunch \-n10 myprogram
-
-.SH "COPYING"
-Copyright (C) 2006\-2007 The Regents of the University of California.
-Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
-.LP
-This file is part of SLURM, a resource management program.
-For details, see <https://computing.llnl.gov/linux/slurm/>.
-.LP
-SLURM is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your option)
-any later version.
-.LP
-SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-details.
-
-.SH "SEE ALSO"
-.LP 
-sinfo(1), sattach(1), salloc(1), sbatch(1), squeue(1), scancel(1), scontrol(1), slurm.conf(5), sched_setaffinity(2), numa(3)
diff --git a/doc/man/man1/slurm.1 b/doc/man/man1/slurm.1
index 096f029a75810a132db90af3cb0a75f275638310..3e4626bf6c80f96046a1331e9a328692a8b84f40 100644
--- a/doc/man/man1/slurm.1
+++ b/doc/man/man1/slurm.1
@@ -37,7 +37,7 @@ Extensive documenation is also available on the internet at
 .SH "COPYING"
 Copyright (C) 2005\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
@@ -55,7 +55,7 @@ details.
 .SH "SEE ALSO"
 \fBsacct\fR(1), \fBsalloc\fR(1), \fBsattach\fR(1), \fBsbatch\fR(1), 
 \fBsbcast\fR(1), \fBscancel\fR(1), \fBscontrol\fR(1), \fBsinfo\fR(1), 
-\fBslaunch\fR(1), \fBsmap\fR(1), \fBsqueue\fR(1), \fBsrun\fR(1),
+\fBsmap\fR(1), \fBsqueue\fR(1), \fBsrun\fR(1),
 \fBsview\fR(1), 
 \fBbluegene.conf\fR(5), \fBslurm.conf\fR(5), \fBwiki.conf\fR(5),
 \fBslurmctld\fR(8), \fBslurmd\fR(8), \fBslurmstepd\fR(8), \fBspank\fR(8)
diff --git a/doc/man/man1/smap.1 b/doc/man/man1/smap.1
index a077063eaf2bcf388015470993fd93d17825c901..3319ce082ee12e11b99b1756038d615eb9d6cf12 100644
--- a/doc/man/man1/smap.1
+++ b/doc/man/man1/smap.1
@@ -1,4 +1,4 @@
-.TH SMAP "1" "March 2006" "smap 1.1" "Slurm components"
+.TH SMAP "1" "May 2007" "smap 1.3" "Slurm components"
 
 .SH "NAME"
 smap \- graphically view information about SLURM jobs, partitions, and set 
@@ -26,8 +26,8 @@ views and displaying a corresponding node chart. While in any
 display a user can switch by typing a different view letter.  This is true in
 all modes except for 'configure mode' user can type 'quit' to exit just 
 configure mode.  Typing 'exit' will end the configuration mode and exit smap.
-Note that unallocated nodes are indicated by a '.' and DOWN or DRAINED 
-nodes by a '#'.
+Note that unallocated nodes are indicated by a '.' and nodes in the 
+DOWN, DRAINED or FAIL state by a '#'.
 .RS
 .TP 15
 .I "j"
@@ -126,11 +126,13 @@ F (failed), TO (timeout), and NF (node failure). See
 \fBJOB STATE CODES\fR section below for more information.
 .TP
 \fBSTATE\fR
-State of the nodes. Possible states include: down, unknown,
-idle, allocated, drained, draining, completing and their
-abbreviated forms: down, unk, idle, alloc, drain, drng, and
-comp respectively.  Note that the suffix "*" identifies nodes
-that are presently not responding.
+State of the nodes. 
+Possible states include: allocated, completing, down, 
+drained, draining, fail, failing, idle, and unknown plus
+their abbreviated forms: alloc, comp, donw, drain, drng, 
+fail, failg, idle, and unk respectively.
+Note that the suffix "*" identifies nodes that are presently 
+not responding.
 See \fBNODE STATE CODES\fR section below for more information.
 .TP
 \fBTIMELIMIT\fR
@@ -326,7 +328,9 @@ If the node state code is followed by "*", this indicates the
 node is presently not responding and will not be allocated
 any new work.  If the node remains non\-responsive, it will
 be placed in the \fBDOWN\fR state (except in the case of
-\fBDRAINED\fR, \fBDRAINING\fR, or \fBCOMPLETING\fR nodes).
+\fBCOMPLETING\fR, \fBDRAINED\fR, \fBDRAINING\fR,
+\fBFAIL\fR, \fBFAILING\fR nodes).
+
 If the node state code is followed by "~", this indicates
 the node is presently in a power saving mode (typically
 running at reduced frequency).
@@ -369,6 +373,18 @@ this state per system administrator request. See the \fBupdate
 node\fR command in the \fBscontrol\fR(1) man page or the
 \fBslurm.conf\fR(5) man page for more information.
 .TP
+\fBFAIL\fR
+The node is expected to fail soon and is unavailable for 
+use per system administrator request.  
+See the \fBupdate node\fR command in the \fBscontrol\fR(1) 
+man page or the \fBslurm.conf\fR(5) man page for more information.
+.TP
+\fBFAILING\fR
+The node is currently executing a job, but is expected to fail 
+soon and is unavailable for use per system administrator request.  
+See the \fBupdate node\fR command in the \fBscontrol\fR(1) 
+man page or the \fBslurm.conf\fR(5) man page for more information.
+.TP
 \fBIDLE\fR
 The node is not allocated to any jobs and is available for use.
 .TP
@@ -421,7 +437,7 @@ The location of the SLURM configuration file.
 .SH "COPYING"
 Copyright (C) 2004\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/squeue.1 b/doc/man/man1/squeue.1
index 99a5ff82113009e3cd30735d256834a575945175..b522252abe00d574f9e1cd68654c085affdb1e25 100644
--- a/doc/man/man1/squeue.1
+++ b/doc/man/man1/squeue.1
@@ -1,4 +1,4 @@
-.TH SQUEUE "1" "December 2006" "squeue 1.2" "Slurm components"
+.TH SQUEUE "1" "May 2008" "squeue 1.3" "Slurm components"
 
 .SH "NAME"
 squeue \- view information about jobs located in the SLURM scheduling queue.
@@ -189,7 +189,8 @@ Minimum number of nodes requested by the job.
 Are contiguous nodes requested by the job
 .TP
 \fB%p\fR
-Priority of the job (converted to a floating point number between 0.0 and 1.0
+Priority of the job (converted to a floating point number between 0.0 and 1.0).
+Also see \fB%Q\fR.
 .TP
 \fB%P\fR 
 Partition of the job or job step
@@ -197,6 +198,10 @@ Partition of the job or job step
 \fB%q\fR 
 Comment associated with the job
 .TP
+\fB%Q\fR
+Priority of the job (generally a very large unsigned integer).
+Also see \fB%p\fR.
+.TP
 \fB%r\fR
 The reason a job is in its current state.
 See the \fBJOB REASON CODES\fR section below for more information.
@@ -327,6 +332,7 @@ The partition required by this job is in a DOWN state.
 \fBPartitionNodeLimit\fR
 The number of nodes required by this job is outside of it's 
 partitions current limits.
+Can also indicate that required nodes are DOWN or DRAINED.
 .TP
 \fBPartitionTimeLimit\fR
 The job's time limit exceeds it's partition's current time limit.
@@ -478,7 +484,7 @@ Print information only about job step 65552.1:
 .SH "COPYING"
 Copyright (C) 2002\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/sreport.1 b/doc/man/man1/sreport.1
new file mode 100644
index 0000000000000000000000000000000000000000..e67311c9fec92a1a9ef82d517af9f06f70d23860
--- /dev/null
+++ b/doc/man/man1/sreport.1
@@ -0,0 +1,111 @@
+.TH SREPORT "1" "May 2008" "sreport 1.3" "Slurm components"
+
+.SH "NAME"
+sreport \- Used to generate reports from the slurm accounting data.
+
+.SH "SYNOPSIS"
+\fBssreport\fR [\fIOPTIONS\fR...] [\fICOMMAND\fR...]
+
+.SH "DESCRIPTION"
+\fBssreport\fR is used to generator certain reports.  Right now
+sreport is a template that does not really do anything.  In the future
+it will provide a view into accounting data gathered from slurm via
+the account information maintained within a database with the interface 
+being provided by \fBslurmdbd\fR (Slurm Database daemon).
+
+.SH "OPTIONS"
+
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Print a help message describing the usage of \fBssreport\fR.
+This is equivalent to the \fBhelp\fR command.
+
+.TP
+\fB\-o\fR, \fB\-\-oneliner\fR
+Print information one line per record.
+This is equivalent to the \fBoneliner\fR command.
+
+.TP
+\fB\-q\fR, \fB\-\-quiet\fR
+Print no warning or informational messages, only error messages.
+This is equivalent to the \fBquiet\fR command.
+
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+Print detailed event logging. 
+This is equivalent to the \fBverbose\fR command.
+
+.TP
+\fB\-V\fR , \fB\-\-version\fR
+Print version information and exit.
+This is equivalent to the \fBversion\fR command.
+
+.TP
+\fBCOMMANDS\fR
+
+.TP
+\fBexit\fP
+Terminate the execution of sreport.
+Identical to the \fBquit\fR command.
+
+.TP
+\fBhelp\fP
+Display a description of sreport options and commands.
+
+.TP
+\fBhide\fP
+Do not display information about hidden or deleted entities. 
+
+.TP
+\fBoneliner\fP
+Print information one line per record.
+
+.TP
+\fBquiet\fP
+Print no warning or informational messages, only fatal error messages.
+
+.TP
+\fBquit\fP
+Terminate the execution of sreport.
+Identical to the \fBexit\fR command.
+
+.TP
+\fBverbose\fP
+Print detailed event logging. 
+This includes time\-stamps on data structures, record counts, etc.
+This is an independent command with no options meant for use in interactive mode.
+
+.TP
+\fBversion\fP
+Display the version number of sreport being executed.
+
+.TP
+\fB!!\fP
+Repeat the last command executed.
+
+.SH "EXAMPLES"
+.eo
+.br
+.ec
+
+.SH "COPYING"
+Copyright (C) 2008 Lawrence Livermore National Security.
+Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+LLNL\-CODE\-402394.
+.LP
+This file is part of SLURM, a resource management program.
+For details, see <https://computing.llnl.gov/linux/slurm/>.
+.LP
+SLURM is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+.LP
+SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+details.
+
+.SH "SEE ALSO"
+\fBslurm.conf\fR(5)
+\fBslurmdbd\fR(8)
diff --git a/doc/man/man1/srun.1 b/doc/man/man1/srun.1
index 2f2249ac7339cf7205eeac3064f18aa4aa815939..afe14ad594fa4022d3e53ab6be8394657f0ed267 100644
--- a/doc/man/man1/srun.1
+++ b/doc/man/man1/srun.1
@@ -1,27 +1,28 @@
-.\" $Id: srun.1 13766 2008-04-02 17:19:34Z jette $
+.\" $Id: srun.1 14123 2008-05-23 20:22:46Z jette $
 .\"
-.TH SRUN "1" "July 2007" "srun 1.2" "slurm components"
+.TH SRUN "1" "May 2008" "srun 1.3" "slurm components"
 
 .SH "NAME"
 srun \- run parallel jobs
 
 .SH SYNOPSIS
 \fBsrun\fR            [\fIOPTIONS\fR...]  \fIexecutable \fR[\fIargs\fR...]
-.br
-\fBsrun\fR \-\-batch    [\fIOPTIONS\fR...]  job_script \fR[\fIargs\fR...]
-.br
-\fBsrun\fR \-\-allocate [\fIOPTIONS\fR...] [job_script \fR[\fIargs\fR...]]
-.br
-.B srun
-\-\-attach=jobid
 
 .SH DESCRIPTION
-Allocate resources and optionally initiate parallel jobs on
-clusters managed by SLURM.
+Run a parallel job on cluster managed by SLURM.  If necessary, srun will
+first create a resource allocation in which to run the parallel job.
 
 .SH "OPTIONS"
 .LP
 
+.TP
+\fB\-\-acctg\-freq\fR=\fIseconds\fR
+Define the job accounting sampling interval.
+This can be used to override the \fIJobAcctGatherFrequency\fR parameter in SLURM's 
+configuration file, \fIslurm.conf\fR.
+A value of zero disables real the periodic job sampling and provides accounting
+information only on job termination (reducing SLURM interference with the job).
+
 .TP
 \fB\-B\fR \fB\-\-extra\-node\-info\fR=\fIsockets\fR[:\fIcores\fR[:\fIthreads\fR]]
 Request a specific allocation of resources with details as to the
@@ -50,46 +51,6 @@ configured.
 If select/cons_res is configured, it must have a parameter of CR_Core, 
 CR_Core_Memory, CR_Socket, or CR_Socket_Memory. 
 
-.TP
-\fB\-b\fR, \fB\-\-batch\fR
-\fBNOTE: This functionality has been moved to a new command, sbatch
-This option will be removed from srun at a later date.\fR
-.br
-Submit in "batch mode." \fBsrun\fR will make a copy of the \fIexecutable\fR 
-file (a script) and submit the request for execution when resouces are 
-available. \fBsrun\fR will terminate after the request has been submitted. 
-The \fIexecutable\fR file will run on the first node allocated to the 
-job and must contain \fBsrun\fR commands to initiate parallel tasks.
-stdin will be redirected from /dev/null, stdout and stderr will be
-redirected to a file (default is \fIjobname\fR.out or \fIjobid\fR.out in
-current working directory, see \fB\-o\fR for other IO options).
-Note that if the slurm daemons are cold\-started, jobid values will be 
-reused. Plan accordingly to avoid over\-writing output and error files. 
-\fIexecutable\fR must be specified using either a fully qualified 
-pathname or its pathname will be relative to the current working directory. 
-The search path will not be used to locate the file. \fIexecutable\fR 
-will be interpreted by the users default shell unless the file begins 
-with "#!" followed by the fully qualified pathname of a valid shell.
-Note that batch jobs will be re\-queued if a node fails while it is being 
-initiated. 
-
-Srun commandline options can also be inserted into the script by prefacing 
-the option with #SLURM. Multiple options can be on one line or multiple lines. 
-For example:
-
-.nf
-    #SLURM \-N 2 \-n 2
-    #SLURM \-\-mpi=lam
-.fi
-
-This is run the script on 2 nodes, with 2 procs with mpi type lam.  
-All commandline options are able to be set inside the script with the 
-exception of the mode (which has already been set since to run a batch 
-script you are in batch mode).
-.br
-Options on the command line take precedence over options in the batch 
-script, which in turn take precedence over exiting environmement variables.
-
 .TP
 \fB\-\-begin\fR=\fItime\fR
 Defer initiation of this job until the specified time.
@@ -117,6 +78,19 @@ For example:
    \-\-begin=02/22/08-12:34:67
 .fi
 
+.TP
+\fB\-\-checkpoint\fR=\fItime\fR
+Specifies the interval between creating checkpoints of the job step. 
+By default, the job step will no checkpoints created.
+Acceptable time formats include "minutes", "minutes:seconds", 
+"hours:minutes:seconds", "days\-hours", "days\-hours:minutes" and 
+"days\-hours:minutes:seconds".
+
+.TP
+\fB\-\-checkpoint\-path\fR=\fIdirectory\fR
+Specifies the directory into which the job step's checkpoint should 
+be written (used by the checkpoint/xlch plugin only).
+
 .TP
 \fB\-C\fR, \fB\-\-constraint\fR[=]<\fIlist\fR>
 Specify a list of constraints. 
@@ -131,6 +105,12 @@ nodes, then use the OR operator and enclose the options within square brackets.
 For example: "\fB\-\-constraint="[rack1|rack2|rack3|rack4]"\fR might 
 be used to specify that all nodes must be allocated on a single rack of 
 the cluster, but any of those four racks can be used.
+A request can also specify the number of nodes needed with some feature
+by appending an asterisk and count after the feature name. 
+For example "\fBsrun \-\-nodes=16 \-\-constraint=graphics*4 ..."\fR 
+indicates that the job requires 16 nodes at that at least four of those
+nodes must have the feature "graphics."
+Constraints with node counts may only be combined with AND operators.
 If no nodes have the requested features, then the job will be rejected 
 by the slurm job manager.
 
@@ -276,33 +256,19 @@ parameter in slurm.conf.
 
 .TP
 \fB\-\-exclusive\fR
-Dedicate whole nodes to the job rather than individual processors 
-even if consumable resources are enabled 
+When used to initiate a job step within an existing resource allocation, 
+proceed only when processors can be dedicated to the job step without 
+sharing with other job steps. This can be used to initiate many 
+job steps simultaneously within an existing job allocation and have 
+SLURM perform resource management for the job. 
+In this mode, use with the \fB\-\-ntasks\fR option and NOT the 
+\fB\-\-nodes\fR, \fB\-\-relative\fR, \fB\-\-relative\fR=\fIarbitrary\fR
+options (which provide user control over task layout).
+See \fBEXAMPLE\fR below.
+When used to initiate a job, dedicate whole nodes to the job rather 
+than individual processors even if consumable resources are enabled 
 (e.g. \fBSelectType=select/cons_res\fR).
 
-.TP
-\fB\-\-get\-user\-env\fR[=\fItimeout\fR][\fImode\fR]
-For a batch script submission, this option will tell srun to retrieve the
-login environment variables for the user specified in the \fB\-\-uid\fR option.
-The environment variables are retrieved by running something of this sort
-"su \- <username> \-c /usr/bin/env" and parsing the output.  
-Be aware that any environment variables already set in srun's environment 
-will take precedence over any environment variables in the user's 
-login environment.
-The optional \fItimeout\fR value is in seconds. Default value is 8 seconds.
-The optional \fImode\fR value control the "su" options.
-With a \fImode\fR value of "S", "su" is executed without the "\-" option.
-With a \fImode\fR value of "L", "su" is executed with the "\-" option,
-replicating the login environment.
-If \fImode\fR not specified, the mode established at SLURM build time 
-is used.
-Example of use include "\-\-get\-user\-env", "\-\-get\-user\-env=10"
-"\-\-get\-user\-env=10L", and "\-\-get\-user\-env=S".
-NOTE: This option only works if the caller has an
-effective uid of "root", and only takes effect in batch mode 
-(\fB\-b\fR/\fB\-\-batch\fR).  
-This option was originally created for use by Moab.
-
 .TP
 \fB\-\-gid\fR=\fIgroup\fR
 If \fBsrun\fR is run as root, and the \fB\-\-gid\fR option is used, 
@@ -380,9 +346,7 @@ not for the submission of individual job steps.
 The job will assume all responsibilities for fault\-tolerance. The 
 active job step (MPI job) will almost certainly suffer a fatal error, 
 but subsequent job steps may be run if this option is specified. The
-default action is to terminate job upon node failure. Note that
-\fB\-\-batch\fR jobs will be re\-queued if a node failure occurs in the 
-process of initiating it.
+default action is to terminate job upon node failure.
 
 .TP
 \fB\-l\fR, \fB\-\-label\fR
@@ -393,11 +357,16 @@ The \fB\-\-label\fR option will prepend lines of output with the remote
 task id.
 
 .TP
-\fB-u\fR, \fB\-\-unbuffered\fR
-do not line buffer stdout from remote tasks. This option cannot be used
-with \fI\-\-label\fR. 
+\fB\-L\fR, \fB\-\-licenses\fR=
+Specification of licenses (or other resources available on all 
+nodes of the cluster) which must be allocated to this job.
+License names can be followed by an asterisk and count 
+(the default count is one).
+Multiple license names should be comma separated (e.g.
+"\-\-licenses=foo*4,bar").
+
 .TP
-\fB\-m\fR, \fB\-\-distribution\fR=
+\fB\-m\fR, \fB\-\-relative\fR
 (\fIblock\fR|\fIcyclic\fR|\fIarbitrary\fR|\fIplane=<options>\fR)
 Specify an alternate distribution method for remote processes.
 .RS
@@ -454,8 +423,13 @@ User to receive email notification of state changes as defined by
 The default value is the submitting user.
 
 .TP
-\fB\-\-mem\fR=\fIMB\fR
-Specify a minimum amount of real memory.
+\fB\-\-mem\fR[=]<\fIMB\fR>
+Specify the real memory required per node in MegaBytes.
+If a value is specified, that quantity of memory will be 
+reserved for this job. 
+If no value is specified and real memory is exhausted on 
+any allocated node then the job is subject to cancellation.
+Also see \fB\-\-task\-mem\fR.
 
 .TP
 \fB\-\-mem_bind\fR=[{\fIquiet,verbose\fR},]\fItype\fR
@@ -550,8 +524,9 @@ Specify a minimum number of threads per core.
 
 .TP
 \fB\-\-msg\-timeout\fR=\fIseconds\fR
-Modify the job launch message timeout. 
-Changes to this are typically not recommended.
+Modify the job launch message timeout.
+The default value is \fBMessageTimeout\fR in the SLURM configuration file slurm.conf. 
+Changes to this are typically not recommended, but could be useful to diagnose problems.
 
 .TP
 \fB\-\-mpi\fR=\fImpi_type\fR
@@ -560,7 +535,7 @@ procedures.
 .RS
 .TP
 .B list
-Lists avaliable mpi types to choose from.
+Lists available mpi types to choose from.
 .TP
 .B lam
 Initiates one 'lamd' process per node and establishes necessary
@@ -612,16 +587,18 @@ Note that the environment
 variable \fBSLURM_NNODES\fR will be set to the count of nodes actually 
 allocated to the job. See the \fBENVIRONMENT VARIABLES \fR section 
 for more information.  If \fB\-N\fR is not specified, the default
-behaviour is to allocate enough nodes to satisfy the requirements of
+behavior is to allocate enough nodes to satisfy the requirements of
 the \fB\-n\fR and \fB\-c\fR options.
-The job will be allocated as many nodes as possible within the range specified 
+The job will be allocated as many nodes as possible within the range specified
 and without delaying the initiation of the job.
 
 .TP
 \fB\-n\fR, \fB\-\-ntasks\fR=\fIntasks\fR
-Specify the number of processes to run. Request that \fBsrun\fR
-allocate \fIntasks\fR processes.  The default is one process per
-node, but note that the \fB\-c\fR parameter will change this default.
+Specify the number of tasks to run. Request that \fBsrun\fR
+allocate resources for \fIntasks\fR tasks.  
+The default is one task per socket or core (depending upon the value 
+of the \fISelectTypeParameters\fR parameter in slurm.conf), but note 
+that the \fB\-\-cpus\-per\-task\fR option will change this default.
 
 .TP
 \fB\-\-network\fR=\fItype\fR
@@ -631,10 +608,10 @@ Since POE is used to launch tasks, this option is not normally used or
 is specified using the \fBSLURM_NETWORK\fR environment variable.
 The interpretation of \fItype\fR is system dependent. 
 For systems with an IBM Federation switch, the following 
-comma\-separated and case insensitive types are recongnized:
+comma\-separated and case insensitive types are recognized:
 \fBIP\fR (the default is user\-space), \fBSN_ALL\fR, \fBSN_SINGLE\fR, 
 \fBBULK_XFER\fR and adapter names  (e.g. \fBSNI0\fR and \fBSNI1\fR). 
-For more information, on IBM systems see \fIpoe\fR documenation on 
+For more information, on IBM systems see \fIpoe\fR documentation on 
 the environment variables \fBMP_EUIDEVICE\fR and \fBMP_USE_BULK_XFER\fR.
 Note that only four jobs steps may be active at once on a node with the 
 \fBBULK_XFER\fR option due to limitations in the Federation switch driver.
@@ -649,14 +626,6 @@ a negative adjustment. NOTE: This option is presently
 ignored if \fISchedulerType=sched/wiki\fR or 
 \fISchedulerType=sched/wiki2\fR.
 
-.TP
-\fB\-\-no\-requeue\fR
-Specifies that the batch job is not requeue. 
-Setting this option will prevent system administrators from being able 
-to restart the job (for example, after a scheduled downtime).
-When a job is requeued, the batch script is initiated from its beginning.
-This option is only applicable to batch job submission (see \fB\-\-batch\fR).
-
 .TP
 \fB\-\-ntasks\-per\-core\fR=\fIntasks\fR
 Request that no more than \fIntasks\fR be invoked on each core.
@@ -680,7 +649,7 @@ or \fISelectType=CR_Socket_Memory\fR is configured.
 .TP
 \fB\-\-ntasks\-per\-node\fR=\fIntasks\fR
 Request that no more than \fIntasks\fR be invoked on each node.
-This is similiar to using \fB\-\-cpus\-per\-task\fR=\fIncpus\fR
+This is similar to using \fB\-\-cpus\-per\-task\fR=\fIncpus\fR
 but does not require knowledge of the actual number of cpus on
 each node.  In some cases, it is more convenient to be able to
 request that no more than a specific number of ntasks be invoked
@@ -715,12 +684,38 @@ If \fB\-\-error\fR is not also specified on the command line, both
 stdout and stderr will directed to the file specified by \fB\-\-output\fR.
 
 .TP
-\fB\-P\fR, \fB\-\-dependency\fR=\fIjobid\fR
-Defer initiation of this job until the specified jobid
-has completed execution.  Many jobs can share the same 
-dependency and these jobs may belong to different users.
-The value may be changed after job submission using the 
-\fBscontrol\fR command.
+\fB\-\-open\-mode\fR=append|truncate
+Open the output and error files using append or truncate mode as specified.
+The default value is specified by the system configuration parameter
+\fIJobFileAppend\fR.
+
+.TP 
+\fB\-P\fR, \fB\-\-dependency\fR[=]<\fIdependency_list\fR>
+Defer the start of this job until the specified dependencies have been
+satisfied completed.
+<\fIdependency_list\fR> is of the form 
+<\fItype:job_id[:job_id][,type:job_id[:job_id]]\fR>.
+Many jobs can share the same dependency and these jobs may even belong to
+different  users. The  value may be changed after job submission using the
+scontrol command.
+.PD
+.RS
+.TP
+\fBafter:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have begun
+execution.
+.TP
+\fBafterany:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have terminated.
+.TP
+\fBafternotok:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have terminated
+in some failed state (non-zero exit code, node failure, timed out, etc).
+.TP
+\fBafterok:job_id[:jobid...]\fR
+This job can begin execution after the specified jobs have successfully
+executed (ran to completion with non-zero exit code).
+.RE
 
 .TP
 \fB\-p\fR, \fB\-\-partition\fR=\fIpartition\fR
@@ -780,6 +775,14 @@ The maximum resident set size
 The maximum stack size
 .RE
 
+.TP
+\fB\-\-pty\fR
+Execute task zero in pseudo terminal.
+Implicitly sets \fB\-\-unbuffered\fR.
+Implicitly sets \fB\-\-error\fR and \fB\-\-output\fR to /dev/null 
+for all tasks except task zero.
+Not currently supported on AIX platforms.
+
 .TP
 \fB\-Q\fR, \fB\-\-quiet\fR
 Quiet operation. Suppress informational messages. Errors will still
@@ -840,6 +843,13 @@ in slurm.conf is executed. This is meant to be a very short\-lived
 program. If it fails to terminate within a few seconds, it will 
 be killed along with any descendant processes.
 
+.TP
+\fB\-\-task\-mem\fR[=]<\fIMB\fR>
+Mimimum memory available per task in MegaBytes.
+Default value is \fBDefMemPerTask\fR and the maximum value is
+\fBMaxMemPerTask\fR, both of which can be seen using the
+\fBscontrol show config\fR command.
+
 .TP
 \fB\-\-task\-prolog\fR=\fIexecutable\fR
 The \fBslurmd\fR daemon will run \fIexecutable\fR just before launching 
@@ -923,42 +933,6 @@ Request that a specific list of hosts not be included in the resources
 allocated to this job. The host list will be assumed to be a filename 
 if it contains a "/"character.
 
-.PP
-Allocate options. \fBNOTE: This functionality has been moved to a new command,
-salloc. This option will be removed from srun at a later date.\fR
-
-.TP
-\fB\-A\fR, \fB\-\-allocate\fR
-allocate resources and spawn a shell. When \fB\-\-allocate\fR is specified to
-\fBsrun\fR, no remote tasks are started. Instead a subshell is started that 
-has access to the allocated resources. Multiple jobs can then be run on the 
-same cpus from within this subshell. See \fBAllocate Mode\fR below.
-
-.TP
-\fB\-\-no\-shell\fR
-immediately exit after allocating resources instead of spawning a
-shell when used with the \fB\-A\fR, \fB\-\-allocate\fR option.
-
-.PP
-Attach to running job. \fBNOTE: This functionality has been moved to a new 
-command, sattach. This option will be removed from srun at a later date.\fR
-
-.TP
-\fB\-a\fR, \fB\-\-attach\fR=\fIid\fR
-This option will attach \fBsrun\fR
-to a running job with job id = \fIid\fR. Provided that the calling user
-has access to that running job, stdout and stderr will be redirected to the
-current session (assuming that the tasks' stdout and stderr are not connected
-directly to files).  stdin is not connected to the remote tasks, and signals
-are not forwarded unless the \fB\-\-join\fR parameter is also specified.
-
-.TP
-\fB\-j\fR, \fB\-\-join\fR
-Used in conjunction with \fB\-\-attach\fR to specify that stdin should
-also be connected to the remote tasks (assuming that the remote tasks'
-stdin are not directly connected to files), and signals sent to \fBsrun\fR
-will be forwarded to the remote tasks.  
-
 .PP
 The following options support Blue Gene systems, but may be 
 applicable to other systems as well.
@@ -1010,9 +984,6 @@ Default from \fIblugene.conf\fR if not set.
 Force the allocated nodes to reboot before starting the job.
 
 .PP
-Unless the \fB\-a\fR (\fB\-\-attach\fR) or \fB\-A\fR (\fB\-\-allocate\fR)
-options are specified (see \fBAllocate mode\fR and \fBAttaching to jobs\fR
-below),
 .B srun
 will submit the job request to the slurm job controller, then initiate all
 processes on the remote nodes. If the request cannot be met immediately,
@@ -1090,11 +1061,7 @@ This file will be written on the node executing the task.
 \fBsrun\fR will redirect stdout and/or stderr to the named file from 
 all tasks.
 stdin will be redirected from the named file and broadcast to all
-tasks in the job.  
-If the job is submitted in batch mode using the \fB\-b\fR or 
-\fB\-\-batch\fR option, \fIfilename\fR refers to a path on the first
-node allocated to the job. 
-Otherwise \fIfilename\fR refers to a path on the host
+tasks in the job.  \fIfilename\fR refers to a path on the host
 that runs \fBsrun\fR.  Depending on the cluster's file system layout,
 this may result in the output appearing in different places depending
 on whether the job is run in batch mode.
@@ -1149,41 +1116,7 @@ job128\-00.out, job128\-01.out, ...
 .PP
 .RS -10
 .PP
-.B "Allocate Mode"
-.PP
-When the allocate option is specified (\fB\-A\fR, \fB\-\-allocate\fR)
-\fBsrun\fR will not initiate any remote processes after acquiring
-resources. Instead, \fBsrun\fR will spawn a subshell which has access
-to the acquired resources. Subsequent instances of \fBsrun\fR from within
-this subshell will then run on these resources.
-.PP
-If the name of a script is specified on the
-commandline with \fB\-\-allocate\fR, the spawned shell will run the
-specified script. Resources allocated in this way will only be freed
-when the subshell terminates.
-.PP
-.B "Attaching to a running job"
-.PP
-Use of the \fB\-a\fR \fIjobid\fR (or \fB\-\-attach\fR) option allows
-\fBsrun\fR to reattach to a running job, receiving stdout and stderr
-from the job and forwarding signals to the job, just as if the current
-session of \fBsrun\fR had started the job. (stdin, however, cannot
-be forwarded to the job).
-.PP
-There are two ways to reattach to a running job. The default method
-is to attach to the current job read\-only. In this case, 
-stdout and stderr are duplicated to the attaching \fBsrun\fR, but
-signals are not forwarded to the remote processes (A single 
-Ctrl\-C will detach this read\-only \fBsrun\fR from the job). If
-the \fB\-j\fR (\fB\-\-join\fR) option is is also specified, 
-\fBsrun\fR "joins" the running job, and is able to forward signals,
-connects stdin, and acts for the most part much like the \fBsrun\fR
-process that initiated the job. 
-.PP
-Node and CPU selection options do not make sense when specifying 
-\fB\-\-attach\fR, and it is an error to use \fB\-n\fR, \fB\-c\fR, 
-or \fB\-N\fR in attach mode.
-.PP
+
 .SH "ENVIRONMENT VARIABLES"
 .PP
 Some srun options may be set via environment variables. 
@@ -1198,7 +1131,7 @@ sends messages to application programs (via the PMI library)
 and those applications may be called upon to forward that 
 data to up to this number of additional tasks. Higher values
 offload work from the srun command to the applications and 
-likely increase the vulernability to failures. 
+likely increase the vulnerability to failures. 
 The default value is 32.
 .TP
 \fBPMI_FANOUT_OFF_HOST\fR
@@ -1211,8 +1144,10 @@ per host and one task on that host forwards the data to other
 tasks on that host up to \fBPMI_FANOUT\fR. 
 If \fBPMI_FANOUT_OFF_HOST\fR is defined, the user task 
 may be required to forward the data to tasks on other hosts.
-Setting \fBPMI_FANOUT_OFF_HOST\fR may increase performance
-and vulernability to failures.
+Setting \fBPMI_FANOUT_OFF_HOST\fR may increase performance. 
+Since more work is performed by the PMI library loaded by
+the user application, failures also can be more common and 
+more difficult to diagnose.
 .TP
 \fBPMI_TIME\fR
 This is used exclusively with PMI (MPICH2 and MVAPICH2) and 
@@ -1220,7 +1155,7 @@ controls how much the communications from the tasks to the
 srun are spread out in time in order to avoid overwhelming the 
 srun command with work. The default value is 500 (microseconds)
 per task. On relatively slow processors or systems with very 
-large processsor counts (and large PMI data sets), higher values 
+large processor counts (and large PMI data sets), higher values 
 may be required.
 .TP
 \fBSLURM_CONF\fR
@@ -1229,6 +1164,9 @@ The location of the SLURM configuration file.
 \fBSLURM_ACCOUNT\fR
 Same as \fB\-U, \-\-account\fR=\fIaccount\fR
 .TP
+\fBSLURM_CHECKPOINT\fR
+Same as \fB\-\-checkpoint\fR=\fItime\fR
+.TP
 \fBSLURM_CPU_BIND\fR
 Same as \fB\-\-cpu_bind\fR=\fItype\fR
 .TP
@@ -1292,15 +1230,15 @@ Same as \fB\-\-ntasks\-per\-node\fRa
 \fBSLURN_NTASKS_PER_SOCKET\fR
 Same as \fB\-\-ntasks\-per\-socket\fRa
 .TP
-\fBSLURM_NO_REQUEUE\fR
-Same as \fB\-\-no\-requeue\fR
-.TP
 \fBSLURM_NO_ROTATE\fR
 Same as \fB\-\-no\-rotate\fR
 .TP
 \fBSLURM_NPROCS\fR
 Same as \fB\-n, \-\-ntasks\fR=\fIn\fR
 .TP
+\fBSLURM_OPEN_MODE\fR
+Same as \fB\-\-open\-mode\fR
+.TP
 \fBSLURM_OVERCOMMIT\fR
 Same as \fB\-O, \-\-overcommit\fR
 .TP
@@ -1328,6 +1266,9 @@ Same as \fB\-o, \-\-output\fR=\fImode\fR
 \fBSLURM_TASK_EPILOG\fR
 Same as \fB\-\-task\-epilog\fR=\fIexecutable\fR
 .TP
+\fBSLURM_TASK_MEM\fR
+Same as \fB\-\-task\-mem\fR
+.TP
 \fBSLURM_TASK_PROLOG\fR
 Same as \fB\-\-task\-prolog\fR=\fIexecutable\fR
 .TP
@@ -1379,7 +1320,7 @@ Zero origin and comma separated.
 Job id of the executing job
 .TP
 \fBSLURM_LAUNCH_NODE_IPADDR\fR
-IP adddress of the node from which the task launch was 
+IP address of the node from which the task launch was 
 initiated (where the srun command ran from)
 .TP
 \fBSLURM_LOCALID\fR
@@ -1410,7 +1351,7 @@ Total number of processes in the current job
 .TP
 \fBSLURM_PRIO_PROCESS\fR
 The scheduling priority (nice value) at the time of job submission.
-This value is propaged to the spawned processes.
+This value is propagated to the spawned processes.
 .TP
 \fBSLURM_PROCID\fR
 The MPI rank (or relative process ID) of the current process
@@ -1435,7 +1376,7 @@ The umask (user file\-create mask) at the time of job submission.
 This value is propagated to the spawned processes.
 .TP
 \fBMPIRUN_NOALLOCATE\fR
-Do not allcate a block on Blue Gene systems only.
+Do not allocate a block on Blue Gene systems only.
 .TP
 \fBMPIRUN_NOFREE\fR
 Do not free a block on Blue Gene systems only.
@@ -1509,7 +1450,7 @@ The expression "%t" will be replaced with the task's number.
 The expression "%o" will be replaced with the task's offset within
 this range (e.g. a configured task rank value of "1\-5" would
 have offset values of "0\-4").
-Single quotes may be used to avoid having the enclosed values interpretted.
+Single quotes may be used to avoid having the enclosed values interpreted.
 This field is optional.
 .PP
 For example:
@@ -1555,26 +1496,6 @@ the request. The output of each task will be proceeded with its task number.
 6: dev3
 7: dev3
 
-.fi
-.PP
-This example demonstrates how one might submit a script for later 
-execution (batch mode). The script will be initiated when resources 
-are available and no higher priority job is pending for the same 
-partition. The script will execute on 4 nodes with one task per node 
-implicit. Note that the script executes on one node. For the script 
-to utilize all allocated nodes, it must execute the \fBsrun\fR command 
-or an MPI program.
-
-.nf
-
-> cat test.sh
-#!/bin/sh
-date
-srun \-l hostname
-
-> srun \-N4 \-b test.sh
-srun: jobid 42 submitted
-
 .fi
 .PP
 The output of test.sh would be found in the default output file
@@ -1593,7 +1514,7 @@ echo $SLURM_NODELIST
 srun \-lN2 \-r2 hostname
 srun \-lN2 hostname
 
-> srun \-A \-N4 test.sh
+> salloc \-N4 test.sh
 dev[7\-10]
 0: dev9
 1: dev10
@@ -1616,7 +1537,7 @@ squeue
 squeue \-s
 wait
 
-> srun \-A \-N4 test.sh
+> salloc \-N4 test.sh
   JOBID PARTITION     NAME     USER  ST      TIME  NODES NODELIST
   65641     batch  test.sh   grondo   R      0:01      4 dev[7\-10]
 
@@ -1647,7 +1568,7 @@ mpirun \-np $SLURM_NPROCS \-machinefile $MACHINEFILE mpi\-app
 
 rm $MACHINEFILE
 
-> srun \-AN2 \-n4 test.sh
+> salloc \-N2 \-n4 test.sh
 
 .fi 
 .PP
@@ -1684,11 +1605,27 @@ dedicated to the job.
 
 > srun \-N2 \-B 4\-4:2\-2 a.out
 .fi
+.PP
+This example shows a script in which Slurm is used to provide resource 
+management for a job by executing the various job steps as processors 
+become available for their dedicated use.
+
+.nf
+
+> cat my.script
+#!/bin/bash
+srun \-\-exclusive \-n4 prog1 &
+srun \-\-exclusive \-n3 prog2 &
+srun \-\-exclusive \-n1 prog3 &
+srun \-\-exclusive \-n1 prog4 &
+wait
+.fi
+
 
 .SH "COPYING"
 Copyright (C) 2006\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/sstat.1 b/doc/man/man1/sstat.1
new file mode 100644
index 0000000000000000000000000000000000000000..d8ca661fc7dc1b7e4ac522bb5cf6a0172a3e9f3f
--- /dev/null
+++ b/doc/man/man1/sstat.1
@@ -0,0 +1,262 @@
+.TH SSTAT "1" "May 2008" "sacctmgr 1.3" "Slurm components"
+
+.SH "NAME"
+sstat \- Used to query running job and see various usage information
+of job/step running.
+
+.SH "SYNOPSIS"
+.BR "sstat "
+\fBsstat\fR [\fIOPTIONS\fR...] 
+
+.SH "DESCRIPTION"
+.PP
+Status information for jobs invoked with SLURM.
+.PP
+The 
+.BR "sstat "
+command displays job accounting data stored in the job accounting log 
+file in a variety of forms for your analysis.
+The 
+.BR "sstat "
+command displays information on jobs, job steps, status, and exitcodes by 
+default.
+You can tailor the output with the use of the 
+\f3\-\-fields=\fP 
+option to specify the fields to be shown.
+.PP
+For the root user, the 
+.BR "sstat "
+command displays job status data for any job running on the system.
+.PP
+For the non\-root user, the 
+.BR "sstat "
+command limits the display of job status data to jobs that were 
+launched with their own user identifier (UID) by default.
+
+.SS "Options"
+.TP "10"
+
+.TP "3"
+\(bu
+\f3jobid\fP 
+.IP 
+and 
+\f3\-\-fields=\fP 
+options.
+.IP 
+
+.TP 
+\f3\-F \fP\f2field_list\fP \f3,\fP  \f3\-\-fields\fP\f3=\fP\f2field_list\fP
+Displays the job status data specified by the 
+\f2field_list\fP 
+operand, which is a comma\-separated list of fields.
+Space characters are not allowed in the 
+\f2field_list\fP\c
+\&. 
+.IP 
+See the 
+\f3\-\-help\-fields\fP 
+option for a list of the available fields.
+See the section titled "Job Status Fields" for a description of 
+each field.
+.IP 
+The job accounting data is displayed in the order specified by the 
+\f2field_list\fP 
+operand.
+Thus, the following two commands display the same data but in different order:
+.RS 
+.PP
+.nf 
+.ft 3
+# sstat \-\-fields=jobid,state
+Jobid    State
+\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-
+3          COMPLETED
+3.0        COMPLETED
+
+.ft 1
+.fi 
+.RE 
+.RS 
+.PP
+.nf 
+.ft 3
+# sacct \-\-fields=status,jobid
+State     Jobid
+\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-
+COMPLETED  3
+COMPLETED  3.0
+
+.ft 1
+.fi 
+.RE 
+.IP 
+The default value for the 
+\f2field_list\fP 
+operand is 
+\f3"jobid,vsize,rss,pages,cputime,ntasks,state"\fP\c
+\&.
+.IP 
+This option has no effect when the 
+\f3\-\-dump\fP 
+option is also specified.
+
+
+.TP 
+\f3\-h \fP\f3,\fP \f3\-\-help\fP
+Displays a general help message.
+.TP 
+\f3\-\-help\-fields\fP
+Displays a list of fields that can be specified with the 
+\f3\-\-fields\fP 
+option.
+.RS 
+.PP
+.nf 
+.ft 3
+Fields available:
+cputime     jobid       ntasks      pages
+rss         state       vsize
+
+.ft 1
+.fi 
+.RE 
+.IP 
+The section titled "Job Accounting Fields" describes these fields.
+
+.TP 
+\f3\-j \fP\f2job(.step)\fP \f3,\fP  \f3\-\-jobs\fP\f3=\fP\f2job(.step)\fP
+Displays information about the specified job(.step) or list of job(.step)s.
+.IP 
+The 
+\f2job(.step)\fP 
+parameter is a comma\-separated list of jobs.
+Space characters are not permitted in this list.
+.IP 
+The default is to display information on all jobs.
+
+.TP 
+\f3\-\-noheader\fP
+Prevents the display of the heading over the output.
+The default action is to display a header.
+.IP 
+This option has no effect when used with the 
+\f3\-\-dump\fP 
+option.
+
+\f3\-S \fP\f3,\fP \f3\-\-stat\fP
+.IP
+Queries the status of a job as the job is running displaying
+the following data:
+.RS 
+.TP "3"
+\(bu
+\f3jobid\fP 
+.TP "3"
+\(bu
+\f3vsize\fP 
+.TP "3"
+\(bu
+\f3rss\fP 
+.TP "3"
+\(bu
+\f3pages\fP 
+.TP "3"
+\(bu
+\f3cputime\fP 
+.TP "3"
+\(bu
+\f3ntasks\fP 
+.TP "3"
+\(bu
+\f3status\fP 
+.RE 
+.IP
+You must also include the \-\-jobs=job(.step) option if no (.step) is 
+given you will recieve the job.0 step.
+
+.TP 
+\f3\-\-usage\fP
+Displays a help message.
+
+.TP 
+\f3\-v \fP\f3,\fP \f3\-\-verbose\fP
+Reports the state of certain variables during processing.
+This option is primarily used for debugging.
+
+.SS "Job Status Fields"
+The following describes each job accounting field:
+.RS 
+.TP
+\f3cputime\fP
+Minimum CPU time of any process followed by its task id along with
+the average of all processes running in the step.
+
+.TP 
+\f3jobid\fP 
+The number of the job or job step.
+It is in the form: 
+\f2job.jobstep\fP\c
+\&.
+
+.TP
+\f3ntasks\fP 
+Total number of tasks in job.
+
+.TP
+\f3pages\fP
+Maximum page faults of any process followed by its task id along with
+the average of all processes running in the step.
+
+.TP 
+\f3rss\fP 
+Maximum resident set size of any process followed by its task id along with
+the average of all processes running in the step.
+
+.TP
+\f3state\fP
+Displays the job state.
+.IP 
+Output can be 
+\f3RUNNING\fP\c
+\&, 
+\f3SUSPENDED\fP\c
+\&,
+\f3COMPLETED\fP\c
+\&, 
+\f3CANCELLED\fP\c
+\&, 
+\f3FAILED\fP\c
+\&, 
+\f3TIMEOUT\fP\c
+\&, or 
+\f3NODE_FAIL\fP\c
+\&.
+
+.TP
+\f3vsize\fP
+Maximum Virtual Memory size of any process followed by its task id along with
+the average of all processes running in the step.
+
+.SH "EXAMPLES"
+
+.SH "COPYING"
+Copyright (C) 2008 Lawrence Livermore National Security.
+Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+LLNL\-CODE\-402394.
+.LP
+This file is part of SLURM, a resource management program.
+For details, see <https://computing.llnl.gov/linux/slurm/>.
+.LP
+SLURM is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+.LP
+SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+details.
+
+.SH "SEE ALSO"
+\fBsacct\fR(1)
diff --git a/doc/man/man1/strigger.1 b/doc/man/man1/strigger.1
index 5d06e3a6c1e2d872a6772c77b0906f6ad8b50f42..f7f298ad8034a2a4078e0ab4df157909f36cd34e 100644
--- a/doc/man/man1/strigger.1
+++ b/doc/man/man1/strigger.1
@@ -1,4 +1,4 @@
-.TH SCONTROL "1" "April 2007" "strigger 1.2" "Slurm components"
+.TH STRIGGER "1" "May 2008" "strigger 1.3" "Slurm components"
 
 .SH "NAME"
 strigger \- Used set, get or clear Slurm trigger information.
@@ -18,8 +18,22 @@ These events can cause actions such as the execution of an arbitrary
 script. 
 Typical uses include notifying system administrators of node failures 
 and gracefully terminating a job when it's time limit is approaching.
-
-\fBNOTE:\fR This command can only set triggers if run by the 
+A hostlist expression for the nodelist or job ID is passed as an argument 
+to the program.
+
+Trigger events are not processed instantly, but a check is performed for 
+trigger events on a periodic basis (currently every 15 seconds). 
+Any trigger events which occur within that interval will be compared 
+against the trigger programs set at the end of the time interval. 
+The trigger program will be executed once for any event occuring in
+that interval.
+The record of those events (e.g. nodes which went DOWN in the previous
+15 seconds) will then be cleared.
+The trigger program must set a new trigger before the end of the next 
+interval to insure that no trigger events are missed.
+If desired, multiple trigger programs can be set for the same event.
+
+\fBIMPORTANT NOTE:\fR This command can only set triggers if run by the 
 user \fISlurmUser\fR unless \fISlurmUser\fR is configured as user root.
 This is required for the \fIslurmctld\fR daemon to set the appropriate
 user and group IDs for the executed program. 
@@ -45,6 +59,15 @@ be cleared.
 \fB\-d\fR, \fB\-\-down\fR
 Trigger an event if the specified node goes into a DOWN state.
 
+
+.TP
+\fB\-D\fR, \fB\-\-drained\fR
+Trigger an event if the specified node goes into a DRAINED state.
+
+.TP
+\fB\-F\fR, \fB\-\-fail\fR
+Trigger an event if the specified node goes into a FAILING state.
+
 .TP
 \fB\-f\fR, \fB\-\-fini\fR
 Trigger an event when the specified job completes execution.
@@ -81,7 +104,8 @@ By default, all nodes associated with the job (if \fB\-\-jobid\fR
 is specified) or on the system are considered for event triggers.
 \fBNOTE:\fR The \fB\-\-node\fR option can not be used in conjunction 
 with the \fB\-\-jobid\fR option. When the \fB\-\-jobid\fR option is 
-used in conjunction with the \fB\-\-up\fR or \fB\-\-down\fR option, 
+used in conjunction with the \fB\-\-up\fR, \fB\-\-down\fR or 
+\fB\-\-drained\fR option, 
 all nodes allocated to that job will considered the nodes used as a 
 trigger event.
 
@@ -159,7 +183,7 @@ Resource ID: job ID or host names or "*" for any host
 \fBTYPE\fP
 Trigger type: \fItime\fR or \fIfini\fR (for jobs only), 
 \fIdown\fR or \fIup\fR (for jobs or nodes), or
-\fIidle\fR or \fIreconfig\fR (for nodes only)
+\fIdrained\fR, \fIidle\fR or \fIreconfig\fR (for nodes only)
 
 .TP
 \fBOFFSET\fP
@@ -176,7 +200,9 @@ Pathname of the program to execute when the event occurs
 
 .SH "EXAMPLES"
 Execute the program "/usr/sbin/slurm_admin_notify" whenever 
-any node in the cluster goes down. 
+any node in the cluster goes down. The subject line will include
+the node names which have entered the down state (passed as an
+argument to the script by SLURM).
 
 .nf
 	> cat /usr/sbin/slurm_admin_notify
@@ -185,7 +211,7 @@ any node in the cluster goes down.
 	strigger \-\-set \-\-node \-\-down \\
 	         \-\-program=/usr/sbin/slurm_admin_notify
 	# Notify administrator using by e\-mail
-	/bin/mail slurm_admin@site.com \-s NodeDown
+	/bin/mail slurm_admin@site.com \-s NodesDown:$*
 
 	> strigger \-\-set \-\-node \-\-down \\
 	           \-\-program=/usr/sbin/slurm_admin_notify
@@ -246,7 +272,7 @@ Execute /home/joe/job_fini upon completion of job 1237.
 .SH "COPYING"
 Copyright (C) 2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man1/sview.1 b/doc/man/man1/sview.1
index ecbe0fc5281adde840483accab995f12b749cabe..a6ca8cf1fb879665d05e56741e0c4c97aa477b9d 100644
--- a/doc/man/man1/sview.1
+++ b/doc/man/man1/sview.1
@@ -49,7 +49,7 @@ the sview command.
 .SH "COPYING"
 Copyright (C) 2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_allocate_resources.3 b/doc/man/man3/slurm_allocate_resources.3
index 1c143f701b19a3733d02354f5ee14886b2e542b4..e74f053d21e8e00c6f969164a82f0b1a15bad1eb 100644
--- a/doc/man/man3/slurm_allocate_resources.3
+++ b/doc/man/man3/slurm_allocate_resources.3
@@ -258,7 +258,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_checkpoint_error.3 b/doc/man/man3/slurm_checkpoint_error.3
index fe98352bb2e3ffb05d45c9342dac9aaf8882ff5a..3a5fcf213939dd1625f6e33a5ae78a919e99f4e3 100644
--- a/doc/man/man3/slurm_checkpoint_error.3
+++ b/doc/man/man3/slurm_checkpoint_error.3
@@ -219,7 +219,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2004 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_complete_job.3 b/doc/man/man3/slurm_complete_job.3
index 41e045769616b7e9fdbae4197e153436c20345b1..5c3a1221b74a3f1ae18a1a94eb6c05f0ef65ed9f 100644
--- a/doc/man/man3/slurm_complete_job.3
+++ b/doc/man/man3/slurm_complete_job.3
@@ -75,7 +75,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2002 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_free_ctl_conf.3 b/doc/man/man3/slurm_free_ctl_conf.3
index 0c32f5b05235001aeec2334922a63a431a3b5e13..04faaed7a5a8e4e361bfd18a18d1efe7e34e9100 100644
--- a/doc/man/man3/slurm_free_ctl_conf.3
+++ b/doc/man/man3/slurm_free_ctl_conf.3
@@ -148,7 +148,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2002\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_free_job_info_msg.3 b/doc/man/man3/slurm_free_job_info_msg.3
index c4e4cb6449b876f92a93dcda7a5a311b1608a72a..4471ae0cb5a724fc48f8db7bbbf466a1d0227e77 100644
--- a/doc/man/man3/slurm_free_job_info_msg.3
+++ b/doc/man/man3/slurm_free_job_info_msg.3
@@ -332,7 +332,7 @@ expressions into a collection of individual node names.
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_free_job_step_info_response_msg.3 b/doc/man/man3/slurm_free_job_step_info_response_msg.3
index c692a015370b85c17a342939723b63bea41e6d8d..cc76f32dfe89708a581389b25241f92af19d95a3 100644
--- a/doc/man/man3/slurm_free_job_step_info_response_msg.3
+++ b/doc/man/man3/slurm_free_job_step_info_response_msg.3
@@ -204,7 +204,7 @@ expressions into a collection of individual node names.
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_free_node_info.3 b/doc/man/man3/slurm_free_node_info.3
index f94fe37f94e159d6283ed7167940113195b7f5dd..3ce4424e44fcb1c8e7c71829bb030f64c62908b0 100644
--- a/doc/man/man3/slurm_free_node_info.3
+++ b/doc/man/man3/slurm_free_node_info.3
@@ -241,7 +241,7 @@ data, these index values will be invalid.
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_free_partition_info.3 b/doc/man/man3/slurm_free_partition_info.3
index dee723fe2808a776bd35f96be34a4206b833cc6c..37191e03bcd4f7da81195a053fdfd2b95ebe1044 100644
--- a/doc/man/man3/slurm_free_partition_info.3
+++ b/doc/man/man3/slurm_free_partition_info.3
@@ -189,7 +189,7 @@ expressions into a collection of individual node names.
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_get_errno.3 b/doc/man/man3/slurm_get_errno.3
index 84b8c008b0dc507c761d43f6010041c696c54c25..d80bf817c8521297d98b0ed3488441e8ac101a23 100644
--- a/doc/man/man3/slurm_get_errno.3
+++ b/doc/man/man3/slurm_get_errno.3
@@ -74,7 +74,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2002 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_hostlist_create.3 b/doc/man/man3/slurm_hostlist_create.3
index 1f9cea53d0e9f1fc8a6af667c57a61f1f23dd4d4..d08f47feb1e86c75506a4219ac864cf900c18307 100644
--- a/doc/man/man3/slurm_hostlist_create.3
+++ b/doc/man/man3/slurm_hostlist_create.3
@@ -108,7 +108,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_job_step_create.3 b/doc/man/man3/slurm_job_step_create.3
index 22fec53ab7ee7d78e5294be92553dfc56a86693a..67d848ba0194d2022544229e6329627f1cede663 100644
--- a/doc/man/man3/slurm_job_step_create.3
+++ b/doc/man/man3/slurm_job_step_create.3
@@ -75,7 +75,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2002-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_kill_job.3 b/doc/man/man3/slurm_kill_job.3
index 3b2e4470266d9ae5f3bbb28388321abbcaffd84c..0f6685bcfea73a026c912c1a0b85a5574e815b1a 100644
--- a/doc/man/man3/slurm_kill_job.3
+++ b/doc/man/man3/slurm_kill_job.3
@@ -76,7 +76,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2002 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_reconfigure.3 b/doc/man/man3/slurm_reconfigure.3
index 769bddfd15d52570e95a6e68a4304185aa2830b1..ee6b45e26a866e109f676ff50ea762e470680602 100644
--- a/doc/man/man3/slurm_reconfigure.3
+++ b/doc/man/man3/slurm_reconfigure.3
@@ -1,4 +1,4 @@
-.TH "Slurm API" "3" "October 2005" "Morris Jette" "Slurm administrative calls"
+.TH "Slurm API" "3" "May 2007" "Morris Jette" "Slurm administrative calls"
 .SH "NAME"
 slurm_delete_partition, slurm_init_part_desc_msg,
 slurm_reconfigure, slurm_shutdown, slurm_update_job, 
@@ -92,8 +92,8 @@ prior to setting values of the parameters to be changed. Note:
 values to zero. This function may only be successfully executed by user root. 
 Note the job priority of zero represents a job that will not be scheduled. 
 Slurm uses the priority one to represent jobs that can not be scheduled until 
-additional nodes are returned to service (i.e. not DOWN or DRAINED). This 
-permits lower priority jobs to utilize those resources which are available.
+additional nodes are returned to service (i.e. not DOWN, DRAINED, or FAILED). 
+This permits lower priority jobs to utilize those resources which are available.
 .LP 
 \fBslurm_update_node\fR Request that the state of one or more nodes be updated. 
 Note that the state of a node (e.g. DRAINING, IDLE, etc.) may be changed, but 
@@ -101,7 +101,7 @@ its hardware configuration may not be changed by this function. If the hardware
 configuration of a node changes, update the Slurm configuration file and execute 
 the \fBslurm_reconfigure\fR function. This function may only be successfully 
 executed by user root. If used by some autonomous program, the state value 
-most likely to be used is \fBNODE_STATE_DRAIN\fR. 
+most likely to be used is \fBNODE_STATE_DRAIN\fR or \fBNODE_STATE_FAILING\fR. 
 The node state flag \fBNODE_STATE_NO_RESPOND\fR may be specified without 
 changing the underlying node state. Note that the node's 
 \fBNODE_STATE_NO_RESPOND\fR flag will be cleared as soon as the slurmd 
@@ -242,9 +242,9 @@ which must be linked to your process for use
 (e.g. "cc \-lslurm myprog.c").
 
 .SH "COPYING"
-Copyright (C) 2002 The Regents of the University of California.
+Copyright (C) 2002\-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_resume.3 b/doc/man/man3/slurm_resume.3
index 9dc6729eead5bc36a5c09863dd8ff07bdf6b6943..c31c9741b0382adeea71c87550bd1a912342225f 100644
--- a/doc/man/man3/slurm_resume.3
+++ b/doc/man/man3/slurm_resume.3
@@ -75,7 +75,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2005\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_step_ctx_create.3 b/doc/man/man3/slurm_step_ctx_create.3
index ac62538fa297440833287fceedd897b05ef38f24..76f6cff977427c451794c568dc445e093eb4c263 100644
--- a/doc/man/man3/slurm_step_ctx_create.3
+++ b/doc/man/man3/slurm_step_ctx_create.3
@@ -204,7 +204,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2004-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man3/slurm_step_launch.3 b/doc/man/man3/slurm_step_launch.3
index 70f27685dbf81d66c21893af6257480d187c41d1..cda4e827e77415b7076d3ad995337f4ccd609703 100644
--- a/doc/man/man3/slurm_step_launch.3
+++ b/doc/man/man3/slurm_step_launch.3
@@ -183,7 +183,7 @@ which must be linked to your process for use
 .SH "COPYING"
 Copyright (C) 2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man5/bluegene.conf.5 b/doc/man/man5/bluegene.conf.5
index a059f07b561d41c69818eb11cb80b1701e35be2d..29bcb9520de49e1d3ffa428b49dacc2d42d8a2f5 100644
--- a/doc/man/man5/bluegene.conf.5
+++ b/doc/man/man5/bluegene.conf.5
@@ -1,4 +1,4 @@
-.TH "bluegene.conf" "5" "November 2006" "bluegene.conf 1.2" "Slurm configuration file"
+.TH "bluegene.conf" "5" "April 2008" "bluegene.conf 1.2" "Slurm configuration file"
 .SH "NAME"
 bluegene.conf \- Slurm configuration file for BlueGene systems 
 .SH "DESCRIPTION"
@@ -16,51 +16,6 @@ of the command "scontrol reconfigure" unless otherwise noted.
 .LP
 The overall configuration parameters available include:
 
-.TP
-\fBBasePartitionNodeCount\fR
-The number of c\-nodes per base partition.
-There is no default value and this must be specified.
-
-.TP
-\fBBridgeAPILogFile\fR
-Fully qualified pathname of a into which the Bridge API logs are 
-to be written.
-There is no default value.
-
-.TP
-\fBBridgeAPIVerbose\fR
-Specify how verbose the Bridge API logs should be.
-The default value is 0.
-.RS
-.TP
-\fB0\fR: Log only error and warning messages
-.TP
-\fB1\fR: Log level 0 and information messasges
-.TP
-\fB2\fR: Log level 1 and basic debug messages
-.TP
-\fB3\fR: Log level 2 and more debug message
-.TP
-\fB4\fR: Log all messages
-.RE
-
-.TP
-\fBBlrtsImage\fR
-BlrtsImage used for creation of all bgblocks.
-There is no default value and this must be specified.
-.TP
-\fBLinuxImage\fR
-LinuxImage used for creation of all bgblocks.
-There is no default value and this must be specified.
-.TP
-\fBMloaderImage\fR
-MloaderImage used for creation of all bgblocks.
-There is no default value and this must be specified.
-.TP
-\fBRamDiskImage\fR
-RamDiskImage used for creation of all bgblocks.
-There is no default value and this must be specified.
-
 .TP
 \fBAltBlrtsImage\fR
 Alternative BlrtsImage.  This is an optional field only used for 
@@ -93,6 +48,40 @@ the user groups allowed to use this image (i.e. Groups=da,jette) if
 Groups= is not stated then this image will be able to be used by all
 groups. You can but as many alternative images as you want in the conf file.
 
+.TP
+\fBBasePartitionNodeCount\fR
+The number of c\-nodes per base partition.
+There is no default value and this must be specified. (For bgl systems this
+is usually 512)
+
+.TP
+\fBBlrtsImage\fR
+BlrtsImage used for creation of all bgblocks.
+There is no default value and this must be specified.
+
+.TP
+\fBBridgeAPILogFile\fR
+Fully qualified pathname of a into which the Bridge API logs are 
+to be written.
+There is no default value.
+
+.TP
+\fBBridgeAPIVerbose\fR
+Specify how verbose the Bridge API logs should be.
+The default value is 0.
+.RS
+.TP
+\fB0\fR: Log only error and warning messages
+.TP
+\fB1\fR: Log level 0 and information messasges
+.TP
+\fB2\fR: Log level 1 and basic debug messages
+.TP
+\fB3\fR: Log level 2 and more debug message
+.TP
+\fB4\fR: Log all messages
+.RE
+
 .TP
 \fBLayoutMode\fR
 Describes how SLURM should create bgblocks.
@@ -112,15 +101,34 @@ and starvation of larger jobs.
 \fBUse this mode with caution.\fR
 .RE
 
+.TP
+\fBLinuxImage\fR
+LinuxImage used for creation of all bgblocks.
+There is no default value and this must be specified.
+
+.TP
+\fBMloaderImage\fR
+MloaderImage used for creation of all bgblocks.
+There is no default value and this must be specified.
+
 .TP
 \fBNodeCardNodeCount\fR
 Number of c\-nodes per node card.
-There is no default value and this must be specified.
+There is no default value and this must be specified. (For bgl systems this 
+is usually 32)
 
 .TP
 \fBNumPsets\fR
 The Numpsets used for creation of all bgblocks  equals this value 
 multiplied by the number of  base partitions in the bgblock.
+There is no default value and this must be specified.  The typical settings
+for bgl systems goes as follows... For IO rich systems 64 is the value that 
+should be used to create small blocks.  For systems that are not IO rich, or 
+you do not wish to create small blocks, 8 is usually the number to use.
+
+.TP
+\fBRamDiskImage\fR
+RamDiskImage used for creation of all bgblocks.
 There is no default value and this must be specified.
 
 .LP
@@ -188,7 +196,7 @@ BasePartitionNodeCnt=512
 .br
 NodeCardNodeCnt=32
 .br
-NumPsets=8
+NumPsets=64	# An I/O rich environment
 .br
 LayoutMode=STATIC
 .br
@@ -217,7 +225,7 @@ BPs=[333x333] Type=SMALL NodeCards=4 Quarters=3 # 1/16 * 4 + 1/4 * 3
 .SH "COPYING"
 Copyright (C) 2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man5/slurm.conf.5 b/doc/man/man5/slurm.conf.5
index a49f3ada397fe13a9abbba2cd62e4987fde1b057..fb26318c4010335afa3940923593c69da6188e0b 100644
--- a/doc/man/man5/slurm.conf.5
+++ b/doc/man/man5/slurm.conf.5
@@ -1,11 +1,12 @@
-.TH "slurm.conf" "5" "July 2007" "slurm.conf 1.2" "Slurm configuration file"
+.TH "slurm.conf" "5" "May 2008" "slurm.conf 1.3" "Slurm configuration file"
 .SH "NAME"
 slurm.conf \- Slurm configuration file 
 .SH "DESCRIPTION"
 \fB/etc/slurm.conf\fP is an ASCII file which describes general SLURM
 configuration information, the nodes to be managed, information about
 how those nodes are grouped into partitions, and various scheduling
-parameters associated with those partitions.
+parameters associated with those partitions. This file should be
+consistent across all nodes in the cluster.
 .LP
 The file location can be modified at system build time using the
 DEFAULT_SLURM_CONF parameter. In addition, you can use the
@@ -14,6 +15,12 @@ location of this file. The SLURM daemons also allow you to override
 both the built\-in and environment\-provided location using the "\-f"
 option on the command line.
 .LP
+Note the while SLURM daemons create log files and other files as needed, 
+it treats the lack of parent directories as a fatal error. 
+This prevents the daemons from running if critical file systems are
+not mounted and will minimize the risk of cold\-starting (starting 
+without preserving jobs).
+.LP
 The contents of the file are case insensitive except for the names of nodes 
 and partitions. Any text following a "#" in the configuration file is treated 
 as a comment through the end of that line. 
@@ -27,6 +34,81 @@ and then a file name, that file will be included inline with the current
 configuration file.
 .LP
 The overall configuration parameters available include:
+
+.TP
+\fBAccountingStorageEnforce\fR
+If set to a non-zero value and the user, partition, account association is not 
+defined for a job in the accounting database then prevent the job from being 
+executed.
+The default value is zero.
+
+.TP
+\fBAccountingStorageHost\fR
+Define the name of the host where the database is running we are going
+to store the accounting data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBDefaultStorageHost\fR.
+
+.TP
+\fBAccountingStorageLoc\fR
+Specifies the location of the file or database where accounting 
+records are written.
+Also see \fBDefaultStorageLoc\fR.
+
+.TP
+\fBAccountingStoragePass\fR
+Define the password used to gain access to the database to store the
+accounting data.
+Only used for database type storage plugins, ignored otherwise.
+In the case of Slurm DBD (Data Base Daemon) with Munge authentication this can be 
+configured to use a Munge daemon specifically configured to provide authentication 
+between clusters while the default Munge daemon provides authentication within a cluster. 
+In that case, \fBAccountingStoragePass\fR should specify the named port to be used
+for communications with the alternate Munge daemon (e.g. 
+"/var/run/munge/global.socket.2"). The default value is NULL.
+Also see \fBDefaultStoragePass\fR.
+
+.TP
+\fBAccountingStoragePort\fR
+Define the port the database server is listening on where we are going
+to store the accounting data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBDefaultStoragePort\fR.
+
+.TP
+\fBAccountingStorageType\fR
+Define the accounting storage mechanism type.
+Acceptable values at present include 
+"accounting_storage/filetxt", "accounting_storage/gold",
+"accounting_storage/mysql", "accounting_storage/none", 
+"accounting_storage/pgsql", and "accounting_storage/slurmdbd".
+The value "accounting_storage/filetxt" indicates that accounting records
+will be written to a the file specified by the 
+\fBAccountingStorageLoc\fR parameter.
+The value "accounting_storage/gold" indicates that account records
+will be written to Gold
+(http://www.clusterresources.com/pages/products/gold-allocation-manager.php),
+which maintains its own database.
+The value "accounting_storage/mysql" indicates that accounting records
+should be written to a MySQL database specified by the 
+\fBAccountingStorageLoc\fR parameter.
+The default value is "accounting_storage/none", which means that
+account records are not maintained. 
+The value "accounting_storage/pgsql" indicates that accounting records
+should be written to a PostgreSQL database specified by the 
+\fBAccountingStorageLoc\fR parameter.
+The value "accounting_storage/slurmdbd" indicates that accounting records
+will be written to SlurmDDB, which manages an underlying MySQL or 
+PostgreSQL database. See "man slurmdbd" for more information.
+Also see \fBDefaultStorageType\fR.
+
+.TP
+\fBAccountingStorageUser\fR
+Define the name of the user we are going to connect to the database
+with to store the accounting data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBDefaultStorageUser\fR.
+
 .TP
 \fBAuthType\fR
 Define the authentication method for communications between SLURM 
@@ -38,13 +120,15 @@ communication messages is not verified.
 This may be fine for testing purposes, but 
 \fBdo not use "auth/none" if you desire any security\fR.
 "auth/authd" indicates that Brett Chun's authd is to be used (see
-"http://www.theether.org/authd/" for more information).
-"auth/munge" indicates that Chris Dunlap's munge is to be used
+"http://www.theether.org/authd/" for more information, Note that
+authd is no longer actively supported).
+"auth/munge" indicates that LLNL's MUNGE is to be used
 (this is the best supported authentication mechanism for SLURM, 
-see "https://computing.llnl.gov/linux/munge/" for more information).
+see "http://home.gna.org/munge/" for more information).
 All SLURM daemons and commands must be terminated prior to changing 
 the value of \fBAuthType\fR and later restarted (SLURM jobs can be 
 preserved).
+
 .TP
 \fBBackupAddr\fR
 Name that \fBBackupController\fR should be referred to in 
@@ -76,15 +160,21 @@ The default value is 0 to disable caching group data.
 .TP
 \fBCheckpointType\fR
 Define the system\-initiated checkpoint method to be used for user jobs. 
-The slurmctld daemon must be restarted for a change in CheckpointType 
+The slurmctld daemon must be restarted for a change in \fBCheckpointType\fR 
 to take effect. 
 Acceptable values at present include
 "checkpoint/aix" (only on AIX systems),
-"checkpoint/ompi" (requires OpenMPI version 1.3 or higher), and
+"checkpoint/ompi" (requires OpenMPI version 1.3 or higher),
+"checkpoint/xlch" (for XLCH, requires that SlurmUser be root), and
 "checkpoint/none".
-(only on AIX systems). 
 The default value is "checkpoint/none".
 
+.TP
+\fBClusterName\fR
+The name by which this SLURM managed cluster is known for accounting 
+purposes. This is needed distinguish between accounting data from 
+multiple clusters being recorded in a single database.
+
 .TP
 \fBControlAddr\fR
 Name that \fBControlMachine\fR should be referred to in 
@@ -97,23 +187,108 @@ By default the \fBControlAddr\fR will be identical in value to
 
 .TP
 \fBControlMachine\fR
-The name of the machine where SLURM control functions are executed. 
-This should be a node name without the full domain name (e.g. "lx0001"). 
+The name of the machine where SLURM control functions are executed
+as returned by the \fIgethostname()\fR function the cut at the first dot
+or the \fIhostname \-s\fR command (e.g. use "tux001" rather than "tux001.my.com"). 
 This value must be specified.
 See  the \fBRELOCATING CONTROLLERS\fR section if you change this.
 
+.TP
+\fBCryptoType\fR
+Define the cryptographic signature tool to be used in the creation of 
+job step credentials.
+The slurmctld daemon must be restarted for a change in \fBCryptoType\fR
+to take effect.
+Acceptable values at present include "crypto/munge" and "crypto/openssl".
+OpenSSL offers the best performance and is available with an 
+Apache style open source license.
+Munge is a little slower, but is available under the Gnu General Public 
+License (GPL).
+The default value is "crypto/openssl".
 
 .TP
-\fBDisableRootJobs\fR
-If set to 1 then user root will be prevented from running any jobs
-The default value is 0, meaning user root will be able to execute jobs.
+\fBDefMemPerTask\fR
+Default real memory size available per task in MegaBytes. 
+Used to avoid over\-subscribing memory and causing paging.
+Also see \fBMaxMemPerTask\fR.
+The default value is 0 (unlimited).
 
 .TP
+\fBDefaultStorageHost\fR
+Define the name of the host where the database is running and used to
+to store the accounting and job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBAccountingStorageHost\fR and \fBJobCompHost\fR.
+
+.TP
+\fBDefaultStorageLoc\fR
+Specifies the location of the file or database where accounting 
+and job completion records are written.
+Also see \fBAccountingStorageLoc\fR and \fBJobCompLoc\fR.
+
+.TP
+\fBDefaultStoragePass\fR
+Define the password used to gain access to the database to store the
+accounting and job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBAccountingStoragePass\fR and \fBJobCompPass\fR.
+
+.TP
+\fBDefaultStoragePort\fR
+Define the port the database server is listening on where we are going
+to store the accounting and job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBAccountingStoragePort\fR and \fBJobCompPort\fR.
+
+.TP
+\fBDefaultStorageType\fR
+.ad l
+Define the accounting and job completion storage mechanism type.
+Acceptable values at present include 
+"filetxt", "gold", "mysql", "none", "pgsql", and "slurmdbd".
+The value "filetxt" indicates that records will be written to a the file.
+The value "gold" indicates that records will be written to Gold
+(http://www.clusterresources.com/pages/products/gold-allocation-manager.php),
+which maintains its own database.
+The value "mysql" indicates that accounting records will be written to 
+a mysql database.
+The default value is "none", which means that records are not maintained. 
+The value "pgsql" indicates that records will be written to a postresql 
+database.
+The value "slurmdbd" indicates that records will be written to SlurmDbd,
+which maintains its own database. See "man slurmdbd for more information".
+Also see \fBAccountingStorageType\fR  and \fBJobCompType\fR.
+.ad
+
+.TP
+\fBDefaultStorageUser\fR
+Define the name of the user we are going to connect to the database
+with to store the accounting and job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBAccountingStorageUser\fR and \fBJobCompUser\fR.
+
+.TP
+\fBDisableRootJobs\fR
+If set to "YES" then user root will be prevented from running any jobs.
+The default value is "NO", meaning user root will be able to execute jobs.
+\fBDisableRootJobs\fR may also be set by partition.
+
 \fBEpilog\fR
 Fully qualified pathname of a script to execute as user root on every 
 node when a user's job completes (e.g. "/usr/local/slurm/epilog"). This may 
 be used to purge files, disable user login, etc. By default there is no epilog.
 
+.TP
+\fBEpilogMsgTime\fR
+The number of microseconds the the slurmctld daemon requires to process
+an epilog completion message from the slurmd dameons. This parameter can
+be used to prevent a burst of epilog completion messages from being sent 
+at the same time which should help prevent lost messages and improve 
+throughput for large jobs.
+The default value is 2000 microseconds.
+For a 1000 node job, this spreads the epilog completion messages out over
+two seconds.
+
 .TP
 \fBFastSchedule\fR
 Controls how a nodes configuration specifications in slurm.conf are used.
@@ -131,7 +306,7 @@ Consider which value you want to be used for scheduling purposes.
 \fB1\fR (default)
 Consider the configuration of each node to be that specified in the
 configuration file and any node with less
-than the configured resouces will be set DOWN.
+than the configured resources will be set DOWN.
 .TP
 \fB0\fR
 Base scheduling decisions upon the actual configuration of 
@@ -160,10 +335,22 @@ load it from a cache file. Applies when the srun or sbatch
 \fI--get-user-env\fR option is used. Default value is 2 seconds.
 
 .TP
-\fBHeartbeatInterval\fR
-Defunct paramter. 
-Interval of heartbeat for slurmd daemon is half of \fBSlurmdTimeout\fR. 
-Interval of heartbeat for  slurmctld daemon is half of \fBSlurmctldTimeout\fR.
+\fBHealthCheckInterval\fR
+The interval in seconds between executions of \fBHealthCheckProgram\fR.
+The default value is zero, which disables execution.
+
+.TP
+\fBHealthCheckProgram\fR
+Fully qualified pathname of a script to execute as user root periodically 
+on all compute nodes that are not in the DOWN state. This may be used to 
+verify the node is fully operational and DRAIN the it otherwise.
+The interval is controlled using the \fBHealthCheckInterval\fR parameter.
+Note that the \fBHealthCheckProgram\fR will be executed at the same time 
+on all nodes to minimize its impact upon parallel programs.
+This program is will be killed if it does not terminate normally within
+60 seconds. 
+By default, no program will be executed.
+
 .TP
 \fBInactiveLimit\fR
 The interval, in seconds, a job or job step is permitted to be inactive
@@ -182,49 +369,93 @@ This limit is ignored for jobs running in partitions with the
 responsible for the job).
 The default value is unlimited (zero). 
 May not exceed 65533.
+
 .TP
-\fBJobAcctType\fR
+\fBJobAcctGatherType\fR
 Define the job accounting mechanism type.
-Acceptable values at present include "jobacct/aix" (for AIX operating
-system), "jobacct/linux" (for Linux operating system) and "jobacct/none"
+Acceptable values at present include "jobacct_gather/aix" (for AIX operating
+system), "jobacct_gather/linux" (for Linux operating system) and "jobacct_gather/none"
 (no accounting data collected).
-The default value is "jobacct/none".
-In order to use the \fBsacct\fR tool, "jobacct/aix" or "jobacct/linux" 
+The default value is "jobacct_gather/none".
+In order to use the \fBsacct\fR tool, "jobacct_gather/aix" or "jobacct_gather/linux" 
 must be configured.
+
 .TP
-\fBJobAcctLogFile\fR
-Define the location where job accounting logs are to be written.
-For jobacct/none this parameter is ignored.
-For jobacct/linux this is the fully\-qualified file name for the data file.
+\fBJobAcctGatherFrequency\fR
+Define the job accounting sampling interval.
+For jobacct_gather/none this parameter is ignored.
+For  jobacct_gather/aix and jobacct_gather/linux the parameter is a number is 
+seconds between sampling job state.
+The default value is 30 seconds. 
+A value of zero disables real the periodic job sampling and provides accounting 
+information only on job termination (reducing SLURM interference with the job).
+
 .TP
-\fBJobAcctFrequency\fR
-Define the polling frequencys to pass to the job accounting plugin.
-For jobacct/none this parameter is ignored.
-For jobacct/linux the parameter is a number is seconds between polls.
+\fBJobCompHost\fR
+Define the name of the host where the database is running and used
+to store the job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBDefaultStorageHost\fR.
+
 .TP
 \fBJobCompLoc\fR
 The interpretation of this value depends upon the logging mechanism 
-specified by the \fBJobCompType\fR parameter. 
+specified by the \fBJobCompType\fR parameter either a filename or a 
+database name. 
+Also see \fBDefaultStorageLoc\fR.
+
+.TP
+\fBJobCompPass\fR
+Define the password used to gain access to the database to store the job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBDefaultStoragePass\fR.
+
+.TP
+\fBJobCompPort\fR
+Define the port the database server is listening on where we are going
+to store the job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBDefaultStoragePort\fR.
+
 .TP
 \fBJobCompType\fR
 Define the job completion logging mechanism type.
 Acceptable values at present include "jobcomp/none", "jobcomp/filetxt", 
-and "jobcomp/script".
+"jobcomp/mysql", "jobcomp/pgsql", "jobcomp/script"and "jobcomp/slurmdbd".
 The default value is "jobcomp/none", which means that upon job completion 
 the record of the job is purged from the system. 
 The value "jobcomp/filetxt" indicates that a record of the job should be 
 written to a text file specified by the \fBJobCompLoc\fR parameter.
+The value "jobcomp/mysql" indicates that a record of the job should be 
+written to a mysql database specified by the \fBJobCompLoc\fR parameter.
+The value "jobcomp/pgsql" indicates that a record of the job should be 
+written to a postgresql database specified by the \fBJobCompLoc\fR parameter.
 The value "jobcomp/script" indicates that a script specified by the 
 \fBJobCompLoc\fR parameter is to be executed with environment variables 
 indicating the job information.
+The value "jobcomp/slurmdbd" indicates that job completion records
+will be written to SlurmDbd, which maintains its own database. See 
+"man slurmdbd" for more information.
+Also see \fBDefaultStorageType\fR.
+
+.TP
+\fBJobCompUser\fR
+Define the name of the user we are going to connect to the database
+with to store the job completion data.
+Only used for database type storage plugins, ignored otherwise.
+Also see \fBDefaultStorageUser\fR.
+
 .TP
 \fBJobCredentialPrivateKey\fR
 Fully qualified pathname of a file containing a private key used for 
 authentication by Slurm daemons.
+This parameter is ignored if \fBCryptType=munge\fR.
+
 .TP
 \fBJobCredentialPublicCertificate\fR
 Fully qualified pathname of a file containing a public key used for 
 authentication by Slurm daemons.
+This parameter is ignored if \fBCryptType=munge\fR.
 
 .TP
 \fBJobFileAppend\fR
@@ -233,22 +464,40 @@ exist when the job is started.
 If \fBJobFileAppend\fR is set to a value of 1, then append to 
 the existing file.
 By default, any existing file is truncated.
-NOTE: This variable does not appear in the output of the command
-"scontrol show config" in versions of SLURM less than version 1.3.
 
 .TP
-\fBKillTree\fR
-This option is mapped to "ProctrackType=proctrack/linuxproc". 
-It will be removed from a future release.
+\fBJobRequeue\fR
+This option controls what to do by default after a node failure. 
+If \fBJobRequeue\fR is set to a value of 1, then any job running 
+on the failed node will be requeued for execution on different nodes.
+If \fBJobRequeue\fR is set to a value of 0, then any job running 
+on the failed node will be terminated.
+Use the \fBsbatch\fR \fI\-\-no\-requeue\fR or \fI\-\-requeue\fR 
+option to change the default behavior for individual jobs.
+The default value is 1.
+
 .TP
 \fBKillWait\fR
 The interval, in seconds, given to a job's processes between the 
 SIGTERM and SIGKILL signals upon reaching its time limit. 
 If the job fails to terminate gracefully 
-in the interval specified, it will be forcably terminated. 
+in the interval specified, it will be forcibly terminated. 
 The default value is 30 seconds.
 May not exceed 65533.
 
+.TP
+\fBLicenses\fR
+Specification of licenses (or other resources available on all 
+nodes of the cluster) which can be allocated to jobs.
+License names can optionally be followed by an asterisk 
+and count with a default count of one.
+Multiple license names should be comma separated (e.g.
+"Licenses=foo*4,bar").
+Note that SLURM prevents jobs from being scheduled if their 
+required license specification is not available.
+SLURM does not prevent jobs from using licenses that are
+not explicitly listed in the job submission specification.
+
 .TP
 \fBMailProg\fR
 Fully qualified pathname to the program used to send email per user request.
@@ -260,11 +509,18 @@ The maximum number of jobs SLURM can have in its active database
 at one time. Set the values of \fBMaxJobCount\fR and \fBMinJobAge\fR 
 to insure the slurmctld daemon does not exhaust its memory or other 
 resources. Once this limit is reached, requests to submit additional 
-jobs will fail. The default value is 2000 jobs. This value may not 
+jobs will fail. The default value is 5000 jobs. This value may not 
 be reset via "scontrol reconfig". It only takes effect upon restart 
 of the slurmctld daemon.
 May not exceed 65533.
 
+.TP
+\fBMaxMemPerTask\fR
+Maximum real memory size available per task in MegaBytes. 
+Used to avoid over\-subscribing memory and causing paging.
+Also see \fBDefMemPerTask\fR.
+The default value is 0 (unlimited).
+
 .TP
 \fBMessageTimeout\fR
 Time permitted for a round\-trip communication to complete
@@ -297,6 +553,7 @@ Identifies the places in which to look for SLURM plugins.
 This is a colon\-separated list of directories, like the PATH 
 environment variable. 
 The default value is "/usr/local/lib/slurm".
+
 .TP
 \fBPlugStackConfig\fR
 Location of the config file for SLURM stackable plugins that use
@@ -306,6 +563,14 @@ be called before and/or after execution of each task spawned as
 part of a user's job step.  Default location is "plugstack.conf"
 in the same directory as the system slurm.conf. For more information
 on SPANK plugins, see the \fBspank\fR(8) manual.
+
+.TP
+\fBPrivateData\fR
+If non-zero then users are unable to view jobs or job steps belonging 
+to other users (except for SlurmUser or root, who can view all jobs).
+The default value is "0", permitting any user to view any jobs or 
+job steps.
+
 .TP
 \fBProctrackType\fR
 Identifies the plugin to be used for process tracking. 
@@ -323,7 +588,7 @@ NOTE: "proctrack/linuxproc" is not compatible with "switch/elan."
 Acceptable values at present include:
 .RS
 .TP 
-\fBproctrack/aix\fR which uses an AIX kernel extenstion and is 
+\fBproctrack/aix\fR which uses an AIX kernel extension and is 
 the default for AIX systems
 .TP
 \fBproctrack/linuxproc\fR which uses linux process tree using 
@@ -427,6 +692,37 @@ appearing in this list.   The user can override this by specifying which
 resource limits to propagate with the srun commands "\-\-propagate" option.
 See \fBPropagateResourceLimits\fR above for a list of valid limit names.
 
+.TP
+\fBResumeProgram\fR
+SLURM supports a mechanism to reduce power consumption on nodes that 
+remain idle for an extended period of time. 
+This is typically accomplished by reducing voltage and frequency. 
+\fBResumeProgram\fR is the program that will be executed when a node 
+in power save mode is assigned work to perform.
+The program executes as \fBSlurmUser\fR.
+The argument to the program will be the names of nodes to
+be removed from power savings mode (using SLURM's hostlist
+expression format).
+By default no program is run.
+Related configuration options include \fBResumeRate\fR, \fBSuspendRate\fR,
+\fBSuspendTime\fR, \fBSuspendProgram\fR, \fBSuspendExcNodes\fR, and
+\fBSuspendExcParts\fR.
+More information is available at the SLURM web site
+(https://computing.llnl.gov/linux/slurm/power_save.html).
+
+.TP
+\fBResumeRate\fR
+The rate at which nodes in power save mode are returned to normal 
+operation by \fBResumeProgram\fR. 
+The value is number of nodes per minute and it can be used to prevent 
+power surges if a large number of nodes in power save mode are 
+assigned work at the same time (e.g. a large job starts).
+A value of zero results in no limits being imposed.
+The default value is 60 nodes per minute.
+Related configuration options include \fBResumeProgram\fR, \fBSuspendRate\fR,
+\fBSuspendTime\fR, \fBSuspendProgram\fR, \fBSuspendExcNodes\fR, and
+\fBSuspendExcParts\fR.
+
 .TP
 \fBReturnToService\fR
 If set to 1, then a non\-responding (DOWN) node will become available 
@@ -437,18 +733,13 @@ failure, etc.), its state will not automatically be changed.  The
 default value is 0, which means that a node will remain in the 
 DOWN state until a system administrator explicitly changes its state
 (even if the slurmd daemon registers and resumes communications).
-.TP
-\fBSchedulerRootFilter\fR
-If set to '1' then scheduler will filter and avoid \fBRootOnly\fR 
-partitions (let root user or process schedule these partitions).
-Otherwise scheduler will treat \fBRootOnly\fR partitions as any 
-other standard partition.
-Currently only supported by sched/backfill schedululer plugin.
+
 .TP
 \fBSchedulerPort\fR
 The port number on which slurmctld should listen for connection requests.
 This value is only used by the Maui Scheduler (see \fBSchedulerType\fR).
 The default value is 7321.
+
 .TP
 \fBSchedulerRootFilter\fR
 Identifies whether or not \fBRootOnly\fR partitions should be filtered from
@@ -457,12 +748,19 @@ are treated like any other partition. If set to 1, then \fBRootOnly\fR
 partitions are exempt from any external scheduling activities. The
 default value is 1. Currently only used by the built\-in backfill
 scheduling module "sched/backfill" (see \fBSchedulerType\fR).
+
+.TP
+\fBSchedulerTimeSlice\fR
+Number of seconds in each time slice when \fBSchedulerType=sched/gang\fR.
+The default value is 30.
+
 .TP
 \fBSchedulerType\fR
 Identifies the type of scheduler to be used. Acceptable values include 
 "sched/builtin" for the built\-in FIFO scheduler, 
 "sched/backfill" for a backfill scheduling module to augment 
 the default FIFO scheduling, 
+"sched/gang" for gang scheduler (time\-slicing of parallel jobs),
 "sched/hold" to hold all newly arriving jobs if a file "/etc/slurm.hold" 
 exists otherwise use the built\-in FIFO scheduler, and 
 "sched/wiki" for the Wiki interface to the Maui Scheduler. 
@@ -481,6 +779,7 @@ should have their priority change from zero to some large number.
 The \fBscontrol\fR command can be used to change job priorities.
 The \fBslurmctld\fR daemon must be restarted for a change in 
 scheduler type to become effective.
+
 .TP
 \fBSelectType\fR
 Identifies the type of resource selection algorithm to be used. 
@@ -489,7 +788,7 @@ Acceptable values include
 .TP
 \fBselect/linear\fR
 for allocation of entire nodes assuming a
-one\-dimentional array of nodes in which sequentially ordered 
+one\-dimensional array of nodes in which sequentially ordered 
 nodes are preferable. 
 This is the default value for non\-BlueGene systems. 
 .TP
@@ -497,23 +796,29 @@ This is the default value for non\-BlueGene systems.
 The resources within a node are individually allocated as
 consumable resources. 
 Note that whole nodes can be allocated to jobs for selected 
-partitions by using the \fIShared=EXCLUSIVE\fR option.
+partitions by using the \fIShared=Exclusive\fR option.
 See the partition \fBShared\fR parameter for more information.
 .TP
 \fBselect/bluegene\fR
-for a three\-dimentional BlueGene system. 
+for a three\-dimensional BlueGene system. 
 The default value is "select/bluegene" for BlueGene systems.
 .RE
 
 .TP
 \fBSelectTypeParameters\fR
-This only apply for \fISelectType=select/cons_res\fR.
+The permitted values of \fBSelectTypeParameters\fR depend upon the 
+configured value of \fBSelectType\fR.
+\fBSelectType=select/bluegene\fR supports no \fBSelectTypeParameters\fR.
+The only supported option for \fBSelectType=select/linear\fR is 
+\fBCR_Memory\fR, which treats memory as a consumable resource and 
+prevents memory over subscription with job preemption or gang scheduling.
+The following values are supported for \fBSelectType=select/cons_res\fR:
 .RS
 .TP
 \fBCR_CPU\fR
 CPUs are consumable resources.
 There is no notion of sockets, cores or threads.
-On a multi\-core system, each core will be consided a CPU.
+On a multi\-core system, each core will be considered a CPU.
 On a multi\-core and hyperthreaded system, each thread will be
 considered a CPU.
 On single\-core systems, each CPUs will be considered a CPU.
@@ -535,7 +840,7 @@ Memory and CPUs are consumable resources.
 .TP
 \fBCR_Memory\fR
 Memory is a consumable resource.
-NOTE: This implies \fIShared=Yes\fR for all partitions.
+NOTE: This implies \fIShared=YES\fR or \fIShared=FORCE\fR for all partitions.
 .RE
 
 .TP
@@ -543,22 +848,26 @@ NOTE: This implies \fIShared=Yes\fR for all partitions.
 The name of the user that the \fBslurmctld\fR daemon executes as. 
 For security purposes, a user other than "root" is recommended.
 The default value is "root". 
+
 .TP
 \fBSlurmctldDebug\fR
 The level of detail to provide \fBslurmctld\fR daemon's logs. 
 Values from 0 to 7 are legal, with `0' being "quiet" operation and `7' 
 being insanely verbose.
 The default value is 3.
+
 .TP
 \fBSlurmctldLogFile\fR
 Fully qualified pathname of a file into which the \fBslurmctld\fR daemon's 
 logs are written.
 The default value is none (performs logging via syslog).
+
 .TP
 \fBSlurmctldPidFile\fR
 Fully qualified pathname of a file into which the  \fBslurmctld\fR daemon 
 may write its process id. This may be used for automated signal processing.
 The default value is "/var/run/slurmctld.pid".
+
 .TP
 \fBSlurmctldPort\fR
 The port number that the SLURM controller, \fBslurmctld\fR, listens 
@@ -567,18 +876,21 @@ build time. If none is explicitly specified, it will be set to 6817.
 NOTE: Either \fBslurmctld\fR and \fBslurmd\fR daemons must not 
 execute on the same nodes or the values of \fBSlurmctldPort\fR and 
 \fBSlurmdPort\fR must be different.
+
 .TP
 \fBSlurmctldTimeout\fR
 The interval, in seconds, that the backup controller waits for the 
 primary controller to respond before assuming control. 
 The default value is 120 seconds.
 May not exceed 65533.
+
 .TP
 \fBSlurmdDebug\fR
 The level of detail to provide \fBslurmd\fR daemon's logs. 
 Values from 0 to 7 are legal, with `0' being "quiet" operation and `7' being 
 insanely verbose.
 The default value is 3.
+
 .TP
 \fBSlurmdLogFile\fR
 Fully qualified pathname of a file into which the  \fBslurmd\fR daemon's 
@@ -586,11 +898,13 @@ logs are written.
 The default value is none (performs logging via syslog).
 Any "%h" within the name is replaced with the hostname on which the 
 \fBslurmd\fR is running.
+
 .TP
 \fBSlurmdPidFile\fR
 Fully qualified pathname of a file into which the  \fBslurmd\fR daemon may write 
 its process id. This may be used for automated signal processing.
 The default value is "/var/run/slurmd.pid".
+
 .TP
 \fBSlurmdPort\fR
 The port number that the SLURM compute node daemon, \fBslurmd\fR, listens 
@@ -599,6 +913,7 @@ build time. If none is explicitly specified, its value will be 6818.
 NOTE: Either slurmctld and slurmd daemons must not execute
 on the same nodes or the values of \fBSlurmctldPort\fR and \fBSlurmdPort\fR
 must be different.
+
 .TP
 \fBSlurmdSpoolDir\fR
 Fully qualified pathname of a directory into which the \fBslurmd\fR
@@ -611,6 +926,7 @@ shared memory lockfile, and \fBshould not be changed\fR unless the system
 is being cleanly restarted. If the location of \fBSlurmdSpoolDir\fR is
 changed and \fBslurmd\fR is restarted, the new daemon will attach to a
 different shared memory region and lose track of any running jobs.
+
 .TP
 \fBSlurmdTimeout\fR
 The interval, in seconds, that the SLURM controller waits for \fBslurmd\fR 
@@ -622,6 +938,21 @@ a DOWN state indicating a non\-responsive \fBslurmd\fR, and some other tool
 will take responsibility for monitoring the state of each compute node 
 and its \fBslurmd\fR daemon.
 The value may not exceed 65533.
+
+.TP
+\fBSrunEpilog\fR
+Fully qualified pathname of an executable to be run by srun following the
+completion of a job step.  The command line arguments for the executable will
+be the command and arguments of the job step.  This configuration parameter
+may be overridden by srun's \fB\-\-epilog\fR parameter.
+
+.TP
+\fBSrunProlog\fR
+Fully qualified pathname of an executable to be run by srun prior to the
+launch of a job step.  The command line arguments for the executable will
+be the command and arguments of the job step.  This configuration parameter
+may be overridden by srun's \fB\-\-prolog\fR parameter.
+
 .TP
 \fBStateSaveLocation\fR
 Fully qualified pathname of a directory into which the SLURM controller, 
@@ -630,21 +961,66 @@ SLURM state will saved here to recover from system failures.
 \fBSlurmUser\fR must be able to create files in this directory.
 If you have a \fBBackupController\fR configured, this location should be 
 readable and writable by both systems. 
+Since all running and pending job information is stored here, the use of 
+a reliable file system (e.g. RAID) is recommended.
 The default value is "/tmp".
 If any slurm daemons terminate abnormally, their core files will also be written 
 into this directory.
+
 .TP
-\fBSrunEpilog\fR
-Fully qualified pathname of an executable to be run by srun following the
-completion of a job step.  The command line arguments for the executable will
-be the command and arguments of the job step.  This configuration parameter
-may be overridden by srun's \fB\-\-epilog\fR parameter.
+\fBSuspendExcNodes\fR
+Specifies the nodes which are to not be placed in power save mode, even 
+if the node remains idle for an extended period of time.
+Use SLURM's hostlist expression to identify nodes.
+By default no nodes are excluded.
+Related configuration options include \fBResumeProgram\fR, \fBResumeRate\fR,
+\fBSuspendProgram\fR, \fBSuspendRate\fR, \fBSuspendTime\fR and
+\fBSuspendExcParts\fR.
+
 .TP
-\fBSrunProlog\fR
-Fully qualified pathname of an executable to be run by srun prior to the
-launch of a job step.  The command line arguments for the executable will
-be the command and arguments of the job step.  This configuration parameter
-may be overridden by srun's \fB\-\-prolog\fR parameter.
+\fBSuspendExcParts\fR
+Specifies the partitions whose nodes are to not be placed in power save 
+mode, even if the node remains idle for an extended period of time.
+Multiple partitions can be identified and separated by commas.
+By default no nodes are excluded.
+Related configuration options include \fBResumeProgram\fR, \fBResumeRate\fR,
+\fBSuspendProgram\fR, \fBSuspendRate\fR, \fBSuspendTime\fR and
+\fBSuspendExcNodes\fR.
+
+.TP
+\fBSuspendProgram\fR
+\fBSuspendProgram\fR is the program that will be executed when a node
+remains idle for an extended period of time.
+This program is expected to place the node into some power save mode.
+The program executes as \fBSlurmUser\fR.
+The argument to the program will be the names of nodes to
+be placed into power savings mode (using SLURM's hostlist
+expression format).
+By default no program is run.
+Related configuration options include \fBResumeProgram\fR, \fBResumeRate\fR,
+\fBSuspendRate\fR, \fBSuspendTime\fR, \fBSuspendExcNodes\fR, and
+\fBSuspendExcParts\fR.
+
+.TP
+\fBSuspendRate\fR
+The rate at which nodes are place into power save mode by \fBSuspendProgram\fR.
+The value is number of nodes per minute and it can be used to prevent
+a large drop in power power consumption (e.g. after a large job completes).
+A value of zero results in no limits being imposed.
+The default value is 60 nodes per minute.
+Related configuration options include \fBResumeProgram\fR, \fBResumeRate\fR,
+\fBSuspendProgram\fR, \fBSuspendTime\fR, \fBSuspendExcNodes\fR, and
+\fBSuspendExcParts\fR.
+
+.TP
+\fBSuspendTime\fR
+Nodes which remain idle for this number of seconds will be placed into 
+power save mode by \fBSuspendProgram\fR,
+A value of \-1 disables power save mode and is the default.
+Related configuration options include \fBResumeProgram\fR, \fBResumeRate\fR,
+\fBSuspendProgram\fR, \fBSuspendRate\fR, \fBSuspendExcNodes\fR, and
+\fBSuspendExcParts\fR.
+
 .TP
 \fBSwitchType\fR
 Identifies the type of switch or interconnect used for application
@@ -658,11 +1034,13 @@ All SLURM daemons, commands and running jobs must be restarted for a
 change in \fBSwitchType\fR to take effect.
 If running jobs exist at the time \fBslurmctld\fR is restarted with a new 
 value of \fBSwitchType\fR, records of all jobs in any state may be lost.
+
 .TP
 \fBTaskEpilog\fR
 Fully qualified pathname of a program to be execute as the slurm job's
 owner after termination of each task.
 See \fBTaskPlugin\fR for execution order details.
+
 .TP
 \fBTaskPlugin\fR
 Identifies the type of task launch plugin, typically used to provide 
@@ -725,6 +1103,7 @@ Standard output from this program of the form
 "export NAME=value" will be used to set environment variables 
 for the task being spawned. 
 See \fBTaskPlugin\fR for execution order details.
+
 .TP
 \fBTmpFS\fR
 Fully qualified pathname of the file system available to user jobs for 
@@ -740,7 +1119,7 @@ The default value is 50, meaning each slurmd daemon can communicate
 with up to 50 other slurmd daemons and over 2500 nodes can be contacted
 with two message hops.
 The default value will work well for most clusters.
-Optimaly system performance can typically be achieved if \fBTreeWidth\fR
+Optimal system performance can typically be achieved if \fBTreeWidth\fR
 is set to the square root of the number of nodes in the cluster for
 systems having no more than 2500 nodes or the cube root for larger
 systems.
@@ -752,16 +1131,13 @@ of time specified by the UnkillableStepTimeout variable, the program
 specified by the UnkillableStepProgram string will be executed.  This 
 program can be used to take special actions to clean up the unkillable
 processes.  The program will be run as the same user as the slurmd (usually
-"root").  NOTE: This variable does not appear in the output of the command
-"scontrol show config" in versions of SLURM less than version 1.3.
+"root").
 
 .TP
 \fBUnkillableStepTimeout\fR
 The length of time, in seconds, that SLURM will wait before deciding that
-processes in a job step are unkillable (after they have been signalled with
-SIGKILL).  The default timeout value is 60 seconds.  NOTE: This variable does
-not appear in the output of the command "scontrol show config" in versions
-of SLURM less than version 1.3.
+processes in a job step are unkillable (after they have been signaled with
+SIGKILL).  The default timeout value is 60 seconds.
 
 .TP
 \fBUsePAM\fR
@@ -789,6 +1165,7 @@ session     required      pam_unix.so
 .br
 For sites configuring PAM with a general configuration file, the appropriate
 lines (see above), where \fBslurm\fR is the service\-name, should be added.
+
 .TP
 \fBWaitTime\fR
 Specifies how many seconds the srun command should by default wait after 
@@ -796,9 +1173,12 @@ the first task terminates before terminating all remaining tasks. The
 "\-\-wait" option on the srun command line overrides this value. 
 If set to 0, this feature is disabled.
 May not exceed 65533.
+
 .LP
 The configuration of nodes (or machines) to be managed by Slurm is 
 also specified in \fB/etc/slurm.conf\fR. 
+Changes in node configuration (e.g. adding nodes, changing their
+processor count, etc.) require restarting the slurmctld daemon.
 Only the NodeName must be supplied in the configuration file.
 All other node configuration information is optional.
 It is advisable to establish baseline node configurations, 
@@ -836,11 +1216,11 @@ node specifications should be place in this file in consecutive order.
 No single node name may be listed more than once in the configuration
 file.
 Use "DownNodes=" to record the state of nodes which are temporarily 
-in a DOWN or DRAIN state without altering permanent configuration 
-information.
+in a DOWN, DRAIN or FAILING state without altering permanent 
+configuration information.
 A job step's tasks are allocated to nodes in order the nodes appear 
 in the configuration file. There is presently no capability within 
-SLURM to arbitarily order a job step's tasks.
+SLURM to arbitrarily order a job step's tasks.
 .LP
 Multiple node names may be comma separated (e.g. "alpha,beta,gamma")
 and/or a simple node range expression may optionally be used to 
@@ -861,12 +1241,13 @@ See BlueGene documentation for more details.
 Presently the numeric range must be the last characters in the 
 node name (e.g. "unit[0\-31]rack1" is invalid). 
 The node configuration specified the following information:
+
 .TP
 \fBNodeName\fR
 Name that SLURM uses to refer to a node (or base partition for 
 BlueGene systems). 
 Typically this would be the string that "/bin/hostname \-s" 
-returns, however it may be an arbitary string if 
+returns, however it may be an arbitrary string if 
 \fBNodeHostname\fR is specified.
 If the \fBNodeName\fR is "DEFAULT", the values specified 
 with that record will apply to subsequent node specifications   
@@ -877,6 +1258,7 @@ nodes will be considered consecutive in the order defined.
 For example, if the configuration for "NodeName=charlie" immediately 
 follows the configuration for "NodeName=baker" they will be 
 considered adjacent in the computer.
+
 .TP
 \fBNodeHostname\fR
 The string that "/bin/hostname \-s" returns. 
@@ -886,6 +1268,7 @@ If an expression is used, the number of nodes identified by
 be identical to the number of nodes identified by \fBNodeName\fR.
 By default, the \fBNodeHostname\fR will be identical in value to 
 \fBNodeName\fR.
+
 .TP
 \fBNodeAddr\fR
 Name that a node should be referred to in establishing 
@@ -898,6 +1281,16 @@ they must exactly match the entries in the \fBNodeName\fR
 \fBNodeAddr\fR may also contain IP addresses.
 By default, the \fBNodeAddr\fR will be identical in value to 
 \fBNodeName\fR.
+
+.TP
+\fBCoresPerSocket\fR
+Number of cores in a single physical processor socket (e.g. "2").
+The CoresPerSocket value describes physical cores, not the
+logical number of processors per socket.
+\fBNOTE\fR: If you have multi\-core processors, you will likely
+need to specify this parameter in order to optimize scheduling.
+The default value is 1.
+
 .TP
 \fBFeature\fR
 A comma delimited list of arbitrary strings indicative of some 
@@ -907,16 +1300,25 @@ either has a feature or it does not.
 If desired a feature may contain a numeric component indicating, 
 for example, processor speed. 
 By default a node has no features.
-.TP
-\fBRealMemory\fR
-Size of real memory on the node in MegaBytes (e.g. "2048").
-The default value is 1.
+
 .TP
 \fBProcs\fR
 Number of logical processors on the node (e.g. "2").
 If Procs is omitted, it will be inferred from
 \fBSockets\fR, \fBCoresPerSocket\fR, and \fBThreadsPerCore\fR.
 The default value is 1. 
+
+.TP
+\fBRealMemory\fR
+Size of real memory on the node in MegaBytes (e.g. "2048").
+The default value is 1.
+
+.TP
+\fBReason\fR
+Identifies the reason for a node being in state "DOWN", "DRAINED" 
+"DRAINING", "FAIL" or "FAILING". 
+Use quotes to enclose a reason having more than one word.
+
 .TP
 \fBSockets\fR
 Number of physical processor sockets/chips on the node (e.g. "2").
@@ -925,33 +1327,30 @@ If Sockets is omitted, it will be inferred from
 \fBNOTE\fR: If you have multi\-core processors, you will likely 
 need to specify these parameters.
 The default value is 1.
-.TP
-\fBCoresPerSocket\fR
-Number of cores in a single physical processor socket (e.g. "2").
-The CoresPerSocket value describes physical cores, not the
-logical number of processors per socket.
-\fBNOTE\fR: If you have multi\-core processors, you will likely
-need to specify this parameter.
-The default value is 1.
-.TP
-\fBThreadsPerCore\fR
-Number of logical threads in a single physical core (e.g. "2").
-The default value is 1.
-.TP
-\fBReason\fR
-Identifies the reason for a node being in state "DOWN" or "DRAIN". 
-Use quotes to enclose a reason having more than one word.
+
 .TP
 \fBState\fR
 State of the node with respect to the initiation of user jobs. 
-Acceptable values are "DOWN", "DRAIN" and "UNKNOWN". 
+Acceptable values are "DOWN", "DRAIN", "FAIL", "FAILING" and "UNKNOWN". 
 "DOWN" indicates the node failed and is unavailable to be allocated work.
 "DRAIN" indicates the node is unavailable to be allocated work.
+"FAIL" indicates the node is expected to fail soon, has 
+no jobs allocated to it, and will not be allocated 
+to any new jobs.
+"FAILING" indicates the node is expected to fail soon, has 
+one or more jobs allocated to it, but will not be allocated 
+to any new jobs.
 "UNKNOWN" indicates the node's state is undefined (BUSY or IDLE), 
 but will be established when the \fBslurmd\fR daemon on that node 
 registers.
 The default value is "UNKNOWN".
-Also see the \fBDownNodes\fR paramter below. 
+Also see the \fBDownNodes\fR parameter below. 
+
+.TP
+\fBThreadsPerCore\fR
+Number of logical threads in a single physical core (e.g. "2").
+The default value is 1.
+
 .TP
 \fBTmpDisk\fR
 Total size of temporary disk storage in \fBTmpFS\fR in MegaBytes 
@@ -965,6 +1364,7 @@ most of this space.
 The Prolog and/or Epilog programs (specified in the configuration file) 
 might be used to insure the file system is kept clean. 
 The default value is 0.
+
 .TP
 \fBWeight\fR
 The priority of the node for scheduling purposes. 
@@ -981,21 +1381,32 @@ disk space, higher processor speed, etc.
 Weight is an integer value with a default value of 1.
 .LP
 The "DownNodes=" configuration permits you to mark certain nodes as in a 
-DOWN or DRAIN state without altering the permanent configuration
-information listed under a "NodeName=" specification.
+DOWN, DRAIN, FAIL, or FAILING state without altering the permanent 
+configuration information listed under a "NodeName=" specification.
+
 .TP
 \fBDownNodes\fR
 Any node name, or list of node names, from the "NodeName=" specifications.
+
 .TP
 \fBReason\fR
-Identifies the reason for a node being in state "DOWN" or "DRAIN". 
-Use quotes to enclose a reason having more than one word.
+Identifies the reason for a node being in state "DOWN", "DRAIN", 
+"FAIL" or "FAILING. 
+\Use quotes to enclose a reason having more than one word.
+
 .TP
 \fBState\fR
 State of the node with respect to the initiation of user jobs. 
-Acceptable values are "DOWN", "DRAIN" and "UNKNOWN". 
+Acceptable values are "BUSY", "DOWN", "DRAIN", "FAIL",
+"FAILING, "IDLE", and "UNKNOWN". 
 "DOWN" indicates the node failed and is unavailable to be allocated work.
 "DRAIN" indicates the node is unavailable to be allocated work.
+"FAIL" indicates the node is expected to fail soon, has
+no jobs allocated to it, and will not be allocated
+to any new jobs.
+"FAILING" indicates the node is expected to fail soon, has
+one or more jobs allocated to it, but will not be allocated
+to any new jobs.
 "UNKNOWN" indicates the node's state is undefined (BUSY or IDLE), 
 but will be established when the \fBslurmd\fR daemon on that node 
 registers.
@@ -1020,6 +1431,7 @@ describing the configuration of partitions.
 Each line of partition configuration information should 
 represent a different partition.
 The partition configuration file contains the following information:
+
 .TP
 \fBAllowGroups\fR
 Comma separated list of group IDs which may execute jobs in the partition. 
@@ -1029,14 +1441,24 @@ Jobs executed as user root can use any partition without regard to
 the value of AllowGroups.
 If user root attempts to execute a job as another user (e.g. using 
 srun's \-\-uid option), this other user must be in one of groups 
-identified by AllowGroups for the job to succesfully execute.
+identified by AllowGroups for the job to successfully execute.
 The default value is "ALL". 
+
 .TP
 \fBDefault\fR
 If this keyword is set, jobs submitted without a partition 
 specification will utilize this partition.
 Possible values are "YES" and "NO". 
 The default value is "NO".
+
+.TP
+\fBDisableRootJobs\fR
+If set to "YES" then user root will be prevented from running any jobs
+on this partition.
+The default value will be the value of \fBDisableRootJobs\fR set 
+outside of a partition specification (which is "NO", allowing user
+root to execute jobs).
+
 .TP
 \fBHidden\fR
 Specifies if the partition and its jobs are to be hidden by default. 
@@ -1044,33 +1466,31 @@ Hidden partitions will by default not be reported by the SLURM
 APIs or commands.
 Possible values are "YES" and "NO". 
 The default value is "NO".
-.TP
-\fBRootOnly\fR
-Specifies if only user ID zero (i.e. user \fIroot\fR) may allocate resources 
-in this partition. User root may allocate resources for any other user, 
-but the request must be initiated by user root. 
-This option can be useful for a partition to be managed by some 
-external entity (e.g. a higher\-level job manager) and prevents 
-users from directly using those resources.
-Possible values are "YES" and "NO". 
-The default value is "NO".
+
 .TP
 \fBMaxNodes\fR
 Maximum count of nodes (or base partitions for BlueGene systems) which 
 may be allocated to any single job.
 The default value is "UNLIMITED", which is represented internally as \-1.
 This limit does not apply to jobs executed by SlurmUser or user root.
+
 .TP
 \fBMaxTime\fR
-Maximum wall\-time limit for any job in minutes. The default 
-value is "UNLIMITED", which is represented internally as \-1.
+Maximum run time limit for jobs.
+Format is minutes, minutes:seconds, hours:minutes:seconds, 
+days\-hours, days\-hours:minutes, days\-hours:minutes:seconds or
+"UNLIMITED". 
+Time resolution is one minute and second values are rounded up to 
+the next minute.
 This limit does not apply to jobs executed by SlurmUser or user root.
+
 .TP
 \fBMinNodes\fR
 Minimum count of nodes (or base partitions for BlueGene systems) which 
 may be allocated to any single job.
 The default value is 1.
 This limit does not apply to jobs executed by SlurmUser or user root.
+
 .TP
 \fBNodes\fR
 Comma separated list of nodes (or base partitions for BlueGene systems) 
@@ -1079,6 +1499,7 @@ Node names may be specified using the node range expression syntax
 described above. A blank list of nodes 
 (i.e. "Nodes= ") can be used if one wants a partition to exist, 
 but have no resources (possibly on a temporary basis).
+
 .TP
 \fBPartitionName\fR
 Name by which the partition may be referenced (e.g. "Interactive"). 
@@ -1087,24 +1508,76 @@ If the \fBPartitionName\fR is "DEFAULT", the values specified
 with that record will apply to subsequent partition specifications
 unless explicitly set to other values in that partition record or
 replaced with a different set of default values.
+
+.TP
+\fBPriority\fR
+Jobs submitted to a higher priority partition will be dispatched 
+before pending jobs in lower priority partitions and if possible
+they will preempt running jobs from lower priority partitions.
+Note that a partition's priority takes precedence over a job's 
+priority.
+The value may not exceed 65533.
+
+
+.TP
+\fBRootOnly\fR
+Specifies if only user ID zero (i.e. user \fIroot\fR) may allocate resources 
+in this partition. User root may allocate resources for any other user, 
+but the request must be initiated by user root. 
+This option can be useful for a partition to be managed by some 
+external entity (e.g. a higher\-level job manager) and prevents 
+users from directly using those resources.
+Possible values are "YES" and "NO". 
+The default value is "NO".
+
 .TP
 \fBShared\fR
-Ability of the partition to execute more than one job at a 
-time on each node. Shared nodes will offer unpredictable performance 
-for application programs, but can provide higher system utilization 
-and responsiveness than otherwise possible. 
-Possible values are "EXCLUSIVE", "FORCE", "YES", and "NO".
-"EXCLUSIVE" allocates entire nodes to jobs even with 
-select/cons_res configured.
+Controls the ability of the partition to execute more than one job at a 
+time on each resource (node, socket or core depending upon the value
+of \fBSelectTypeParameters\fR).
+If resources are to be shared, avoiding memory over\-subscription
+is very important.
+\fBSelectTypeParameters\fR should be configured to treat
+memory as a consumable resource and the \fB\-\-mem\fR option
+should be used for job allocations.
+For more information see the following web page:
+\fIhttps://computing.llnl.gov/linux/slurm/cons_res_share.html\fR.
+Possible values for \fBShared\fR are "EXCLUSIVE", "FORCE", "YES", and "NO".
+.RS
+.TP 12
+\fBEXCLUSIVE\fR
+Aallocates entire nodes to jobs even with select/cons_res configured.
 This can be used to allocate whole nodes in some partitions 
-and individual processors in other partitions. 
-"FORCE" makes all nodes in the partition available for sharing 
-without user means of disabling it.
-"YES" makes nodes in the partition available for sharing if and 
-only if the individual jobs permit sharing (see the srun 
-"\-\-share" option).
-"NO" makes nodes unavailable for sharing under all circumstances. 
-The default value is "NO".
+and individual processors in other partitions.
+.TP 
+\fBFORCE\fR
+Make all resources in the partition available for sharing 
+without any means for users to disable it.
+May be followed with a colon and maximum number of jobs in
+running or suspended state.
+For example "Shared=FORCE:4" enables each node, socket or
+core to execute up to four jobs at once.
+Recommended only for BlueGene systems configured with
+small blocks or for systems running
+with gang scheduling (\fBSchedulerType=sched/gang\fR).
+.TP
+\fBYES\fR
+Make nodes in the partition available for sharing, but provides
+the user with a means of getting dediated resources.
+If \fBSelectType=select/cons_res\fR, then resources will be 
+over\-subscribed unless explicitly disabled in the job submit 
+request using the "\-\-exclusive" option.
+With \fBSelectType=select/bluegene\fR or \fBSelectType=select/linear\fR,
+resources will only be over\-subscribed when explicitly requested
+by the user using the "\-\-share" option on job submission.
+May be followed with a colon and maximum number of jobs in 
+running or suspended state.
+For example "Shared=YES:4" enables each node, socket or
+core to execute up to four jobs at once.
+Recommended only for systems running with gang scheduling 
+(\fBSchedulerType=sched/gang\fR).
+.RE
+
 .TP
 \fBState\fR
 State of partition or availability for use.  Possible values 
@@ -1158,7 +1631,7 @@ BackupAddr=edev1
 .br
 #
 .br
-AuthType=auth/authd
+AuthType=auth/munge
 .br
 Epilog=/usr/local/slurm/epilog 
 .br
@@ -1168,13 +1641,11 @@ FastSchedule=1
 .br
 FirstJobId=65536
 .br
-HeartbeatInterval=60
-.br
 InactiveLimit=120
 .br
 JobCompType=jobcomp/filetxt
 .br
-JobCompLoc=/var/log/slurm.job.log
+JobCompLoc=/var/log/slurm/jobcomp
 .br
 KillWait=30
 .br
@@ -1186,13 +1657,11 @@ PluginDir=/usr/local/lib:/usr/local/slurm/lib
 .br
 ReturnToService=0
 .br
-SchedulerType=sched/wiki
-.br
-SchedulerPort=7004
+SchedulerType=sched/backfill
 .br
-SlurmctldLogFile=/var/log/slurmctld.log
+SlurmctldLogFile=/var/log/slurm/slurmctld.log
 .br
-SlurmdLogFile=/var/log/slurmd.log
+SlurmdLogFile=/var/log/slurm/slurmd.log
 .br
 SlurmctldPort=7002
 .br
@@ -1212,12 +1681,6 @@ JobCredentialPrivateKey=/usr/local/slurm/private.key
 .br
 JobCredentialPublicCertificate=/usr/local/slurm/public.cert
 .br
-JobAcctType=jobacct/linux
-.br
-JobAcctLogFile=/var/log/slurm_accounting.log
-.br
-JobAcctParameters="Frequency=30,MaxSendRetries=5"
-.br
 #
 .br
 # Node Configurations
@@ -1250,8 +1713,9 @@ PartitionName=long Nodes=dev[9\-17] MaxTime=120 AllowGroups=admin
 
 .SH "COPYING"
 Copyright (C) 2002\-2007 The Regents of the University of California.
+Copyright (C) 2008 Lawrence Livermore National Security.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
@@ -1269,8 +1733,8 @@ details.
 /etc/slurm.conf
 .SH "SEE ALSO"
 .LP
-\fBbluegene.conf\fR(5),
-\fBgetrlimit\fR(2),
-\fBgethostbyname\fR(3), \fBgroup\fR(5), \fBhostname\fR(1), 
-\fBscontrol\fR(1), \fBslurmctld\fR(8), \fBslurmd\fR(8), \fBspank(8)\fR,
+\fBbluegene.conf\fR(5), \fBgethostbyname\fR(3), 
+\fBgetrlimit\fR(2), \fBgroup\fR(5), \fBhostname\fR(1), 
+\fBscontrol\fR(1), \fBslurmctld\fR(8), \fBslurmd\fR(8), 
+\fBslurmdbd\fR(8), \fBslurmdbd.conf\fR(5), \fBspank(8)\fR,
 \fBsyslog\fR(2), \fBwiki.conf\fR(5)
diff --git a/doc/man/man5/slurmdbd.conf.5 b/doc/man/man5/slurmdbd.conf.5
new file mode 100644
index 0000000000000000000000000000000000000000..0b55090de0d388f068c1a228edf7688c2c1b2af0
--- /dev/null
+++ b/doc/man/man5/slurmdbd.conf.5
@@ -0,0 +1,216 @@
+.TH "slurmdbd.conf" "5" "February 2008" "slurmdbd.conf 1.3" "Slurm configuration file"
+.SH "NAME"
+slurmdbd.conf \- Slurm Database Daemon (SlurmDBD) configuration file 
+
+.SH "DESCRIPTION"
+\fB/etc/slurmdb.conf\fP is an ASCII file which describes Slurm Database 
+Daemon (SlurmDBD) configuration information.
+.LP
+The file location can be modified at system build time using the
+DEFAULT_SLURM_CONF parameter. 
+The contents of the file are case insensitive except for the names of nodes 
+and files. Any text following a "#" in the configuration file is treated 
+as a comment through the end of that line. 
+The size of each line in the file is limited to 1024 characters.
+Changes to the configuration file take effect upon restart of 
+SlurmDbd or daemon receipt of the SIGHUP signal unless otherwise noted.
+.LP
+This file should be only on the computer where SlurmDBD executes and 
+should only be readable by the user which executes SlurmDBD (e.g. "slurm").
+This file should be protected from unauthorized access since it
+contains a database password.
+The overall configuration parameters available include:
+
+.TP
+\fBAuthInfo\fR
+Additional information to be used for authentication of communications 
+with the Slurm control daemon (slurmctld) on each cluster.
+The interpretation of this option is specific to the configured \fBAuthType\fR.
+In the case of \fIauth/munge\fR, this can be configured to use a Munge daemon 
+specifically configured to provide authentication between clusters while the 
+default Munge daemon provides authentication within a cluster. 
+In that case, this will specify the pathname of the socket to use.
+The default value is NULL, which results in the default authentication 
+mechanism being used.
+
+.TP
+\fBAuthType\fR
+Define the authentication method for communications between SLURM 
+components. 
+Acceptable values at present include "auth/none", "auth/authd", 
+and "auth/munge".
+The default value is "auth/none", which means the UID included in 
+communication messages is not verified. 
+This may be fine for testing purposes, but 
+\fBdo not use "auth/none" if you desire any security\fR.
+"auth/authd" indicates that Brett Chun's authd is to be used (see
+"http://www.theether.org/authd/" for more information).
+"auth/munge" indicates that LLNL's Munge system is to be used
+(this is the best supported authentication mechanism for SLURM, 
+see "http://home.gna.org/munge/" for more information).
+SlurmDbd must be terminated prior to changing the value of \fBAuthType\fR 
+and later restarted.
+
+.TP
+\fBDbdAddr\fR
+Name that \fBDbdHost\fR should be referred to in 
+establishing a communications path to the Slurm Database Daemon. 
+This name will be used as an argument to the gethostbyname() 
+function for identification. For example, "elx0000" might be used 
+to designate the ethernet address for node "lx0000". 
+By default the \fBDbdAddr\fR will be identical in value to 
+\fBDbdHost\fR.
+This value must be equal to the \fBSlurmDbdAddr\fR parameter in 
+the slurm.conf file.
+
+.TP
+\fBDbdHost\fR
+The name of the machine where the Slurm Database Daemon is executed. 
+This should be a node name without the full domain name (e.g. "lx0001"). 
+This value must be specified.
+
+.TP
+\fBDbdPort\fR
+The port number that the Slurm Database Daemon (slurmdbd) listens 
+to for work. The default value is SLURMDBD_PORT as established at system 
+build time. If none is explicitly specified, it will be set to 6819.
+This value must be equal to the \fBSlurmDbdPort\fR parameter in the
+slurm.conf file.
+
+.TP
+\fBDebugLevel\fR
+The level of detail to provide the Slurm Database Daemon's logs. 
+Values from 0 to 7 are legal, with `0' being "quiet" operation and 
+`7' being insanely verbose.
+The default value is 3.
+
+.TP
+\fBLogFile\fR
+Fully qualified pathname of a file into which the Slurm Database Daemon's 
+logs are written.
+The default value is none (performs logging via syslog).
+
+.TP
+\fBMessageTimeout\fR
+Time permitted for a round\-trip communication to complete
+in seconds. Default value is 10 seconds. 
+
+.TP
+\fBPidFile\fR
+Fully qualified pathname of a file into which the Slurm Database Daemon 
+may write its process ID. This may be used for automated signal processing.
+The default value is "/var/run/slurmdbd.pid".
+
+.TP
+\fBPluginDir\fR
+Identifies the places in which to look for SLURM plugins. 
+This is a colon\-separated list of directories, like the PATH 
+environment variable. 
+The default value is "/usr/local/lib/slurm".
+
+.TP
+\fBSlurmUser\fR
+The name of the user that the \fBslurmctld\fR daemon executes as. 
+This user must exist on the machine executing the Slurm Database Daemon
+and have the same user ID as the hosts on which \fBslurmctld\fR execute.
+For security purposes, a user other than "root" is recommended.
+The default value is "root". 
+
+.TP
+\fBStorageHost\fR
+Define the name of the host the database is running where we are going
+to store the data.
+Ideally this should be the host on which slurmdbd executes.
+
+.TP
+\fBStorageLoc\fR
+Specify the name of the database as the location where accounting 
+records are written.
+
+.TP
+\fBStoragePass\fR
+Define the password used to gain access to the database to store 
+the job accounting data.
+
+.TP
+\fBStoragePort\fR
+The port number that the Slurm Database Daemon (slurmdbd) communicates
+with the database.
+
+.TP
+\fBStorageType\fR
+Define the accounting storage mechanism type.
+Acceptable values at present include 
+"accounting_storage/gold", "accounting_storage/mysql", and
+"accounting_storage/pgsql".
+The value "accounting_storage/gold" indicates that account records
+will be written to Gold
+(http://www.clusterresources.com/pages/products/gold-allocation-manager.php),
+which maintains its own database.
+The value "accounting_storage/mysql" indicates that accounting records
+should be written to a MySQL database specified by the 
+\fStorageLoc\fR parameter.
+The value "accounting_storage/pgsql" indicates that accounting records
+should be written to a PostgreSQL database specified by the 
+\fBStorageLoc\fR parameter.
+This value must be specified.
+
+.TP
+\fBStorageUser\fR
+Define the name of the user we are going to connect to the database
+with to store the job accounting data.
+
+.SH "EXAMPLE"
+.LP 
+#
+.br
+# Sample /etc/slurmdbd.conf
+.br
+#
+.br
+AuthInfo=/var/run/munge/munge.socket.2
+.br
+AuthType=auth/munge
+.br
+DbdHost=db_host
+.br
+DebugLevel=4
+.br
+LogFile=/var/log/slurmdbd.log
+.br
+PidFile=/var/tmp/jette/slurmdbd.pid
+.br
+SlurmUser=slurm_mgr
+.br
+StoragePass=shazaam
+.br
+StorageType=accounting_storage/mysql
+.br
+StorageUser=database_mgr
+
+.SH "COPYING"
+Copyright (C) 2008 Lawrence Livermore National Security.
+Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+LLNL\-CODE\-402394.
+.LP
+This file is part of SLURM, a resource management program.
+For details, see <https://computing.llnl.gov/linux/slurm/>.
+.LP
+SLURM is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+.LP
+SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+details.
+
+.SH "FILES"
+/etc/slurmdbd.conf
+
+.SH "SEE ALSO"
+.LP
+\fBslurm.conf\fR(5),
+\fBslurmctld\fR(8), \fBslurmdbd\fR(8)
+\fBsyslog\fR(2)
diff --git a/doc/man/man5/wiki.conf.5 b/doc/man/man5/wiki.conf.5
index c84957fdff535b00bd1d303dda802b9b54437660..5edce905f26542c8259361b666798c5e6d140dd6 100644
--- a/doc/man/man5/wiki.conf.5
+++ b/doc/man/man5/wiki.conf.5
@@ -1,4 +1,4 @@
-.TH "wiki.conf" "5" "August 2007" "wiki.conf 1.2" "Slurm configuration file"
+.TH "wiki.conf" "5" "December 2007" "wiki.conf 1.2" "Slurm configuration file"
 .SH "NAME"
 wiki.conf \- Slurm configuration file for wiki and wiki2 scheduler plugins
 .SH "DESCRIPTION"
@@ -91,8 +91,11 @@ No data compression. Each host name is listed individually.
 .TP
 \fB1\fR
 SLURM hostlist expressions are exchanged with task counts
-(e.g. "tux[0\-16]*2").
-This is currently experimental.
+(e.g. "tux[0\-16]*2") in job state information and job 
+initiation requests.
+.TP
+\fB2\fR
+SLURM hostlist expressions are used to report node state information.
 .RE
 
 .TP
@@ -167,7 +170,7 @@ JobAggregationTime=15
 .SH "COPYING"
 Copyright (C) 2006-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man8/slurmctld.8 b/doc/man/man8/slurmctld.8
index 0e37e751f987cae59727487b8e2b969dcf2a8ffd..67f64b5b3a9d91d34727c495a83376b98d7c6757 100644
--- a/doc/man/man8/slurmctld.8
+++ b/doc/man/man8/slurmctld.8
@@ -57,7 +57,7 @@ configuration file, \fBslurm.conf\fR.
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man8/slurmd.8 b/doc/man/man8/slurmd.8
index bca7fdc879c73f3b0bae72b3ccec4c00c6a0f65d..8cb55211162e93ebcaf41c59c273b5c03b6c68b1 100644
--- a/doc/man/man8/slurmd.8
+++ b/doc/man/man8/slurmd.8
@@ -60,7 +60,7 @@ configuration file, \fBslurm.conf\fR.
 .SH "COPYING"
 Copyright (C) 2002\-2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man8/slurmdbd.8 b/doc/man/man8/slurmdbd.8
new file mode 100644
index 0000000000000000000000000000000000000000..0b3b656c6baf89c8e6b3fed5a05f762195a01942
--- /dev/null
+++ b/doc/man/man8/slurmdbd.8
@@ -0,0 +1,55 @@
+.TH slurmdbd "8" "February 2008" "slurmdbd 1.3" "Slurm components"
+.SH "NAME"
+slurmdbd \- Slurm Database Daemon.
+
+.SH "SYNOPSIS"
+\fBslurmdbd\fR [\fIOPTIONS\fR...]
+
+.SH "DESCRIPTION"
+\fBslurmdbd\fR provides a secure enterprise\-wide interface to a database
+for Slurm. This is particularly useful for archiving accounting records.
+.TP
+OPTIONS
+.TP
+\fB\-D\fR
+Debug mode. Execute \fBslurmdbd\fR in the foreground with logging to stdout. 
+.TP
+\fB\-h\fR
+Help; print a brief summary of command options.
+.TP
+\fB\-v\fR
+Verbose operation. Multiple \fB\-v\fR's increase verbosity.
+.TP
+\fB\-V\fR
+Print version information and exit.
+
+.SH "NOTES"
+It may be useful to experiment with different \fBslurmctld\fR specific
+configuration parameters using a distinct configuration file
+(e.g. timeouts).  However, this special configuration file will not be
+used by the \fBslurmd\fR daemon or the Slurm programs, unless you
+specifically tell each of them to use it. If you desire changing
+communication ports, the location of the temporary file system, or
+other parameters used by other Slurm components, change the common
+configuration file, \fBslurm.conf\fR.
+
+.SH "COPYING"
+Copyright (C) 2008 Lawrence Livermore National Security.
+Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+LLNL\-CODE\-402394.
+.LP
+This file is part of SLURM, a resource management program.
+For details, see <https://computing.llnl.gov/linux/slurm/>.
+.LP
+SLURM is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+.LP
+SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+details.
+
+.SH "SEE ALSO"
+\fBslurm.conf\fR(5), \fBslurmdbd.conf\fR(5), \fBslurmctld\fR(8)
diff --git a/doc/man/man8/slurmstepd.8 b/doc/man/man8/slurmstepd.8
index fe27e4a23458e55f2d7fd7224d7beeac9c8bc0dd..24748ec2b114d443f5f7f3cb47810e8b817bb1df 100644
--- a/doc/man/man8/slurmstepd.8
+++ b/doc/man/man8/slurmstepd.8
@@ -13,7 +13,7 @@ for the job step along with its accounting and signal processing.
 .SH "COPYING"
 Copyright (C) 2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
diff --git a/doc/man/man8/spank.8 b/doc/man/man8/spank.8
index 7f04657887b29412f639197433ecccfc8f421325..7813a6d646df0c26124810c0c6e020bd23b66542 100644
--- a/doc/man/man8/spank.8
+++ b/doc/man/man8/spank.8
@@ -1,6 +1,7 @@
 .TH "SPANK" "8" "May 2006" "SPANK" "SLURM plug\-in architecture for Node and job (K)control"
 .SH "NAME"
 \fBSPANK\fR \- SLURM Plug\-in Architecture for Node and job (K)control 
+
 .SH "DESCRIPTION"
 This manual briefly describes the capabilities of the SLURM Plug\-in
 architecture for Node and job Kontrol (\fBSPANK\fR) as well as the \fBSPANK\fR
@@ -16,10 +17,12 @@ the \fBSPANK\fR infrastructure provides administrators and other developers
 a low cost, low effort ability to dynamically modify the runtime
 behavior of SLURM job launch.
 .LP
+
 .SH "SPANK PLUGINS"
 \fBSPANK\fR plugins are loaded in two separate contexts during a 
-\fBSLURM\fR job.  In "local" context, the plugin is loaded by \fBsrun\fR
-or other \fBSLURM\fR user interface. In local context, options provided by 
+\fBSLURM\fR job.  In "local" context, the plugin is loaded by \fBsrun\fR,
+\fBsbatch\fR or other \fBSLURM\fR user interface. 
+In local context, options provided by 
 plugins are read by \fBSPANK\fR, and these options are presented to the user. 
 In "remote" context, the plugin is loaded on a compute node of the job,
 in other words, the plugin is loaded by \fBslurmd\fR. In local context, only
@@ -36,7 +39,12 @@ just after job step is initialized. For local context, this is before
 user options are processed.
 .TP
 \fBslurm_spank_local_user_init\fR
-Called in local (srun) context only after all options have been processed.
+Called in local (\fBsrun\fR or \fBsbatch\fR) context only after all 
+options have been processed. 
+This is called after the job ID and step IDs are available.
+This happens in \fBsrun\fR after the allocation is made, but before 
+tasks are launched.
+This happens in \fBsbatch\fR after the job is submitted.
 .TP
 \fBslurm_spank_user_init\fR 
 Called after privileges are temporarily dropped. (remote context only)
@@ -56,7 +64,7 @@ Called for each task as its exit status is collected by SLURM.
 .TP
 \fBslurm_spank_exit\fR
 Called once just before \fBslurmstepd\fR exits in remote context.
-In local context, called before \fBsrun\fR exits.
+In local context, called before \fBsrun\fR or \fBsbatch\fR exits.
 .LP
 All of these functions have the same prototype, for example:
 .nf
@@ -104,6 +112,8 @@ User id for running job. (uid_t *) is third arg of \fBspank_get_item\fR
 .TP
 \fBS_JOB_STEPID\fR
 Job step id for running job. (uint32_t *) is third arg of \fBspank_get_item\fR
+For batch jobs (initiated by \fBsbatch\fR), the step id will be 
+\fBSLURM_BATCH_SCRIPT\fR as defined in the \fBslurm.h\fR file.
 .TP
 \fBS_TASK_EXIT_STATUS\fR
 Exit status for exited task. Only valid from \fBslurm_spank_task_exit\fR.
@@ -140,11 +150,13 @@ and \fBunsetenv\fR(3) may be used in local context.
 .LP
 See \fBspank.h\fR for more information, and \fBEXAMPLES\fR below for an example
 for \fBspank_getenv\fR usage.
+
 .SH "SPANK OPTIONS"
 .LP
 SPANK plugins also have an interface through which they may define
 and implement extra job options. These options are made available to
-the user through SLURM commands such as \fBsrun\fR(1), and if the
+the user through SLURM commands such as \fBsrun\fR(1) or 
+\fBsbatch\fR(1), and if the
 option is specified, its value is forwarded and registered with
 the plugin on the remote side. In this way, \fBSPANK\fR plugins
 may dynamically provide new options and functionality to SLURM.
@@ -198,8 +210,8 @@ registered with SLURM. \fBspank_opt_cb_f\fR is typedef'd in
 .fi
 Where \fIval\fR is the value of the \fIval\fR field in the \fBspank_option\fR
 struct, \fIoptarg\fR is the supplied argument if applicable, and \fIremote\fR
-is 0 if the function is being called from the "local" host (e.g. srun) or
-1 from the "remote" host (slurmd).
+is 0 if the function is being called from the "local" host 
+(e.g. \fBsrun\fR or \fBsbatch\fR) or 1 from the "remote" host (\fBslurmd\fR).
 .LP
 The last element of the array must filled with zeros. A
 \fBSPANK_OPTIONS_TABLE_END\fR macro is defined in \fB<slurm/spank.h>\fR
@@ -260,6 +272,7 @@ The \fBSPANK\fR config file is re\-read on each job launch, so editing
 the config file will not affect running jobs. However care should
 be taken so that a partially edited config file is not read by a
 launching job.  
+
 .SH "EXAMPLES"
 .LP
 Simple \fBSPANK\fR config file:
@@ -276,8 +289,8 @@ required          /usr/lib/slurm/test.so
 .fi
 .LP
 The following is a simple \fBSPANK\fR plugin to modify the nice value
-of job tasks. This plugin adds a \-\-renice=[prio] option to srun which
-users can use to set the priority of all remote tasks. Priority may
+of job tasks. This plugin adds a \-\-renice=[prio] option to \fBsrun\fR 
+which users can use to set the priority of all remote tasks. Priority may
 also be specified via a SLURM_RENICE environment variable. A minimum
 priority may be established via a "min_prio" parameter in \fBplugstack.conf\fR
 (See above for example).
@@ -321,7 +334,7 @@ static int _str2prio (const char *str, int *p2int);
  */
 struct spank_option spank_options[] =
 {
-    { "renice", "[prio]", "Re\-nice job tasks to priority [prio].", 1, 0,
+    { "renice", "[prio]", "Re\-nice job tasks to priority [prio].", 2, 0,
         (spank_opt_cb_f) _renice_opt_process
     },
     SPANK_OPTIONS_TABLE_END
@@ -430,7 +443,7 @@ static int _renice_opt_process (int val, const char *optarg, int remote)
 .SH "COPYING"
 Copyright (C) 2006 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-UCRL\-CODE\-226842.
+LLNL\-CODE\-402394.
 .LP
 This file is part of SLURM, a resource management program.
 For details, see <https://computing.llnl.gov/linux/slurm/>.
@@ -452,4 +465,4 @@ details.
 \fB/usr/include/slurm/spank.h\fR \- SPANK header file.
 .SH "SEE ALSO"
 .LP
-\fBslurm.conf\fR(5)
+\fBsbatch\fR(1), \fBsrun\fR(1), \fBslurm.conf\fR(5)
diff --git a/etc/bluegene.conf.example b/etc/bluegene.conf.example
index a1dfa9fa14eb25f89596356d6a3d4fa3537515aa..ef9fb3859dac06f12156dd01db169d9e4c6b23da 100644
--- a/etc/bluegene.conf.example
+++ b/etc/bluegene.conf.example
@@ -67,7 +67,8 @@ AltRamDiskImage=*  Groups=da,adamb
 LayoutMode=STATIC
 BasePartitionNodeCnt=512
 NodeCardNodeCnt=32
-Numpsets=8
+#Numpsets=8 #used for IO poor systems (Can't create 32 cnode blocks)
+Numpsets=64 #used for IO rich systems
 
 BridgeAPILogFile=/var/log/slurm/bridgeapi.log
 BridgeAPIVerbose=0
diff --git a/etc/init.d.slurm b/etc/init.d.slurm
index 89aeb6ac8994c4b79d3d4d91ef7b84858aa4455d..72bd3ec5023ed9a1968f14724282de307fc9be10 100644
--- a/etc/init.d.slurm
+++ b/etc/init.d.slurm
@@ -70,9 +70,11 @@ fi
 export LD_LIBRARY_PATH="$LIBDIR:$LD_LIBRARY_PATH"
 
 start() {
-    echo -n "starting $1: " 
+    prog=$1
+    shift
+    echo -n "starting $prog: " 
     unset HOME MAIL USER USERNAME 
-    $STARTPROC $SBINDIR/$1 $2
+    $STARTPROC $SBINDIR/$prog $*
     rc_status -v
     echo
     touch /var/lock/subsys/slurm
diff --git a/etc/init.d.slurmdbd b/etc/init.d.slurmdbd
new file mode 100755
index 0000000000000000000000000000000000000000..55473e4383d870b7c8a9b4871285c84deebedc8d
--- /dev/null
+++ b/etc/init.d.slurmdbd
@@ -0,0 +1,146 @@
+#!/bin/bash
+#
+# chkconfig: 345 90 10
+# description: SLURMDBD is a database server interface for \
+#              SLURM (Simple Linux Utility for Resource Management).
+#
+# processname: /usr/sbin/slurmdbd
+# pidfile: /var/run/slurmdbd.pid
+#
+# config: /etc/sysconfig/slurm
+#
+### BEGIN INIT INFO
+# Provides:          slurmbd
+# Required-Start:    $local_fs $syslog $network $named munge
+# Required-Stop:     $local_fs $syslog $network $named munge
+# Default-Start:     3 5
+# Default-Stop:      0 1 2 6
+# Short-Description: SLURM database daemon
+# Description:       Start slurm to provide database server for SLURM
+### END INIT INFO
+
+CONFDIR=/etc/slurm
+SBINDIR=/usr/sbin
+
+# Source function library.
+if [ -f /etc/rc.status ]; then
+   . /etc/rc.status
+   SUSE=1
+   STARTPROC=startproc
+
+   rc_reset
+else
+   [ -f /etc/rc.d/init.d/functions ] || exit 0
+   . /etc/rc.d/init.d/functions
+   SUSE=0
+   STARTPROC=daemon
+
+   function rc_status() {
+      RETVAL=$?
+   }
+   function rc_exit () {
+      exit $RETVAL
+   }
+   RETVAL=0
+fi
+
+# Source slurm specific configuration
+if [ -f /etc/sysconfig/slurm ] ; then
+    . /etc/sysconfig/slurm
+else
+    SLURMDBD_OPTIONS=""
+fi
+
+[ -f $CONFDIR/slurmdbd.conf ] || exit 1
+
+start() {
+    echo -n "starting slurmdbd: " 
+    unset HOME MAIL USER USERNAME 
+    $STARTPROC $SBINDIR/slurmdbd $SLURMDBD_OPTIONS
+    rc_status -v
+    echo
+    touch /var/lock/subsys/slurmdbd
+}
+
+stop() { 
+    echo -n "stopping slurmdbd: "
+    killproc slurmdbd -TERM
+    rc_status -v
+    echo
+    rm -f /var/lock/subsys/slurmdbd
+}
+
+slurmstatus() {
+    local base=${1##*/}
+    local pid
+    local rpid
+    local pidfile
+
+    pidfile=`grep -i PidFile $CONFDIR/slurmdbd.conf | grep -v '^ *#'`
+    if [ $? = 0 ]; then
+        pidfile=${pidfile##*=}
+        pidfile=${pidfile%#*}
+    else
+        pidfile=/var/run/slurmdbd.pid
+    fi
+
+    pid=`pidof -o $$ -o $$PPID -o %PPID -x slurmdbd`
+
+    if [ -f $pidfile ]; then
+        read rpid < $pidfile
+        if [ "$rpid" != "" -a "$pid" != "" ]; then
+            for i in $pid ; do
+                if [ "$i" = "$rpid" ]; then 
+                    echo $"slurmdbd (pid $pid) is running..."
+                    return 0
+                fi     
+            done
+        elif [ "$rpid" != "" -a "$pid" = "" ]; then
+            echo $"slurmdbd is stopped"
+            return 1
+        fi 
+
+    fi
+     
+    echo $"slurmdbd is stopped"
+    
+    return 3
+}
+
+#
+# The pathname substitution in daemon command assumes prefix and
+# exec_prefix are same.  This is the default, unless the user requests
+# otherwise.
+#
+# Any node can be a slurm controller and/or server.
+#
+case "$1" in
+    start)
+	start slurmdbd
+        ;;
+    stop)
+	stop slurmdbd
+        ;;
+    status)
+	slurmstatus slurmdbd
+        ;;
+    restart)
+	stop slurmdbd
+	start slurmdbd
+        ;;
+    condrestart)
+        if [ -f /var/lock/subsys/slurm ]; then
+                 stop slurmdbd
+                 start slurmdbd
+        fi
+        ;;
+    reconfig)
+	killproc slurmdbd -HUP
+	;;
+    *)
+        echo "Usage: $0 {start|stop|status|restart|condrestart|reconfig}"
+        exit 1
+        ;;
+esac
+
+rc_exit
diff --git a/etc/slurm.conf.example b/etc/slurm.conf.example
index 9d48acbc59346500a841d5a7e1dff2634b5ff52d..000432c86466d92ef34e5d60eda1b313fafc5f51 100644
--- a/etc/slurm.conf.example
+++ b/etc/slurm.conf.example
@@ -69,8 +69,13 @@ SlurmdDebug=3
 JobCompType=jobcomp/none
 #JobCompLoc=
 JobAcctType=jobacct/none
-#JobAcctLogfile=
+#JobAcctLoc=
 #JobAcctFrequency=
+DatabaseType=database/flatfile
+#DatabaseHost=localhost
+#DatabasePort=1234
+#DatabaseUser=mysql
+#DatabasePass=mysql
 #
 # COMPUTE NODES
 NodeName=linux[1-32] Procs=1 State=UNKNOWN
diff --git a/slurm.spec b/slurm.spec
index bc9eaf08e29aeddad4d9bdbfbdaaeb8afe34b4ff..9448a966345edd1ed6ad3ea8bad152fa6eb881f5 100644
--- a/slurm.spec
+++ b/slurm.spec
@@ -1,4 +1,4 @@
-# $Id: slurm.spec 13299 2008-02-19 19:46:58Z da $
+# $Id: slurm.spec 14109 2008-05-22 16:26:23Z jette $
 #
 # Note that this package is not relocatable
 
@@ -8,10 +8,11 @@
 # --with aix         %_with_aix         1    build aix-federation RPM
 # --with authd       %_with_authd       1    build auth-authd RPM
 # --with auth_none   %_with_auth_none   1    build auth-none RPM
-# --with elan        %_with_elan        1    build switch_elan RPM
-# --without munge    %_without_munge    1    don't build auth-munge RPM
 # --with bluegene    %_with_bluegene    1    build bluegene RPM
 # --with debug       %_with_debug       1    enable extra debugging within SLURM
+# --with elan        %_with_elan        1    build switch-elan RPM
+# --without munge    %_without_munge    1    don't build auth-munge RPM
+# --without openssl  %_without_openssl  1    don't require openssl RPM to be installed
 # --without pam      %_without_pam      1    don't require pam-devel RPM to be installed
 # --without readline %_without_readline 1    don't require readline-devel RPM to be installed
 # --with sgijob      %_with_sgijob      1    build proctrack-sgi-job RPM
@@ -35,9 +36,12 @@
 %slurm_without_opt auth_none
 %slurm_without_opt debug
 
-# Build with munge by default on all platforms (disable with --without munge)
+# Build with munge by default on all platforms (disable using --without munge)
 %slurm_with_opt munge
 
+# Build with OpenSSL by default on all platforms (disable using --without openssl)
+%slurm_with_opt openssl
+
 # Use readline by default on all systems
 %slurm_with_opt readline
 
@@ -60,29 +64,24 @@
 %endif
 
 Name:    slurm
-Version: 1.2.27
+Version: 1.3.3
 Release: 1
 
 Summary: Simple Linux Utility for Resource Management
 
 License: GPL 
 Group: System Environment/Base
-Source: slurm-1.2.27.tar.bz2
+Source: slurm-1.3.3.tar.bz2
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
 URL: https://computing.llnl.gov/linux/slurm/
-BuildRequires: openssl-devel >= 0.9.6 openssl >= 0.9.6
 
-%description 
-SLURM is an open source, fault-tolerant, and highly
-scalable cluster management and job scheduling system for Linux clusters
-containing up to thousands of nodes. Components include machine status,
-partition management, job management, and scheduling modules.
+Requires: slurm-plugins
 
 %ifnos aix
 BuildRequires: ncurses-devel
 %endif
 %ifos linux
-BuildRequires: python 
+BuildRequires: python
 %endif
 %if %{slurm_with pam}
 BuildRequires: pam-devel
@@ -90,6 +89,15 @@ BuildRequires: pam-devel
 %if %{slurm_with readline}
 BuildRequires: readline-devel
 %endif
+%if %{slurm_with openssl}
+BuildRequires: openssl-devel >= 0.9.6 openssl >= 0.9.6
+%endif
+
+%description 
+SLURM is an open source, fault-tolerant, and highly
+scalable cluster management and job scheduling system for Linux clusters
+containing up to 65,536 nodes. Components include machine status,
+partition management, job management, scheduling and accounting modules.
 
 #  Allow override of sysconfdir via _slurm_sysconfdir.
 #  Note 'global' instead of 'define' needed here to work around apparent
@@ -117,6 +125,7 @@ BuildRequires: readline-devel
 %define _perlarch %(perl -e 'use Config; $T=$Config{installsitearch}; $P=$Config{installprefix}; $P1="$P/local"; $T =~ s/$P1//; $T =~ s/$P//; print $T;') 
 
 %define _perldir %{_prefix}%{_perlarch}
+%define _php_extdir %(php-config --extension-dir 2>/dev/null || echo %{_libdir}/php5)
 
 %package perlapi
 Summary: Perl API to SLURM.
@@ -153,12 +162,12 @@ SLURM authentication module for Brent Chun's authd
 %endif
 
 %if %{slurm_with munge}
-%package auth-munge
-Summary: SLURM auth implementation using Chris Dunlap's Munge
+%package munge
+Summary: SLURM authentication and crypto implementation using Munge
 Group: System Environment/Base
 Requires: slurm munge
 BuildRequires: munge-devel munge-libs
-%description auth-munge
+%description munge
 SLURM authentication module for Chris Dunlap's Munge
 %endif
 
@@ -181,6 +190,19 @@ BuildRequires: qsnetlibs
 SLURM switch plugin for Quadrics Elan3 or Elan4.
 %endif
 
+%package slurmdbd
+Summary: SLURM database daemon
+Group: System Environment/Base
+Requires: slurm-plugins
+%description slurmdbd
+SLURM database daemon
+
+%package plugins
+Summary: SLURM plugins (loadable shared objects)
+Group: System Environment/Base
+%description plugins
+SLURM plugins (loadable shared objects)
+
 %package torque
 Summary: Torque/PBS wrappers for transitition from Torque/PBS to SLURM.
 Group: Development/System
@@ -212,7 +234,7 @@ SLURM process tracking plugin for SGI job containers.
 #############################################################################
 
 %prep
-%setup -n slurm-1.2.27
+%setup -n slurm-1.3.3
 
 %build
 %configure --program-prefix=%{?_program_prefix:%{_program_prefix}} \
@@ -235,11 +257,11 @@ DESTDIR="$RPM_BUILD_ROOT" make install-contrib
 
 %ifos aix5.3
 mv ${RPM_BUILD_ROOT}%{_bindir}/srun ${RPM_BUILD_ROOT}%{_sbindir}
-mv ${RPM_BUILD_ROOT}%{_bindir}/slaunch ${RPM_BUILD_ROOT}%{_sbindir}
 %endif
 
 if [ -d /etc/init.d ]; then
-   install -D -m755 etc/init.d.slurm $RPM_BUILD_ROOT/etc/init.d/slurm
+   install -D -m755 etc/init.d.slurm    $RPM_BUILD_ROOT/etc/init.d/slurm
+   install -D -m755 etc/init.d.slurmdbd $RPM_BUILD_ROOT/etc/init.d/slurmdbd
 fi
 install -D -m644 etc/slurm.conf.example ${RPM_BUILD_ROOT}%{_sysconfdir}/slurm.conf.example
 install -D -m755 etc/slurm.epilog.clean ${RPM_BUILD_ROOT}%{_sysconfdir}/slurm.epilog.clean
@@ -251,18 +273,15 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/slurm/*.{a,la}
 LIST=./slurm.files
 touch $LIST
 if [ -d /etc/init.d ]; then
-   echo "/etc/init.d/slurm" >> $LIST
+   echo "/etc/init.d/slurm"    >> $LIST
 fi
-test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/task_affinity.so &&
-   echo %{_libdir}/slurm/task_affinity.so >> $LIST
 
-# Build file lists for optional plugin packages
-for plugin in auth_munge auth_authd; do
-   LIST=./${plugin}.files
-   touch $LIST
-   test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/${plugin}.so &&
-     echo %{_libdir}/slurm/${plugin}.so > $LIST
-done
+LIST=./munge.files
+touch $LIST
+test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/auth_munge.so   &&
+  echo %{_libdir}/slurm/auth_munge.so             >> $LIST
+test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/crypto_munge.so &&
+  echo %{_libdir}/slurm/crypto_munge.so           >> $LIST
 
 LIST=./switch_elan.files
 touch $LIST
@@ -290,11 +309,40 @@ test -f $RPM_BUILD_ROOT/%{_perldir}/Slurm.pm &&
   echo "%{_perldir}/Slurm.pm"                 >> $LIST
 test -f $RPM_BUILD_ROOT/%{_perldir}/auto/Slurm/Slurm.so &&
   echo "%{_perldir}/auto/Slurm/Slurm.so"      >> $LIST
+test -f $RPM_BUILD_ROOT/%{_mandir}/man3/Slurm.3 &&
+echo "%{_mandir}/man3/Slurm.3"                 >> $LIST
 test -f $RPM_BUILD_ROOT/%{_perldir}/auto/Slurm/Slurm.bs &&
   echo "%{_perldir}/auto/Slurm/Slurm.bs"      >> $LIST
 test -f $RPM_BUILD_ROOT/%{_perldir}/auto/Slurm/autosplit.ix &&
   echo "%{_perldir}/auto/Slurm/autosplit.ix"      >> $LIST
 
+LIST=./slurmdbd.files
+touch $LIST
+if [ -d /etc/init.d ]; then
+   echo "/etc/init.d/slurmdbd" >> $LIST
+fi
+
+LIST=./plugins.files
+test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/task_affinity.so &&
+   echo %{_libdir}/slurm/task_affinity.so >> $LIST
+test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/crypto_openssl.so &&
+   echo %{_libdir}/slurm/crypto_openssl.so >> $LIST
+test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/accounting_storage_gold.so
+   echo %{_libdir}/slurm/accounting_storage_gold.so >> $LIST
+
+# Build file lists for optional plugin packages
+for plugin in auth_authd; do
+   LIST=./${plugin}.files
+   touch $LIST
+   test -f $RPM_BUILD_ROOT/%{_libdir}/slurm/${plugin}.so &&
+     echo %{_libdir}/slurm/${plugin}.so > $LIST
+done
+
+
+
+
+
+
 LIST=./torque.files
 touch $LIST
 echo "%{_bindir}/pbsnodes"                    >> $LIST
@@ -342,7 +390,6 @@ rm -rf $RPM_BUILD_ROOT
 %doc RELEASE_NOTES
 %doc DISCLAIMER
 %doc COPYING
-%doc etc/slurm.conf.example
 %doc doc/html
 %{_bindir}/s*
 %{_sbindir}/slurmctld
@@ -350,43 +397,17 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/slurmstepd
 %ifos aix5.3
 %{_sbindir}/srun
-%{_sbindir}/slaunch
 %endif
 %{_libdir}/*.so*
 %{_libdir}/slurm/src/*
 %{_mandir}/man1/*
 %{_mandir}/man5/slurm.*
 %{_mandir}/man5/wiki.*
-%{_mandir}/man8/*
+%{_mandir}/man8/slurmctld.*
+%{_mandir}/man8/slurmd.*
+%{_mandir}/man8/slurmstepd*
+%{_mandir}/man8/spank*
 %dir %{_sysconfdir}
-%dir %{_libdir}/slurm
-%{_libdir}/slurm/checkpoint_none.so
-%{_libdir}/slurm/checkpoint_ompi.so
-%{_libdir}/slurm/jobacct_gold.so
-%{_libdir}/slurm/jobacct_linux.so
-%{_libdir}/slurm/jobacct_none.so
-%{_libdir}/slurm/jobcomp_none.so
-%{_libdir}/slurm/jobcomp_filetxt.so
-%{_libdir}/slurm/jobcomp_script.so
-%{_libdir}/slurm/proctrack_pgid.so
-%{_libdir}/slurm/proctrack_linuxproc.so
-%{_libdir}/slurm/sched_backfill.so
-%{_libdir}/slurm/sched_builtin.so
-%{_libdir}/slurm/sched_hold.so
-%{_libdir}/slurm/sched_gang.so
-%{_libdir}/slurm/sched_wiki.so
-%{_libdir}/slurm/sched_wiki2.so
-%{_libdir}/slurm/select_cons_res.so
-%{_libdir}/slurm/select_linear.so
-%{_libdir}/slurm/switch_none.so
-%{_libdir}/slurm/mpi_none.so
-%{_libdir}/slurm/mpi_mpich1_p4.so
-%{_libdir}/slurm/mpi_mpich1_shmem.so
-%{_libdir}/slurm/mpi_mpichgm.so
-%{_libdir}/slurm/mpi_mpichmx.so
-%{_libdir}/slurm/mpi_mvapich.so
-%{_libdir}/slurm/mpi_lam.so
-%{_libdir}/slurm/task_none.so
 %dir %{_libdir}/slurm/src
 %config %{_sysconfdir}/slurm.conf.example
 %config %{_sysconfdir}/slurm.epilog.clean
@@ -411,7 +432,7 @@ rm -rf $RPM_BUILD_ROOT
 #############################################################################
 
 %if %{slurm_with munge}
-%files -f auth_munge.files auth-munge
+%files -f munge.files munge
 %defattr(-,root,root)
 %endif
 #############################################################################
@@ -438,6 +459,55 @@ rm -rf $RPM_BUILD_ROOT
 %endif
 #############################################################################
 
+%files -f slurmdbd.files slurmdbd
+%defattr(-,root,root)
+%{_sbindir}/slurmdbd
+%{_mandir}/man5/slurmdbd.*
+%{_mandir}/man8/slurmdbd.*
+#############################################################################
+
+%files -f plugins.files plugins
+%defattr(-,root,root)
+%dir %{_libdir}/slurm
+%{_libdir}/slurm/accounting_storage_filetxt.so
+%{_libdir}/slurm/accounting_storage_mysql.so
+%{_libdir}/slurm/accounting_storage_none.so
+%{_libdir}/slurm/accounting_storage_pgsql.so
+%{_libdir}/slurm/accounting_storage_slurmdbd.so
+%{_libdir}/slurm/checkpoint_none.so
+%{_libdir}/slurm/checkpoint_ompi.so
+%{_libdir}/slurm/checkpoint_xlch.so
+%{_libdir}/slurm/jobacct_gather_aix.so
+%{_libdir}/slurm/jobacct_gather_linux.so
+%{_libdir}/slurm/jobacct_gather_none.so
+%{_libdir}/slurm/jobcomp_none.so
+%{_libdir}/slurm/jobcomp_filetxt.so
+%{_libdir}/slurm/jobcomp_mysql.so
+%{_libdir}/slurm/jobcomp_pgsql.so
+%{_libdir}/slurm/jobcomp_script.so
+%{_libdir}/slurm/jobcomp_slurmdbd.so
+%{_libdir}/slurm/proctrack_pgid.so
+%{_libdir}/slurm/proctrack_linuxproc.so
+%{_libdir}/slurm/sched_backfill.so
+%{_libdir}/slurm/sched_builtin.so
+%{_libdir}/slurm/sched_hold.so
+%{_libdir}/slurm/sched_gang.so
+%{_libdir}/slurm/sched_wiki.so
+%{_libdir}/slurm/sched_wiki2.so
+%{_libdir}/slurm/select_cons_res.so
+%{_libdir}/slurm/select_linear.so
+%{_libdir}/slurm/switch_none.so
+%{_libdir}/slurm/mpi_lam.so
+%{_libdir}/slurm/mpi_mpich1_p4.so
+%{_libdir}/slurm/mpi_mpich1_shmem.so
+%{_libdir}/slurm/mpi_mpichgm.so
+%{_libdir}/slurm/mpi_mpichmx.so
+%{_libdir}/slurm/mpi_mvapich.so
+%{_libdir}/slurm/mpi_none.so
+%{_libdir}/slurm/mpi_openmpi.so
+%{_libdir}/slurm/task_none.so
+#############################################################################
+
 %files -f torque.files torque
 %defattr(-,root,root)
 #############################################################################
@@ -460,6 +530,11 @@ rm -rf $RPM_BUILD_ROOT
 #        /etc/init.d/slurm stop
 #    fi
 #fi
+#if [ -x /etc/init.d/slurmdbd ]; then
+#    if /etc/init.d/slurmdbd status | grep -q running; then
+#        /etc/init.d/slurmdbd stop
+#    fi
+#fi
 
 %post
 if [ -x /sbin/ldconfig ]; then
@@ -484,6 +559,12 @@ if [ "$1" = 0 ]; then
             /etc/init.d/slurm stop
         fi
     fi
+    if [ -x /etc/init.d/slurmdbd ]; then
+        [ -x /sbin/chkconfig ] && /sbin/chkconfig --del slurmdbd
+        if /etc/init.d/slurmdbd status | grep -q running; then
+            /etc/init.d/slurmdbd stop
+        fi
+    fi
 fi
 
 %postun
diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in
index 53a6d9079da0c14565a8b7078b417be40c716fca..04fc802e251d02e5de4e59bf72e51ced8a8ade06 100644
--- a/slurm/slurm.h.in
+++ b/slurm/slurm.h.in
@@ -2,10 +2,11 @@
  *  slurm.h - Definitions for all of the SLURM RPCs
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>, 
  *	Joey Ekstrom <ekstrom1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -83,9 +84,11 @@ BEGIN_C_DECLS
 #if HAVE_INTTYPES_H
 #  include <inttypes.h>		/* for uint16_t, uint32_t definitions */
 #endif
+#include <stdbool.h>
 #include <stdio.h>		/* for FILE definitions */
+#include <sys/types.h>		/* for uid_t definition */
 #include <time.h>		/* for time_t definitions */
-#include <stdbool.h>
+#include <unistd.h>
 
 #ifdef CRAPPY_COMPILER
   /*
@@ -142,6 +145,14 @@ BEGIN_C_DECLS
    typedef struct jobacctinfo *jobacctinfo_t;     /* opaque data type */
 #endif
 
+/* Define allocation_msg_thread_t below to avoid including extraneous 
+   slurm headers */
+#ifndef __allocation_msg_thread_t_defined
+#  define  __allocation_msg_thread_t_defined
+   typedef struct allocation_msg_thread *allocation_msg_thread_t;
+#endif
+
+
 /*****************************************************************************\
  *      DEFINITIONS FOR VERSION MANAGEMENT
 \*****************************************************************************/
@@ -209,6 +220,8 @@ enum job_state_reason {
 	WAIT_PART_STATE,	/* requested partition is down */
 	WAIT_HELD,		/* job is held, priority==0 */
 	WAIT_TIME,		/* job waiting for specific begin time */
+	WAIT_LICENSES,		/* job is waiting for licenses */
+	WAIT_ASSOC_LIMIT,	/* user/bank job limit reached */
 	WAIT_TBD1,
 	WAIT_TBD2,
 	FAIL_DOWN_PARTITION,	/* partition for job is DOWN */
@@ -218,7 +231,8 @@ enum job_state_reason {
 	FAIL_LAUNCH,		/* unable to launch job */
 	FAIL_EXIT_CODE,		/* exit code was non-zero */
 	FAIL_TIMEOUT,		/* reached end of time limit */
-	FAIL_INACTIVE_LIMIT	/* reached slurm InactiveLimit */
+	FAIL_INACTIVE_LIMIT,	/* reached slurm InactiveLimit */
+	FAIL_BANK_ACCOUNT	/* invalid bank account */
 };
 
 enum job_acct_types {
@@ -253,6 +267,7 @@ enum select_data_type {
 	SELECT_DATA_ROTATE,	/* data-> uint16_t rotate */
 	SELECT_DATA_CONN_TYPE,	/* data-> uint16_t connection_type */
 	SELECT_DATA_BLOCK_ID,	/* data-> char *bg_block_id */
+	SELECT_DATA_NODES,	/* data-> char *nodes */
 	SELECT_DATA_IONODES,	/* data-> char *ionodes */
 	SELECT_DATA_NODE_CNT,	/* data-> uint32_t node_cnt */
 	SELECT_DATA_ALTERED,    /* data-> uint16_t altered */
@@ -261,7 +276,7 @@ enum select_data_type {
 	SELECT_DATA_LINUX_IMAGE,/* data-> char *linuximage */
 	SELECT_DATA_MLOADER_IMAGE,/* data-> char *mloaderimage */
 	SELECT_DATA_RAMDISK_IMAGE,/* data-> char *ramdiskimage */
-	SELECT_DATA_REBOOT	/* data-> uint16_t reboot */
+	SELECT_DATA_REBOOT,	/* data-> uint16_t reboot */
 };
 
 enum select_print_mode {
@@ -269,6 +284,7 @@ enum select_print_mode {
 	SELECT_PRINT_DATA,	/* Print just the data */
 	SELECT_PRINT_MIXED,	/* Print "field=value" */
 	SELECT_PRINT_BG_ID,	/* Print just the BG_ID */
+	SELECT_PRINT_NODES,	/* Print the nodelist */
 	SELECT_PRINT_CONNECTION,/* Print just the CONNECTION type */
 	SELECT_PRINT_ROTATE,    /* Print just the ROTATE */
 	SELECT_PRINT_GEOMETRY,	/* Print just the GEO */
@@ -278,21 +294,24 @@ enum select_print_mode {
 	SELECT_PRINT_LINUX_IMAGE,/* Print just the LINUX IMAGE */
 	SELECT_PRINT_MLOADER_IMAGE,/* Print just the MLOADER IMAGE */
 	SELECT_PRINT_RAMDISK_IMAGE,/* Print just the RAMDISK IMAGE */
-	SELECT_PRINT_REBOOT	/* Print just the REBOOT */
+	SELECT_PRINT_REBOOT,	/* Print just the REBOOT */
 };
 
 enum select_node_cnt {
 	SELECT_GET_NODE_SCALING,      /* Give scaling factor for node count */ 
 	SELECT_APPLY_NODE_MIN_OFFSET, /* Apply min offset to variable */
 	SELECT_APPLY_NODE_MAX_OFFSET, /* Apply max offset to variable */
-	SELECT_SET_NODE_CNT	      /* Set altered node cnt */
+	SELECT_SET_NODE_CNT,	      /* Set altered node cnt */
+	SELECT_SET_BP_CNT             /* Given a node cnt return the
+				       * base partition count */
 };
 
 /* jobacct data types */
 enum jobacct_data_type {
 	JOBACCT_DATA_TOTAL,	/* data-> jobacctinfo_t */
 	JOBACCT_DATA_PIPE,      /* data-> file descriptor */
-	JOBACCT_DATA_RUSAGE,	/* data-> struct rusage */
+	JOBACCT_DATA_RUSAGE,	/* data-> rusage set user_cpu_sec,
+				 * user_cpu_usec, sys_cpu_sec, sys_cpu_usec */
 	JOBACCT_DATA_MAX_VSIZE,	/* data-> uint32_t vsize */
 	JOBACCT_DATA_MAX_VSIZE_ID,	/* data-> jobacct_id_t vsize */
 	JOBACCT_DATA_TOT_VSIZE,	/* data-> uint32_t vsize */
@@ -328,6 +347,10 @@ typedef enum task_dist_states {
 	SLURM_DIST_UNKNOWN	/* unknown dist */
 } task_dist_states_t;
 
+/* Open stdout/err file mode, 0 for system default (JobFileAppend) */
+#define OPEN_MODE_APPEND	1
+#define OPEN_MODE_TRUNCATE	2
+
 typedef enum cpu_bind_type {	/* cpu binding type from --cpu_bind=... */
 	/* the following auto-binding flags are mutually exclusive */
 	CPU_BIND_TO_THREADS= 0x01, /* =threads */ 
@@ -369,14 +392,16 @@ enum node_states {
 };
 #define NODE_STATE_BASE       0x00ff
 #define NODE_STATE_FLAGS      0xff00
-#define NODE_RESUME           0x0100	/* Restore a DRAINED, DRAINING, or 
-					 * DOWN node to service (e.g. IDLE or 
-					 * ALLOCATED). Used in 
+#define NODE_RESUME           0x0100	/* Restore a DRAINED, DRAINING, DOWN 
+					 * or FAILING node to service (e.g. 
+					 * IDLE or ALLOCATED). Used in 
 					 * slurm_update_node() request */
-#define NODE_STATE_DRAIN      0x0200	/* node not be be allocated work */
+#define NODE_STATE_DRAIN      0x0200	/* node do not new allocated work */
 #define NODE_STATE_COMPLETING 0x0400	/* node is completing allocated job */
 #define NODE_STATE_NO_RESPOND 0x0800	/* node is not responding */
 #define NODE_STATE_POWER_SAVE 0x1000	/* node in power save mode */
+#define NODE_STATE_FAIL       0x2000	/* node is failing, do not allocate
+					 * new work */
 
 /* used to define the size of the credential.signature size
  * used to define the key size of the io_stream_header_t
@@ -423,53 +448,88 @@ typedef enum select_type_plugin_info {
 #define TASK_PARAM_CPUSETS 0x0001
 #define TASK_PARAM_SCHED   0x0002
 
-enum part_shared {
-	SHARED_NO = 0,		/* Nodes never shared in partition */
-	SHARED_YES,		/* Nodes possible to share in partition */
-	SHARED_FORCE,		/* Nodes always shares in partition */
-	SHARED_EXCLUSIVE	/* Nodes never shared even with cons_res */
-};
+#define SHARED_FORCE 0x8000
 
 /*****************************************************************************\
  *	PROTOCOL DATA STRUCTURE DEFINITIONS
 \*****************************************************************************/
 
 typedef struct job_descriptor {	/* For submit, allocate, and update requests */
+	char *account;		/* charge to specified account */
+	uint16_t acctg_freq;	/* accounting polling interval (seconds) */
+	char *alloc_node;	/* node making resource allocation request
+				 * NOTE: Normally set by slurm_submit* or 
+				 * slurm_allocate* function */
+	uint16_t alloc_resp_port; /* port to send allocation confirmation to */
+	uint32_t alloc_sid;	/* local sid making resource allocation request
+				 * NOTE: Normally set by slurm_submit* or 
+				 * slurm_allocate* function */
+	uint32_t argc;		/* number of arguments to the script */
+	char **argv;		/* arguments to the script */
+	time_t begin_time;	/* delay initiation until this time */
+	char *comment;		/* arbitrary comment (used by Moab scheduler) */
 	uint16_t contiguous;	/* 1 if job requires contiguous nodes,
 				 * 0 otherwise,default=0 */
-	uint16_t kill_on_node_fail; /* 1 if node failure to kill job, 
-				 * 0 otherwise,default=1 */
+	char *dependency;	/* syncrhonize job execution with other jobs */
 	char **environment;	/* environment variables to set for job, 
 				 *  name=value pairs, one per line */
-	uint16_t env_size;	/* element count in environment */
+	uint32_t env_size;	/* element count in environment */
+	char *err;		/* pathname of stderr */
+	char *exc_nodes;	/* comma separated list of nodes excluded
+				 * from job's allocation, default NONE */
 	char *features;		/* comma separated list of required features, 
 				 * default NONE */
+	uint32_t group_id;	/* group to assume, if run as root. */ 
 	uint16_t immediate;	/* 1 if allocate to run or fail immediately, 
 				 * 0 if to be queued awaiting resources */
+	char *in;		/* pathname of stdin */
 	uint32_t job_id;	/* job ID, default set by SLURM */
+	uint16_t kill_on_node_fail; /* 1 if node failure to kill job, 
+				 * 0 otherwise,default=1 */
+	char *licenses;		/* licenses required by the job */
+	uint16_t mail_type;	/* see MAIL_JOB_ definitions above */
+	char *mail_user;	/* user to receive notification */
 	char *name;		/* name of the job, default "" */
-	/* job constraints: */
-	uint16_t job_min_procs;    /* minimum processors per node, default=0 */
-	uint16_t job_min_sockets;  /* minimum sockets per node, default=0 */
-	uint16_t job_min_cores;    /* minimum cores per processor, default=0 */
-	uint16_t job_min_threads;  /* minimum threads per core, default=0 */
-	uint32_t job_min_memory;   /* minimum real memory per node, default=0 */
-	uint32_t job_max_memory;   /* maximum real memory per node, default=0 */
-	uint32_t job_min_tmp_disk; /* minimum tmp disk per node, default=0 */
+	char *network;		/* network use spec */
+	uint16_t nice;		/* requested priority change, 
+				 * NICE_OFFSET == no change */
+	uint32_t num_tasks;	/* number of tasks to be started, for batch only */
+	uint8_t open_mode;	/* out/err open mode truncate or append,
+				 * see OPEN_MODE_* */
+	uint16_t other_port;	/* port to send various notification msg to */
+	char *out;		/* pathname of stdout */
+	uint8_t overcommit;	/* over subscribe resources, for batch only */
 	char *partition;	/* name of requested partition, 
 				 * default in SLURM config */
+	uint16_t plane_size;	/* plane size when task_dist =
+				   SLURM_DIST_PLANE */
 	uint32_t priority;	/* relative priority of the job,  
 				 * explicitly set only for user root, 
 				 * 0 == held (don't initiate) */
+	char *resp_host;	/* NOTE: Set by slurmctld */
 	char *req_nodes;	/* comma separated list of required nodes
 				 * default NONE */
-	char *exc_nodes;	/* comma separated list of nodes excluded
-				 * from job's allocation, default NONE */
+	uint16_t requeue;	/* enable or disable job requeue option */
+
+	char *script;		/* the actual job script, default NONE */
 	uint16_t shared;	/* 1 if job can share nodes with other jobs,
 				 * 0 if job needs exclusive access to the node,
-				 * or NO_VAL to accept the system default. */
+				 * or NO_VAL to accept the system default.
+				 * SHARED_FORCE to eliminate user control. */
+	uint16_t task_dist;	/* see enum task_dist_state */
 	uint32_t time_limit;	/* maximum run time in minutes, default is
 				 * partition limit */
+	uint32_t user_id;	/* set only if different from current UID, 
+				 * can only be explicitly set by user root */
+	char *work_dir;		/* pathname of working directory */
+
+	/* job constraints: */
+	uint16_t job_min_procs;    /* minimum processors per node, default=0 */
+	uint16_t job_min_sockets;  /* minimum sockets per node, default=0 */
+	uint16_t job_min_cores;    /* minimum cores per processor, default=0 */
+	uint16_t job_min_threads;  /* minimum threads per core, default=0 */
+	uint32_t job_min_memory;   /* minimum real memory per node, default=0 */
+	uint32_t job_min_tmp_disk; /* minimum tmp disk per node, default=0 */
 	uint32_t num_procs;	/* total count of processors required, 
 				 * default=0 */
 	uint32_t min_nodes;	/* minimum number of nodes required by job, 
@@ -492,49 +552,7 @@ typedef struct job_descriptor {	/* For submit, allocate, and update requests */
 	uint16_t ntasks_per_node;/* number of tasks to invoke on each node */
 	uint16_t ntasks_per_socket;/* number of tasks to invoke on each socket */
 	uint16_t ntasks_per_core;/* number of tasks to invoke on each core */
-	char *script;		/* the actual job script, default NONE */
-	char **argv;		/* arguments to the script */
-	uint16_t argc;		/* number of arguments to the script */
-	char *err;		/* pathname of stderr */
-	char *in;		/* pathname of stdin */
-	char *out;		/* pathname of stdout */
-	uint32_t user_id;	/* set only if different from current UID, 
-				 * can only be explicitly set by user root */
-	uint32_t group_id;	/* group to assume, if run as root. */ 
-	char *work_dir;		/* pathname of working directory */
-	char *alloc_node;	/* node making resource allocation request
-				 * NOTE: Normally set by slurm_submit* or 
-				 * slurm_allocate* function */
-	uint32_t alloc_sid;	/* local sid making resource allocation request
-				 * NOTE: Normally set by slurm_submit* or 
-				 * slurm_allocate* function */
 
-	/* If the requested allocation is not immediately available,
-	 * The controller sends the RESPONSE_RESOURCE_ALLOCATION message to
-	 * the address designated by the alloc_hostname and alloc_port.
-	 * All other messages (SRUN_PING, SRUN_TIMEOUT, etc.) are sent to
-	 * the address designated by other_hostname/other_port.
-	 */
-	char    *alloc_resp_hostname;
-	uint16_t alloc_resp_port;
-	char    *other_hostname;
-	uint16_t other_port;
-
-	uint32_t dependency;	/* defer until specified job completes */
-	uint16_t overcommit;	/* over subscribe resources, for batch only */
-	uint32_t num_tasks;	/* number of tasks to be started, for batch only */
-	uint16_t nice;		/* requested priority change, 
-				 * NICE_OFFSET == no change */
-	char *account;		/* charge to specified account */
-	char *network;		/* network use spec */
-	char *comment;		/* arbitrary comment (used by Moab scheduler) */
-	uint16_t task_dist;	/* see enum task_dist_state */
-	uint16_t plane_size;	/* plane size when task_dist =
-				   SLURM_DIST_PLANE */
-	time_t begin_time;	/* delay initiation until this time */
-	uint16_t mail_type;	/* see MAIL_JOB_ definitions above */
-	char *mail_user;	/* user to receive notification */
-	uint16_t no_requeue;	/* disable job requeue option */
 /*
  * The following parameters are only meaningful on a Blue Gene
  * system at present. Some will be of value on other system. Don't remove these
@@ -560,27 +578,62 @@ typedef struct job_descriptor {	/* For submit, allocate, and update requests */
 } job_desc_msg_t;
 
 typedef struct job_info {
-	uint32_t job_id;	/* job ID */
-	char *name;		/* name of the job */
-	uint16_t batch_flag;	/* 1 if batch: queued job with script */
-	uint32_t alloc_sid;	/* local sid making resource alloc */
+	char *account;		/* charge to specified account */
 	char    *alloc_node;	/* local node making resource alloc */
-	uint32_t user_id;	/* user the job runs as */
+	uint32_t alloc_sid;	/* local sid making resource alloc */
+	uint16_t batch_flag;	/* 1 if batch: queued job with script */
+	char *command;		/* command to be executed */
+	char *comment;		/* arbitrary comment (used by Moab scheduler) */
+	uint16_t contiguous;	/* 1 if job requires contiguous nodes */
+	uint16_t cpus_per_task;	/* number of processors required for each task */
+	char *dependency;	/* syncrhonize job execution with other jobs */
+	time_t end_time;	/* time of termination, actual or expected */
+	char *exc_nodes;	/* comma separated list of excluded nodes */
+	int *exc_node_inx;	/* excluded list index pairs into node_table:
+				 * start_range_1, end_range_1, 
+				 * start_range_2, .., -1  */
+	uint32_t exit_code;	/* exit code for job (status from wait call) */
+	char *features;		/* comma separated list of required features */
 	uint32_t group_id;	/* group job sumitted as */
+	uint32_t job_id;	/* job ID */
+	uint16_t job_min_cores;    /* minimum cores per processor, default=0 */
+	uint32_t job_min_memory;   /* minimum real memory per node, default=0 */
+	uint16_t job_min_procs;	   /* minimum processors per node, default=0 */
+	uint16_t job_min_sockets;  /* minimum sockets per node, default=0 */
+	uint16_t job_min_threads;  /* minimum threads per core, default=0 */
+	uint32_t job_min_tmp_disk; /* minimum tmp disk per node, default=0 */
 	uint16_t job_state;	/* state of the job, see enum job_states */
-	uint32_t time_limit;	/* maximum run time in minutes or INFINITE */
-	time_t submit_time;	/* time of job submission */
-	time_t start_time;	/* time execution begins, actual or expected */
-	time_t end_time;	/* time of termination, actual or expected */
-	time_t suspend_time;	/* time job last suspended or resumed */
-	time_t pre_sus_time;	/* time job ran prior to last suspend */
-	uint32_t priority;	/* relative priority of the job, 
-				 * 0=held, 1=required nodes DOWN/DRAINED */
+	char *licenses;		/* licenses required by the job */
+	char *name;		/* name of the job */
+	char *network;		/* network specification */
 	char *nodes;		/* list of nodes allocated to job */
 	int *node_inx;		/* list index pairs into node_table for *nodes:
 				 * start_range_1, end_range_1, 
 				 * start_range_2, .., -1  */
+	uint16_t ntasks_per_core;/* number of tasks to invoke on each core */
+	uint16_t ntasks_per_node;/* number of tasks to invoke on each node */
+	uint16_t ntasks_per_socket;/* number of tasks to invoke on each socket */
 	char *partition;	/* name of assigned partition */
+	time_t pre_sus_time;	/* time job ran prior to last suspend */
+	uint32_t priority;	/* relative priority of the job, 
+				 * 0=held, 1=required nodes DOWN/DRAINED */
+	char *req_nodes;	/* comma separated list of required nodes */
+	int *req_node_inx;	/* required list index pairs into node_table: 
+				 * start_range_1, end_range_1, 
+				 * start_range_2, .., -1  */
+        uint16_t requeue;       /* enable or disable job requeue option */
+	select_jobinfo_t select_jobinfo; /* opaque data type,
+				 * process using select_g_get_jobinfo() */
+	uint16_t shared;	/* 1 if job can share nodes with other jobs */
+	time_t start_time;	/* time execution begins, actual or expected */
+	uint16_t state_reason;	/* reason job still pending or failed, see
+				 * slurm.h:enum job_state_reason */
+	time_t submit_time;	/* time of job submission */
+	time_t suspend_time;	/* time job last suspended or resumed */
+	uint32_t time_limit;	/* maximum run time in minutes or INFINITE */
+	uint32_t user_id;	/* user the job runs as */
+	char *work_dir;		/* pathname of working directory */
+
 	uint16_t num_cpu_groups;/* elements in below cpu arrays */
 	uint32_t *cpus_per_node;/* cpus per node */
 	uint32_t *cpu_count_reps;/* how many nodes have same cpu count */
@@ -593,38 +646,6 @@ typedef struct job_info {
 	uint16_t max_cores;	/* maximum number of cores per cpu */
 	uint16_t min_threads;	/* minimum number of threads per core */
 	uint16_t max_threads;	/* maximum number of threads per core */
-	uint16_t shared;	/* 1 if job can share nodes with other jobs */
-	uint16_t contiguous;	/* 1 if job requires contiguous nodes */
-	uint16_t cpus_per_task;	/* number of processors required for each task */
-	uint16_t ntasks_per_node;/* number of tasks to invoke on each node */
-	uint16_t ntasks_per_socket;/* number of tasks to invoke on each socket */
-	uint16_t ntasks_per_core;/* number of tasks to invoke on each core */
-	/* job constraints: */
-	uint16_t job_min_procs;	   /* minimum processors per node, default=0 */
-	uint16_t job_min_sockets;  /* minimum sockets per node, default=0 */
-	uint16_t job_min_cores;    /* minimum cores per processor, default=0 */
-	uint16_t job_min_threads;  /* minimum threads per core, default=0 */
-	uint32_t job_min_memory;   /* minimum real memory per node, default=0 */
-	uint32_t job_max_memory;   /* maximum real memory per node, default=0 */
-	uint32_t job_min_tmp_disk; /* minimum tmp disk per node, default=0 */
-	char *req_nodes;	/* comma separated list of required nodes */
-	int *req_node_inx;	/* required list index pairs into node_table: 
-				 * start_range_1, end_range_1, 
-				 * start_range_2, .., -1  */
-	char *exc_nodes;	/* comma separated list of excluded nodes */
-	int *exc_node_inx;	/* excluded list index pairs into node_table:
-				 * start_range_1, end_range_1, 
-				 * start_range_2, .., -1  */
-	char *features;		/* comma separated list of required features */
-	uint32_t dependency;	/* defer until specified job completes */
-	uint32_t exit_code;	/* exit code for job (status from wait call) */
-	char *account;		/* charge to specified account */
-	uint16_t state_reason;	/* reason job still pending or failed, see
-				 * slurm.h:enum job_state_reason */
-	char *network;		/* network specification */
-	char *comment;		/* arbitrary comment (used by Moab scheduler) */
-	select_jobinfo_t select_jobinfo; /* opaque data type,
-			* process using select_g_get_jobinfo() */
 } job_info_t;
 
 typedef struct job_info_msg {
@@ -634,21 +655,22 @@ typedef struct job_info_msg {
 } job_info_msg_t;
 
 typedef struct slurm_step_layout {
-	uint16_t node_cnt;	/* node count */
+	uint32_t node_cnt;	/* node count */
 	uint32_t task_cnt;	/* total number of tasks in the step */
+
 	char *node_list;        /* list of nodes in step */
 	/* Array of length "node_cnt". Each element of the array
-	   is the number of tasks assigned to the corresponding node */
+	 * is the number of tasks assigned to the corresponding node */
 	uint16_t *tasks;
 
 	/* Array (of length "node_cnt") of task ID arrays.  The length
-	   of each subarray is designated by the corresponding value in
-           the tasks array. */
+	 * of each subarray is designated by the corresponding value in
+         * the tasks array. */
 	uint32_t **tids;	/* host id => task id mapping */
 
 	uint16_t task_dist;	/* see enum task_dist_state */
 	uint16_t plane_size;	/* plane size when task_dist =
-				   SLURM_DIST_PLANE */
+				 * SLURM_DIST_PLANE */
 } slurm_step_layout_t;
 
 typedef struct slurm_step_io_fds {
@@ -678,6 +700,33 @@ typedef struct task_ext_msg {
 	uint32_t return_code;
 } task_exit_msg_t;
 
+typedef struct srun_ping_msg {
+	uint32_t job_id;	/* slurm job_id */
+	uint32_t step_id;	/* step_id or NO_VAL */
+} srun_ping_msg_t;
+
+typedef struct srun_job_complete_msg {
+        uint32_t job_id;        /* slurm job_id */
+        uint32_t step_id;       /* step_id or NO_VAL */
+} srun_job_complete_msg_t;
+
+typedef struct srun_timeout_msg {
+	uint32_t job_id;	/* slurm job_id */
+	uint32_t step_id;	/* step_id or NO_VAL */
+	time_t   timeout;	/* when job scheduled to be killed */
+} srun_timeout_msg_t;
+
+typedef struct srun_user_msg {
+	uint32_t job_id;	/* slurm job_id */
+	char *msg;		/* message to user's srun */
+} srun_user_msg_t;
+
+typedef struct srun_node_fail_msg {
+	uint32_t job_id;	/* slurm job_id */
+	uint32_t step_id;	/* step_id or NO_VAL */
+	char *nodelist;		/* name of failed node(s) */
+} srun_node_fail_msg_t;
+
 typedef struct {
 	uint32_t job_id;	/* job ID */
 	uid_t uid;
@@ -692,19 +741,29 @@ typedef struct {
 				   SLURM_DIST_PLANE */
 	char *node_list;	/* list of required nodes */
 	char *network;		/* network use spec */
+	uint16_t immediate;	/* 1 if allocate to run or fail immediately, 
+				 * 0 if to be queued awaiting resources */
+	uint16_t exclusive;	/* 1 if CPUs not shared with other steps */
 	bool overcommit;	/* "true" to allow the allocation of more tasks
 				   to a node than available processors,
 				   "false" to accept at most one task per
 				   processor. "false" by default. */
+	uint16_t ckpt_interval;	/* checkpoint interval in minutes */
+	char *ckpt_path;	/* path to store checkpoint image files */
+	uint16_t verbose_level; /* for extra logging decisions in step
+				   launch api */
+
+	uint16_t mem_per_task;	/* memory required per task (MB), 0=no limit */
 } slurm_step_ctx_params_t;
 
 typedef struct {
-	uint16_t argc;
+	uint32_t argc;
 	char **argv;
-	uint16_t envc;
+	uint32_t envc;
 	char **env;
 	char *cwd;
 	bool user_managed_io;
+	uint32_t msg_timeout; /* timeout set for sending message */    
 
 	/* START - only used if user_managed_io is false */
 	bool buffered_stdio;
@@ -726,6 +785,9 @@ typedef struct {
 	uint16_t mem_bind_type;	/* use mem_bind_type_t */
 	char *mem_bind;
 
+	uint16_t max_sockets;
+	uint16_t max_cores;
+	uint16_t max_threads;
 	uint16_t cpus_per_task;
 	uint16_t ntasks_per_node;
 	uint16_t ntasks_per_socket;
@@ -734,6 +796,10 @@ typedef struct {
 	uint16_t plane_size;
 
 	char *mpi_plugin_name;
+	uint8_t open_mode;
+	uint16_t acctg_freq;
+	bool pty;
+	char *ckpt_path;
 } slurm_step_launch_params_t;
 
 typedef struct {
@@ -741,6 +807,13 @@ typedef struct {
 	void (*task_finish)(task_exit_msg_t *);
 } slurm_step_launch_callbacks_t;
 
+typedef struct {
+	void (*ping)(srun_ping_msg_t *);
+	void (*job_complete)(srun_job_complete_msg_t *);
+	void (*timeout)(srun_timeout_msg_t *);
+	void (*user_msg)(srun_user_msg_t *);
+	void (*node_fail)(srun_node_fail_msg_t *);
+} slurm_allocation_callbacks_t;
 
 typedef struct {
 	uint32_t job_id;	/* job ID */
@@ -756,6 +829,8 @@ typedef struct {
 	int *node_inx;		/* list index pairs into node_table for *nodes:
 				 * start_range_1, end_range_1,
 				 * start_range_2, .., -1  */
+	uint16_t ckpt_interval;	/* checkpoint interval in minutes */
+	char *ckpt_path;	/* path to store checkpoint image files */
 } job_step_info_t;
 
 typedef struct job_step_info_response_msg {
@@ -776,7 +851,9 @@ typedef struct node_info {
 	uint32_t real_memory;	/* configured MB of real memory on the node */
 	uint32_t tmp_disk;	/* configured MB of total disk in TMP_FS */
 	uint32_t weight;	/* arbitrary priority of node for scheduling */
+	char *arch;		/* computer architecture */
 	char *features;		/* arbitrary list of features for node */
+	char *os;		/* operating system currently running */
 	char *reason;   	/* reason for node being DOWN or DRAINING */
 } node_info_t;
 
@@ -791,24 +868,26 @@ typedef struct job_alloc_info_msg {
 } job_alloc_info_msg_t;
 
 typedef struct partition_info {
-	char *name;		/* name of the partition */
-	uint32_t max_time;	/* minutes or INFINITE */
-	uint32_t max_nodes;	/* per job or INFINITE */
-	uint32_t min_nodes;	/* per job */
-	uint32_t total_nodes;	/* total number of nodes in the partition */
-	uint32_t total_cpus;	/* total number of cpus in the partition */
-	uint16_t node_scaling;	/* select plugin node scaling factor */
+	char *allow_groups;	/* comma delimited list of groups, 
+				 * null indicates all */
 	uint16_t default_part;	/* 1 if this is default partition */
+	uint16_t disable_root_jobs; /* 1 if user root jobs disabled */
 	uint16_t hidden;	/* 1 if partition is hidden by default */
-	uint16_t root_only;	/* 1 if allocate must come for user root */
-	uint16_t shared;	/* See part_shared above */
-	uint16_t state_up;	/* 1 if state is up, 0 if down */
-	char *nodes;		/* list names of nodes in partition */
+	uint32_t max_nodes;	/* per job or INFINITE */
+	uint16_t max_share;	/* number of jobs to gang schedule */
+	uint32_t max_time;	/* minutes or INFINITE */
+	uint32_t min_nodes;	/* per job */
+	char *name;		/* name of the partition */
 	int *node_inx;		/* list index pairs into node_table:
 				 * start_range_1, end_range_1, 
 				 * start_range_2, .., -1  */
-	char *allow_groups;	/* comma delimited list of groups, 
-				 * null indicates all */
+	uint16_t node_scaling;	/* select plugin node scaling factor */
+	char *nodes;		/* list names of nodes in partition */
+	uint16_t priority;	/* scheduling priority for jobs */
+	uint16_t root_only;	/* 1 if allocate must come for user root */
+	uint16_t state_up;	/* 1 if state is up, 0 if down */
+	uint32_t total_cpus;	/* total number of cpus in the partition */
+	uint32_t total_nodes;	/* total number of nodes in the partition */
 } partition_info_t;
 
 typedef struct delete_partition_msg {
@@ -848,46 +927,81 @@ typedef struct partition_info_msg {
 
 typedef struct slurm_ctl_conf {
 	time_t last_update;	/* last update time of the build parameters */
+	uint16_t accounting_storage_enforce; /* job requires valid association:
+					* user/account/partition/cluster */
+	char *accounting_storage_host; /* accounting storage host */
+	char *accounting_storage_loc; /* accounting storage (db table)
+				       * location */
+	char *accounting_storage_pass; /* accounting storage
+					    password */
+	uint32_t accounting_storage_port;/* node accountinging storage port */
+	char *accounting_storage_type; /* accounting storage type */
+	char *accounting_storage_user; /* accounting storage user */
 	char *authtype;		/* authentication type */
 	char *backup_addr;	/* comm path of slurmctld secondary server */
 	char *backup_controller;/* name of slurmctld secondary server */
+	time_t boot_time;	/* time slurmctld last booted */
 	uint16_t cache_groups;	/* cache /etc/groups to avoid initgroups(2) */
 	char *checkpoint_type;	/* checkpoint plugin type */
+	char *cluster_name;     /* general name of the entire cluster */
 	char *control_addr;	/* comm path of slurmctld primary server */
 	char *control_machine;	/* name of slurmctld primary server */
+	char *crypto_type;	/* cryptographic signature plugin */
+	uint32_t def_mem_per_task; /* default MB memory per spawned task */
 	uint16_t disable_root_jobs; /* if set then user root can't run jobs */
 	char *epilog;		/* pathname of job epilog */
+	uint32_t epilog_msg_time;  /* usecs for slurmctld to process an
+				 * epilog complete message */
+	uint16_t fast_schedule;	/* 1 to *not* check configurations by node
+				 * (only check configuration file, faster) */
 	uint32_t first_job_id;	/* first slurm generated job_id to assign */
 	uint32_t next_job_id;	/* next slurm generated job_id to assign */
-	uint16_t fast_schedule;	/* 1 to *not* check configurations by node 
-				 * (only check configuration file, faster) */
+	uint16_t get_env_timeout; /* timeout for srun --get-user-env option */
+	uint16_t health_check_interval;	/* secs between health checks */
+	char * health_check_program;	/* pathname of health check program */
 	uint16_t inactive_limit;/* seconds of inactivity before a
 				 * inactive resource allocation is released */
-	char *job_acct_logfile;	/* job accounting log location */
-	uint16_t job_acct_freq; /* poll frequency for job accounting plugins */
-	char *job_acct_type;	/* job accounting type */
-	char *job_comp_type;	/* job completion logger type */
+	char *job_acct_gather_type; /* job accounting gather type */
+	uint16_t job_acct_gather_freq; /* poll frequency for job accounting 
+					* gather plugins */
+	char *job_comp_host;	/* job completion logging host */
 	char *job_comp_loc;	/* job completion logging location */
+	char *job_comp_pass;	/* job completion storage password */
+	uint32_t job_comp_port;	/* job completion storage port */
+	char *job_comp_type;	/* job completion storage type */
+	char *job_comp_user;	/* job completion storage user */
+	char *job_credential_private_key;	/* path to private key */
+	char *job_credential_public_certificate;/* path to public certificate*/
 	uint16_t job_file_append; /* if set, append to stdout/err file */
-	uint16_t get_env_timeout; /* secs allowed for srun --get-user-env */
+	uint16_t job_requeue;	/* If set, jobs get requeued on node failre */
 	uint16_t kill_wait;	/* seconds between SIGXCPU to SIGKILL 
 				 * on job termination */
+	char *licenses;		/* licenses available on this cluster */
 	char *mail_prog;	/* pathname of mail program */
 	uint16_t max_job_cnt;	/* maximum number of active jobs */
+	uint32_t max_mem_per_task; /* maximum MB memory per spawned task */
 	uint16_t min_job_age;	/* COMPLETED jobs over this age (secs) 
 	                         * purged from in memory records */
 	char *mpi_default;	/* Default version of MPI in use */
 	uint16_t msg_timeout;	/* message timeout */
+	char *node_prefix;      /* prefix of nodes in partition, only set in 
+				   bluegene clusters NULL otherwise */
 	char *plugindir;	/* pathname to plugins */
 	char *plugstack;        /* pathname to plugin stack config file */
+	uint16_t private_data;	/* block viewing of other user jobs */
 	char *proctrack_type;	/* process tracking plugin type */
 	char *prolog;		/* pathname of job prolog */
 	uint16_t propagate_prio_process; /* 1 if process priority should
 				          * be propagated */
         char *propagate_rlimits;/* Propagate (all/specific) resource limits */
         char *propagate_rlimits_except;/* Propagate all rlimits except these */
+	uint16_t resume_rate;	/* nodes to make full power, per minute */
+	char *resume_program;	/* program to make nodes full power */
 	uint16_t ret2service;	/* 1 return DOWN node to service at 
 				 * registration */
+	char *sched_params;	/* SchedulerParameters OR 
+				 * contents of scheduler plugin config file */
+	uint16_t sched_time_slice;	/* gang scheduler slice time, secs */
 	char *schedtype;	/* type of scheduler to use */
 	uint16_t schedport;	/* port for scheduler connection */
 	uint16_t schedrootfltr;	/* 1 if rootOnly partitions should be
@@ -905,34 +1019,35 @@ typedef struct slurm_ctl_conf {
 				 * on non-responding primarly controller */
 	uint16_t slurmd_debug;	/* slurmd logging level */
 	char *slurmd_logfile;	/* where slurmd error log gets written */
+	char *slurmd_pidfile;   /* where to put slurmd pidfile           */
 	uint32_t slurmd_port;	/* default communications port to slurmd */
 	char *slurmd_spooldir;	/* where slurmd put temporary state info */
-	char *slurmd_pidfile;   /* where to put slurmd pidfile           */
 	uint16_t slurmd_timeout;/* how long slurmctld waits for slurmd before 
 				 * considering node DOWN */
 	char *slurm_conf;	/* pathname of slurm config file */
+	char *srun_epilog;      /* srun epilog program */
+	char *srun_prolog;      /* srun prolog program */
 	char *state_save_location;/* pathname of slurmctld state save
 				 * directory */
+	char *suspend_exc_nodes;/* nodes to not make power saving */
+	char *suspend_exc_parts;/* partitions to not make power saving */
+	char *suspend_program;	/* program to make nodes power saving */
+	uint16_t suspend_rate;	/* nodes to make power saving, per minute */
+	uint16_t suspend_time;	/* node idle for this long before power save mode */
 	char *switch_type;	/* switch or interconnect type */
 	char *task_epilog;	/* pathname of task launch epilog */
 	char *task_plugin;	/* task launch plugin */
 	uint16_t task_plugin_param;	/* see TASK_PARAM_* */
 	char *task_prolog;	/* pathname of task launch prolog */
 	char *tmp_fs;		/* pathname of temporary file system */
-	uint16_t wait_time;	/* default job --wait time */
-	char *job_credential_private_key;	/* path to private key */
-	char *job_credential_public_certificate;/* path to public certificate*/
-	char *srun_prolog;      /* srun prolog program */
-	char *srun_epilog;      /* srun epilog program */
-	char *node_prefix;      /* prefix of nodes in partition only set in 
-				   bluegene clusters NULL otherwise */
 	uint16_t tree_width;    /* number of threads per node to span */
-	uint16_t use_pam;	/* enable/disable PAM support */
 	char *unkillable_program; /* program run by the slurmstepd when
                                    * processes in a job step are unkillable */
 	uint16_t unkillable_timeout; /* time in seconds, after processes in a
                                       * job step have been signalled, before
                                       * they are considered "unkillable". */
+	uint16_t use_pam;	/* enable/disable PAM support */
+	uint16_t wait_time;	/* default job --wait time */
 } slurm_ctl_conf_t;
 
 typedef struct slurmd_status_msg {
@@ -969,20 +1084,23 @@ typedef struct partition_info update_part_msg_t;
 
 /* Opaque data type for slurm_step_ctx_* functions */
 typedef struct slurm_step_ctx_struct *slurm_step_ctx;
+typedef struct slurm_step_ctx_struct slurm_step_ctx_t;
 
 #define TRIGGER_RES_TYPE_JOB   1
 #define TRIGGER_RES_TYPE_NODE  2
-#define TRIGGER_TYPE_UP        0x01
-#define TRIGGER_TYPE_DOWN      0x02
-#define TRIGGER_TYPE_TIME      0x04
-#define TRIGGER_TYPE_FINI      0x08
-#define TRIGGER_TYPE_RECONFIG  0x10
-#define TRIGGER_TYPE_BLOCK_ERR 0x20
-#define TRIGGER_TYPE_IDLE      0x40
+#define TRIGGER_TYPE_UP        0x0001
+#define TRIGGER_TYPE_DOWN      0x0002
+#define TRIGGER_TYPE_FAIL      0x0004
+#define TRIGGER_TYPE_TIME      0x0008
+#define TRIGGER_TYPE_FINI      0x0010
+#define TRIGGER_TYPE_RECONFIG  0x0020
+#define TRIGGER_TYPE_BLOCK_ERR 0x0040
+#define TRIGGER_TYPE_IDLE      0x0080
+#define TRIGGER_TYPE_DRAINED   0x0100
 
 typedef struct trigger_info {
 	uint32_t trig_id;	/* trigger ID */
-	uint8_t  res_type;	/* TRIGGER_RES_TYPE_* */
+	uint16_t res_type;	/* TRIGGER_RES_TYPE_* */
 	char *   res_id;	/* resource ID */
 	uint16_t trig_type;	/* TRIGGER_TYPE_* */
 	uint16_t offset;	/* seconds from trigger, 0x8000 origin */
@@ -1100,6 +1218,26 @@ extern int slurm_allocation_lookup_lite PARAMS((
  */
 extern char *slurm_read_hostfile PARAMS((char *filename, int n));
 
+/*
+ * slurm_allocation_msg_thr_create - startup a message handler talking 
+ * with the controller dealing with messages from the controller during an 
+ * allocation. 
+ * IN port - port we are listening for messages on from the controller
+ * IN callbacks - callbacks for different types of messages
+ * RET allocation_msg_thread_t * or NULL on failure
+ */
+extern allocation_msg_thread_t *slurm_allocation_msg_thr_create PARAMS(
+	(uint16_t *port, const slurm_allocation_callbacks_t *callbacks));
+
+/*
+ * slurm_allocation_msg_thr_destroy - shutdown the message handler talking 
+ * with the controller dealing with messages from the controller during an
+ * allocation. 
+ * IN msg_thr - allocation_msg_thread_t pointer allocated with
+ *              slurm_allocation_msg_thr_create
+ */
+extern void slurm_allocation_msg_thr_destroy PARAMS(
+	(allocation_msg_thread_t * msg_thr));
 /*
  * slurm_submit_batch_job - issue RPC to submit a job for later execution
  * NOTE: free the response using slurm_free_submit_response_response_msg
@@ -1229,15 +1367,27 @@ extern void slurm_step_ctx_params_t_init PARAMS((slurm_step_ctx_params_t *ptr));
  * RET the step context or NULL on failure with slurm errno set
  * NOTE: Free allocated memory using slurm_step_ctx_destroy.
  */
-extern slurm_step_ctx slurm_step_ctx_create PARAMS((
+extern slurm_step_ctx_t *slurm_step_ctx_create PARAMS((
 	const slurm_step_ctx_params_t *step_params));
 
+/*
+ * slurm_step_ctx_create_no_alloc - Create a job step and its context without
+ *                                  getting an allocation. 
+ * IN step_params - job step parameters
+ * IN step_id     - since we are faking it give me the id to use
+ * RET the step context or NULL on failure with slurm errno set
+ * NOTE: Free allocated memory using slurm_step_ctx_destroy.
+ */
+extern slurm_step_ctx_t *
+slurm_step_ctx_create_no_alloc PARAMS((
+	const slurm_step_ctx_params_t *step_params, uint32_t step_id));
+
 /*
  * slurm_step_ctx_get - get parameters from a job step context.
  * IN ctx - job step context generated by slurm_step_ctx_create
  * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
  */
-extern int slurm_step_ctx_get PARAMS((slurm_step_ctx ctx, 
+extern int slurm_step_ctx_get PARAMS((slurm_step_ctx_t *ctx, 
 	int ctx_key, ...));
 
 /*
@@ -1262,14 +1412,14 @@ extern int slurm_jobinfo_ctx_get PARAMS((switch_jobinfo_t jobinfo,
  * IN ctx - job step context generated by slurm_step_ctx_create
  * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
  */
-extern int slurm_step_ctx_daemon_per_node_hack PARAMS((slurm_step_ctx ctx));
+extern int slurm_step_ctx_daemon_per_node_hack PARAMS((slurm_step_ctx_t *ctx));
 
 /*
  * slurm_step_ctx_destroy - free allocated memory for a job step context.
  * IN ctx - job step context generated by slurm_step_ctx_create
  * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
  */
-extern int slurm_step_ctx_destroy PARAMS((slurm_step_ctx ctx));
+extern int slurm_step_ctx_destroy PARAMS((slurm_step_ctx_t *ctx));
 
 /* 
  * slurm_step_launch_params_t_init - initialize a user-allocated
@@ -1284,28 +1434,37 @@ extern void slurm_step_launch_params_t_init
 /*
  * slurm_step_launch - launch a parallel job step
  * IN ctx - job step context generated by slurm_step_ctx_create
+ * IN launcher_host - address used for PMI communications
+ * IN callbacks - Identify functions to be called when various events occur
  * RET SLURM_SUCCESS or SLURM_ERROR (with errno set)
  */
-extern int slurm_step_launch PARAMS((slurm_step_ctx ctx,
+extern int slurm_step_launch PARAMS((slurm_step_ctx_t *ctx,
+	char *launcher_host,
 	const slurm_step_launch_params_t *params,
 	const slurm_step_launch_callbacks_t *callbacks));
 
 /*
  * Block until all tasks have started.
  */
-extern int slurm_step_launch_wait_start PARAMS((slurm_step_ctx ctx));
+extern int slurm_step_launch_wait_start PARAMS((slurm_step_ctx_t *ctx));
 
 /*
  * Block until all tasks have finished (or failed to start altogether).
  */
-extern void slurm_step_launch_wait_finish PARAMS((slurm_step_ctx ctx));
+extern void slurm_step_launch_wait_finish PARAMS((slurm_step_ctx_t *ctx));
 
 /*
  * Abort an in-progress launch, or terminate the fully launched job step.
  *
  * Can be called from a signal handler.
  */
-void slurm_step_launch_abort PARAMS((slurm_step_ctx ctx));
+extern void slurm_step_launch_abort PARAMS((slurm_step_ctx_t *ctx));
+
+/* 
+ * Forward a signal to all those nodes with running tasks 
+ */
+extern void slurm_step_launch_fwd_signal PARAMS((slurm_step_ctx_t *ctx,
+	 int signo));
 
 /*****************************************************************************\
  *	SLURM CONTROL CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
@@ -1355,7 +1514,7 @@ extern void slurm_print_ctl_conf PARAMS((
  * RET 0 or -1 on error
  * NOTE: free the response using slurm_free_slurmd_status()
  */
-extern int slurm_load_slurmd_status(slurmd_status_t **slurmd_status_ptr);
+extern int slurm_load_slurmd_status PARAMS((slurmd_status_t **slurmd_status_ptr));
 
 /*
  * slurm_free_slurmd_status - free slurmd state information
@@ -1471,6 +1630,15 @@ extern int slurm_update_job PARAMS(( job_desc_msg_t * job_msg )) ;
 extern int slurm_get_select_jobinfo PARAMS((select_jobinfo_t jobinfo,
 		enum select_data_type data_type, void *data));
 
+/*
+ * slurm_notify_job - send message to the job's stdout, 
+ *	usable only by user root
+ * IN job_id - slurm job_id or 0 for all jobs
+ * IN message - arbitrary message
+ * RET 0 or -1 on error
+ */
+extern int slurm_notify_job PARAMS(( uint32_t job_id, char *message ));
+
 /*****************************************************************************\
  *	SLURM JOB STEP CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
 \*****************************************************************************/
@@ -1720,6 +1888,14 @@ extern int slurm_reconfigure PARAMS(( void ));
  */
 extern int slurm_shutdown PARAMS(( uint16_t core ));
 
+/*
+ * slurm_set_debug_level - issue RPC to set slurm controller debug level
+ * IN debug_level - requested debug level
+ * RET 0 on success, otherwise return -1 and set errno to indicate the error
+ */
+extern int slurm_set_debug_level PARAMS((uint32_t debug_level));
+
+
 /*****************************************************************************\
  *      SLURM JOB SUSPEND FUNCTIONS
 \*****************************************************************************/
@@ -1824,6 +2000,21 @@ extern int slurm_checkpoint_complete PARAMS(( uint32_t job_id,
 		uint32_t step_id, time_t begin_time, 
 		uint32_t error_code, char *error_msg ));
 
+/*
+ * slurm_checkpoint_task_complete - note the completion of a task's checkpoint
+ *	operation.
+ * IN job_id  - job on which to perform operation
+ * IN step_id - job step on which to perform operation
+ * IN task_id - task which completed the operation
+ * IN begin_time - time at which checkpoint began
+ * IN error_code - error code, highest value for all complete calls is preserved
+ * IN error_msg - error message, preserved for highest error_code
+ * RET 0 or a slurm error code
+ */
+extern int slurm_checkpoint_task_complete (uint32_t job_id, uint32_t step_id,
+					   uint32_t task_id, time_t begin_time, 
+					   uint32_t error_code, char *error_msg);
+
 /*
  * slurm_checkpoint_error - gather error information for the last checkpoint
  *	operation for some job step
@@ -1841,6 +2032,15 @@ extern int slurm_checkpoint_error PARAMS(( uint32_t job_id,
 		uint32_t step_id, uint32_t *error_code, 
 		char **error_msg ));
 
+/*
+ * slurm_get_checkpoint_file_path - return the checkpoint file
+ *      path of this process, creating the directory if needed.
+ * IN len: length of the file path buffer
+ * OUT buf: buffer to store the checkpoint file path
+ * RET: 0 on success, -1 on failure with errno set
+ */
+extern int slurm_get_checkpoint_file_path(size_t len, char *buf);
+
 /*****************************************************************************\
  *      SLURM HOSTLIST FUNCTIONS
 \*****************************************************************************/
diff --git a/slurm/slurm_errno.h b/slurm/slurm_errno.h
index 6143acfde7d0b9a3cc6b8f8ffc68fc194b718bf0..3e9b7e9b7a2466ca387a85cecf236e5a58d873d1 100644
--- a/slurm/slurm_errno.h
+++ b/slurm/slurm_errno.h
@@ -5,7 +5,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, 
  *	Jim Garlick <garlick@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -150,6 +150,13 @@ enum {
 	ESLURM_TASKDIST_ARBITRARY_UNSUPPORTED,
 	ESLURM_TASKDIST_REQUIRES_OVERCOMMIT,
 	ESLURM_JOB_HELD,
+	ESLURM_INVALID_CRYPTO_TYPE_CHANGE,
+	ESLURM_INVALID_BANK_ACCOUNT,
+	ESLURM_INVALID_TASK_MEMORY,
+	ESLURM_INVALID_ACCOUNT,
+	ESLURM_INVALID_LICENSES,
+	ESLURM_NEED_RESTART,
+	ESLURM_ACCOUNTING_POLICY,
 
 	/* switch specific error codes, specific values defined in plugin module */
 	ESLURM_SWITCH_MIN = 3000,
diff --git a/slurm/spank.h b/slurm/spank.h
index 20bc4090a108f02ec09f54c2cf9ea1d6eb7ad128..27f2a7f9cb8484d76c93c26bff314fb801da3473 100644
--- a/slurm/spank.h
+++ b/slurm/spank.h
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/Makefile.am b/src/Makefile.am
index 1289d019348fbf63ba3e9cbe49b4ec832ea89a66..a852e7d97c8d6acca5345b16d7790ffdf0bfceaa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,6 @@
 
-SUBDIRS = common api slurmctld slurmd plugins srun sacct sbcast \
-	scontrol scancel squeue sinfo smap sview slaunch salloc \
-	sbatch sattach strigger
+SUBDIRS = common api database \
+	slurmctld slurmd slurmdbd plugins srun sbcast \
+	scontrol scancel squeue sinfo smap sview salloc \
+	sbatch sattach strigger sacct sacctmgr sreport sstat
 
diff --git a/src/Makefile.in b/src/Makefile.in
index 80490da898ebada8330400a84667e62c00e5f765..a7366a69a610e7c065e4973ba15fd265ea9d6287 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -99,6 +101,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -112,10 +115,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -135,7 +141,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -146,6 +155,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -161,6 +172,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -176,6 +188,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -232,9 +245,10 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = common api slurmctld slurmd plugins srun sacct sbcast \
-	scontrol scancel squeue sinfo smap sview slaunch salloc \
-	sbatch sattach strigger
+SUBDIRS = common api database \
+	slurmctld slurmd slurmdbd plugins srun sbcast \
+	scontrol scancel squeue sinfo smap sview salloc \
+	sbatch sattach strigger sacct sacctmgr sreport sstat
 
 all: all-recursive
 
@@ -350,8 +364,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +390,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +401,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/api/Makefile.am b/src/api/Makefile.am
index 6023cef721ab31280a1952262a2fe5f351db4d33..b5634c6e73cd9eecbd9f936d734152f0da03e775 100644
--- a/src/api/Makefile.am
+++ b/src/api/Makefile.am
@@ -59,6 +59,7 @@ noinst_LTLIBRARIES = libslurmhelper.la
 
 slurmapi_src =           \
 	allocate.c       \
+	allocate_msg.c   \
 	cancel.c         \
 	checkpoint.c     \
 	complete.c       \
@@ -104,6 +105,11 @@ libslurm_la_LDFLAGS        = \
         -version-info $(current):$(rev):$(age) \
         $(OTHER_FLAGS)
 
+#
+# The libpmi_la_LIBADD specification below causes libpmi.la to relink
+# when running "make install", but removing it prevents essential slurm
+# symbols from being available in programs linking with libpmi
+#
 libpmi_la_SOURCES = pmi.c
 libpmi_la_LIBADD = $(top_builddir)/src/api/libslurm.la
 libpmi_la_LDFLAGS = $(LIB_LDFLAGS) \
diff --git a/src/api/Makefile.in b/src/api/Makefile.in
index 7b0a3474e1a555eb97f4cb7088e514e0faa2827c..107f973d111487e627ac6046c649c4bee579f09b 100644
--- a/src/api/Makefile.in
+++ b/src/api/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -89,15 +91,15 @@ libslurm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 am__DEPENDENCIES_1 = $(common_dir)/libcommon.la \
 	$(common_dir)/libspank.la $(common_dir)/libeio.la
 libslurmhelper_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am__objects_1 = allocate.lo cancel.lo checkpoint.lo complete.lo \
-	config_info.lo init_msg.lo job_info.lo job_step_info.lo \
-	node_info.lo node_select_info.lo partition_info.lo signal.lo \
-	slurm_pmi.lo step_ctx.lo step_io.lo step_launch.lo \
-	pmi_server.lo submit.lo suspend.lo triggers.lo reconfigure.lo \
-	update_config.lo
+am__objects_1 = allocate.lo allocate_msg.lo cancel.lo checkpoint.lo \
+	complete.lo config_info.lo init_msg.lo job_info.lo \
+	job_step_info.lo node_info.lo node_select_info.lo \
+	partition_info.lo signal.lo slurm_pmi.lo step_ctx.lo \
+	step_io.lo step_launch.lo pmi_server.lo submit.lo suspend.lo \
+	triggers.lo reconfigure.lo update_config.lo
 am_libslurmhelper_la_OBJECTS = $(am__objects_1)
 libslurmhelper_la_OBJECTS = $(am_libslurmhelper_la_OBJECTS)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -139,6 +141,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -152,10 +155,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -175,7 +181,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -186,6 +195,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -201,6 +212,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -216,6 +228,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -328,6 +341,7 @@ BUILT_SOURCES = $(VERSION_SCRIPT) $(PMI_VERSION_SCRIPT) libslurm.la
 noinst_LTLIBRARIES = libslurmhelper.la
 slurmapi_src = \
 	allocate.c       \
+	allocate_msg.c   \
 	cancel.c         \
 	checkpoint.c     \
 	complete.c       \
@@ -371,6 +385,12 @@ libslurm_la_LDFLAGS = \
         -version-info $(current):$(rev):$(age) \
         $(OTHER_FLAGS)
 
+
+#
+# The libpmi_la_LIBADD specification below causes libpmi.la to relink
+# when running "make install", but removing it prevents essential slurm
+# symbols from being available in programs linking with libpmi
+#
 libpmi_la_SOURCES = pmi.c
 libpmi_la_LIBADD = $(top_builddir)/src/api/libslurm.la
 libpmi_la_LDFLAGS = $(LIB_LDFLAGS) \
@@ -422,8 +442,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -431,8 +451,8 @@ uninstall-libLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
 	done
 
 clean-libLTLIBRARIES:
@@ -466,6 +486,7 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocate.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocate_msg.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cancel.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpoint.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/complete.Plo@am__quote@
@@ -521,8 +542,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -534,8 +555,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -545,13 +566,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/api/allocate.c b/src/api/allocate.c
index 438035bf7b20f3e9ab01a37c0d6092dd1cb6d3c9..192c15226658c91a3530b1a216d9dd1fa0061acf 100644
--- a/src/api/allocate.c
+++ b/src/api/allocate.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  allocate.c - allocate nodes for a job or step with supplied contraints
- *  $Id: allocate.c 11342 2007-04-10 22:54:27Z da $
+ *  $Id: allocate.c 13722 2008-03-27 16:39:22Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -16,7 +16,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -63,7 +63,9 @@ extern pid_t getsid(pid_t pid);		/* missing from <unistd.h> */
 #include "src/common/xstring.h"
 #include "src/common/forward.h"
 #include "src/common/fd.h"
+#include "src/common/parse_time.h"
 #include "src/common/slurm_auth.h"
+#include "src/common/slurm_protocol_defs.h"
 
 #define BUFFER_SIZE 1024
 #define MAX_ALLOC_WAIT 60	/* seconds */
@@ -212,7 +214,6 @@ slurm_allocate_resources_blocking (const job_desc_msg_t *user_req,
 			xfree(req);
 			return NULL;
 		}
-		req->alloc_resp_hostname = listen->hostname;
 		req->alloc_resp_port = listen->port;
 	}
 
@@ -279,7 +280,6 @@ slurm_allocate_resources_blocking (const job_desc_msg_t *user_req,
 	return resp;
 }
 
-
 /*
  * slurm_job_will_run - determine if a job would execute immediately if 
  *	submitted now
@@ -288,19 +288,40 @@ slurm_allocate_resources_blocking (const job_desc_msg_t *user_req,
  */
 int slurm_job_will_run (job_desc_msg_t *req)
 {
-	slurm_msg_t req_msg;
-	int rc;
+	slurm_msg_t req_msg, resp_msg;
+	will_run_response_msg_t *will_run_resp;
+	char buf[64];
 
 	/* req.immediate = true;    implicit */
+	if ((req->alloc_node == NULL)
+	&&  (gethostname_short(buf, sizeof(buf)) == 0))
+		req->alloc_node = buf;
 	slurm_msg_t_init(&req_msg);
 	req_msg.msg_type = REQUEST_JOB_WILL_RUN;
 	req_msg.data     = req; 
 	
-	if (slurm_send_recv_controller_rc_msg(&req_msg, &rc) < 0)
+	if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0)
 		return SLURM_SOCKET_ERROR;
 
-	if (rc)
-		slurm_seterrno_ret(rc);
+	switch (resp_msg.msg_type) {
+	case RESPONSE_SLURM_RC:
+		if (_handle_rc_msg(&resp_msg) < 0)
+			return SLURM_PROTOCOL_ERROR;
+		break;
+	case RESPONSE_JOB_WILL_RUN:
+		will_run_resp = (will_run_response_msg_t *) resp_msg.data;
+		slurm_make_time_str(&will_run_resp->start_time,
+				    buf, sizeof(buf));
+		info("Job %u to start at %s using %u processors on %s",
+			will_run_resp->job_id, buf,
+			will_run_resp->proc_cnt,
+			will_run_resp->node_list);
+		slurm_free_will_run_response_msg(will_run_resp);
+		break;
+	default:
+		slurm_seterrno_ret(SLURM_UNEXPECTED_MSG_ERROR);
+		break;
+	}
 
 	return SLURM_PROTOCOL_SUCCESS;
 }
@@ -316,8 +337,7 @@ int
 slurm_job_step_create (job_step_create_request_msg_t *req, 
                        job_step_create_response_msg_t **resp)
 {
-	slurm_msg_t req_msg;
-	slurm_msg_t resp_msg;
+	slurm_msg_t req_msg, resp_msg;
 
 	slurm_msg_t_init(&req_msg);
 	slurm_msg_t_init(&resp_msg);
@@ -556,12 +576,9 @@ static listen_t *_create_allocation_response_socket(char *interface_hostname)
 	listen_t *listen = NULL;
 
 	listen = xmalloc(sizeof(listen_t));
-	if (listen == NULL)
-		return NULL;
 
 	/* port "0" lets the operating system pick any port */
-	slurm_set_addr(&listen->address, 0, interface_hostname);
-	if ((listen->fd = slurm_init_msg_engine(&listen->address)) < 0) {
+	if ((listen->fd = slurm_init_msg_engine_port(0)) < 0) {
 		error("slurm_init_msg_engine_port error %m");
 		return NULL;
 	}
@@ -596,7 +613,7 @@ static void _destroy_allocation_response_socket(listen_t *listen)
 static int
 _handle_msg(slurm_msg_t *msg, resource_allocation_response_msg_t **resp)
 {
-	uid_t req_uid   = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid   = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	uid_t uid       = getuid();
 	uid_t slurm_uid = (uid_t) slurm_get_slurm_user_id();
 	int rc = 0;
diff --git a/src/salloc/msg.c b/src/api/allocate_msg.c
similarity index 60%
rename from src/salloc/msg.c
rename to src/api/allocate_msg.c
index 12a6834e66ea8a9450ef151aa4dbabdf24275045..9ae77a6e8b103ac904b8af61f31e780834f5d093 100644
--- a/src/salloc/msg.c
+++ b/src/api/allocate_msg.c
@@ -1,10 +1,12 @@
 /*****************************************************************************\
- *  src/salloc/msg.c - Message handler for salloc
+ *  allocate_msg.c - Message handler for communication with with
+ *                       the slurmctld during an allocation.
+ *  $Id: allocate_msg.c 11641 2007-06-05 23:03:51Z jette $
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
+ *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  Written by Morris Jette <jette1@llnl.gov>.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -13,7 +15,18 @@
  *  the terms of the GNU General Public License as published by the Free
  *  Software Foundation; either version 2 of the License, or (at your option)
  *  any later version.
- *  
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ * 
  *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
@@ -21,7 +34,7 @@
  *  
  *  You should have received a copy of the GNU General Public License along
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
 #if HAVE_CONFIG_H
@@ -49,17 +62,15 @@
 #include "src/common/eio.h"
 #include "src/common/xsignal.h"
 
-#include "src/salloc/salloc.h"
-#include "src/salloc/opt.h"
-#include "src/salloc/msg.h"
-
-struct salloc_msg_thread {
+struct allocation_msg_thread {
+	slurm_allocation_callbacks_t callback;
 	eio_handle_t *handle;
 	pthread_t id;
 };
 
 static uid_t slurm_uid;
-static void _handle_msg(slurm_msg_t *msg);
+static void _handle_msg(struct allocation_msg_thread *msg_thr,
+			slurm_msg_t *msg);
 static bool _message_socket_readable(eio_obj_t *obj);
 static int _message_socket_accept(eio_obj_t *obj, List objs);
 static pthread_mutex_t msg_thr_start_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -85,15 +96,31 @@ static void *_msg_thr_internal(void *arg)
 	return NULL;
 }
 
-extern salloc_msg_thread_t *msg_thr_create(uint16_t *port)
+extern allocation_msg_thread_t *slurm_allocation_msg_thr_create(
+	uint16_t *port,
+	const slurm_allocation_callbacks_t *callbacks)
 {
+	pthread_attr_t attr;
 	int sock = -1;
 	eio_obj_t *obj;
-	salloc_msg_thread_t *msg_thr = NULL;
+	struct allocation_msg_thread *msg_thr = NULL;
+
+	debug("Entering slurm_allocation_msg_thr_create()");
 
-	debug("Entering _msg_thr_create()");
 	slurm_uid = (uid_t) slurm_get_slurm_user_id();
-	msg_thr = (salloc_msg_thread_t *)xmalloc(sizeof(salloc_msg_thread_t));
+	msg_thr = (struct allocation_msg_thread *)xmalloc(
+		sizeof(struct allocation_msg_thread));
+
+	/* Initialize the callback pointers */
+	if (callbacks != NULL) {
+		/* copy the user specified callback pointers */
+		memcpy(&(msg_thr->callback), callbacks,
+		       sizeof(slurm_allocation_callbacks_t));
+	} else {
+		/* set all callbacks to NULL */
+		memset(&(msg_thr->callback), 0,
+		       sizeof(slurm_allocation_callbacks_t));
+	}
 
 	if (net_stream_listen(&sock, (short *)port) < 0) {
 		error("unable to intialize step launch listening socket: %m");
@@ -102,31 +129,38 @@ extern salloc_msg_thread_t *msg_thr_create(uint16_t *port)
 	}
 	debug("port from net_stream_listen is %hu", *port);
 
-	obj = eio_obj_create(sock, &message_socket_ops, NULL);
+	obj = eio_obj_create(sock, &message_socket_ops, (void *)msg_thr);
 
 	msg_thr->handle = eio_handle_create();
 	eio_new_initial_obj(msg_thr->handle, obj);
 	pthread_mutex_lock(&msg_thr_start_lock);
-	if (pthread_create(&msg_thr->id, NULL,
+	slurm_attr_init(&attr);
+	if (pthread_create(&msg_thr->id, &attr,
 			   _msg_thr_internal, (void *)msg_thr->handle) != 0) {
 		error("pthread_create of message thread: %m");
+		slurm_attr_destroy(&attr);
 		eio_handle_destroy(msg_thr->handle);
 		xfree(msg_thr);
 		return NULL;
 	}
+	slurm_attr_destroy(&attr);
 	/* Wait until the message thread has blocked signals
 	   before continuing. */
 	pthread_cond_wait(&msg_thr_start_cond, &msg_thr_start_lock);
 	pthread_mutex_unlock(&msg_thr_start_lock);
 
-	return msg_thr;
+	return (allocation_msg_thread_t *)msg_thr;
 }
 
-extern void msg_thr_destroy(salloc_msg_thread_t *msg_thr)
+extern void slurm_allocation_msg_thr_destroy(
+	allocation_msg_thread_t *arg)
 {
+	struct allocation_msg_thread *msg_thr =
+		(struct allocation_msg_thread *)arg;
 	if (msg_thr == NULL)
 		return;
 
+	debug2("slurm_allocation_msg_thr_destroy: clearing up message thread");
 	eio_signal_shutdown(msg_thr->handle);
 	pthread_join(msg_thr->id, NULL);
 	eio_handle_destroy(msg_thr->handle);
@@ -154,6 +188,9 @@ static bool _message_socket_readable(eio_obj_t *obj)
 
 static int _message_socket_accept(eio_obj_t *obj, List objs)
 {
+	struct allocation_msg_thread *msg_thr = 
+		(struct allocation_msg_thread *)obj->arg;
+
 	int fd;
 	unsigned char *uc;
 	short        port;
@@ -161,12 +198,13 @@ static int _message_socket_accept(eio_obj_t *obj, List objs)
 	slurm_msg_t *msg = NULL;
 	int len = sizeof(addr);
 	
-	debug3("Called _msg_socket_accept");
+	debug2("Called _msg_socket_accept");
 
 	while ((fd = accept(obj->fd, (struct sockaddr *)&addr,
 			    (socklen_t *)&len)) < 0) {
 		if (errno == EINTR)
 			continue;
+		
 		if (errno == EAGAIN
 		    || errno == ECONNABORTED
 		    || errno == EWOULDBLOCK) {
@@ -184,7 +222,7 @@ static int _message_socket_accept(eio_obj_t *obj, List objs)
 	   in /etc/hosts. */
 	uc = (unsigned char *)&((struct sockaddr_in *)&addr)->sin_addr.s_addr;
 	port = ((struct sockaddr_in *)&addr)->sin_port;
-	debug2("got message connection from %u.%u.%u.%u:%hu",
+	debug2("allocation got message connection from %u.%u.%u.%u:%hu",
 	       uc[0], uc[1], uc[2], uc[3], ntohs(port));
 	fflush(stdout);
 
@@ -202,7 +240,7 @@ again:
 		goto cleanup;
 	}
 	
-	_handle_msg(msg); /* handle_msg frees msg->data */
+	_handle_msg(msg_thr, msg); /* handle_msg frees msg->data */
 cleanup:
 	if ((msg->conn_fd >= 0) && slurm_close_accepted_conn(msg->conn_fd) < 0)
 		error ("close(%d): %m", msg->conn_fd);
@@ -212,11 +250,13 @@ cleanup:
 }
 
 
-static void _handle_node_fail(slurm_msg_t *msg)
+static void _handle_node_fail(struct allocation_msg_thread *msg_thr, 
+			      slurm_msg_t *msg)
 {
 	srun_node_fail_msg_t *nf = (srun_node_fail_msg_t *)msg->data;
 
-	error("Node failure on %s", nf->nodelist);
+	if (msg_thr->callback.node_fail != NULL)
+		(msg_thr->callback.node_fail)(nf);
 
 	slurm_free_srun_node_fail_msg(msg->data);
 }
@@ -226,66 +266,59 @@ static void _handle_node_fail(slurm_msg_t *msg)
  * Job will be killed shortly after timeout.
  * This RPC can arrive multiple times with the same or updated timeouts.
  */
-static void _handle_timeout(slurm_msg_t *msg)
+static void _handle_timeout(struct allocation_msg_thread *msg_thr, 
+			    slurm_msg_t *msg)
 {
-	static time_t last_timeout = 0;
 	srun_timeout_msg_t *to = (srun_timeout_msg_t *)msg->data;
 
 	debug3("received timeout message");
-	if (to->timeout != last_timeout) {
-		last_timeout = to->timeout;
-		info("Job allocation time limit to be reached at %s",
-		     ctime(&to->timeout));
-	}
+	
+	if (msg_thr->callback.timeout != NULL)
+		(msg_thr->callback.timeout)(to);
 
 	slurm_free_srun_timeout_msg(msg->data);
 }
 
-static void _handle_user_msg(slurm_msg_t *msg)
+static void _handle_user_msg(struct allocation_msg_thread *msg_thr, 
+			     slurm_msg_t *msg)
 {
-	srun_user_msg_t *um;
-
-	um = msg->data;
-	info("%s", um->msg);
+	srun_user_msg_t *um = (srun_user_msg_t *)msg->data;
+	debug3("received user message");
+	
+	if (msg_thr->callback.user_msg != NULL)
+		(msg_thr->callback.user_msg)(um);
+	
 	slurm_free_srun_user_msg(msg->data);
 }
 
-static void _handle_job_complete(slurm_msg_t *msg)
+static void _handle_ping(struct allocation_msg_thread *msg_thr, 
+			     slurm_msg_t *msg)
+{
+	srun_ping_msg_t *ping = (srun_ping_msg_t *)msg->data;
+	debug3("received ping message");
+	slurm_send_rc_msg(msg, SLURM_SUCCESS);
+
+	if (msg_thr->callback.ping != NULL)
+		(msg_thr->callback.ping)(ping);
+	
+	slurm_free_srun_ping_msg(msg->data);
+}
+static void _handle_job_complete(struct allocation_msg_thread *msg_thr, 
+				 slurm_msg_t *msg)
 {
 	srun_job_complete_msg_t *comp = (srun_job_complete_msg_t *)msg->data;
 	debug3("job complete message received");
 
-	if (comp->step_id == NO_VAL) {
-		pthread_mutex_lock(&allocation_state_lock);
-		if (allocation_state != REVOKED) {
-			/* If the allocation_state is already REVOKED, then
-			 * no need to print this message.  We probably
-			 * relinquished the allocation ourself.
-			 */
-			info("Job allocation %u has been revoked.",
-			     comp->job_id);
-		}
-		if (allocation_state == GRANTED
-		    && command_pid > -1
-		    && opt.kill_command_signal_set) {
-			verbose("Sending signal %d to command \"%s\", pid %d",
-				opt.kill_command_signal,
-				command_argv[0], command_pid);
-			kill(command_pid, opt.kill_command_signal);
-		}
-		allocation_state = REVOKED;
-		pthread_mutex_unlock(&allocation_state_lock);
-	} else {
-		verbose("Job step %u.%u is finished.",
-			comp->job_id, comp->step_id);
-	}
+	if (msg_thr->callback.job_complete != NULL)
+		(msg_thr->callback.job_complete)(comp);
+	
 	slurm_free_srun_job_complete_msg(msg->data);
 }
 
 static void
-_handle_msg(slurm_msg_t *msg)
+_handle_msg(struct allocation_msg_thread *msg_thr, slurm_msg_t *msg)
 {
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	uid_t uid = getuid();
 	
 	if ((req_uid != slurm_uid) && (req_uid != 0) && (req_uid != uid)) {
@@ -296,21 +329,19 @@ _handle_msg(slurm_msg_t *msg)
 
 	switch (msg->msg_type) {
 	case SRUN_PING:
-		debug("received ping message");
-		slurm_send_rc_msg(msg, SLURM_SUCCESS);
-		slurm_free_srun_ping_msg(msg->data);
+		_handle_ping(msg_thr, msg);
 		break;
 	case SRUN_JOB_COMPLETE:
-		_handle_job_complete(msg);
+		_handle_job_complete(msg_thr, msg);
 		break;
 	case SRUN_TIMEOUT:
-		_handle_timeout(msg);
+		_handle_timeout(msg_thr, msg);
 		break;
 	case SRUN_USER_MSG:
-		_handle_user_msg(msg);
+		_handle_user_msg(msg_thr, msg);
 		break;
 	case SRUN_NODE_FAIL:
-		_handle_node_fail(msg);
+		_handle_node_fail(msg_thr, msg);
 		break;
 	default:
 		error("received spurious message type: %d\n",
diff --git a/src/api/cancel.c b/src/api/cancel.c
index 23155474721a20f79091b5a73c2e1cf50ee588e1..678605d236acb9c3eb9edd31a6e78fb928e84d42 100644
--- a/src/api/cancel.c
+++ b/src/api/cancel.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  cancel.c - cancel a slurm job or job step
- *  $Id: cancel.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: cancel.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/checkpoint.c b/src/api/checkpoint.c
index fd5659ae208fedba15fb2ebb00d22f5457493caa..be3c46acbd51339f9545bd0166a06c73b6bd6a9e 100644
--- a/src/api/checkpoint.c
+++ b/src/api/checkpoint.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  checkpoint.c - Process checkpoint related functions.
- *  $Id: checkpoint.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: checkpoint.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -41,11 +41,21 @@
 #endif
 
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
 #include <slurm/slurm.h>
 
 #include "src/common/checkpoint.h"
 #include "src/common/slurm_protocol_api.h"
 
+#ifdef HAVE_AIX
+  char *__progname = "PROGRAM";
+#else
+  extern char * __progname;
+#endif
+
 static int _handle_rc_msg(slurm_msg_t *msg);
 static int _checkpoint_op (uint16_t op, uint16_t data,
 		uint32_t job_id, uint32_t step_id);
@@ -294,3 +304,114 @@ _handle_rc_msg(slurm_msg_t *msg)
 	slurm_seterrno(rc);
 	return rc;
 }
+
+/*
+ * slurm_checkpoint_task_complete - note the completion of a task's checkpoint
+ *	operation.
+ * IN job_id  - job on which to perform operation
+ * IN step_id - job step on which to perform operation
+ * IN task_id - task which completed the operation
+ * IN begin_time - time at which checkpoint began
+ * IN error_code - error code, highest value for all complete calls is preserved
+ * IN error_msg - error message, preserved for highest error_code
+ * RET 0 or a slurm error code
+ */
+extern int slurm_checkpoint_task_complete (uint32_t job_id, uint32_t step_id,
+		uint32_t task_id, time_t begin_time, uint32_t error_code, char *error_msg)
+{
+	int rc;
+	slurm_msg_t msg;
+	checkpoint_task_comp_msg_t req;
+
+	slurm_msg_t_init(&msg);
+	req.job_id       = job_id;
+	req.step_id      = step_id;
+	req.task_id      = task_id;
+	req.begin_time   = begin_time;
+	req.error_code   = error_code;
+	req.error_msg    = error_msg;
+	msg.msg_type     = REQUEST_CHECKPOINT_TASK_COMP;
+	msg.data         = &req;
+
+	if (slurm_send_recv_controller_rc_msg(&msg, &rc) < 0)
+		return SLURM_ERROR;
+	if (rc)
+		slurm_seterrno_ret(rc);
+	return SLURM_SUCCESS;
+}
+
+/*
+ * slurm_get_checkpoint_file_path - return the checkpoint file
+ *      path of this process, creating the directory if needed.
+ * IN len: length of the file path buffer
+ * OUT buf: buffer to store the checkpoint file path
+ * RET: 0 on success, -1 on failure with errno set
+ */
+extern int
+slurm_get_checkpoint_file_path(size_t len, char *buf)
+{
+       char *ckpt_path, *job_id, *step_id, *proc_id;
+       struct stat mystat;
+       int idx;
+
+       len --;                 /* for a terminating 0 */
+
+       ckpt_path = getenv("SLURM_CHECKPOINT_PATH");
+       if (ckpt_path == NULL) { /* this should not happen since the program may chdir */
+               ckpt_path = getcwd(buf, len);
+               if (ckpt_path == NULL)  /* ERANGE: len is too short */
+                       return -1;
+       } else {
+               if (snprintf(buf, len, "%s", ckpt_path) >= len) { /* glibc >= 2.1 */
+                       errno = ERANGE;
+                       return -1;
+               }
+               ckpt_path = buf;
+       }
+       idx = strlen(ckpt_path) - 1;
+       while (idx > 0 && ckpt_path[idx] == '/')
+               ckpt_path[idx --] = 0;
+
+       if (stat(ckpt_path, &mystat) < 0)
+               return -1;
+       if (! S_ISDIR(mystat.st_mode)) {
+               errno = ENOTDIR;
+               return -1;
+       }
+
+       job_id = getenv("SLURM_JOBID");
+       step_id = getenv("SLURM_STEPID");
+       proc_id = getenv("SLURM_PROCID");
+       if (job_id == NULL || step_id == NULL || proc_id == NULL) {
+               errno = ENODATA;
+               return -1;
+       }
+       idx = strlen(buf);
+       if (snprintf(buf + idx, len - idx, "/%s.%s", job_id, step_id) >= len - idx) {
+               errno = ERANGE;
+               return -1;
+       }
+
+       if (stat(buf, &mystat) < 0) {
+               if (errno == ENOENT) { /* dir does not exists */
+                       if (mkdir(buf, 0750) < 0 && errno != EEXIST)
+                               return -1;
+                       if (stat(buf, &mystat) < 0)
+                               return -1;
+               }
+               else
+                       return -1;
+       }
+       if (! S_ISDIR(mystat.st_mode)) {
+               errno = ENOTDIR;
+               return -1;
+       }
+
+       idx = strlen(buf);
+       if (snprintf(buf + idx, len - idx, "/%s.%s.ckpt", __progname, proc_id) >= len - idx) {
+               errno = ERANGE;
+               return -1;
+       }
+
+       return 0;
+}
diff --git a/src/api/complete.c b/src/api/complete.c
index 2ea808ccb375f14ef703b47cc4608505eb004794..15ce8c44adab7b8c7f57ecea0444496a1e70957f 100644
--- a/src/api/complete.c
+++ b/src/api/complete.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  complete.c - note the completion a slurm job or job step
- *  $Id: complete.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: complete.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/config_info.c b/src/api/config_info.c
index 3147cdee7e091f88864b14ac7f4613cdde6f61d0..e649accd835dd8200a132199883a7b77c4ad8652 100644
--- a/src/api/config_info.c
+++ b/src/api/config_info.c
@@ -1,11 +1,11 @@
 /****************************************************************************\
  *  config_info.c - get/print the system configuration information of slurm
- *  $Id: config_info.c 11798 2007-07-07 00:02:31Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> and Kevin Tew <tew1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -117,144 +117,224 @@ void slurm_print_ctl_conf ( FILE* out,
 	slurm_make_time_str ((time_t *)&slurm_ctl_conf_ptr->last_update, 
 			     time_str, sizeof(time_str));
 	fprintf(out, "Configuration data as of %s\n", time_str);
-	fprintf(out, "AuthType          = %s\n", 
+	fprintf(out, "AccountingStorageEnforce = %u\n",
+		slurm_ctl_conf_ptr->accounting_storage_enforce);
+	fprintf(out, "AccountingStorageHost   = %s\n", 
+		slurm_ctl_conf_ptr->accounting_storage_host);
+	fprintf(out, "AccountingStorageLoc    = %s\n", 
+		slurm_ctl_conf_ptr->accounting_storage_loc);
+	fprintf(out, "AccountingStoragePass   = %s\n", 
+		slurm_ctl_conf_ptr->accounting_storage_pass);
+	fprintf(out, "AccountingStoragePort   = %u\n", 
+		slurm_ctl_conf_ptr->accounting_storage_port);
+	fprintf(out, "AccountingStorageType   = %s\n", 
+		slurm_ctl_conf_ptr->accounting_storage_type);
+	fprintf(out, "AccountingStorageUser   = %s\n", 
+		slurm_ctl_conf_ptr->accounting_storage_user);
+	fprintf(out, "AuthType                = %s\n", 
 		slurm_ctl_conf_ptr->authtype);
-	fprintf(out, "BackupAddr        = %s\n", 
+	fprintf(out, "BackupAddr              = %s\n", 
 		slurm_ctl_conf_ptr->backup_addr);
-	fprintf(out, "BackupController  = %s\n", 
+	fprintf(out, "BackupController        = %s\n", 
 		slurm_ctl_conf_ptr->backup_controller);
-	fprintf(out, "CacheGroups       = %u\n", 
+	slurm_make_time_str ((time_t *)&slurm_ctl_conf_ptr->boot_time,
+			     time_str, sizeof(time_str));
+	fprintf(out, "BOOT_TIME               = %s\n",
+		time_str);
+	fprintf(out, "CacheGroups             = %u\n", 
 		slurm_ctl_conf_ptr->cache_groups);
-	fprintf(out, "CheckpointType    = %s\n",
+	fprintf(out, "CheckpointType          = %s\n",
 		slurm_ctl_conf_ptr->checkpoint_type);
-	fprintf(out, "ControlAddr       = %s\n", 
+	fprintf(out, "ClusterName             = %s\n",
+		slurm_ctl_conf_ptr->cluster_name);
+	fprintf(out, "ControlAddr             = %s\n", 
 		slurm_ctl_conf_ptr->control_addr);
-	fprintf(out, "ControlMachine    = %s\n", 
+	fprintf(out, "ControlMachine          = %s\n", 
 		slurm_ctl_conf_ptr->control_machine);
-	fprintf(out, "Epilog            = %s\n", 
+	fprintf(out, "CryptoType              = %s\n",
+		slurm_ctl_conf_ptr->crypto_type);
+	if (slurm_ctl_conf_ptr->def_mem_per_task) {
+		fprintf(out, "DefMemPerTask           = %u\n",
+			slurm_ctl_conf_ptr->def_mem_per_task);
+	} else
+		fprintf(out, "DefMemPerTask           = UNLIMITED\n");
+	if (slurm_ctl_conf_ptr->disable_root_jobs)
+		fprintf(out, "DisableRootJobs         = YES\n");
+	else
+		fprintf(out, "DisableRootJobs         = NO\n");
+	fprintf(out, "Epilog                  = %s\n",
 		slurm_ctl_conf_ptr->epilog);
-	fprintf(out, "FastSchedule      = %u\n", 
+	fprintf(out, "EpilogMsgTime           = %u\n",
+		slurm_ctl_conf_ptr->epilog_msg_time);
+	fprintf(out, "FastSchedule            = %u\n",
 		slurm_ctl_conf_ptr->fast_schedule);
-	fprintf(out, "FirstJobId        = %u\n", 
+	fprintf(out, "FirstJobId              = %u\n",
 		slurm_ctl_conf_ptr->first_job_id);
+	fprintf(out, "GetEnvTimeout           = %u\n",
+		slurm_ctl_conf_ptr->get_env_timeout);
+	fprintf(out, "HealthCheckInterval     = %u\n",
+		slurm_ctl_conf_ptr->health_check_interval);
+	fprintf(out, "HealthCheckProgram      = %s\n",
+		slurm_ctl_conf_ptr->health_check_program);
 #ifdef HAVE_XCPU
-	fprintf(out, "HAVE_XCPU         = %d\n", HAVE_XCPU);
+	fprintf(out, "HAVE_XCPU               = %d\n", HAVE_XCPU);
 #endif
-	fprintf(out, "InactiveLimit     = %u\n", 
+	fprintf(out, "InactiveLimit           = %u\n",
 		slurm_ctl_conf_ptr->inactive_limit);
-	fprintf(out, "JobAcctLogFile    = %s\n", 
-		slurm_ctl_conf_ptr->job_acct_logfile);
-	fprintf(out, "JobAcctFrequency  = %u\n",
-		slurm_ctl_conf_ptr->job_acct_freq);
-	fprintf(out, "JobAcctType       = %s\n", 
-		slurm_ctl_conf_ptr->job_acct_type);
-	fprintf(out, "JobCompLoc        = %s\n", 
-		slurm_ctl_conf_ptr->job_comp_loc);
-	fprintf(out, "JobCompType       = %s\n", 
+	fprintf(out, "JobAcctGatherFrequency  = %u\n",
+		slurm_ctl_conf_ptr->job_acct_gather_freq);
+	fprintf(out, "JobAcctGatherType       = %s\n",
+		slurm_ctl_conf_ptr->job_acct_gather_type);
+	fprintf(out, "JobCompHost             = %s\n",
+		slurm_ctl_conf_ptr->job_comp_host);
+	fprintf(out, "JobCompLoc              = %s\n",
+		 slurm_ctl_conf_ptr->job_comp_loc);
+	fprintf(out, "JobCompPass             = %s\n",
+		 slurm_ctl_conf_ptr->job_comp_pass);
+	fprintf(out, "JobCompPort             = %u\n",
+		slurm_ctl_conf_ptr->job_comp_port);
+	fprintf(out, "JobCompType             = %s\n", 
 		slurm_ctl_conf_ptr->job_comp_type);
+	fprintf(out, "JobCompUser             = %s\n", 
+		slurm_ctl_conf_ptr->job_comp_user);
 	fprintf(out, "JobCredentialPrivateKey = %s\n", 
 		slurm_ctl_conf_ptr->job_credential_private_key);
 	fprintf(out, "JobCredentialPublicCertificate = %s\n", 
 		slurm_ctl_conf_ptr->job_credential_public_certificate);
-	fprintf(out, "KillWait          = %u\n", 
+	fprintf(out, "JobFileAppend           = %u\n",
+		slurm_ctl_conf_ptr->job_file_append);
+	fprintf(out, "JobRequeue              = %u\n",
+		slurm_ctl_conf_ptr->job_requeue);
+	fprintf(out, "KillWait                = %u\n", 
 		slurm_ctl_conf_ptr->kill_wait);
-	fprintf(out, "MailProg          = %s\n",
+	fprintf(out, "Licenses                = %s\n",
+		slurm_ctl_conf_ptr->licenses);
+	fprintf(out, "MailProg                = %s\n",
 		slurm_ctl_conf_ptr->mail_prog);
-	fprintf(out, "MaxJobCount       = %u\n", 
+	fprintf(out, "MaxJobCount             = %u\n", 
 		slurm_ctl_conf_ptr->max_job_cnt);
-	fprintf(out, "MessageTimeout    = %u\n",
+	if (slurm_ctl_conf_ptr->max_mem_per_task) {
+		fprintf(out, "MaxMemPerTask           = %u\n",
+			slurm_ctl_conf_ptr->max_mem_per_task);
+	} else
+		fprintf(out, "MaxMemPerTask           = UNLIMITED\n");
+	fprintf(out, "MessageTimeout          = %u\n",
 		slurm_ctl_conf_ptr->msg_timeout);
-	fprintf(out, "MinJobAge         = %u\n", 
+	fprintf(out, "MinJobAge               = %u\n", 
 		slurm_ctl_conf_ptr->min_job_age);
-	fprintf(out, "MpiDefault        = %s\n",
+	fprintf(out, "MpiDefault              = %s\n",
 		slurm_ctl_conf_ptr->mpi_default);
 #ifdef MULTIPLE_SLURMD
-	fprintf(out, "MULTIPLE_SLURMD   = %d\n", MULTIPLE_SLURMD);
+	fprintf(out, "MULTIPLE_SLURMD         = %d\n", MULTIPLE_SLURMD);
 #endif
-	fprintf(out, "NEXT_JOB_ID       = %u\n",
+	fprintf(out, "NEXT_JOB_ID             = %u\n",
 		slurm_ctl_conf_ptr->next_job_id);
-	fprintf(out, "PluginDir         = %s\n", 
+	fprintf(out, "PluginDir               = %s\n", 
 		slurm_ctl_conf_ptr->plugindir);
-	fprintf(out, "PlugStackConfig   = %s\n",
+	fprintf(out, "PlugStackConfig         = %s\n",
 		slurm_ctl_conf_ptr->plugstack);
-	fprintf(out, "ProctrackType     = %s\n",
+	fprintf(out, "PrivateData             = %u\n",
+		slurm_ctl_conf_ptr->private_data);
+	fprintf(out, "ProctrackType           = %s\n",
 		slurm_ctl_conf_ptr->proctrack_type);
-	fprintf(out, "Prolog            = %s\n", 
+	fprintf(out, "Prolog                  = %s\n", 
 		slurm_ctl_conf_ptr->prolog);
-	fprintf(out, "PropagatePrioProcess = %u\n",
+	fprintf(out, "PropagatePrioProcess    = %u\n",
 		slurm_ctl_conf_ptr->propagate_prio_process);
         fprintf(out, "PropagateResourceLimits = %s\n",
                 slurm_ctl_conf_ptr->propagate_rlimits);
         fprintf(out, "PropagateResourceLimitsExcept = %s\n", 
                 slurm_ctl_conf_ptr->propagate_rlimits_except);
-	fprintf(out, "ReturnToService   = %u\n", 
+	fprintf(out, "ResumeProgram           = %s\n", 
+		slurm_ctl_conf_ptr->resume_program);
+	fprintf(out, "ResumeRate              = %u\n", 
+		slurm_ctl_conf_ptr->resume_rate);
+	fprintf(out, "ReturnToService         = %u\n", 
 		slurm_ctl_conf_ptr->ret2service);
-	fprintf(out, "SchedulerPort     = %u\n",
+	fprintf(out, "SchedulerParameters     = %s\n",
+		slurm_ctl_conf_ptr->sched_params);
+	fprintf(out, "SchedulerPort           = %u\n",
 		slurm_ctl_conf_ptr->schedport);
-	fprintf(out, "SchedulerRootFilter = %u\n",
+	fprintf(out, "SchedulerRootFilter     = %u\n",
 		slurm_ctl_conf_ptr->schedrootfltr);
-	fprintf(out, "SchedulerType     = %s\n",
+	fprintf(out, "SchedulerTimeSlice      = %u\n",
+		slurm_ctl_conf_ptr->sched_time_slice);
+	fprintf(out, "SchedulerType           = %s\n",
 		slurm_ctl_conf_ptr->schedtype);
-	fprintf(out, "SelectType        = %s\n",
+	fprintf(out, "SelectType              = %s\n",
 		slurm_ctl_conf_ptr->select_type);
 	if (slurm_ctl_conf_ptr->select_type_param) {
-		fprintf(out, "SelectTypeParameters = %s\n",
+		fprintf(out, "SelectTypeParameters    = %s\n",
 			_select_info(slurm_ctl_conf_ptr->
 			select_type_param));
 	}
-	fprintf(out, "SlurmUser         = %s(%u)\n", 
+	fprintf(out, "SlurmUser               = %s(%u)\n", 
 		slurm_ctl_conf_ptr->slurm_user_name,
 		slurm_ctl_conf_ptr->slurm_user_id);
-	fprintf(out, "SlurmctldDebug    = %u\n", 
+	fprintf(out, "SlurmctldDebug          = %u\n", 
 		slurm_ctl_conf_ptr->slurmctld_debug);
-	fprintf(out, "SlurmctldLogFile  = %s\n", 
+	fprintf(out, "SlurmctldLogFile        = %s\n", 
 		slurm_ctl_conf_ptr->slurmctld_logfile);
-	fprintf(out, "SlurmctldPidFile  = %s\n", 
+	fprintf(out, "SlurmctldPidFile        = %s\n", 
 		slurm_ctl_conf_ptr->slurmctld_pidfile);
-	fprintf(out, "SlurmctldPort     = %u\n", 
+	fprintf(out, "SlurmctldPort           = %u\n", 
 		slurm_ctl_conf_ptr->slurmctld_port);
-	fprintf(out, "SlurmctldTimeout  = %u\n", 
+	fprintf(out, "SlurmctldTimeout        = %u\n", 
 		slurm_ctl_conf_ptr->slurmctld_timeout);
-	fprintf(out, "SlurmdDebug       = %u\n", 
+	fprintf(out, "SlurmdDebug             = %u\n", 
 		slurm_ctl_conf_ptr->slurmd_debug);
-	fprintf(out, "SlurmdLogFile     = %s\n", 
+	fprintf(out, "SlurmdLogFile           = %s\n", 
 		slurm_ctl_conf_ptr->slurmd_logfile);
-	fprintf(out, "SlurmdPidFile     = %s\n", 
+	fprintf(out, "SlurmdPidFile           = %s\n", 
 		slurm_ctl_conf_ptr->slurmd_pidfile);
 #ifndef MULTIPLE_SLURMD
-	fprintf(out, "SlurmdPort        = %u\n", 
+	fprintf(out, "SlurmdPort              = %u\n", 
 		slurm_ctl_conf_ptr->slurmd_port);
 #endif
-	fprintf(out, "SlurmdSpoolDir    = %s\n", 
+	fprintf(out, "SlurmdSpoolDir          = %s\n", 
 		slurm_ctl_conf_ptr->slurmd_spooldir);
-	fprintf(out, "SlurmdTimeout     = %u\n", 
+	fprintf(out, "SlurmdTimeout           = %u\n", 
 		slurm_ctl_conf_ptr->slurmd_timeout);
-	fprintf(out, "SLURM_CONFIG_FILE = %s\n", 
+	fprintf(out, "SLURM_CONFIG_FILE       = %s\n", 
 		slurm_ctl_conf_ptr->slurm_conf);
-	fprintf(out, "SLURM_VERSION     = %s\n", SLURM_VERSION);
-	fprintf(out, "SrunProlog        = %s\n",
-		slurm_ctl_conf_ptr->srun_prolog);
-	fprintf(out, "SrunEpilog        = %s\n",
+	fprintf(out, "SLURM_VERSION           = %s\n", SLURM_VERSION);
+	fprintf(out, "SrunEpilog              = %s\n",
 		slurm_ctl_conf_ptr->srun_epilog);
-	fprintf(out, "StateSaveLocation = %s\n", 
+	fprintf(out, "SrunProlog              = %s\n",
+		slurm_ctl_conf_ptr->srun_prolog);
+	fprintf(out, "StateSaveLocation       = %s\n", 
 		slurm_ctl_conf_ptr->state_save_location);
-	fprintf(out, "SwitchType        = %s\n",
+	fprintf(out, "SuspendExcNodes         = %s\n", 
+		slurm_ctl_conf_ptr->suspend_exc_nodes);
+	fprintf(out, "SuspendExcParts         = %s\n", 
+		slurm_ctl_conf_ptr->suspend_exc_parts);
+	fprintf(out, "SuspendProgram          = %s\n", 
+		slurm_ctl_conf_ptr->suspend_program);
+	fprintf(out, "SuspendRate             = %u\n", 
+		slurm_ctl_conf_ptr->suspend_rate);
+	fprintf(out, "SuspendTime             = %d\n", 
+		((int)slurm_ctl_conf_ptr->suspend_time - 1));
+	fprintf(out, "SwitchType              = %s\n",
 		slurm_ctl_conf_ptr->switch_type);
-	fprintf(out, "TaskEpilog        = %s\n",
+	fprintf(out, "TaskEpilog              = %s\n",
 		slurm_ctl_conf_ptr->task_epilog);
-	fprintf(out, "TaskPlugin        = %s\n",
+	fprintf(out, "TaskPlugin              = %s\n",
 		 slurm_ctl_conf_ptr->task_plugin);
-	fprintf(out, "TaskPluginParam   = %s\n",
+	fprintf(out, "TaskPluginParam         = %s\n",
 		_task_plugin_param(slurm_ctl_conf_ptr->task_plugin_param));
-	fprintf(out, "TaskProlog        = %s\n",
+	fprintf(out, "TaskProlog              = %s\n",
 		slurm_ctl_conf_ptr->task_prolog);
-	fprintf(out, "TmpFS             = %s\n", 
+	fprintf(out, "TmpFS                   = %s\n", 
 		slurm_ctl_conf_ptr->tmp_fs);
-	fprintf(out, "TreeWidth         = %u\n",
+	fprintf(out, "TreeWidth               = %u\n",
 		slurm_ctl_conf_ptr->tree_width);
-	fprintf(out, "UsePam            = %u\n",
+	fprintf(out, "UsePam                  = %u\n",
 		slurm_ctl_conf_ptr->use_pam);
-	fprintf(out, "WaitTime          = %u\n", 
+	fprintf(out, "UnkillableStepProgram   = %s\n",
+		slurm_ctl_conf_ptr->unkillable_program);
+	fprintf(out, "UnkillableStepTimeout   = %u\n",
+		slurm_ctl_conf_ptr->unkillable_timeout);
+	fprintf(out, "WaitTime                = %u\n", 
 		slurm_ctl_conf_ptr->wait_time);
 }
 
diff --git a/src/api/init_msg.c b/src/api/init_msg.c
index 528eb3850a888145ba8f60be095ddba555becb9f..ec1e1f797fea38d789dae485e710e2a87ac061ad 100644
--- a/src/api/init_msg.c
+++ b/src/api/init_msg.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  init_msg.c - initialize RPC messages contents
- *  $Id: init_msg.c 12457 2007-10-05 23:15:28Z jette $
+ *  $Id: init_msg.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,6 +56,7 @@
 void slurm_init_job_desc_msg(job_desc_msg_t * job_desc_msg)
 {
 	job_desc_msg->account     = NULL;
+	job_desc_msg->acctg_freq  = (uint16_t) NO_VAL;
 	job_desc_msg->alloc_node  = NULL;
 	job_desc_msg->alloc_sid   = NO_VAL;
 	job_desc_msg->comment     = NULL;
@@ -64,7 +65,7 @@ void slurm_init_job_desc_msg(job_desc_msg_t * job_desc_msg)
 	job_desc_msg->ntasks_per_node   = (uint16_t) NO_VAL;
 	job_desc_msg->ntasks_per_socket = (uint16_t) NO_VAL;
 	job_desc_msg->ntasks_per_core   = (uint16_t) NO_VAL;
-	job_desc_msg->dependency  = NO_VAL;
+	job_desc_msg->dependency  = NULL;
 	job_desc_msg->environment = ((char **) NULL);
 	job_desc_msg->env_size    = 0;
 	job_desc_msg->features    = NULL;
@@ -74,10 +75,10 @@ void slurm_init_job_desc_msg(job_desc_msg_t * job_desc_msg)
 	job_desc_msg->job_min_procs   = (uint16_t) NO_VAL;
 	job_desc_msg->job_min_sockets = (uint16_t) NO_VAL;
 	job_desc_msg->job_min_threads = (uint16_t) NO_VAL;
-	job_desc_msg->job_max_memory  = NO_VAL;
 	job_desc_msg->job_min_memory  = NO_VAL;
 	job_desc_msg->job_min_tmp_disk= NO_VAL;
 	job_desc_msg->kill_on_node_fail = (uint16_t) NO_VAL;
+	job_desc_msg->licenses    = NULL;
 	job_desc_msg->name        = NULL;
 	job_desc_msg->network     = NULL;
 	job_desc_msg->nice        = NICE_OFFSET;
@@ -85,7 +86,8 @@ void slurm_init_job_desc_msg(job_desc_msg_t * job_desc_msg)
 	job_desc_msg->ntasks_per_node   = (uint16_t) NO_VAL;
 	job_desc_msg->ntasks_per_socket = (uint16_t) NO_VAL;
 	job_desc_msg->num_tasks   = NO_VAL;
-	job_desc_msg->overcommit  = (uint16_t) NO_VAL;
+	job_desc_msg->open_mode   = 0;	/* system default */
+	job_desc_msg->overcommit  = (uint8_t) NO_VAL;
 	job_desc_msg->partition   = NULL;
 	job_desc_msg->plane_size  = (uint16_t) NO_VAL;
 	job_desc_msg->priority    = NO_VAL;
@@ -112,14 +114,12 @@ void slurm_init_job_desc_msg(job_desc_msg_t * job_desc_msg)
 	job_desc_msg->user_id     = NO_VAL;
 	job_desc_msg->group_id    = NO_VAL;
 	job_desc_msg->work_dir    = NULL;
-	job_desc_msg->alloc_resp_hostname = NULL;
-	job_desc_msg->alloc_resp_port        = 0;
-	job_desc_msg->other_hostname = NULL;
+	job_desc_msg->alloc_resp_port = 0;
 	job_desc_msg->other_port  = 0;
 	job_desc_msg->mail_type   = 0;
 	job_desc_msg->mail_user   = NULL;
 	job_desc_msg->begin_time  = 0;
-	job_desc_msg->no_requeue  = (uint16_t) NO_VAL;
+	job_desc_msg->requeue  = (uint16_t) NO_VAL;
 #if SYSTEM_DIMENSIONS
 {
 	int i;
@@ -153,7 +153,8 @@ void slurm_init_part_desc_msg (update_part_msg_t * update_part_msg)
 	update_part_msg->hidden 	= (uint16_t) NO_VAL;
 	update_part_msg->default_part 	= (uint16_t) NO_VAL;
 	update_part_msg->root_only 	= (uint16_t) NO_VAL;
-	update_part_msg->shared 	= (uint16_t) NO_VAL;
+	update_part_msg->max_share 	= (uint16_t) NO_VAL;
+	update_part_msg->priority 	= (uint16_t) NO_VAL;
 	update_part_msg->state_up 	= (uint16_t) NO_VAL;
 }
 
diff --git a/src/api/job_info.c b/src/api/job_info.c
index a71cdde15fe556b3513396b56958833781a1e9b5..26bf30965c4ee61be508cb3877c83b3e4ef55b22 100644
--- a/src/api/job_info.c
+++ b/src/api/job_info.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  job_info.c - get/print the job state information of slurm
- *  $Id: job_info.c 13465 2008-03-04 16:51:08Z jette $
+ *  $Id: job_info.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -189,8 +189,11 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 		sprintf(tmp_line, "UNLIMITED ");
 	else if (job_ptr->time_limit == NO_VAL)
 		sprintf(tmp_line, "Partition_Limit ");
-	else
-		sprintf(tmp_line, "%u ", job_ptr->time_limit);
+	else {
+		secs2time_str(job_ptr->time_limit * 60, tmp1,
+			sizeof(tmp1));
+		sprintf(tmp_line, "%s ", tmp1);
+	}
 	xstrcat(out, tmp_line);
 	if (WIFSIGNALED(job_ptr->exit_code))
 		term_sig = WTERMSIG(job_ptr->exit_code);
@@ -339,10 +342,11 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 
 	/****** Line 8 ******/
 	snprintf(tmp_line, sizeof(tmp_line),
-		"Shared=%s Contiguous=%d CPUs/task=%u", 
+		"Shared=%s Contiguous=%d CPUs/task=%u Licenses=%s", 
 		 (job_ptr->shared == 0 ? "0" :
 		  job_ptr->shared == 1 ? "1" : "OK"),
-		 job_ptr->contiguous, job_ptr->cpus_per_task);
+		 job_ptr->contiguous, job_ptr->cpus_per_task,
+		 job_ptr->licenses);
 	xstrcat(out, tmp_line);
 
 	if (one_liner)
@@ -377,8 +381,17 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 
 	/****** Line 11 ******/
 	snprintf(tmp_line, sizeof(tmp_line), 
-		"Dependency=%u Account=%s Reason=%s Network=%s",
-		job_ptr->dependency, job_ptr->account,
+		"Dependency=%s Account=%s Requeue=%u",
+		job_ptr->dependency, job_ptr->account, job_ptr->requeue);
+	xstrcat(out, tmp_line);
+	if (one_liner)
+		xstrcat(out, " ");
+	else
+		xstrcat(out, "\n   ");
+
+	/****** Line 12 ******/
+	snprintf(tmp_line, sizeof(tmp_line), 
+		"Reason=%s Network=%s",
 		job_reason_string(job_ptr->state_reason), 
 		job_ptr->network);
 	xstrcat(out, tmp_line);
@@ -387,7 +400,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 	else
 		xstrcat(out, "\n   ");
 
-	/****** Line 12 ******/
+	/****** Line 13 ******/
 	snprintf(tmp_line, sizeof(tmp_line), "Req%s=%s Req%sIndices=", 
 		nodelist, job_ptr->req_nodes, nodelist);
 	xstrcat(out, tmp_line);
@@ -404,7 +417,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 	else
 		xstrcat(out, "\n   ");
 
-	/****** Line 13 ******/
+	/****** Line 14 ******/
 	snprintf(tmp_line, sizeof(tmp_line), "Exc%s=%s Exc%sIndices=", 
 		nodelist, job_ptr->exc_nodes, nodelist);
 	xstrcat(out, tmp_line);
@@ -421,7 +434,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 	else
 		xstrcat(out, "\n   ");
 
-	/****** Line 14 ******/
+	/****** Line 15 ******/
 	slurm_make_time_str((time_t *)&job_ptr->submit_time, time_str, 
 		sizeof(time_str));
 	snprintf(tmp_line, sizeof(tmp_line), "SubmitTime=%s ", 
@@ -437,7 +450,24 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 		  time_str, (long int)job_ptr->pre_sus_time);
 	xstrcat(out, tmp_line);
 
-	/****** Line 15 (optional) ******/
+	/****** Lines 16, 17 (optional, batch only) ******/
+	if (job_ptr->batch_flag) {
+		if (one_liner)
+			xstrcat(out, " ");
+		else
+			xstrcat(out, "\n   ");
+		sprintf(tmp_line, "Command=%s", job_ptr->command);
+		xstrcat(out, tmp_line);
+
+		if (one_liner)
+			xstrcat(out, " ");
+		else
+			xstrcat(out, "\n   ");
+		sprintf(tmp_line, "WorkDir=%s", job_ptr->work_dir);
+		xstrcat(out, tmp_line);
+	}
+
+	/****** Line 18 (optional) ******/
 	if (job_ptr->comment) {
 		if (one_liner)
 			xstrcat(out, " ");
@@ -448,7 +478,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 		xstrcat(out, tmp_line);
 	}
 
-	/****** Line 16 (optional) ******/
+	/****** Line 19 (optional) ******/
 	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
 				select_buf, sizeof(select_buf),
 				SELECT_PRINT_MIXED);
@@ -459,7 +489,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 			xstrcat(out, "\n   ");
 		xstrcat(out, select_buf);
 	}
-	/****** Line 17 (optional) ******/
+	/****** Line 20 (optional) ******/
 	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
 				select_buf, sizeof(select_buf),
 				SELECT_PRINT_BLRTS_IMAGE);
@@ -472,7 +502,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 			 "BlrtsImage=%s", select_buf);
 		xstrcat(out, tmp_line);
 	}
-	/****** Line 18 (optional) ******/
+	/****** Line 21 (optional) ******/
 	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
 				select_buf, sizeof(select_buf),
 				SELECT_PRINT_LINUX_IMAGE);
@@ -485,7 +515,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 			 "LinuxImage=%s", select_buf);
 		xstrcat(out, tmp_line);
 	}
-	/****** Line 19 (optional) ******/
+	/****** Line 22 (optional) ******/
 	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
 				select_buf, sizeof(select_buf),
 				SELECT_PRINT_MLOADER_IMAGE);
@@ -498,7 +528,7 @@ slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner )
 			 "MloaderImage=%s", select_buf);
 		xstrcat(out, tmp_line);
 	}
-	/****** Line 20 (optional) ******/
+	/****** Line 23 (optional) ******/
 	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
 				select_buf, sizeof(select_buf),
 				SELECT_PRINT_RAMDISK_IMAGE);
diff --git a/src/api/job_info.h b/src/api/job_info.h
index 0c4c788554876dc75f91ed0716b550576480a708..b9fe249ba8fb71f624c0d5193137a0e6f30ae6b5 100644
--- a/src/api/job_info.h
+++ b/src/api/job_info.h
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  job_info.h - get/print the job state information of slurm
  *
- *  $Id: job_info.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: job_info.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/job_step_info.c b/src/api/job_step_info.c
index 08cdee08769cdd6da840fe3635c42dca047cef2e..f90d56f925d060c9a847a7b0a7b7435299a976ec 100644
--- a/src/api/job_step_info.c
+++ b/src/api/job_step_info.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  job_step_info.c - get/print the job step state information of slurm
- *  $Id: job_step_info.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: job_step_info.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>, 
  *             Joey Ekstrom <ekstrom1@llnl.gov>,  et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -128,9 +128,20 @@ slurm_sprint_job_step_info ( job_step_info_t * job_step_ptr,
 
 	/****** Line 2 ******/
 	snprintf(tmp_line, sizeof(tmp_line),
-		"Partition=%s Nodes=%s Name=%s Network=%s\n\n", 
+		"Partition=%s Nodes=%s Name=%s Network=%s Checkpoint=%u", 
 		job_step_ptr->partition, job_step_ptr->nodes,
-		job_step_ptr->name, job_step_ptr->network);
+		job_step_ptr->name, job_step_ptr->network,
+		job_step_ptr->ckpt_interval);
+	xstrcat(out, tmp_line);
+	if (one_liner)
+		xstrcat(out, " ");
+	else
+		xstrcat(out, "\n   ");
+
+	/****** Line 3 ******/
+	snprintf(tmp_line, sizeof(tmp_line),
+		"CheckpointPath=%s\n\n", 
+		 job_step_ptr->ckpt_path);
 	xstrcat(out, tmp_line);
 
 	return out;
diff --git a/src/api/node_info.c b/src/api/node_info.c
index b22adfa2e2357467f1490ea970ad478e05ebdd63..b26c8c365074341cf2541e58b3b0e138331a6ec9 100644
--- a/src/api/node_info.c
+++ b/src/api/node_info.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  node_info.c - get/print the node state information of slurm
- *  $Id: node_info.c 12825 2007-12-14 21:23:57Z jette $
+ *  $Id: node_info.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -147,6 +147,18 @@ slurm_sprint_node_table (node_info_t * node_ptr, int one_liner )
 		node_ptr->weight, node_ptr->features,
 		node_ptr->reason);
 	xstrcat(out, tmp_line);
+
+	/****** Line 3 (optional) ******/
+	if (node_ptr->arch || node_ptr->os) {
+		if (one_liner)
+			xstrcat(out, " ");
+		else
+			xstrcat(out, "\n   ");
+		snprintf(tmp_line, sizeof(tmp_line),
+			"Arch=%s OS=%s",
+			node_ptr->arch, node_ptr->os);
+		xstrcat(out, tmp_line);
+	}
 	xstrcat(out, "\n");
 
 	return out;
diff --git a/src/api/node_select_info.c b/src/api/node_select_info.c
index cefbe01d0ccadba377606b27454c3befc9dbaddf..2e5f2f982778c76891babb4a14f8368c88b1d7da 100644
--- a/src/api/node_select_info.c
+++ b/src/api/node_select_info.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  node_select_info.c - get the node select plugin state information of slurm
  *
- *  $Id: node_select_info.c 12825 2007-12-14 21:23:57Z jette $
+ *  $Id: node_select_info.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/node_select_info.h b/src/api/node_select_info.h
index 6c4c03f4926051c2e623dd7ff8b9f53948fd7762..be41041e5aaef022859fec2352a244bee5e74115 100644
--- a/src/api/node_select_info.h
+++ b/src/api/node_select_info.h
@@ -5,12 +5,12 @@
  *  NOTE: This software specifically supports only BlueGene/L for now. It 
  *	will be made more general in the future
  *
- *  $Id: node_select_info.h 10744 2007-01-11 20:09:18Z da $
+ *  $Id: node_select_info.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/partition_info.c b/src/api/partition_info.c
index 5729074ce9cccd7ec1d7dff609ccc79498eb2a2a..416d43440e46ddcb692f6eaf21d27233591e61ad 100644
--- a/src/api/partition_info.c
+++ b/src/api/partition_info.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  partition_info.c - get/print the partition state information of slurm
- *  $Id: partition_info.c 12627 2007-11-06 19:48:55Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *   
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -108,6 +108,7 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr,
 	char tmp1[16], tmp2[16];
 	char tmp_line[MAXHOSTRANGELEN];
 	char *out = NULL;
+	uint16_t force, val;
 
 	/****** Line 1 ******/
 #ifdef HAVE_BG
@@ -139,14 +140,20 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr,
 	else
 		sprintf(tmp_line, "Default=NO ");
 	xstrcat(out, tmp_line);
-	if (part_ptr->shared == SHARED_NO)
-		sprintf(tmp_line, "Shared=NO ");
-	else if (part_ptr->shared == SHARED_YES)
-		sprintf(tmp_line, "Shared=YES ");
-	else if (part_ptr->shared == SHARED_EXCLUSIVE)
-		sprintf(tmp_line, "Shared=EXCLUSIVE ");
-	else
-		sprintf(tmp_line, "Shared=FORCE ");
+	force = part_ptr->max_share & SHARED_FORCE;
+	val = part_ptr->max_share & (~SHARED_FORCE);
+	if (val == 0)
+		xstrcat(out, "Shared=EXCLUSIVE ");
+	else if (force) {
+		sprintf(tmp_line, "Shared=FORCE:%u ", val);
+		xstrcat(out, tmp_line);
+	} else if (val == 1)
+		xstrcat(out, "Shared=NO ");
+	else {
+		sprintf(tmp_line, "Shared=YES:%u ", val);
+		xstrcat(out, tmp_line);
+	}
+	sprintf(tmp_line, "Priority=%u ", part_ptr->priority);
 	xstrcat(out, tmp_line);
 	if (part_ptr->state_up)
 		sprintf(tmp_line, "State=UP ");
@@ -155,8 +162,12 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr,
 	xstrcat(out, tmp_line);
 	if (part_ptr->max_time == INFINITE)
 		sprintf(tmp_line, "MaxTime=UNLIMITED ");
-	else
-		sprintf(tmp_line, "MaxTime=%u ", part_ptr->max_time);
+	else {
+		char time_line[32];
+		secs2time_str(part_ptr->max_time * 60, time_line, 
+			sizeof(time_line));
+		sprintf(tmp_line, "MaxTime=%s ", time_line);
+	}
 	xstrcat(out, tmp_line);
 	if (part_ptr->hidden)
 		sprintf(tmp_line, "Hidden=YES");
@@ -169,7 +180,6 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr,
 		xstrcat(out, "\n   ");
 	
 	/****** Line 3 ******/
-
 #ifdef HAVE_BG
 	convert_num_unit((float)part_ptr->min_nodes, tmp1, sizeof(tmp1),
 			 UNIT_NONE);
@@ -191,6 +201,11 @@ char *slurm_sprint_partition_info ( partition_info_t * part_ptr,
 		sprintf(tmp_line, "MaxNodes=%s ", tmp1);
 	}
 	xstrcat(out, tmp_line);
+	if (part_ptr->disable_root_jobs)
+		sprintf(tmp_line, "DisableRootJobs=YES ");
+	else
+		sprintf(tmp_line, "DisableRootJobs=NO ");
+	xstrcat(out, tmp_line);
 	if ((part_ptr->allow_groups == NULL) || 
 	    (part_ptr->allow_groups[0] == '\0'))
 		sprintf(tmp_line, "AllowGroups=ALL");
diff --git a/src/api/pmi.c b/src/api/pmi.c
index 67742612765c0da05a35bb9a1096eae53d97e900..d0a7754beb1d3a336318e3bb75e9af5cf09ea5ee 100644
--- a/src/api/pmi.c
+++ b/src/api/pmi.c
@@ -49,7 +49,7 @@
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -60,7 +60,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -79,7 +79,9 @@
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
-#define _GNU_SOURCE
+#ifndef   _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
 
 #include <pthread.h>
 #include <signal.h>
diff --git a/src/api/pmi_server.c b/src/api/pmi_server.c
index 406da910d5b099fda0796573897a1cf0a01a17c0..ee0122497abc145c41f811b7c9f76d87fedd638f 100644
--- a/src/api/pmi_server.c
+++ b/src/api/pmi_server.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
- *  pmi.c - Global PMI data as maintained within srun
- *  $Id: pmi_server.c 12620 2007-11-05 19:00:45Z jette $
+ *  pmi_server.c - Global PMI data as maintained within srun
+ *  $Id: pmi_server.c 14078 2008-05-19 23:56:20Z jette $
  *****************************************************************************
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/pmi_server.h b/src/api/pmi_server.h
index d8d24ad69ea6c9ac1da1924eb9ba58ff6849093b..03e42c52e4fabf235a0cd001483086cde7efc4d2 100644
--- a/src/api/pmi_server.h
+++ b/src/api/pmi_server.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  pmi.h - Global PMI data as maintained within srun
- *  $Id: pmi_server.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: pmi_server.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/reconfigure.c b/src/api/reconfigure.c
index b281ce7f61d7670f9e6e9227e4c06659dd156d43..9ac7fc5db13e9adb59a76e7f4335b54d42b061a1 100644
--- a/src/api/reconfigure.c
+++ b/src/api/reconfigure.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  reconfigure.c - request that slurmctld shutdown or re-read the 
  *	            configuration files
- *  $Id: reconfigure.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: reconfigure.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -138,7 +138,7 @@ _send_message_controller (enum controller_id dest, slurm_msg_t *req)
 	slurm_fd fd = -1;
 	slurm_msg_t *resp_msg = NULL;
 		
-	/*always only going to 1 node */
+	/* always going to one node (primary or backup per value of "dest") */
 	if ((fd = slurm_open_controller_conn_spec(dest)) < 0)
 		slurm_seterrno_ret(SLURMCTLD_COMMUNICATIONS_CONNECTION_ERROR);
 
@@ -165,3 +165,39 @@ _send_message_controller (enum controller_id dest, slurm_msg_t *req)
         return rc;
 }
 
+/*
+ * slurm_set_debug_level - issue RPC to set slurm controller debug level
+ * IN debug_level - requested debug level
+ * RET 0 on success, otherwise return -1 and set errno to indicate the error
+ */
+int
+slurm_set_debug_level (uint32_t debug_level)
+{
+	int rc;
+	slurm_msg_t req_msg;
+	slurm_msg_t resp_msg;
+	set_debug_level_msg_t req;
+
+	slurm_msg_t_init(&req_msg);
+	slurm_msg_t_init(&resp_msg);
+
+	req.debug_level  = debug_level;
+	req_msg.msg_type = REQUEST_SET_DEBUG_LEVEL;
+	req_msg.data     = &req;
+
+	if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0)
+		return SLURM_ERROR;
+
+	switch (resp_msg.msg_type) {
+	case RESPONSE_SLURM_RC:
+		rc = ((return_code_msg_t *) resp_msg.data)->return_code;
+		slurm_free_return_code_msg(resp_msg.data);
+		if (rc)
+			slurm_seterrno_ret(rc);
+		break;
+	default:
+		slurm_seterrno_ret(SLURM_UNEXPECTED_MSG_ERROR);
+		break;
+	}
+        return SLURM_PROTOCOL_SUCCESS;
+}
diff --git a/src/api/signal.c b/src/api/signal.c
index 3091fa6de220ccc1b2856ec3b8c996ca7e7fc784..76916aa66631f3157e880553a360bb4c3c764aa5 100644
--- a/src/api/signal.c
+++ b/src/api/signal.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  signal.c - Send a signal to a slurm job or job step
- *  $Id: signal.c 12647 2007-11-12 17:09:47Z da $
+ *  $Id: signal.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -404,3 +404,37 @@ static int _terminate_batch_script_step(
 	return rc;
 }
 
+/*
+ * slurm_notify_job - send message to the job's stdout, 
+ *	usable only by user root
+ * IN job_id - slurm job_id or 0 for all jobs
+ * IN message - arbitrary message
+ * RET 0 or -1 on error
+ */
+extern int slurm_notify_job (uint32_t job_id, char *message)
+{
+	int rc;
+	slurm_msg_t msg;
+	job_notify_msg_t req;
+
+	slurm_msg_t_init(&msg);
+	/* 
+	 * Request message:
+	 */
+	req.job_id      = job_id;
+	req.job_step_id = NO_VAL;	/* currently not used */
+	req.message     = message;
+	msg.msg_type    = REQUEST_JOB_NOTIFY;
+	msg.data        = &req;
+
+	if (slurm_send_recv_controller_rc_msg(&msg, &rc) < 0)
+		return SLURM_FAILURE;
+
+	if (rc) {
+		slurm_seterrno_ret(rc);
+		return SLURM_FAILURE;
+	}
+
+	return SLURM_SUCCESS;
+}
+
diff --git a/src/api/slurm_pmi.c b/src/api/slurm_pmi.c
index f1c2454e455396d730b9c936cffeb16dda1ad2b9..54165bfd1332efb7f71acf4eaa1ccd7591583e30 100644
--- a/src/api/slurm_pmi.c
+++ b/src/api/slurm_pmi.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/slurm_pmi.h b/src/api/slurm_pmi.h
index 8a46e05b8872b21b436aba5e4d897b5a5a79db36..8b0a61ba2d282c29d8f382d8021c1ba8f4b7adc2 100644
--- a/src/api/slurm_pmi.h
+++ b/src/api/slurm_pmi.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/step_ctx.c b/src/api/step_ctx.c
index f43a12aa37d1de9ef7e651111c8bd008a1a86d6d..3b3bd1d1cdea26de18b97a8c7f6c4b64295cb851 100644
--- a/src/api/step_ctx.c
+++ b/src/api/step_ctx.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  step_ctx.c - step_ctx task functions for use by AIX/POE
  *
- *  $Id: step_ctx.c 12171 2007-08-29 17:22:48Z jette $
+ *  $Id: step_ctx.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -50,16 +50,56 @@
 #include "src/common/slurm_protocol_defs.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
+#include "src/common/slurm_cred.h"
 
 #include "src/api/step_ctx.h"
 
+static void
+_job_fake_cred(struct slurm_step_ctx_struct *ctx)
+{
+	slurm_cred_arg_t arg;
+	arg.jobid    = ctx->job_id;
+	arg.stepid   = ctx->step_resp->job_step_id;
+	arg.uid      = ctx->user_id;
+	arg.hostlist = ctx->step_req->node_list;
+        arg.alloc_lps_cnt = 0;    
+        arg.alloc_lps     =  NULL; 
+	ctx->step_resp->cred = slurm_cred_faker(&arg);
+}
+
+static job_step_create_request_msg_t *_create_step_request(
+	const slurm_step_ctx_params_t *step_params)
+{
+	job_step_create_request_msg_t *step_req = 
+		xmalloc(sizeof(job_step_create_request_msg_t));
+	step_req->job_id = step_params->job_id;
+	step_req->user_id = (uint32_t)step_params->uid;
+	step_req->node_count = step_params->node_count;
+	step_req->cpu_count = step_params->cpu_count;
+	step_req->num_tasks = step_params->task_count;
+	step_req->relative = step_params->relative;
+	step_req->exclusive  = step_params->exclusive;
+	step_req->immediate  = step_params->immediate;
+	step_req->ckpt_interval = step_params->ckpt_interval;
+	step_req->ckpt_path = xstrdup(step_params->ckpt_path);
+	step_req->task_dist = step_params->task_dist;
+	step_req->plane_size = step_params->plane_size;
+	step_req->node_list = xstrdup(step_params->node_list);
+	step_req->network = xstrdup(step_params->network);
+	step_req->name = xstrdup(step_params->name);
+	step_req->overcommit = step_params->overcommit ? 1 : 0;
+	step_req->mem_per_task = step_params->mem_per_task;
+
+	return step_req;
+}
+
 /*
  * slurm_step_ctx_create - Create a job step and its context. 
  * IN step_params - job step parameters
  * RET the step context or NULL on failure with slurm errno set
  * NOTE: Free allocated memory using slurm_step_ctx_destroy.
  */
-extern slurm_step_ctx
+extern slurm_step_ctx_t *
 slurm_step_ctx_create (const slurm_step_ctx_params_t *step_params)
 {
 	struct slurm_step_ctx_struct *ctx = NULL;
@@ -69,21 +109,9 @@ slurm_step_ctx_create (const slurm_step_ctx_params_t *step_params)
 	short port = 0;
 	int errnum = 0;
 	
-	/* First copy the user's step_params into a step request struct */
-	step_req = (job_step_create_request_msg_t *)
-		xmalloc(sizeof(job_step_create_request_msg_t));
-	step_req->job_id = step_params->job_id;
-	step_req->user_id = (uint32_t)step_params->uid;
-	step_req->node_count = step_params->node_count;
-	step_req->cpu_count = step_params->cpu_count;
-	step_req->num_tasks = step_params->task_count;
-	step_req->relative = step_params->relative;
-	step_req->task_dist = step_params->task_dist;
-	step_req->plane_size = step_params->plane_size;
-	step_req->node_list = xstrdup(step_params->node_list);
-	step_req->network = xstrdup(step_params->network);
-	step_req->name = xstrdup(step_params->name);
-	step_req->overcommit = step_params->overcommit ? 1 : 0;
+	/* First copy the user's step_params into a step request
+	 * struct */
+	step_req = _create_step_request(step_params);
 
 	/* We will handle the messages in the step_launch.c mesage handler,
 	 * but we need to open the socket right now so we can tell the
@@ -112,13 +140,90 @@ slurm_step_ctx_create (const slurm_step_ctx_params_t *step_params)
 	ctx->user_id	= step_req->user_id;
 	ctx->step_req   = step_req;
 	ctx->step_resp	= step_resp;
+	ctx->verbose_level = step_params->verbose_level;
 
 	ctx->launch_state = step_launch_state_create(ctx);
 	ctx->launch_state->slurmctld_socket_fd = sock;
+fail:
+	errno = errnum;
+	return (slurm_step_ctx_t *)ctx;
+}
+
+/*
+ * slurm_step_ctx_create_no_alloc - Create a job step and its context without
+ *                                  getting an allocation. 
+ * IN step_params - job step parameters
+ * IN step_id     - since we are faking it give me the id to use
+ * RET the step context or NULL on failure with slurm errno set
+ * NOTE: Free allocated memory using slurm_step_ctx_destroy.
+ */
+extern slurm_step_ctx_t *
+slurm_step_ctx_create_no_alloc (const slurm_step_ctx_params_t *step_params,
+				uint32_t step_id)
+{
+	struct slurm_step_ctx_struct *ctx = NULL;
+	job_step_create_request_msg_t *step_req = NULL;
+	job_step_create_response_msg_t *step_resp = NULL;
+	int sock = -1;
+	short port = 0;
+	int errnum = 0;
+	int cyclic = (step_params->task_dist == SLURM_DIST_CYCLIC);
+	
+	/* First copy the user's step_params into a step request struct */
+	step_req = _create_step_request(step_params);
+
+	/* We will handle the messages in the step_launch.c mesage handler,
+	 * but we need to open the socket right now so we can tell the
+	 * controller which port to use.
+	 */
+	if (net_stream_listen(&sock, &port) < 0) {
+		errnum = errno;
+		error("unable to intialize step context socket: %m");
+		slurm_free_job_step_create_request_msg(step_req);
+		goto fail;
+	}
+	step_req->port = port;
+	step_req->host = xshort_hostname();
+
+	/* Then make up a reponse with only certain things filled in */
+	step_resp = (job_step_create_response_msg_t *)
+		xmalloc(sizeof(job_step_create_response_msg_t));
+
+	step_resp->step_layout = fake_slurm_step_layout_create(
+		step_req->node_list, 
+		NULL, NULL,
+		step_req->node_count,
+		step_req->num_tasks);
+	
+	if (switch_alloc_jobinfo(&step_resp->switch_job) < 0)
+		fatal("switch_alloc_jobinfo: %m");
+	if (switch_build_jobinfo(step_resp->switch_job, 
+				 step_resp->step_layout->node_list, 
+				 step_resp->step_layout->tasks, 
+				 cyclic, step_req->network) < 0)
+		fatal("switch_build_jobinfo: %m");
+
 
+
+	step_resp->job_step_id = step_id;
+
+	ctx = xmalloc(sizeof(struct slurm_step_ctx_struct));
+	ctx->launch_state = NULL;
+	ctx->magic	= STEP_CTX_MAGIC;
+	ctx->job_id	= step_req->job_id;
+	ctx->user_id	= step_req->user_id;
+	ctx->step_req   = step_req;
+	ctx->step_resp	= step_resp;
+	ctx->verbose_level = step_params->verbose_level;
+
+	ctx->launch_state = step_launch_state_create(ctx);
+	ctx->launch_state->slurmctld_socket_fd = sock;
+	
+	_job_fake_cred(ctx);
+	
 fail:
 	errno = errnum;
-	return (slurm_step_ctx)ctx;
+	return (slurm_step_ctx_t *)ctx;
 }
 
 /*
@@ -127,7 +232,7 @@ fail:
  * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
  */
 extern int
-slurm_step_ctx_get (slurm_step_ctx ctx, int ctx_key, ...)
+slurm_step_ctx_get (slurm_step_ctx_t *ctx, int ctx_key, ...)
 {
 	va_list ap;
 	int rc = SLURM_SUCCESS;
@@ -252,7 +357,7 @@ slurm_jobinfo_ctx_get(switch_jobinfo_t jobinfo, int data_type, void *data)
  * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
  */
 extern int
-slurm_step_ctx_destroy (slurm_step_ctx ctx)
+slurm_step_ctx_destroy (slurm_step_ctx_t *ctx)
 {
 	if ((ctx == NULL) || (ctx->magic != STEP_CTX_MAGIC)) {
 		slurm_seterrno(EINVAL);
@@ -278,7 +383,7 @@ slurm_step_ctx_destroy (slurm_step_ctx ctx)
  * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
  */
 extern int
-slurm_step_ctx_daemon_per_node_hack(slurm_step_ctx ctx)
+slurm_step_ctx_daemon_per_node_hack(slurm_step_ctx_t *ctx)
 {
 	slurm_step_layout_t *new_layout, *old_layout;
 	int i;
@@ -347,3 +452,4 @@ extern void slurm_step_ctx_params_t_init (slurm_step_ctx_params_t *ptr)
 		ptr->job_id = (uint32_t)NO_VAL;
 	}
 }
+
diff --git a/src/api/step_ctx.h b/src/api/step_ctx.h
index 023e5113a93ed91ddaa5daabd718d50af13f490b..7b1ae2a5cec4764b060bca41647fc3cf54dc3443 100644
--- a/src/api/step_ctx.h
+++ b/src/api/step_ctx.h
@@ -7,7 +7,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>,
  *  Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -47,12 +47,14 @@ struct slurm_step_ctx_struct {
 
 	uint32_t job_id;	/* assigned job id */
 	uint32_t user_id;	/* user the job runs as */
-	
+
 	job_step_create_request_msg_t *step_req;
 	job_step_create_response_msg_t *step_resp;
 
 	/* Used by slurm_step_launch() */
 	struct step_launch_state *launch_state;
+	uint16_t verbose_level; /* for extra logging decisions in step
+				   launch api */
 };
 
 #endif /* _STEP_CTX_H */
diff --git a/src/api/step_io.c b/src/api/step_io.c
index 2b2bca71dae75cfe9b76971b14023c853dc0747a..37e673bd93ee09dfe891c30568220a53cccf8407 100644
--- a/src/api/step_io.c
+++ b/src/api/step_io.c
@@ -1,11 +1,11 @@
 /****************************************************************************\
  *  step_io.c - process stdin, stdout, and stderr for parallel jobs.
- *  $Id: step_io.c 10799 2007-01-18 19:20:00Z morrone $
+ *  $Id: step_io.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/step_io.h b/src/api/step_io.h
index 74b0a4014728eca6834d426f24655d5ce1292c4d..477eb9a6485a895a8ab43d62424ceed733b6015b 100644
--- a/src/api/step_io.h
+++ b/src/api/step_io.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/api/step_io.h - job-step client-side I/O routines
- * $Id: step_io.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: step_io.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/step_launch.c b/src/api/step_launch.c
index c018fabe68142e591008f74589e3ffe62c7f4ecb..2656d598f4bc29fe5f0035972c46f6cd3162ff1a 100644
--- a/src/api/step_launch.c
+++ b/src/api/step_launch.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  step_launch.c - launch a parallel job step
  *
- *  $Id: step_launch.c 13373 2008-02-27 16:47:13Z jette $
+ *  $Id: step_launch.c 14142 2008-05-28 20:07:50Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -31,6 +31,7 @@
 #endif
 
 #include <errno.h>
+#include <fcntl.h>
 #include <pthread.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -40,6 +41,7 @@
 #include <netinet/in.h>
 #include <sys/param.h>
 #include <sys/socket.h>
+#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/un.h>
 #include <netdb.h> /* for gethostbyname */
@@ -69,18 +71,25 @@ extern char **environ;
 /**********************************************************************
  * General declarations for step launch code
  **********************************************************************/
-static int _launch_tasks(slurm_step_ctx ctx,
-			 launch_tasks_request_msg_t *launch_msg);
+static int _launch_tasks(slurm_step_ctx_t *ctx,
+			 launch_tasks_request_msg_t *launch_msg,
+			 uint32_t timeout);
 static char *_lookup_cwd(void);
+static void _print_launch_msg(launch_tasks_request_msg_t *msg,
+			      char *hostname, int nodeid);
 
 /**********************************************************************
  * Message handler declarations
  **********************************************************************/
+static pid_t  srun_ppid = (pid_t) 0;
 static uid_t  slurm_uid;
-static int _msg_thr_create(struct step_launch_state *sls, int num_nodes);
+static bool   force_terminated_job = false;
+static int    task_exit_signal = 0;
+static void _exec_prog(slurm_msg_t *msg);
+static int  _msg_thr_create(struct step_launch_state *sls, int num_nodes);
 static void _handle_msg(struct step_launch_state *sls, slurm_msg_t *msg);
 static bool _message_socket_readable(eio_obj_t *obj);
-static int _message_socket_accept(eio_obj_t *obj, List objs);
+static int  _message_socket_accept(eio_obj_t *obj, List objs);
 
 static struct io_operations message_socket_ops = {
 	readable:	&_message_socket_readable,
@@ -109,15 +118,17 @@ void slurm_step_launch_params_t_init (slurm_step_launch_params_t *ptr)
 	ptr->buffered_stdio = true;
 	memcpy(&ptr->local_fds, &fds, sizeof(fds));
 	ptr->gid = getgid();
+	ptr->acctg_freq = (uint16_t) NO_VAL;
 }
 
 /*
  * slurm_step_launch - launch a parallel job step
  * IN ctx - job step context generated by slurm_step_ctx_create
+ * IN launcher_host - address used for PMI communications
  * IN callbacks - Identify functions to be called when various events occur
  * RET SLURM_SUCCESS or SLURM_ERROR (with errno set)
  */
-int slurm_step_launch (slurm_step_ctx ctx,
+int slurm_step_launch (slurm_step_ctx_t *ctx, char *launcher_host,
 		       const slurm_step_launch_params_t *params,
 		       const slurm_step_launch_callbacks_t *callbacks)
 {
@@ -131,8 +142,7 @@ int slurm_step_launch (slurm_step_ctx ctx,
 	memset(&launch, 0, sizeof(launch));
 
 	if (ctx == NULL || ctx->magic != STEP_CTX_MAGIC) {
-		error("Not a valid slurm_step_ctx!");
-
+		error("Not a valid slurm_step_ctx_t!");
 		slurm_seterrno(EINVAL);
 		return SLURM_ERROR;
 	}
@@ -166,7 +176,8 @@ int slurm_step_launch (slurm_step_ctx ctx,
 	}
 
 	/* Create message receiving sockets and handler thread */
-	_msg_thr_create(ctx->launch_state, ctx->step_req->node_count);
+	_msg_thr_create(ctx->launch_state,
+			ctx->step_resp->step_layout->node_cnt);
 
 	/* Start tasks on compute nodes */
 	launch.job_id = ctx->step_req->job_id;
@@ -183,18 +194,8 @@ int slurm_step_launch (slurm_step_ctx ctx,
 	} else {
 		env_array_merge(&env, (const char **)params->env);
 	}
-	{
-		/* FIXME - hostname and IP need to be user settable */
-		char *launcher_hostname = xshort_hostname();
-		struct hostent *ent = gethostbyname(launcher_hostname);
-
-		env_array_for_step(&env,
-				   ctx->step_resp,
-				   launcher_hostname,
-				   ctx->launch_state->resp_port[0],
-				   ent->h_addr_list[0]);
-		xfree(launcher_hostname);
-	}
+	env_array_for_step(&env, ctx->step_resp, launcher_host,
+			   ctx->launch_state->resp_port[0]);
 	env_array_merge(&env, (const char **)mpi_env);
 	env_array_free(mpi_env);
 
@@ -205,24 +206,31 @@ int slurm_step_launch (slurm_step_ctx ctx,
 	} else {
 		launch.cwd = _lookup_cwd();
 	}
-	launch.nnodes = ctx->step_req->node_count;
-	launch.nprocs = ctx->step_req->num_tasks;
-	launch.slurmd_debug = params->slurmd_debug;
-	launch.switch_job = ctx->step_resp->switch_job;
-	launch.task_prolog = params->task_prolog;
-	launch.task_epilog = params->task_epilog;
-	launch.cpu_bind_type = params->cpu_bind_type;
-	launch.cpu_bind = params->cpu_bind;
-	launch.mem_bind_type = params->mem_bind_type;
-	launch.mem_bind = params->mem_bind;
-	launch.multi_prog = params->multi_prog ? 1 : 0;
+	launch.nnodes		= ctx->step_resp->step_layout->node_cnt;
+	launch.nprocs		= ctx->step_resp->step_layout->task_cnt;
+	launch.slurmd_debug	= params->slurmd_debug;
+	launch.switch_job	= ctx->step_resp->switch_job;
+	launch.task_prolog	= params->task_prolog;
+	launch.task_epilog	= params->task_epilog;
+	launch.cpu_bind_type	= params->cpu_bind_type;
+	launch.cpu_bind		= params->cpu_bind;
+	launch.mem_bind_type	= params->mem_bind_type;
+	launch.mem_bind		= params->mem_bind;
+	launch.multi_prog	= params->multi_prog ? 1 : 0;
+	launch.max_sockets	= params->max_sockets;
+	launch.max_cores	= params->max_cores;
+	launch.max_threads	= params->max_threads;
 	launch.cpus_per_task	= params->cpus_per_task;
 	launch.ntasks_per_node	= params->ntasks_per_node;
 	launch.ntasks_per_socket= params->ntasks_per_socket;
 	launch.ntasks_per_core	= params->ntasks_per_core;
 	launch.task_dist	= params->task_dist;
 	launch.plane_size	= params->plane_size;
-	launch.options = job_options_create();
+	launch.pty              = params->pty;
+	launch.ckpt_path        = params->ckpt_path;
+	launch.acctg_freq	= params->acctg_freq;
+	launch.open_mode        = params->open_mode;
+	launch.options          = job_options_create();
 	launch.complete_nodelist = 
 		xstrdup(ctx->step_resp->step_layout->node_list);
 	spank_set_remote_options (launch.options);
@@ -236,6 +244,7 @@ int slurm_step_launch (slurm_step_ctx ctx,
 	
 	launch.user_managed_io = params->user_managed_io ? 1 : 0;
 	ctx->launch_state->user_managed_io = params->user_managed_io;
+	
 	if (!ctx->launch_state->user_managed_io) {
 		launch.ofname = params->remote_output_filename;
 		launch.efname = params->remote_error_filename;
@@ -277,7 +286,7 @@ int slurm_step_launch (slurm_step_ctx ctx,
 		launch.resp_port[i] = ctx->launch_state->resp_port[i];
 	}
 
-	_launch_tasks(ctx, &launch);
+	rc = _launch_tasks(ctx, &launch, params->msg_timeout);
 
 	/* clean up */
 	xfree(launch.resp_port);
@@ -298,7 +307,7 @@ done:
 /*
  * Block until all tasks have started.
  */
-int slurm_step_launch_wait_start(slurm_step_ctx ctx)
+int slurm_step_launch_wait_start(slurm_step_ctx_t *ctx)
 {
 	struct step_launch_state *sls = ctx->launch_state;
 	/* Wait for all tasks to start */
@@ -341,7 +350,7 @@ int slurm_step_launch_wait_start(slurm_step_ctx ctx)
 /*
  * Block until all tasks have finished (or failed to start altogether).
  */
-void slurm_step_launch_wait_finish(slurm_step_ctx ctx)
+void slurm_step_launch_wait_finish(slurm_step_ctx_t *ctx)
 {
 	struct step_launch_state *sls = ctx->launch_state;
 	struct timespec ts = {0, 0};
@@ -400,10 +409,15 @@ void slurm_step_launch_wait_finish(slurm_step_ctx ctx)
 			}
 		}
 	}
-	
+
+	if (!force_terminated_job && task_exit_signal)
+		info("Force Terminated job step");
+
 	/* Then shutdown the message handler thread */
 	eio_signal_shutdown(sls->msg_handle);
+	pthread_mutex_unlock(&sls->lock);
 	pthread_join(sls->msg_thread, NULL);
+	pthread_mutex_lock(&sls->lock);
 	eio_handle_destroy(sls->msg_handle);
 
 	/* Then wait for the IO thread to finish */
@@ -413,7 +427,6 @@ void slurm_step_launch_wait_finish(slurm_step_ctx ctx)
 	}
 
 	mpi_hook_client_fini(sls->mpi_state);
-
 	pthread_mutex_unlock(&sls->lock);
 }
 
@@ -422,7 +435,7 @@ void slurm_step_launch_wait_finish(slurm_step_ctx ctx)
  *
  * Can be called from a signal handler.
  */
-void slurm_step_launch_abort(slurm_step_ctx ctx)
+void slurm_step_launch_abort(slurm_step_ctx_t *ctx)
 {
 	struct step_launch_state *sls = ctx->launch_state;
 
@@ -430,6 +443,100 @@ void slurm_step_launch_abort(slurm_step_ctx ctx)
 	pthread_cond_signal(&sls->cond);
 }
 
+/* 
+ * Forward a signal to all those nodes with running tasks 
+ */
+void slurm_step_launch_fwd_signal(slurm_step_ctx_t *ctx, int signo)
+{
+	int node_id, j, active, num_tasks;
+	slurm_msg_t req;
+	kill_tasks_msg_t msg;
+	hostlist_t hl;
+	char *name = NULL;
+	char buf[8192];
+	List ret_list = NULL;
+	ListIterator itr;
+	ret_data_info_t *ret_data_info = NULL;
+	int rc = SLURM_SUCCESS;
+	struct step_launch_state *sls = ctx->launch_state;
+	
+	debug2("forward signal %d to job", signo);
+	
+	/* common to all tasks */
+	msg.job_id      = ctx->job_id;
+	msg.job_step_id = ctx->step_resp->job_step_id;
+	msg.signal      = (uint32_t) signo;
+	
+	pthread_mutex_lock(&sls->lock);
+	
+	hl = hostlist_create("");
+	for (node_id = 0;
+	     node_id < ctx->step_resp->step_layout->node_cnt;
+	     node_id++) {
+		active = 0;		
+		num_tasks = sls->layout->tasks[node_id];
+		for (j = 0; j < num_tasks; j++) {
+			if(bit_test(sls->tasks_started,
+				    sls->layout->tids[node_id][j]) &&
+			   !bit_test(sls->tasks_exited,
+				     sls->layout->tids[node_id][j])) {
+				/* this one has active tasks */
+				active = 1;
+				break;
+			}
+		}
+		
+		if (!active)
+			continue;
+		
+		name = nodelist_nth_host(sls->layout->node_list, node_id);
+		hostlist_push(hl, name);
+		free(name);
+	}
+
+	pthread_mutex_unlock(&sls->lock);
+	
+	if(!hostlist_count(hl)) {
+		hostlist_destroy(hl);
+		goto nothing_left;
+	}
+	hostlist_ranged_string(hl, sizeof(buf), buf);
+	hostlist_destroy(hl);
+	name = xstrdup(buf);
+	
+	slurm_msg_t_init(&req);	
+	req.msg_type = REQUEST_SIGNAL_TASKS;
+	req.data     = &msg;
+	
+	debug3("sending signal to host %s", name);
+	
+	if (!(ret_list = slurm_send_recv_msgs(name, &req, 0))) { 
+		error("fwd_signal: slurm_send_recv_msgs really failed bad");
+		xfree(name);
+		return;
+	}
+	xfree(name);
+	itr = list_iterator_create(ret_list);		
+	while((ret_data_info = list_next(itr))) {
+		rc = slurm_get_return_code(ret_data_info->type, 
+					   ret_data_info->data);
+		/*
+		 *  Report error unless it is "Invalid job id" which 
+		 *    probably just means the tasks exited in the meanwhile.
+		 */
+		if ((rc != 0) && (rc != ESLURM_INVALID_JOB_ID)
+		    &&  (rc != ESLURMD_JOB_NOTRUNNING) && (rc != ESRCH)) {
+			error("%s: signal: %s", 
+			      ret_data_info->node_name, 
+			      slurm_strerror(rc));
+		}
+	}
+	list_iterator_destroy(itr);
+	list_destroy(ret_list);
+nothing_left:
+	debug2("All tasks have been signalled");
+	
+}
 
 /**********************************************************************
  * Functions used by step_ctx code, but not exported throught the API
@@ -437,27 +544,30 @@ void slurm_step_launch_abort(slurm_step_ctx ctx)
 /*
  * Create a launch state structure for a specified step context, "ctx".
  */
-struct step_launch_state *step_launch_state_create(slurm_step_ctx ctx)
+struct step_launch_state *step_launch_state_create(slurm_step_ctx_t *ctx)
 {
 	struct step_launch_state *sls;
+	slurm_step_layout_t *layout = ctx->step_resp->step_layout;
 
 	sls = xmalloc(sizeof(struct step_launch_state));
-	if (sls != NULL) {
-		sls->slurmctld_socket_fd = -1;
-		sls->tasks_requested = ctx->step_req->num_tasks;
-		sls->tasks_started = bit_alloc(ctx->step_req->num_tasks);
-		sls->tasks_exited = bit_alloc(ctx->step_req->num_tasks);
-		sls->layout = ctx->step_resp->step_layout;
-		sls->resp_port = NULL;
-		sls->abort = false;
-		sls->abort_action_taken = false;
-		sls->mpi_info->jobid = ctx->step_req->job_id;
-		sls->mpi_info->stepid = ctx->step_resp->job_step_id;
-		sls->mpi_info->step_layout = ctx->step_resp->step_layout;
-		sls->mpi_state = NULL;
-		pthread_mutex_init(&sls->lock, NULL);
-		pthread_cond_init(&sls->cond, NULL);
-	}
+	sls->slurmctld_socket_fd = -1;
+	/* Hack for LAM-MPI's lamboot, launch one task per node */
+	if (mpi_hook_client_single_task_per_node())
+		sls->tasks_requested = layout->node_cnt;
+	else
+		sls->tasks_requested = layout->task_cnt;
+	sls->tasks_started = bit_alloc(layout->task_cnt);
+	sls->tasks_exited = bit_alloc(layout->task_cnt);
+	sls->layout = layout;
+	sls->resp_port = NULL;
+	sls->abort = false;
+	sls->abort_action_taken = false;
+	sls->mpi_info->jobid = ctx->step_req->job_id;
+	sls->mpi_info->stepid = ctx->step_resp->job_step_id;
+	sls->mpi_info->step_layout = layout;
+	sls->mpi_state = NULL;
+	pthread_mutex_init(&sls->lock, NULL);
+	pthread_cond_init(&sls->cond, NULL);
 	return sls;
 }
 
@@ -478,7 +588,6 @@ void step_launch_state_destroy(struct step_launch_state *sls)
 	}
 }
 
-
 /**********************************************************************
  * Message handler functions
  **********************************************************************/
@@ -504,7 +613,8 @@ static int _msg_thr_create(struct step_launch_state *sls, int num_nodes)
 	int sock = -1;
 	short port = -1;
 	eio_obj_t *obj;
-	int i;
+	int i, rc = SLURM_SUCCESS;
+	pthread_attr_t attr;
 
 	debug("Entering _msg_thr_create()");
 	slurm_uid = (uid_t) slurm_get_slurm_user_id();
@@ -529,12 +639,15 @@ static int _msg_thr_create(struct step_launch_state *sls, int num_nodes)
 		eio_new_initial_obj(sls->msg_handle, obj);
 	}
 
-	if (pthread_create(&sls->msg_thread, NULL,
+	slurm_attr_init(&attr);
+	if (pthread_create(&sls->msg_thread, &attr,
 			   _msg_thr_internal, (void *)sls) != 0) {
 		error("pthread_create of message thread: %m");
-		return SLURM_ERROR;
+		
+		rc = SLURM_ERROR;
 	}
-	return SLURM_SUCCESS;
+	slurm_attr_destroy(&attr);
+	return rc;
 }
 
 static bool _message_socket_readable(eio_obj_t *obj)
@@ -590,7 +703,7 @@ static int _message_socket_accept(eio_obj_t *obj, List objs)
 	   in /etc/hosts. */
 	uc = (unsigned char *)&((struct sockaddr_in *)&addr)->sin_addr.s_addr;
 	port = ((struct sockaddr_in *)&addr)->sin_port;
-	debug2("got message connection from %u.%u.%u.%u:%hu",
+	debug2("step got message connection from %u.%u.%u.%u:%hu",
 	       uc[0], uc[1], uc[2], uc[3], ntohs(port));
 	fflush(stdout);
 
@@ -646,6 +759,14 @@ _exit_handler(struct step_launch_state *sls, slurm_msg_t *exit_msg)
 	task_exit_msg_t *msg = (task_exit_msg_t *) exit_msg->data;
 	int i;
 
+	/* Record SIGTERM and SIGKILL termination codes to 
+	 * recognize abnormal termination */
+	if (WIFSIGNALED(msg->return_code)) {
+		i = WTERMSIG(msg->return_code);
+		if ((i == SIGKILL) || (i == SIGTERM))
+			task_exit_signal = i;
+	}
+
 	pthread_mutex_lock(&sls->lock);
 
 	for (i = 0; i < msg->num_tasks; i++) {
@@ -660,6 +781,36 @@ _exit_handler(struct step_launch_state *sls, slurm_msg_t *exit_msg)
 	pthread_mutex_unlock(&sls->lock);
 }
 
+static void 
+_job_complete_handler(struct step_launch_state *sls, slurm_msg_t *complete_msg)
+{
+	srun_job_complete_msg_t *step_msg = 
+		(srun_job_complete_msg_t *) complete_msg->data;
+	
+	if (step_msg->step_id == NO_VAL) {
+		verbose("Complete job %u received",
+			step_msg->job_id);
+	} else {
+		verbose("Complete job step %u.%u received",
+			step_msg->job_id, step_msg->step_id);
+	}
+
+	/* FIXME: does nothing yet */
+
+	pthread_mutex_lock(&sls->lock);
+	pthread_cond_signal(&sls->cond);
+	pthread_mutex_unlock(&sls->lock);
+}
+
+static void 
+_timeout_handler(struct step_launch_state *sls, slurm_msg_t *timeout_msg)
+{
+	/* FIXME: does nothing yet */
+	pthread_mutex_lock(&sls->lock);
+	pthread_cond_signal(&sls->cond);
+	pthread_mutex_unlock(&sls->lock);
+}
+
 /*
  * Take the list of node names of down nodes and convert into an
  * array of nodeids for the step.  The nodeid array is passed to
@@ -766,8 +917,9 @@ _task_user_managed_io_handler(struct step_launch_state *sls,
 static void
 _handle_msg(struct step_launch_state *sls, slurm_msg_t *msg)
 {
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	uid_t uid = getuid();
+	srun_user_msg_t *um;
 	int rc;
 	
 	if ((req_uid != slurm_uid) && (req_uid != 0) && (req_uid != uid)) {
@@ -787,21 +939,36 @@ _handle_msg(struct step_launch_state *sls, slurm_msg_t *msg)
 		_exit_handler(sls, msg);
 		slurm_free_task_exit_msg(msg->data);
 		break;
-	case SRUN_NODE_FAIL:
-		debug2("received srun node fail");
-		_node_fail_handler(sls, msg);
-		slurm_free_srun_node_fail_msg(msg->data);
+	case SRUN_PING:
+		debug3("slurmctld ping received");
+		slurm_send_rc_msg(msg, SLURM_SUCCESS);
+		slurm_free_srun_ping_msg(msg->data);
 		break;
-	case SRUN_TIMEOUT:
-		debug2("received job step timeout message");
-		/* FIXME - does nothing yet */
-		slurm_free_srun_timeout_msg(msg->data);
+	case SRUN_EXEC:
+		_exec_prog(msg);
+		slurm_free_srun_exec_msg(msg->data);
 		break;
 	case SRUN_JOB_COMPLETE:
 		debug2("received job step complete message");
-		/* FIXME - does nothing yet */
+		force_terminated_job = true;
+		_job_complete_handler(sls, msg);
 		slurm_free_srun_job_complete_msg(msg->data);
 		break;
+	case SRUN_TIMEOUT:
+		debug2("received job step timeout message");
+		_timeout_handler(sls, msg);
+		slurm_free_srun_timeout_msg(msg->data);
+		break;
+	case SRUN_USER_MSG:
+		um = msg->data;
+		info("%s", um->msg);
+		slurm_free_srun_user_msg(msg->data);
+		break;
+	case SRUN_NODE_FAIL:
+		debug2("received srun node fail");
+		_node_fail_handler(sls, msg);
+		slurm_free_srun_node_fail_msg(msg->data);
+		break;
 	case PMI_KVS_PUT_REQ:
 		debug2("PMI_KVS_PUT_REQ received");
 		rc = pmi_kvs_put((struct kvs_comm_set *) msg->data);
@@ -828,8 +995,9 @@ _handle_msg(struct step_launch_state *sls, slurm_msg_t *msg)
 /**********************************************************************
  * Task launch functions
  **********************************************************************/
-static int _launch_tasks(slurm_step_ctx ctx,
-			 launch_tasks_request_msg_t *launch_msg)
+static int _launch_tasks(slurm_step_ctx_t *ctx,
+			 launch_tasks_request_msg_t *launch_msg,
+			 uint32_t timeout)
 {
 	slurm_msg_t msg;
 	List ret_list = NULL;
@@ -838,13 +1006,24 @@ static int _launch_tasks(slurm_step_ctx ctx,
 	int rc = SLURM_SUCCESS;
 
 	debug("Entering _launch_tasks");
+	if (ctx->verbose_level) {
+		char *name = NULL;
+		hostlist_t hl = hostlist_create(launch_msg->complete_nodelist);
+		int i = 0;
+		while((name = hostlist_shift(hl))) {
+			_print_launch_msg(launch_msg, name, i++);
+			free(name);			
+		}
+		hostlist_destroy(hl);
+	}
+
 	slurm_msg_t_init(&msg);
 	msg.msg_type = REQUEST_LAUNCH_TASKS;
 	msg.data = launch_msg;
 	
 	if(!(ret_list = slurm_send_recv_msgs(
 		     ctx->step_resp->step_layout->node_list,
-		     &msg, 0))) {
+		     &msg, timeout))) {
 		error("slurm_send_recv_msgs failed miserably: %m");
 		return SLURM_ERROR;
 	}
@@ -855,9 +1034,13 @@ static int _launch_tasks(slurm_step_ctx ctx,
 		debug("launch returned msg_rc=%d err=%d type=%d",
 		      rc, ret_data->err, ret_data->type);
 		if (rc != SLURM_SUCCESS) {
-			errno = ret_data->err;
+			if (ret_data->err)
+				errno = ret_data->err;
+			else
+				errno = rc;
 			error("Task launch failed on node %s: %m",
 			      ret_data->node_name);
+			rc = SLURM_ERROR;
 		} else {
 #if 0 /* only for debugging, might want to make this a callback */
 			errno = ret_data->err;
@@ -868,7 +1051,7 @@ static int _launch_tasks(slurm_step_ctx ctx,
 	}
 	list_iterator_destroy(ret_itr);
 	list_destroy(ret_list);
-	return SLURM_SUCCESS;
+	return rc;
 }
 
 /* returns an xmalloc cwd string, or NULL if lookup failed. */
@@ -882,3 +1065,123 @@ static char *_lookup_cwd(void)
 		return NULL;
 	}
 }
+
+static void _print_launch_msg(launch_tasks_request_msg_t *msg,
+			      char *hostname, int nodeid)
+{
+	int i;
+	char tmp_str[10], task_list[4096];
+	hostlist_t hl = hostlist_create("");
+
+	for (i=0; i<msg->tasks_to_launch[nodeid]; i++) {
+		sprintf(tmp_str, "%u", msg->global_task_ids[nodeid][i]);
+		hostlist_push(hl, tmp_str);
+	}
+	hostlist_ranged_string(hl, 4096, task_list);
+	hostlist_destroy(hl);
+	
+	info("launching %u.%u on host %s, %u tasks: %s", 
+	     msg->job_id, msg->job_step_id, hostname, 
+	     msg->tasks_to_launch[nodeid], task_list);
+
+	debug3("uid:%ld gid:%ld cwd:%s %d", (long) msg->uid,
+		(long) msg->gid, msg->cwd, nodeid);
+}
+
+void record_ppid(void)
+{
+	srun_ppid = getppid();
+}
+
+/* This is used to initiate an OpenMPI checkpoint program, 
+ * but is written to be general purpose */
+static void
+_exec_prog(slurm_msg_t *msg)
+{
+	pid_t child;
+	int pfd[2], status, exit_code = 0, i;
+	ssize_t len;
+	char *argv[4], buf[256] = "";
+	time_t now = time(NULL);
+	bool checkpoint = false;
+	srun_exec_msg_t *exec_msg = msg->data;
+
+	if (exec_msg->argc > 2) {
+		verbose("Exec '%s %s' for %u.%u", 
+			exec_msg->argv[0], exec_msg->argv[1],
+			exec_msg->job_id, exec_msg->step_id);
+	} else {
+		verbose("Exec '%s' for %u.%u", 
+			exec_msg->argv[0], 
+			exec_msg->job_id, exec_msg->step_id);
+	}
+
+	if (strcmp(exec_msg->argv[0], "ompi-checkpoint") == 0) {
+		if (srun_ppid)
+			checkpoint = true;
+		else {
+			error("Can not create checkpoint, no srun_ppid set");
+			exit_code = EINVAL;
+			goto fini;
+		}
+	}
+	if (checkpoint) {
+		/* OpenMPI specific checkpoint support */
+		info("Checkpoint started at %s", ctime(&now));
+		for (i=0; (exec_msg->argv[i] && (i<2)); i++) {
+			argv[i] = exec_msg->argv[i];
+		}
+		snprintf(buf, sizeof(buf), "%ld", (long) srun_ppid);
+		argv[i] = buf;
+		argv[i+1] = NULL;
+	}
+
+	if (pipe(pfd) == -1) {
+		snprintf(buf, sizeof(buf), "pipe: %s", strerror(errno));
+		error("%s", buf);
+		exit_code = errno;
+		goto fini;
+	}
+
+	child = fork();
+	if (child == 0) {
+		int fd = open("/dev/null", O_RDONLY);
+		dup2(fd, 0);		/* stdin from /dev/null */
+		dup2(pfd[1], 1);	/* stdout to pipe */
+		dup2(pfd[1], 2);	/* stderr to pipe */
+		close(pfd[0]);
+		close(pfd[1]);
+		if (checkpoint)
+			execvp(exec_msg->argv[0], argv);
+		else
+			execvp(exec_msg->argv[0], exec_msg->argv);
+		error("execvp(%s): %m", exec_msg->argv[0]);
+	} else if (child < 0) {
+		snprintf(buf, sizeof(buf), "fork: %s", strerror(errno));
+		error("%s", buf);
+		exit_code = errno;
+		goto fini;
+	} else {
+		close(pfd[1]);
+		len = read(pfd[0], buf, sizeof(buf));
+		close(pfd[0]);
+		waitpid(child, &status, 0);
+		exit_code = WEXITSTATUS(status);
+	}
+
+fini:	if (checkpoint) {
+		now = time(NULL);
+		if (exit_code) {
+			info("Checkpoint completion code %d at %s", 
+				exit_code, ctime(&now));
+		} else {
+			info("Checkpoint completed successfully at %s",
+				ctime(&now));
+		}
+		if (buf[0])
+			info("Checkpoint location: %s", buf);
+		slurm_checkpoint_complete(exec_msg->job_id, exec_msg->step_id,
+			time(NULL), (uint32_t) exit_code, buf);
+	}
+}
+
diff --git a/src/api/step_launch.h b/src/api/step_launch.h
index eed284cd23c20ea3296fec23b9a7050a1fb85e91..529193eb6173bad86e1f5ce203e425cba96bcbd4 100644
--- a/src/api/step_launch.h
+++ b/src/api/step_launch.h
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  step_launch.h - launch a parallel job step
  *
- *  $Id: step_launch.h 10920 2007-02-02 03:01:14Z morrone $
+ *  $Id: step_launch.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -87,11 +87,16 @@ struct step_launch_state {
 /*
  * Create a launch state structure for a specified step context, "ctx".
  */
-struct step_launch_state * step_launch_state_create(slurm_step_ctx ctx);
+struct step_launch_state * step_launch_state_create(slurm_step_ctx_t *ctx);
 
 /*
  * Free the memory associated with the a launch state structure.
  */
 void step_launch_state_destroy(struct step_launch_state *sls);
 
+/*
+ * Record the parent process ID of the program which spawned this.
+ * Needed to locate the mpirun program for OpenMPI checkpoint
+ */
+void record_ppid(void);
 #endif /* _STEP_LAUNCH_H */
diff --git a/src/api/submit.c b/src/api/submit.c
index 0a90e26cb4c47ce97dc433f43c15fbefa54f4c92..c66b349611c1a2f0dcf4a7d09ad8c61d822789ae 100644
--- a/src/api/submit.c
+++ b/src/api/submit.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  submit.c - submit a job with supplied contraints
- *  $Id: submit.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: submit.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/suspend.c b/src/api/suspend.c
index 7be3d5423e7f066186eb58ecb4649feb215e28f8..d447a8d97d56c2155a54a2948697adb7eb1794de 100644
--- a/src/api/suspend.c
+++ b/src/api/suspend.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  suspend.c - job step suspend and resume functions.
- *  $Id: suspend.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: suspend.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/triggers.c b/src/api/triggers.c
index 1dc88e03c35f1cb19eb8fd56b4153de261a30881..67981abd3b9a23f2e3afb244b5a250fa18ea6a45 100644
--- a/src/api/triggers.c
+++ b/src/api/triggers.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/api/update_config.c b/src/api/update_config.c
index 6ad715fd41a3580feb41279251f5a0ff354492d3..b317331d66194d85463f8c4854a0064fb6a2e36e 100644
--- a/src/api/update_config.c
+++ b/src/api/update_config.c
@@ -1,11 +1,11 @@
 /****************************************************************************\
  *  update_config.c - request that slurmctld update its configuration
- *  $Id: update_config.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: update_config.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> and Kevin Tew <tew1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 0dfe31e6bfe615666fda3a97ce40650cb0a45bc0..8d61a722ee3b1107e91812ab20e5731f9e97e302 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -1,4 +1,12 @@
 # Makefile for common library 
+# If you are linking to this lib any know you are not linking to 
+# anything else that will need variables here link to 
+# $(top_builddir)/src/common/libcommon.la
+# if you are linking to a stand alone program that needs all symbols link to
+# $(top_builddir)/src/common/libcommon.o with -ldl added 
+# This avoids having multiple symbols running around when there should 
+# only be 1 address per symbol.  If you link to the libcommon.la in
+# a plugin you will get 2 addresses for one symbol which could lead to problems.
 
 AUTOMAKE_OPTIONS = foreign
 
@@ -10,7 +18,9 @@ build_unsetenv_src = unsetenv.c unsetenv.h
 extra_unsetenv_src = 
 endif
 
-INCLUDES     = -I$(top_srcdir) $(SSL_CPPFLAGS)
+INCLUDES     = -I$(top_srcdir)
+
+noinst_PROGRAMS = libcommon.o
 
 noinst_LTLIBRARIES = 			\
 	libcommon.la 			\
@@ -19,6 +29,7 @@ noinst_LTLIBRARIES = 			\
 	libspank.la
 
 libcommon_la_SOURCES = 			\
+	assoc_mgr.c assoc_mgr.h 	\
 	xmalloc.c xmalloc.h 		\
 	xassert.c xassert.h		\
 	xstring.c xstring.h		\
@@ -58,10 +69,13 @@ libcommon_la_SOURCES = 			\
 	slurm_protocol_defs.h		\
 	slurm_rlimits_info.h		\
 	slurm_rlimits_info.c		\
+	slurmdbd_defs.c slurmdbd_defs.h	\
 	uid.c uid.h			\
 	util-net.c util-net.h		\
 	slurm_auth.c slurm_auth.h	\
-	slurm_jobacct.c slurm_jobacct.h \
+	jobacct_common.c jobacct_common.h \
+	slurm_accounting_storage.c slurm_accounting_storage.h \
+	slurm_jobacct_gather.c slurm_jobacct_gather.h \
 	slurm_jobcomp.c slurm_jobcomp.h	\
 	switch.c switch.h		\
 	arg_desc.c arg_desc.h		\
@@ -80,7 +94,8 @@ libcommon_la_SOURCES = 			\
 	global_defaults.c		\
 	timers.c timers.h		\
 	slurm_xlator.h			\
-	stepd_api.c stepd_api.h		
+	stepd_api.c stepd_api.h		\
+	proc_args.c proc_args.h		
 
 EXTRA_libcommon_la_SOURCES = 	\
 	$(extra_unsetenv_src)
@@ -98,9 +113,18 @@ libspank_la_SOURCES = \
 	plugstack.c plugstack.h \
 	optz.c      optz.h
 
-libcommon_la_LIBADD   = $(SSL_LIBS) -ldl
+libcommon_la_LIBADD   = -ldl 
+
+libcommon_la_LDFLAGS  = $(LIB_LDFLAGS) -module --export-dynamic
+
+libcommon_o_SOURCES = 
+
+
+# This was made so we chould export all symbols from libcommon 
+# on multiple platforms
+libcommon.o :  $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) 
+	$(libcommon_la_LINK)  $(libcommon_la_OBJECTS) 
 
-libcommon_la_LDFLAGS  = $(LIB_LDFLAGS) $(SSL_LDFLAGS)
 
 global_defaults.c : $(top_builddir)/config.h Makefile
 	@( echo "/* This file autogenerated by src/common/Makefile */"; \
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 39c4e23ad89ccd69adeb65be4ca3dd9cdf030869..ae339dd578e880ba3ab2f652890c5d9ec0cbb745 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,6 +15,15 @@
 @SET_MAKE@
 
 # Makefile for common library 
+# If you are linking to this lib any know you are not linking to 
+# anything else that will need variables here link to 
+# $(top_builddir)/src/common/libcommon.la
+# if you are linking to a stand alone program that needs all symbols link to
+# $(top_builddir)/src/common/libcommon.o with -ldl added 
+# This avoids having multiple symbols running around when there should 
+# only be 1 address per symbol.  If you link to the libcommon.la in
+# a plugin you will get 2 addresses for one symbol which could lead to problems.
+
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -35,6 +44,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
+noinst_PROGRAMS = libcommon.o$(EXEEXT)
 subdir = src/common
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -44,6 +54,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -65,48 +77,52 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
 CONFIG_CLEAN_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
-am__DEPENDENCIES_1 =
-libcommon_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am__libcommon_la_SOURCES_DIST = xmalloc.c xmalloc.h xassert.c \
-	xassert.h xstring.c xstring.h xsignal.c xsignal.h forward.c \
-	forward.h strlcpy.c strlcpy.h list.c list.h net.c net.h fd.c \
-	fd.h log.c log.h cbuf.c cbuf.h safeopen.c safeopen.h \
-	bitstring.c bitstring.h mpi.c mpi.h pack.c pack.h \
-	parse_config.c parse_config.h parse_spec.c parse_spec.h \
-	plugin.c plugin.h plugrack.c plugrack.h read_config.c \
-	read_config.h node_select.c node_select.h env.c env.h \
-	slurm_cred.h slurm_cred.c slurm_errno.c slurm_protocol_api.c \
-	slurm_protocol_api.h slurm_protocol_pack.c \
-	slurm_protocol_pack.h slurm_protocol_util.c \
-	slurm_protocol_util.h slurm_protocol_socket_implementation.c \
+libcommon_la_DEPENDENCIES =
+am__libcommon_la_SOURCES_DIST = assoc_mgr.c assoc_mgr.h xmalloc.c \
+	xmalloc.h xassert.c xassert.h xstring.c xstring.h xsignal.c \
+	xsignal.h forward.c forward.h strlcpy.c strlcpy.h list.c \
+	list.h net.c net.h fd.c fd.h log.c log.h cbuf.c cbuf.h \
+	safeopen.c safeopen.h bitstring.c bitstring.h mpi.c mpi.h \
+	pack.c pack.h parse_config.c parse_config.h parse_spec.c \
+	parse_spec.h plugin.c plugin.h plugrack.c plugrack.h \
+	read_config.c read_config.h node_select.c node_select.h env.c \
+	env.h slurm_cred.h slurm_cred.c slurm_errno.c \
+	slurm_protocol_api.c slurm_protocol_api.h \
+	slurm_protocol_pack.c slurm_protocol_pack.h \
+	slurm_protocol_util.c slurm_protocol_util.h \
+	slurm_protocol_socket_implementation.c \
 	slurm_protocol_socket_common.h slurm_protocol_common.h \
 	slurm_protocol_interface.h slurm_protocol_defs.c \
 	slurm_protocol_defs.h slurm_rlimits_info.h \
-	slurm_rlimits_info.c uid.c uid.h util-net.c util-net.h \
-	slurm_auth.c slurm_auth.h slurm_jobacct.c slurm_jobacct.h \
-	slurm_jobcomp.c slurm_jobcomp.h switch.c switch.h arg_desc.c \
-	arg_desc.h macros.h malloc.c malloc.h getopt.h getopt.c \
-	getopt1.c unsetenv.c unsetenv.h slurm_selecttype_info.c \
-	slurm_resource_info.c slurm_resource_info.h hostlist.c \
-	hostlist.h slurm_step_layout.c slurm_step_layout.h \
-	checkpoint.c checkpoint.h parse_time.c parse_time.h \
-	job_options.c job_options.h global_defaults.c timers.c \
-	timers.h slurm_xlator.h stepd_api.c stepd_api.h
+	slurm_rlimits_info.c slurmdbd_defs.c slurmdbd_defs.h uid.c \
+	uid.h util-net.c util-net.h slurm_auth.c slurm_auth.h \
+	jobacct_common.c jobacct_common.h slurm_accounting_storage.c \
+	slurm_accounting_storage.h slurm_jobacct_gather.c \
+	slurm_jobacct_gather.h slurm_jobcomp.c slurm_jobcomp.h \
+	switch.c switch.h arg_desc.c arg_desc.h macros.h malloc.c \
+	malloc.h getopt.h getopt.c getopt1.c unsetenv.c unsetenv.h \
+	slurm_selecttype_info.c slurm_resource_info.c \
+	slurm_resource_info.h hostlist.c hostlist.h \
+	slurm_step_layout.c slurm_step_layout.h checkpoint.c \
+	checkpoint.h parse_time.c parse_time.h job_options.c \
+	job_options.h global_defaults.c timers.c timers.h \
+	slurm_xlator.h stepd_api.c stepd_api.h proc_args.c proc_args.h
 @HAVE_UNSETENV_FALSE@am__objects_1 = unsetenv.lo
-am_libcommon_la_OBJECTS = xmalloc.lo xassert.lo xstring.lo xsignal.lo \
-	forward.lo strlcpy.lo list.lo net.lo fd.lo log.lo cbuf.lo \
-	safeopen.lo bitstring.lo mpi.lo pack.lo parse_config.lo \
-	parse_spec.lo plugin.lo plugrack.lo read_config.lo \
-	node_select.lo env.lo slurm_cred.lo slurm_errno.lo \
-	slurm_protocol_api.lo slurm_protocol_pack.lo \
+am_libcommon_la_OBJECTS = assoc_mgr.lo xmalloc.lo xassert.lo \
+	xstring.lo xsignal.lo forward.lo strlcpy.lo list.lo net.lo \
+	fd.lo log.lo cbuf.lo safeopen.lo bitstring.lo mpi.lo pack.lo \
+	parse_config.lo parse_spec.lo plugin.lo plugrack.lo \
+	read_config.lo node_select.lo env.lo slurm_cred.lo \
+	slurm_errno.lo slurm_protocol_api.lo slurm_protocol_pack.lo \
 	slurm_protocol_util.lo slurm_protocol_socket_implementation.lo \
-	slurm_protocol_defs.lo slurm_rlimits_info.lo uid.lo \
-	util-net.lo slurm_auth.lo slurm_jobacct.lo slurm_jobcomp.lo \
-	switch.lo arg_desc.lo malloc.lo getopt.lo getopt1.lo \
-	$(am__objects_1) slurm_selecttype_info.lo \
+	slurm_protocol_defs.lo slurm_rlimits_info.lo slurmdbd_defs.lo \
+	uid.lo util-net.lo slurm_auth.lo jobacct_common.lo \
+	slurm_accounting_storage.lo slurm_jobacct_gather.lo \
+	slurm_jobcomp.lo switch.lo arg_desc.lo malloc.lo getopt.lo \
+	getopt1.lo $(am__objects_1) slurm_selecttype_info.lo \
 	slurm_resource_info.lo hostlist.lo slurm_step_layout.lo \
 	checkpoint.lo parse_time.lo job_options.lo global_defaults.lo \
-	timers.lo stepd_api.lo
+	timers.lo stepd_api.lo proc_args.lo
 am__EXTRA_libcommon_la_SOURCES_DIST = unsetenv.c unsetenv.h
 libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
 libcommon_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -121,7 +137,11 @@ libeio_la_OBJECTS = $(am_libeio_la_OBJECTS)
 libspank_la_LIBADD =
 am_libspank_la_OBJECTS = plugstack.lo optz.lo
 libspank_la_OBJECTS = $(am_libspank_la_OBJECTS)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+PROGRAMS = $(noinst_PROGRAMS)
+am_libcommon_o_OBJECTS =
+libcommon_o_OBJECTS = $(am_libcommon_o_OBJECTS)
+libcommon_o_LDADD = $(LDADD)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -135,11 +155,11 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	$(LDFLAGS) -o $@
 SOURCES = $(libcommon_la_SOURCES) $(EXTRA_libcommon_la_SOURCES) \
 	$(libdaemonize_la_SOURCES) $(libeio_la_SOURCES) \
-	$(libspank_la_SOURCES)
+	$(libspank_la_SOURCES) $(libcommon_o_SOURCES)
 DIST_SOURCES = $(am__libcommon_la_SOURCES_DIST) \
 	$(am__EXTRA_libcommon_la_SOURCES_DIST) \
 	$(libdaemonize_la_SOURCES) $(libeio_la_SOURCES) \
-	$(libspank_la_SOURCES)
+	$(libspank_la_SOURCES) $(libcommon_o_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -166,6 +186,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -179,10 +200,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -202,7 +226,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -213,6 +240,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -228,6 +257,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -243,6 +273,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -304,7 +335,7 @@ AUTOMAKE_OPTIONS = foreign
 @HAVE_UNSETENV_TRUE@build_unsetenv_src = 
 @HAVE_UNSETENV_FALSE@extra_unsetenv_src = 
 @HAVE_UNSETENV_TRUE@extra_unsetenv_src = unsetenv.c unsetenv.h
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS)
+INCLUDES = -I$(top_srcdir)
 noinst_LTLIBRARIES = \
 	libcommon.la 			\
 	libdaemonize.la 		\
@@ -312,6 +343,7 @@ noinst_LTLIBRARIES = \
 	libspank.la
 
 libcommon_la_SOURCES = \
+	assoc_mgr.c assoc_mgr.h 	\
 	xmalloc.c xmalloc.h 		\
 	xassert.c xassert.h		\
 	xstring.c xstring.h		\
@@ -351,10 +383,13 @@ libcommon_la_SOURCES = \
 	slurm_protocol_defs.h		\
 	slurm_rlimits_info.h		\
 	slurm_rlimits_info.c		\
+	slurmdbd_defs.c slurmdbd_defs.h	\
 	uid.c uid.h			\
 	util-net.c util-net.h		\
 	slurm_auth.c slurm_auth.h	\
-	slurm_jobacct.c slurm_jobacct.h \
+	jobacct_common.c jobacct_common.h \
+	slurm_accounting_storage.c slurm_accounting_storage.h \
+	slurm_jobacct_gather.c slurm_jobacct_gather.h \
 	slurm_jobcomp.c slurm_jobcomp.h	\
 	switch.c switch.h		\
 	arg_desc.c arg_desc.h		\
@@ -373,7 +408,8 @@ libcommon_la_SOURCES = \
 	global_defaults.c		\
 	timers.c timers.h		\
 	slurm_xlator.h			\
-	stepd_api.c stepd_api.h		
+	stepd_api.c stepd_api.h		\
+	proc_args.c proc_args.h		
 
 EXTRA_libcommon_la_SOURCES = \
 	$(extra_unsetenv_src)
@@ -391,8 +427,9 @@ libspank_la_SOURCES = \
 	plugstack.c plugstack.h \
 	optz.c      optz.h
 
-libcommon_la_LIBADD = $(SSL_LIBS) -ldl
-libcommon_la_LDFLAGS = $(LIB_LDFLAGS) $(SSL_LDFLAGS)
+libcommon_la_LIBADD = -ldl 
+libcommon_la_LDFLAGS = $(LIB_LDFLAGS) -module --export-dynamic
+libcommon_o_SOURCES = 
 all: all-am
 
 .SUFFIXES:
@@ -444,6 +481,13 @@ libeio.la: $(libeio_la_OBJECTS) $(libeio_la_DEPENDENCIES)
 libspank.la: $(libspank_la_OBJECTS) $(libspank_la_DEPENDENCIES) 
 	$(LINK)  $(libspank_la_OBJECTS) $(libspank_la_LIBADD) $(LIBS)
 
+clean-noinstPROGRAMS:
+	@list='$(noinst_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
 
@@ -451,6 +495,7 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arg_desc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assoc_mgr.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitstring.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cbuf.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpoint.Plo@am__quote@
@@ -465,6 +510,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hostlist.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io_hdr.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/job_options.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_common.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloc.Plo@am__quote@
@@ -479,12 +525,14 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugrack.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugstack.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc_args.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_config.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safeopen.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_accounting_storage.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_auth.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_cred.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_errno.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_jobacct.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_jobacct_gather.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_jobcomp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_protocol_api.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_protocol_defs.Plo@am__quote@
@@ -495,6 +543,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_rlimits_info.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_selecttype_info.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_step_layout.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurmdbd_defs.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stepd_api.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/switch.Plo@am__quote@
@@ -539,8 +588,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -552,8 +601,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -563,13 +612,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
@@ -610,7 +658,7 @@ distdir: $(DISTFILES)
 	done
 check-am: all-am
 check: check-am
-all-am: Makefile $(LTLIBRARIES)
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
 installdirs:
 install: install-am
 install-exec: install-exec-am
@@ -639,7 +687,7 @@ maintainer-clean-generic:
 clean: clean-am
 
 clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
-	mostlyclean-am
+	clean-noinstPROGRAMS mostlyclean-am
 
 distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
@@ -698,18 +746,24 @@ uninstall-am:
 .MAKE: install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
-	distclean-compile distclean-generic distclean-libtool \
-	distclean-tags distdir dvi dvi-am html html-am info info-am \
-	install install-am install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am
-
+	clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \
+	ctags distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+# This was made so we chould export all symbols from libcommon 
+# on multiple platforms
+libcommon.o :  $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) 
+	$(libcommon_la_LINK)  $(libcommon_la_OBJECTS) 
 
 global_defaults.c : $(top_builddir)/config.h Makefile
 	@( echo "/* This file autogenerated by src/common/Makefile */"; \
diff --git a/src/common/arg_desc.c b/src/common/arg_desc.c
index 20bbb9f5a4ab2bc0bbd9104ce483c1e1543d7eae..72b82dfebd8a917e9f0ef62da3c554dedb83051d 100644
--- a/src/common/arg_desc.c
+++ b/src/common/arg_desc.c
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/arg_desc.h b/src/common/arg_desc.h
index 9a0ce185719ddf2ab9557e292163fecea07413b1..f365582efb6e8fd21b75634c6b000182febb81b7 100644
--- a/src/common/arg_desc.h
+++ b/src/common/arg_desc.h
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/assoc_mgr.c b/src/common/assoc_mgr.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a35ca4322188de0af46159f32675d3cda38c890
--- /dev/null
+++ b/src/common/assoc_mgr.c
@@ -0,0 +1,675 @@
+/*****************************************************************************\
+ *  accounting_storage_slurmdbd.c - accounting interface to slurmdbd.
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "assoc_mgr.h"
+
+#include <sys/types.h>
+#include <pwd.h>
+
+#include "src/common/xstring.h"
+#include "src/slurmdbd/read_config.h"
+
+static List local_association_list = NULL;
+static List local_user_list = NULL;
+static char *local_cluster_name = NULL;
+
+static pthread_mutex_t local_association_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t local_user_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static int _get_local_association_list(void *db_conn, int enforce)
+{
+	acct_association_cond_t assoc_q;
+	char *cluster_name = NULL;
+//	DEF_TIMERS;
+	slurm_mutex_lock(&local_association_lock);
+	if(local_association_list)
+		list_destroy(local_association_list);
+
+	memset(&assoc_q, 0, sizeof(acct_association_cond_t));
+	if(local_cluster_name) {
+		assoc_q.cluster_list = list_create(slurm_destroy_char);
+		cluster_name = xstrdup(local_cluster_name);
+		if(!cluster_name) {
+			if(enforce && !slurmdbd_conf) {
+				error("_get_local_association_list: "
+				      "no cluster name here going to get "
+				      "all associations.");
+			}
+		} else 
+			list_append(assoc_q.cluster_list, cluster_name);
+	}
+
+//	START_TIMER;
+	local_association_list =
+		acct_storage_g_get_associations(db_conn, &assoc_q);
+//	END_TIMER2("get_associations");
+
+	if(assoc_q.cluster_list)
+		list_destroy(assoc_q.cluster_list);
+	
+	if(!local_association_list) {
+		/* create list so we don't keep calling this if there
+		   isn't anything there */
+		local_association_list = list_create(NULL);
+		slurm_mutex_unlock(&local_association_lock);
+		if(enforce) {
+			error("_get_local_association_list: "
+			      "no list was made.");
+			return SLURM_ERROR;
+		} else {
+			debug3("not enforcing associations and no "
+			       "list was given so we are giving a blank list");
+			return SLURM_SUCCESS;
+		}
+	} else {
+		acct_association_rec_t *assoc = NULL;
+		acct_association_rec_t *assoc2 = NULL;
+		struct passwd *passwd_ptr = NULL;
+		ListIterator itr = list_iterator_create(local_association_list);
+		ListIterator itr2 = 
+			list_iterator_create(local_association_list);
+		//START_TIMER;
+		while((assoc = list_next(itr))) {
+			if(assoc->parent_id) {
+				while((assoc2 = list_next(itr2))) {
+					if(assoc2->id == assoc->parent_id) {
+						assoc->parent_acct_ptr = assoc2;
+						break;
+					}
+				}
+				list_iterator_reset(itr2);
+			}
+			if(!assoc->user) {
+				continue;
+			}
+			passwd_ptr = getpwnam(assoc->user);
+			if(passwd_ptr) 
+				assoc->uid = passwd_ptr->pw_uid;
+			//log_assoc_rec(assoc);
+		}
+		list_iterator_destroy(itr2);
+		list_iterator_destroy(itr);
+		//END_TIMER2("load_associations");
+	}
+	slurm_mutex_unlock(&local_association_lock);
+
+	return SLURM_SUCCESS;
+}
+
+static int _get_local_user_list(void *db_conn, int enforce)
+{
+	acct_user_cond_t user_q;
+
+	memset(&user_q, 0, sizeof(acct_user_cond_t));
+
+	slurm_mutex_lock(&local_user_lock);
+	if(local_user_list)
+		list_destroy(local_user_list);
+	local_user_list = acct_storage_g_get_users(db_conn, &user_q);
+
+	if(!local_user_list) {
+		slurm_mutex_unlock(&local_user_lock);
+		if(enforce) {
+			error("_get_local_user_list: "
+			      "no list was made.");
+			return SLURM_ERROR;
+		} else {
+			return SLURM_SUCCESS;
+		}		
+	} 
+
+	slurm_mutex_unlock(&local_user_lock);
+	return SLURM_SUCCESS;
+}
+
+extern int assoc_mgr_init(void *db_conn, int enforce)
+{
+	if(!local_cluster_name && !slurmdbd_conf)
+		local_cluster_name = slurm_get_cluster_name();
+
+	if(!local_association_list) 
+		if(_get_local_association_list(db_conn, enforce) == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	if(!local_user_list) 
+		if(_get_local_user_list(db_conn, enforce) == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+extern int assoc_mgr_fini()
+{
+	if(local_association_list) 
+		list_destroy(local_association_list);
+	if(local_user_list)
+		list_destroy(local_user_list);
+	xfree(local_cluster_name);
+	local_association_list = NULL;
+	local_user_list = NULL;
+
+	return SLURM_SUCCESS;
+}
+
+extern int assoc_mgr_fill_in_assoc(void *db_conn, acct_association_rec_t *assoc,
+				   int enforce, 
+				   acct_association_rec_t **assoc_pptr)
+{
+	ListIterator itr = NULL;
+	acct_association_rec_t * found_assoc = NULL;
+	acct_association_rec_t * ret_assoc = NULL;
+
+	if (assoc_pptr)
+		*assoc_pptr = NULL;
+	if(!local_association_list) {
+		if(_get_local_association_list(db_conn, enforce) == SLURM_ERROR)
+			return SLURM_ERROR;
+	}
+	if((!local_association_list || !list_count(local_association_list))
+	   && !enforce) 
+		return SLURM_SUCCESS;
+
+	if(!assoc->id) {
+		if(!assoc->acct) {
+			acct_user_rec_t user;
+
+			if(!assoc->uid) {
+				if(enforce) {
+					error("get_assoc_id: "
+					      "Not enough info to "
+					      "get an association");
+					return SLURM_ERROR;
+				} else {
+					return SLURM_SUCCESS;
+				}
+			}
+			memset(&user, 0, sizeof(acct_user_rec_t));
+			user.uid = assoc->uid;
+			if(assoc_mgr_fill_in_user(db_conn, &user, enforce) 
+			   == SLURM_ERROR) {
+				if(enforce) 
+					return SLURM_ERROR;
+				else {
+					return SLURM_SUCCESS;
+				}
+			}					
+			assoc->user = user.name;
+			assoc->acct = user.default_acct;
+		} 
+		
+		if(!assoc->cluster)
+			assoc->cluster = local_cluster_name;
+	}
+/* 	info("looking for assoc of user=%s(%u), acct=%s, " */
+/* 	     "cluster=%s, partition=%s", */
+/* 	     assoc->user, assoc->uid, assoc->acct,  */
+/* 	     assoc->cluster, assoc->partition); */
+	slurm_mutex_lock(&local_association_lock);
+	itr = list_iterator_create(local_association_list);
+	while((found_assoc = list_next(itr))) {
+		if(assoc->id) {
+			if(assoc->id == found_assoc->id) {
+				ret_assoc = found_assoc;
+				break;
+			}
+			continue;
+		} else {
+			if(!assoc->uid && found_assoc->uid) {
+				debug3("we are looking for a "
+				       "nonuser association");
+				continue;
+			} else if(assoc->uid != found_assoc->uid) {
+				debug3("not the right user %u != %u",
+				       assoc->uid, found_assoc->uid);
+				continue;
+			}
+			
+			if(found_assoc->acct 
+			   && strcasecmp(assoc->acct, found_assoc->acct)) {
+				   debug3("not the right account");
+				   continue;
+			}
+
+			/* only check for on the slurmdbd */
+			if(!local_cluster_name && found_assoc->cluster
+			   && strcasecmp(assoc->cluster,
+					 found_assoc->cluster)) {
+				debug3("not the right cluster");
+				continue;
+			}
+	
+			if(assoc->partition
+			   && (!found_assoc->partition 
+			       || strcasecmp(assoc->partition, 
+					     found_assoc->partition))) {
+				ret_assoc = found_assoc;
+				debug3("found association for no partition");
+				continue;
+			}
+		}
+		ret_assoc = found_assoc;
+		break;
+	}
+	list_iterator_destroy(itr);
+	
+	if(!ret_assoc) {
+		slurm_mutex_unlock(&local_association_lock);
+		if(enforce) 
+			return SLURM_ERROR;
+		else
+			return SLURM_SUCCESS;
+	}
+	debug3("found correct association");
+	if (assoc_pptr)
+		*assoc_pptr = ret_assoc;
+	assoc->id = ret_assoc->id;
+	if(!assoc->user)
+		assoc->user = ret_assoc->user;
+	if(!assoc->acct)
+		assoc->acct = ret_assoc->acct;
+	if(!assoc->cluster)
+		assoc->cluster = ret_assoc->cluster;
+	if(!assoc->partition)
+		assoc->partition = ret_assoc->partition;
+	assoc->fairshare                 = ret_assoc->fairshare;
+	assoc->max_cpu_secs_per_job      = ret_assoc->max_cpu_secs_per_job;
+	assoc->max_jobs                  = ret_assoc->max_jobs;
+	assoc->max_nodes_per_job         = ret_assoc->max_nodes_per_job;
+	assoc->max_wall_duration_per_job = ret_assoc->max_wall_duration_per_job;
+	assoc->parent_acct_ptr           = ret_assoc->parent_acct_ptr;
+	if(assoc->parent_acct) {
+		xfree(assoc->parent_acct);
+		assoc->parent_acct       = xstrdup(ret_assoc->parent_acct);
+	} else 
+		assoc->parent_acct       = ret_assoc->parent_acct;
+	slurm_mutex_unlock(&local_association_lock);
+
+	return SLURM_SUCCESS;
+}
+
+extern int assoc_mgr_fill_in_user(void *db_conn, acct_user_rec_t *user,
+				  int enforce)
+{
+	ListIterator itr = NULL;
+	acct_user_rec_t * found_user = NULL;
+
+	if(!local_user_list) 
+		if(_get_local_user_list(db_conn, enforce) == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	if((!local_user_list || !list_count(local_user_list)) && !enforce) 
+		return SLURM_SUCCESS;
+
+	slurm_mutex_lock(&local_user_lock);
+	itr = list_iterator_create(local_user_list);
+	while((found_user = list_next(itr))) {
+		if(user->uid == found_user->uid) 
+			break;
+	}
+	list_iterator_destroy(itr);
+
+	if(found_user) {
+		memcpy(user, found_user, sizeof(acct_user_rec_t));		
+		slurm_mutex_unlock(&local_user_lock);
+		return SLURM_SUCCESS;
+	}
+	slurm_mutex_unlock(&local_user_lock);
+	return SLURM_ERROR;
+}
+
+extern acct_admin_level_t assoc_mgr_get_admin_level(void *db_conn,
+						    uint32_t uid)
+{
+	ListIterator itr = NULL;
+	acct_user_rec_t * found_user = NULL;
+
+	if(!local_user_list) 
+		if(_get_local_user_list(db_conn, 0) == SLURM_ERROR)
+			return ACCT_ADMIN_NOTSET;
+
+	if(!local_user_list) 
+		return ACCT_ADMIN_NOTSET;
+
+	slurm_mutex_lock(&local_user_lock);
+	itr = list_iterator_create(local_user_list);
+	while((found_user = list_next(itr))) {
+		if(uid == found_user->uid) 
+			break;
+	}
+	list_iterator_destroy(itr);
+	slurm_mutex_unlock(&local_user_lock);
+		
+	if(found_user) 
+		return found_user->admin_level;
+		
+	return ACCT_ADMIN_NOTSET;	
+}
+
+extern int assoc_mgr_is_user_acct_coord(void *db_conn,
+					uint32_t uid,
+					char *acct_name)
+{
+	ListIterator itr = NULL;
+	acct_coord_rec_t *acct = NULL;
+	acct_user_rec_t * found_user = NULL;
+
+	if(!local_user_list) 
+		if(_get_local_user_list(db_conn, 0) == SLURM_ERROR)
+			return ACCT_ADMIN_NOTSET;
+
+	if(!local_user_list) 
+		return ACCT_ADMIN_NOTSET;
+
+	slurm_mutex_lock(&local_user_lock);
+	itr = list_iterator_create(local_user_list);
+	while((found_user = list_next(itr))) {
+		if(uid == found_user->uid) 
+			break;
+	}
+	list_iterator_destroy(itr);
+		
+	if(!found_user) {
+		slurm_mutex_unlock(&local_user_lock);
+		return 0;
+	}
+	itr = list_iterator_create(found_user->coord_accts);
+	while((acct = list_next(itr))) {
+		if(!strcmp(acct_name, acct->acct_name))
+			break;
+	}
+	list_iterator_destroy(itr);
+	
+	if(acct) {
+		slurm_mutex_unlock(&local_user_lock);
+		return 1;
+	}
+	slurm_mutex_unlock(&local_user_lock);
+
+	return 0;	
+}
+
+extern int assoc_mgr_update_local_assocs(acct_update_object_t *update)
+{
+	acct_association_rec_t * rec = NULL;
+	acct_association_rec_t * object = NULL;
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	int parents_changed = 0;
+
+	if(!local_association_list)
+		return SLURM_SUCCESS;
+
+	slurm_mutex_lock(&local_association_lock);
+	itr = list_iterator_create(local_association_list);
+	while((object = list_pop(update->objects))) {
+		if(object->cluster && local_cluster_name) {
+			/* only update the local clusters assocs */
+			if(strcasecmp(object->cluster, local_cluster_name))
+				continue;
+		}
+		list_iterator_reset(itr);
+		while((rec = list_next(itr))) {
+			if(object->id) {
+				if(object->id == rec->id) {
+					break;
+				}
+				continue;
+			} else {
+				if(!object->user && rec->user) {
+					debug3("we are looking for a "
+					       "nonuser association");
+					continue;
+				} else if(object->uid != rec->uid) {
+					debug3("not the right user");
+					continue;
+				}
+				
+				if(object->acct
+				   && (!rec->acct 
+				       || strcasecmp(object->acct,
+						     rec->acct))) {
+					debug3("not the right account");
+					continue;
+				}
+				
+				/* only check for on the slurmdbd */
+				if(!local_cluster_name && object->acct
+				   && (!rec->cluster
+				       || strcasecmp(object->cluster,
+						     rec->cluster))) {
+					debug3("not the right cluster");
+					continue;
+				}
+				
+				if(object->partition
+				   && (!rec->partition 
+				       || strcasecmp(object->partition, 
+						     rec->partition))) {
+					debug3("not the right partition");
+					continue;
+				}
+				break;
+			}			
+		}
+		//info("%d assoc %u", update->type, object->id);
+		switch(update->type) {
+		case ACCT_MODIFY_ASSOC:
+			if(!rec) {
+				rc = SLURM_ERROR;
+				break;
+			}
+			debug("updating assoc %u", rec->id);
+			if(object->fairshare != (uint32_t)NO_VAL) {
+				rec->fairshare = object->fairshare;
+			}
+
+			if(object->max_jobs != (uint32_t)NO_VAL) {
+				rec->max_jobs = object->max_jobs;
+			}
+
+			if(object->max_nodes_per_job != (uint32_t)NO_VAL) {
+				rec->max_nodes_per_job =
+					object->max_nodes_per_job;
+			}
+
+			if(object->max_wall_duration_per_job !=
+			   (uint32_t)NO_VAL) {
+				rec->max_wall_duration_per_job =
+					object->max_wall_duration_per_job;
+			}
+
+			if(object->max_cpu_secs_per_job != (uint32_t)NO_VAL) {
+				rec->max_cpu_secs_per_job = 
+					object->max_cpu_secs_per_job;
+			}
+
+			if(object->parent_acct) {
+				xfree(rec->parent_acct);
+				rec->parent_acct = xstrdup(object->parent_acct);
+			}
+			if(object->parent_id) {
+				rec->parent_id = object->parent_id;
+				// after all new parents have been set we will
+				// reset the parent pointers below
+				parents_changed = 1;
+				
+			}
+			log_assoc_rec(rec);
+			/* FIX ME: do more updates here */
+			break;
+		case ACCT_ADD_ASSOC:
+			if(rec) {
+				//rc = SLURM_ERROR;
+				break;
+			}
+			list_append(local_association_list, object);
+		case ACCT_REMOVE_ASSOC:
+			if(!rec) {
+				//rc = SLURM_ERROR;
+				break;
+			}
+			list_delete_item(itr);
+			break;
+		default:
+			break;
+		}
+		if(update->type != ACCT_ADD_ASSOC) {
+			destroy_acct_association_rec(object);			
+		}				
+	}
+
+	if(parents_changed) {
+		ListIterator itr2 = 
+			list_iterator_create(local_association_list);
+		list_iterator_reset(itr);
+
+		while((object = list_next(itr))) {
+			if(object->parent_id) {
+				while((rec = list_next(itr2))) {
+					if(rec->id == object->parent_id) {
+						object->parent_acct_ptr = rec;
+						break;
+					}
+				}
+				list_iterator_reset(itr2);
+			}
+		}
+		list_iterator_destroy(itr2);
+	}
+
+	list_iterator_destroy(itr);
+	slurm_mutex_unlock(&local_association_lock);
+
+	return rc;	
+}
+
+extern int assoc_mgr_update_local_users(acct_update_object_t *update)
+{
+	acct_user_rec_t * rec = NULL;
+	acct_user_rec_t * object = NULL;
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+
+	if(!local_user_list)
+		return SLURM_SUCCESS;
+
+	slurm_mutex_lock(&local_user_lock);
+	itr = list_iterator_create(local_user_list);
+	while((object = list_pop(update->objects))) {
+		list_iterator_reset(itr);
+		while((rec = list_next(itr))) {
+			if(!strcasecmp(object->name, rec->name)) {
+				break;
+			}
+		}
+		//info("%d user %s", update->type, object->name);
+		switch(update->type) {
+		case ACCT_MODIFY_USER:
+			if(!rec) {
+				rc = SLURM_ERROR;
+				break;
+			}
+
+			if(object->default_acct) {
+				xfree(rec->default_acct);
+				rec->default_acct = object->default_acct;
+				object->default_acct = NULL;
+			}
+
+			if(object->qos != ACCT_QOS_NOTSET)
+				rec->qos = object->qos;
+			
+			if(object->admin_level != ACCT_ADMIN_NOTSET)
+				rec->admin_level = rec->admin_level;
+
+			break;
+		case ACCT_ADD_USER:
+			if(rec) {
+				//rc = SLURM_ERROR;
+				break;
+			}
+			list_append(local_user_list, object);
+		case ACCT_REMOVE_USER:
+			if(!rec) {
+				//rc = SLURM_ERROR;
+				break;
+			}
+			list_delete_item(itr);
+			break;
+		default:
+			break;
+		}
+		if(update->type != ACCT_ADD_USER) {
+			destroy_acct_user_rec(object);			
+		}
+	}
+	list_iterator_destroy(itr);
+	slurm_mutex_unlock(&local_user_lock);
+
+	return rc;	
+}
+
+extern int assoc_mgr_validate_assoc_id(void *db_conn,
+				       uint32_t assoc_id,
+				       int enforce)
+{
+	ListIterator itr = NULL;
+	acct_association_rec_t * found_assoc = NULL;
+
+	if(!local_association_list) 
+		if(_get_local_association_list(db_conn, enforce) == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	if((!local_association_list || !list_count(local_association_list))
+	   && !enforce) 
+		return SLURM_SUCCESS;
+	
+	slurm_mutex_lock(&local_association_lock);
+	itr = list_iterator_create(local_association_list);
+	while((found_assoc = list_next(itr))) {
+		if(assoc_id == found_assoc->id) 
+			break;
+	}
+	list_iterator_destroy(itr);
+	slurm_mutex_unlock(&local_association_lock);
+
+	if(found_assoc || !enforce)
+		return SLURM_SUCCESS;
+
+	return SLURM_ERROR;
+}
+
diff --git a/src/common/assoc_mgr.h b/src/common/assoc_mgr.h
new file mode 100644
index 0000000000000000000000000000000000000000..d0d1826c53e498cf67d716528449cb8d921fcf9e
--- /dev/null
+++ b/src/common/assoc_mgr.h
@@ -0,0 +1,123 @@
+/*****************************************************************************\
+ *  assoc_mgr.h - keep track of local cache of accounting data.
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _SLURM_ASSOC_MGR_H 
+#define _SLURM_ASSOC_MGR_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "src/common/list.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/slurmctld/slurmctld.h"
+#include <slurm/slurm.h>
+#include <slurm/slurm_errno.h>
+
+/* 
+ * get info from the storage 
+ * IN/OUT:  user - acct_user_rec_t with the name set of the user.
+ *                 "default_account" will be filled in on
+ *                 successful return DO NOT FREE.
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int assoc_mgr_fill_in_user(void *db_conn, acct_user_rec_t *user,
+				  int enforce);
+
+/* 
+ * get info from the storage 
+ * IN/OUT:  assoc - acct_association_rec_t with at least cluster and
+ *		    account set for account association.  To get user
+ *		    association set user, and optional partition.
+ *		    Sets "id" field with the association ID.
+ * IN: enforce - return an error if no such association exists
+ * IN/OUT: assoc_pptr - if non-NULL then return a pointer to the 
+ *			acct_association record in cache on success
+ * RET: SLURM_SUCCESS on success, else SLURM_ERROR
+ */
+extern int assoc_mgr_fill_in_assoc(void *db_conn,
+				   acct_association_rec_t *assoc,
+				   int enforce,
+				   acct_association_rec_t **assoc_pptr);
+
+/* 
+ * get admin_level of uid 
+ * IN: uid - uid of user to check admin_level of.
+ * RET: admin level ACCT_ADMIN_NOTSET on error 
+ */
+extern acct_admin_level_t assoc_mgr_get_admin_level(void *db_conn, 
+						    uint32_t uid);
+
+/* 
+ * see if user is coordinator of given acct 
+ * IN: uid - uid of user to check.
+ * IN: acct - name of account
+ * RET: 0 for no, 1 for yes
+ */
+extern int assoc_mgr_is_user_acct_coord(void *db_conn, uint32_t uid,
+					char *acct);
+
+extern int assoc_mgr_init(void *db_conn, int enforce);
+extern int assoc_mgr_fini();
+
+/* 
+ * update associations in local cache 
+ * IN:  acct_update_object_t *object
+ * RET: SLURM_SUCCESS on success (or not found) SLURM_ERROR else
+ */
+extern int assoc_mgr_update_local_assocs(acct_update_object_t *update);
+
+/* 
+ * update users in local cache 
+ * IN:  acct_update_object_t *object
+ * RET: SLURM_SUCCESS on success (or not found) SLURM_ERROR else
+ */
+extern int assoc_mgr_update_local_users(acct_update_object_t *update);
+
+/* 
+ * validate that an association ID is still valid 
+ * IN:  assoc_id - association ID previously returned by 
+ *		get_assoc_id(void *db_conn, 
+ )
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int assoc_mgr_validate_assoc_id(void *db_conn, 
+				       uint32_t assoc_id,
+				       int enforce);
+
+#endif /* _SLURM_ASSOC_MGR_H */
diff --git a/src/common/bitstring.c b/src/common/bitstring.c
index 69d7029c763a8e97dd1626c1600037acf328dceb..a1ecb9473eb745a9c3727ecb87cca5a9eac57700 100644
--- a/src/common/bitstring.c
+++ b/src/common/bitstring.c
@@ -7,7 +7,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick@llnl.gov>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/bitstring.h b/src/common/bitstring.h
index 01ca9b4c0f8769cecc22068fbce8a3e3ba70f2db..e937b5725c846a74561c344c7847019d81bb3afb 100644
--- a/src/common/bitstring.h
+++ b/src/common/bitstring.h
@@ -8,7 +8,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick@llnl.gov>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/checkpoint.c b/src/common/checkpoint.c
index 83a8fec6c9880265e74a4883ccc67d1e740f5e59..54e7874b06ad9a3b23bbf0dcf696f5282cfe4773 100644
--- a/src/common/checkpoint.c
+++ b/src/common/checkpoint.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  checkpoint.c - implementation-independent checkpoint functions
- *  $Id: checkpoint.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: checkpoint.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,6 +62,8 @@ typedef struct slurm_checkpoint_ops {
 			 uint32_t *error_code, char **error_msg);
 	int	(*ckpt_comp) (struct step_record * step_ptr, time_t event_time,
 			 uint32_t error_code, char *error_msg);
+	int	(*ckpt_task_comp) (struct step_record * step_ptr, uint32_t task_id,
+			 time_t event_time, uint32_t error_code, char *error_msg);
 
 	int	(*ckpt_alloc_jobinfo) (check_jobinfo_t *jobinfo);
 	int	(*ckpt_free_jobinfo) (check_jobinfo_t jobinfo);
@@ -146,6 +148,7 @@ _slurm_checkpoint_get_ops( slurm_checkpoint_context_t c )
 	static const char *syms[] = {
 		"slurm_ckpt_op",
 		"slurm_ckpt_comp",
+		"slurm_ckpt_task_comp",
 		"slurm_ckpt_alloc_job",
 		"slurm_ckpt_free_job",
 		"slurm_ckpt_pack_job",
@@ -277,6 +280,25 @@ checkpoint_comp(void * step_ptr, time_t event_time, uint32_t error_code,
 	return retval;
 }
 
+extern int
+checkpoint_task_comp(void * step_ptr, uint32_t task_id, time_t event_time,
+		     uint32_t error_code, char *error_msg)
+{
+	int retval = SLURM_SUCCESS;
+
+	slurm_mutex_lock( &context_lock );
+	if ( g_context )
+		retval = (*(g_context->ops.ckpt_task_comp))(
+			(struct step_record *) step_ptr, task_id, 
+			event_time, error_code, error_msg);
+	else {
+		error ("slurm_checkpoint plugin context not initialized");
+		retval = ENOENT;
+	}
+	slurm_mutex_unlock( &context_lock );
+	return retval;
+}
+
 /* allocate and initialize a job step's checkpoint context */
 extern int checkpoint_alloc_jobinfo(check_jobinfo_t *jobinfo)
 {
diff --git a/src/common/checkpoint.h b/src/common/checkpoint.h
index e4ce11356c2ace81aaec645d1df78f683e38a84c..0a5c8b92c22cb202f02e14266734bf5ec968d40d 100644
--- a/src/common/checkpoint.h
+++ b/src/common/checkpoint.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  checkpoint.h - implementation-independent checkpoint API definitions. 
- *  $Id: checkpoint.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: checkpoint.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -78,6 +78,9 @@ extern int checkpoint_op(uint16_t op, uint16_t data, void * step_ptr,
 extern int checkpoint_comp(void * step_ptr, time_t event_time, uint32_t error_code,
 		char *error_msg);
 
+extern int checkpoint_task_comp(void * step_ptr, uint32_t task_id, 
+			time_t event_time, uint32_t error_code, char *error_msg);
+
 /* gather checkpoint error info */
 extern int checkpoint_error(void * step_ptr, 
 		uint16_t *ckpt_errno, char **ckpt_strerror);
diff --git a/src/common/daemonize.c b/src/common/daemonize.c
index 528aaaa145511b81ca7da01a1706fc53368dd99d..c396d84311101af9ecd512ca251e7c8e917f68b8 100644
--- a/src/common/daemonize.c
+++ b/src/common/daemonize.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  daemonize.c - daemonization routine
- *  $Id: daemonize.c 12723 2007-11-29 18:55:48Z jette $
+ *  $Id: daemonize.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark A. Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/daemonize.h b/src/common/daemonize.h
index e976d42e31ed7a10c8e090c8a2f0e7485b49d446..93c57a1c0ebc75b512942bec415a8728c75723df 100644
--- a/src/common/daemonize.h
+++ b/src/common/daemonize.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/daemonize.h - function definition for making a daemon
- * $Id: daemonize.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: daemonize.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/eio.c b/src/common/eio.c
index 2053fae9e11b9bd8c8d0d5b037b0d8b04f56e0c7..3f7ce2ca85289c919f5f9272861db60fdc2c2522 100644
--- a/src/common/eio.c
+++ b/src/common/eio.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/eio.h b/src/common/eio.h
index eabd120fae5718788ea10ab2321142dbaff48282..1351ad56093b7c542dfedb36adaa3f4c20aea0a5 100644
--- a/src/common/eio.h
+++ b/src/common/eio.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/env.c b/src/common/env.c
index e28cc028aa2656dc6fc048b38599c3293e5f473b..f7e5b5e5148d4556348aa70be47417ad97ee2a09 100644
--- a/src/common/env.c
+++ b/src/common/env.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/common/env.c - add an environment variable to environment vector
- *  $Id: env.c 13678 2008-03-20 21:02:07Z jette $
+ *  $Id: env.c 14025 2008-05-09 16:37:03Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>, Danny Auble <da@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -48,8 +48,9 @@
 #include <strings.h>
 #include <unistd.h>
 #include <sys/poll.h>
+#include <sys/stat.h>
 #include <sys/types.h>
-
+#include <sys/param.h>		/* MAXPATHLEN */
 #include "src/common/macros.h"
 #include "slurm/slurm.h"
 #include "src/common/log.h"
@@ -77,7 +78,7 @@ strong_alias(env_array_append_fmt,	slurm_env_array_append_fmt);
 strong_alias(env_array_overwrite,	slurm_env_array_overwrite);
 strong_alias(env_array_overwrite_fmt,	slurm_env_array_overwrite_fmt);
 
-#define ENV_BUFSIZE (64 * 1024)
+#define ENV_BUFSIZE (256 * 1024)
 
 /*
  *  Return pointer to `name' entry in environment if found, or
@@ -172,7 +173,7 @@ setenvfs(const char *fmt, ...)
 	int rc;
 
 	va_start(ap, fmt);
-	vsnprintf(buf, ENV_BUFSIZE, fmt, ap);
+	vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 	
 	bufcpy = xstrdup(buf);
@@ -191,7 +192,7 @@ setenvf(char ***envp, const char *name, const char *fmt, ...)
 	char *bufcpy;
 
 	va_start(ap, fmt);
-	vsnprintf (buf, ENV_BUFSIZE, fmt, ap);
+	vsnprintf (buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 	bufcpy = xstrdup(buf);
 	
@@ -649,8 +650,28 @@ int setup_env(env_t *env)
 		setenvf(&env->env, "LOADL_ACTIVE", "3.2.0");
 	}
 #endif
-	
-	return SLURM_SUCCESS;
+
+	if (env->pty_port
+	&&  setenvf(&env->env, "SLURM_PTY_PORT", "%hu", env->pty_port)) {
+		error("Can't set SLURM_PTY_PORT env variable");
+		rc = SLURM_FAILURE;
+	}
+	if (env->ws_col
+	&&  setenvf(&env->env, "SLURM_PTY_WIN_COL", "%hu", env->ws_col)) {
+		error("Can't set SLURM_PTY_WIN_COL env variable");
+		rc = SLURM_FAILURE;
+	}
+	if (env->ws_row
+	&&  setenvf(&env->env, "SLURM_PTY_WIN_ROW", "%hu", env->ws_row)) {
+		error("Can't set SLURM_PTY_WIN_ROW env variable");
+		rc = SLURM_FAILURE;
+	}
+	if (env->ckpt_path 
+        && setenvf(&env->env, "SLURM_CHECKPOINT_PATH", "%s", env->ckpt_path)) {
+		error("Can't set SLURM_CHECKPOINT_PATH env variable");
+		rc = SLURM_FAILURE;
+	}
+	return rc;
 }
 
 /**********************************************************************
@@ -878,8 +899,7 @@ void
 env_array_for_step(char ***dest, 
 		   const job_step_create_response_msg_t *step,
 		   const char *launcher_hostname,
-		   uint16_t launcher_port,
-		   const char *ip_addr_str)
+		   uint16_t launcher_port)
 {
 	char *tmp;
 
@@ -897,8 +917,6 @@ env_array_for_step(char ***dest,
 			 "%s", launcher_hostname);
 	env_array_overwrite_fmt(dest, "SLURM_STEP_LAUNCHER_PORT",
 			 "%hu", launcher_port);
-/* 	env_array_overwrite_fmt(dest, "SLURM_STEP_LAUNCHER_IPADDR", */
-/* 			 "%s", ip_addr_str); */
 
 	/* OBSOLETE */
 	env_array_overwrite_fmt(dest, "SLURM_STEPID", "%u", step->job_step_id);
@@ -911,8 +929,6 @@ env_array_for_step(char ***dest,
 			 "%s", launcher_hostname);
 	env_array_overwrite_fmt(dest, "SLURM_SRUN_COMM_PORT",
 			 "%hu", launcher_port);
-/* 	env_array_overwrite_fmt(dest, "SLURM_LAUNCH_NODE_IPADDR", */
-/* 			 "%s", ip_addr_str); */
 
 	xfree(tmp);
 }
@@ -977,7 +993,7 @@ int env_array_append_fmt(char ***array_ptr, const char *name,
 	}
 
 	va_start(ap, value_fmt);
-	vsnprintf (buf, ENV_BUFSIZE, value_fmt, ap);
+	vsnprintf (buf, sizeof(buf), value_fmt, ap);
 	va_end(ap);
 	
 	ep = _find_name_in_env(*array_ptr, name);
@@ -1053,7 +1069,7 @@ int env_array_overwrite_fmt(char ***array_ptr, const char *name,
 	}
 
 	va_start(ap, value_fmt);
-	vsnprintf (buf, ENV_BUFSIZE, value_fmt, ap);
+	vsnprintf (buf, sizeof(buf), value_fmt, ap);
 	va_end(ap);
 	
 	xstrfmtcat (str, "%s=%s", name, buf);
@@ -1172,11 +1188,11 @@ static int _env_array_entry_splitter(const char *entry,
  */
 static int _env_array_putenv(const char *string)
 {
-	char name[ENV_BUFSIZE];
+	char name[256];
 	char value[ENV_BUFSIZE];
 
-	if (!_env_array_entry_splitter(string, name, ENV_BUFSIZE, value, 
-				       ENV_BUFSIZE))
+	if (!_env_array_entry_splitter(string, name, sizeof(name),
+				       value, sizeof(value)))
 		return 0;
 	if (setenv(name, value, 1) == -1)
 		return 0;
@@ -1208,16 +1224,16 @@ void env_array_set_environment(char **env_array)
 void env_array_merge(char ***dest_array, const char **src_array)
 {
 	char **ptr;
-	char name[ENV_BUFSIZE];
+	char name[256];
 	char value[ENV_BUFSIZE];
 
 	if (src_array == NULL)
 		return;
 
 	for (ptr = (char **)src_array; *ptr != NULL; ptr++) {
-		_env_array_entry_splitter(*ptr, name, ENV_BUFSIZE, value, 
-					  ENV_BUFSIZE);
-		env_array_overwrite(dest_array, name, value);
+		if (_env_array_entry_splitter(*ptr, name, sizeof(name),
+					      value, sizeof(value)))
+			env_array_overwrite(dest_array, name, value);
 	}
 }
 
@@ -1244,8 +1260,8 @@ static void _strip_cr_nl(char *line)
  */
 char **_load_env_cache(const char *username)
 {
-	char *state_save_loc, fname[ENV_BUFSIZE];
-	char line[ENV_BUFSIZE], name[ENV_BUFSIZE], value[ENV_BUFSIZE];
+	char *state_save_loc, fname[MAXPATHLEN];
+	char line[ENV_BUFSIZE], name[256], value[ENV_BUFSIZE];
 	char **env = NULL;
 	FILE *fp;
 	int i;
@@ -1267,11 +1283,11 @@ char **_load_env_cache(const char *username)
 	info("Getting cached environment variables at %s", fname);
 	env = env_array_create();
 	while (1) {
-		if (!fgets(line, ENV_BUFSIZE, fp))
+		if (!fgets(line, sizeof(line), fp))
 			break;
 		_strip_cr_nl(line);
-		if (_env_array_entry_splitter(line, name, ENV_BUFSIZE, value, 
-					      ENV_BUFSIZE) &&
+		if (_env_array_entry_splitter(line, name, sizeof(name), 
+					      value, sizeof(value)) &&
 		    (!_discard_env(name, value)))
 			env_array_overwrite(&env, name, value);
 	}
@@ -1297,17 +1313,29 @@ char **_load_env_cache(const char *username)
  */
 char **env_array_user_default(const char *username, int timeout, int mode)
 {
-	char *line, *last, name[128], value[ENV_BUFSIZE];
+	char *line = NULL, *last = NULL, name[128], value[ENV_BUFSIZE];
 	char buffer[ENV_BUFSIZE];
 	char **env = NULL;
 	char *starttoken = "XXXXSLURMSTARTPARSINGHEREXXXX";
 	char *stoptoken  = "XXXXSLURMSTOPPARSINGHEREXXXXX";
-	char cmdstr[256];
+	char cmdstr[256], *env_loc = NULL;
 	int fildes[2], found, fval, len, rc, timeleft;
 	int buf_read, buf_rem;
 	pid_t child;
 	struct timeval begin, now;
 	struct pollfd ufds;
+	struct stat buf;
+
+	if (stat("/bin/su", &buf))
+		fatal("Could not locate command: /bin/su");
+	if (stat("/bin/echo", &buf))
+		fatal("Could not locate command: /bin/echo");
+	if (stat("/bin/env", &buf) == 0)
+		env_loc = "/bin/env";
+	else if (stat("/usr/bin/env", &buf) == 0)
+		env_loc = "/usr/bin/env";
+	else
+		fatal("Could not location command: env");
 
 	if (geteuid() != (uid_t)0) {
 		fatal("WARNING: you must be root to use --get-user-env");
@@ -1332,8 +1360,8 @@ char **env_array_user_default(const char *username, int timeout, int mode)
 		open("/dev/null", O_WRONLY);
 		snprintf(cmdstr, sizeof(cmdstr),
 			 "/bin/echo; /bin/echo; /bin/echo; "
-			 "/bin/echo %s; /bin/env; /bin/echo %s",
-			 starttoken, stoptoken);
+			 "/bin/echo %s; %s; /bin/echo %s",
+			 starttoken, env_loc, stoptoken);
 		if      (mode == 1)
 			execl("/bin/su", "su", username, "-c", cmdstr, NULL);
 		else if (mode == 2)
diff --git a/src/common/env.h b/src/common/env.h
index 3f8901d66565847d0ecda3680c5f93be959fe611..f59adaf17ddecab542c076840d4615a409768a80 100644
--- a/src/common/env.h
+++ b/src/common/env.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -70,6 +70,10 @@ typedef struct env_options {
 	int cpus_on_node;
 	pid_t task_pid;
 	char *sgtids;		/* global ranks array of integers */	
+	uint16_t pty_port;	/* used to communicate window size changes */
+	uint8_t ws_col;		/* window size, columns */
+	uint8_t ws_row;		/* window size, row count */
+	char *ckpt_path;	/* --ckpt-path=                 */
 } env_t;
 
 
@@ -161,8 +165,7 @@ void
 env_array_for_step(char ***dest,
 		   const job_step_create_response_msg_t *step,
 		   const char *launcher_hostname,
-		   uint16_t launcher_port,
-		   const char *ip_addr_str);
+		   uint16_t launcher_port);
 
 /*
  * Return an empty environment variable array (contains a single
diff --git a/src/common/forward.c b/src/common/forward.c
index f1c8ec408d0be99eaca7968018d80977ecb71955..05b62d6619a8f24f267fe9dc77f2351297f0eae7 100644
--- a/src/common/forward.c
+++ b/src/common/forward.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <auble1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/forward.h b/src/common/forward.h
index 086d4cdbc8fef51769d59cdff0962e486afbd433..c7e92eee62792966d8f4cccef27c832625851104 100644
--- a/src/common/forward.h
+++ b/src/common/forward.h
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <auble1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/hostlist.c b/src/common/hostlist.c
index 19f340942d715b26125b95caa7cb57b5c5df01f0..2b9cf4a1b65305e1fdd69fe9b99b74fbd94b3a5a 100644
--- a/src/common/hostlist.c
+++ b/src/common/hostlist.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
- *  $Id: hostlist.c 13270 2008-02-14 19:40:44Z da $
+ *  $Id: hostlist.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  $LSDId: hostlist.c,v 1.14 2003/10/14 20:11:54 grondo Exp $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -168,7 +168,7 @@ strong_alias(hostset_nth,		slurm_hostset_nth);
 /* ----[ Internal Data Structures ]---- */
 
 
-char *alpha_num = "0123456789ABCDEFGHIJKLMNOPQRSTUZWXYZ";
+char *alpha_num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 #ifdef HAVE_BG		
 /* logic for block node description */
diff --git a/src/common/hostlist.h b/src/common/hostlist.h
index b60e86f5961350116c5bdf11d6e0f6ef413bdfab..bc4061cc81b57d9f71ad24b0fbd99710fa63d5be 100644
--- a/src/common/hostlist.h
+++ b/src/common/hostlist.h
@@ -1,12 +1,12 @@
 /*****************************************************************************\
- *  $Id: hostlist.h 11402 2007-04-25 17:39:08Z da $
+ *  $Id: hostlist.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  $LSDId: hostlist.h,v 1.4 2003/09/19 21:37:34 grondo Exp $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/io_hdr.c b/src/common/io_hdr.c
index cce4ed8084683b053535f993ea8749f0106a5ecd..3a782025fa727cb9c66aba18c8926ecb3db4acaf 100644
--- a/src/common/io_hdr.c
+++ b/src/common/io_hdr.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/common/io_hdr.c - IO connection header functions
- * $Id: io_hdr.c 10574 2006-12-15 23:38:29Z jette $
+ * $Id: io_hdr.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark A. Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -179,7 +179,7 @@ io_init_msg_packed_size(void)
 
 	len = sizeof(uint16_t)        /* version */
 		+ sizeof(uint32_t)    /* nodeid */
-		+ (SLURM_IO_KEY_SIZE + sizeof(uint16_t))  /* signature */
+		+ (SLURM_IO_KEY_SIZE + sizeof(uint32_t))  /* signature */
 		+ sizeof(uint32_t)    /* stdout_objs */
 		+ sizeof(uint32_t);   /* stderr_objs */
 	return len;
@@ -193,15 +193,14 @@ io_init_msg_pack(struct slurm_io_init_msg *hdr, Buf buffer)
 	pack32(hdr->stdout_objs, buffer);
 	pack32(hdr->stderr_objs, buffer);
 	packmem((char *) hdr->cred_signature,
-		(uint16_t) SLURM_IO_KEY_SIZE, buffer);
+		(uint32_t) SLURM_IO_KEY_SIZE, buffer);
 }
 
 
 static int
 io_init_msg_unpack(struct slurm_io_init_msg *hdr, Buf buffer)
 {
-	uint16_t val;
-
+	uint32_t val;
 	safe_unpack16(&hdr->version, buffer);
 	safe_unpack32(&hdr->nodeid, buffer);
 	safe_unpack32(&hdr->stdout_objs, buffer);
diff --git a/src/common/io_hdr.h b/src/common/io_hdr.h
index e5f60f49ce9b51e98e68e86e1114ad5866c1ea36..ec6f3d149ba176c0e66f675b15e4e102942249d9 100644
--- a/src/common/io_hdr.h
+++ b/src/common/io_hdr.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/common/io_hdr.h - IO connection header functions
- * $Id: io_hdr.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: io_hdr.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark A. Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/job_options.c b/src/common/job_options.c
index f4ba8a9cbcf6b9551b0a551b3bd0edfb946791c0..95ae5be10dc539b73c019e9dce2df87aec808077 100644
--- a/src/common/job_options.c
+++ b/src/common/job_options.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -94,19 +94,16 @@ static struct job_option_info * job_option_info_unpack (Buf buf)
 {
 	struct job_option_info *ji = xmalloc (sizeof (*ji));
 	uint32_t type;
-	uint16_t len;
+	uint32_t len;
 
-	if (unpack32 (&type, buf) != SLURM_SUCCESS)
-		goto error;
-	if (unpackstr_xmalloc (&ji->option, &len, buf) != SLURM_SUCCESS)
-		goto error;
-	if (unpackstr_xmalloc (&ji->optarg, &len, buf) != SLURM_SUCCESS)
-		goto error;
+	safe_unpack32 (&type, buf);
+	safe_unpackstr_xmalloc (&ji->option, &len, buf);
+	safe_unpackstr_xmalloc (&ji->optarg, &len, buf);
 
 	ji->type = (int) type;
 	return (ji);
 
-    error:
+  unpack_error:
 	job_option_info_destroy (ji);
 	return (NULL);
 }
@@ -196,19 +193,18 @@ int job_options_pack (job_options_t opts, Buf buf)
 int job_options_unpack (job_options_t opts, Buf buf)
 {
 	uint32_t count;
-	uint16_t len;
-	char *   tag;
+	uint32_t len;
+	char *   tag = NULL;
 	int      i;
 
-	if (unpackstr_xmalloc (&tag, &len, buf) != SLURM_SUCCESS)
-		return (SLURM_ERROR);
+	safe_unpackstr_xmalloc (&tag, &len, buf);
 
 	if (strncmp (tag, JOB_OPTIONS_PACK_TAG, len) != 0) {
 		xfree(tag);
 		return (-1);
 	}
 	xfree(tag);
-	unpack32 (&count, buf);
+	safe_unpack32 (&count, buf);
 
 	for (i = 0; i < count; i++) {
 		struct job_option_info *ji;
@@ -218,6 +214,10 @@ int job_options_unpack (job_options_t opts, Buf buf)
 	}
 
 	return (0);
+
+  unpack_error:
+	xfree(tag);
+	return SLURM_ERROR;
 }
 
 /*
diff --git a/src/common/job_options.h b/src/common/job_options.h
index 7c910d0060ecbbdb8cb75f845694559c52214c4c..18a50a28c01c0d239ee6df595bfaf64b7a4a722c 100644
--- a/src/common/job_options.h
+++ b/src/common/job_options.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/jobacct_common.c b/src/common/jobacct_common.c
new file mode 100644
index 0000000000000000000000000000000000000000..316123bfa186f973d50a7903473371213adfa465
--- /dev/null
+++ b/src/common/jobacct_common.c
@@ -0,0 +1,886 @@
+/*****************************************************************************\
+ *  jobacct_common.c - common functions for almost all jobacct plugins.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
+ *  Written by Danny Auble, <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "jobacct_common.h"
+
+bool jobacct_shutdown = false;
+bool jobacct_suspended = false;
+List task_list = NULL;
+pthread_mutex_t jobacct_lock = PTHREAD_MUTEX_INITIALIZER;
+uint32_t cont_id = (uint32_t)NO_VAL;
+uint32_t acct_job_id = 0;
+uint32_t job_mem_limit = 0;
+bool pgid_plugin = false;
+
+static void _pack_jobacct_id(jobacct_id_t *jobacct_id, Buf buffer)
+{
+	pack32((uint32_t)jobacct_id->nodeid, buffer);
+	pack16((uint16_t)jobacct_id->taskid, buffer);
+}
+
+static int _unpack_jobacct_id(jobacct_id_t *jobacct_id, Buf buffer)
+{
+	safe_unpack32(&jobacct_id->nodeid, buffer);
+	safe_unpack16(&jobacct_id->taskid, buffer);
+	return SLURM_SUCCESS;
+unpack_error:
+	return SLURM_ERROR;
+}
+
+static void _pack_sacct(sacct_t *sacct, Buf buffer)
+{
+	int i=0;
+	int mult = 1000000;
+
+	if(!sacct) {
+		for(i=0; i<8; i++)
+			pack32((uint32_t) 0, buffer);
+
+		for(i=0; i<4; i++) {	/* _pack_jobacct_id() */
+			pack32((uint32_t) 0, buffer);
+			pack16((uint16_t) 0, buffer);
+		}
+		return;
+	} 
+	pack32((uint32_t)sacct->max_vsize, buffer);
+	pack32((uint32_t)(sacct->ave_vsize*mult), buffer);
+	pack32((uint32_t)sacct->max_rss, buffer);
+	pack32((uint32_t)(sacct->ave_rss*mult), buffer);
+	pack32((uint32_t)sacct->max_pages, buffer);
+	pack32((uint32_t)(sacct->ave_pages*mult), buffer);
+	pack32((uint32_t)(sacct->min_cpu*mult), buffer);
+	pack32((uint32_t)(sacct->ave_cpu*mult), buffer);
+
+	_pack_jobacct_id(&sacct->max_vsize_id, buffer);
+	_pack_jobacct_id(&sacct->max_rss_id, buffer);
+	_pack_jobacct_id(&sacct->max_pages_id, buffer);
+	_pack_jobacct_id(&sacct->min_cpu_id, buffer);
+}
+
+/* you need to xfree this */
+static int _unpack_sacct(sacct_t *sacct, Buf buffer)
+{
+	int mult = 1000000;
+
+	safe_unpack32(&sacct->max_vsize, buffer);
+	safe_unpack32((uint32_t *)&sacct->ave_vsize, buffer);
+	sacct->ave_vsize /= mult;
+	safe_unpack32(&sacct->max_rss, buffer);
+	safe_unpack32((uint32_t *)&sacct->ave_rss, buffer);
+	sacct->ave_rss /= mult;
+	safe_unpack32(&sacct->max_pages, buffer);
+	safe_unpack32((uint32_t *)&sacct->ave_pages, buffer);
+	sacct->ave_pages /= mult;
+	safe_unpack32((uint32_t *)&sacct->min_cpu, buffer);
+	sacct->min_cpu /= mult;
+	safe_unpack32((uint32_t *)&sacct->ave_cpu, buffer);
+	sacct->ave_cpu /= mult;
+	if(_unpack_jobacct_id(&sacct->max_vsize_id, buffer) != SLURM_SUCCESS)
+		goto unpack_error;
+	if(_unpack_jobacct_id(&sacct->max_rss_id, buffer) != SLURM_SUCCESS)
+		goto unpack_error;
+	if(_unpack_jobacct_id(&sacct->max_pages_id, buffer) != SLURM_SUCCESS)
+		goto unpack_error;
+	if(_unpack_jobacct_id(&sacct->min_cpu_id, buffer) != SLURM_SUCCESS)
+		goto unpack_error;
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	sacct = NULL;
+       	return SLURM_ERROR;
+}
+extern jobacct_job_rec_t *create_jobacct_job_rec()
+{
+	jobacct_job_rec_t *job = xmalloc(sizeof(jobacct_job_rec_t));
+	memset(&job->sacct, 0, sizeof(sacct_t));
+	job->sacct.min_cpu = (float)NO_VAL;
+	job->state = JOB_PENDING;
+	job->steps = list_create(destroy_jobacct_step_rec);
+	job->requid = -1;
+
+      	return job;
+}
+
+extern jobacct_step_rec_t *create_jobacct_step_rec()
+{
+	jobacct_step_rec_t *step = xmalloc(sizeof(jobacct_job_rec_t));
+	memset(&step->sacct, 0, sizeof(sacct_t));
+	step->stepid = (uint32_t)NO_VAL;
+	step->state = NO_VAL;
+	step->exitcode = NO_VAL;
+	step->ncpus = (uint32_t)NO_VAL;
+	step->elapsed = (uint32_t)NO_VAL;
+	step->tot_cpu_sec = (uint32_t)NO_VAL;
+	step->tot_cpu_usec = (uint32_t)NO_VAL;
+	step->requid = -1;
+
+	return step;
+}
+
+extern void destroy_jobacct_job_rec(void *object)
+{
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	if (job) {
+		xfree(job->account);
+		xfree(job->blockid);
+		xfree(job->cluster);
+		xfree(job->jobname);
+		xfree(job->partition);
+		xfree(job->nodes);
+		xfree(job->user);
+		if(job->steps)
+			list_destroy(job->steps);
+		xfree(job);
+	}
+}
+
+extern void destroy_jobacct_step_rec(void *object)
+{
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	if (step) {
+		xfree(step->nodes);
+		xfree(step->stepname);
+		xfree(step);
+	}
+}
+
+extern void destroy_jobacct_selected_step(void *object)
+{
+	jobacct_selected_step_t *step = (jobacct_selected_step_t *)object;
+	if (step) {
+		xfree(step->job);
+		xfree(step->step);
+		xfree(step);
+	}
+}
+
+ 
+extern void pack_jobacct_job_rec(void *object, Buf buffer)
+{
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	ListIterator itr = NULL;
+	jobacct_step_rec_t *step = NULL;
+	uint32_t count = 0;
+
+	pack32(job->alloc_cpus, buffer);
+	pack32(job->associd, buffer);
+	packstr(job->account, buffer);
+	packstr(job->blockid, buffer);
+	packstr(job->cluster, buffer);
+	pack32(job->elapsed, buffer);
+	pack_time(job->eligible, buffer);
+	pack_time(job->end, buffer);
+	pack32(job->exitcode, buffer);
+	pack32(job->gid, buffer);
+	pack32(job->jobid, buffer);
+	packstr(job->jobname, buffer);
+	packstr(job->partition, buffer);
+	packstr(job->nodes, buffer);
+	pack32(job->priority, buffer);
+	pack16(job->qos, buffer);
+	pack32(job->req_cpus, buffer);
+	pack32(job->requid, buffer);
+	_pack_sacct(&job->sacct, buffer);
+	pack32(job->show_full, buffer);
+	pack_time(job->start, buffer);
+	pack16(job->state, buffer);
+	if(job->steps)
+		count = list_count(job->steps);
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(job->steps);
+		while((step = list_next(itr))) {
+			pack_jobacct_step_rec(step, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	pack_time(job->submit, buffer);
+	pack32(job->suspended, buffer);
+	pack32(job->sys_cpu_sec, buffer);
+	pack32(job->sys_cpu_usec, buffer);
+	pack32(job->tot_cpu_sec, buffer);
+	pack32(job->tot_cpu_usec, buffer);
+	pack16(job->track_steps, buffer);
+	pack32(job->uid, buffer);
+	//packstr(job->user, buffer);
+	pack32(job->user_cpu_sec, buffer);
+	pack32(job->user_cpu_usec, buffer);
+}
+
+extern int unpack_jobacct_job_rec(void **job, Buf buffer)
+{
+	jobacct_job_rec_t *job_ptr = xmalloc(sizeof(jobacct_job_rec_t));
+	int i = 0;
+	jobacct_step_rec_t *step = NULL;
+	uint32_t count = 0;
+	uint32_t uint32_tmp;
+
+	*job = job_ptr;
+
+	safe_unpack32(&job_ptr->alloc_cpus, buffer);
+	safe_unpack32(&job_ptr->associd, buffer);
+	safe_unpackstr_xmalloc(&job_ptr->account, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_ptr->blockid, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_ptr->cluster, &uint32_tmp, buffer);
+	safe_unpack32(&job_ptr->elapsed, buffer);
+	safe_unpack_time(&job_ptr->eligible, buffer);
+	safe_unpack_time(&job_ptr->end, buffer);
+	safe_unpack32((uint32_t *)&job_ptr->exitcode, buffer);
+	safe_unpack32(&job_ptr->gid, buffer);
+	safe_unpack32(&job_ptr->jobid, buffer);
+	safe_unpackstr_xmalloc(&job_ptr->jobname, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_ptr->partition, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_ptr->nodes, &uint32_tmp, buffer);
+	safe_unpack32((uint32_t *)&job_ptr->priority, buffer);
+	safe_unpack16(&job_ptr->qos, buffer);
+	safe_unpack32(&job_ptr->req_cpus, buffer);
+	safe_unpack32(&job_ptr->requid, buffer);
+	_pack_sacct(&job_ptr->sacct, buffer);
+	safe_unpack32(&job_ptr->show_full, buffer);
+	safe_unpack_time(&job_ptr->start, buffer);
+	safe_unpack16((uint16_t *)&job_ptr->state, buffer);
+	safe_unpack32(&count, buffer);
+
+	job_ptr->steps = list_create(destroy_jobacct_step_rec);
+	for(i=0; i<count; i++) {
+		unpack_jobacct_step_rec(&step, buffer);
+		if(step)
+			list_append(job_ptr->steps, step);
+	}
+
+	safe_unpack_time(&job_ptr->submit, buffer);
+	safe_unpack32(&job_ptr->suspended, buffer);
+	safe_unpack32(&job_ptr->sys_cpu_sec, buffer);
+	safe_unpack32(&job_ptr->sys_cpu_usec, buffer);
+	safe_unpack32(&job_ptr->tot_cpu_sec, buffer);
+	safe_unpack32(&job_ptr->tot_cpu_usec, buffer);
+	safe_unpack16(&job_ptr->track_steps, buffer);
+	safe_unpack32(&job_ptr->uid, buffer);
+	//safe_unpackstr_xmalloc(&job_ptr->user, &uint32_tmp, buffer);
+	safe_unpack32(&job_ptr->user_cpu_sec, buffer);
+	safe_unpack32(&job_ptr->user_cpu_usec, buffer);
+	
+	return SLURM_SUCCESS;
+
+unpack_error:
+	xfree(job_ptr->account);
+	xfree(job_ptr->blockid);
+	xfree(job_ptr->cluster);
+	xfree(job_ptr->jobname);
+	xfree(job_ptr->partition);
+	xfree(job_ptr->nodes);
+	if(job_ptr->steps)
+		list_destroy(job_ptr->steps);
+	xfree(job_ptr->user);
+	xfree(job_ptr);
+	*job = NULL;
+	return SLURM_ERROR;
+}
+ 
+extern void pack_jobacct_step_rec(jobacct_step_rec_t *step, Buf buffer)
+{
+	pack32(step->elapsed, buffer);
+	pack_time(step->end, buffer);
+	pack32((uint32_t)step->exitcode, buffer);
+	pack32(step->jobid, buffer);
+	pack32(step->ncpus, buffer);
+        packstr(step->nodes, buffer);
+	pack32(step->requid, buffer);
+	_pack_sacct(&step->sacct, buffer);
+	pack_time(step->start, buffer);
+	pack16(step->state, buffer);
+	pack32(step->stepid, buffer);	/* job's step number */
+	packstr(step->stepname, buffer);
+	pack32(step->suspended, buffer);
+	pack32(step->sys_cpu_sec, buffer);
+	pack32(step->sys_cpu_usec, buffer);
+	pack32(step->tot_cpu_sec, buffer);
+	pack32(step->tot_cpu_usec, buffer);
+	pack32(step->user_cpu_sec, buffer);
+	pack32(step->user_cpu_usec, buffer);
+}
+
+extern int unpack_jobacct_step_rec(jobacct_step_rec_t **step, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	jobacct_step_rec_t *step_ptr = xmalloc(sizeof(jobacct_step_rec_t));
+
+	*step = step_ptr;
+
+	safe_unpack32(&step_ptr->elapsed, buffer);
+	safe_unpack_time(&step_ptr->end, buffer);
+	safe_unpack32((uint32_t *)&step_ptr->exitcode, buffer);
+	safe_unpack32(&step_ptr->jobid, buffer);
+	safe_unpack32(&step_ptr->ncpus, buffer);
+        safe_unpackstr_xmalloc(&step_ptr->nodes, &uint32_tmp, buffer);
+	safe_unpack32(&step_ptr->requid, buffer);
+	_unpack_sacct(&step_ptr->sacct, buffer);
+	safe_unpack_time(&step_ptr->start, buffer);
+	safe_unpack16((uint16_t *)&step_ptr->state, buffer);
+	safe_unpack32(&step_ptr->stepid, buffer);	/* job's step number */
+	safe_unpackstr_xmalloc(&step_ptr->stepname, &uint32_tmp, buffer);
+	safe_unpack32(&step_ptr->suspended, buffer);
+	safe_unpack32(&step_ptr->sys_cpu_sec, buffer);
+	safe_unpack32(&step_ptr->sys_cpu_usec, buffer);
+	safe_unpack32(&step_ptr->tot_cpu_sec, buffer);
+	safe_unpack32(&step_ptr->tot_cpu_usec, buffer);
+	safe_unpack32(&step_ptr->user_cpu_sec, buffer);
+	safe_unpack32(&step_ptr->user_cpu_usec, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	xfree(step_ptr->nodes);
+	xfree(step_ptr->stepname);
+	xfree(step_ptr);
+	*step = NULL;
+	return SLURM_ERROR;
+} 
+
+extern void pack_jobacct_selected_step(jobacct_selected_step_t *step,
+				       Buf buffer)
+{
+	packstr(step->job, buffer);
+	packstr(step->step, buffer);
+	pack32(step->jobid, buffer);
+	pack32(step->stepid, buffer);
+}
+
+extern int unpack_jobacct_selected_step(jobacct_selected_step_t **step,
+					Buf buffer)
+{
+	uint32_t uint32_tmp;
+	jobacct_selected_step_t *step_ptr =
+		xmalloc(sizeof(jobacct_selected_step_t));
+	
+	*step = step_ptr;
+
+	safe_unpackstr_xmalloc(&step_ptr->job, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&step_ptr->step, &uint32_tmp, buffer);
+	safe_unpack32(&step_ptr->jobid, buffer);
+	safe_unpack32(&step_ptr->stepid, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	xfree(step_ptr->job);
+	xfree(step_ptr->step);
+	xfree(step_ptr);
+	*step = NULL;
+	return SLURM_ERROR;
+}
+
+extern int jobacct_common_init_struct(struct jobacctinfo *jobacct, 
+				      jobacct_id_t *jobacct_id)
+{
+	if(!jobacct_id) {
+		jobacct_id_t temp_id;
+		temp_id.taskid = (uint16_t)NO_VAL;
+		temp_id.nodeid = (uint32_t)NO_VAL;
+		jobacct_id = &temp_id;
+	}
+	memset(jobacct, 0, sizeof(struct jobacctinfo));
+	jobacct->sys_cpu_sec = 0;
+	jobacct->sys_cpu_usec = 0;
+	jobacct->user_cpu_sec = 0;
+	jobacct->user_cpu_usec = 0;
+
+	jobacct->max_vsize = 0;
+	memcpy(&jobacct->max_vsize_id, jobacct_id, sizeof(jobacct_id_t));
+	jobacct->tot_vsize = 0;
+	jobacct->max_rss = 0;
+	memcpy(&jobacct->max_rss_id, jobacct_id, sizeof(jobacct_id_t));
+	jobacct->tot_rss = 0;
+	jobacct->max_pages = 0;
+	memcpy(&jobacct->max_pages_id, jobacct_id, sizeof(jobacct_id_t));
+	jobacct->tot_pages = 0;
+	jobacct->min_cpu = (uint32_t)NO_VAL;
+	memcpy(&jobacct->min_cpu_id, jobacct_id, sizeof(jobacct_id_t));
+	jobacct->tot_cpu = 0;
+	
+	return SLURM_SUCCESS;
+}
+
+extern struct jobacctinfo *jobacct_common_alloc_jobacct(
+	jobacct_id_t *jobacct_id)
+{
+	struct jobacctinfo *jobacct = xmalloc(sizeof(struct jobacctinfo));
+	jobacct_common_init_struct(jobacct, jobacct_id);
+	return jobacct;
+}
+
+extern void jobacct_common_free_jobacct(void *object)
+{
+	struct jobacctinfo *jobacct = (struct jobacctinfo *)object;
+	xfree(jobacct);
+	jobacct = NULL;
+}
+
+extern int jobacct_common_setinfo(struct jobacctinfo *jobacct, 
+				  enum jobacct_data_type type, void *data)
+{
+	int rc = SLURM_SUCCESS;
+	int *fd = (int *)data;
+	struct rusage *rusage = (struct rusage *)data;
+	uint32_t *uint32 = (uint32_t *) data;
+	jobacct_id_t *jobacct_id = (jobacct_id_t *) data;
+	struct jobacctinfo *send = (struct jobacctinfo *) data;
+
+	slurm_mutex_lock(&jobacct_lock);
+	switch (type) {
+	case JOBACCT_DATA_TOTAL:
+		memcpy(jobacct, send, sizeof(struct jobacctinfo));
+		break;
+	case JOBACCT_DATA_PIPE:
+		safe_write(*fd, jobacct, sizeof(struct jobacctinfo));
+		break;
+	case JOBACCT_DATA_RUSAGE:
+		jobacct->user_cpu_sec = rusage->ru_utime.tv_sec;
+		jobacct->user_cpu_usec = rusage->ru_utime.tv_usec;
+		jobacct->sys_cpu_sec = rusage->ru_stime.tv_sec;
+		jobacct->sys_cpu_usec = rusage->ru_stime.tv_usec;
+		break;
+	case JOBACCT_DATA_MAX_RSS:
+		jobacct->max_rss = *uint32;
+		break;
+	case JOBACCT_DATA_MAX_RSS_ID:
+		jobacct->max_rss_id = *jobacct_id;
+		break;
+	case JOBACCT_DATA_TOT_RSS:
+		jobacct->tot_rss = *uint32;
+		break;
+	case JOBACCT_DATA_MAX_VSIZE:
+		jobacct->max_vsize = *uint32;
+		break;
+	case JOBACCT_DATA_MAX_VSIZE_ID:
+		jobacct->max_vsize_id = *jobacct_id;
+		break;
+	case JOBACCT_DATA_TOT_VSIZE:
+		jobacct->tot_vsize = *uint32;
+		break;
+	case JOBACCT_DATA_MAX_PAGES:
+		jobacct->max_pages = *uint32;
+		break;
+	case JOBACCT_DATA_MAX_PAGES_ID:
+		jobacct->max_pages_id = *jobacct_id;
+		break;
+	case JOBACCT_DATA_TOT_PAGES:
+		jobacct->tot_pages = *uint32;
+		break;
+	case JOBACCT_DATA_MIN_CPU:
+		jobacct->min_cpu = *uint32;
+		break;
+	case JOBACCT_DATA_MIN_CPU_ID:
+		jobacct->min_cpu_id = *jobacct_id;
+		break;
+	case JOBACCT_DATA_TOT_CPU:
+		jobacct->tot_cpu = *uint32;
+		break;
+	default:
+		debug("jobacct_g_set_setinfo data_type %d invalid", 
+		      type);
+	}
+	slurm_mutex_unlock(&jobacct_lock);
+	return rc;
+rwfail:
+	slurm_mutex_unlock(&jobacct_lock);
+	return SLURM_ERROR;
+	
+}
+
+extern int jobacct_common_getinfo(struct jobacctinfo *jobacct, 
+			  enum jobacct_data_type type, void *data)
+{
+	int rc = SLURM_SUCCESS;
+	int *fd = (int *)data;
+	uint32_t *uint32 = (uint32_t *) data;
+	jobacct_id_t *jobacct_id = (jobacct_id_t *) data;
+	struct rusage *rusage = (struct rusage *)data;
+	struct jobacctinfo *send = (struct jobacctinfo *) data;
+
+	slurm_mutex_lock(&jobacct_lock);
+	switch (type) {
+	case JOBACCT_DATA_TOTAL:
+		memcpy(send, jobacct, sizeof(struct jobacctinfo));
+		break;
+	case JOBACCT_DATA_PIPE:
+		safe_read(*fd, jobacct, sizeof(struct jobacctinfo));
+		break;
+	case JOBACCT_DATA_RUSAGE:
+		memset(rusage, 0, sizeof(struct rusage));
+		rusage->ru_utime.tv_sec = jobacct->user_cpu_sec;
+		rusage->ru_utime.tv_usec = jobacct->user_cpu_usec;
+		rusage->ru_stime.tv_sec = jobacct->sys_cpu_sec;
+		rusage->ru_stime.tv_usec = jobacct->sys_cpu_usec;
+		break;
+	case JOBACCT_DATA_MAX_RSS:
+		*uint32 = jobacct->max_rss;
+		break;
+	case JOBACCT_DATA_MAX_RSS_ID:
+		*jobacct_id = jobacct->max_rss_id;
+		break;
+	case JOBACCT_DATA_TOT_RSS:
+		*uint32 = jobacct->tot_rss;
+		break;
+	case JOBACCT_DATA_MAX_VSIZE:
+		*uint32 = jobacct->max_vsize;
+		break;
+	case JOBACCT_DATA_MAX_VSIZE_ID:
+		*jobacct_id = jobacct->max_vsize_id;
+		break;
+	case JOBACCT_DATA_TOT_VSIZE:
+		*uint32 = jobacct->tot_vsize;
+		break;
+	case JOBACCT_DATA_MAX_PAGES:
+		*uint32 = jobacct->max_pages;
+		break;
+	case JOBACCT_DATA_MAX_PAGES_ID:
+		*jobacct_id = jobacct->max_pages_id;
+		break;
+	case JOBACCT_DATA_TOT_PAGES:
+		*uint32 = jobacct->tot_pages;
+		break;
+	case JOBACCT_DATA_MIN_CPU:
+		*uint32 = jobacct->min_cpu;
+		break;
+	case JOBACCT_DATA_MIN_CPU_ID:
+		*jobacct_id = jobacct->min_cpu_id;
+		break;
+	case JOBACCT_DATA_TOT_CPU:
+		*uint32 = jobacct->tot_cpu;
+		break;
+	default:
+		debug("jobacct_g_set_setinfo data_type %d invalid", 
+		      type);
+	}
+	slurm_mutex_unlock(&jobacct_lock);
+	return rc;
+rwfail:
+	slurm_mutex_unlock(&jobacct_lock);
+	return SLURM_ERROR;
+
+}
+
+extern void jobacct_common_aggregate(struct jobacctinfo *dest, 
+			     struct jobacctinfo *from)
+{
+	xassert(dest);
+	xassert(from);
+
+	slurm_mutex_lock(&jobacct_lock);
+	if(dest->max_vsize < from->max_vsize) {
+		dest->max_vsize = from->max_vsize;
+		dest->max_vsize_id = from->max_vsize_id;
+	}
+	dest->tot_vsize += from->tot_vsize;
+	
+	if(dest->max_rss < from->max_rss) {
+		dest->max_rss = from->max_rss;
+		dest->max_rss_id = from->max_rss_id;
+	}
+	dest->tot_rss += from->tot_rss;
+	
+	if(dest->max_pages < from->max_pages) {
+		dest->max_pages = from->max_pages;
+		dest->max_pages_id = from->max_pages_id;
+	}
+	dest->tot_pages += from->tot_pages;
+	if((dest->min_cpu > from->min_cpu) 
+	   || (dest->min_cpu == (uint32_t)NO_VAL)) {
+		if(from->min_cpu == (uint32_t)NO_VAL)
+			from->min_cpu = 0;
+		dest->min_cpu = from->min_cpu;
+		dest->min_cpu_id = from->min_cpu_id;
+	}
+	dest->tot_cpu += from->tot_cpu;
+		
+	if(dest->max_vsize_id.taskid == (uint16_t)NO_VAL)
+		dest->max_vsize_id = from->max_vsize_id;
+
+	if(dest->max_rss_id.taskid == (uint16_t)NO_VAL)
+		dest->max_rss_id = from->max_rss_id;
+
+	if(dest->max_pages_id.taskid == (uint16_t)NO_VAL)
+		dest->max_pages_id = from->max_pages_id;
+
+	if(dest->min_cpu_id.taskid == (uint16_t)NO_VAL)
+		dest->min_cpu_id = from->min_cpu_id;
+
+	dest->user_cpu_sec	+= from->user_cpu_sec;
+	dest->user_cpu_usec	+= from->user_cpu_usec;
+	while (dest->user_cpu_usec >= 1E6) {
+		dest->user_cpu_sec++;
+		dest->user_cpu_usec -= 1E6;
+	}
+	dest->sys_cpu_sec	+= from->sys_cpu_sec;
+	dest->sys_cpu_usec	+= from->sys_cpu_usec;
+	while (dest->sys_cpu_usec >= 1E6) {
+		dest->sys_cpu_sec++;
+		dest->sys_cpu_usec -= 1E6;
+	}
+
+	slurm_mutex_unlock(&jobacct_lock);	
+}
+
+extern void jobacct_common_2_sacct(sacct_t *sacct, struct jobacctinfo *jobacct)
+{
+	xassert(jobacct);
+	xassert(sacct);
+	slurm_mutex_lock(&jobacct_lock);
+	sacct->max_vsize = jobacct->max_vsize;
+	sacct->max_vsize_id = jobacct->max_vsize_id;
+	sacct->ave_vsize = jobacct->tot_vsize;
+	sacct->max_rss = jobacct->max_rss;
+	sacct->max_rss_id = jobacct->max_rss_id;
+	sacct->ave_rss = jobacct->tot_rss;
+	sacct->max_pages = jobacct->max_pages;
+	sacct->max_pages_id = jobacct->max_pages_id;
+	sacct->ave_pages = jobacct->tot_pages;
+	sacct->min_cpu = jobacct->min_cpu;
+	sacct->min_cpu_id = jobacct->min_cpu_id;
+	sacct->ave_cpu = jobacct->tot_cpu;
+	slurm_mutex_unlock(&jobacct_lock);
+}
+
+extern void jobacct_common_pack(struct jobacctinfo *jobacct, Buf buffer)
+{
+	int i=0;
+
+	if(!jobacct) {
+		for(i=0; i<16; i++)
+			pack32((uint32_t) 0, buffer);
+		for(i=0; i<4; i++)
+			pack16((uint16_t) 0, buffer);
+		return;
+	} 
+	slurm_mutex_lock(&jobacct_lock);
+	pack32((uint32_t)jobacct->user_cpu_sec, buffer);
+	pack32((uint32_t)jobacct->user_cpu_usec, buffer);
+	pack32((uint32_t)jobacct->sys_cpu_sec, buffer);
+	pack32((uint32_t)jobacct->sys_cpu_usec, buffer);
+	pack32((uint32_t)jobacct->max_vsize, buffer);
+	pack32((uint32_t)jobacct->tot_vsize, buffer);
+	pack32((uint32_t)jobacct->max_rss, buffer);
+	pack32((uint32_t)jobacct->tot_rss, buffer);
+	pack32((uint32_t)jobacct->max_pages, buffer);
+	pack32((uint32_t)jobacct->tot_pages, buffer);
+	pack32((uint32_t)jobacct->min_cpu, buffer);
+	pack32((uint32_t)jobacct->tot_cpu, buffer);
+	_pack_jobacct_id(&jobacct->max_vsize_id, buffer);
+	_pack_jobacct_id(&jobacct->max_rss_id, buffer);
+	_pack_jobacct_id(&jobacct->max_pages_id, buffer);
+	_pack_jobacct_id(&jobacct->min_cpu_id, buffer);
+	slurm_mutex_unlock(&jobacct_lock);
+}
+
+/* you need to xfree this */
+extern int jobacct_common_unpack(struct jobacctinfo **jobacct, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	*jobacct = xmalloc(sizeof(struct jobacctinfo));
+	safe_unpack32(&uint32_tmp, buffer);
+	(*jobacct)->user_cpu_sec = uint32_tmp;
+	safe_unpack32(&uint32_tmp, buffer);
+	(*jobacct)->user_cpu_usec = uint32_tmp;
+	safe_unpack32(&uint32_tmp, buffer);
+	(*jobacct)->sys_cpu_sec = uint32_tmp;
+	safe_unpack32(&uint32_tmp, buffer);
+	(*jobacct)->sys_cpu_usec = uint32_tmp;
+	safe_unpack32(&(*jobacct)->max_vsize, buffer);
+	safe_unpack32(&(*jobacct)->tot_vsize, buffer);
+	safe_unpack32(&(*jobacct)->max_rss, buffer);
+	safe_unpack32(&(*jobacct)->tot_rss, buffer);
+	safe_unpack32(&(*jobacct)->max_pages, buffer);
+	safe_unpack32(&(*jobacct)->tot_pages, buffer);
+	safe_unpack32(&(*jobacct)->min_cpu, buffer);
+	safe_unpack32(&(*jobacct)->tot_cpu, buffer);
+	if(_unpack_jobacct_id(&(*jobacct)->max_vsize_id, buffer) 
+	   != SLURM_SUCCESS)
+		goto unpack_error;
+	if(_unpack_jobacct_id(&(*jobacct)->max_rss_id, buffer)
+	   != SLURM_SUCCESS)
+		goto unpack_error;
+	if(_unpack_jobacct_id(&(*jobacct)->max_pages_id, buffer)
+	   != SLURM_SUCCESS)
+		goto unpack_error;
+	if(_unpack_jobacct_id(&(*jobacct)->min_cpu_id, buffer)
+	   != SLURM_SUCCESS)
+		goto unpack_error;
+	return SLURM_SUCCESS;
+
+unpack_error:
+	xfree(*jobacct);
+       	return SLURM_ERROR;
+}
+
+extern int jobacct_common_set_proctrack_container_id(uint32_t id)
+{
+	if(pgid_plugin)
+		return SLURM_SUCCESS;
+
+	if(cont_id != (uint32_t)NO_VAL) 
+		info("Warning: jobacct: set_proctrack_container_id: "
+		     "cont_id is already set to %d you are setting it to %d",
+		     cont_id, id);
+	if(id <= 0) {
+		error("jobacct: set_proctrack_container_id: "
+		      "I was given most likely an unset cont_id %d",
+		      id);
+		return SLURM_ERROR;
+	}
+	cont_id = id;
+
+	return SLURM_SUCCESS;
+}
+
+extern int jobacct_common_set_mem_limit(uint32_t job_id, uint32_t mem_limit)
+{
+	if ((job_id == 0) || (mem_limit == 0)) {
+		error("jobacct_common_set_mem_limit: jobid:%u mem_limit:%u",
+		      job_id, mem_limit);
+		return SLURM_ERROR;
+	}
+
+	acct_job_id   = job_id;
+	job_mem_limit = mem_limit * 1024;	/* MB to KB */
+	return SLURM_SUCCESS;
+}
+
+extern int jobacct_common_add_task(pid_t pid, jobacct_id_t *jobacct_id)
+{
+	struct jobacctinfo *jobacct = jobacct_common_alloc_jobacct(jobacct_id);
+	
+	slurm_mutex_lock(&jobacct_lock);
+	if(pid <= 0) {
+		error("invalid pid given (%d) for task acct", pid);
+		goto error;
+	} else if (!task_list) {
+		error("no task list created!");
+		goto error;
+	}
+
+	jobacct->pid = pid;
+	jobacct->min_cpu = 0;
+	debug2("adding task %u pid %d on node %u to jobacct", 
+	       jobacct_id->taskid, pid, jobacct_id->nodeid);
+	list_push(task_list, jobacct);
+	slurm_mutex_unlock(&jobacct_lock);
+
+	return SLURM_SUCCESS;
+error:
+	slurm_mutex_unlock(&jobacct_lock);
+	jobacct_common_free_jobacct(jobacct);
+	return SLURM_ERROR;
+}
+
+extern struct jobacctinfo *jobacct_common_stat_task(pid_t pid)
+{
+	struct jobacctinfo *jobacct = NULL;
+	struct jobacctinfo *ret_jobacct = NULL;
+	ListIterator itr = NULL;
+	
+	slurm_mutex_lock(&jobacct_lock);
+	if (!task_list) {
+		error("no task list created!");
+		goto error;
+	}
+
+	itr = list_iterator_create(task_list);
+	while((jobacct = list_next(itr))) { 
+		if(jobacct->pid == pid)
+			break;
+	}
+	list_iterator_destroy(itr);
+	ret_jobacct = xmalloc(sizeof(struct jobacctinfo));
+	memcpy(ret_jobacct, jobacct, sizeof(struct jobacctinfo));
+error:
+	slurm_mutex_unlock(&jobacct_lock);
+	return ret_jobacct;
+}
+
+extern struct jobacctinfo *jobacct_common_remove_task(pid_t pid)
+{
+	struct jobacctinfo *jobacct = NULL;
+
+	ListIterator itr = NULL;
+
+	slurm_mutex_lock(&jobacct_lock);
+	if (!task_list) {
+		error("no task list created!");
+		goto error;
+	}
+
+	itr = list_iterator_create(task_list);
+	while((jobacct = list_next(itr))) { 
+		if(jobacct->pid == pid) {
+			list_remove(itr);
+			break;
+		}
+	}
+	list_iterator_destroy(itr);
+	if(jobacct) {
+		debug2("removing task %u pid %d from jobacct", 
+		       jobacct->max_vsize_id.taskid, jobacct->pid);
+	} else {
+		error("pid(%d) not being watched in jobacct!", pid);
+	}
+error:
+	slurm_mutex_unlock(&jobacct_lock);
+	return jobacct;
+}
+
+extern int jobacct_common_endpoll()
+{
+	jobacct_shutdown = true;
+
+	return SLURM_SUCCESS;
+}
+
+extern void jobacct_common_suspend_poll()
+{
+	jobacct_suspended = true;
+}
+
+extern void jobacct_common_resume_poll()
+{
+	jobacct_suspended = false;
+}
+
diff --git a/src/common/jobacct_common.h b/src/common/jobacct_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..e9e7089d53bd630da49c83c2b572e15c439e6f28
--- /dev/null
+++ b/src/common/jobacct_common.h
@@ -0,0 +1,267 @@
+/*****************************************************************************\
+ *  jobacct_common.h - common functions for almost all jobacct plugins.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
+ *  Written by Danny Auble, <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_JOBACCT_COMMON_H
+#define _HAVE_JOBACCT_COMMON_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include "src/common/xmalloc.h"
+#include "src/common/list.h"
+#include "src/common/xstring.h"
+#include "src/common/node_select.h"
+
+
+#include <ctype.h>
+
+#define BUFFER_SIZE 4096
+
+typedef struct {
+	uint16_t taskid; /* contains which task number it was on */
+	uint32_t nodeid; /* contains which node number it was on */	
+} jobacct_id_t;
+
+typedef struct {
+	uint32_t max_vsize; 
+	jobacct_id_t max_vsize_id;
+	float ave_vsize;
+	uint32_t max_rss;
+	jobacct_id_t max_rss_id;
+	float ave_rss;
+	uint32_t max_pages;
+	jobacct_id_t max_pages_id;
+	float ave_pages;
+	float min_cpu;
+	jobacct_id_t min_cpu_id;
+	float ave_cpu;	
+} sacct_t;
+
+typedef struct {
+	char *opt_cluster;	/* --cluster */
+	int opt_completion;	/* --completion */
+	int opt_dump;		/* --dump */
+	int opt_dup;		/* --duplicates; +1 = explicitly set */
+	int opt_fdump;		/* --formattted_dump */
+	int opt_stat;		/* --stat */
+	int opt_gid;		/* --gid (-1=wildcard, 0=root) */
+	int opt_header;		/* can only be cleared */
+	int opt_help;		/* --help */
+	int opt_long;		/* --long */
+	int opt_lowmem;		/* --low_memory */
+	int opt_raw;		/* --raw */
+	int opt_purge;		/* --purge */
+	int opt_total;		/* --total */
+	int opt_uid;		/* --uid (-1=wildcard, 0=root) */
+	int opt_uid_set;	
+	int opt_verbose;	/* --verbose */
+	long opt_expire;		/* --expire= */ 
+	char *opt_expire_timespec; /* --expire= */
+	char *opt_field_list;	/* --fields= */
+	char *opt_filein;	/* --file */
+	char *opt_job_list;	/* --jobs */
+	char *opt_partition_list;/* --partitions */
+	char *opt_state_list;	/* --states */
+} sacct_parameters_t;
+
+typedef struct {
+	uint32_t alloc_cpus;
+	uint32_t associd;
+	char    *account;
+	char	*blockid;
+	char    *cluster;
+	uint32_t elapsed;
+	time_t eligible;
+	time_t end;
+	int32_t	exitcode;
+	uint32_t gid;
+	uint32_t jobid;
+	char	*jobname;
+	char	*partition;
+	char	*nodes;
+	int32_t priority;
+	uint16_t qos;
+	uint32_t req_cpus;
+	uint32_t requid;
+	sacct_t sacct;
+	uint32_t show_full;
+	time_t start;
+	enum job_states	state;
+	List    steps; /* list of jobacct_step_rec_t *'s */
+	time_t submit;
+	uint32_t suspended;
+	uint32_t sys_cpu_sec;
+	uint32_t sys_cpu_usec;
+	uint32_t tot_cpu_sec;
+	uint32_t tot_cpu_usec;
+	uint16_t track_steps;
+	uint32_t uid;
+	char    *user;
+	uint32_t user_cpu_sec;
+	uint32_t user_cpu_usec;
+} jobacct_job_rec_t;
+
+typedef struct {
+	uint32_t elapsed;
+	time_t end;
+	int32_t exitcode;
+	uint32_t jobid;
+	uint32_t ncpus;
+	char *nodes;
+	uint32_t requid;
+	sacct_t sacct;
+	time_t start;
+	enum job_states	state;
+	uint32_t stepid;	/* job's step number */
+	char *stepname;
+	uint32_t suspended;
+	uint32_t sys_cpu_sec;
+	uint32_t sys_cpu_usec;
+	uint32_t tot_cpu_sec;
+	uint32_t tot_cpu_usec;
+	uint32_t user_cpu_sec;
+	uint32_t user_cpu_usec;
+} jobacct_step_rec_t;
+
+typedef struct selected_step_t {
+	char *job;
+	char *step;
+	uint32_t jobid;
+	uint32_t stepid;
+} jobacct_selected_step_t;
+
+struct jobacctinfo {
+	pid_t pid;
+	uint32_t sys_cpu_sec;
+	uint32_t sys_cpu_usec;
+	uint32_t user_cpu_sec;
+	uint32_t user_cpu_usec;
+	uint32_t max_vsize; /* max size of virtual memory */
+	jobacct_id_t max_vsize_id; /* contains which task number it was on */
+	uint32_t tot_vsize; /* total virtual memory 
+			       (used to figure out ave later) */
+	uint32_t max_rss; /* max Resident Set Size */
+	jobacct_id_t max_rss_id; /* contains which task it was on */
+	uint32_t tot_rss; /* total rss 
+			     (used to figure out ave later) */
+	uint32_t max_pages; /* max pages */
+	jobacct_id_t max_pages_id; /* contains which task it was on */
+	uint32_t tot_pages; /* total pages
+			     (used to figure out ave later) */ 
+	uint32_t min_cpu; /* min cpu time */
+	jobacct_id_t min_cpu_id; /* contains which task it was on */
+	uint32_t tot_cpu; /* total cpu time 
+				 (used to figure out ave later) */
+};
+
+/* Define jobacctinfo_t below to avoid including extraneous slurm headers */
+#ifndef __jobacctinfo_t_defined
+#  define  __jobacctinfo_t_defined
+   typedef struct jobacctinfo *jobacctinfo_t;     /* opaque data type */
+#endif
+
+extern jobacct_step_rec_t *create_jobacct_step_rec();
+extern jobacct_job_rec_t *create_jobacct_job_rec();
+extern void free_jobacct_header(void *object);
+extern void destroy_jobacct_job_rec(void *object);
+extern void destroy_jobacct_step_rec(void *object);
+extern void destroy_jobacct_selected_step(void *object);
+
+extern void pack_jobacct_job_rec(void *object, Buf buffer);
+extern int unpack_jobacct_job_rec(void **object, Buf buffer);
+ 
+extern void pack_jobacct_step_rec(jobacct_step_rec_t *step, Buf buffer);
+extern int unpack_jobacct_step_rec(jobacct_step_rec_t **step, Buf buffer);
+
+extern void pack_jobacct_selected_step(jobacct_selected_step_t *step,
+				       Buf buffer);
+extern int unpack_jobacct_selected_step(jobacct_selected_step_t **step,
+					Buf buffer);
+
+/* These should only be called from the jobacct-gather plugin */
+extern int jobacct_common_init_struct(struct jobacctinfo *jobacct, 
+				      jobacct_id_t *jobacct_id);
+extern struct jobacctinfo *jobacct_common_alloc_jobacct(
+	jobacct_id_t *jobacct_id);
+extern void jobacct_common_free_jobacct(void *object);
+extern int jobacct_common_setinfo(struct jobacctinfo *jobacct, 
+			  enum jobacct_data_type type, void *data);
+extern int jobacct_common_getinfo(struct jobacctinfo *jobacct, 
+			  enum jobacct_data_type type, void *data);
+extern void jobacct_common_aggregate(struct jobacctinfo *dest, 
+			     struct jobacctinfo *from);
+extern void jobacct_common_2_sacct(sacct_t *sacct,
+				   struct jobacctinfo *jobacct);
+extern void jobacct_common_pack(struct jobacctinfo *jobacct, Buf buffer);
+extern int jobacct_common_unpack(struct jobacctinfo **jobacct, Buf buffer);
+
+extern int jobacct_common_endpoll();
+extern int jobacct_common_set_proctrack_container_id(uint32_t id);
+extern int jobacct_common_set_mem_limit(uint32_t job_id, uint32_t mem_limit);
+extern int jobacct_common_add_task(pid_t pid, jobacct_id_t *jobacct_id);
+extern struct jobacctinfo *jobacct_common_stat_task(pid_t pid);
+extern struct jobacctinfo *jobacct_common_remove_task(pid_t pid);
+extern void jobacct_common_suspend_poll();
+extern void jobacct_common_resume_poll();
+/***************************************************************/
+
+
+/* defined in common_jobacct.c */
+extern bool jobacct_shutdown;
+extern bool jobacct_suspended;
+extern List task_list;
+extern pthread_mutex_t jobacct_lock;
+extern uint32_t cont_id;
+extern uint32_t acct_job_id;
+extern uint32_t job_mem_limit;	/* job's memory limit in KB */
+extern bool pgid_plugin;
+
+#endif
diff --git a/src/common/list.c b/src/common/list.c
index c55c69ce61bc98ad8177d1edf9ccc9b0e0b4e26e..3162fe01286aa486b939cfc6c2a12e98e5c9766e 100644
--- a/src/common/list.c
+++ b/src/common/list.c
@@ -63,6 +63,8 @@ strong_alias(list_destroy,	slurm_list_destroy);
 strong_alias(list_is_empty,	slurm_list_is_empty);
 strong_alias(list_count,	slurm_list_count);
 strong_alias(list_append,	slurm_list_append);
+strong_alias(list_append_list,	slurm_list_append_list);
+strong_alias(list_transfer,	slurm_list_transfer);
 strong_alias(list_prepend,	slurm_list_prepend);
 strong_alias(list_find_first,	slurm_list_find_first);
 strong_alias(list_delete_all,	slurm_list_delete_all);
@@ -80,7 +82,7 @@ strong_alias(list_next,		slurm_list_next);
 strong_alias(list_insert,	slurm_list_insert);
 strong_alias(list_find,		slurm_list_find);
 strong_alias(list_remove,	slurm_list_remove);
-strong_alias(list_delete,	slurm_list_delete);
+strong_alias(list_delete_item,	slurm_list_delete_item);
 strong_alias(list_install_fork_handlers, slurm_list_install_fork_handlers);
 /*********************
  *  lsd_fatal_error  *
@@ -369,6 +371,50 @@ list_append (List l, void *x)
 }
 
 
+int
+list_append_list (List l, List sub)
+{
+    ListIterator itr;
+    void *v;
+    int n = 0;
+    
+    assert(l != NULL);
+    assert(l->fDel == NULL);
+    assert(sub != NULL);
+    itr = list_iterator_create(sub);
+    while((v = list_next(itr))) {
+        if(list_append(l, v))
+	    n++;
+	else 
+	    break;
+    }
+    list_iterator_destroy(itr);
+    
+    return n;
+}
+
+int
+list_transfer (List l, List sub)
+{
+    void *v;
+    int n = 0;
+    
+    assert(l != NULL);
+    assert(sub != NULL);
+    assert(l->fDel == sub->fDel);
+    while((v = list_pop(sub))) {
+        if(list_append(l, v))
+	    n++;
+	else {
+	    if(l->fDel)
+		l->fDel(v);
+	    break;
+	}
+    }
+    
+    return n;
+}
+
 void *
 list_prepend (List l, void *x)
 {
@@ -457,6 +503,29 @@ list_for_each (List l, ListForF f, void *arg)
 }
 
 
+int
+list_flush (List l)
+{
+    ListNode *pp;
+    void *v;
+    int n = 0;
+
+    assert(l != NULL);
+    list_mutex_lock(&l->mutex);
+    assert(l->magic == LIST_MAGIC);
+    pp = &l->head;
+    while (*pp) {
+        if ((v = list_node_destroy(l, pp))) {
+            if (l->fDel)
+                l->fDel(v);
+	    n++;
+	}
+    }
+    list_mutex_unlock(&l->mutex);
+    return(n);
+}
+
+
 void
 list_sort (List l, ListCmpF f)
 {
@@ -501,7 +570,6 @@ list_sort (List l, ListCmpF f)
     return;
 }
 
-
 void *
 list_push (List l, void *x)
 {
@@ -697,7 +765,7 @@ list_remove (ListIterator i)
 
 
 int
-list_delete (ListIterator i)
+list_delete_item (ListIterator i)
 {
     void *v;
 
diff --git a/src/common/list.h b/src/common/list.h
index d9efbd693e6c2da9baf3ed1036d80ae9c36fa4fd..9039c8fd65116c09d2fe037820773d4803c913ed 100644
--- a/src/common/list.h
+++ b/src/common/list.h
@@ -145,6 +145,21 @@ void * list_append (List l, void *x);
  *  Returns the data's ptr, or lsd_nomem_error() if insertion failed.
  */
 
+int list_append_list (List l, List sub);
+/*
+ *  Inserts list [sub] at the end of list [l].
+ *  Note: list [l] must have a destroy function of NULL.
+ *  Returns a count of the number of items added to list [l].
+ */
+
+int list_transfer (List l, List sub);
+/*
+ *  Pops off list [sub] and appends data at the end of list [l].
+ *  Note: list [l] must have the same destroy function as list [sub].
+ *  Note: list [sub] will be returned empty, but not destroyed.
+ *  Returns a count of the number of items added to list [l].
+ */
+
 void * list_prepend (List l, void *x);
 /*
  *  Inserts data [x] at the beginning of list [l].
@@ -178,6 +193,14 @@ int list_for_each (List l, ListForF f, void *arg);
  *    function returns the negative of that item's position in the list.
  */
 
+int list_flush (List l);
+/*
+ *  Traverses list [l] and removes all items in list
+ *  If a deletion function was specified when the list was
+ *  created, it will be called to deallocate each item being removed.
+ *  Returns a count of the number of items removed from the list.
+ */
+
 void list_sort (List l, ListCmpF f);
 /*
  *  Sorts list [l] into ascending order according to the function [f].
@@ -185,7 +208,6 @@ void list_sort (List l, ListCmpF f);
  *  Note: The sort algorithm is stable.
  */
 
-
 /****************************
  *  Stack Access Functions  *
  ****************************/
@@ -281,7 +303,7 @@ void * list_remove (ListIterator i);
  *  Note: The client is responsible for freeing the returned data.
  */
 
-int list_delete (ListIterator i);
+int list_delete_item (ListIterator i);
 /*
  *  Removes from the list the last item returned via list iterator [i];
  *    if a deletion function was specified when the list was created,
diff --git a/src/common/log.c b/src/common/log.c
index 9493af549b8d5c8db6615ae67409f3904c849cfb..7a6acc7e046c1c886cb516ad2586d1fd1ab5edbd 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  log.c - slurm logging facilities
- *  $Id: log.c 12825 2007-12-14 21:23:57Z jette $
+ *  $Id: log.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  Much of this code was derived or adapted from the log.c component of 
  *  openssh which contains the following notices:
diff --git a/src/common/log.h b/src/common/log.h
index b257b138cd99f33d347885909e8dff3a3f09fedf..e159a9b76627e9393cb0b0dce24d6cab2040b39b 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  Much of this code was derived or adapted from the log.c component of 
  *  openssh which contains the following notices:
diff --git a/src/common/macros.h b/src/common/macros.h
index ac4b53eaa920d04773135babfbf8759a97b1a2f5..a2492f767f12f65aafacef6403efb6b4ff6d9ac3 100644
--- a/src/common/macros.h
+++ b/src/common/macros.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/common/macros.h - some standard macros for slurm
- * $Id: macros.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: macros.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/mpi.c b/src/common/mpi.c
index 4d54fbf5e379340a48544e39fbeb30fde1235ba5..ace6fab970aa28395bbb459a8788296f6c6a617f 100644
--- a/src/common/mpi.c
+++ b/src/common/mpi.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondo1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/mpi.h b/src/common/mpi.h
index 8a6dc7af65f9c1f55fbdb499a5cebd4c1b23ed04..75255181a4e1a6a2d137d08e9fbdca95cb9ebe11 100644
--- a/src/common/mpi.h
+++ b/src/common/mpi.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondo1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/net.c b/src/common/net.c
index 59a6329dc5b7e9c533c220a19935146e6882e59d..5fb33c058f8c3e0cc0b5c407ee0561f537d8de15 100644
--- a/src/common/net.c
+++ b/src/common/net.c
@@ -5,7 +5,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, Kevin Tew <tew1@llnl.gov>, 
  *  et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/net.h b/src/common/net.h
index 94bdf6d8a94945e7a520f6858557d87dfc8c47e5..7b5e8548bef736526333be177cdbafb63630cb10 100644
--- a/src/common/net.h
+++ b/src/common/net.h
@@ -5,7 +5,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, Kevin Tew <tew1@llnl.gov>,
  *  et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/node_select.c b/src/common/node_select.c
index ede1c38fcfb1b80684b1afd52ed25c7b35e88c4f..d247fbd4d70c1fc37c5cf7675e5c3301358f7ef7 100644
--- a/src/common/node_select.c
+++ b/src/common/node_select.c
@@ -9,12 +9,12 @@
  *  the plugin. This is because functions required by the plugin can not be 
  *  resolved on the front-end nodes, so we can't load the plugins there.
  *
- *  $Id: node_select.c 13270 2008-02-14 19:40:44Z da $
+ *  $Id: node_select.c 13697 2008-03-21 21:56:40Z da $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -81,12 +81,15 @@ typedef struct slurm_select_ops {
 						uint32_t min_nodes, 
 						uint32_t max_nodes,
 						uint32_t req_nodes,
-						bool test_only);
+						int mode);
+	int             (*job_list_test)       (List req_list);
 	int		(*job_begin)	       (struct job_record *job_ptr);
 	int		(*job_ready)	       (struct job_record *job_ptr);
 	int		(*job_fini)	       (struct job_record *job_ptr);
 	int		(*job_suspend)	       (struct job_record *job_ptr);
 	int		(*job_resume)	       (struct job_record *job_ptr);
+	int		(*get_job_cores)       (uint32_t job_id,
+						int alloc_index, int s);
 	int		(*pack_node_info)      (time_t last_query_time,
 						Buf *buffer_ptr);
         int             (*get_extra_jobinfo)   (struct node_record *node_ptr,
@@ -106,6 +109,9 @@ typedef struct slurm_select_ops {
 	int             (*update_node_state)   (int index, uint16_t state);
 	int             (*alter_node_cnt)      (enum select_node_cnt type,
 						void *data);
+	int		(*reconfigure)         (void);
+	int		(*step_begin)          (struct step_record *step_ptr);
+	int		(*step_fini)           (struct step_record *step_ptr);
 } slurm_select_ops_t;
 
 typedef struct slurm_select_context {
@@ -132,6 +138,7 @@ struct select_jobinfo {
 	uint16_t rotate;	/* permit geometry rotation if set */
 	char *bg_block_id;	/* Blue Gene block ID */
 	uint16_t magic;		/* magic number */
+	char *nodes;            /* node list given for estimated start */ 
 	char *ionodes;          /* for bg to tell which ionodes of a small
 				 * block the job is running */ 
 	uint32_t node_cnt;      /* how many cnodes in block */ 
@@ -167,11 +174,13 @@ static slurm_select_ops_t * _select_get_ops(slurm_select_context_t *c)
 		"select_p_node_init",
 		"select_p_block_init",
 		"select_p_job_test",
+		"select_p_job_list_test",
 		"select_p_job_begin",
 		"select_p_job_ready",
 		"select_p_job_fini",
 		"select_p_job_suspend",
 		"select_p_job_resume",
+		"select_p_get_job_cores",
 		"select_p_pack_node_info",
                 "select_p_get_extra_jobinfo",
                 "select_p_get_select_nodeinfo",
@@ -180,7 +189,10 @@ static slurm_select_ops_t * _select_get_ops(slurm_select_context_t *c)
  		"select_p_update_sub_node",
                 "select_p_get_info_from_plugin",
 		"select_p_update_node_state",
-		"select_p_alter_node_cnt"
+		"select_p_alter_node_cnt",
+		"select_p_reconfigure",
+		"select_p_step_begin",
+		"select_p_step_fini",
 	};
 	int n_syms = sizeof( syms ) / sizeof( char * );
 
@@ -499,26 +511,61 @@ extern int select_g_alter_node_cnt (enum select_node_cnt type, void *data)
 	return (*(g_select_context->ops.alter_node_cnt))(type, data);
 }
 
+/*
+ * Note reconfiguration or change in partition configuration
+ */
+extern int select_g_reconfigure (void)
+{
+	if (slurm_select_init() < 0)
+		return SLURM_ERROR;
+
+	return (*(g_select_context->ops.reconfigure))();
+}
+
 /*
  * Select the "best" nodes for given job from those available
- * IN job_ptr - pointer to job being considered for initiation
+ * IN/OUT job_ptr - pointer to job being considered for initiation,
+ *                  set's start_time when job expected to start
  * IN/OUT bitmap - map of nodes being considered for allocation on input,
  *                 map of nodes actually to be assigned on output
  * IN min_nodes - minimum number of nodes to allocate to job
  * IN max_nodes - maximum number of nodes to allocate to job
  * IN req_nodes - requested (or desired) count of nodes
- * IN test_only - if true, only test if ever could run, not necessarily now 
+ * IN mode - SELECT_MODE_RUN_NOW: try to schedule job now
+ *           SELECT_MODE_TEST_ONLY: test if job can ever run
+ *           SELECT_MODE_WILL_RUN: determine when and where job can run
+ * RET zero on success, EINVAL otherwise
  */
 extern int select_g_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
-		uint32_t min_nodes, uint32_t max_nodes, uint32_t req_nodes, 
-		bool test_only)
+			     uint32_t min_nodes, uint32_t max_nodes, 
+			     uint32_t req_nodes, int mode)
 {
 	if (slurm_select_init() < 0)
 		return SLURM_ERROR;
 
 	return (*(g_select_context->ops.job_test))(job_ptr, bitmap, 
 						   min_nodes, max_nodes, 
-						   req_nodes, test_only);
+						   req_nodes, mode);
+}
+
+/*
+ * Given a list of select_will_run_t's in
+ * accending priority order we will see if we can start and
+ * finish all the jobs without increasing the start times of the
+ * jobs specified and fill in the est_start of requests with no
+ * est_start.  If you are looking to see if one job will ever run
+ * then use select_p_job_test instead.
+ * IN/OUT req_list - list of select_will_run_t's in asscending
+ *	             priority order on success of placement fill in
+ *	             est_start of request with time.
+ * RET zero on success, EINVAL otherwise
+ */
+extern int select_g_job_list_test(List req_list) 
+{
+	if (slurm_select_init() < 0)
+		return SLURM_ERROR;
+
+	return (*(g_select_context->ops.job_list_test))(req_list);
 }
 
 /*
@@ -559,6 +606,7 @@ extern int select_g_job_fini(struct job_record *job_ptr)
 
 	return (*(g_select_context->ops.job_fini))(job_ptr);
 }
+
 /*
  * Suspend a job. Executed from slurmctld.
  * IN job_ptr - pointer to job being suspended
@@ -585,6 +633,21 @@ extern int select_g_job_resume(struct job_record *job_ptr)
 	return (*(g_select_context->ops.job_resume))(job_ptr);
 }
 
+/*
+ * Get job core info. Executed from sched/gang.
+ * IN job_id      - id of job from which to obtain data
+ * IN alloc_index - allocated node index
+ * IN s           - socket index
+ * RET number of allocated cores on the given socket from the given node
+ */
+extern int select_g_get_job_cores(uint32_t job_id, int alloc_index, int s)
+{
+	if (slurm_select_init() < 0)
+		return 0;
+
+	return (*(g_select_context->ops.get_job_cores))(job_id, alloc_index, s);
+}
+
 extern int select_g_pack_node_info(time_t last_query_time, Buf *buffer)
 {
 	if (slurm_select_init() < 0)
@@ -594,6 +657,28 @@ extern int select_g_pack_node_info(time_t last_query_time, Buf *buffer)
 		(last_query_time, buffer);
 }
 
+/* Prepare to start a job step, allocate memory as needed
+ * RET - slurm error code
+ */
+extern int select_g_step_begin(struct step_record *step_ptr)
+{
+	if (slurm_select_init() < 0)
+		return SLURM_ERROR;
+
+	return (*(g_select_context->ops.step_begin))(step_ptr);
+}
+
+/* Prepare to terminate a job step, release memory as needed
+ * RET - slurm error code
+ */
+extern int select_g_step_fini(struct step_record *step_ptr)
+{
+	if (slurm_select_init() < 0)
+		return SLURM_ERROR;
+
+	return (*(g_select_context->ops.step_fini))(step_ptr);
+}
+
 #ifdef HAVE_BG		/* node selection specific logic */
 static void _free_node_info(bg_info_record_t *bg_info_record)
 {
@@ -619,14 +704,12 @@ static int _unpack_node_info(bg_info_record_t *bg_info_record, Buf buffer)
 	uint32_t uint32_tmp;
 	char *bp_inx_str;
 	
-	safe_unpackstr_xmalloc(&(bg_info_record->nodes), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(bg_info_record->ionodes), &uint16_tmp,
-			       buffer);
-	safe_unpackstr_xmalloc(&bg_info_record->owner_name, &uint16_tmp, 
-			       buffer);
-	safe_unpackstr_xmalloc(&bg_info_record->bg_block_id, &uint16_tmp, 
-			       buffer);
-
+	safe_unpackstr_xmalloc(&(bg_info_record->nodes), &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(bg_info_record->ionodes), &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&bg_info_record->owner_name,
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&bg_info_record->bg_block_id,
+			       &uint32_tmp, buffer);
 	safe_unpack16(&uint16_tmp, buffer);
 	bg_info_record->state     = (int) uint16_tmp;
 	safe_unpack16(&uint16_tmp, buffer);
@@ -639,32 +722,33 @@ static int _unpack_node_info(bg_info_record_t *bg_info_record, Buf buffer)
 	bg_info_record->nodecard = (int) uint16_tmp;
 	safe_unpack32(&uint32_tmp, buffer);
 	bg_info_record->node_cnt = (int) uint32_tmp;
-	safe_unpackstr_xmalloc(&bp_inx_str, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&bp_inx_str, &uint32_tmp, buffer);
 	if (bp_inx_str == NULL) {
 		bg_info_record->bp_inx = bitfmt2int("");
 	} else {
 		bg_info_record->bp_inx = bitfmt2int(bp_inx_str);
 		xfree(bp_inx_str);
 	}
-	safe_unpackstr_xmalloc(&bp_inx_str, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&bp_inx_str, &uint32_tmp, buffer);
 	if (bp_inx_str == NULL) {
 		bg_info_record->ionode_inx = bitfmt2int("");
 	} else {
 		bg_info_record->ionode_inx = bitfmt2int(bp_inx_str);
 		xfree(bp_inx_str);
 	}
-	safe_unpackstr_xmalloc(&bg_info_record->blrtsimage, &uint16_tmp, 
+	safe_unpackstr_xmalloc(&bg_info_record->blrtsimage,   &uint32_tmp, 
 			       buffer);
-	safe_unpackstr_xmalloc(&bg_info_record->linuximage, &uint16_tmp, 
+	safe_unpackstr_xmalloc(&bg_info_record->linuximage,   &uint32_tmp, 
 			       buffer);
-	safe_unpackstr_xmalloc(&bg_info_record->mloaderimage, &uint16_tmp, 
+	safe_unpackstr_xmalloc(&bg_info_record->mloaderimage, &uint32_tmp, 
 			       buffer);
-	safe_unpackstr_xmalloc(&bg_info_record->ramdiskimage, &uint16_tmp, 
+	safe_unpackstr_xmalloc(&bg_info_record->ramdiskimage, &uint32_tmp, 
 			       buffer);
-
+	
 	return SLURM_SUCCESS;
 
 unpack_error:
+	error("_unpack_node_info: error unpacking here");
 	_free_node_info(bg_info_record);
 	return SLURM_ERROR;
 }
@@ -711,6 +795,7 @@ extern int select_g_alloc_jobinfo (select_jobinfo_t *jobinfo)
 	(*jobinfo)->rotate = (uint16_t) NO_VAL;
 	(*jobinfo)->bg_block_id = NULL;
 	(*jobinfo)->magic = JOBINFO_MAGIC;
+	(*jobinfo)->nodes = NULL;
 	(*jobinfo)->ionodes = NULL;
 	(*jobinfo)->node_cnt = NO_VAL;
 	(*jobinfo)->max_procs =  NO_VAL;
@@ -767,6 +852,10 @@ extern int select_g_set_jobinfo (select_jobinfo_t jobinfo,
 		xfree(jobinfo->bg_block_id);
 		jobinfo->bg_block_id = xstrdup(tmp_char);
 		break;
+	case SELECT_DATA_NODES:
+		xfree(jobinfo->nodes);
+		jobinfo->nodes = xstrdup(tmp_char);
+		break;
 	case SELECT_DATA_IONODES:
 		xfree(jobinfo->ionodes);
 		jobinfo->ionodes = xstrdup(tmp_char);
@@ -858,6 +947,13 @@ extern int select_g_get_jobinfo (select_jobinfo_t jobinfo,
 		else
 			*tmp_char = xstrdup(jobinfo->bg_block_id);
 		break;
+	case SELECT_DATA_NODES:
+		if ((jobinfo->nodes == NULL)
+		    ||  (jobinfo->nodes[0] == '\0'))
+			*tmp_char = NULL;
+		else
+			*tmp_char = xstrdup(jobinfo->nodes);
+		break;
 	case SELECT_DATA_IONODES:
 		if ((jobinfo->ionodes == NULL)
 		    ||  (jobinfo->ionodes[0] == '\0'))
@@ -937,6 +1033,7 @@ extern select_jobinfo_t select_g_copy_jobinfo(select_jobinfo_t jobinfo)
 		rc->rotate = jobinfo->rotate;
 		rc->bg_block_id = xstrdup(jobinfo->bg_block_id);
 		rc->magic = JOBINFO_MAGIC;
+		rc->nodes = xstrdup(jobinfo->nodes);
 		rc->ionodes = xstrdup(jobinfo->ionodes);
 		rc->node_cnt = jobinfo->node_cnt;
 		rc->altered = jobinfo->altered;
@@ -945,7 +1042,6 @@ extern select_jobinfo_t select_g_copy_jobinfo(select_jobinfo_t jobinfo)
 		rc->linuximage = xstrdup(jobinfo->linuximage);
 		rc->mloaderimage = xstrdup(jobinfo->mloaderimage);
 		rc->ramdiskimage = xstrdup(jobinfo->ramdiskimage);
-		
 	}
 
 	return rc;
@@ -967,6 +1063,7 @@ extern int select_g_free_jobinfo  (select_jobinfo_t *jobinfo)
 	} else {
 		(*jobinfo)->magic = 0;
 		xfree((*jobinfo)->bg_block_id);
+		xfree((*jobinfo)->nodes);
 		xfree((*jobinfo)->ionodes);
 		xfree((*jobinfo)->blrtsimage);
 		xfree((*jobinfo)->linuximage);
@@ -1001,24 +1098,29 @@ extern int  select_g_pack_jobinfo  (select_jobinfo_t jobinfo, Buf buffer)
 		pack32(jobinfo->max_procs, buffer);
 
 		packstr(jobinfo->bg_block_id, buffer);
+		packstr(jobinfo->nodes, buffer);
 		packstr(jobinfo->ionodes, buffer);
 		packstr(jobinfo->blrtsimage, buffer);
 		packstr(jobinfo->linuximage, buffer);
 		packstr(jobinfo->mloaderimage, buffer);
 		packstr(jobinfo->ramdiskimage, buffer);
 	} else {
+		/* pack space for 3 positions for start and for geo
+		 * then 1 for conn_type, reboot, and rotate
+		 */
 		for (i=0; i<((SYSTEM_DIMENSIONS*2)+3); i++)
 			pack16((uint16_t) 0, buffer);
 
-		pack32((uint32_t) 0, buffer);
-		pack32((uint32_t) 0, buffer);
+		pack32((uint32_t) 0, buffer); //node_cnt
+		pack32((uint32_t) 0, buffer); //max_procs
 
-		packstr("", buffer);
-		packstr("", buffer);
-		packstr("", buffer);
-		packstr("", buffer);
-		packstr("", buffer);
-		packstr("", buffer);
+		packnull(buffer); //bg_block_id
+		packnull(buffer); //nodes
+		packnull(buffer); //ionodes
+		packnull(buffer); //blrts
+		packnull(buffer); //linux
+		packnull(buffer); //mloader
+		packnull(buffer); //ramdisk
 	}
 
 	return SLURM_SUCCESS;
@@ -1033,7 +1135,7 @@ extern int  select_g_pack_jobinfo  (select_jobinfo_t jobinfo, Buf buffer)
 extern int  select_g_unpack_jobinfo(select_jobinfo_t jobinfo, Buf buffer)
 {
 	int i;
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 
 	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
 		safe_unpack16(&(jobinfo->start[i]), buffer);
@@ -1046,13 +1148,14 @@ extern int  select_g_unpack_jobinfo(select_jobinfo_t jobinfo, Buf buffer)
 	safe_unpack32(&(jobinfo->node_cnt), buffer);
 	safe_unpack32(&(jobinfo->max_procs), buffer);
 
-	safe_unpackstr_xmalloc(&(jobinfo->bg_block_id), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(jobinfo->ionodes), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(jobinfo->blrtsimage), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(jobinfo->linuximage), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(jobinfo->mloaderimage), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(jobinfo->ramdiskimage), &uint16_tmp, buffer);
-
+	safe_unpackstr_xmalloc(&(jobinfo->bg_block_id),  &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(jobinfo->nodes),      &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(jobinfo->ionodes),      &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(jobinfo->blrtsimage),   &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(jobinfo->linuximage),   &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(jobinfo->mloaderimage), &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(jobinfo->ramdiskimage), &uint32_tmp, buffer);
+	
 	return SLURM_SUCCESS;
 
       unpack_error:
@@ -1162,6 +1265,13 @@ extern char *select_g_sprint_jobinfo(select_jobinfo_t jobinfo,
 	case SELECT_PRINT_BG_ID:
 		snprintf(buf, size, "%s", jobinfo->bg_block_id);
 		break;
+	case SELECT_PRINT_NODES:
+		if(jobinfo->ionodes && jobinfo->ionodes[0]) 
+			snprintf(buf, size, "%s[%s]",
+				 jobinfo->nodes, jobinfo->ionodes);
+		else
+			snprintf(buf, size, "%s", jobinfo->nodes);
+		break;
 	case SELECT_PRINT_CONNECTION:
 		snprintf(buf, size, "%s", 
 			 _job_conn_type_string(jobinfo->conn_type));
diff --git a/src/common/node_select.h b/src/common/node_select.h
index 281fca31303bdf80fbe3f86911144f7256ab3f75..46e1defa2b2537fd655995b1f35ca2fa0beafb09 100644
--- a/src/common/node_select.h
+++ b/src/common/node_select.h
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  node_select.h - Define node selection plugin functions.
  *
- * $Id: node_select.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: node_select.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -46,6 +46,21 @@
 #include <slurm/slurm.h>
 #include <slurm/slurm_errno.h>
 
+typedef struct {
+	bitstr_t *avail_nodes;      /* usable nodes are set on input, nodes
+				     * not required to satisfy the request
+				     * are cleared, other left set */
+	struct job_record *job_ptr; /* pointer to job being scheduled
+				     * start_time is set when we can
+				     * possibly start job. Or must not
+				     * increase for success of running
+				     * other jobs.
+				     */
+	uint32_t max_nodes;         /* maximum count of nodes (0==don't care) */
+	uint32_t min_nodes;         /* minimum count of nodes */
+	uint32_t req_nodes;         /* requested (or desired) count of nodes */
+} select_will_run_t;
+
 /*****************************************\
  * GLOBAL SELECT STATE MANGEMENT FUNCIONS *
 \*****************************************/
@@ -152,19 +167,42 @@ extern int select_g_block_init(List part_list);
  * JOB-SPECIFIC SELECT CREDENTIAL MANAGEMENT FUNCIONS *
 \******************************************************/
 
+#define SELECT_MODE_RUN_NOW	0
+#define SELECT_MODE_TEST_ONLY	1
+#define SELECT_MODE_WILL_RUN	2
+
 /*
  * Select the "best" nodes for given job from those available
- * IN job_ptr - pointer to job being considered for initiation
+ * IN/OUT job_ptr - pointer to job being considered for initiation,
+ *                  set's start_time when job expected to start
  * IN/OUT bitmap - map of nodes being considered for allocation on input,
  *                 map of nodes actually to be assigned on output
  * IN min_nodes - minimum number of nodes to allocate to job
  * IN max_nodes - maximum number of nodes to allocate to job
  * IN req_nodes - requested (or desired) count of nodes
- * IN test_only - if true, only test if ever could run, not necessarily now
+ * IN mode - SELECT_MODE_RUN_NOW: try to schedule job now
+ *           SELECT_MODE_TEST_ONLY: test if job can ever run
+ *           SELECT_MODE_WILL_RUN: determine when and where job can run
+ * RET zero on success, EINVAL otherwise
  */
 extern int select_g_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 			uint32_t min_nodes, uint32_t max_nodes, 
-			uint32_t req_nodes, bool test_only);
+			uint32_t req_nodes, int mode);
+
+
+/*
+ * Given a list of select_will_run_t's in
+ * accending priority order we will see if we can start and
+ * finish all the jobs without increasing the start times of the
+ * jobs specified and fill in the est_start of requests with no
+ * est_start.  If you are looking to see if one job will ever run
+ * then use select_p_job_test instead.
+ * IN/OUT req_list - list of select_will_run_t's in asscending
+ *	             priority order on success of placement fill in
+ *	             est_start of request with time.
+ * RET zero on success, EINVAL otherwise
+ */
+extern int select_g_job_list_test(List req_list);
 
 /*
  * Note initiation of job is about to begin. Called immediately 
@@ -200,6 +238,14 @@ extern int select_g_job_suspend(struct job_record *job_ptr);
  */
 extern int select_g_job_resume(struct job_record *job_ptr);
 
+/*
+ * Get number of allocated cores per socket from a job
+ * IN job_id      - identifies the job
+ * IN alloc_index - allocated node index
+ * IN s           - socket index
+ */
+extern int select_g_get_job_cores(uint32_t job_id, int alloc_index, int s);
+
 /* allocate storage for a select job credential
  * OUT jobinfo - storage for a select job credential
  * RET         - slurm error code
@@ -274,6 +320,16 @@ extern int  select_g_unpack_jobinfo(select_jobinfo_t jobinfo, Buf buffer);
 extern char *select_g_sprint_jobinfo(select_jobinfo_t jobinfo,
 				     char *buf, size_t size, int mode);
 
+/* Prepare to start a job step, allocate memory as needed
+ * RET - slurm error code
+ */
+extern int select_g_step_begin(struct step_record *step_ptr);
+
+/* Prepare to terminate a job step, release memory as needed
+ * RET - slurm error code
+ */
+extern int select_g_step_fini(struct step_record *step_ptr);
+
 /******************************************************\
  * NODE-SELECT PLUGIN SPECIFIC INFORMATION FUNCTIONS  *
 \******************************************************/
@@ -294,4 +350,7 @@ extern int select_g_unpack_node_info(node_select_info_msg_t **
 extern int select_g_free_node_info(node_select_info_msg_t **
 				   node_select_info_msg_pptr);
 
+/* Note reconfiguration or change in partition configuration */
+extern int select_g_reconfigure(void);
+
 #endif /*__SELECT_PLUGIN_API_H__*/
diff --git a/src/common/optz.c b/src/common/optz.c
index f8afe22384f11e8475357f053e83266bf2e1b8f7..ec9d67d84bcfd684fc229dfc7d1f899197b981f4 100644
--- a/src/common/optz.c
+++ b/src/common/optz.c
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/optz.h b/src/common/optz.h
index 4898b4d6e10059d0013e482bd9e46773145e71c5..07cf1b257546841b2440b9fe5ea446df6627e85b 100644
--- a/src/common/optz.h
+++ b/src/common/optz.h
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/pack.c b/src/common/pack.c
index 50bbe43d9eb9734cd400304130373ae55b32704b..53902756f17b2e44a7b0d21658ce656fda389346 100644
--- a/src/common/pack.c
+++ b/src/common/pack.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick@llnl.gov>, 
  *             Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -333,9 +333,9 @@ int unpack8(uint8_t * valp, Buf buffer)
  * size_val to network byte order and store at buffer followed by 
  * the data at valp. Adjust buffer counters.
  */
-void packmem(char *valp, uint16_t size_val, Buf buffer)
+void packmem(char *valp, uint32_t size_val, Buf buffer)
 {
-	uint16_t ns = htons(size_val);
+	uint32_t ns = htonl(size_val);
 
 	if (remaining_buf(buffer) < (sizeof(ns) + size_val)) {
 		buffer->size += (size_val + BUF_SIZE);
@@ -360,15 +360,15 @@ void packmem(char *valp, uint16_t size_val, Buf buffer)
  * NOTE: valp is set to point into the buffer bufp, a copy of 
  *	the data is not made
  */
-int unpackmem_ptr(char **valp, uint16_t * size_valp, Buf buffer)
+int unpackmem_ptr(char **valp, uint32_t * size_valp, Buf buffer)
 {
-	uint16_t ns;
+	uint32_t ns;
 
 	if (remaining_buf(buffer) < sizeof(ns))
 		return SLURM_ERROR;
 
 	memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns));
-	*size_valp = ntohs(ns);
+	*size_valp = ntohl(ns);
 	buffer->processed += sizeof(ns);
 
 	if (*size_valp > 0) {
@@ -390,15 +390,15 @@ int unpackmem_ptr(char **valp, uint16_t * size_valp, Buf buffer)
  * NOTE: The caller is responsible for the management of valp and 
  * insuring it has sufficient size
  */
-int unpackmem(char *valp, uint16_t * size_valp, Buf buffer)
+int unpackmem(char *valp, uint32_t * size_valp, Buf buffer)
 {
-	uint16_t ns;
+	uint32_t ns;
 
 	if (remaining_buf(buffer) < sizeof(ns))
 		return SLURM_ERROR;
 
 	memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns));
-	*size_valp = ntohs(ns);
+	*size_valp = ntohl(ns);
 	buffer->processed += sizeof(ns);
 
 	if (*size_valp > 0) {
@@ -420,15 +420,15 @@ int unpackmem(char *valp, uint16_t * size_valp, Buf buffer)
  *	the caller is responsible for calling xfree() on *valp
  *	if non-NULL (set to NULL on zero size buffer value)
  */
-int unpackmem_xmalloc(char **valp, uint16_t * size_valp, Buf buffer)
+int unpackmem_xmalloc(char **valp, uint32_t * size_valp, Buf buffer)
 {
-	uint16_t ns;
+	uint32_t ns;
 
 	if (remaining_buf(buffer) < sizeof(ns))
 		return SLURM_ERROR;
 
 	memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns));
-	*size_valp = ntohs(ns);
+	*size_valp = ntohl(ns);
 	buffer->processed += sizeof(ns);
 
 	if (*size_valp > 0) {
@@ -452,15 +452,15 @@ int unpackmem_xmalloc(char **valp, uint16_t * size_valp, Buf buffer)
  *	the caller is responsible for calling free() on *valp
  *	if non-NULL (set to NULL on zero size buffer value)
  */
-int unpackmem_malloc(char **valp, uint16_t * size_valp, Buf buffer)
+int unpackmem_malloc(char **valp, uint32_t * size_valp, Buf buffer)
 {
-	uint16_t ns;
+	uint32_t ns;
 
 	if (remaining_buf(buffer) < sizeof(ns))
 		return SLURM_ERROR;
 
 	memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns));
-	*size_valp = ntohs(ns);
+	*size_valp = ntohl(ns);
 	buffer->processed += sizeof(ns);
 
 	if (*size_valp > 0) {
@@ -480,10 +480,10 @@ int unpackmem_malloc(char **valp, uint16_t * size_valp, Buf buffer)
  * (size_val), convert size_val to network byte order and store in the  
  * buffer followed by the data at valp. Adjust buffer counters. 
  */
-void packstr_array(char **valp, uint16_t size_val, Buf buffer)
+void packstr_array(char **valp, uint32_t size_val, Buf buffer)
 {
 	int i;
-	uint16_t ns = htons(size_val);
+	uint32_t ns = htonl(size_val);
 
 	if (remaining_buf(buffer) < sizeof(ns)) {
 		buffer->size += BUF_SIZE;
@@ -507,23 +507,23 @@ void packstr_array(char **valp, uint16_t size_val, Buf buffer)
  *	the caller is responsible for calling xfree on *valp
  *	if non-NULL (set to NULL on zero size buffer value)
  */
-int unpackstr_array(char ***valp, uint16_t * size_valp, Buf buffer)
+int unpackstr_array(char ***valp, uint32_t * size_valp, Buf buffer)
 {
 	int i;
-	uint16_t ns;
-	uint16_t uint16_tmp;
+	uint32_t ns;
+	uint32_t uint32_tmp;
 
 	if (remaining_buf(buffer) < sizeof(ns))
 		return SLURM_ERROR;
 
 	memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns));
-	*size_valp = ntohs(ns);
+	*size_valp = ntohl(ns);
 	buffer->processed += sizeof(ns);
 
 	if (*size_valp > 0) {
 		*valp = xmalloc(sizeof(char *) * (*size_valp + 1));
 		for (i = 0; i < *size_valp; i++) {
-			if (unpackmem_xmalloc(&(*valp)[i], &uint16_tmp, buffer))
+			if (unpackmem_xmalloc(&(*valp)[i], &uint32_tmp, buffer))
 				return SLURM_ERROR;
 		}
 		(*valp)[i] = NULL;	/* NULL terminated array so that execle */
diff --git a/src/common/pack.h b/src/common/pack.h
index fd5b8e6bb5319853f504ef2cffcc9d1f615c7739..4b18355e9c46e703c06cb6d55d14b91a4374d40a 100644
--- a/src/common/pack.h
+++ b/src/common/pack.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -98,14 +98,14 @@ int     unpack16_array(uint16_t **valp, uint32_t* size_val, Buf buffer);
 void	pack32_array(uint32_t *valp, uint32_t size_val, Buf buffer);
 int	unpack32_array(uint32_t **valp, uint32_t* size_val, Buf buffer);
 
-void	packmem(char *valp, uint16_t size_val, Buf buffer);
-int	unpackmem(char *valp, uint16_t *size_valp, Buf buffer);
-int	unpackmem_ptr(char **valp, uint16_t *size_valp, Buf buffer);
-int	unpackmem_xmalloc(char **valp, uint16_t *size_valp, Buf buffer);
-int	unpackmem_malloc(char **valp, uint16_t *size_valp, Buf buffer);
+void	packmem(char *valp, uint32_t size_val, Buf buffer);
+int	unpackmem(char *valp, uint32_t *size_valp, Buf buffer);
+int	unpackmem_ptr(char **valp, uint32_t *size_valp, Buf buffer);
+int	unpackmem_xmalloc(char **valp, uint32_t *size_valp, Buf buffer);
+int	unpackmem_malloc(char **valp, uint32_t *size_valp, Buf buffer);
 
-void	packstr_array(char **valp, uint16_t size_val, Buf buffer);
-int	unpackstr_array(char ***valp, uint16_t* size_val, Buf buffer);
+void	packstr_array(char **valp, uint32_t size_val, Buf buffer);
+int	unpackstr_array(char ***valp, uint32_t* size_val, Buf buffer);
 
 void	packmem_array(char *valp, uint32_t size_val, Buf buffer);
 int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
@@ -189,7 +189,7 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 } while (0)
 
 #define safe_packmem(valp,size_val,buf) do {		\
-	assert(sizeof(size_val) == sizeof(uint16_t)); 	\
+	assert(sizeof(size_val) == sizeof(uint32_t)); 	\
 	assert(size_val == 0 || valp != NULL);		\
 	assert(buf->magic == BUF_MAGIC);		\
 	packmem(valp,size_val,buf);			\
@@ -197,7 +197,7 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 
 #define safe_unpackmem(valp,size_valp,buf) do {		\
 	assert(valp != NULL);		                \
-	assert(sizeof(*size_valp) == sizeof(uint16_t)); \
+	assert(sizeof(*size_valp) == sizeof(uint32_t)); \
 	assert(buf->magic == BUF_MAGIC);		\
 	if (unpackmem(valp,size_valp,buf))		\
 		goto unpack_error;			\
@@ -205,7 +205,7 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 
 #define safe_unpackmem_ptr(valp,size_valp,buf) do {	\
 	assert(valp != NULL);				\
-	assert(sizeof(*size_valp) == sizeof(uint16_t)); \
+	assert(sizeof(*size_valp) == sizeof(uint32_t)); \
 	assert(buf->magic == BUF_MAGIC);		\
 	if (unpackmem_ptr(valp,size_valp,buf))		\
 		goto unpack_error;			\
@@ -213,7 +213,7 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 
 #define safe_unpackmem_xmalloc(valp,size_valp,buf) do {	\
 	assert(valp != NULL);				\
-	assert(sizeof(*size_valp) == sizeof(uint16_t)); \
+	assert(sizeof(*size_valp) == sizeof(uint32_t)); \
 	assert(buf->magic == BUF_MAGIC);		\
 	if (unpackmem_xmalloc(valp,size_valp,buf))	\
 		goto unpack_error;			\
@@ -221,7 +221,7 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 
 #define safe_unpackmem_malloc(valp,size_valp,buf) do {	\
 	assert(valp != NULL);				\
-	assert(sizeof(*size_valp) == sizeof(uint16_t)); \
+	assert(sizeof(*size_valp) == sizeof(uint32_t)); \
 	assert(buf->magic == BUF_MAGIC);		\
 	if (unpackmem_malloc(valp,size_valp,buf))	\
 		goto unpack_error;			\
@@ -235,31 +235,32 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 		uint32_t _size;				\
 		bit_fmt(_tmp_str,max_len,bitmap);	\
 		_size = strlen(_tmp_str)+1;		\
-		packmem(_tmp_str,(uint16_t)_size,buf);	\
+		packmem(_tmp_str,_size,buf);	\
 	} else						\
-		packmem(NULL,(uint16_t)0,buf);		\
+		packmem(NULL,(uint32_t)0,buf);		\
 } while (0)				
 
 #define safe_packstr(str,max_len,buf) do {		\
 	uint32_t _size;					\
 	assert(buf->magic == BUF_MAGIC);		\
-	assert(max_len <= 0xffff);			\
+	assert(sizeof(*max_len) === sizeof(uint32_t));	\
 	_size = (str ? strlen(str)+1 : 0);		\
 	assert(_size == 0 || str != NULL);		\
 	if (_size <= max_len)				\
-		packmem(str,(uint16_t)_size,buf);	\
+		packmem(str,_size,buf);	\
 	else {						\
 		char tmp_str[max_len];			\
 		strncpy(tmp_str, str, max_len-1);	\
 		tmp_str[max_len - 1] = (char) NULL;	\
-		packmem(tmp_str,(uint16_t)max_len,buf);	\
+		packmem(tmp_str,max_len,buf);	\
 	}						\
 } while (0)				
 
 #define packstr(str,buf) do {				\
-	uint32_t _size;					\
-	_size = (uint32_t)(str ? strlen(str)+1 : 0);	\
-        assert(_size == 0 || str != NULL);		\
+	uint32_t _size = 0;				\
+	if((char *)str != NULL)				\
+		_size = (uint32_t)strlen(str)+1;	\
+        assert(_size == 0 || str != NULL);             	\
 	assert(_size <= 0xffff);			\
 	assert(buf->magic == BUF_MAGIC);		\
 	packmem(str,(uint16_t)_size,buf);		\
@@ -278,9 +279,9 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 		uint32_t _size;				\
 		bit_fmt(_tmp_str,0xfffe,bitmap);	\
 		_size = strlen(_tmp_str)+1;		\
-		packmem(_tmp_str,(uint16_t)_size,buf);	\
+		packmem(_tmp_str,_size,buf);	\
 	} else						\
-		packmem(NULL,(uint16_t)0,buf);		\
+		packmem(NULL,(uint32_t)0,buf);		\
 } while (0)				
 
 #define unpackstr_ptr		                        \
@@ -300,6 +301,7 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 
 #define safe_packstr_array(array,size_val,buf) do {	\
 	assert(size_val == 0 || array != NULL);		\
+	assert(sizeof(*size_valp) == sizeof(uint32_t)); \
 	assert(buf->magic == BUF_MAGIC);		\
 	packstr_array(array,size_val,buf);		\
 } while (0)				
@@ -307,7 +309,7 @@ int	unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
 #define safe_unpackstr_array(valp,size_valp,buf) do {	\
 	assert(valp != NULL);				\
 	assert(size_valp != NULL);			\
-	assert(sizeof(*size_valp) == sizeof(uint16_t)); \
+	assert(sizeof(*size_valp) == sizeof(uint32_t)); \
 	assert(buf->magic == BUF_MAGIC);		\
 	if (unpackstr_array(valp,size_valp,buf))	\
 		goto unpack_error;			\
diff --git a/src/common/parse_config.c b/src/common/parse_config.c
index bcca5b03d6719ac20138f108cc26434d39df0749..cf156a0fc7e004f944ee3dc3dcac7301cf344267 100644
--- a/src/common/parse_config.c
+++ b/src/common/parse_config.c
@@ -3,12 +3,12 @@
  *
  *  NOTE: when you see the prefix "s_p_", think "slurm parser".
  *
- *  $Id: parse_config.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: parse_config.c 14064 2008-05-15 23:53:06Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -511,10 +511,14 @@ static int _handle_uint32(s_p_values_t *v,
 
 		errno = 0;
 		num = strtoul(value, &endptr, 0);
+		if ((endptr[0] == 'k') || (endptr[0] == 'K')) {
+			num *= 1024;
+			endptr++;
+		}
 		if ((num == 0 && errno == EINVAL)
 		    || (*endptr != '\0')) {
-			if (strcasecmp(value, "UNLIMITED") == 0
-			    || strcasecmp(value, "INFINITE") == 0) {
+			if ((strcasecmp(value, "UNLIMITED") == 0) ||
+			    (strcasecmp(value, "INFINITE")  == 0)) {
 				num = (uint32_t)-1;
 			} else {
 				error("%s value (%s) is not a valid number", 
diff --git a/src/common/parse_config.h b/src/common/parse_config.h
index 3b7ff37fff5acfd26afae5843937f80ff61a5d32..acbbdf02b63c5dd05fb13ca4143a8fc59833ff98 100644
--- a/src/common/parse_config.h
+++ b/src/common/parse_config.h
@@ -3,12 +3,12 @@
  *
  *  NOTE: when you see the prefix "s_p_", think "slurm parser".
  *
- *  $Id: parse_config.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: parse_config.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/parse_spec.c b/src/common/parse_spec.c
index 0bfbc78f0d179d23bf325ce408a8e4188c09d799..e1ff00c3f1198b4a0d49787ccbaf5c6b581f09bc 100644
--- a/src/common/parse_spec.c
+++ b/src/common/parse_spec.c
@@ -1,11 +1,11 @@
-/* $Id: parse_spec.c 12452 2007-10-05 19:07:07Z da $ */
+/* $Id: parse_spec.c 13672 2008-03-19 23:10:58Z jette $ */
 /*****************************************************************************\
  * parse_spec.c - configuration file parser
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/parse_spec.h b/src/common/parse_spec.h
index 678eb287b1fae8d2c15f7d3f1a30aa5f67de9ba7..6b4359c3c99ff7a503f844d577ff84840334295c 100644
--- a/src/common/parse_spec.h
+++ b/src/common/parse_spec.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/parse_time.c b/src/common/parse_time.c
index b7253ac918966a6b5d61eb44984b66314319abb1..e72f2c93e455f3e69936a8bac89ad03e9ddcda9f 100644
--- a/src/common/parse_time.c
+++ b/src/common/parse_time.c
@@ -1,11 +1,10 @@
 /*****************************************************************************\
  *  src/common/parse_time.c - time parsing utility functions
- *  $Id$
  *****************************************************************************
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -462,7 +461,7 @@ slurm_make_time_str (time_t *time, char *string, int size)
  *   days-hr:min:sec
  *   days-hr
  * output:
- *   minutes  (or -1 on error) (or INFINITE value defined in slurm.h
+ *   minutes  (or -2 on error, INFINITE is -1 as defined in slurm.h)
  *   if unlimited is the value of string)
  */
 extern int time_str2mins(char *string)
@@ -472,8 +471,9 @@ extern int time_str2mins(char *string)
 
 	if ((string == NULL) || (string[0] == '\0'))
 		return -1;	/* invalid input */
-
-	if (!strcasecmp(string, "UNLIMITED")) {
+	if ((!strcasecmp(string, "-1")) ||
+	    (!strcasecmp(string, "INFINITE")) ||
+	    (!strcasecmp(string, "UNLIMITED"))) {
 		return INFINITE;
 	}
 
@@ -482,7 +482,7 @@ extern int time_str2mins(char *string)
 			tmp = (tmp * 10) + (string[i] - '0');
 		} else if (string[i] == '-') {
 			if (days != -1)
-				return -1;	/* invalid input */
+				return -2;	/* invalid input */
 			days = tmp;
 			tmp = 0;
 		} else if ((string[i] == ':') || (string[i] == '\0')) {
@@ -495,10 +495,10 @@ extern int time_str2mins(char *string)
 				min = sec;
 				sec = tmp;
 			} else
-				return -1;	/* invalid input */
+				return -2;	/* invalid input */
 			tmp = 0;
 		} else
-			return -1;		/* invalid input */
+			return -2;		/* invalid input */
 
 		if (string[i] == '\0')
 			break;
@@ -546,3 +546,25 @@ extern void secs2time_str(time_t time, char *string, int size)
 				hours, minutes, seconds);
 	}
 }
+
+extern void mins2time_str(uint32_t time, char *string, int size)
+{
+	if (time == INFINITE) {
+		snprintf(string, size, "UNLIMITED");
+	} else {
+		long days, hours, minutes, seconds;
+		seconds = 0;
+		minutes = time % 60;
+		hours = time / 60 % 24;
+		days = time / 1440;
+
+		if (days)
+			snprintf(string, size,
+				"%ld-%2.2ld:%2.2ld:%2.2ld",
+				days, hours, minutes, seconds);
+		else
+			snprintf(string, size,
+				"%2.2ld:%2.2ld:%2.2ld", 
+				hours, minutes, seconds);
+	}
+}
diff --git a/src/common/parse_time.h b/src/common/parse_time.h
index 5b4a7b547c8f73c8f4b56d222d7ed720f376f9e6..0189f81aa443b37a6167d82d27c562751417929d 100644
--- a/src/common/parse_time.h
+++ b/src/common/parse_time.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -16,7 +16,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -39,6 +39,19 @@
 #ifndef _PARSE_TIME_H_
 #define _PARSE_TIME_H_
 
+#if HAVE_CONFIG_H
+#  include "config.h"
+#  if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#  else
+#    if HAVE_STDINT_H
+#      include <stdint.h>
+#    endif
+#  endif                        /* HAVE_INTTYPES_H */
+#else                           /* !HAVE_CONFIG_H */
+#  include <inttypes.h>
+#endif
+
 #include <time.h>
 
 /* Convert string to equivalent time value
@@ -62,8 +75,7 @@ extern time_t parse_time(char *time_str);
  * IN size - length of string buffer, we recommend a size of 32 bytes to
  *	easily support different site-specific formats
  */
-extern void
-slurm_make_time_str (time_t *time, char *string, int size);
+extern void slurm_make_time_str (time_t *time, char *string, int size); 
 
 /* Convert a string to an equivalent time value
  * input formats:
@@ -82,5 +94,6 @@ extern int time_str2mins(char *string);
  * fill in string with HH:MM:SS or D-HH:MM:SS
  */
 extern void secs2time_str(time_t time, char *string, int size);
+extern void mins2time_str(uint32_t time, char *string, int size);
 
 #endif
diff --git a/src/common/plugin.c b/src/common/plugin.c
index b31db74596dcb482202815bdd21c3833e0f16050..5ca7f372c0de1e1b75c45ae7875a4a88f8ebd52c 100644
--- a/src/common/plugin.c
+++ b/src/common/plugin.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -220,8 +220,12 @@ plugin_get_syms( plugin_handle_t plug,
         count = 0;
         for ( i = 0; i < n_syms; ++i ) {
                 ptrs[ i ] = dlsym( plug, names[ i ] );
-                if ( ptrs[ i ] ) ++count;
-        }
+                if ( ptrs[ i ] ) 
+			++count;
+		else 
+			error("Couldn't find sym '%s' in the plugin",
+			      names[ i ]);
+	}
 
         return count;
 }
diff --git a/src/common/plugin.h b/src/common/plugin.h
index c57d2be1f684786310436741439ebb844d76ca14..9db07b24d549765b30a141bee7c7304dbc6dd4a2 100644
--- a/src/common/plugin.h
+++ b/src/common/plugin.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windlay <jwindley@lnxi.com>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/plugrack.c b/src/common/plugrack.c
index cb40dfebdddcc27bf4aeec2de32f1f5db984df9c..cc4a948b38990e94ec892d1f32753c09ed831b03 100644
--- a/src/common/plugrack.c
+++ b/src/common/plugrack.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/plugrack.h b/src/common/plugrack.h
index 2c8161d90ed1d465ef04bc674659a15efa9ff839..3937f0bd1a9c36e88c6cd8d8ea0a20e65e82f221 100644
--- a/src/common/plugrack.h
+++ b/src/common/plugrack.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/plugstack.c b/src/common/plugstack.c
index 2c9f30e6a9184276ff679d3469607ad0f95eff36..16b3a137d64c1aebc0952423b5f7b0581ed21b5d 100644
--- a/src/common/plugstack.c
+++ b/src/common/plugstack.c
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -1017,7 +1017,7 @@ static struct spank_plugin_opt *_find_remote_option_by_name(const char
 	}
 
 	if (!(name = strchr(buf, ':'))) {
-		error("Malformed plugin option \"%s\" recieved. Ignoring",
+		error("Malformed plugin option \"%s\" received. Ignoring",
 		      str);
 		return (NULL);
 	}
diff --git a/src/common/plugstack.h b/src/common/plugstack.h
index 7a7f57a8023cc81a7b5f8b8a29d36fe3f795389f..288663c762c2b149893a465ed5d1b8ec062facb9 100644
--- a/src/common/plugstack.h
+++ b/src/common/plugstack.h
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/proc_args.c b/src/common/proc_args.c
new file mode 100644
index 0000000000000000000000000000000000000000..e46fbf4b8e0975c0018eddc20a43b7cf70786c8d
--- /dev/null
+++ b/src/common/proc_args.c
@@ -0,0 +1,653 @@
+/*****************************************************************************\
+ *  proc_args.c - helper functions for command argument processing
+ *  $Id: opt.h 11996 2007-08-10 20:36:26Z jette $
+ *****************************************************************************
+ *  Copyright (C) 2007 Hewlett-Packard Development Company, L.P.
+ *  Written by Christopher Holmes <cholmes@hp.com>, who borrowed heavily
+ *  from existing SLURM source code, particularly src/srun/opt.c 
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>		/* strcpy, strncasecmp */
+
+#ifdef HAVE_STRINGS_H
+#  include <strings.h>
+#endif
+
+#ifndef _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
+
+#include <fcntl.h>
+#include <stdarg.h>		/* va_start   */
+#include <stdio.h>
+#include <stdlib.h>		/* getenv     */
+#include <pwd.h>		/* getpwuid   */
+#include <ctype.h>		/* isdigit    */
+#include <sys/param.h>		/* MAXPATHLEN */
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/utsname.h>
+
+#include "src/common/list.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+
+#include "src/common/proc_args.h"
+
+
+
+
+/* print this version of SLURM */
+void print_slurm_version(void)
+{
+	printf("%s %s\n", PACKAGE, SLURM_VERSION);
+}
+
+/* 
+ * verify that a distribution type in arg is of a known form
+ * returns the task_dist_states, or -1 if state is unknown
+ */
+task_dist_states_t verify_dist_type(const char *arg, uint32_t *plane_size)
+{
+	int len = strlen(arg);
+	char *dist_str = NULL;
+	task_dist_states_t result = SLURM_DIST_UNKNOWN;
+	bool lllp_dist = false, plane_dist = false;
+
+	dist_str = strchr(arg,':');
+	if (dist_str != NULL) {
+		/* -m cyclic|block:cyclic|block */
+		lllp_dist = true;
+	} else {
+		/* -m plane=<plane_size> */
+		dist_str = strchr(arg,'=');
+		if(dist_str != NULL) {
+			*plane_size=atoi(dist_str+1);
+			len = dist_str-arg;
+			plane_dist = true;
+		}
+	}
+
+	if (lllp_dist) {
+		if (strcasecmp(arg, "cyclic:cyclic") == 0) {
+			result = SLURM_DIST_CYCLIC_CYCLIC;
+		} else if (strcasecmp(arg, "cyclic:block") == 0) {
+			result = SLURM_DIST_CYCLIC_BLOCK;
+		} else if (strcasecmp(arg, "block:block") == 0) {
+			result = SLURM_DIST_BLOCK_BLOCK;
+		} else if (strcasecmp(arg, "block:cyclic") == 0) {
+			result = SLURM_DIST_BLOCK_CYCLIC;
+		}
+	} else if (plane_dist) {
+		if (strncasecmp(arg, "plane", len) == 0) {
+			result = SLURM_DIST_PLANE;
+		}
+	} else {
+		if (strncasecmp(arg, "cyclic", len) == 0) {
+			result = SLURM_DIST_CYCLIC;
+		} else if (strncasecmp(arg, "block", len) == 0) {
+			result = SLURM_DIST_BLOCK;
+		} else if ((strncasecmp(arg, "arbitrary", len) == 0) ||
+		           (strncasecmp(arg, "hostfile", len) == 0)) {
+			result = SLURM_DIST_ARBITRARY;
+		}
+	}
+
+	return result;
+}
+
+/*
+ * verify that a connection type in arg is of known form
+ * returns the connection_type or -1 if not recognized
+ */
+int verify_conn_type(const char *arg)
+{
+	int len = strlen(arg);
+
+	if (!strncasecmp(arg, "MESH", len))
+		return SELECT_MESH;
+	else if (!strncasecmp(arg, "TORUS", len))
+		return SELECT_TORUS;
+	else if (!strncasecmp(arg, "NAV", len))
+		return SELECT_NAV;
+
+	error("invalid --conn-type argument %s ignored.", arg);
+	return -1;
+}
+
+/*
+ * verify geometry arguments, must have proper count
+ * returns -1 on error, 0 otherwise
+ */
+int verify_geometry(const char *arg, uint16_t *geometry)
+{
+	char* token, *delimiter = ",x", *next_ptr;
+	int i, rc = 0;
+	char* geometry_tmp = xstrdup(arg);
+	char* original_ptr = geometry_tmp;
+
+	token = strtok_r(geometry_tmp, delimiter, &next_ptr);
+	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
+		if (token == NULL) {
+			error("insufficient dimensions in --geometry");
+			rc = -1;
+			break;
+		}
+		geometry[i] = (uint16_t)atoi(token);
+		if (geometry[i] == 0 || geometry[i] == (uint16_t)NO_VAL) {
+			error("invalid --geometry argument");
+			rc = -1;
+			break;
+		}
+		geometry_tmp = next_ptr;
+		token = strtok_r(geometry_tmp, delimiter, &next_ptr);
+	}
+	if (token != NULL) {
+		error("too many dimensions in --geometry");
+		rc = -1;
+	}
+
+	if (original_ptr)
+		xfree(original_ptr);
+
+	return rc;
+}
+
+/* return command name from its full path name */
+char * base_name(char* command)
+{
+	char *char_ptr, *name;
+	int i;
+
+	if (command == NULL)
+		return NULL;
+
+	char_ptr = strrchr(command, (int)'/');
+	if (char_ptr == NULL)
+		char_ptr = command;
+	else
+		char_ptr++;
+
+	i = strlen(char_ptr);
+	name = xmalloc(i+1);
+	strcpy(name, char_ptr);
+	return name;
+}
+
+/*
+ * str_to_bytes(): verify that arg is numeric with optional "G" or "M" at end
+ * if "G" or "M" is there, multiply by proper power of 2 and return
+ * number in bytes
+ */
+long str_to_bytes(const char *arg)
+{
+	char *buf;
+	char *endptr;
+	int end;
+	int multiplier = 1;
+	long result;
+
+	buf = xstrdup(arg);
+
+	end = strlen(buf) - 1;
+
+	if (isdigit(buf[end])) {
+		result = strtol(buf, &endptr, 10);
+
+		if (*endptr != '\0')
+			result = -result;
+
+	} else {
+
+		switch (toupper(buf[end])) {
+
+		case 'G':
+			multiplier = 1024;
+			break;
+
+		case 'M':
+			/* do nothing */
+			break;
+
+		default:
+			multiplier = -1;
+		}
+
+		buf[end] = '\0';
+
+		result = multiplier * strtol(buf, &endptr, 10);
+
+		if (*endptr != '\0')
+			result = -result;
+	}
+
+	return result;
+}
+
+/* Convert a string into a node count */
+static int
+_str_to_nodes(const char *num_str, char **leftover)
+{
+	long int num;
+	char *endptr;
+
+	num = strtol(num_str, &endptr, 10);
+	if (endptr == num_str) { /* no valid digits */
+		*leftover = (char *)num_str;
+		return 0;
+	} 
+	if (*endptr != '\0' && (*endptr == 'k' || *endptr == 'K')) {
+		num *= 1024;
+		endptr++;
+	}
+	*leftover = endptr;
+
+	return (int)num;
+}
+
+/* 
+ * verify that a node count in arg is of a known form (count or min-max)
+ * OUT min, max specified minimum and maximum node counts
+ * RET true if valid
+ */
+bool verify_node_count(const char *arg, int *min_nodes, int *max_nodes)
+{
+	char *ptr, *min_str, *max_str;
+	char *leftover;
+	
+	/* Does the string contain a "-" character?  If so, treat as a range.
+	 * otherwise treat as an absolute node count. */
+	if ((ptr = index(arg, '-')) != NULL) {
+		min_str = xstrndup(arg, ptr-arg);
+		*min_nodes = _str_to_nodes(min_str, &leftover);
+		if (!xstring_is_whitespace(leftover)) {
+			error("\"%s\" is not a valid node count", min_str);
+			xfree(min_str);
+			return false;
+		}
+		xfree(min_str);
+		if (*min_nodes == 0)
+			*min_nodes = 1;
+
+		max_str = xstrndup(ptr+1, strlen(arg)-((ptr+1)-arg));
+		*max_nodes = _str_to_nodes(max_str, &leftover);
+		if (!xstring_is_whitespace(leftover)) {
+			error("\"%s\" is not a valid node count", max_str);
+			xfree(max_str);
+			return false;
+		}
+		xfree(max_str);
+	} else {
+		*min_nodes = *max_nodes = _str_to_nodes(arg, &leftover);
+		if (!xstring_is_whitespace(leftover)) {
+			error("\"%s\" is not a valid node count", arg);
+			return false;
+		}
+		if (*min_nodes == 0) {
+			/* whitespace does not a valid node count make */
+			error("\"%s\" is not a valid node count", arg);
+			return false;
+		}
+	}
+
+	if ((*max_nodes != 0) && (*max_nodes < *min_nodes)) {
+		error("Maximum node count %d is less than"
+		      " minimum node count %d",
+		      *max_nodes, *min_nodes);
+		return false;
+	}
+
+	return true;
+}
+
+/* 
+ * get either 1 or 2 integers for a resource count in the form of either
+ * (count, min-max, or '*')
+ * A partial error message is passed in via the 'what' param.
+ * RET true if valid
+ */
+bool
+get_resource_arg_range(const char *arg, const char *what, int* min, int *max, 
+		       bool isFatal)
+{
+	char *p;
+	long int result;
+
+	if (*arg == '\0') return true;
+
+	/* wildcard meaning every possible value in range */
+	if (*arg == '*' ) {
+		*min = 1;
+		*max = INT_MAX;
+		return true;
+	}
+
+	result = strtol(arg, &p, 10);
+        if (*p == 'k' || *p == 'K') {
+		result *= 1024;
+		p++;
+	}
+
+	if (((*p != '\0')&&(*p != '-')) || (result <= 0L)) {
+		error ("Invalid numeric value \"%s\" for %s.", arg, what);
+		if (isFatal) exit(1);
+		return false;
+	} else if (result > INT_MAX) {
+		error ("Numeric argument (%ld) to big for %s.", result, what);
+		if (isFatal) exit(1);
+		return false;
+	}
+
+	*min = (int) result;
+
+	if (*p == '\0') return true;
+	if (*p == '-') p++;
+
+	result = strtol(p, &p, 10);
+        if (*p == 'k' || *p == 'K') {
+		result *= 1024;
+		p++;
+	}
+	
+	if (((*p != '\0')&&(*p != '-')) || (result <= 0L)) {
+		error ("Invalid numeric value \"%s\" for %s.", arg, what);
+		if (isFatal) exit(1);
+		return false;
+	} else if (result > INT_MAX) {
+		error ("Numeric argument (%ld) to big for %s.", result, what);
+		if (isFatal) exit(1);
+		return false;
+	}
+
+	*max = (int) result;
+
+	return true;
+}
+
+/* 
+ * verify that a resource counts in arg are of a known form X, X:X, X:X:X, or 
+ * X:X:X:X, where X is defined as either (count, min-max, or '*')
+ * RET true if valid
+ */
+bool verify_socket_core_thread_count(const char *arg, 
+				     int *min_sockets, int *max_sockets,
+				     int *min_cores, int *max_cores,
+				     int *min_threads, int  *max_threads,
+				     cpu_bind_type_t *cpu_bind_type)
+{
+	bool tmp_val,ret_val;
+	int i,j;
+	const char *cur_ptr = arg;
+	char buf[3][48]; /* each can hold INT64_MAX - INT64_MAX */
+	buf[0][0] = '\0';
+	buf[1][0] = '\0';
+	buf[2][0] = '\0';
+
+ 	for (j=0;j<3;j++) {	
+		for (i=0;i<47;i++) {
+			if (*cur_ptr == '\0' || *cur_ptr ==':') break;
+			buf[j][i] = *cur_ptr++;
+		}
+		if (*cur_ptr == '\0') break;
+		xassert(*cur_ptr == ':');
+		buf[j][i] = '\0';
+		cur_ptr++;
+	}
+	/* if cpu_bind_type doesn't already have a auto preference, choose
+	 * the level based on the level of the -E specification
+	 */
+	if (!(*cpu_bind_type & (CPU_BIND_TO_SOCKETS |
+				CPU_BIND_TO_CORES |
+				CPU_BIND_TO_THREADS))) {
+		if (j == 0) {
+			*cpu_bind_type |= CPU_BIND_TO_SOCKETS;
+		} else if (j == 1) {
+			*cpu_bind_type |= CPU_BIND_TO_CORES;
+		} else if (j == 2) {
+			*cpu_bind_type |= CPU_BIND_TO_THREADS;
+		}
+        }
+	buf[j][i] = '\0';
+
+	ret_val = true;
+	tmp_val = get_resource_arg_range(&buf[0][0], "first arg of -B", 
+					 min_sockets, max_sockets, true);
+	ret_val = ret_val && tmp_val;
+	tmp_val = get_resource_arg_range(&buf[1][0], "second arg of -B", 
+					 min_cores, max_cores, true);
+	ret_val = ret_val && tmp_val;
+	tmp_val = get_resource_arg_range(&buf[2][0], "third arg of -B", 
+					 min_threads, max_threads, true);
+	ret_val = ret_val && tmp_val;
+
+	return ret_val;
+}
+
+/* 
+ * verify that a hint is valid and convert it into the implied settings
+ * RET true if valid
+ */
+bool verify_hint(const char *arg, int *min_sockets, int *max_sockets,
+		 int *min_cores, int *max_cores, int *min_threads,
+		 int *max_threads, cpu_bind_type_t *cpu_bind_type)
+{
+	char *buf, *p, *tok;
+	if (!arg) {
+		return true;
+	}
+
+	buf = xstrdup(arg);
+	p = buf;
+	/* change all ',' delimiters not followed by a digit to ';'  */
+	/* simplifies parsing tokens while keeping map/mask together */
+	while (p[0] != '\0') {
+		if ((p[0] == ',') && (!isdigit(p[1])))
+			p[0] = ';';
+		p++;
+	}
+
+	p = buf;
+	while ((tok = strsep(&p, ";"))) {
+		if (strcasecmp(tok, "help") == 0) {
+			printf(
+"Application hint options:\n"
+"    --hint=             Bind tasks according to application hints\n"
+"        compute_bound   use all cores in each physical CPU\n"
+"        memory_bound    use only one core in each physical CPU\n"
+"        [no]multithread [don't] use extra threads with in-core multi-threading\n"
+"        help            show this help message\n");
+			return 1;
+		} else if (strcasecmp(tok, "compute_bound") == 0) {
+		        *min_sockets = 1;
+		        *max_sockets = INT_MAX;
+		        *min_cores   = 1;
+		        *max_cores   = INT_MAX;
+			*cpu_bind_type |= CPU_BIND_TO_CORES;
+		} else if (strcasecmp(tok, "memory_bound") == 0) {
+		        *min_cores = 1;
+		        *max_cores = 1;
+			*cpu_bind_type |= CPU_BIND_TO_CORES;
+		} else if (strcasecmp(tok, "multithread") == 0) {
+		        *min_threads = 1;
+		        *max_threads = INT_MAX;
+			*cpu_bind_type |= CPU_BIND_TO_THREADS;
+		} else if (strcasecmp(tok, "nomultithread") == 0) {
+		        *min_threads = 1;
+		        *max_threads = 1;
+			*cpu_bind_type |= CPU_BIND_TO_THREADS;
+		} else {
+			error("unrecognized --hint argument \"%s\", see --hint=help", tok);
+			xfree(buf);
+			return 1;
+		}
+	}
+
+	xfree(buf);
+	return 0;
+}
+
+uint16_t parse_mail_type(const char *arg)
+{
+	uint16_t rc;
+
+	if (strcasecmp(arg, "BEGIN") == 0)
+		rc = MAIL_JOB_BEGIN;
+	else if  (strcasecmp(arg, "END") == 0)
+		rc = MAIL_JOB_END;
+	else if (strcasecmp(arg, "FAIL") == 0)
+		rc = MAIL_JOB_FAIL;
+	else if (strcasecmp(arg, "ALL") == 0)
+		rc = MAIL_JOB_BEGIN |  MAIL_JOB_END |  MAIL_JOB_FAIL;
+	else
+		rc = 0;		/* failure */
+
+	return rc;
+}
+char *print_mail_type(const uint16_t type)
+{
+	if (type == 0)
+		return "NONE";
+
+	if (type == MAIL_JOB_BEGIN)
+		return "BEGIN";
+	if (type == MAIL_JOB_END)
+		return "END";
+	if (type == MAIL_JOB_FAIL)
+		return "FAIL";
+	if (type == (MAIL_JOB_BEGIN |  MAIL_JOB_END |  MAIL_JOB_FAIL))
+		return "ALL";
+
+	return "MULTIPLE";
+}
+
+static void
+_freeF(void *data)
+{
+	xfree(data);
+}
+
+static List
+_create_path_list(void)
+{
+	List l = list_create(_freeF);
+	char *path = xstrdup(getenv("PATH"));
+	char *c, *lc;
+
+	c = getenv("PATH");
+	if (!c) {
+		error("No PATH environment variable");
+		return l;
+	}
+	path = xstrdup(c);
+	c = lc = path;
+
+	while (*c != '\0') {
+		if (*c == ':') {
+			/* nullify and push token onto list */
+			*c = '\0';
+			if (lc != NULL && strlen(lc) > 0)
+				list_append(l, xstrdup(lc));
+			lc = ++c;
+		} else
+			c++;
+	}
+
+	if (strlen(lc) > 0)
+		list_append(l, xstrdup(lc));
+
+	xfree(path);
+
+	return l;
+}
+
+char *
+search_path(char *cwd, char *cmd, bool check_current_dir, int access_mode)
+{
+	List         l        = NULL;
+	ListIterator i        = NULL;
+	char *path, *fullpath = NULL;
+
+	if (  (cmd[0] == '.' || cmd[0] == '/') 
+           && (access(cmd, access_mode) == 0 ) ) {
+		if (cmd[0] == '.')
+			xstrfmtcat(fullpath, "%s/", cwd);
+		xstrcat(fullpath, cmd);
+		goto done;
+	}
+
+	l = _create_path_list();
+	if (l == NULL)
+		return NULL;
+
+	if (check_current_dir) 
+		list_prepend(l, xstrdup(cwd));
+
+	i = list_iterator_create(l);
+	while ((path = list_next(i))) {
+		xstrfmtcat(fullpath, "%s/%s", path, cmd);
+
+		if (access(fullpath, access_mode) == 0)
+			goto done;
+
+		xfree(fullpath);
+		fullpath = NULL;
+	}
+  done:
+	if (l)
+		list_destroy(l);
+	return fullpath;
+}
+
+char *print_commandline(const int script_argc, char **script_argv)
+{
+	int i;
+	char buf[256];
+
+	buf[0] = '\0';
+	for (i = 0; i < script_argc; i++)
+		snprintf(buf, 256,  "%s", script_argv[i]);
+	return xstrdup(buf);
+}
+
+char *print_geometry(const uint16_t *geometry)
+{
+	int i;
+	char buf[32], *rc = NULL;
+
+	if ((SYSTEM_DIMENSIONS == 0)
+	||  (geometry[0] == (uint16_t)NO_VAL))
+		return NULL;
+
+	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
+		if (i > 0)
+			snprintf(buf, sizeof(buf), "x%u", geometry[i]);
+		else
+			snprintf(buf, sizeof(buf), "%u", geometry[i]);
+		xstrcat(rc, buf);
+	}
+
+	return rc;
+}
diff --git a/src/common/proc_args.h b/src/common/proc_args.h
new file mode 100644
index 0000000000000000000000000000000000000000..109556bad9063fdae84d23da8c61dfca7c982615
--- /dev/null
+++ b/src/common/proc_args.h
@@ -0,0 +1,106 @@
+/*****************************************************************************\
+ *  proc_args.h - helper functions for command argument processing
+ *  $Id: opt.h 11996 2007-08-10 20:36:26Z jette $
+ *****************************************************************************
+ *  Copyright (C) 2007 Hewlett-Packard Development Company, L.P.
+ *  Written by Christopher Holmes <cholmes@hp.com>, who borrowed heavily
+ *  from existing SLURM source code, particularly src/srun/opt.c 
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+\*****************************************************************************/
+
+#ifndef _PROC_ARGS_H
+#define _PROC_ARGS_H
+
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "src/common/macros.h" /* true and false */
+#include "src/common/env.h"
+
+
+#define format_task_dist_states(t) (t == SLURM_DIST_BLOCK) ? "block" :   \
+		                 (t == SLURM_DIST_CYCLIC) ? "cyclic" : \
+		                 (t == SLURM_DIST_PLANE) ? "plane" : \
+		                 (t == SLURM_DIST_CYCLIC_CYCLIC) ? "cyclic:cyclic" : \
+		                 (t == SLURM_DIST_CYCLIC_BLOCK) ? "cyclic:block" : \
+		                 (t == SLURM_DIST_BLOCK_CYCLIC) ? "block:cyclic" : \
+		                 (t == SLURM_DIST_BLOCK_BLOCK) ? "block:block" : \
+			         (t == SLURM_DIST_ARBITRARY) ? "arbitrary" : \
+			         "unknown"
+
+
+/* print this version of SLURM */
+void print_slurm_version(void);
+
+/* verify the requested distribution type */
+task_dist_states_t verify_dist_type(const char *arg, uint32_t *plane_size);
+
+/* verify the requested connection type */
+int verify_conn_type(const char *arg);
+
+/* verify the requested geometry arguments */
+int verify_geometry(const char *arg, uint16_t *geometry);
+
+/* return command name from its full path name */
+char * base_name(char* command);
+
+/* confirm and convert a str to it's presented numeric value */
+long str_to_bytes(const char *arg);
+
+/* verify that a node count in arg is of a known form (count or min-max) */
+bool verify_node_count(const char *arg, int *min_nodes, int *max_nodes);
+
+/* parse a possible range of values from the form: count, min-max, or '*' */
+bool get_resource_arg_range(const char *arg, const char *what,
+				   int* min, int *max, bool isFatal);
+
+/* verify resource counts from a complex form of: X, X:X, X:X:X or X:X:X:X */
+bool verify_socket_core_thread_count(const char *arg, 
+				     int *min_sockets, int *max_sockets,
+				     int *min_cores, int *max_cores,
+				     int *min_threads, int  *max_threads,
+				     cpu_bind_type_t *cpu_bind_type);
+
+/* verify a hint and convert it into the implied settings */
+bool verify_hint(const char *arg, int *min_sockets, int *max_sockets,
+		 int *min_cores, int *max_cores, int *min_threads,
+		 int  *max_threads, cpu_bind_type_t *cpu_bind_type);
+
+/* parse the mail type */
+uint16_t parse_mail_type(const char *arg);
+
+/* print the mail type */
+char *print_mail_type(const uint16_t type);
+
+/* search PATH to confirm the access of the given command */
+char *search_path(char *cwd, char *cmd, bool check_current_dir,
+		  int access_mode);
+
+/* helper function for printing options */
+char *print_commandline(const int script_argc, char **script_argv);
+
+/* helper function for printing geometry option */
+char *print_geometry(const uint16_t *geometry);
+
+#endif /* !_PROC_ARGS_H */
diff --git a/src/common/read_config.c b/src/common/read_config.c
index 1d9c515a4d40ed8496f1440605637cc7c8b228d1..131fb27d360cdd78c820f8fa5bf915cd6ec442f9 100644
--- a/src/common/read_config.c
+++ b/src/common/read_config.c
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  read_config.c - read the overall slurm configuration file
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -64,6 +65,7 @@
 #include "src/common/xstring.h"
 #include "src/common/slurm_rlimits_info.h"
 #include "src/common/parse_config.h"
+#include "src/common/parse_time.h"
 #include "src/common/slurm_selecttype_info.h"
 
 /* Instantiation of the "extern slurm_ctl_conf_t slurmcltd_conf"
@@ -119,48 +121,81 @@ static void validate_and_set_defaults(slurm_ctl_conf_t *conf,
 				      s_p_hashtbl_t *hashtbl);
 
 s_p_options_t slurm_conf_options[] = {
+	{"AccountingStorageEnforce", S_P_UINT16},
+	{"AccountingStorageHost", S_P_STRING},
+	{"AccountingStorageLoc", S_P_STRING},
+	{"AccountingStoragePass", S_P_STRING},
+	{"AccountingStoragePort", S_P_UINT32},
+	{"AccountingStorageType", S_P_STRING},
+	{"AccountingStorageUser", S_P_STRING},
 	{"AuthType", S_P_STRING},
-	{"CheckpointType", S_P_STRING},
-	{"CacheGroups", S_P_UINT16},
 	{"BackupAddr", S_P_STRING},
 	{"BackupController", S_P_STRING},
+	{"CheckpointType", S_P_STRING},
+	{"CacheGroups", S_P_UINT16},
+	{"ClusterName", S_P_STRING},
 	{"ControlAddr", S_P_STRING},
 	{"ControlMachine", S_P_STRING},
-	{"DisableRootJobs", S_P_UINT16},
+	{"CryptoType", S_P_STRING},
+	{"DefaultStorageHost", S_P_STRING},
+	{"DefaultStorageLoc", S_P_STRING},
+	{"DefaultStoragePass", S_P_STRING},
+	{"DefaultStoragePort", S_P_UINT32},
+	{"DefaultStorageType", S_P_STRING},
+	{"DefaultStorageUser", S_P_STRING},
+	{"DefMemPerTask", S_P_UINT32},
+	{"DisableRootJobs", S_P_BOOLEAN},
 	{"Epilog", S_P_STRING},
+	{"EpilogMsgTime", S_P_UINT32},
 	{"FastSchedule", S_P_UINT16},
 	{"FirstJobId", S_P_UINT32},
+	{"GetEnvTimeout", S_P_UINT16},
 	{"HashBase", S_P_LONG, defunct_option},
 	{"HeartbeatInterval", S_P_LONG, defunct_option},
+	{"HealthCheckInterval", S_P_UINT16},
+	{"HealthCheckProgram", S_P_STRING},
 	{"InactiveLimit", S_P_UINT16},
+	{"JobAcctGatherType", S_P_STRING},
+	{"JobAcctFrequency", S_P_UINT16, defunct_option},
+	{"JobAcctGatherFrequency", S_P_UINT16},
 	{"JobAcctLogFile", S_P_STRING},
-	{"JobAcctFrequency", S_P_UINT16},
 	{"JobAcctType", S_P_STRING},
+	{"JobCompHost", S_P_STRING},
 	{"JobCompLoc", S_P_STRING},
+	{"JobCompPass", S_P_STRING},
+	{"JobCompPort", S_P_UINT32},
 	{"JobCompType", S_P_STRING},
+	{"JobCompUser", S_P_STRING},
 	{"JobCredentialPrivateKey", S_P_STRING},
 	{"JobCredentialPublicCertificate", S_P_STRING},
 	{"JobFileAppend", S_P_UINT16},
-	{"GetEnvTimeout", S_P_UINT16},
+	{"JobRequeue", S_P_UINT16},
 	{"KillTree", S_P_UINT16, defunct_option},
 	{"KillWait", S_P_UINT16},
+	{"Licenses", S_P_STRING},
 	{"MailProg", S_P_STRING},
 	{"MaxJobCount", S_P_UINT16},
+	{"MaxMemPerTask", S_P_UINT32},
 	{"MessageTimeout", S_P_UINT16},
 	{"MinJobAge", S_P_UINT16},
-	{"MpichGmDirectSupport", S_P_LONG},
+	{"MpichGmDirectSupport", S_P_LONG, defunct_option},
 	{"MpiDefault", S_P_STRING},
 	{"PluginDir", S_P_STRING},
 	{"PlugStackConfig", S_P_STRING},
+	{"PrivateData", S_P_UINT16},
 	{"ProctrackType", S_P_STRING},
 	{"Prolog", S_P_STRING},
 	{"PropagatePrioProcess", S_P_UINT16},
 	{"PropagateResourceLimitsExcept", S_P_STRING},
 	{"PropagateResourceLimits", S_P_STRING},
+	{"ResumeProgram", S_P_STRING},
+	{"ResumeRate", S_P_UINT16},
 	{"ReturnToService", S_P_UINT16},
-	{"SchedulerAuth", S_P_STRING},
+	{"SchedulerAuth", S_P_STRING, defunct_option},
+	{"SchedulerParameters", S_P_STRING},
 	{"SchedulerPort", S_P_UINT16},
 	{"SchedulerRootFilter", S_P_UINT16},
+	{"SchedulerTimeSlice", S_P_UINT16},
 	{"SchedulerType", S_P_STRING},
 	{"SelectType", S_P_STRING},
 	{"SelectTypeParameters", S_P_STRING},
@@ -179,6 +214,11 @@ s_p_options_t slurm_conf_options[] = {
 	{"SrunEpilog", S_P_STRING},
 	{"SrunProlog", S_P_STRING},
 	{"StateSaveLocation", S_P_STRING},
+	{"SuspendExcNodes", S_P_STRING},
+	{"SuspendExcParts", S_P_STRING},
+	{"SuspendProgram", S_P_STRING},
+	{"SuspendRate", S_P_UINT16},
+	{"SuspendTime", S_P_LONG},
 	{"SwitchType", S_P_STRING},
 	{"TaskEpilog", S_P_STRING},
 	{"TaskProlog", S_P_STRING},
@@ -214,10 +254,10 @@ static int parse_nodename(void **dest, slurm_parser_enum_t type,
 	s_p_hashtbl_t *tbl, *dflt;
 	slurm_conf_node_t *n;
 	static s_p_options_t _nodename_options[] = {
-		{"NodeHostname", S_P_STRING},
-		{"NodeAddr", S_P_STRING},
 		{"CoresPerSocket", S_P_UINT16},
 		{"Feature", S_P_STRING},
+		{"NodeAddr", S_P_STRING},
+		{"NodeHostname", S_P_STRING},
 		{"Port", S_P_UINT16},
 		{"Procs", S_P_UINT16},
 		{"RealMemory", S_P_UINT32},
@@ -280,8 +320,8 @@ static int parse_nodename(void **dest, slurm_parser_enum_t type,
 
 		if (!s_p_get_uint16(&n->port, "Port", tbl)
 		    && !s_p_get_uint16(&n->port, "Port", dflt)) {
-			/* This gets resolved in slurm_conf_get_port()
-			 * and slurm_conf_get_addr(). For now just
+			/* This gets resolved in slurm_conf_get_port() 
+			 * and slurm_conf_get_addr(). For now just 
 			 * leave with a value of zero */
 			n->port = 0;
 		}
@@ -400,11 +440,13 @@ static int parse_partitionname(void **dest, slurm_parser_enum_t type,
 	static s_p_options_t _partition_options[] = {
 		{"AllowGroups", S_P_STRING},
 		{"Default", S_P_BOOLEAN}, /* YES or NO */
+		{"DisableRootJobs", S_P_BOOLEAN}, /* YES or NO */
 		{"Hidden", S_P_BOOLEAN}, /* YES or NO */
-		{"MaxTime", S_P_UINT32}, /* INFINITE or a number */
+		{"MaxTime", S_P_STRING},
 		{"MaxNodes", S_P_UINT32}, /* INFINITE or a number */
 		{"MinNodes", S_P_UINT32},
 		{"Nodes", S_P_STRING},
+		{"Priority", S_P_UINT16},
 		{"RootOnly", S_P_BOOLEAN}, /* YES or NO */
 		{"Shared", S_P_STRING}, /* YES, NO, or FORCE */
 		{"State", S_P_BOOLEAN}, /* UP or DOWN */
@@ -439,13 +481,29 @@ static int parse_partitionname(void **dest, slurm_parser_enum_t type,
 		    && !s_p_get_boolean(&p->default_flag, "Default", dflt))
 			p->default_flag = false;
 
+		if (!s_p_get_boolean((bool *)&p->disable_root_jobs,
+				     "DisableRootJobs", tbl))
+			p->disable_root_jobs = (uint16_t)NO_VAL;
+
 		if (!s_p_get_boolean(&p->hidden_flag, "Hidden", tbl)
 		    && !s_p_get_boolean(&p->hidden_flag, "Hidden", dflt))
 			p->hidden_flag = false;
 
-		if (!s_p_get_uint32(&p->max_time, "MaxTime", tbl)
-		    && !s_p_get_uint32(&p->max_time, "MaxTime", dflt))
+		if (!s_p_get_string(&tmp, "MaxTime", tbl) &&
+		    !s_p_get_string(&tmp, "MaxTime", dflt))
 			p->max_time = INFINITE;
+		else {
+			int max_time = time_str2mins(tmp);
+			if ((max_time < 0) && (max_time != INFINITE)) {
+				error("Bad value \"%s\" for MaxTime", tmp);
+				destroy_partitionname(p);
+				s_p_hashtbl_destroy(tbl);
+				xfree(tmp);
+				return -1;
+			}
+			p->max_time = max_time;
+			xfree(tmp);
+		}
 
 		if (!s_p_get_uint32(&p->max_nodes, "MaxNodes", tbl)
 		    && !s_p_get_uint32(&p->max_nodes, "MaxNodes", dflt))
@@ -470,20 +528,27 @@ static int parse_partitionname(void **dest, slurm_parser_enum_t type,
 		    && !s_p_get_boolean(&p->root_only_flag, "RootOnly", dflt))
 			p->root_only_flag = false;
 
-		if (!s_p_get_string(&tmp, "Shared", tbl)
-		    && !s_p_get_string(&tmp, "Shared", dflt)) {
-			p->shared = SHARED_NO;
-		} else {
+		if (!s_p_get_uint16(&p->priority, "Priority", tbl) &&
+		    !s_p_get_uint16(&p->priority, "Priority", dflt))
+			p->priority = 1;
+
+		if (s_p_get_string(&tmp, "Shared", tbl) ||
+		    s_p_get_string(&tmp, "Shared", dflt)) {
 			if (strcasecmp(tmp, "NO") == 0)
-				p->shared = SHARED_NO;
+				p->max_share = 1;
 #ifndef HAVE_XCPU
 			/* Only "Shared=NO" is valid on XCPU systems */
-			else if (strcasecmp(tmp, "YES") == 0)
-				p->shared = SHARED_YES;
 			else if (strcasecmp(tmp, "EXCLUSIVE") == 0)
-				p->shared = SHARED_EXCLUSIVE;
-			else if (strcasecmp(tmp, "FORCE") == 0)
-				p->shared = SHARED_FORCE;
+				p->max_share = 0;
+			else if (strncasecmp(tmp, "YES:", 4) == 0)
+				p->max_share = strtol(&tmp[4], (char **) NULL, 10);
+			else if (strcasecmp(tmp, "YES") == 0) 
+				p->max_share = 4;
+			else if (strncasecmp(tmp, "FORCE:", 6) == 0) {
+				p->max_share = strtol(&tmp[6], (char **) NULL, 10) |
+					SHARED_FORCE;
+			} else if (strcasecmp(tmp, "FORCE") == 0)
+				p->max_share = 4 | SHARED_FORCE;
 #endif
 			else {
 				error("Bad value \"%s\" for Shared", tmp);
@@ -492,7 +557,9 @@ static int parse_partitionname(void **dest, slurm_parser_enum_t type,
 				xfree(tmp);
 				return -1;
 			}
-		}
+		} else
+			p->max_share = 1;
+
 		xfree(tmp);
 
 		if (!s_p_get_boolean(&p->state_up_flag, "State", tbl)
@@ -875,8 +942,8 @@ extern uint16_t slurm_conf_get_port(const char *node_name)
 	p = node_to_host_hashtbl[idx];
 	while (p) {
 		if (strcmp(p->alias, node_name) == 0) {
-			uint16_t port = p->port;
-			if (!port)
+			uint16_t port;
+			if (!p->port)
 				p->port = (uint16_t) conf_ptr->slurmd_port;
 			port = p->port;
 			slurm_conf_unlock();
@@ -998,46 +1065,60 @@ gethostname_short (char *name, size_t len)
 extern void
 free_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr, bool purge_node_hash)
 {
+	xfree (ctl_conf_ptr->accounting_storage_host);
+	xfree (ctl_conf_ptr->accounting_storage_loc);
+	xfree (ctl_conf_ptr->accounting_storage_pass);
+	xfree (ctl_conf_ptr->accounting_storage_type);
+	xfree (ctl_conf_ptr->accounting_storage_user);
 	xfree (ctl_conf_ptr->authtype);
-	xfree (ctl_conf_ptr->checkpoint_type);
 	xfree (ctl_conf_ptr->backup_addr);
 	xfree (ctl_conf_ptr->backup_controller);
+	xfree (ctl_conf_ptr->checkpoint_type);
+	xfree (ctl_conf_ptr->cluster_name);
 	xfree (ctl_conf_ptr->control_addr);
 	xfree (ctl_conf_ptr->control_machine);
+	xfree (ctl_conf_ptr->crypto_type);
 	xfree (ctl_conf_ptr->epilog);
-	xfree (ctl_conf_ptr->job_acct_logfile);
-	xfree (ctl_conf_ptr->job_acct_type);
+	xfree (ctl_conf_ptr->health_check_program);
+	xfree (ctl_conf_ptr->job_acct_gather_type);
+	xfree (ctl_conf_ptr->job_comp_host);
 	xfree (ctl_conf_ptr->job_comp_loc);
+	xfree (ctl_conf_ptr->job_comp_pass);
 	xfree (ctl_conf_ptr->job_comp_type);
+	xfree (ctl_conf_ptr->job_comp_user);
 	xfree (ctl_conf_ptr->job_credential_private_key);
 	xfree (ctl_conf_ptr->job_credential_public_certificate);
+	xfree (ctl_conf_ptr->licenses);
 	xfree (ctl_conf_ptr->mail_prog);
 	xfree (ctl_conf_ptr->mpi_default);
+	xfree (ctl_conf_ptr->node_prefix);
 	xfree (ctl_conf_ptr->plugindir);
 	xfree (ctl_conf_ptr->plugstack);
 	xfree (ctl_conf_ptr->proctrack_type);
 	xfree (ctl_conf_ptr->prolog);
 	xfree (ctl_conf_ptr->propagate_rlimits_except);
 	xfree (ctl_conf_ptr->propagate_rlimits);
+	xfree (ctl_conf_ptr->resume_program);
+	xfree (ctl_conf_ptr->slurm_conf);
 	xfree (ctl_conf_ptr->schedtype);
 	xfree (ctl_conf_ptr->select_type);
-	xfree (ctl_conf_ptr->slurm_conf);
 	xfree (ctl_conf_ptr->slurm_user_name);
 	xfree (ctl_conf_ptr->slurmctld_logfile);
 	xfree (ctl_conf_ptr->slurmctld_pidfile);
 	xfree (ctl_conf_ptr->slurmd_logfile);
 	xfree (ctl_conf_ptr->slurmd_pidfile);
 	xfree (ctl_conf_ptr->slurmd_spooldir);
+	xfree (ctl_conf_ptr->srun_epilog);
+	xfree (ctl_conf_ptr->srun_prolog);
 	xfree (ctl_conf_ptr->state_save_location);
+	xfree (ctl_conf_ptr->suspend_exc_nodes);
+	xfree (ctl_conf_ptr->suspend_exc_parts);
+	xfree (ctl_conf_ptr->suspend_program);
 	xfree (ctl_conf_ptr->switch_type);
-	xfree (ctl_conf_ptr->tmp_fs);
 	xfree (ctl_conf_ptr->task_epilog);
-	xfree (ctl_conf_ptr->task_prolog);
 	xfree (ctl_conf_ptr->task_plugin);
+	xfree (ctl_conf_ptr->task_prolog);
 	xfree (ctl_conf_ptr->tmp_fs);
-	xfree (ctl_conf_ptr->srun_prolog);
-	xfree (ctl_conf_ptr->srun_epilog);
-	xfree (ctl_conf_ptr->node_prefix);
 	xfree (ctl_conf_ptr->unkillable_program);
 
 	if (purge_node_hash)
@@ -1054,44 +1135,69 @@ void
 init_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr)
 {
 	ctl_conf_ptr->last_update		= time(NULL);
-	xfree (ctl_conf_ptr->authtype);
 	ctl_conf_ptr->cache_groups		= (uint16_t) NO_VAL;
-	xfree (ctl_conf_ptr->checkpoint_type);
+	xfree (ctl_conf_ptr->accounting_storage_host);
+	xfree (ctl_conf_ptr->accounting_storage_loc);
+	xfree (ctl_conf_ptr->accounting_storage_pass);
+	ctl_conf_ptr->accounting_storage_port             = 0;
+	xfree (ctl_conf_ptr->accounting_storage_type);
+	xfree (ctl_conf_ptr->accounting_storage_user);
+	xfree (ctl_conf_ptr->authtype);
 	xfree (ctl_conf_ptr->backup_addr);
 	xfree (ctl_conf_ptr->backup_controller);
+	ctl_conf_ptr->cache_groups		= 0;
+	xfree (ctl_conf_ptr->checkpoint_type);
+	xfree (ctl_conf_ptr->cluster_name);
 	xfree (ctl_conf_ptr->control_addr);
 	xfree (ctl_conf_ptr->control_machine);
+	xfree (ctl_conf_ptr->crypto_type);
+	ctl_conf_ptr->def_mem_per_task          = 0;
 	ctl_conf_ptr->disable_root_jobs         = 0;
 	xfree (ctl_conf_ptr->epilog);
+	ctl_conf_ptr->epilog_msg_time		= (uint32_t) NO_VAL;
 	ctl_conf_ptr->fast_schedule		= (uint16_t) NO_VAL;
 	ctl_conf_ptr->first_job_id		= (uint32_t) NO_VAL;
+	ctl_conf_ptr->get_env_timeout		= 0;
+	ctl_conf_ptr->health_check_interval	= 0;
+	xfree(ctl_conf_ptr->health_check_program);
 	ctl_conf_ptr->inactive_limit		= (uint16_t) NO_VAL;
-	xfree (ctl_conf_ptr->job_acct_logfile);
-	ctl_conf_ptr->job_acct_freq             = 0;
-	xfree (ctl_conf_ptr->job_acct_type);
+	xfree (ctl_conf_ptr->job_acct_gather_type);
+	ctl_conf_ptr->job_acct_gather_freq             = 0;
 	xfree (ctl_conf_ptr->job_comp_loc);
+	xfree (ctl_conf_ptr->job_comp_pass);
+	ctl_conf_ptr->job_comp_port             = 0;
 	xfree (ctl_conf_ptr->job_comp_type);
+	xfree (ctl_conf_ptr->job_comp_user);
 	xfree (ctl_conf_ptr->job_credential_private_key);
 	xfree (ctl_conf_ptr->job_credential_public_certificate);
 	ctl_conf_ptr->job_file_append		= (uint16_t) NO_VAL;
+	ctl_conf_ptr->job_requeue		= (uint16_t) NO_VAL;
 	ctl_conf_ptr->kill_wait			= (uint16_t) NO_VAL;
+	xfree (ctl_conf_ptr->licenses);
 	xfree (ctl_conf_ptr->mail_prog);
 	ctl_conf_ptr->max_job_cnt		= (uint16_t) NO_VAL;
+	ctl_conf_ptr->max_mem_per_task          = 0;
 	ctl_conf_ptr->min_job_age		= (uint16_t) NO_VAL;
 	xfree (ctl_conf_ptr->mpi_default);
 	ctl_conf_ptr->msg_timeout		= (uint16_t) NO_VAL;
 	ctl_conf_ptr->next_job_id		= (uint32_t) NO_VAL;
+	xfree (ctl_conf_ptr->node_prefix);
 	xfree (ctl_conf_ptr->plugindir);
 	xfree (ctl_conf_ptr->plugstack);
+	ctl_conf_ptr->private_data              = 0;
 	xfree (ctl_conf_ptr->proctrack_type);
 	xfree (ctl_conf_ptr->prolog);
 	ctl_conf_ptr->propagate_prio_process	= (uint16_t) NO_VAL;
-	xfree (ctl_conf_ptr->propagate_rlimits_except);
 	xfree (ctl_conf_ptr->propagate_rlimits);
+	xfree (ctl_conf_ptr->propagate_rlimits_except);
+	xfree (ctl_conf_ptr->resume_program);
+	ctl_conf_ptr->resume_rate		= (uint16_t) NO_VAL;
 	ctl_conf_ptr->ret2service		= (uint16_t) NO_VAL;
+	xfree( ctl_conf_ptr->sched_params );
+	ctl_conf_ptr->sched_time_slice		= (uint16_t) NO_VAL;
+	xfree( ctl_conf_ptr->schedtype );
 	ctl_conf_ptr->schedport			= (uint16_t) NO_VAL;
 	ctl_conf_ptr->schedrootfltr		= (uint16_t) NO_VAL;
-	xfree( ctl_conf_ptr->schedtype );
 	xfree( ctl_conf_ptr->select_type );
 	ctl_conf_ptr->select_type_param         = (uint16_t) NO_VAL;
 	ctl_conf_ptr->slurm_user_id		= (uint16_t) NO_VAL; 
@@ -1107,20 +1213,25 @@ init_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr)
  	ctl_conf_ptr->slurmd_port		= (uint32_t) NO_VAL;
 	xfree (ctl_conf_ptr->slurmd_spooldir);
 	ctl_conf_ptr->slurmd_timeout		= (uint16_t) NO_VAL;
+	xfree (ctl_conf_ptr->srun_prolog);
+	xfree (ctl_conf_ptr->srun_epilog);
 	xfree (ctl_conf_ptr->state_save_location);
+	xfree (ctl_conf_ptr->suspend_exc_nodes);
+	xfree (ctl_conf_ptr->suspend_exc_parts);
+	xfree (ctl_conf_ptr->suspend_program);
+	ctl_conf_ptr->suspend_rate		= (uint16_t) NO_VAL;
+	ctl_conf_ptr->suspend_time		= (uint16_t) NO_VAL;
 	xfree (ctl_conf_ptr->switch_type);
 	xfree (ctl_conf_ptr->task_epilog);
-	xfree (ctl_conf_ptr->task_prolog);
 	xfree (ctl_conf_ptr->task_plugin);
+	ctl_conf_ptr->task_plugin_param		= 0;
+	xfree (ctl_conf_ptr->task_prolog);
 	xfree (ctl_conf_ptr->tmp_fs);
-	ctl_conf_ptr->wait_time			= (uint16_t) NO_VAL;
-	xfree (ctl_conf_ptr->srun_prolog);
-	xfree (ctl_conf_ptr->srun_epilog);
-	xfree (ctl_conf_ptr->node_prefix);
 	ctl_conf_ptr->tree_width       		= (uint16_t) NO_VAL;
-	ctl_conf_ptr->use_pam			= 0;
 	xfree (ctl_conf_ptr->unkillable_program);
 	ctl_conf_ptr->unkillable_timeout        = (uint16_t) NO_VAL;
+	ctl_conf_ptr->use_pam			= 0;
+	ctl_conf_ptr->wait_time			= (uint16_t) NO_VAL;
 
 	_free_name_hashtbl();
 	_init_name_hashtbl();
@@ -1339,8 +1450,13 @@ static void
 validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 {
 	char *temp_str = NULL;
+	long long_suspend_time;
 	bool truth;
-
+	char *default_storage_type = NULL, *default_storage_host = NULL;
+	char *default_storage_user = NULL, *default_storage_pass = NULL;
+	char *default_storage_loc = NULL;
+	uint32_t default_storage_port = 0;
+		
 	if (s_p_get_string(&conf->backup_controller, "BackupController",
 			   hashtbl)
 	    && strcasecmp("localhost", conf->backup_controller) == 0) {
@@ -1359,6 +1475,8 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 			conf->backup_addr = xstrdup(conf->backup_controller);
 	}
 
+	s_p_get_string(&conf->cluster_name, "ClusterName", hashtbl);
+
 	if (!s_p_get_string(&conf->control_machine, "ControlMachine", hashtbl))
 		fatal ("validate_and_set_defaults: "
 		       "ControlMachine not specified.");
@@ -1380,6 +1498,13 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 		xfree(conf->backup_controller);
 	}
 
+	s_p_get_string(&default_storage_type, "DefaultStorageType", hashtbl);
+	s_p_get_string(&default_storage_host, "DefaultStorageHost", hashtbl);
+	s_p_get_string(&default_storage_user, "DefaultStorageUser", hashtbl);
+	s_p_get_string(&default_storage_pass, "DefaultStoragePass", hashtbl);
+	s_p_get_string(&default_storage_loc, "DefaultStorageLoc", hashtbl);
+	s_p_get_uint32(&default_storage_port, "DefaultStoragePort", hashtbl);
+
 	if (!s_p_get_string(&conf->job_credential_private_key,
 			    "JobCredentialPrivateKey", hashtbl))
 		fatal("JobCredentialPrivateKey not set");
@@ -1400,12 +1525,21 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 	if (!s_p_get_string(&conf->checkpoint_type, "CheckpointType", hashtbl))
 		conf->checkpoint_type = xstrdup(DEFAULT_CHECKPOINT_TYPE);
 
-	if (!s_p_get_uint16(&conf->disable_root_jobs, "DisableRootJobs", 
-			    hashtbl))
+	if (!s_p_get_string(&conf->crypto_type, "CryptoType", hashtbl))
+		 conf->crypto_type = xstrdup(DEFAULT_CRYPTO_TYPE);
+
+	if (!s_p_get_uint32(&conf->def_mem_per_task, "DefMemPerTask", hashtbl))
+		conf->def_mem_per_task = DEFAULT_MEM_PER_TASK;
+
+	if (!s_p_get_boolean((bool *) &conf->disable_root_jobs, 
+			     "DisableRootJobs", hashtbl))
 		conf->disable_root_jobs = DEFAULT_DISABLE_ROOT_JOBS;
 
 	s_p_get_string(&conf->epilog, "Epilog", hashtbl);
 
+	if (!s_p_get_uint32(&conf->epilog_msg_time, "EpilogMsgTime", hashtbl))
+		conf->epilog_msg_time = DEFAULT_EPILOG_MSG_TIME;
+
 	if (!s_p_get_uint16(&conf->fast_schedule, "FastSchedule", hashtbl))
 		conf->fast_schedule = DEFAULT_FAST_SCHEDULE;
 
@@ -1428,40 +1562,108 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 		conf->inactive_limit = DEFAULT_INACTIVE_LIMIT;
 	}
 
-	if (!s_p_get_string(&conf->job_acct_logfile, 
-			    "JobAcctLogFile", hashtbl))
-		conf->job_acct_logfile = xstrdup(DEFAULT_JOB_ACCT_LOGFILE);
-
-	if (!s_p_get_uint16(&conf->job_acct_freq, "JobAcctFrequency", hashtbl))
-		conf->job_acct_freq = DEFAULT_JOB_ACCT_FREQ;
-
-	if (!s_p_get_string(&conf->job_acct_type, "JobAcctType", hashtbl))
-		conf->job_acct_type = xstrdup(DEFAULT_JOB_ACCT_TYPE);
-
-	s_p_get_string(&conf->job_comp_loc, "JobCompLoc", hashtbl);
-
-	if (!s_p_get_string(&conf->job_comp_type, "JobCompType", hashtbl))
-		conf->job_comp_type = xstrdup(DEFAULT_JOB_COMP_TYPE);
+	if (!s_p_get_uint16(&conf->job_acct_gather_freq,
+			    "JobAcctGatherFrequency", hashtbl))
+		conf->job_acct_gather_freq = DEFAULT_JOB_ACCT_GATHER_FREQ;
+
+	if (s_p_get_string(&conf->job_acct_gather_type,
+			    "JobAcctType", hashtbl)) {
+		fatal("JobAcctType is no longer a valid parameter.\n"
+		      "The job accounting plugin has changed to 2 different "
+		      "plugins one for gathering and one for storing the "
+		      "gathered information.\n"
+		      "Please change this to JobAcctGatherType to "
+		      "correctly work.\n"
+		      "The major 'jobacct' is now 'jobacct_gather' and "
+		      "'jobacct_storage' your declarations will also need "
+		      "to change in your slurm.conf file.\n"
+		      "Refer to the slurm.conf man page or the web "
+		      "documentation for further explanation.");
+	}
+	
+	if(!s_p_get_string(&conf->job_acct_gather_type,
+			   "JobAcctGatherType", hashtbl))
+		conf->job_acct_gather_type =
+			xstrdup(DEFAULT_JOB_ACCT_GATHER_TYPE);
+
+	if (!s_p_get_string(&conf->job_comp_type, "JobCompType", hashtbl)) {
+		if(default_storage_type)
+			conf->job_comp_type =
+				xstrdup_printf("jobcomp/%s",
+					       default_storage_type);
+		else
+			conf->job_comp_type = xstrdup(DEFAULT_JOB_COMP_TYPE);
+	}
+	if (!s_p_get_string(&conf->job_comp_loc, "JobCompLoc", hashtbl)) {
+		if(default_storage_loc)
+			conf->job_comp_loc = xstrdup(default_storage_loc);
+		else
+			conf->job_comp_loc = xstrdup(DEFAULT_JOB_COMP_LOC);
+	}
 
+	if (!s_p_get_string(&conf->job_comp_host, "JobCompHost",
+			    hashtbl)) {
+		if(default_storage_host)
+			conf->job_comp_host =
+				xstrdup(default_storage_host);
+		else
+			conf->job_comp_host = xstrdup(DEFAULT_STORAGE_HOST);
+	}
+	if (!s_p_get_string(&conf->job_comp_user, "JobCompUser",
+			    hashtbl)) {
+		if(default_storage_user)
+			conf->job_comp_user =
+				xstrdup(default_storage_user);
+		else
+			conf->job_comp_user = xstrdup(DEFAULT_STORAGE_USER);
+	}
+	if (!s_p_get_string(&conf->job_comp_pass, "JobCompPass",
+			    hashtbl)) {
+		if(default_storage_pass)
+			conf->job_comp_pass =
+				xstrdup(default_storage_pass);
+	}
+	if (!s_p_get_uint32(&conf->job_comp_port, "JobCompPort",
+			    hashtbl)) {
+		if(default_storage_port)
+			conf->job_comp_port = default_storage_port;
+		else
+			conf->job_comp_port = DEFAULT_STORAGE_PORT;
+	}
 	if (!s_p_get_uint16(&conf->job_file_append, "JobFileAppend", hashtbl))
 		conf->job_file_append = 0;
 
+	if (!s_p_get_uint16(&conf->job_requeue, "JobRequeue", hashtbl))
+		conf->job_requeue = 1;
+	else if (conf->job_requeue > 1)
+		conf->job_requeue = 1;
+
 	if (!s_p_get_uint16(&conf->get_env_timeout, "GetEnvTimeout", hashtbl))
 		conf->get_env_timeout = DEFAULT_GET_ENV_TIMEOUT;
 
+	s_p_get_uint16(&conf->health_check_interval, "HealthCheckInterval", hashtbl);
+	s_p_get_string(&conf->health_check_program, "HealthCheckProgram", hashtbl);
+
 	if (!s_p_get_uint16(&conf->kill_wait, "KillWait", hashtbl))
 		conf->kill_wait = DEFAULT_KILL_WAIT;
 
+	s_p_get_string(&conf->licenses, "Licenses", hashtbl);
+
 	if (!s_p_get_string(&conf->mail_prog, "MailProg", hashtbl))
 		conf->mail_prog = xstrdup(DEFAULT_MAIL_PROG);
 
 	if (!s_p_get_uint16(&conf->max_job_cnt, "MaxJobCount", hashtbl))
 		conf->max_job_cnt = DEFAULT_MAX_JOB_COUNT;
 
+	if (!s_p_get_uint32(&conf->max_mem_per_task, "MaxMemPerTask", hashtbl))
+		conf->max_mem_per_task = DEFAULT_MAX_MEM_PER_TASK;
+
 	if (!s_p_get_uint16(&conf->msg_timeout, "MessageTimeout", hashtbl))
 		conf->msg_timeout = DEFAULT_MSG_TIMEOUT;
-	else if (conf->msg_timeout > 100)
-		info("WARNING: MessageTimeout is too high for effective fault-tolerance");
+	else if (conf->msg_timeout > 100) {
+		info("WARNING: MessageTimeout is too high for effective "
+			"fault-tolerance");
+	}
 
 	if (!s_p_get_uint16(&conf->min_job_age, "MinJobAge", hashtbl))
 		conf->min_job_age = DEFAULT_MIN_JOB_AGE;
@@ -1469,6 +1671,69 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 	if (!s_p_get_string(&conf->mpi_default, "MpiDefault", hashtbl))
 		conf->mpi_default = xstrdup(DEFAULT_MPI_DEFAULT);
 
+	if (!s_p_get_string(&conf->accounting_storage_type,
+			    "AccountingStorageType", hashtbl)) {
+		if(default_storage_type)
+			conf->accounting_storage_type =
+				xstrdup_printf("accounting_storage/%s",
+					       default_storage_type);
+		else	
+			conf->accounting_storage_type =
+				xstrdup(DEFAULT_ACCOUNTING_STORAGE_TYPE);
+	}
+
+	if (!s_p_get_uint16(&conf->accounting_storage_enforce, 
+			    "AccountingStorageEnforce", hashtbl))
+		conf->accounting_storage_enforce = DEFAULT_ACCOUNTING_ENFORCE;
+
+	if (!s_p_get_string(&conf->accounting_storage_host,
+			    "AccountingStorageHost", hashtbl)) {
+		if(default_storage_host)
+			conf->accounting_storage_host =
+				xstrdup(default_storage_host);
+		else
+			conf->accounting_storage_host =
+				xstrdup(DEFAULT_STORAGE_HOST);
+	}
+
+	/* AccountingStorageLoc replaces JobAcctLogFile since it now represents
+	 * the database name also depending on the storage type you
+	 * use so we still check JobAcctLogFile for the same thing
+	 */
+	if (!s_p_get_string(&conf->accounting_storage_loc,
+			    "AccountingStorageLoc", hashtbl)
+		&& !s_p_get_string(&conf->accounting_storage_loc,
+			       "JobAcctLogFile", hashtbl)) {
+		if(default_storage_loc)
+			conf->accounting_storage_loc =
+				xstrdup(default_storage_loc);
+		else
+			conf->accounting_storage_loc =
+				xstrdup(DEFAULT_STORAGE_LOC);
+	}
+
+	if (!s_p_get_string(&conf->accounting_storage_user,
+			    "AccountingStorageUser", hashtbl)) {
+		if(default_storage_user)
+			conf->accounting_storage_user =
+				xstrdup(default_storage_user);
+		else
+			conf->accounting_storage_user =
+				xstrdup(DEFAULT_STORAGE_USER);
+	}
+	if (!s_p_get_string(&conf->accounting_storage_pass,
+			    "AccountingStoragePass", hashtbl)) {
+		if(default_storage_pass)
+			conf->accounting_storage_pass =
+				xstrdup(default_storage_pass);
+	}
+	if (!s_p_get_uint32(&conf->accounting_storage_port,
+			    "AccountingStoragePort", hashtbl)) {
+		if(default_storage_port)
+			conf->accounting_storage_port = default_storage_port;
+		else
+			conf->accounting_storage_port = DEFAULT_STORAGE_PORT;
+	}
 	if (!s_p_get_string(&conf->plugindir, "PluginDir", hashtbl))
 		conf->plugindir = xstrdup(default_plugin_path);
 
@@ -1489,6 +1754,8 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 	    && (!strcmp(conf->proctrack_type,"proctrack/linuxproc")))
 		fatal("proctrack/linuxproc is incompatable with switch/elan");
 
+	s_p_get_uint16(&conf->private_data, "PrivateData", hashtbl);
+
 	s_p_get_string(&conf->prolog, "Prolog", hashtbl);
 
 	if (!s_p_get_uint16(&conf->propagate_prio_process,
@@ -1518,6 +1785,12 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 	if (!s_p_get_uint16(&conf->ret2service, "ReturnToService", hashtbl))
 		conf->ret2service = DEFAULT_RETURN_TO_SERVICE;
 
+	s_p_get_string(&conf->resume_program, "ResumeProgram", hashtbl);
+	if (!s_p_get_uint16(&conf->resume_rate, "ResumeRate", hashtbl))
+		conf->resume_rate = DEFAULT_RESUME_RATE;
+
+	s_p_get_string(&conf->sched_params, "SchedulerParameters", hashtbl);
+
 	if (s_p_get_uint16(&conf->schedport, "SchedulerPort", hashtbl)) {
 		if (conf->schedport == 0) {
 			error("SchedulerPort=0 is invalid");
@@ -1531,6 +1804,10 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 			    "SchedulerRootFilter", hashtbl))
 		conf->schedrootfltr = DEFAULT_SCHEDROOTFILTER;
 
+	if (!s_p_get_uint16(&conf->sched_time_slice, "SchedulerTimeSlice",
+	    hashtbl))
+		conf->sched_time_slice = DEFAULT_SCHED_TIME_SLICE;
+
 	if (!s_p_get_string(&conf->schedtype, "SchedulerType", hashtbl))
 		conf->schedtype = xstrdup(DEFAULT_SCHEDTYPE);
 
@@ -1565,11 +1842,7 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 			       conf->slurm_user_name);
 			xfree(conf->slurm_user_name);
 		} else {
-			if (slurm_passwd->pw_uid > 0xffff)
-				error("SlurmUser numeric overflow, "
-				      "will be fixed soon");
-			else
-				conf->slurm_user_id = slurm_passwd->pw_uid;
+			conf->slurm_user_id = slurm_passwd->pw_uid;
 		}
 	}
 
@@ -1617,6 +1890,16 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 			    "StateSaveLocation", hashtbl))
 		conf->state_save_location = xstrdup(DEFAULT_SAVE_STATE_LOC);
 
+	s_p_get_string(&conf->suspend_exc_nodes, "SuspendExcNodes", hashtbl);
+	s_p_get_string(&conf->suspend_exc_parts, "SuspendExcParts", hashtbl);
+	s_p_get_string(&conf->suspend_program, "SuspendProgram", hashtbl);
+	if (!s_p_get_uint16(&conf->suspend_rate, "SuspendRate", hashtbl))
+		conf->suspend_rate = DEFAULT_SUSPEND_RATE;
+	if (s_p_get_long(&long_suspend_time, "SuspendTime", hashtbl))
+		conf->suspend_time = long_suspend_time + 1;
+	else
+		conf->suspend_time = 0;
+
 	/* see above for switch_type, order dependent */
 
 	if (!s_p_get_string(&conf->task_plugin, "TaskPlugin", hashtbl))
@@ -1663,6 +1946,11 @@ validate_and_set_defaults(slurm_ctl_conf_t *conf, s_p_hashtbl_t *hashtbl)
 	if (!s_p_get_uint16(&conf->unkillable_timeout,
 			    "UnkillableStepTimeout", hashtbl))
 		conf->unkillable_timeout = DEFAULT_UNKILLABLE_TIMEOUT;
+	xfree(default_storage_type);
+	xfree(default_storage_loc);
+	xfree(default_storage_host);
+	xfree(default_storage_user);
+	xfree(default_storage_pass);
 }
 
 /*
diff --git a/src/common/read_config.h b/src/common/read_config.h
index fa2156dd1b5414d7794ef9e6311b096c8f6c59f8..8badcb691d4a0c3381bfc5a3d129b4f658b33a2d 100644
--- a/src/common/read_config.h
+++ b/src/common/read_config.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Mette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -16,7 +16,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -48,22 +48,30 @@ extern char *default_slurm_config_file;
 extern char *default_plugin_path;
 extern char *default_plugstack;
 
+#define DEFAULT_ACCOUNTING_ENFORCE  0
+#define DEFAULT_ACCOUNTING_STORAGE_TYPE "accounting_storage/none"
 #define DEFAULT_AUTH_TYPE          "auth/none"
 #define DEFAULT_CACHE_GROUPS        0
-#define DEFAULT_DISABLE_ROOT_JOBS   0
+#define DEFAULT_CRYPTO_TYPE        "crypto/openssl"
+#define DEFAULT_EPILOG_MSG_TIME     2000
 #define DEFAULT_FAST_SCHEDULE       1
 #define DEFAULT_FIRST_JOB_ID        1
 #define DEFAULT_GET_ENV_TIMEOUT     2
 /* NOTE: DEFAULT_INACTIVE_LIMIT must be 0 for Blue Gene/L systems */
 #define DEFAULT_INACTIVE_LIMIT      0
-#define DEFAULT_JOB_ACCT_LOGFILE    "/var/log/slurm_accounting.log"
-#define DEFAULT_JOB_ACCT_FREQ       30
-#define DEFAULT_JOB_ACCT_TYPE       "jobacct/none"
+#define DEFAULT_JOB_ACCT_GATHER_TYPE  "jobacct_gather/none"
+#define JOB_ACCT_GATHER_TYPE_NONE "jobacct_gather/none"
+#define DEFAULT_JOB_ACCT_GATHER_FREQ  30
+#define ACCOUNTING_STORAGE_TYPE_NONE "accounting_storage/none"
+#define DEFAULT_DISABLE_ROOT_JOBS   0
 #define DEFAULT_JOB_COMP_TYPE       "jobcomp/none"
+#define DEFAULT_JOB_COMP_LOC        "/var/log/slurm_jobcomp.log"
 #define DEFAULT_KILL_TREE           0
 #define DEFAULT_KILL_WAIT           30
 #define DEFAULT_MAIL_PROG           "/bin/mail"
-#define DEFAULT_MAX_JOB_COUNT       2000
+#define DEFAULT_MAX_JOB_COUNT       5000
+#define DEFAULT_MEM_PER_TASK        0
+#define DEFAULT_MAX_MEM_PER_TASK    0
 #define DEFAULT_MIN_JOB_AGE         300
 #define DEFAULT_MPI_DEFAULT         "none"
 #define DEFAULT_MSG_TIMEOUT         10
@@ -76,9 +84,11 @@ extern char *default_plugstack;
 #endif
 #define DEFAULT_PROPAGATE_PRIO_PROCESS 0
 #define DEFAULT_RETURN_TO_SERVICE   0
+#define DEFAULT_RESUME_RATE         60
 #define DEFAULT_SAVE_STATE_LOC      "/tmp"
 #define DEFAULT_SCHEDROOTFILTER     1
 #define DEFAULT_SCHEDULER_PORT      7321
+#define DEFAULT_SCHED_TIME_SLICE    30
 #define DEFAULT_SCHEDTYPE           "sched/builtin"
 #ifdef HAVE_BG		/* Blue Gene specific default configuration parameters */
 #  define DEFAULT_SELECT_TYPE       "select/bluegene"
@@ -90,6 +100,12 @@ extern char *default_plugstack;
 #define DEFAULT_SLURMD_PIDFILE      "/var/run/slurmd.pid"
 #define DEFAULT_SLURMD_TIMEOUT      300
 #define DEFAULT_SPOOLDIR            "/var/spool/slurmd"
+#define DEFAULT_STORAGE_HOST        "localhost"
+#define DEFAULT_STORAGE_LOC         "/var/log/slurm_jobacct.log"
+#define DEFAULT_STORAGE_USER        "root"
+#define DEFAULT_STORAGE_PORT        0
+#define DEFAULT_SUSPEND_RATE        60
+#define DEFAULT_SUSPEND_TIME        0
 #define DEFAULT_SWITCH_TYPE         "switch/none"
 #define DEFAULT_TASK_PLUGIN         "task/none"
 #define DEFAULT_TMP_FS              "/tmp"
@@ -116,6 +132,9 @@ typedef struct slurm_conf_node {
 } slurm_conf_node_t;
 
 typedef struct slurm_conf_partition {
+	uint16_t disable_root_jobs; /* if set then user root can't run
+				     * jobs if NO_VAL use global
+				     * default */
 	char	*name;		/* name of the partition */
 	bool     hidden_flag;	/* 1 if hidden by default */
 	uint32_t max_time;	/* minutes or INFINITE */
@@ -123,10 +142,10 @@ typedef struct slurm_conf_partition {
 	uint32_t min_nodes;	/* per job */
 	uint32_t total_nodes;	/* total number of nodes in the partition */
 	uint32_t total_cpus;	/* total number of cpus in the partition */
+	uint16_t priority;	/* scheduling priority for jobs */
 	bool     root_only_flag;/* 1 if allocate/submit RPC can only be 
 				   issued by user root */
-	uint16_t shared;	/* 1 if job can share a node,
-				   2 if sharing required */
+	uint16_t max_share;	/* number of jobs to gang schedule */
 	bool     state_up_flag;	/* 1 if state is up, 0 if down */
 	char *nodes;		/* comma delimited list names of nodes */
 	char *allow_groups;	/* comma delimited list of groups, 
diff --git a/src/common/safeopen.c b/src/common/safeopen.c
index 3843a5a61fa0221ba88bc6c0af110ad31d6debcd..21e1bd8c1e1cab8d73495d6e5e9d3f99de9417e2 100644
--- a/src/common/safeopen.c
+++ b/src/common/safeopen.c
@@ -1,10 +1,10 @@
 /*****************************************************************************\
  *  safeopen.c - safer interface to open()
- *  $Id: safeopen.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: safeopen.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/safeopen.h b/src/common/safeopen.h
index e119bee1bdb6543e0bfcab9b0d7ceb799eb91c51..3708a26575258ea7721e34c0451206f27f807f92 100644
--- a/src/common/safeopen.h
+++ b/src/common/safeopen.h
@@ -1,10 +1,10 @@
 /*****************************************************************************\
  *  safeopen.h - safer interface to open()
- *  $Id: safeopen.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: safeopen.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_accounting_storage.c b/src/common/slurm_accounting_storage.c
new file mode 100644
index 0000000000000000000000000000000000000000..31d94d6277282d9f514827ac56e4b77fe4ce61c5
--- /dev/null
+++ b/src/common/slurm_accounting_storage.c
@@ -0,0 +1,2029 @@
+/*****************************************************************************\
+ *  slurm_accounting_storage.c - account storage plugin wrapper.
+ *
+ *  $Id: slurm_accounting_storage.c 10744 2007-01-11 20:09:18Z da $
+ *****************************************************************************
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Aubke <da@llnl.gov>.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <pthread.h>
+
+#include "src/common/list.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/plugin.h"
+#include "src/common/plugrack.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/xstring.h"
+#include "src/slurmctld/slurmctld.h"
+#include "src/sacctmgr/sacctmgr.h"
+
+/*
+ * Local data
+ */
+
+typedef struct slurm_acct_storage_ops {
+	void *(*get_conn)          (bool make_agent, bool rollback);
+	int  (*close_conn)         (void **db_conn);
+	int  (*commit)             (void *db_conn, bool commit);
+	int  (*add_users)          (void *db_conn, uint32_t uid,
+				    List user_list);
+	int  (*add_coord)          (void *db_conn, uint32_t uid,
+				    char *acct,
+				    acct_user_cond_t *user_q);
+	int  (*add_accts)          (void *db_conn, uint32_t uid,
+				    List acct_list);
+	int  (*add_clusters)       (void *db_conn, uint32_t uid,
+				    List cluster_list);
+	int  (*add_associations)   (void *db_conn, uint32_t uid,
+				    List association_list);
+	List (*modify_users)       (void *db_conn, uint32_t uid,
+				    acct_user_cond_t *user_q,
+				    acct_user_rec_t *user);
+	List (*modify_accts)       (void *db_conn, uint32_t uid,
+				    acct_account_cond_t *acct_q,
+				    acct_account_rec_t *acct);
+	List (*modify_clusters)    (void *db_conn, uint32_t uid,
+				    acct_cluster_cond_t *cluster_q,
+				    acct_cluster_rec_t *cluster);
+	List (*modify_associations)(void *db_conn, uint32_t uid,
+				    acct_association_cond_t *assoc_q,
+				    acct_association_rec_t *assoc);
+	List (*remove_users)       (void *db_conn, uint32_t uid,
+				    acct_user_cond_t *user_q);
+	List (*remove_coord)       (void *db_conn, uint32_t uid,
+				    char *acct,
+				    acct_user_cond_t *user_q);
+	List (*remove_accts)       (void *db_conn, uint32_t uid,
+				    acct_account_cond_t *acct_q);
+	List (*remove_clusters)    (void *db_conn, uint32_t uid,
+				    acct_cluster_cond_t *cluster_q);
+	List (*remove_associations)(void *db_conn, uint32_t uid,
+				    acct_association_cond_t *assoc_q);
+	List (*get_users)          (void *db_conn,
+				    acct_user_cond_t *user_q);
+	List (*get_accts)          (void *db_conn,
+				    acct_account_cond_t *acct_q);
+	List (*get_clusters)       (void *db_conn,
+				    acct_cluster_cond_t *cluster_q);
+	List (*get_associations)   (void *db_conn,
+				    acct_association_cond_t *assoc_q);
+	int  (*get_usage)          (void *db_conn,
+				    void *acct_assoc,
+				    time_t start, 
+				    time_t end);
+	int (*roll_usage)          (void *db_conn, 
+				    time_t sent_start);
+	int  (*node_down)          (void *db_conn,
+				    char *cluster,
+				    struct node_record *node_ptr,
+				    time_t event_time,
+				    char *reason);
+	int  (*node_up)            (void *db_conn,
+				    char *cluster,
+				    struct node_record *node_ptr,
+				    time_t event_time);
+	int  (*cluster_procs)      (void *db_conn,
+				    char *cluster,
+				    uint32_t procs, time_t event_time);
+	int  (*c_get_usage)        (void *db_conn,
+				    void *cluster_rec, 
+				    time_t start, time_t end);
+	int  (*register_ctld)      (char *cluster, uint16_t port);
+	int  (*job_start)          (void *db_conn,
+				    struct job_record *job_ptr);
+	int  (*job_complete)       (void *db_conn,
+				    struct job_record *job_ptr);
+	int  (*step_start)         (void *db_conn,
+				    struct step_record *step_ptr);
+	int  (*step_complete)      (void *db_conn,
+				    struct step_record *step_ptr);
+	int  (*job_suspend)        (void *db_conn,
+				    struct job_record *job_ptr);
+	List (*get_jobs)           (void *db_conn,
+				    List selected_steps,
+				    List selected_parts,
+				    void *params);	
+	void (*job_archive)        (void *db_conn,
+				    List selected_parts, void *params);	
+	int (*update_shares_used)  (void *db_conn,
+				    List shares_used);
+	int (*flush_jobs)          (void *db_conn,
+				    char *cluster,
+				    time_t event_time);
+} slurm_acct_storage_ops_t;
+
+typedef struct slurm_acct_storage_context {
+	char	       	*acct_storage_type;
+	plugrack_t     	plugin_list;
+	plugin_handle_t	cur_plugin;
+	int		acct_storage_errno;
+	slurm_acct_storage_ops_t ops;
+} slurm_acct_storage_context_t;
+
+static slurm_acct_storage_context_t * g_acct_storage_context = NULL;
+static pthread_mutex_t		g_acct_storage_context_lock = 
+					PTHREAD_MUTEX_INITIALIZER;
+
+/*
+ * Local functions
+ */
+static slurm_acct_storage_ops_t *_acct_storage_get_ops(
+	slurm_acct_storage_context_t *c);
+static slurm_acct_storage_context_t *_acct_storage_context_create(
+	const char *acct_storage_type);
+static int _acct_storage_context_destroy(
+	slurm_acct_storage_context_t *c);
+
+/*
+ * Locate and load the appropriate plugin
+ */
+static slurm_acct_storage_ops_t * _acct_storage_get_ops(
+	slurm_acct_storage_context_t *c)
+{
+	/*
+	 * Must be synchronized with slurm_acct_storage_ops_t above.
+	 */
+	static const char *syms[] = {
+		"acct_storage_p_get_connection",
+		"acct_storage_p_close_connection",
+		"acct_storage_p_commit",
+		"acct_storage_p_add_users",
+		"acct_storage_p_add_coord",
+		"acct_storage_p_add_accts",
+		"acct_storage_p_add_clusters",
+		"acct_storage_p_add_associations",
+		"acct_storage_p_modify_users",
+		"acct_storage_p_modify_accts",
+		"acct_storage_p_modify_clusters",
+		"acct_storage_p_modify_associations",
+		"acct_storage_p_remove_users",
+		"acct_storage_p_remove_coord",
+		"acct_storage_p_remove_accts",
+		"acct_storage_p_remove_clusters",
+		"acct_storage_p_remove_associations",
+		"acct_storage_p_get_users",
+		"acct_storage_p_get_accts",
+		"acct_storage_p_get_clusters",
+		"acct_storage_p_get_associations",
+		"acct_storage_p_get_usage",
+		"acct_storage_p_roll_usage",
+		"clusteracct_storage_p_node_down",
+		"clusteracct_storage_p_node_up",
+		"clusteracct_storage_p_cluster_procs",
+		"clusteracct_storage_p_get_usage",
+		"clusteracct_storage_p_register_ctld",
+		"jobacct_storage_p_job_start",
+		"jobacct_storage_p_job_complete",
+		"jobacct_storage_p_step_start",
+		"jobacct_storage_p_step_complete",
+		"jobacct_storage_p_suspend",
+		"jobacct_storage_p_get_jobs",
+		"jobacct_storage_p_archive",
+		"acct_storage_p_update_shares_used",
+		"acct_storage_p_flush_jobs_on_cluster"
+	};
+	int n_syms = sizeof( syms ) / sizeof( char * );
+
+	/* Get plugin list. */
+	if ( c->plugin_list == NULL ) {
+		char *plugin_dir;
+		c->plugin_list = plugrack_create();
+		if ( c->plugin_list == NULL ) {
+			error( "cannot create plugin manager" );
+			return NULL;
+		}
+		plugrack_set_major_type( c->plugin_list, "accounting_storage" );
+		plugrack_set_paranoia( c->plugin_list,
+				       PLUGRACK_PARANOIA_NONE,
+				       0 );
+		plugin_dir = slurm_get_plugin_dir();
+		plugrack_read_dir( c->plugin_list, plugin_dir );
+		xfree(plugin_dir);
+	}
+
+	c->cur_plugin = plugrack_use_by_type( c->plugin_list,
+					      c->acct_storage_type );
+	if ( c->cur_plugin == PLUGIN_INVALID_HANDLE ) {
+		error( "cannot find accounting_storage plugin for %s", 
+			c->acct_storage_type );
+		return NULL;
+	}
+
+	/* Dereference the API. */
+	if ( plugin_get_syms( c->cur_plugin,
+			      n_syms,
+			      syms,
+			      (void **) &c->ops ) < n_syms ) {
+		error( "incomplete acct_storage plugin detected" );
+		return NULL;
+	}
+
+	return &c->ops;
+}
+
+/*
+ * Create a acct_storage context
+ */
+static slurm_acct_storage_context_t *_acct_storage_context_create(
+	const char *acct_storage_type)
+{
+	slurm_acct_storage_context_t *c;
+
+	if ( acct_storage_type == NULL ) {
+		debug3( "_acct_storage_context_create: no uler type" );
+		return NULL;
+	}
+
+	c = xmalloc( sizeof( slurm_acct_storage_context_t ) );
+	c->acct_storage_type	= xstrdup( acct_storage_type );
+	c->plugin_list	= NULL;
+	c->cur_plugin	= PLUGIN_INVALID_HANDLE;
+	c->acct_storage_errno	= SLURM_SUCCESS;
+
+	return c;
+}
+
+/*
+ * Destroy a acct_storage context
+ */
+static int _acct_storage_context_destroy(slurm_acct_storage_context_t *c)
+{
+	/*
+	 * Must check return code here because plugins might still
+	 * be loaded and active.
+	 */
+	if ( c->plugin_list ) {
+		if ( plugrack_destroy( c->plugin_list ) != SLURM_SUCCESS ) {
+			return SLURM_ERROR;
+		}
+	}
+
+	xfree( c->acct_storage_type );
+	xfree( c );
+
+	return SLURM_SUCCESS;
+}
+
+extern void destroy_acct_user_rec(void *object)
+{
+	acct_user_rec_t *acct_user = (acct_user_rec_t *)object;
+
+	if(acct_user) {
+		if(acct_user->assoc_list)
+			list_destroy(acct_user->assoc_list);
+		if(acct_user->coord_accts)
+			list_destroy(acct_user->coord_accts);
+		xfree(acct_user->default_acct);
+		xfree(acct_user->name);
+		xfree(acct_user);
+	}
+}
+
+extern void destroy_acct_account_rec(void *object)
+{
+	acct_account_rec_t *acct_account =
+		(acct_account_rec_t *)object;
+
+	if(acct_account) {
+		if(acct_account->assoc_list)
+			list_destroy(acct_account->assoc_list);
+		if(acct_account->coordinators)
+			list_destroy(acct_account->coordinators);
+		xfree(acct_account->description);
+		xfree(acct_account->name);
+		xfree(acct_account->organization);
+		xfree(acct_account);
+	}
+}
+
+extern void destroy_acct_coord_rec(void *object)
+{
+	acct_coord_rec_t *acct_coord =
+		(acct_coord_rec_t *)object;
+
+	if(acct_coord) {
+		xfree(acct_coord->acct_name);
+		xfree(acct_coord);
+	}
+}
+
+extern void destroy_cluster_accounting_rec(void *object)
+{
+	cluster_accounting_rec_t *clusteracct_rec =
+		(cluster_accounting_rec_t *)object;
+
+	if(clusteracct_rec) {
+		xfree(clusteracct_rec);
+	}
+}
+
+extern void destroy_acct_cluster_rec(void *object)
+{
+	acct_cluster_rec_t *acct_cluster =
+		(acct_cluster_rec_t *)object;
+
+	if(acct_cluster) {
+		if(acct_cluster->accounting_list)
+			list_destroy(acct_cluster->accounting_list);
+		xfree(acct_cluster->control_host);
+		xfree(acct_cluster->name);
+		xfree(acct_cluster);
+	}
+}
+
+extern void destroy_acct_accounting_rec(void *object)
+{
+	acct_accounting_rec_t *acct_accounting =
+		(acct_accounting_rec_t *)object;
+
+	if(acct_accounting) {
+		xfree(acct_accounting);
+	}
+}
+
+extern void destroy_acct_association_rec(void *object)
+{
+	acct_association_rec_t *acct_association = 
+		(acct_association_rec_t *)object;
+
+	if(acct_association) {
+		if(acct_association->accounting_list)
+			list_destroy(acct_association->accounting_list);
+		xfree(acct_association->acct);
+		xfree(acct_association->cluster);
+		xfree(acct_association->parent_acct);
+		xfree(acct_association->partition);
+		xfree(acct_association->user);
+		xfree(acct_association);
+	}
+}
+
+extern void destroy_acct_user_cond(void *object)
+{
+	acct_user_cond_t *acct_user = (acct_user_cond_t *)object;
+
+	if(acct_user) {
+		destroy_acct_association_cond(acct_user->assoc_cond);
+		if(acct_user->def_acct_list)
+			list_destroy(acct_user->def_acct_list);
+		if(acct_user->user_list)
+			list_destroy(acct_user->user_list);
+		xfree(acct_user);
+	}
+}
+
+extern void destroy_acct_account_cond(void *object)
+{
+	acct_account_cond_t *acct_account =
+		(acct_account_cond_t *)object;
+
+	if(acct_account) {
+		if(acct_account->acct_list)
+			list_destroy(acct_account->acct_list);
+		destroy_acct_association_cond(acct_account->assoc_cond);
+		if(acct_account->description_list)
+			list_destroy(acct_account->description_list);
+		if(acct_account->organization_list)
+			list_destroy(acct_account->organization_list);
+		xfree(acct_account);
+	}
+}
+
+extern void destroy_acct_cluster_cond(void *object)
+{
+	acct_cluster_cond_t *acct_cluster =
+		(acct_cluster_cond_t *)object;
+
+	if(acct_cluster) {
+		if(acct_cluster->cluster_list)
+			list_destroy(acct_cluster->cluster_list);
+		xfree(acct_cluster);
+	}
+}
+
+extern void destroy_acct_association_cond(void *object)
+{
+	acct_association_cond_t *acct_association = 
+		(acct_association_cond_t *)object;
+
+	if(acct_association) {
+		if(acct_association->acct_list)
+			list_destroy(acct_association->acct_list);
+		if(acct_association->cluster_list)
+			list_destroy(acct_association->cluster_list);
+		if(acct_association->id_list)
+			list_destroy(acct_association->id_list);
+		if(acct_association->partition_list)
+			list_destroy(acct_association->partition_list);
+		xfree(acct_association->parent_acct);
+		if(acct_association->user_list)
+			list_destroy(acct_association->user_list);
+		xfree(acct_association);
+	}
+}
+
+extern void destroy_acct_update_object(void *object)
+{
+	acct_update_object_t *acct_update = 
+		(acct_update_object_t *) object;
+
+	if(acct_update) {
+		if(acct_update->objects)
+			list_destroy(acct_update->objects);
+		xfree(acct_update);
+	}
+}
+
+extern void destroy_update_shares_rec(void *object)
+{
+	xfree(object);
+}
+
+/****************************************************************************\
+ * Pack and unpack data structures
+\****************************************************************************/
+extern void pack_acct_user_rec(void *in, Buf buffer)
+{
+	ListIterator itr = NULL;
+	acct_user_rec_t *object = (acct_user_rec_t *)in;
+	uint32_t count = 0;
+	acct_coord_rec_t *coord = NULL;
+	acct_association_rec_t *assoc = NULL;
+
+	if(!object) {
+		pack16(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		packnull(buffer);
+		packnull(buffer);
+		pack16(0, buffer);
+		pack32(0, buffer);
+		return;
+	}
+ 
+	pack16((uint16_t)object->admin_level, buffer);
+	if(object->assoc_list)
+		count = list_count(object->assoc_list);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->assoc_list);
+		while((assoc = list_next(itr))) {
+			pack_acct_association_rec(assoc, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	if(object->coord_accts)
+		count = list_count(object->coord_accts);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->coord_accts);
+		while((coord = list_next(itr))) {
+			pack_acct_coord_rec(coord, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	packstr(object->default_acct, buffer);
+	packstr(object->name, buffer);
+	pack16((uint16_t)object->qos, buffer);
+	pack32(object->uid, buffer);
+}
+
+extern int unpack_acct_user_rec(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	acct_user_rec_t *object_ptr = xmalloc(sizeof(acct_user_rec_t));
+	uint32_t count = 0;
+	acct_coord_rec_t *coord = NULL;
+	acct_association_rec_t *assoc = NULL;
+	int i;
+
+	*object = object_ptr;
+	safe_unpack16((uint16_t *)&object_ptr->admin_level, buffer);
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->assoc_list =
+			list_create(destroy_acct_association_rec);
+		for(i=0; i<count; i++) {
+			unpack_acct_association_rec((void *)&assoc, buffer);
+			list_append(object_ptr->assoc_list, assoc);
+		}
+	}
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->coord_accts = list_create(destroy_acct_coord_rec);
+		for(i=0; i<count; i++) {
+			unpack_acct_coord_rec((void *)&coord, buffer);
+			list_append(object_ptr->coord_accts, coord);
+		}
+	}
+	safe_unpackstr_xmalloc(&object_ptr->default_acct, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
+	safe_unpack16((uint16_t *)&object_ptr->qos, buffer);
+	safe_unpack32(&object_ptr->uid, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_user_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_update_shares_used(void *object, Buf buffer)
+{
+	shares_used_object_t *object_ptr = (shares_used_object_t *) object;
+	pack32(object_ptr->assoc_id, buffer);
+	pack32(object_ptr->shares_used, buffer);
+}
+
+extern int unpack_update_shares_used(void **object, Buf buffer)
+{
+	shares_used_object_t *object_ptr = xmalloc(sizeof(shares_used_object_t));
+
+	*object = (void *) object_ptr;
+	safe_unpack32(&object_ptr->assoc_id, buffer);
+	safe_unpack32(&object_ptr->shares_used, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_update_shares_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+extern void pack_acct_account_rec(void *in, Buf buffer)
+{
+	char *coord = NULL;
+	ListIterator itr = NULL;
+	uint32_t count = 0;
+	acct_account_rec_t *object = (acct_account_rec_t *)in;
+	acct_association_rec_t *assoc = NULL;
+
+	if(!object) {
+		pack32(0, buffer);
+		pack32(0, buffer);
+		packnull(buffer);
+		packnull(buffer);
+		packnull(buffer);
+		pack16(0, buffer);
+		return;
+	}
+ 
+	if(object->assoc_list)
+		count = list_count(object->assoc_list);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->assoc_list);
+		while((assoc = list_next(itr))) {
+			pack_acct_association_rec(assoc, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	if(object->coordinators)
+		count = list_count(object->coordinators);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->coordinators);
+		while((coord = list_next(itr))) {
+			packstr(coord, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	packstr(object->description, buffer);
+	packstr(object->name, buffer);
+	packstr(object->organization, buffer);
+	pack16((uint16_t)object->qos, buffer);
+}
+
+extern int unpack_acct_account_rec(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	int i;
+	uint32_t count;
+	char *coord = NULL;
+	acct_association_rec_t *assoc = NULL;
+	acct_account_rec_t *object_ptr = xmalloc(sizeof(acct_account_rec_t));
+
+	*object = object_ptr;
+
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->assoc_list =
+			list_create(destroy_acct_association_rec);
+		for(i=0; i<count; i++) {
+			unpack_acct_association_rec((void *)&assoc, buffer);
+			list_append(object_ptr->assoc_list, assoc);
+		}
+	}
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->coordinators = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&coord, &uint32_tmp, buffer);
+			list_append(object_ptr->coordinators, coord);
+		}
+	}
+	safe_unpackstr_xmalloc(&object_ptr->description, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->organization, &uint32_tmp, buffer);
+	safe_unpack16((uint16_t *)&object_ptr->qos, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_account_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_coord_rec(void *in, Buf buffer)
+{
+	acct_coord_rec_t *object = (acct_coord_rec_t *)in;
+
+	if(!object) {
+		packnull(buffer);
+		pack16(0, buffer);
+		return;
+	}
+
+	packstr(object->acct_name, buffer);
+	pack16(object->sub_acct, buffer);
+}
+
+extern int unpack_acct_coord_rec(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	acct_coord_rec_t *object_ptr = xmalloc(sizeof(acct_coord_rec_t));
+
+	*object = object_ptr;
+	safe_unpackstr_xmalloc(&object_ptr->acct_name, &uint32_tmp, buffer);
+	safe_unpack16(&object_ptr->sub_acct, buffer);
+
+unpack_error:
+	destroy_acct_coord_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_cluster_accounting_rec(void *in, Buf buffer)
+{
+	cluster_accounting_rec_t *object = (cluster_accounting_rec_t *)in;
+	
+	if(!object) {
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack_time(0, buffer);
+		pack32(0, buffer);
+		return;
+	}
+
+ 	pack32(object->alloc_secs, buffer);
+	pack32(object->cpu_count, buffer);
+	pack32(object->down_secs, buffer);
+	pack32(object->idle_secs, buffer);
+	pack_time(object->period_start, buffer);
+	pack32(object->resv_secs, buffer);
+}
+
+extern int unpack_cluster_accounting_rec(void **object, Buf buffer)
+{
+	cluster_accounting_rec_t *object_ptr =
+		xmalloc(sizeof(cluster_accounting_rec_t));
+	
+	*object = object_ptr;
+	safe_unpack32(&object_ptr->alloc_secs, buffer);
+	safe_unpack32(&object_ptr->cpu_count, buffer);
+	safe_unpack32(&object_ptr->down_secs, buffer);
+	safe_unpack32(&object_ptr->idle_secs, buffer);
+	safe_unpack_time(&object_ptr->period_start, buffer);
+	safe_unpack32(&object_ptr->resv_secs, buffer);
+	
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_cluster_accounting_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_cluster_rec(void *in, Buf buffer)
+{
+	cluster_accounting_rec_t *acct_info = NULL;
+	ListIterator itr = NULL;
+	uint32_t count = 0;
+	acct_cluster_rec_t *object = (acct_cluster_rec_t *)in;
+
+	if(!object) {
+		pack32(0, buffer);
+		packnull(buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		packnull(buffer);
+		return;
+	}
+ 
+	if(object->accounting_list)
+		count = list_count(object->accounting_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(object->accounting_list);
+		while((acct_info = list_next(itr))) {
+			pack_cluster_accounting_rec(acct_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	packstr(object->control_host, buffer);
+	pack32(object->control_port, buffer);
+	pack32(object->default_fairshare, buffer);
+	pack32(object->default_max_cpu_secs_per_job, buffer);
+	pack32(object->default_max_jobs, buffer);
+	pack32(object->default_max_nodes_per_job, buffer);
+	pack32(object->default_max_wall_duration_per_job, buffer);
+
+	packstr(object->name, buffer);
+}
+
+extern int unpack_acct_cluster_rec(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	int i;
+	uint32_t count;
+	acct_cluster_rec_t *object_ptr = xmalloc(sizeof(acct_cluster_rec_t));
+	cluster_accounting_rec_t *acct_info = NULL;
+
+	*object = object_ptr;
+
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->accounting_list =
+			list_create(destroy_cluster_accounting_rec);
+		for(i=0; i<count; i++) {
+			unpack_cluster_accounting_rec((void *)&acct_info,
+						      buffer);
+			list_append(object_ptr->accounting_list, acct_info);
+		}
+	}
+	safe_unpackstr_xmalloc(&object_ptr->control_host, &uint32_tmp, buffer);
+	safe_unpack32(&object_ptr->control_port, buffer);
+	safe_unpack32(&object_ptr->default_fairshare, buffer);
+	safe_unpack32(&object_ptr->default_max_cpu_secs_per_job, buffer);
+	safe_unpack32(&object_ptr->default_max_jobs, buffer);
+	safe_unpack32(&object_ptr->default_max_nodes_per_job, buffer);
+	safe_unpack32(&object_ptr->default_max_wall_duration_per_job, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->name, &uint32_tmp, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_cluster_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_accounting_rec(void *in, Buf buffer)
+{
+	acct_accounting_rec_t *object = (acct_accounting_rec_t *)in;
+	
+	if(!object) {
+		pack_time(0, buffer);
+		pack32(0, buffer);
+		return;
+	}
+
+	pack_time(object->period_start, buffer);
+	pack32(object->alloc_secs, buffer);
+}
+
+extern int unpack_acct_accounting_rec(void **object, Buf buffer)
+{
+	acct_accounting_rec_t *object_ptr =
+		xmalloc(sizeof(acct_accounting_rec_t));
+	
+	*object = object_ptr;
+	safe_unpack_time(&object_ptr->period_start, buffer);
+	safe_unpack32(&object_ptr->alloc_secs, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_accounting_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_association_rec(void *in, Buf buffer)
+{
+	acct_accounting_rec_t *acct_info = NULL;
+	ListIterator itr = NULL;
+	uint32_t count = 0;
+	acct_association_rec_t *object = (acct_association_rec_t *)in;	
+	
+	if(!object) {
+		pack32(0, buffer);
+		packnull(buffer);
+		packnull(buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		packnull(buffer);
+		pack32(0, buffer);
+		packnull(buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		packnull(buffer);
+		return;
+	}
+ 
+	if(object->accounting_list)
+		count = list_count(object->accounting_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(object->accounting_list);
+		while((acct_info = list_next(itr))) {
+			pack_acct_accounting_rec(acct_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	packstr(object->acct, buffer);
+	packstr(object->cluster, buffer);
+	pack32(object->fairshare, buffer);
+	pack32(object->id, buffer);
+	pack32(object->max_cpu_secs_per_job, buffer);
+	pack32(object->max_jobs, buffer);
+	pack32(object->max_nodes_per_job, buffer);
+	pack32(object->max_wall_duration_per_job, buffer);
+	packstr(object->parent_acct, buffer);
+	pack32(object->parent_id, buffer);
+	packstr(object->partition, buffer);
+	pack32(object->uid, buffer);
+	pack32(object->used_share, buffer);
+	packstr(object->user, buffer);	
+}
+
+extern int unpack_acct_association_rec(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	int i;
+	uint32_t count;
+	acct_association_rec_t *object_ptr = 
+		xmalloc(sizeof(acct_association_rec_t));
+	acct_accounting_rec_t *acct_info = NULL;
+
+	*object = object_ptr;
+
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->accounting_list =
+			list_create(destroy_acct_accounting_rec);
+		for(i=0; i<count; i++) {
+			unpack_acct_accounting_rec((void **)&acct_info, buffer);
+			list_append(object_ptr->accounting_list, acct_info);
+		}
+	}
+	safe_unpackstr_xmalloc(&object_ptr->acct, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->cluster, &uint32_tmp, buffer);
+	safe_unpack32(&object_ptr->fairshare, buffer);
+	safe_unpack32(&object_ptr->id, buffer);
+	safe_unpack32(&object_ptr->max_cpu_secs_per_job, buffer);
+	safe_unpack32(&object_ptr->max_jobs, buffer);
+	safe_unpack32(&object_ptr->max_nodes_per_job, buffer);
+	safe_unpack32(&object_ptr->max_wall_duration_per_job, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->parent_acct, &uint32_tmp, buffer);
+	safe_unpack32(&object_ptr->parent_id, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->partition, &uint32_tmp, buffer);
+	safe_unpack32(&object_ptr->uid, buffer);
+	safe_unpack32(&object_ptr->used_share, buffer);
+	safe_unpackstr_xmalloc(&object_ptr->user, &uint32_tmp, buffer);
+
+	//log_assoc_rec(object_ptr);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_association_rec(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_user_cond(void *in, Buf buffer)
+{
+	char *tmp_info = NULL;
+	ListIterator itr = NULL;
+	acct_user_cond_t *object = (acct_user_cond_t *)in;
+	uint32_t count = 0;
+
+	if(!object) {
+		pack16(0, buffer);
+		pack_acct_association_cond(NULL, buffer);
+		pack32(0, buffer);
+		pack16(0, buffer);
+		pack32(0, buffer);
+		pack16(0, buffer);
+		return;
+	}
+ 
+	pack16((uint16_t)object->admin_level, buffer);
+
+	pack_acct_association_cond(object->assoc_cond, buffer);
+	
+	if(object->def_acct_list)
+		count = list_count(object->def_acct_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(object->def_acct_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	pack16((uint16_t)object->qos, buffer);
+
+	if(object->user_list)
+		count = list_count(object->user_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(object->user_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	pack16((uint16_t)object->with_assocs, buffer);
+
+}
+
+extern int unpack_acct_user_cond(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	int i;
+	uint32_t count;
+	acct_user_cond_t *object_ptr = xmalloc(sizeof(acct_user_cond_t));
+	char *tmp_info = NULL;
+
+	*object = object_ptr;
+
+	safe_unpack16((uint16_t *)&object_ptr->admin_level, buffer);
+
+	if(unpack_acct_association_cond((void **)&object_ptr->assoc_cond,
+					buffer) == SLURM_ERROR)
+		goto unpack_error;
+	
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->def_acct_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->def_acct_list, tmp_info);
+		}
+	}
+	safe_unpack16((uint16_t *)&object_ptr->qos, buffer);
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->user_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->user_list, tmp_info);
+		}
+	}
+	safe_unpack16((uint16_t *)&object_ptr->with_assocs, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_user_cond(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_account_cond(void *in, Buf buffer)
+{
+	char *tmp_info = NULL;
+	ListIterator itr = NULL;
+	acct_account_cond_t *object = (acct_account_cond_t *)in;
+	uint32_t count = 0;
+
+	if(!object) {
+		pack32(0, buffer);
+		pack_acct_association_cond(NULL, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack16(0, buffer);
+		pack16(0, buffer);
+		return;
+	}
+ 	if(object->acct_list)
+		count = list_count(object->acct_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(object->acct_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+
+	pack_acct_association_cond(object->assoc_cond, buffer);
+	
+	count = 0;
+	if(object->description_list)
+		count = list_count(object->description_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(object->description_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	if(object->organization_list)
+		count = list_count(object->organization_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(object->organization_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	pack16((uint16_t)object->qos, buffer);
+	pack16((uint16_t)object->with_assocs, buffer);
+}
+
+extern int unpack_acct_account_cond(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	int i;
+	uint32_t count;
+	acct_account_cond_t *object_ptr = xmalloc(sizeof(acct_account_cond_t));
+	char *tmp_info = NULL;
+
+	*object = object_ptr;
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->acct_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->acct_list, tmp_info);
+		}
+	}
+
+	if(unpack_acct_association_cond((void **)&object_ptr->assoc_cond,
+					buffer) == SLURM_ERROR)
+		goto unpack_error;
+	
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->description_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->description_list, tmp_info);
+		}
+	}
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->organization_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->organization_list, tmp_info);
+		}
+	}
+	safe_unpack16((uint16_t *)&object_ptr->qos, buffer);
+	safe_unpack16((uint16_t *)&object_ptr->with_assocs, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_account_cond(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_cluster_cond(void *in, Buf buffer)
+{
+	char *tmp_info = NULL;
+	ListIterator itr = NULL;
+	acct_cluster_cond_t *object = (acct_cluster_cond_t *)in;
+	uint32_t count = 0;
+
+	if(!object) {
+		pack32(0, buffer);
+		pack16(0, buffer);
+		return;
+	}
+ 
+	if(object->cluster_list)
+		count = list_count(object->cluster_list);
+	
+	pack32(count, buffer);
+			
+	if(count) {
+		itr = list_iterator_create(object->cluster_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+}
+
+extern int unpack_acct_cluster_cond(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	int i;
+	uint32_t count;
+	acct_cluster_cond_t *object_ptr = xmalloc(sizeof(acct_cluster_cond_t));
+	char *tmp_info = NULL;
+
+	*object = object_ptr;
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->cluster_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->cluster_list, tmp_info);
+		}
+	}
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_cluster_cond(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_association_cond(void *in, Buf buffer)
+{
+	char *tmp_info = NULL;
+	uint32_t count = 0;
+
+	ListIterator itr = NULL;
+	acct_association_cond_t *object = (acct_association_cond_t *)in;
+
+	if(!object) {
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		pack32(0, buffer);
+		packnull(buffer);
+		pack32(0, buffer);
+		return;
+	}
+
+	if(object->acct_list)
+		count = list_count(object->acct_list);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->acct_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	if(object->cluster_list)
+		count = list_count(object->cluster_list);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->cluster_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	pack32(object->fairshare, buffer);
+	
+	if(object->id_list)
+		count = list_count(object->id_list);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->id_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+	}
+	count = 0;
+
+	pack32(object->max_cpu_secs_per_job, buffer);
+	pack32(object->max_jobs, buffer);
+	pack32(object->max_nodes_per_job, buffer);
+	pack32(object->max_wall_duration_per_job, buffer);
+
+	if(object->partition_list)
+		count = list_count(object->partition_list);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->partition_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+
+	packstr(object->parent_acct, buffer);
+
+	if(object->user_list)
+		count = list_count(object->user_list);
+	
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->user_list);
+		while((tmp_info = list_next(itr))) {
+			packstr(tmp_info, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	count = 0;
+}
+
+extern int unpack_acct_association_cond(void **object, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	int i;
+	uint32_t count;
+	acct_association_cond_t *object_ptr =
+		xmalloc(sizeof(acct_association_cond_t));
+	char *tmp_info = NULL;
+
+	*object = object_ptr;
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->acct_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->acct_list, tmp_info);
+		}
+	}
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->cluster_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->cluster_list, tmp_info);
+		}
+	}
+
+	safe_unpack32(&object_ptr->fairshare, buffer);
+
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->id_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->id_list, tmp_info);
+		}
+	}
+	
+	safe_unpack32(&object_ptr->max_cpu_secs_per_job, buffer);
+	safe_unpack32(&object_ptr->max_jobs, buffer);
+	safe_unpack32(&object_ptr->max_nodes_per_job, buffer);
+	safe_unpack32(&object_ptr->max_wall_duration_per_job, buffer);
+
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->partition_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->partition_list, tmp_info);
+		}
+	}
+
+	safe_unpackstr_xmalloc(&object_ptr->parent_acct, &uint32_tmp, buffer);
+
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->user_list = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&tmp_info, &uint32_tmp, buffer);
+			list_append(object_ptr->user_list, tmp_info);
+		}
+	}
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	destroy_acct_association_cond(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern void pack_acct_update_object(acct_update_object_t *object, Buf buffer)
+{
+	uint32_t count = 0;
+	ListIterator itr = NULL;
+	void *acct_object = NULL;
+	void (*my_function) (void *object, Buf buffer);
+
+	pack16(object->type, buffer);
+	switch(object->type) {
+	case ACCT_MODIFY_USER:
+	case ACCT_ADD_USER:
+	case ACCT_REMOVE_USER:
+		my_function = pack_acct_user_rec;
+		break;
+	case ACCT_ADD_ASSOC:
+	case ACCT_MODIFY_ASSOC:
+	case ACCT_REMOVE_ASSOC:
+		my_function = pack_acct_association_rec;
+		break;
+	case ACCT_UPDATE_NOTSET:
+	default:
+		error("unknown type set in update_object: %d", object->type);
+		return;
+	}
+	if(object->objects) 
+		count = list_count(object->objects);
+			
+	pack32(count, buffer);
+	if(count) {
+		itr = list_iterator_create(object->objects);
+		while((acct_object = list_next(itr))) {
+			(*(my_function))(acct_object, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+}
+
+extern int unpack_acct_update_object(acct_update_object_t **object, Buf buffer)
+{
+	int i;
+	uint32_t count;
+	acct_update_object_t *object_ptr = 
+		xmalloc(sizeof(acct_update_object_t));
+	void *acct_object = NULL;
+	int (*my_function) (void **object, Buf buffer);
+	void (*my_destroy) (void *object);
+
+	*object = object_ptr;
+
+	safe_unpack16((uint16_t *)&object_ptr->type, buffer);
+	switch(object_ptr->type) {
+	case ACCT_MODIFY_USER:
+	case ACCT_ADD_USER:
+	case ACCT_REMOVE_USER:
+		my_function = unpack_acct_user_rec;
+		my_destroy = destroy_acct_user_rec;
+		break;
+	case ACCT_ADD_ASSOC:
+	case ACCT_MODIFY_ASSOC:
+	case ACCT_REMOVE_ASSOC:
+		my_function = unpack_acct_association_rec;
+		my_destroy = destroy_acct_association_rec;
+		break;
+	case ACCT_UPDATE_NOTSET:
+	default:
+		error("unknown type set in update_object: %d",
+		      object_ptr->type);
+		goto unpack_error;
+	}
+	safe_unpack32(&count, buffer);
+	if(count) {
+		object_ptr->objects = list_create((*(my_destroy)));
+		for(i=0; i<count; i++) {
+			if(((*(my_function))(&acct_object, buffer))
+			   == SLURM_ERROR)
+				goto unpack_error;
+			list_append(object_ptr->objects, acct_object);
+		}
+	}
+	return SLURM_SUCCESS;
+	
+unpack_error:
+	destroy_acct_update_object(object_ptr);
+	*object = NULL;
+	return SLURM_ERROR;
+}
+
+extern char *acct_qos_str(acct_qos_level_t level)
+{
+	switch(level) {
+	case ACCT_QOS_NOTSET:
+		return "Not Set";
+		break;
+	case ACCT_QOS_NORMAL:
+		return "Normal";
+		break;
+	case ACCT_QOS_EXPEDITE:
+		return "Expedite";
+		break;
+	case ACCT_QOS_STANDBY:
+		return "Standby";
+		break;
+	case ACCT_QOS_EXEMPT:
+		return "Exempt";
+		break;
+	default:
+		return "Unknown";
+		break;
+	}
+	return "Unknown";
+}
+
+extern acct_qos_level_t str_2_acct_qos(char *level)
+{
+	if(!level) {
+		return ACCT_QOS_NOTSET;
+	} else if(!strncasecmp(level, "Normal", 1)) {
+		return ACCT_QOS_NORMAL;
+	} else if(!strncasecmp(level, "Expedite", 3)) {
+		return ACCT_QOS_EXPEDITE;
+	} else if(!strncasecmp(level, "Standby", 1)) {
+		return ACCT_QOS_STANDBY;
+	} else if(!strncasecmp(level, "Exempt", 3)) {
+		return ACCT_QOS_EXEMPT;
+	} else {
+		return ACCT_QOS_NOTSET;		
+	}
+}
+
+extern char *acct_admin_level_str(acct_admin_level_t level)
+{
+	switch(level) {
+	case ACCT_ADMIN_NOTSET:
+		return "Not Set";
+		break;
+	case ACCT_ADMIN_NONE:
+		return "None";
+		break;
+	case ACCT_ADMIN_OPERATOR:
+		return "Operator";
+		break;
+	case ACCT_ADMIN_SUPER_USER:
+		return "Administrator";
+		break;
+	default:
+		return "Unknown";
+		break;
+	}
+	return "Unknown";
+}
+
+extern acct_admin_level_t str_2_acct_admin_level(char *level)
+{
+	if(!level) {
+		return ACCT_ADMIN_NOTSET;
+	} else if(!strncasecmp(level, "None", 1)) {
+		return ACCT_ADMIN_NONE;
+	} else if(!strncasecmp(level, "Operator", 1)) {
+		return ACCT_ADMIN_OPERATOR;
+	} else if(!strncasecmp(level, "SuperUser", 1) 
+		  || !strncasecmp(level, "Admin", 1)) {
+		return ACCT_ADMIN_SUPER_USER;
+	} else {
+		return ACCT_ADMIN_NOTSET;		
+	}	
+}
+
+extern void log_assoc_rec(acct_association_rec_t *assoc_ptr)
+{
+	debug("association rec id          : %u", assoc_ptr->id);
+	debug("  acct                      : %s", assoc_ptr->acct);
+	debug("  cluster                   : %s", assoc_ptr->cluster);
+	if(assoc_ptr->fairshare == INFINITE)
+		debug("  fairshare                 : NONE");
+	else
+		debug("  fairshare                 : %u",
+		       assoc_ptr->fairshare);
+	if(assoc_ptr->max_cpu_secs_per_job == INFINITE)
+		debug("  max_cpu_secs_per_job      : NONE");
+	else
+		debug("  max_cpu_secs_per_job      : %d",
+		     assoc_ptr->max_cpu_secs_per_job);
+	if(assoc_ptr->max_jobs == INFINITE)
+		debug("  max_jobs                  : NONE");
+	else
+		debug("  max_jobs                  : %u", assoc_ptr->max_jobs);
+	if(assoc_ptr->max_nodes_per_job == INFINITE)
+		debug("  max_nodes_per_job         : NONE");
+	else
+		debug("  max_nodes_per_job         : %d",
+		     assoc_ptr->max_nodes_per_job);
+	if(assoc_ptr->max_wall_duration_per_job == INFINITE)
+		debug("  max_wall_duration_per_job : NONE");
+	else
+		debug("  max_wall_duration_per_job : %d", 
+		     assoc_ptr->max_wall_duration_per_job);
+	debug("  parent_acct               : %s", assoc_ptr->parent_acct);
+	debug("  partition                 : %s", assoc_ptr->partition);
+	debug("  user                      : %s(%u)",
+	      assoc_ptr->user, assoc_ptr->uid);
+	debug("  used_jobs                 : %u", assoc_ptr->used_jobs);
+	debug("  used_share                : %u", assoc_ptr->used_share);
+}
+
+/*
+ * Initialize context for acct_storage plugin
+ */
+extern int slurm_acct_storage_init(char *loc)
+{
+	int retval = SLURM_SUCCESS;
+	char *acct_storage_type = NULL;
+	
+	slurm_mutex_lock( &g_acct_storage_context_lock );
+
+	if ( g_acct_storage_context )
+		goto done;
+	if(loc)
+		slurm_set_accounting_storage_loc(loc);
+	
+	acct_storage_type = slurm_get_accounting_storage_type();
+	
+	g_acct_storage_context = _acct_storage_context_create(
+		acct_storage_type);
+	if ( g_acct_storage_context == NULL ) {
+		error( "cannot create acct_storage context for %s",
+		       acct_storage_type );
+		retval = SLURM_ERROR;
+		goto done;
+	}
+
+	if ( _acct_storage_get_ops( g_acct_storage_context ) == NULL ) {
+		error( "cannot resolve acct_storage plugin operations" );
+		_acct_storage_context_destroy( g_acct_storage_context );
+		g_acct_storage_context = NULL;
+		retval = SLURM_ERROR;
+	}
+
+done:
+	slurm_mutex_unlock( &g_acct_storage_context_lock );
+	xfree(acct_storage_type);
+	return retval;
+}
+
+extern int slurm_acct_storage_fini(void)
+{
+	int rc;
+
+	if (!g_acct_storage_context)
+		return SLURM_SUCCESS;
+
+//	(*(g_acct_storage_context->ops.acct_storage_fini))();
+	rc = _acct_storage_context_destroy( g_acct_storage_context );
+	g_acct_storage_context = NULL;
+	return rc;
+}
+
+extern void *acct_storage_g_get_connection(bool make_agent, bool rollback)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.get_conn))(make_agent, rollback);
+}
+
+extern int acct_storage_g_close_connection(void **db_conn)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.close_conn))(db_conn);
+
+}
+
+extern int acct_storage_g_commit(void *db_conn, bool commit)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.commit))(db_conn, commit);
+
+}
+
+extern int acct_storage_g_add_users(void *db_conn, uint32_t uid,
+				    List user_list)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.add_users))
+		(db_conn, uid, user_list);
+}
+
+extern int acct_storage_g_add_coord(void *db_conn, uint32_t uid,
+				    char *acct, acct_user_cond_t *user_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.add_coord))
+		(db_conn, uid, acct, user_q);
+}
+
+extern int acct_storage_g_add_accounts(void *db_conn, uint32_t uid,
+				       List acct_list)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.add_accts))
+		(db_conn, uid, acct_list);
+}
+
+extern int acct_storage_g_add_clusters(void *db_conn, uint32_t uid,
+				       List cluster_list)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.add_clusters))
+		(db_conn, uid, cluster_list);
+}
+
+extern int acct_storage_g_add_associations(void *db_conn, uint32_t uid,
+					   List association_list)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.add_associations))
+		(db_conn, uid, association_list);
+}
+
+extern List acct_storage_g_modify_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q,
+				       acct_user_rec_t *user)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.modify_users))
+		(db_conn, uid, user_q, user);
+}
+
+extern List acct_storage_g_modify_accounts(void *db_conn, uint32_t uid,
+					  acct_account_cond_t *acct_q,
+					  acct_account_rec_t *acct)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.modify_accts))
+		(db_conn, uid, acct_q, acct);
+}
+
+extern List acct_storage_g_modify_clusters(void *db_conn, uint32_t uid,
+					  acct_cluster_cond_t *cluster_q,
+					  acct_cluster_rec_t *cluster)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.modify_clusters))
+		(db_conn, uid, cluster_q, cluster);
+}
+
+extern List acct_storage_g_modify_associations(void *db_conn, uint32_t uid,
+					      acct_association_cond_t *assoc_q,
+					      acct_association_rec_t *assoc)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.modify_associations))
+		(db_conn, uid, assoc_q, assoc);
+}
+
+extern List acct_storage_g_remove_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.remove_users))
+		(db_conn, uid, user_q);
+}
+
+extern List acct_storage_g_remove_coord(void *db_conn, uint32_t uid,
+				       char *acct, acct_user_cond_t *user_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.remove_coord))
+		(db_conn, uid, acct, user_q);
+}
+
+extern List acct_storage_g_remove_accounts(void *db_conn, uint32_t uid,
+					  acct_account_cond_t *acct_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.remove_accts))
+		(db_conn, uid, acct_q);
+}
+
+extern List acct_storage_g_remove_clusters(void *db_conn, uint32_t uid,
+					  acct_cluster_cond_t *cluster_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.remove_clusters))
+		(db_conn, uid, cluster_q);
+}
+
+extern List acct_storage_g_remove_associations(void *db_conn, uint32_t uid,
+					      acct_association_cond_t *assoc_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.remove_associations))
+		(db_conn, uid, assoc_q);
+}
+
+extern List acct_storage_g_get_users(void *db_conn,
+				     acct_user_cond_t *user_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.get_users))(db_conn, user_q);
+}
+
+extern List acct_storage_g_get_accounts(void *db_conn,
+					acct_account_cond_t *acct_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.get_accts))
+		(db_conn, acct_q);
+}
+
+extern List acct_storage_g_get_clusters(void *db_conn,
+					acct_cluster_cond_t *cluster_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.get_clusters))
+		(db_conn, cluster_q);
+}
+
+extern List acct_storage_g_get_associations(void *db_conn,
+					    acct_association_cond_t *assoc_q)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+	return (*(g_acct_storage_context->ops.get_associations))
+		(db_conn, assoc_q);
+}
+
+extern int acct_storage_g_get_usage(void *db_conn, 
+				    void *acct_assoc,
+				    time_t start, time_t end)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.get_usage))
+		(db_conn, acct_assoc, start, end);
+}
+
+extern int acct_storage_g_roll_usage(void *db_conn, 
+				     time_t sent_start)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.roll_usage))(db_conn, sent_start);
+}
+
+extern int clusteracct_storage_g_node_down(void *db_conn,
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time,
+					   char *reason)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+ 	return (*(g_acct_storage_context->ops.node_down))
+		(db_conn, cluster, node_ptr, event_time, reason);
+}
+
+extern int clusteracct_storage_g_node_up(void *db_conn,
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+ 	return (*(g_acct_storage_context->ops.node_up))
+		(db_conn, cluster, node_ptr, event_time);
+}
+
+
+extern int clusteracct_storage_g_cluster_procs(void *db_conn,
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+ 	return (*(g_acct_storage_context->ops.cluster_procs))
+		(db_conn, cluster, procs, event_time);
+}
+
+
+extern int clusteracct_storage_g_get_usage(
+	void *db_conn, void *cluster_rec,
+	time_t start, time_t end)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.c_get_usage))
+		(db_conn, cluster_rec, start, end);
+}
+
+extern int clusteracct_storage_g_register_ctld(char *cluster, uint16_t port)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+ 	return (*(g_acct_storage_context->ops.register_ctld))(cluster, port);
+}
+
+/* 
+ * load into the storage the start of a job
+ */
+extern int jobacct_storage_g_job_start (void *db_conn,
+					struct job_record *job_ptr) 
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.job_start))(db_conn, job_ptr);
+}
+
+/* 
+ * load into the storage the end of a job
+ */
+extern int jobacct_storage_g_job_complete  (void *db_conn,
+					    struct job_record *job_ptr)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.job_complete))(db_conn, job_ptr);
+}
+
+/* 
+ * load into the storage the start of a job step
+ */
+extern int jobacct_storage_g_step_start (void *db_conn,
+					 struct step_record *step_ptr)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.step_start))(db_conn, step_ptr);
+}
+
+/* 
+ * load into the storage the end of a job step
+ */
+extern int jobacct_storage_g_step_complete (void *db_conn,
+					    struct step_record *step_ptr)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+	return (*(g_acct_storage_context->ops.step_complete))(db_conn, step_ptr);
+}
+
+/* 
+ * load into the storage a suspention of a job
+ */
+extern int jobacct_storage_g_job_suspend (void *db_conn,
+					  struct job_record *job_ptr)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+ 	return (*(g_acct_storage_context->ops.job_suspend))(db_conn, job_ptr);
+}
+
+
+/* 
+ * get info from the storage 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_g_get_jobs(void *db_conn,
+				       List selected_steps,
+				       List selected_parts,
+				       void *params)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return NULL;
+ 	return (*(g_acct_storage_context->ops.get_jobs))
+		(db_conn, selected_steps, selected_parts, params);
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void jobacct_storage_g_archive(void *db_conn,
+				      List selected_parts, void *params)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return;
+ 	(*(g_acct_storage_context->ops.job_archive))(db_conn, selected_parts, params);
+	return;
+}
+
+/* 
+ * record shares used information for backup in case slurmctld restarts 
+ * IN:  account_list List of shares_used_object_t *
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_update_shares_used(void *db_conn, List acct_list)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+ 	return (*(g_acct_storage_context->ops.update_shares_used))(db_conn, 
+								   acct_list);
+}
+
+/* 
+ * This should be called when a cluster does a cold start to flush out
+ * any jobs that were running during the restart so we don't have any
+ * jobs in the database "running" forever since no endtime will be
+ * placed in there other wise. 
+ * IN:  char * = cluster name
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_flush_jobs_on_cluster(
+	void *db_conn, char *cluster, time_t event_time)
+{
+	if (slurm_acct_storage_init(NULL) < 0)
+		return SLURM_ERROR;
+ 	return (*(g_acct_storage_context->ops.flush_jobs))
+		(db_conn, cluster, event_time);
+
+}
+
diff --git a/src/common/slurm_accounting_storage.h b/src/common/slurm_accounting_storage.h
new file mode 100644
index 0000000000000000000000000000000000000000..710d0457a50cc10387de02ea407d8400a8cb55dc
--- /dev/null
+++ b/src/common/slurm_accounting_storage.h
@@ -0,0 +1,563 @@
+/*****************************************************************************\
+ *  slurm_accounting_storage.h - Define accounting storage plugin functions.
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _SLURM_ACCOUNTING_STORAGE_H 
+#define _SLURM_ACCOUNTING_STORAGE_H
+
+#include "src/common/list.h"
+#include "src/slurmctld/slurmctld.h"
+#include <slurm/slurm.h>
+#include <slurm/slurm_errno.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+typedef enum {
+	ACCT_ADMIN_NOTSET,
+	ACCT_ADMIN_NONE,
+	ACCT_ADMIN_OPERATOR,
+	ACCT_ADMIN_SUPER_USER
+} acct_admin_level_t;
+
+typedef enum {
+	ACCT_QOS_NOTSET,
+	ACCT_QOS_NORMAL,
+	ACCT_QOS_EXPEDITE,
+	ACCT_QOS_STANDBY,
+	ACCT_QOS_EXEMPT	
+} acct_qos_level_t;
+
+typedef enum {
+	ACCT_UPDATE_NOTSET,
+	ACCT_ADD_USER,
+	ACCT_ADD_ASSOC,
+	ACCT_MODIFY_USER,
+	ACCT_MODIFY_ASSOC,
+	ACCT_REMOVE_USER,
+	ACCT_REMOVE_ASSOC
+} acct_update_type_t;
+
+/* Association conditions used for queries of the database */
+typedef struct {
+	List acct_list;		/* list of char * */
+	List cluster_list;	/* list of char * */
+	uint32_t fairshare;	/* fairshare number */
+	List id_list;		/* list of char */
+	uint32_t max_cpu_secs_per_job; /* max number of cpu seconds this 
+					* association can have per job */
+	uint32_t max_jobs;	/* max number of jobs this association can run
+				 * at one time */
+	uint32_t max_nodes_per_job; /* max number of nodes this
+				     * association can allocate per job */
+	uint32_t max_wall_duration_per_job; /* longest time this association
+					     * can run a job (seconds) */
+	List partition_list;	/* list of char * */
+	char *parent_acct;	/* name of parent account */
+	List user_list;		/* list of char * */
+} acct_association_cond_t;
+
+typedef struct {
+	List acct_list; /* list of char * */
+	acct_association_cond_t *assoc_cond;
+	List description_list; /* list of char * */
+	List organization_list; /* list of char * */
+	acct_qos_level_t qos;	
+	uint16_t with_assocs; 
+} acct_account_cond_t;
+
+typedef struct {
+	List assoc_list; /* list of acct_association_rec_t *'s */
+	List coordinators; /* list of char *'s */
+	char *description;
+	char *name;
+	char *organization;
+	acct_qos_level_t qos;
+} acct_account_rec_t;
+
+typedef struct {
+	uint32_t alloc_secs; /* number of cpu seconds allocated */
+	time_t period_start; 
+} acct_accounting_rec_t;
+
+typedef struct acct_association_rec {
+	List accounting_list; 	/* list of acct_accounting_rec_t *'s */
+	char *acct;		/* account/project associated to association */
+	char *cluster;		/* cluster associated to association */
+	uint32_t fairshare;	/* fairshare number */
+	uint32_t id;		/* id identifing a combination of
+				 * user-account-cluster(-partition) */
+	uint32_t max_cpu_secs_per_job; /* max number of cpu seconds this 
+					   * association can have per job */
+	uint32_t max_jobs;	/* max number of jobs this association can run
+				 * at one time */
+	uint32_t max_nodes_per_job; /* max number of nodes this
+				     * association can allocate per job */
+	uint32_t max_wall_duration_per_job; /* longest time this
+					     * association can run a job */
+	char *parent_acct;	/* name of parent account */
+	struct acct_association_rec *parent_acct_ptr;	/* ptr to parent acct
+							 * set in slurmctld */
+	uint32_t parent_id;	/* id of parent account */
+	char *partition;	/* optional partition in a cluster 
+				 * associated to association */
+	uint32_t uid;		/* user ID */
+	uint32_t used_jobs;	/* count of active jobs */
+	uint32_t used_share;	/* measure of resource usage */
+	char *user;		/* user associated to association */
+} acct_association_rec_t;
+
+typedef struct {
+	List cluster_list; /* list of char * */
+} acct_cluster_cond_t;
+
+typedef struct {
+	List accounting_list; /* list of cluster_accounting_rec_t *'s */
+	char *control_host;
+	uint32_t control_port;
+	uint32_t default_fairshare;	/* fairshare number */
+	uint32_t default_max_cpu_secs_per_job; /* max number of cpu seconds this 
+					* association can have per job */
+	uint32_t default_max_jobs;	/* max number of jobs this association can run
+				 * at one time */
+	uint32_t default_max_nodes_per_job; /* max number of nodes this
+				     * association can allocate per job */
+	uint32_t default_max_wall_duration_per_job; /* longest time this
+					     * association can run a job */
+	char *name;
+
+} acct_cluster_rec_t;
+
+typedef struct {
+	char *acct_name;
+	uint16_t sub_acct;
+} acct_coord_rec_t;
+
+typedef struct {
+	acct_admin_level_t admin_level;
+	acct_association_cond_t *assoc_cond;
+	List def_acct_list; /* list of char * */
+	acct_qos_level_t qos;	
+	List user_list; /* list of char * */
+	uint16_t with_assocs; 
+} acct_user_cond_t;
+
+typedef struct {
+	acct_admin_level_t admin_level;
+	List assoc_list; /* list of acct_association_rec_t *'s */
+	List coord_accts; /* list of acct_coord_rec_t *'s */
+	char *default_acct;
+	char *name;
+	acct_qos_level_t qos;
+	uint32_t uid;
+} acct_user_rec_t;
+
+typedef struct {
+	List objects; /* depending on type */ 
+	acct_update_type_t type;
+} acct_update_object_t;
+
+typedef struct {
+	uint32_t assoc_id;	/* association ID		*/
+	uint32_t shares_used;	/* measure of recent usage	*/
+} shares_used_object_t;
+
+typedef struct {
+	uint32_t alloc_secs; /* number of cpu seconds allocated */
+	uint32_t cpu_count; /* number of cpus during time period */
+	uint32_t down_secs; /* number of cpu seconds down */
+	uint32_t idle_secs; /* number of cpu seconds idle */
+	time_t period_start; /* when this record was started */
+	uint32_t resv_secs; /* number of cpu seconds reserved */	
+} cluster_accounting_rec_t;
+
+extern void destroy_acct_user_rec(void *object);
+extern void destroy_acct_account_rec(void *object);
+extern void destroy_acct_coord_rec(void *object);
+extern void destroy_cluster_accounting_rec(void *object);
+extern void destroy_acct_cluster_rec(void *object);
+extern void destroy_acct_accounting_rec(void *object);
+extern void destroy_acct_association_rec(void *object);
+
+extern void destroy_acct_user_cond(void *object);
+extern void destroy_acct_account_cond(void *object);
+extern void destroy_acct_cluster_cond(void *object);
+extern void destroy_acct_association_cond(void *object);
+
+extern void destroy_acct_update_object(void *object);
+extern void destroy_update_shares_rec(void *object);
+
+/* pack functions */
+extern void pack_acct_user_rec(void *object, Buf buffer);
+extern int unpack_acct_user_rec(void **object, Buf buffer);
+extern void pack_acct_account_rec(void *object, Buf buffer);
+extern int unpack_acct_account_rec(void **object, Buf buffer);
+extern void pack_acct_coord_rec(void *object, Buf buffer);
+extern int unpack_acct_coord_rec(void **object, Buf buffer);
+extern void pack_cluster_accounting_rec(void *object, Buf buffer);
+extern int unpack_cluster_accounting_rec(void **object, Buf buffer);
+extern void pack_acct_cluster_rec(void *object, Buf buffer);
+extern int unpack_acct_cluster_rec(void **object, Buf buffer);
+extern void pack_acct_accounting_rec(void *object, Buf buffer);
+extern int unpack_acct_accounting_rec(void **object, Buf buffer);
+extern void pack_acct_association_rec(void *object, Buf buffer);
+extern int unpack_acct_association_rec(void **object, Buf buffer);
+
+extern void pack_acct_user_cond(void *object, Buf buffer);
+extern int unpack_acct_user_cond(void **object, Buf buffer);
+extern void pack_acct_account_cond(void *object, Buf buffer);
+extern int unpack_acct_account_cond(void **object, Buf buffer);
+extern void pack_acct_cluster_cond(void *object, Buf buffer);
+extern int unpack_acct_cluster_cond(void **object, Buf buffer);
+extern void pack_acct_association_cond(void *object, Buf buffer);
+extern int unpack_acct_association_cond(void **object, Buf buffer);
+
+extern void pack_acct_update_object(acct_update_object_t *object, Buf buffer);
+extern int unpack_acct_update_object(acct_update_object_t **object, Buf buffer);
+
+extern void pack_update_shares_used(void *object, Buf buffer);
+extern int unpack_update_shares_used(void **object, Buf buffer);
+
+extern char *acct_qos_str(acct_qos_level_t level);
+extern acct_qos_level_t str_2_acct_qos(char *level);
+extern char *acct_admin_level_str(acct_admin_level_t level);
+extern acct_admin_level_t str_2_acct_admin_level(char *level);
+
+extern void log_assoc_rec(acct_association_rec_t *assoc_ptr);
+
+extern int slurm_acct_storage_init(char *loc); /* load the plugin */
+extern int slurm_acct_storage_fini(void); /* unload the plugin */
+
+/*
+ * get a new connection to the storage unit
+ * IN: make_agent - Make an agent to manage queued requests
+ * IN: rollback - maintain journal of changes to permit rollback
+ * RET: pointer used to access db 
+ */
+extern void *acct_storage_g_get_connection(bool make_agent, bool rollback);
+
+/*
+ * release connection to the storage unit
+ * IN/OUT: void ** pointer returned from
+ *         acct_storage_g_get_connection() which will be freed.
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else 
+ */
+extern int acct_storage_g_close_connection(void **db_conn);
+
+/*
+ * commit or rollback changes made without closing connection
+ * IN: void * pointer returned from acct_storage_g_get_connection()
+ * IN: bool - true will commit changes false will rollback
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else 
+ */
+extern int acct_storage_g_commit(void *db_conn, bool commit);
+
+/* 
+ * add users to accounting system 
+ * IN:  user_list List of acct_user_rec_t *
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_add_users(void *db_conn, uint32_t uid, 
+				    List user_list);
+
+/* 
+ * add users as account coordinators 
+ * IN:  acct name of account
+ * IN:  acct_user_cond_t *user_q
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_add_coord(void *db_conn, uint32_t uid,
+				    char *acct, acct_user_cond_t *user_q);
+
+
+/* 
+ * add accounts to accounting system 
+ * IN:  account_list List of acct_account_rec_t *
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_add_accounts(void *db_conn, uint32_t uid,
+				       List acct_list);
+
+/* 
+ * add clusters to accounting system 
+ * IN:  cluster_list List of acct_cluster_rec_t *
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_add_clusters(void *db_conn, uint32_t uid,
+				       List cluster_list);
+
+/* 
+ * add accts to accounting system 
+ * IN:  association_list List of acct_association_rec_t *
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_add_associations(void *db_conn, uint32_t uid, 
+					   List association_list);
+
+/* 
+ * modify existing users in the accounting system 
+ * IN:  acct_user_cond_t *user_q
+ * IN:  acct_user_rec_t *user
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_modify_users(void *db_conn, uint32_t uid, 
+				       acct_user_cond_t *user_q,
+				       acct_user_rec_t *user);
+
+/* 
+ * modify existing accounts in the accounting system 
+ * IN:  acct_acct_cond_t *acct_q
+ * IN:  acct_account_rec_t *acct
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_modify_accounts(void *db_conn, uint32_t uid, 
+					  acct_account_cond_t *acct_q,
+					  acct_account_rec_t *acct);
+
+/* 
+ * modify existing clusters in the accounting system 
+ * IN:  acct_cluster_cond_t *cluster_q
+ * IN:  acct_cluster_rec_t *cluster
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_modify_clusters(void *db_conn, uint32_t uid, 
+					  acct_cluster_cond_t *cluster_q,
+					  acct_cluster_rec_t *cluster);
+
+/* 
+ * modify existing associations in the accounting system 
+ * IN:  acct_association_cond_t *assoc_q
+ * IN:  acct_association_rec_t *assoc
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_modify_associations(void *db_conn, uint32_t uid, 
+					      acct_association_cond_t *assoc_q,
+					      acct_association_rec_t *assoc);
+
+/* 
+ * remove users from accounting system 
+ * IN:  acct_user_cond_t *user_q
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_remove_users(void *db_conn, uint32_t uid, 
+				       acct_user_cond_t *user_q);
+
+/* 
+ * remove users from being a coordinator of an account
+ * IN: acct name of acct
+ * IN: acct_user_cond_t *user_q
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_remove_coord(void *db_conn, uint32_t uid, 
+				       char *acct, acct_user_cond_t *user_q);
+
+/* 
+ * remove accounts from accounting system 
+ * IN:  acct_account_cond_t *acct_q
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_remove_accounts(void *db_conn, uint32_t uid, 
+					  acct_account_cond_t *acct_q);
+
+/* 
+ * remove clusters from accounting system 
+ * IN:  acct_cluster_cond_t *cluster_q
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_remove_clusters(void *db_conn, uint32_t uid, 
+					  acct_cluster_cond_t *cluster_q);
+
+/* 
+ * remove associations from accounting system 
+ * IN:  acct_association_cond_t *assoc_q
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern List acct_storage_g_remove_associations(void *db_conn, uint32_t uid, 
+					      acct_association_cond_t *assoc_q);
+
+/* 
+ * get info from the storage 
+ * IN:  acct_user_cond_t *
+ * IN:  params void *
+ * returns List of acct_user_rec_t *
+ * note List needs to be freed when called
+ */
+extern List acct_storage_g_get_users(void *db_conn, 
+				     acct_user_cond_t *user_q);
+
+/* 
+ * get info from the storage 
+ * IN:  acct_account_cond_t *
+ * IN:  params void *
+ * returns List of acct_account_rec_t *
+ * note List needs to be freed when called
+ */
+extern List acct_storage_g_get_accounts(void *db_conn, 
+					acct_account_cond_t *acct_q);
+
+/* 
+ * get info from the storage 
+ * IN:  acct_cluster_cond_t *
+ * IN:  params void *
+ * returns List of acct_cluster_rec_t *
+ * note List needs to be freed when called
+ */
+extern List acct_storage_g_get_clusters(void *db_conn, 
+					acct_cluster_cond_t *cluster_q);
+
+/* 
+ * get info from the storage 
+ * IN:  acct_association_cond_t *
+ * RET: List of acct_association_rec_t *
+ * note List needs to be freed when called
+ */
+extern List acct_storage_g_get_associations(void *db_conn, 
+					    acct_association_cond_t *assoc_q);
+
+/* 
+ * get info from the storage 
+ * IN/OUT:  assoc void * (acct_association_rec_t *) with the id set
+ * IN:  start time stamp for records >=
+ * IN:  end time stamp for records <=
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_get_usage(
+	void *db_conn, void *assoc, time_t start, time_t end);
+/* 
+ * roll up data in the storage 
+ * IN: sent_start (option time to do a re-roll or start from this point)
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_roll_usage(void *db_conn, 
+				     time_t sent_start);
+/* 
+ * record shares used information for backup in case slurmctld restarts 
+ * IN:  account_list List of shares_used_object_t *
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_update_shares_used(void *db_conn, List acct_list);
+
+/* 
+ * This should be called when a cluster does a cold start to flush out
+ * any jobs that were running during the restart so we don't have any
+ * jobs in the database "running" forever since no endtime will be
+ * placed in there other wise. 
+ * IN:  char * = cluster name
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int acct_storage_g_flush_jobs_on_cluster(
+	void *db_conn, char *cluster, time_t event_time);
+
+/*********************** CLUSTER ACCOUNTING STORAGE **************************/
+
+extern int clusteracct_storage_g_node_down(void *db_conn, 
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time,
+					   char *reason);
+
+extern int clusteracct_storage_g_node_up(void *db_conn, 
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time);
+
+extern int clusteracct_storage_g_cluster_procs(void *db_conn, 
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time);
+
+extern int clusteracct_storage_g_register_ctld(char *cluster, uint16_t port);
+
+/* 
+ * get info from the storage 
+ * IN/OUT:  cluster_rec void * (acct_cluster_rec_t *) with the name set
+ * IN:  start time stamp for records >=
+ * IN:  end time stamp for records <
+ * IN:  params void *
+ * RET: SLURM_SUCCESS on success SLURM_ERROR else
+ */
+extern int clusteracct_storage_g_get_usage(
+	void *db_conn, void *cluster_rec,
+	time_t start, time_t end);
+
+/* 
+ * load into the storage the start of a job
+ */
+extern int jobacct_storage_g_job_start (void *db_conn, 
+					struct job_record *job_ptr);
+
+/* 
+ * load into the storage the end of a job
+ */
+extern int jobacct_storage_g_job_complete (void *db_conn, 
+					   struct job_record *job_ptr);
+
+/* 
+ * load into the storage the start of a job step
+ */
+extern int jobacct_storage_g_step_start (void *db_conn, 
+					 struct step_record *step_ptr);
+
+/* 
+ * load into the storage the end of a job step
+ */
+extern int jobacct_storage_g_step_complete (void *db_conn, 
+					    struct step_record *step_ptr);
+
+/* 
+ * load into the storage a suspention of a job
+ */
+extern int jobacct_storage_g_job_suspend (void *db_conn, 
+					  struct job_record *job_ptr);
+
+/* 
+ * get info from the storage 
+ * returns List of jobacct_job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_g_get_jobs(void *db_conn, 
+				       List selected_steps,
+				       List selected_parts,
+				       void *params);
+
+/* 
+ * expire old info from the storage 
+ */
+extern void jobacct_storage_g_archive(void *db_conn, 
+				      List selected_parts,
+				      void *params);
+
+#endif /*_SLURM_ACCOUNTING_STORAGE_H*/
diff --git a/src/common/slurm_auth.c b/src/common/slurm_auth.c
index 99d101c8f492719f96fda22743e65e18fdc98a21..9e2305b5d725343a577946595e1a9265abcf5812 100644
--- a/src/common/slurm_auth.c
+++ b/src/common/slurm_auth.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -59,11 +59,11 @@ static bool auth_dummy = false;	/* for security testing */
  * end of the structure.
  */
 typedef struct slurm_auth_ops {
-        void *       (*create)    ( void *argv[] );
+        void *       (*create)    ( void *argv[], char *auth_info );
         int          (*destroy)   ( void *cred );
-        int          (*verify)    ( void *cred, void *argv[] );
-        uid_t        (*get_uid)   ( void *cred );
-        gid_t        (*get_gid)   ( void *cred );
+        int          (*verify)    ( void *cred, void *argv[], char *auth_info );
+        uid_t        (*get_uid)   ( void *cred, char *auth_info );
+        gid_t        (*get_gid)   ( void *cred, char *auth_info );
         int          (*pack)      ( void *cred, Buf buf );
         void *       (*unpack)    ( Buf buf );
         int          (*print)     ( void *cred, FILE *fp );
@@ -193,7 +193,7 @@ slurm_auth_marshal_args( void *hosts, int timeout )
         if ( ( hostlist_idx == -1 ) &&
              ( timeout_idx == -1 ) ) {
                 hostlist_idx = arg_idx_by_name( auth_args, ARG_HOST_LIST );
-                timeout_idx = arg_idx_by_name( auth_args, ARG_TIMEOUT );                
+                timeout_idx = arg_idx_by_name( auth_args, ARG_TIMEOUT );        
         }
 
         argv = xmalloc( count * sizeof( void * ) );
@@ -287,17 +287,20 @@ _slurm_auth_context_destroy( slurm_auth_context_t c )
 }
 
 int inline
-slurm_auth_init( void )
+slurm_auth_init( char *auth_type )
 {
         int retval = SLURM_SUCCESS;
-	char *auth_type = NULL;
-
+	char *auth_type_local = NULL;
+	
         slurm_mutex_lock( &context_lock );
 
         if ( g_context ) 
                 goto done;
 
-	auth_type = slurm_get_auth_type();
+	if (auth_type == NULL) {
+		auth_type_local = slurm_get_auth_type();
+		auth_type = auth_type_local;
+	}
 	if (strcmp(auth_type, "auth/dummy") == 0) {
 		info( "warning: %s plugin selected", auth_type);
 		auth_dummy = true;
@@ -320,7 +323,7 @@ slurm_auth_init( void )
         }
 
  done:
-	xfree(auth_type);
+	xfree(auth_type_local);
         slurm_mutex_unlock( &context_lock );
         return retval;
 }
@@ -347,12 +350,12 @@ slurm_auth_fini( void )
  */
           
 void *
-g_slurm_auth_create( void *hosts, int timeout )
+g_slurm_auth_create( void *hosts, int timeout, char *auth_info )
 {
         void **argv;
         void *ret;
 
-	if ( slurm_auth_init() < 0 )
+	if ( slurm_auth_init(NULL) < 0 )
 		return NULL;
 
 	if ( auth_dummy )
@@ -362,7 +365,7 @@ g_slurm_auth_create( void *hosts, int timeout )
                 return NULL;
         }
        
-        ret = (*(g_context->ops.create))( argv );
+        ret = (*(g_context->ops.create))( argv, auth_info );
         xfree( argv );
         return ret;
 }
@@ -370,7 +373,7 @@ g_slurm_auth_create( void *hosts, int timeout )
 int
 g_slurm_auth_destroy( void *cred )
 {
-        if ( slurm_auth_init() < 0 )
+        if ( slurm_auth_init(NULL) < 0 )
                 return SLURM_ERROR;
 
 	if ( auth_dummy )	/* don't worry about leak in testing */
@@ -380,12 +383,12 @@ g_slurm_auth_destroy( void *cred )
 }
 
 int
-g_slurm_auth_verify( void *cred, void *hosts, int timeout )
+g_slurm_auth_verify( void *cred, void *hosts, int timeout, char *auth_info )
 {
         int ret;
         void **argv;
 
-        if ( slurm_auth_init() < 0 )
+        if ( slurm_auth_init(NULL) < 0 )
                 return SLURM_ERROR;
 
 	if ( auth_dummy )
@@ -395,33 +398,33 @@ g_slurm_auth_verify( void *cred, void *hosts, int timeout )
                 return SLURM_ERROR;
         }
         
-        ret = (*(g_context->ops.verify))( cred, argv );
+        ret = (*(g_context->ops.verify))( cred, argv, auth_info );
         xfree( argv );
         return ret;
 }
 
 uid_t
-g_slurm_auth_get_uid( void *cred )
+g_slurm_auth_get_uid( void *cred, char *auth_info )
 {
-	if (( slurm_auth_init() < 0 ) || auth_dummy )
+	if (( slurm_auth_init(NULL) < 0 ) || auth_dummy )
                 return SLURM_AUTH_NOBODY;
         
-        return (*(g_context->ops.get_uid))( cred );
+        return (*(g_context->ops.get_uid))( cred, auth_info );
 }
 
 gid_t
-g_slurm_auth_get_gid( void *cred )
+g_slurm_auth_get_gid( void *cred, char *auth_info )
 {
-	if (( slurm_auth_init() < 0 ) || auth_dummy )
+	if (( slurm_auth_init(NULL) < 0 ) || auth_dummy )
                 return SLURM_AUTH_NOBODY;
         
-        return (*(g_context->ops.get_gid))( cred );
+        return (*(g_context->ops.get_gid))( cred, auth_info );
 }
 
 int
 g_slurm_auth_pack( void *cred, Buf buf )
 {
-        if ( slurm_auth_init() < 0 )
+        if ( slurm_auth_init(NULL) < 0 )
                 return SLURM_ERROR;
  
 	if ( auth_dummy )
@@ -433,7 +436,7 @@ g_slurm_auth_pack( void *cred, Buf buf )
 void *
 g_slurm_auth_unpack( Buf buf )
 {
-	if (( slurm_auth_init() < 0 ) || auth_dummy )
+	if (( slurm_auth_init(NULL) < 0 ) || auth_dummy )
                 return NULL;
         
         return (*(g_context->ops.unpack))( buf );
@@ -442,7 +445,7 @@ g_slurm_auth_unpack( Buf buf )
 int
 g_slurm_auth_print( void *cred, FILE *fp )
 {
-        if ( slurm_auth_init() < 0 )
+        if ( slurm_auth_init(NULL) < 0 )
                 return SLURM_ERROR;
 
 	if ( auth_dummy )
@@ -454,7 +457,7 @@ g_slurm_auth_print( void *cred, FILE *fp )
 int
 g_slurm_auth_errno( void *cred )
 {
-        if (( slurm_auth_init() < 0 ) || auth_dummy )
+        if (( slurm_auth_init(NULL) < 0 ) || auth_dummy )
                 return SLURM_ERROR;
 
         return (*(g_context->ops.sa_errno))( cred );
@@ -466,7 +469,7 @@ g_slurm_auth_errstr( int slurm_errno )
         static char auth_init_msg[] = "authentication initialization failure";
         char *generic;
 
-	if (( slurm_auth_init() < 0 ) || auth_dummy )
+	if (( slurm_auth_init(NULL) < 0 ) || auth_dummy )
 		return auth_init_msg;
 
         if (( generic = (char *) slurm_auth_generic_errstr( slurm_errno ) ))
diff --git a/src/common/slurm_auth.h b/src/common/slurm_auth.h
index 9950115062c9f408ab1f2bd2782ec9460078e457..3c5bcdee4a207b84979e9df675b397c857cf6584 100644
--- a/src/common/slurm_auth.h
+++ b/src/common/slurm_auth.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -136,8 +136,10 @@ int slurm_auth_context_destroy( slurm_auth_context_t ctxt );
 
 /*
  * Prepare the global context.
+ * auth_type IN: authentication mechanism (e.g. "auth/munge") or 
+ *	NULL to select based upon slurm_get_auth_type() results
  */
-extern int slurm_auth_init( void );
+extern int slurm_auth_init( char *auth_type );
 
 /*
  * Destroy global context, free memory.
@@ -147,11 +149,12 @@ extern int slurm_auth_fini( void );
 /*
  * Static bindings for the global authentication context.
  */
-extern void	*g_slurm_auth_create( void *hosts, int timeout );
+extern void *	g_slurm_auth_create( void *hosts, int timeout, char *auth_info );
 extern int	g_slurm_auth_destroy( void *cred );
-extern int	g_slurm_auth_verify( void *cred, void *hosts, int timeout );
-extern uid_t	g_slurm_auth_get_uid( void *cred );
-extern gid_t	g_slurm_auth_get_gid( void *cred );
+extern int	g_slurm_auth_verify( void *cred, void *hosts, int timeout, 
+				     char *auth_info );
+extern uid_t	g_slurm_auth_get_uid( void *cred, char *auth_info );
+extern gid_t	g_slurm_auth_get_gid( void *cred, char *auth_info );
 extern int	g_slurm_auth_pack( void *cred, Buf buf );
 
 /*
diff --git a/src/common/slurm_cred.c b/src/common/slurm_cred.c
index d719194653eb8721fe08c5ca5fc5cc9d7778298f..ed7dd43198c1bc1cfdac2e5e8b56a9d613ad70c7 100644
--- a/src/common/slurm_cred.c
+++ b/src/common/slurm_cred.c
@@ -1,11 +1,12 @@
 /*****************************************************************************\
  *  src/common/slurm_cred.c - SLURM job credential functions
- *  $Id: slurm_cred.c 11821 2007-07-11 22:25:02Z jette $
+ *  $Id: slurm_cred.c 14148 2008-05-28 23:35:40Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark A. Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Morris Jette <jette1@llnl.gov>.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -47,24 +48,21 @@
 #include <stdlib.h>
 #include <sys/time.h>
 
-/*
- * OpenSSL includes
- */
-#include <openssl/evp.h>
-#include <openssl/pem.h>
-#include <openssl/err.h>
-
 #if WITH_PTHREADS
 #  include <pthread.h>
 #endif /* WITH_PTHREADS */
 
-#include "src/common/macros.h"
+#include "src/common/io_hdr.h"
 #include "src/common/list.h"
 #include "src/common/log.h"
+#include "src/common/macros.h"
+#include "src/common/plugin.h"
+#include "src/common/plugrack.h"
+#include "src/common/slurm_protocol_api.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xassert.h"
 #include "src/common/xstring.h"
-#include "src/common/io_hdr.h"
+
 
 #include "src/common/slurm_cred.h"
 
@@ -106,6 +104,9 @@ enum ctx_type {
 	SLURM_CRED_VERIFIER
 };
 
+/*
+ * Credential context, slurm_cred_ctx_t:
+ */
 struct slurm_cred_context {
 #ifndef NDEBUG
 #  define CRED_CTX_MAGIC 0x0c0c0c
@@ -115,20 +116,19 @@ struct slurm_cred_context {
 	pthread_mutex_t mutex;
 #endif
 	enum ctx_type  type;       /* type of context (creator or verifier) */
-	EVP_PKEY      *key;        /* private or public key                 */
+	void          *key;        /* private or public key                 */
 	List           job_list;   /* List of used jobids (for verifier)    */
 	List           state_list; /* List of cred states (for verifier)    */
 
-	int   expiry_window;       /* expiration window for cached creds    */
+	int          expiry_window;/* expiration window for cached creds    */
 
-	EVP_PKEY      *exkey;      /* Old public key if key is updated      */
+	void          *exkey;      /* Old public key if key is updated      */
 	time_t         exkey_exp;  /* Old key expiration time               */
 };
 
 
 /*
- * Completion of slurm job credential type:
- *
+ * Completion of slurm job credential type, slurm_cred_t:
  */
 struct slurm_job_credential {
 #ifndef NDEBUG
@@ -138,18 +138,55 @@ struct slurm_job_credential {
 #ifdef  WITH_PTHREADS
 	pthread_mutex_t mutex;
 #endif
-	uint32_t jobid;        /* Job ID associated with this credential    */
-	uint32_t stepid;       /* Job step ID for this credential           */
-	uid_t    uid;          /* user for which this cred is valid         */
-	time_t   ctime;        /* time of credential creation               */
-	char    *nodes;        /* list of hostnames for which the cred is ok*/
-        uint32_t alloc_lps_cnt;    /* Number of hosts in the list above     */
-        uint32_t *alloc_lps;       /* Number of tasks on each host          */
-
-	unsigned char *signature; /* credential signature                   */
-	unsigned int siglen;      /* signature length in bytes              */
+	uint32_t  jobid;	/* Job ID associated with this cred	*/
+	uint32_t  stepid;	/* Job step ID for this credential	*/
+	uid_t     uid;		/* user for which this cred is valid	*/
+	uint32_t  job_mem;	/* MB of memory reserved for job	*/
+	uint32_t  task_mem;	/* MB of memory reserved per task	*/
+	time_t    ctime;	/* time of credential creation		*/
+	char     *nodes;	/* hostnames for which the cred is ok	*/
+	uint32_t  alloc_lps_cnt;/* Number of hosts in the list above	*/
+	uint32_t *alloc_lps;	/* Number of tasks on each host		*/
+
+	char     *signature; 	/* credential signature			*/
+	unsigned int siglen;	/* signature length in bytes		*/
 };
 
+/*
+ * WARNING:  Do not change the order of these fields or add additional
+ * fields at the beginning of the structure.  If you do, job accounting
+ * plugins will stop working.  If you need to add fields, add them 
+ * at the end of the structure.
+ */
+typedef struct slurm_crypto_ops {
+	void *(*crypto_read_private_key)	(const char *path);
+	void *(*crypto_read_public_key)		(const char *path);
+	void  (*crypto_destroy_key)		(void *key);
+	int   (*crypto_sign)			(void * key, char *buffer, 
+						 int buf_size, char **sig_pp, 
+						 unsigned int *sig_size_p);
+	int   (*crypto_verify_sign)		(void * key, char *buffer, 
+						 unsigned int buf_size, 
+						 char *signature, 
+						 unsigned int sig_size);
+	char *(*crypto_str_error)		(void);
+} slurm_crypto_ops_t;
+
+/*
+ * A global cryptographic context.  "Global" in the sense that there's
+ * only one, with static bindings.  We don't export it.
+ */
+
+typedef struct slurm_crypto_context {
+	char 			*crypto_type;
+	plugrack_t		plugin_list;
+	plugin_handle_t		cur_plugin;
+	int			crypto_errno;
+	slurm_crypto_ops_t	ops;
+} slurm_crypto_context_t;
+
+static slurm_crypto_context_t *g_crypto_context = NULL;
+static pthread_mutex_t      g_crypto_context_lock = PTHREAD_MUTEX_INITIALIZER;
 
 
 /*
@@ -180,12 +217,12 @@ static void _verifier_ctx_init(slurm_cred_ctx_t ctx);
 static bool _credential_replayed(slurm_cred_ctx_t ctx, slurm_cred_t cred);
 static bool _credential_revoked(slurm_cred_ctx_t ctx, slurm_cred_t cred);
 
-static EVP_PKEY * _read_private_key(const char *path);
-static EVP_PKEY * _read_public_key(const char  *path);
-
 static int _slurm_cred_sign(slurm_cred_ctx_t ctx, slurm_cred_t cred);
 static int _slurm_cred_verify_signature(slurm_cred_ctx_t ctx, slurm_cred_t c);
 
+static int _slurm_crypto_init(void);
+static int _slurm_crypto_fini(void);
+
 static job_state_t  * _job_state_unpack_one(Buf buffer);
 static cred_state_t * _cred_state_unpack_one(Buf buffer);
 
@@ -201,20 +238,185 @@ static void _cred_state_pack_one(cred_state_t *s, Buf buffer);
 static char * timestr (const time_t *tp, char *buf, size_t n);
 #endif
 
+
+static slurm_crypto_context_t *
+_slurm_crypto_context_create( const char *crypto_type)
+{
+	slurm_crypto_context_t *c;
+
+	if ( crypto_type == NULL ) {
+		error( "_slurm_crypto_context_create: no crypto type" );
+		return NULL;
+	}
+
+	c = xmalloc( sizeof( struct slurm_crypto_context ) );
+
+	c->crypto_errno = SLURM_SUCCESS;
+
+	/* Copy the job completion job completion type. */
+	c->crypto_type = xstrdup( crypto_type );
+	if ( c->crypto_type == NULL ) {
+		error( "can't make local copy of crypto type" );
+		xfree( c );
+		return NULL; 
+	}
+
+	/* Plugin rack is demand-loaded on first reference. */
+	c->plugin_list = NULL; 
+	c->cur_plugin = PLUGIN_INVALID_HANDLE; 
+	c->crypto_errno	= SLURM_SUCCESS;
+
+	return c;
+}
+
+static int
+_slurm_crypto_context_destroy( slurm_crypto_context_t *c )
+{
+	/*
+	 * Must check return code here because plugins might still
+	 * be loaded and active.
+	 */
+	if ( c->plugin_list ) {
+		if ( plugrack_destroy( c->plugin_list ) != SLURM_SUCCESS ) {
+			 return SLURM_ERROR;
+		}
+	}
+
+	xfree( c->crypto_type );
+	xfree( c );
+
+	return SLURM_SUCCESS;
+}
+
+/*
+ * Resolve the operations from the plugin.
+ */
+static slurm_crypto_ops_t *
+_slurm_crypto_get_ops( slurm_crypto_context_t *c )
+{
+	/*
+	 * These strings must be in the same order as the fields declared
+	 * for slurm_crypto_ops_t.
+	 */
+	static const char *syms[] = {
+		"crypto_read_private_key",
+		"crypto_read_public_key",
+		"crypto_destroy_key",
+		"crypto_sign",
+		"crypto_verify_sign",
+		"crypto_str_error"
+	};
+	int n_syms = sizeof( syms ) / sizeof( char * );
+	int rc = 0;
+        /* Get the plugin list, if needed. */
+        if ( c->plugin_list == NULL ) {
+		char *plugin_dir;
+                c->plugin_list = plugrack_create();
+                if ( c->plugin_list == NULL ) {
+                        error( "Unable to create a plugin manager" );
+                        return NULL;
+                }
+
+                plugrack_set_major_type( c->plugin_list, "crypto" );
+                plugrack_set_paranoia( c->plugin_list, 
+				       PLUGRACK_PARANOIA_NONE, 
+				       0 );
+		plugin_dir = slurm_get_plugin_dir();
+                plugrack_read_dir( c->plugin_list, plugin_dir );
+		xfree(plugin_dir);
+        }
+  
+        /* Find the correct plugin. */
+        c->cur_plugin = 
+		plugrack_use_by_type( c->plugin_list, c->crypto_type );
+        if ( c->cur_plugin == PLUGIN_INVALID_HANDLE ) {
+                error( "can't find a plugin for type %s", c->crypto_type );
+                return NULL;
+        }  
+
+        /* Dereference the API. */
+        if ( (rc = plugin_get_syms( c->cur_plugin,
+				    n_syms,
+				    syms,
+				    (void **) &c->ops )) < n_syms ) {
+                error( "incomplete crypto plugin detected only "
+		       "got %d out of %d",
+		       rc, n_syms);
+                return NULL;
+        }
+
+        return &c->ops;
+}
+
+static int _slurm_crypto_init(void)
+{
+	char	*crypto_type = NULL;
+	int	retval = SLURM_SUCCESS;
+
+	slurm_mutex_lock( &g_crypto_context_lock );
+	if ( g_crypto_context )
+		goto done;
+
+	crypto_type = slurm_get_crypto_type();
+	g_crypto_context = _slurm_crypto_context_create( crypto_type );
+	if ( g_crypto_context == NULL ) {
+		error( "cannot create a context for %s", crypto_type );
+		retval = SLURM_ERROR;
+		goto done;
+	}
+	
+	if ( _slurm_crypto_get_ops( g_crypto_context ) == NULL ) {
+		error( "cannot resolve crypto plugin operations" );
+		_slurm_crypto_context_destroy( g_crypto_context );
+		g_crypto_context = NULL;
+		retval = SLURM_ERROR;
+	}
+
+  done:
+	slurm_mutex_unlock( &g_crypto_context_lock );
+	xfree(crypto_type);
+
+	return(retval);
+}
+
+static int _slurm_crypto_fini(void)
+{
+	int rc;
+
+	if (!g_crypto_context)
+		return SLURM_SUCCESS;
+
+	rc = _slurm_crypto_context_destroy(g_crypto_context);
+	g_crypto_context = NULL;
+	return rc;
+}
+
+/* Terminate the plugin and release all memory. */
+extern int slurm_crypto_fini(void)
+{
+	if (_slurm_crypto_fini() < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
 slurm_cred_ctx_t 
 slurm_cred_creator_ctx_create(const char *path)
 {
 	slurm_cred_ctx_t ctx = NULL;
 	
 	xassert(path != NULL);
+	if (_slurm_crypto_init() < 0)
+		return NULL;
 
 	ctx = _slurm_cred_ctx_alloc();
 	slurm_mutex_lock(&ctx->mutex);
 
 	ctx->type = SLURM_CRED_CREATOR;
 
-	if (!(ctx->key = _read_private_key(path))) 
-		goto fail;
+	ctx->key = (*(g_crypto_context->ops.crypto_read_private_key))(path);
+	if (!ctx->key)
+ 		goto fail;
 
 	slurm_mutex_unlock(&ctx->mutex);
 	return ctx;
@@ -222,6 +424,7 @@ slurm_cred_creator_ctx_create(const char *path)
     fail:
 	slurm_mutex_unlock(&ctx->mutex);
 	slurm_cred_ctx_destroy(ctx);
+	error("Can not open data encryption key file %s", path);
 	return NULL;
 }
 
@@ -232,13 +435,16 @@ slurm_cred_verifier_ctx_create(const char *path)
 	slurm_cred_ctx_t ctx = NULL;
 
 	xassert(path != NULL);
+	if (_slurm_crypto_init() < 0)
+		return NULL;
 
 	ctx = _slurm_cred_ctx_alloc();
 	slurm_mutex_lock(&ctx->mutex);
 
 	ctx->type = SLURM_CRED_VERIFIER;
 
-	if (!(ctx->key = _read_public_key(path)))
+	ctx->key = (*(g_crypto_context->ops.crypto_read_public_key))(path);
+	if (!ctx->key)
 		goto fail;
 
 	_verifier_ctx_init(ctx);
@@ -249,6 +455,7 @@ slurm_cred_verifier_ctx_create(const char *path)
     fail:
 	slurm_mutex_unlock(&ctx->mutex);
 	slurm_cred_ctx_destroy(ctx);
+	error("Can not open data encryption key file %s", path);
 	return NULL;
 }
 
@@ -258,12 +465,14 @@ slurm_cred_ctx_destroy(slurm_cred_ctx_t ctx)
 {
 	if (ctx == NULL)
 		return;
+	if (_slurm_crypto_init() < 0)
+		return;
 
 	slurm_mutex_lock(&ctx->mutex);
 	xassert(ctx->magic == CRED_CTX_MAGIC);
 
 	if (ctx->key)
-		EVP_PKEY_free(ctx->key);
+		(*(g_crypto_context->ops.crypto_destroy_key))(ctx->key);
 	if (ctx->job_list)
 		list_destroy(ctx->job_list);
 	if (ctx->state_list)
@@ -344,6 +553,9 @@ slurm_cred_ctx_get(slurm_cred_ctx_t ctx, slurm_cred_opt_t opt, ...)
 int 
 slurm_cred_ctx_key_update(slurm_cred_ctx_t ctx, const char *path)
 {
+	if (_slurm_crypto_init() < 0)
+		return SLURM_ERROR;
+
 	if (ctx->type == SLURM_CRED_CREATOR)
 		return _ctx_update_private_key(ctx, path);
 	else
@@ -358,6 +570,8 @@ slurm_cred_create(slurm_cred_ctx_t ctx, slurm_cred_arg_t *arg)
 
 	xassert(ctx != NULL);
 	xassert(arg != NULL);
+	if (_slurm_crypto_init() < 0)
+		return NULL;
 
 	slurm_mutex_lock(&ctx->mutex);
 
@@ -375,12 +589,15 @@ slurm_cred_create(slurm_cred_ctx_t ctx, slurm_cred_arg_t *arg)
 	cred->jobid  = arg->jobid;
 	cred->stepid = arg->stepid;
 	cred->uid    = arg->uid;
+	cred->job_mem = arg->job_mem;
+	cred->task_mem = arg->task_mem;
 	cred->nodes  = xstrdup(arg->hostlist);
         cred->alloc_lps_cnt = arg->alloc_lps_cnt;
         cred->alloc_lps  = NULL;
         if (cred->alloc_lps_cnt > 0) {
                 cred->alloc_lps =  xmalloc(cred->alloc_lps_cnt * sizeof(uint32_t));
-                memcpy(cred->alloc_lps, arg->alloc_lps, cred->alloc_lps_cnt * sizeof(uint32_t));
+                memcpy(cred->alloc_lps, arg->alloc_lps, 
+			cred->alloc_lps_cnt * sizeof(uint32_t));
         }
 	cred->ctime  = time(NULL);
 
@@ -419,6 +636,8 @@ slurm_cred_copy(slurm_cred_t cred)
 	rcred->jobid  = cred->jobid;
 	rcred->stepid = cred->stepid;
 	rcred->uid    = cred->uid;
+	rcred->job_mem = cred->job_mem;
+	rcred->task_mem = cred->task_mem;
 	rcred->nodes  = xstrdup(cred->nodes);
 	rcred->alloc_lps_cnt = cred->alloc_lps_cnt;
 	rcred->alloc_lps  = NULL;
@@ -428,7 +647,10 @@ slurm_cred_copy(slurm_cred_t cred)
 		rcred->alloc_lps_cnt * sizeof(uint32_t));
 	}
 	rcred->ctime  = cred->ctime;
-	rcred->signature = (unsigned char *)xstrdup((char *)cred->signature);
+	rcred->siglen = cred->siglen;
+	/* Assumes signature is a string,
+	 * otherwise use xmalloc and strcpy here */
+	rcred->signature = xstrdup(cred->signature);
 	
 	slurm_mutex_unlock(&cred->mutex);
 	slurm_mutex_unlock(&rcred->mutex);
@@ -448,16 +670,19 @@ slurm_cred_faker(slurm_cred_arg_t *arg)
 
 	slurm_mutex_lock(&cred->mutex);
 
-	cred->jobid  = arg->jobid;
-	cred->stepid = arg->stepid;
-        cred->uid    = arg->uid;
-	cred->nodes  = xstrdup(arg->hostlist);
-        cred->alloc_lps_cnt = arg->alloc_lps_cnt;
-        cred->alloc_lps  = NULL;
-        if (cred->alloc_lps_cnt > 0) {
-                 cred->alloc_lps =  xmalloc(cred->alloc_lps_cnt * sizeof(uint32_t));
-                 memcpy(cred->alloc_lps, arg->alloc_lps, cred->alloc_lps_cnt * sizeof(uint32_t));
-        }
+	cred->jobid    = arg->jobid;
+	cred->stepid   = arg->stepid;
+	cred->uid      = arg->uid;
+	cred->job_mem  = arg->job_mem;
+	cred->task_mem = arg->task_mem;
+	cred->nodes    = xstrdup(arg->hostlist);
+	cred->alloc_lps_cnt = arg->alloc_lps_cnt;
+	cred->alloc_lps  = NULL;
+	if (cred->alloc_lps_cnt > 0) {
+		cred->alloc_lps =  xmalloc(cred->alloc_lps_cnt * sizeof(uint32_t));
+		memcpy(cred->alloc_lps, arg->alloc_lps, 
+		       cred->alloc_lps_cnt * sizeof(uint32_t));
+	}
 	cred->ctime  = time(NULL);
 	cred->siglen = SLURM_IO_KEY_SIZE;
 
@@ -494,6 +719,8 @@ slurm_cred_verify(slurm_cred_ctx_t ctx, slurm_cred_t cred,
 	xassert(ctx  != NULL);
 	xassert(cred != NULL);
 	xassert(arg  != NULL);
+	if (_slurm_crypto_init() < 0)
+		return SLURM_ERROR;
 
 	slurm_mutex_lock(&ctx->mutex);
 	slurm_mutex_lock(&cred->mutex);
@@ -532,12 +759,15 @@ slurm_cred_verify(slurm_cred_ctx_t ctx, slurm_cred_t cred,
 	arg->jobid    = cred->jobid;
 	arg->stepid   = cred->stepid;
 	arg->uid      = cred->uid;
+	arg->job_mem  = cred->job_mem;
+	arg->task_mem = cred->task_mem;
 	arg->hostlist = xstrdup(cred->nodes);
         arg->alloc_lps_cnt = cred->alloc_lps_cnt;
         arg->alloc_lps     = NULL;
         if (arg->alloc_lps_cnt > 0) {
                 arg->alloc_lps =  xmalloc(arg->alloc_lps_cnt * sizeof(uint32_t));
-                memcpy(arg->alloc_lps, cred->alloc_lps, arg->alloc_lps_cnt * sizeof(uint32_t));
+                memcpy(arg->alloc_lps, cred->alloc_lps, 
+			arg->alloc_lps_cnt * sizeof(uint32_t));
         }
 
 	slurm_mutex_unlock(&cred->mutex);
@@ -746,7 +976,7 @@ slurm_cred_pack(slurm_cred_t cred, Buf buffer)
 slurm_cred_t
 slurm_cred_unpack(Buf buffer)
 {
-	uint16_t     len;
+	uint32_t     len;
 	uint32_t     tmpint;
 	slurm_cred_t cred = NULL;
 	char       **sigp;
@@ -762,6 +992,8 @@ slurm_cred_unpack(Buf buffer)
 	safe_unpack32(          &cred->stepid,       buffer);
 	safe_unpack32(          &tmpint,             buffer);
 	cred->uid = tmpint;
+	safe_unpack32(          &cred->job_mem,      buffer);
+	safe_unpack32(          &cred->task_mem,     buffer);
 	safe_unpackstr_xmalloc( &cred->nodes, &len,  buffer);
 	safe_unpack32(          &cred->alloc_lps_cnt,     buffer);
         if (cred->alloc_lps_cnt > 0)
@@ -826,65 +1058,35 @@ slurm_cred_print(slurm_cred_t cred)
 
 	xassert(cred->magic == CRED_MAGIC);
 
-	info("Cred: Jobid   %u",  cred->jobid         );
-	info("Cred: Stepid  %u",  cred->jobid         );
-	info("Cred: UID     %lu", (u_long) cred->uid  );
-	info("Cred: Nodes   %s",  cred->nodes         );
-	info("Cred: alloc_lps_cnt %d", cred->alloc_lps_cnt     ); 
-        info("Cred: alloc_lps: ");                            
-        for (i=0; i<cred->alloc_lps_cnt; i++)                 
-                info("alloc_lps[%d] = %u ", i, cred->alloc_lps[i]);
-	info("Cred: ctime   %s",  ctime(&cred->ctime) );
-	info("Cred: siglen  %u",  cred->siglen        );
+	info("Cred: Jobid    %u",  cred->jobid         );
+	info("Cred: Stepid   %u",  cred->jobid         );
+	info("Cred: UID      %lu", (u_long) cred->uid  );
+	info("Cred: job_mem  %u",  cred->job_mem       );
+	info("Cred: task_mem %u",  cred->task_mem      );
+	info("Cred: Nodes    %s",  cred->nodes         );
+	info("Cred: alloc_lps_cnt %u", cred->alloc_lps_cnt     ); 
+	info("Cred: alloc_lps: ");                            
+	for (i=0; i<cred->alloc_lps_cnt; i++)                 
+		info("alloc_lps[%d] = %u ", i, cred->alloc_lps[i]);
+	info("Cred: ctime    %s",  ctime(&cred->ctime) );
+	info("Cred: siglen   %u",  cred->siglen        );
 	slurm_mutex_unlock(&cred->mutex);
 
 }
 
-
-static EVP_PKEY *
-_read_private_key(const char *path)
+int slurm_cred_get_alloc_lps(slurm_cred_t cred, char **nodes,
+			     uint32_t *alloc_lps_cnt, uint32_t **alloc_lps)
 {
-	FILE     *fp = NULL;
-	EVP_PKEY *pk = NULL;
-
-	xassert(path != NULL);
-
-	if (!(fp = fopen(path, "r"))) {
-		error ("can't open key file '%s' : %m", path);
-		return NULL;
-	}
-
-	if (!PEM_read_PrivateKey(fp, &pk, NULL, NULL))
-		error ("PEM_read_PrivateKey [%s]: %m", path);
-
-	fclose(fp);
-
-	return pk;
-}
-
-
-static EVP_PKEY *
-_read_public_key(const char *path)
-{
-	FILE     *fp = NULL;
-	EVP_PKEY *pk = NULL;
-
-	xassert(path != NULL);
-
-	if ((fp = fopen(path, "r")) == NULL) {
-		error ("can't open public key '%s' : %m ", path);
-		return NULL;
-	}
-
-	if (!PEM_read_PUBKEY(fp, &pk, NULL, NULL)) 
-		error("PEM_read_PUBKEY[%s]: %m", path);
-
-	fclose(fp);
+	if ((cred == NULL) || (nodes == NULL) ||
+	    (alloc_lps_cnt == NULL) || (alloc_lps == NULL))
+		return EINVAL;
 
-	return pk;
+	*nodes         = cred->nodes;
+	*alloc_lps_cnt = cred->alloc_lps_cnt;
+	*alloc_lps     = cred->alloc_lps;
+	return SLURM_SUCCESS;
 }
 
-
 static void 
 _verifier_ctx_init(slurm_cred_ctx_t ctx)
 {
@@ -902,12 +1104,13 @@ _verifier_ctx_init(slurm_cred_ctx_t ctx)
 static int
 _ctx_update_private_key(slurm_cred_ctx_t ctx, const char *path)
 {
-	EVP_PKEY *pk   = NULL;
-	EVP_PKEY *tmpk = NULL;
+	void *pk   = NULL;
+	void *tmpk = NULL;
 
 	xassert(ctx != NULL);
 
-	if (!(pk = _read_private_key(path)))
+	pk = (*(g_crypto_context->ops.crypto_read_private_key))(path);
+	if (!pk)
 		return SLURM_ERROR;
 
 	slurm_mutex_lock(&ctx->mutex);
@@ -920,7 +1123,7 @@ _ctx_update_private_key(slurm_cred_ctx_t ctx, const char *path)
 
 	slurm_mutex_unlock(&ctx->mutex);
 
-	EVP_PKEY_free(tmpk);
+	(*(g_crypto_context->ops.crypto_destroy_key))(tmpk);
 
 	return SLURM_SUCCESS;
 }
@@ -929,11 +1132,11 @@ _ctx_update_private_key(slurm_cred_ctx_t ctx, const char *path)
 static int
 _ctx_update_public_key(slurm_cred_ctx_t ctx, const char *path)
 {
-	EVP_PKEY *pk   = NULL;
+	void *pk   = NULL;
 
 	xassert(ctx != NULL);
-
-	if (!(pk = _read_public_key(path)))
+	pk = (*(g_crypto_context->ops.crypto_read_public_key))(path);
+	if (!pk)
 		return SLURM_ERROR;
 
 	slurm_mutex_lock(&ctx->mutex);
@@ -941,8 +1144,8 @@ _ctx_update_public_key(slurm_cred_ctx_t ctx, const char *path)
 	xassert(ctx->magic == CRED_CTX_MAGIC);
 	xassert(ctx->type  == SLURM_CRED_VERIFIER);
 
-	if (ctx->exkey) 
-		EVP_PKEY_free(ctx->exkey);
+	if (ctx->exkey)
+		(*(g_crypto_context->ops.crypto_destroy_key))(ctx->exkey);
 
 	ctx->exkey = ctx->key;
 	ctx->key   = pk;
@@ -965,7 +1168,7 @@ _exkey_is_valid(slurm_cred_ctx_t ctx)
 	
 	if (time(NULL) > ctx->exkey_exp) {
 		debug2("old job credential key slurmd expired");
-		EVP_PKEY_free(ctx->exkey);
+		(*(g_crypto_context->ops.crypto_destroy_key))(ctx->exkey);
 		ctx->exkey = NULL;
 		return false;
 	}
@@ -978,16 +1181,12 @@ static slurm_cred_ctx_t
 _slurm_cred_ctx_alloc(void)
 {
 	slurm_cred_ctx_t ctx = xmalloc(sizeof(*ctx));
+	/* Contents initialized to zero */
 
 	slurm_mutex_init(&ctx->mutex);
 	slurm_mutex_lock(&ctx->mutex);
 
-	ctx->key           = NULL;
-	ctx->job_list      = NULL;
-	ctx->state_list    = NULL;
 	ctx->expiry_window = DEFAULT_EXPIRATION_WINDOW;
-
-	ctx->exkey         = NULL;
 	ctx->exkey_exp     = (time_t) -1;
 
 	xassert(ctx->magic = CRED_CTX_MAGIC);
@@ -1000,28 +1199,16 @@ static slurm_cred_t
 _slurm_cred_alloc(void)
 {
 	slurm_cred_t cred = xmalloc(sizeof(*cred));
+	/* Contents initialized to zero */
 
 	slurm_mutex_init(&cred->mutex);
-
-	cred->jobid     = 0;
-	cred->stepid    = 0;
-	cred->uid       = (uid_t) -1;
-	cred->nodes     = NULL;
-        cred->alloc_lps_cnt  = 0; 
-	cred->alloc_lps     = NULL;
-	cred->signature = NULL;
-	cred->siglen    = 0;
+	cred->uid = (uid_t) -1;
 
 	xassert(cred->magic = CRED_MAGIC);
 
 	return cred;
 }
 
-static const char *
-_ssl_error(void)
-{
-	return ERR_reason_error_string(ERR_get_error()); 
-}
 
 #ifdef EXTREME_DEBUG
 static void
@@ -1039,89 +1226,62 @@ _print_data(char *data, int datalen)
 static int
 _slurm_cred_sign(slurm_cred_ctx_t ctx, slurm_cred_t cred)
 {
-	EVP_MD_CTX ectx;
 	Buf           buffer;
-	int           rc    = SLURM_SUCCESS;
-	unsigned int *lenp  = &cred->siglen;
-	int           ksize = EVP_PKEY_size(ctx->key);
-
-	/*
-	 * Allocate memory for signature: at most EVP_PKEY_size() bytes
-	 */
-	cred->signature = xmalloc(ksize * sizeof(unsigned char));
+	int           rc;
 
 	buffer = init_buf(4096);
 	_pack_cred(cred, buffer);
-
-	EVP_SignInit(&ectx, EVP_sha1());
-	EVP_SignUpdate(&ectx, get_buf_data(buffer), get_buf_offset(buffer));
-
-	if (!(EVP_SignFinal(&ectx, cred->signature, lenp, ctx->key))) {
-		ERR_print_errors_fp(log_fp());
-		rc = SLURM_ERROR;
-	}
-
-#ifdef HAVE_EVP_MD_CTX_CLEANUP
-	/* Note: Likely memory leak if this function is absent */
-	EVP_MD_CTX_cleanup(&ectx);
-#endif
+	rc = (*(g_crypto_context->ops.crypto_sign))(ctx->key, 
+			get_buf_data(buffer), get_buf_offset(buffer), 
+			&cred->signature, &cred->siglen);
 	free_buf(buffer);
 
-	return rc;
+	if (rc)
+		return SLURM_ERROR;
+	return SLURM_SUCCESS;
 }
 
 static int
 _slurm_cred_verify_signature(slurm_cred_ctx_t ctx, slurm_cred_t cred)
 {
-	EVP_MD_CTX     ectx;
 	Buf            buffer;
 	int            rc;
-	unsigned char *sig    = cred->signature;
-	int            siglen = cred->siglen; 
 
+	debug("Checking credential with %d bytes of sig data", cred->siglen);
 	buffer = init_buf(4096);
 	_pack_cred(cred, buffer);
 
-	debug("Checking credential with %d bytes of sig data", siglen);
-
-	EVP_VerifyInit(&ectx, EVP_sha1());
-	EVP_VerifyUpdate(&ectx, get_buf_data(buffer), get_buf_offset(buffer));
-
-	if (!(rc = EVP_VerifyFinal(&ectx, sig, siglen, ctx->key))) {
-		/*
-		 * Check against old key if one exists and is valid
-		 */
-		if (_exkey_is_valid(ctx))
-			rc = EVP_VerifyFinal(&ectx, sig, siglen, ctx->exkey);
+	rc = (*(g_crypto_context->ops.crypto_verify_sign))(ctx->key, 
+			get_buf_data(buffer), get_buf_offset(buffer),
+			cred->signature, cred->siglen);
+	if (rc && _exkey_is_valid(ctx)) {
+		rc = (*(g_crypto_context->ops.crypto_verify_sign))(ctx->key, 
+			get_buf_data(buffer), get_buf_offset(buffer),
+			cred->signature, cred->siglen);
 	}
-
-	if (!rc) {
-		ERR_load_crypto_strings();
-		info("Credential signature check: %s", _ssl_error());
-		rc = SLURM_ERROR;
-	} else
-		rc = SLURM_SUCCESS;
-
-#ifdef HAVE_EVP_MD_CTX_CLEANUP
-	/* Note: Likely memory leak if this function is absent */
-	EVP_MD_CTX_cleanup(&ectx);
-#endif
 	free_buf(buffer);
 
-	return rc;
+	if (rc) {
+		info("Credential signature check: %s", 
+			(*(g_crypto_context->ops.crypto_str_error))());
+		return SLURM_ERROR;
+	}
+	return SLURM_SUCCESS;
 }
 
 
 static void
 _pack_cred(slurm_cred_t cred, Buf buffer)
 {
-	pack32(           cred->jobid,  buffer);
-	pack32(           cred->stepid, buffer);
-	pack32((uint32_t) cred->uid,    buffer);
-	packstr(          cred->nodes,  buffer);
+	pack32(           cred->jobid,    buffer);
+	pack32(           cred->stepid,   buffer);
+	pack32((uint32_t) cred->uid,      buffer);
+	pack32(           cred->job_mem,  buffer);
+	pack32(           cred->task_mem, buffer);
+	packstr(          cred->nodes,    buffer);
 	pack32(           cred->alloc_lps_cnt, buffer);
-        if (cred->alloc_lps_cnt > 0)
-                pack32_array( cred->alloc_lps, cred->alloc_lps_cnt, buffer);
+	if (cred->alloc_lps_cnt > 0)
+		pack32_array( cred->alloc_lps, cred->alloc_lps_cnt, buffer);
 	pack_time(        cred->ctime,  buffer);
 }
 
@@ -1146,7 +1306,8 @@ _credential_replayed(slurm_cred_ctx_t ctx, slurm_cred_t cred)
 	/*
 	 * If we found a match, this credential is being replayed.
 	 */
-	if (s) return true; 
+	if (s)
+		return true; 
 
 	/*
 	 * Otherwise, save the credential state
@@ -1165,8 +1326,10 @@ static char * timestr (const time_t *tp, char *buf, size_t n)
 	struct tm tmval;
 #ifdef DISABLE_LOCALTIME
 	static int disabled = 0;
-	if (buf == NULL) disabled=1;
-	if (disabled) return NULL;
+	if (buf == NULL)
+		disabled=1;
+	if (disabled)
+		return NULL;
 #endif
 	if (!localtime_r (tp, &tmval))
 		error ("localtime_r: %m");
@@ -1179,15 +1342,15 @@ slurm_cred_handle_reissue(slurm_cred_ctx_t ctx, slurm_cred_t cred)
 {
 	job_state_t  *j = _find_job_state(ctx, cred->jobid);
 
-	if (j != NULL && j->revoked && cred->ctime > j->revoked) {
+	if (j != NULL && j->revoked && (cred->ctime > j->revoked)) {
 		/* The credential has been reissued.  Purge the
-		   old record so that "cred" will look like a new
-		   credential to any ensuing commands. */
+		 * old record so that "cred" will look like a new
+		 * credential to any ensuing commands. */
 		info("reissued job credential for job %u", j->jobid);
 
 		/* Setting j->expiration to zero will make
-		   _clear_expired_job_states() remove this job credential
-		   from the cred context. */
+		 * _clear_expired_job_states() remove this
+		 * job credential from the cred context. */
 		j->expiration = 0;
 		_clear_expired_job_states(ctx);
 	}
@@ -1221,7 +1384,7 @@ _credential_revoked(slurm_cred_ctx_t ctx, slurm_cred_t cred)
 
 	if (cred->ctime <= j->revoked) {
 		char buf[64];
-		debug ("cred for %d revoked. expires at %s", 
+		debug ("cred for %u revoked. expires at %s", 
                        j->jobid, timestr (&j->expiration, buf, 64));
 		return true;
 	}
@@ -1237,7 +1400,10 @@ _find_job_state(slurm_cred_ctx_t ctx, uint32_t jobid)
 	job_state_t  *j = NULL;
 
 	i = list_iterator_create(ctx->job_list);
-	while ((j = list_next(i)) && (j->jobid != jobid)) {;}
+	while ((j = list_next(i))) {
+		if (j->jobid == jobid)
+			break;
+	}
 	list_iterator_destroy(i);
 	return j;
 }
@@ -1305,7 +1471,7 @@ _clear_expired_job_states(slurm_cred_ctx_t ctx)
 		        j->jobid, timestr(&j->ctime, t1, 64), t2, t3);
 
 		if (j->revoked && (now > j->expiration)) {
-			list_delete(i);
+			list_delete_item(i);
 		}
 	}
 
@@ -1324,7 +1490,7 @@ _clear_expired_credential_states(slurm_cred_ctx_t ctx)
 
 	while ((s = list_next(i))) {
 		if (now > s->expiration)
-			list_delete(i);
+			list_delete_item(i);
 	}
 
 	list_iterator_destroy(i);
diff --git a/src/common/slurm_cred.h b/src/common/slurm_cred.h
index fd974979eafebb7e858b1a8ca87f5d237df60ea0..9fb47d6abf5c17ab1cb72be0c805d5ae01a900cf 100644
--- a/src/common/slurm_cred.h
+++ b/src/common/slurm_cred.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/common/slurm_cred.h  - SLURM job credential operations
- *  $Id: slurm_cred.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: slurm_cred.h 14148 2008-05-28 23:35:40Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -129,12 +129,17 @@ int  slurm_cred_ctx_unpack(slurm_cred_ctx_t ctx, Buf buffer);
 typedef struct {
 	uint32_t jobid;
 	uint32_t stepid;
+	uint32_t job_mem;	/* MB of memory reserved for job */
+	uint32_t task_mem;	/* MB of memory reserved per task */
 	uid_t    uid;
 	char    *hostlist;
 	uint32_t alloc_lps_cnt;
         uint32_t *alloc_lps;
 } slurm_cred_arg_t;
 
+/* Terminate the plugin and release all memory. */
+int slurm_crypto_fini(void);
+
 /*
  * Create a slurm credential using the values in `arg.'
  * The credential is signed using the creators public key.
@@ -262,6 +267,11 @@ int slurm_cred_get_signature(slurm_cred_t cred, char **datap, int *len);
  */
 void slurm_cred_print(slurm_cred_t cred);
 
+/*
+ * Get count of allocated LPS (processors) by node
+ */
+int slurm_cred_get_alloc_lps(slurm_cred_t cred, char **nodes, 
+			     uint32_t *alloc_lps_cnt, uint32_t **alloc_lps);
 #ifdef DISABLE_LOCALTIME
 extern char * timestr (const time_t *tp, char *buf, size_t n);
 #endif
diff --git a/src/common/slurm_errno.c b/src/common/slurm_errno.c
index ff413445e38fc50afd3a6c32c616d7f9bb601d74..4720b21895c488ad3cc9fd90f1d5a96065a08eee 100644
--- a/src/common/slurm_errno.c
+++ b/src/common/slurm_errno.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -114,7 +114,7 @@ static slurm_errtab_t slurm_errtab[] = {
 	{ ESLURM_DEFAULT_PARTITION_NOT_SET,
 	  "No partition specified or system default partition"	},
 	{ ESLURM_ACCESS_DENIED, 
-	  "Access denied"					},
+	  "Access/permission denied"				},
 	{ ESLURM_JOB_MISSING_REQUIRED_PARTITION_GROUP,
 	  "User's group not permitted to use this partition"	},
 	{ ESLURM_REQUESTED_NODES_NOT_IN_PARTITION,
@@ -122,7 +122,7 @@ static slurm_errtab_t slurm_errtab[] = {
 	{ ESLURM_TOO_MANY_REQUESTED_CPUS,
 	  "More processors requested than permitted"		},
 	{ ESLURM_TOO_MANY_REQUESTED_NODES,
-	  "More nodes requested than permitted"			},
+	  "Node count specification invalid"			},
 	{ ESLURM_ERROR_ON_DESC_TO_RECORD_COPY,
 	  "Unable to create job record, try again"		},
 	{ ESLURM_JOB_MISSING_SIZE_SPECIFICATION,
@@ -134,7 +134,7 @@ static slurm_errtab_t slurm_errtab[] = {
 	{ ESLURM_DUPLICATE_JOB_ID, 
 	  "Duplicate job id"					},
 	{ ESLURM_PATHNAME_TOO_LONG,
-	  "Pathname of a file or directory too long"   		},
+	  "Pathname of a file, directory or other parameter too long" },
 	{ ESLURM_NOT_TOP_PRIORITY,
 	  "Immediate execution impossible, insufficient priority" },
 	{ ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE,
@@ -170,15 +170,23 @@ static slurm_errtab_t slurm_errtab[] = {
 	{ ESLURM_INVALID_FEATURE, 
 	  "Invalid feature specification"			},
 	{ ESLURM_INVALID_AUTHTYPE_CHANGE,
-	  "AuthType change requires restart of all SLURM daemons and commands"},
+	  "AuthType change requires restart of all SLURM daemons and "
+	  "commands to take effect"},
 	{ ESLURM_INVALID_CHECKPOINT_TYPE_CHANGE,
-	  "Invalid change in CheckpointType requested"		},
+	  "CheckpointType change requires restart of all SLURM daemons "
+	  "to take effect"					},
+	{ ESLURM_INVALID_CRYPTO_TYPE_CHANGE,
+	  "CryptoType change requires restart of all SLURM daemons "
+	  "to take effect"					},
 	{ ESLURM_INVALID_SCHEDTYPE_CHANGE,
-	  "Invalid change in SchedulerType requested"		},
+	  "SchedulerType change requires restart of the slurmctld daemon "
+	  "to take effect"					},
 	{ ESLURM_INVALID_SELECTTYPE_CHANGE,
-	  "Invalid change in SelectType requested"		},
+	  "SelectType change requires restart of the slurmctld daemon "
+	  "to take effect"					},
 	{ ESLURM_INVALID_SWITCHTYPE_CHANGE,
-	  "SwitchType change requires restart of all SLURM daemons and jobs"},
+	  "SwitchType change requires restart of all SLURM daemons and "
+	  "jobs to take effect"					},
 	{ ESLURM_FRAGMENTATION,
 	  "Immediate execution impossible, "
 	  "resources too fragmented for allocation"		},
@@ -187,7 +195,7 @@ static slurm_errtab_t slurm_errtab[] = {
 	{ ESLURM_DISABLED,
 	  "Requested operation is presently disabled"		},
 	{ ESLURM_DEPENDENCY,
-	  "Immediate execution impossible, job dependency problem"},
+	  "Job dependency problem"				},
  	{ ESLURM_BATCH_ONLY,
 	  "Only batch jobs are accepted or processed"		},
 	{ ESLURM_TASKDIST_ARBITRARY_UNSUPPORTED,
@@ -196,6 +204,19 @@ static slurm_errtab_t slurm_errtab[] = {
 	  "Requested more tasks than available processors"	},
 	{ ESLURM_JOB_HELD,
 	  "Job is in held state, pending scheduler release"	},
+	{ ESLURM_INVALID_BANK_ACCOUNT,
+	  "Invalid bank account specified"			},
+	{ ESLURM_INVALID_TASK_MEMORY,
+	  "Memory required by task is not available"		},
+	{ ESLURM_INVALID_ACCOUNT,
+	  "Job has invalid account"				},
+	{ ESLURM_INVALID_LICENSES,
+	  "Job has invalid license specification"		},
+	{ ESLURM_NEED_RESTART,
+	  "The node configuration changes that were made require restart "
+	  "of the slurmctld daemon to take effect"},
+	{ ESLURM_ACCOUNTING_POLICY,
+	  "Job violates accounting policy (the user's size and/or time limits)"},
 
 	/* slurmd error codes */
 
diff --git a/src/common/slurm_jobacct.c b/src/common/slurm_jobacct.c
deleted file mode 100644
index 41a55ff0439c30985801b9406cec81d4905a41b3..0000000000000000000000000000000000000000
--- a/src/common/slurm_jobacct.c
+++ /dev/null
@@ -1,692 +0,0 @@
-/*****************************************************************************\
- *  slurm_jobacct.c - implementation-independent job accounting logging 
- *  functions
- *****************************************************************************
- *  Copyright (C) 2003 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Jay Windley <jwindley@lnxi.com>, Morris Jette <jette1@llnl.com>
- *  UCRL-CODE-226842.
- *  
- *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-/*****************************************************************************\
- *  Modification history
- *
- *  19 Jan 2005 by Andy Riebs <andy.riebs@hp.com>
- *  	 This file is derived from the file slurm_jobcomp.c, written by
- *  	 Morris Jette, et al.
-\*****************************************************************************/
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "src/common/macros.h"
-#include "src/common/plugin.h"
-#include "src/common/plugrack.h"
-#include "src/common/slurm_jobacct.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/slurmd/slurmstepd/slurmstepd_job.h"
-
-
-/*
- * The following global is used by the jobacct/log plugin; it must
- * persist when the plugin is reloaded, so we define it here.
- */
-extern FILE * JOBACCT_LOGFILE;
-
-/*
- * WARNING:  Do not change the order of these fields or add additional
- * fields at the beginning of the structure.  If you do, job accounting
- * plugins will stop working.  If you need to add fields, add them 
- * at the end of the structure.
- */
-typedef struct slurm_jobacct_ops {
-	int (*jobacct_init_struct)    (jobacctinfo_t *jobacct, 
-				       jobacct_id_t *jobacct_id);
-	jobacctinfo_t *(*jobacct_alloc)(jobacct_id_t *jobacct_id);
-	void (*jobacct_free)          (jobacctinfo_t *jobacct);
-	int (*jobacct_setinfo)        (jobacctinfo_t *jobacct, 
-				       enum jobacct_data_type type, 
-				       void *data);
-	int (*jobacct_getinfo)        (jobacctinfo_t *jobacct, 
-				       enum jobacct_data_type type, 
-				       void *data);
-	void (*jobacct_aggregate)     (jobacctinfo_t *dest, 
-				       jobacctinfo_t *from);
-	void (*jobacct_2_sacct)       (sacct_t *sacct, 
-				       jobacctinfo_t *jobacct);
-	void (*jobacct_pack)          (jobacctinfo_t *jobacct, Buf buffer);
-	int (*jobacct_unpack)         (jobacctinfo_t **jobacct, Buf buffer);
-	int (*jobacct_init)	      (char *job_acct_log);
-	int (*jobacct_fini)	      ();
-	int (*jobacct_job_start)      (struct job_record *job_ptr);
-	int (*jobacct_job_complete)   (struct job_record *job_ptr); 
-	int (*jobacct_step_start)     (struct step_record *step);
-	int (*jobacct_step_complete)  (struct step_record *step);
-	int (*jobacct_suspend)        (struct job_record *job_ptr);
-	int (*jobacct_startpoll)      (int frequency);
-	int (*jobacct_endpoll)	      ();
-	int (*jobacct_set_proctrack_container_id)(uint32_t id);
-	int (*jobacct_add_task)       (pid_t pid, jobacct_id_t *jobacct_id);
-	jobacctinfo_t *(*jobacct_stat_task)(pid_t pid);
-	jobacctinfo_t *(*jobacct_remove_task)(pid_t pid);
-	void (*jobacct_suspend_poll)  ();
-	void (*jobacct_resume_poll)   ();
-	int (*jobacct_node_down)      (struct node_record *node_ptr, 
-				       time_t event_time, char *reason);
-	int (*jobacct_node_up)        (struct node_record *node_ptr,
-				       time_t event_time);
-	int (*jobacct_cluster_procs)  (uint32_t procs, time_t event_time);
-	
-} slurm_jobacct_ops_t;
-
-/*
- * A global job accounting context.  "Global" in the sense that there's
- * only one, with static bindings.  We don't export it.
- */
-
-typedef struct slurm_jobacct_context {
-	char 			*jobacct_type;
-	plugrack_t		plugin_list;
-	plugin_handle_t		cur_plugin;
-	int			jobacct_errno;
-	slurm_jobacct_ops_t	ops;
-} slurm_jobacct_context_t;
-
-static slurm_jobacct_context_t *g_jobacct_context = NULL;
-static pthread_mutex_t      g_jobacct_context_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static int _slurm_jobacct_init(void);
-static int _slurm_jobacct_fini(void);
-
-static slurm_jobacct_context_t *
-_slurm_jobacct_context_create( const char *jobacct_type)
-{
-	slurm_jobacct_context_t *c;
-
-	if ( jobacct_type == NULL ) {
-		error( "_slurm_jobacct_context_create: no jobacct type" );
-		return NULL;
-	}
-
-	c = xmalloc( sizeof( struct slurm_jobacct_context ) );
-
-	c->jobacct_errno = SLURM_SUCCESS;
-
-	/* Copy the job completion job completion type. */
-	c->jobacct_type = xstrdup( jobacct_type );
-	if ( c->jobacct_type == NULL ) {
-		error( "can't make local copy of jobacct type" );
-		xfree( c );
-		return NULL; 
-	}
-
-	/* Plugin rack is demand-loaded on first reference. */
-	c->plugin_list = NULL; 
-	c->cur_plugin = PLUGIN_INVALID_HANDLE; 
-	c->jobacct_errno	= SLURM_SUCCESS;
-
-	return c;
-}
-
-static int
-_slurm_jobacct_context_destroy( slurm_jobacct_context_t *c )
-{
-	/*
-	 * Must check return code here because plugins might still
-	 * be loaded and active.
-	 */
-	if ( c->plugin_list ) {
-		if ( plugrack_destroy( c->plugin_list ) != SLURM_SUCCESS ) {
-			 return SLURM_ERROR;
-		}
-	}
-
-	xfree( c->jobacct_type );
-	xfree( c );
-
-	return SLURM_SUCCESS;
-}
-
-/*
- * Resolve the operations from the plugin.
- */
-static slurm_jobacct_ops_t *
-_slurm_jobacct_get_ops( slurm_jobacct_context_t *c )
-{
-	/*
-	 * These strings must be in the same order as the fields declared
-	 * for slurm_jobacct_ops_t.
-	 */
-	static const char *syms[] = {
-		"jobacct_p_init_struct",
-		"jobacct_p_alloc",
-		"jobacct_p_free",
-		"jobacct_p_setinfo",
-		"jobacct_p_getinfo",
-		"jobacct_p_aggregate",
-		"jobacct_p_2_sacct",
-		"jobacct_p_pack",
-		"jobacct_p_unpack",	
-		"jobacct_p_init_slurmctld",
-		"jobacct_p_fini_slurmctld",
-		"jobacct_p_job_start_slurmctld",
-		"jobacct_p_job_complete_slurmctld",
-		"jobacct_p_step_start_slurmctld",
-		"jobacct_p_step_complete_slurmctld",
-		"jobacct_p_suspend_slurmctld",
-		"jobacct_p_startpoll",
-		"jobacct_p_endpoll",
-		"jobacct_p_set_proctrack_container_id",
-		"jobacct_p_add_task",
-		"jobacct_p_stat_task",
-		"jobacct_p_remove_task",
-		"jobacct_p_suspend_poll",
-		"jobacct_p_resume_poll",
-		"jobacct_p_node_down",
-		"jobacct_p_node_up",
-		"jobacct_p_cluster_procs"
-	};
-	int n_syms = sizeof( syms ) / sizeof( char * );
-	int rc = 0;
-        /* Get the plugin list, if needed. */
-        if ( c->plugin_list == NULL ) {
-		char *plugin_dir;
-                c->plugin_list = plugrack_create();
-                if ( c->plugin_list == NULL ) {
-                        error( "Unable to create a plugin manager" );
-                        return NULL;
-                }
-
-                plugrack_set_major_type( c->plugin_list, "jobacct" );
-                plugrack_set_paranoia( c->plugin_list, 
-				       PLUGRACK_PARANOIA_NONE, 
-				       0 );
-		plugin_dir = slurm_get_plugin_dir();
-                plugrack_read_dir( c->plugin_list, plugin_dir );
-		xfree(plugin_dir);
-        }
-  
-        /* Find the correct plugin. */
-        c->cur_plugin = 
-		plugrack_use_by_type( c->plugin_list, c->jobacct_type );
-        if ( c->cur_plugin == PLUGIN_INVALID_HANDLE ) {
-                error( "can't find a plugin for type %s", c->jobacct_type );
-                return NULL;
-        }  
-
-        /* Dereference the API. */
-        if ( (rc = plugin_get_syms( c->cur_plugin,
-				    n_syms,
-				    syms,
-				    (void **) &c->ops )) < n_syms ) {
-                error( "incomplete jobacct plugin detected only "
-		       "got %d out of %d",
-		       rc, n_syms);
-                return NULL;
-        }
-
-        return &c->ops;
-}
-
-static int _slurm_jobacct_init(void)
-{
-	char	*jobacct_type = NULL;
-	int	retval=SLURM_SUCCESS;
-
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		goto done;
-
-	jobacct_type = slurm_get_jobacct_type();
-	g_jobacct_context = _slurm_jobacct_context_create( jobacct_type );
-	if ( g_jobacct_context == NULL ) {
-		error( "cannot create a context for %s", jobacct_type );
-		retval = SLURM_ERROR;
-		goto done;
-	}
-	
-	if ( _slurm_jobacct_get_ops( g_jobacct_context ) == NULL ) {
-		error( "cannot resolve job accounting plugin operations" );
-		_slurm_jobacct_context_destroy( g_jobacct_context );
-		g_jobacct_context = NULL;
-		retval = SLURM_ERROR;
-	}
-
-  done:
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	xfree(jobacct_type);
-
-	return(retval);
-}
-
-static int _slurm_jobacct_fini(void)
-{
-	int rc;
-
-	if (!g_jobacct_context)
-		return SLURM_SUCCESS;
-
-	rc = _slurm_jobacct_context_destroy(g_jobacct_context);
-	g_jobacct_context = NULL;
-	return rc;
-}
-
-extern int jobacct_init(void)
-{
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-
-	return SLURM_SUCCESS;
-}
-
-extern int jobacct_g_init_struct(jobacctinfo_t *jobacct, 
-				 jobacct_id_t *jobacct_id)
-{
-	int retval = SLURM_SUCCESS;
-	
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_init_struct))
-			(jobacct, jobacct_id);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern jobacctinfo_t *jobacct_g_alloc(jobacct_id_t *jobacct_id)
-{
-	jobacctinfo_t *jobacct = NULL;
-
-	if (_slurm_jobacct_init() < 0)
-		return jobacct;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		jobacct = (*(g_jobacct_context->ops.jobacct_alloc))
-			(jobacct_id);
-	
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return jobacct;
-}
-
-extern void jobacct_g_free(jobacctinfo_t *jobacct)
-{
-	if (_slurm_jobacct_init() < 0)
-		return;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		(*(g_jobacct_context->ops.jobacct_free))(jobacct);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return;
-}
-
-extern int jobacct_g_setinfo(jobacctinfo_t *jobacct, 
-			     enum jobacct_data_type type, void *data)
-{
-	int retval = SLURM_SUCCESS;
-
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_setinfo))
-			(jobacct, type, data);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_getinfo(jobacctinfo_t *jobacct, 
-			     enum jobacct_data_type type, void *data)
-{
-	int retval = SLURM_SUCCESS;
-
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_getinfo))
-			(jobacct, type, data);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern void jobacct_g_aggregate(jobacctinfo_t *dest, jobacctinfo_t *from)
-{
-	if (_slurm_jobacct_init() < 0)
-		return;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		(*(g_jobacct_context->ops.jobacct_aggregate))(dest, from);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return;
-}
-
-extern void jobacct_g_2_sacct(sacct_t *sacct, jobacctinfo_t *jobacct)
-{
-	if (_slurm_jobacct_init() < 0)
-		return;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		(*(g_jobacct_context->ops.jobacct_2_sacct))(sacct, jobacct);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return;
-}
-
-extern void jobacct_g_pack(jobacctinfo_t *jobacct, Buf buffer)
-{
-	if (_slurm_jobacct_init() < 0)
-		return;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		(*(g_jobacct_context->ops.jobacct_pack))(jobacct, buffer);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return;
-}
-
-extern int jobacct_g_unpack(jobacctinfo_t **jobacct, Buf buffer)
-{
-	int retval = SLURM_SUCCESS;
-
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_unpack))
-			(jobacct, buffer);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_init_slurmctld(char *job_acct_log)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context ) 
-		retval = (*(g_jobacct_context->ops.jobacct_init))
-			(job_acct_log);
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	return retval;
-}
-
-extern int jobacct_g_fini_slurmctld()
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context ) 
-		retval = (*(g_jobacct_context->ops.jobacct_fini))();
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	
-	if (_slurm_jobacct_fini() < 0)
-		return SLURM_ERROR;
-	return retval;
-}
-
-extern int jobacct_g_job_start_slurmctld(struct job_record *job_ptr)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_job_start))
-			(job_ptr);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_job_complete_slurmctld(struct job_record *job_ptr)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_job_complete))
-			(job_ptr);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_step_start_slurmctld(struct step_record *step_ptr)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_step_start))
-			(step_ptr);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_step_complete_slurmctld(struct step_record *step_ptr)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_step_complete))
-			(step_ptr);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_suspend_slurmctld(struct job_record *job_ptr)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_suspend))
-			(job_ptr);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_startpoll(int frequency)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context ) 
-		retval = (*(g_jobacct_context->ops.jobacct_startpoll))
-			(frequency);
-	
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	return retval;
-}
-
-extern int jobacct_g_endpoll()
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_endpoll))();
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern int jobacct_g_set_proctrack_container_id(uint32_t id)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.
-			    jobacct_set_proctrack_container_id))(id);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-	
-}
-
-extern int jobacct_g_add_task(pid_t pid, jobacct_id_t *jobacct_id)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_add_task))
-			(pid, jobacct_id);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return retval;
-}
-
-extern jobacctinfo_t *jobacct_g_stat_task(pid_t pid)
-{
-	jobacctinfo_t *jobacct = NULL;
-	if (_slurm_jobacct_init() < 0)
-		return jobacct;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		jobacct = (*(g_jobacct_context->ops.jobacct_stat_task))(pid);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return jobacct;
-}
-
-extern jobacctinfo_t *jobacct_g_remove_task(pid_t pid)
-{
-	jobacctinfo_t *jobacct = NULL;
-	if (_slurm_jobacct_init() < 0)
-		return jobacct;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		jobacct = (*(g_jobacct_context->ops.jobacct_remove_task))(pid);
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return jobacct;
-}
-
-extern void jobacct_g_suspend_poll()
-{
-	if (_slurm_jobacct_init() < 0)
-		return;
-	
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		(*(g_jobacct_context->ops.jobacct_suspend_poll))();
-	slurm_mutex_unlock( &g_jobacct_context_lock );	
-	return;
-}
-
-extern void jobacct_g_resume_poll()
-{
-	if (_slurm_jobacct_init() < 0)
-		return;
-
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		(*(g_jobacct_context->ops.jobacct_resume_poll))();
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	return;
-}
-
-extern int jobacct_g_node_down(struct node_record *node_ptr, time_t event_time,
-			       char *reason)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_node_down))
-			(node_ptr, event_time, reason);
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	return retval;
-}
-
-extern int jobacct_g_node_up(struct node_record *node_ptr, time_t event_time)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_node_up))
-			(node_ptr, event_time);
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	return retval;
-}
-
-extern int jobacct_g_cluster_procs(uint32_t procs, time_t event_time)
-{
-	int retval = SLURM_SUCCESS;
-	if (_slurm_jobacct_init() < 0)
-		return SLURM_ERROR;
-
-	slurm_mutex_lock( &g_jobacct_context_lock );
-	if ( g_jobacct_context )
-		retval = (*(g_jobacct_context->ops.jobacct_cluster_procs))
-			(procs, event_time);
-	slurm_mutex_unlock( &g_jobacct_context_lock );
-	return retval;
-}
diff --git a/src/common/slurm_jobacct_gather.c b/src/common/slurm_jobacct_gather.c
new file mode 100644
index 0000000000000000000000000000000000000000..2902c4a27b5e8230be527237342bd2bd4448c2db
--- /dev/null
+++ b/src/common/slurm_jobacct_gather.c
@@ -0,0 +1,524 @@
+/*****************************************************************************\
+ *  slurm_jobacct_gather.c - implementation-independent job accounting logging 
+ *  functions
+ *****************************************************************************
+ *  Copyright (C) 2003-2007/ The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Jay Windley <jwindley@lnxi.com>, Morris Jette <jette1@llnl.com>
+ *  LLNL-CODE-402394.
+ *  
+ *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
+ *
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+/*****************************************************************************\
+ *  Modification history
+ *
+ *  19 Jan 2005 by Andy Riebs <andy.riebs@hp.com>
+ *  	 This file is derived from the file slurm_jobcomp.c, written by
+ *  	 Morris Jette, et al.
+\*****************************************************************************/
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "src/common/macros.h"
+#include "src/common/plugin.h"
+#include "src/common/plugrack.h"
+#include "src/common/slurm_jobacct_gather.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+#include "src/slurmd/slurmstepd/slurmstepd_job.h"
+
+
+/*
+ * WARNING:  Do not change the order of these fields or add additional
+ * fields at the beginning of the structure.  If you do, job accounting
+ * plugins will stop working.  If you need to add fields, add them 
+ * at the end of the structure.
+ */
+typedef struct slurm_jobacct_gather_ops {
+	jobacctinfo_t *(*jobacct_gather_create)(jobacct_id_t *jobacct_id);
+	void (*jobacct_gather_destroy)          (jobacctinfo_t *jobacct);
+	int (*jobacct_gather_setinfo)        (jobacctinfo_t *jobacct, 
+					      enum jobacct_data_type type, 
+					      void *data);
+	int (*jobacct_gather_getinfo)        (jobacctinfo_t *jobacct, 
+					      enum jobacct_data_type type, 
+					      void *data);
+	void (*jobacct_gather_pack)   (jobacctinfo_t *jobacct, Buf buffer);
+	int (*jobacct_gather_unpack)  (jobacctinfo_t **jobacct, Buf buffer);
+	void (*jobacct_gather_aggregate)     (jobacctinfo_t *dest, 
+					      jobacctinfo_t *from);
+	int (*jobacct_gather_startpoll)      (uint16_t frequency);
+	int (*jobacct_gather_endpoll)	     ();
+	void (*jobacct_gather_change_poll)   (uint16_t frequency);
+	void (*jobacct_gather_suspend_poll)  ();
+	void (*jobacct_gather_resume_poll)   ();
+	int (*jobacct_gather_set_proctrack_container_id)(uint32_t id);
+	int (*jobacct_gather_add_task) (pid_t pid, jobacct_id_t *jobacct_id);
+	jobacctinfo_t *(*jobacct_gather_stat_task)(pid_t pid);
+	jobacctinfo_t *(*jobacct_gather_remove_task)(pid_t pid);
+	void (*jobacct_gather_2_sacct)       (sacct_t *sacct, 
+					      jobacctinfo_t *jobacct);
+} slurm_jobacct_gather_ops_t;
+
+/*
+ * A global job accounting context.  "Global" in the sense that there's
+ * only one, with static bindings.  We don't export it.
+ */
+
+typedef struct slurm_jobacct_gather_context {
+	char 			*jobacct_gather_type;
+	plugrack_t		plugin_list;
+	plugin_handle_t		cur_plugin;
+	int			jobacct_gather_errno;
+	slurm_jobacct_gather_ops_t	ops;
+} slurm_jobacct_gather_context_t;
+
+static slurm_jobacct_gather_context_t *g_jobacct_gather_context = NULL;
+static pthread_mutex_t g_jobacct_gather_context_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static int _slurm_jobacct_gather_init(void);
+
+static slurm_jobacct_gather_context_t *
+_slurm_jobacct_gather_context_create( const char *jobacct_gather_type)
+{
+	slurm_jobacct_gather_context_t *c;
+
+	if ( jobacct_gather_type == NULL ) {
+		error("_slurm_jobacct_gather_context_create: no jobacct type");
+		return NULL;
+	}
+
+	c = xmalloc( sizeof( struct slurm_jobacct_gather_context ) );
+
+	c->jobacct_gather_errno = SLURM_SUCCESS;
+
+	/* Copy the job completion job completion type. */
+	c->jobacct_gather_type = xstrdup( jobacct_gather_type );
+	if ( c->jobacct_gather_type == NULL ) {
+		error( "can't make local copy of jobacct type" );
+		xfree( c );
+		return NULL; 
+	}
+
+	/* Plugin rack is demand-loaded on first reference. */
+	c->plugin_list = NULL; 
+	c->cur_plugin = PLUGIN_INVALID_HANDLE; 
+	c->jobacct_gather_errno	= SLURM_SUCCESS;
+
+	return c;
+}
+
+static int
+_slurm_jobacct_gather_context_destroy( slurm_jobacct_gather_context_t *c )
+{
+	/*
+	 * Must check return code here because plugins might still
+	 * be loaded and active.
+	 */
+	if ( c->plugin_list ) {
+		if ( plugrack_destroy( c->plugin_list ) != SLURM_SUCCESS ) {
+			 return SLURM_ERROR;
+		}
+	}
+
+	xfree( c->jobacct_gather_type );
+	xfree( c );
+
+	return SLURM_SUCCESS;
+}
+
+/*
+ * Resolve the operations from the plugin.
+ */
+static slurm_jobacct_gather_ops_t *
+_slurm_jobacct_gather_get_ops( slurm_jobacct_gather_context_t *c )
+{
+	/*
+	 * These strings must be in the same order as the fields declared
+	 * for slurm_jobacct_gather_ops_t.
+	 */
+	static const char *syms[] = {
+		"jobacct_gather_p_create",
+		"jobacct_gather_p_destroy",
+		"jobacct_gather_p_setinfo",
+		"jobacct_gather_p_getinfo",
+		"jobacct_gather_p_pack",
+		"jobacct_gather_p_unpack",	
+		"jobacct_gather_p_aggregate",
+		"jobacct_gather_p_startpoll",
+		"jobacct_gather_p_endpoll",
+		"jobacct_gather_p_change_poll",
+		"jobacct_gather_p_suspend_poll",
+		"jobacct_gather_p_resume_poll",
+		"jobacct_gather_p_set_proctrack_container_id",
+		"jobacct_gather_p_add_task",
+		"jobacct_gather_p_stat_task",
+		"jobacct_gather_p_remove_task",
+		"jobacct_gather_p_2_sacct"
+	};
+	int n_syms = sizeof( syms ) / sizeof( char * );
+	int rc = 0;
+        /* Get the plugin list, if needed. */
+        if ( c->plugin_list == NULL ) {
+		char *plugin_dir;
+                c->plugin_list = plugrack_create();
+                if ( c->plugin_list == NULL ) {
+                        error( "Unable to create a plugin manager" );
+                        return NULL;
+                }
+
+                plugrack_set_major_type( c->plugin_list, "jobacct_gather" );
+                plugrack_set_paranoia( c->plugin_list, 
+				       PLUGRACK_PARANOIA_NONE, 
+				       0 );
+		plugin_dir = slurm_get_plugin_dir();
+                plugrack_read_dir( c->plugin_list, plugin_dir );
+		xfree(plugin_dir);
+        }
+  
+        /* Find the correct plugin. */
+        c->cur_plugin = 
+		plugrack_use_by_type( c->plugin_list, c->jobacct_gather_type );
+        if ( c->cur_plugin == PLUGIN_INVALID_HANDLE ) {
+                error( "can't find a plugin for type %s",
+		       c->jobacct_gather_type );
+                return NULL;
+        }  
+
+        /* Dereference the API. */
+        if ( (rc = plugin_get_syms( c->cur_plugin,
+				    n_syms,
+				    syms,
+				    (void **) &c->ops )) < n_syms ) {
+                error( "incomplete jobacct_gather plugin detected only "
+		       "got %d out of %d",
+		       rc, n_syms);
+                return NULL;
+        }
+
+        return &c->ops;
+
+}
+
+static int _slurm_jobacct_gather_init(void)
+{
+	char	*jobacct_gather_type = NULL;
+	int	retval=SLURM_SUCCESS;
+
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		goto done;
+
+	jobacct_gather_type = slurm_get_jobacct_gather_type();
+	g_jobacct_gather_context = _slurm_jobacct_gather_context_create( 
+		jobacct_gather_type);
+	if ( g_jobacct_gather_context == NULL ) {
+		error( "cannot create a context for %s", jobacct_gather_type );
+		retval = SLURM_ERROR;
+		goto done;
+	}
+	
+	if ( _slurm_jobacct_gather_get_ops( g_jobacct_gather_context )
+	     == NULL ) {
+		error( "cannot resolve job accounting plugin operations" );
+		_slurm_jobacct_gather_context_destroy(
+			g_jobacct_gather_context);
+		g_jobacct_gather_context = NULL;
+		retval = SLURM_ERROR;
+	}
+
+  done:
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );
+	xfree(jobacct_gather_type);
+
+	return(retval);
+}
+
+extern int slurm_jobacct_gather_init(void)
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+extern int slurm_jobacct_gather_fini(void)
+{
+	int rc;
+
+	if (!g_jobacct_gather_context)
+		return SLURM_SUCCESS;
+
+	rc = _slurm_jobacct_gather_context_destroy(g_jobacct_gather_context);
+	g_jobacct_gather_context = NULL;
+	return rc;
+}
+
+extern jobacctinfo_t *jobacct_gather_g_create(jobacct_id_t *jobacct_id)
+{
+	jobacctinfo_t *jobacct = NULL;
+
+	if (_slurm_jobacct_gather_init() < 0)
+		return jobacct;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		jobacct = (*(g_jobacct_gather_context->
+			     ops.jobacct_gather_create))(jobacct_id);
+	
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return jobacct;
+}
+
+extern void jobacct_gather_g_destroy(jobacctinfo_t *jobacct)
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		(*(g_jobacct_gather_context->ops.jobacct_gather_destroy))
+			(jobacct);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return;
+}
+
+extern int jobacct_gather_g_setinfo(jobacctinfo_t *jobacct, 
+				    enum jobacct_data_type type, void *data)
+{
+	int retval = SLURM_SUCCESS;
+
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		retval = (*(g_jobacct_gather_context->
+			    ops.jobacct_gather_setinfo))(jobacct, type, data);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return retval;
+}
+
+extern int jobacct_gather_g_getinfo(jobacctinfo_t *jobacct, 
+				    enum jobacct_data_type type, void *data)
+{
+	int retval = SLURM_SUCCESS;
+
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		retval = (*(g_jobacct_gather_context->
+			    ops.jobacct_gather_getinfo))(jobacct, type, data);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return retval;
+}
+
+extern void jobacct_gather_g_pack(jobacctinfo_t *jobacct, Buf buffer)
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		(*(g_jobacct_gather_context->ops.jobacct_gather_pack))
+			(jobacct, buffer);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return;
+}
+
+extern int jobacct_gather_g_unpack(jobacctinfo_t **jobacct, Buf buffer)
+{
+	int retval = SLURM_SUCCESS;
+
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		retval = (*(g_jobacct_gather_context->
+			    ops.jobacct_gather_unpack))(jobacct, buffer);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return retval;
+}
+
+extern void jobacct_gather_g_aggregate(jobacctinfo_t *dest,
+				       jobacctinfo_t *from)
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		(*(g_jobacct_gather_context->ops.jobacct_gather_aggregate))
+			(dest, from);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return;
+}
+
+extern int jobacct_gather_g_startpoll(uint16_t frequency)
+{
+	int retval = SLURM_SUCCESS;
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context ) 
+		retval = (*(g_jobacct_gather_context->ops.jobacct_gather_startpoll))
+			(frequency);
+	
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );
+	return retval;
+}
+
+extern int jobacct_gather_g_endpoll()
+{
+	int retval = SLURM_SUCCESS;
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		retval = (*(g_jobacct_gather_context->ops.jobacct_gather_endpoll))();
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return retval;
+}
+
+extern void jobacct_gather_g_change_poll(uint16_t frequency)
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return;
+
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context ) 
+		(*(g_jobacct_gather_context->ops.jobacct_gather_change_poll))
+			(frequency);
+	
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );
+}
+
+extern void jobacct_gather_g_suspend_poll()
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		(*(g_jobacct_gather_context->ops.jobacct_gather_suspend_poll))();
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return;
+}
+
+extern void jobacct_gather_g_resume_poll()
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return;
+
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		(*(g_jobacct_gather_context->ops.jobacct_gather_resume_poll))();
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );
+	return;
+}
+
+extern int jobacct_gather_g_set_proctrack_container_id(uint32_t id)
+{
+	int retval = SLURM_SUCCESS;
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		retval = (*(g_jobacct_gather_context->ops.
+			    jobacct_gather_set_proctrack_container_id))(id);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return retval;
+	
+}
+
+extern int jobacct_gather_g_add_task(pid_t pid, jobacct_id_t *jobacct_id)
+{
+	int retval = SLURM_SUCCESS;
+	if (_slurm_jobacct_gather_init() < 0)
+		return SLURM_ERROR;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		retval = (*(g_jobacct_gather_context->
+			    ops.jobacct_gather_add_task))(pid, jobacct_id);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return retval;
+}
+
+extern jobacctinfo_t *jobacct_gather_g_stat_task(pid_t pid)
+{
+	jobacctinfo_t *jobacct = NULL;
+	if (_slurm_jobacct_gather_init() < 0)
+		return jobacct;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		jobacct = (*(g_jobacct_gather_context->
+			     ops.jobacct_gather_stat_task))(pid);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return jobacct;
+}
+
+extern jobacctinfo_t *jobacct_gather_g_remove_task(pid_t pid)
+{
+	jobacctinfo_t *jobacct = NULL;
+	if (_slurm_jobacct_gather_init() < 0)
+		return jobacct;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		jobacct = (*(g_jobacct_gather_context->
+			     ops.jobacct_gather_remove_task))(pid);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return jobacct;
+}
+
+extern void jobacct_gather_g_2_sacct(sacct_t *sacct, jobacctinfo_t *jobacct)
+{
+	if (_slurm_jobacct_gather_init() < 0)
+		return;
+	
+	slurm_mutex_lock( &g_jobacct_gather_context_lock );
+	if ( g_jobacct_gather_context )
+		(*(g_jobacct_gather_context->ops.jobacct_gather_2_sacct))
+			(sacct, jobacct);
+	slurm_mutex_unlock( &g_jobacct_gather_context_lock );	
+	return;
+}
diff --git a/src/common/slurm_jobacct.h b/src/common/slurm_jobacct_gather.h
similarity index 50%
rename from src/common/slurm_jobacct.h
rename to src/common/slurm_jobacct_gather.h
index a7c4ac55e139746c633511b2f44bb7f9f73d83af..3059872e28984ae67f4eaa2ec1df42908ade257b 100644
--- a/src/common/slurm_jobacct.h
+++ b/src/common/slurm_jobacct_gather.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
- *  slurm_jobacct.h - implementation-independent job completion logging 
+ *  slurm_jobacct_gather.h - implementation-independent job completion logging 
  *  API definitions
  *****************************************************************************
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.com> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
  *
@@ -47,70 +47,65 @@
 \*****************************************************************************/
 
 
-#ifndef __SLURM_JOBACCT_H__
-#define __SLURM_JOBACCT_H__
+#ifndef __SLURM_JOBACCT_GATHER_H__
+#define __SLURM_JOBACCT_GATHER_H__
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#  if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#  else
+#    if HAVE_STDINT_H
+#      include <stdint.h>
+#    endif
+#  endif			/* HAVE_INTTYPES_H */
+#else				/* !HAVE_CONFIG_H */
+#  include <inttypes.h>
+#endif				/*  HAVE_CONFIG_H */
 
-#if HAVE_STDINT_H
-#  include <stdint.h>           /* for uint16_t, uint32_t definitions */
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>         /* for uint16_t, uint32_t definitions */
-#endif
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <time.h>
 #include <unistd.h>
 
-#include "src/slurmd/slurmstepd/slurmstepd_job.h"
-#include "src/slurmctld/slurmctld.h"
-#include "src/sacct/sacct_stat.h"
+#include <slurm/slurm.h>
 
-/* common */
-extern int jobacct_init(void); /* load the plugin */
-extern int jobacct_g_init_struct(jobacctinfo_t *jobacct, 
-				 jobacct_id_t *jobacct_id);
-/* must free jobacctinfo_t if not NULL */
-extern jobacctinfo_t *jobacct_g_alloc(jobacct_id_t *jobacct_id);
-extern void jobacct_g_free(jobacctinfo_t *jobacct);
-extern int jobacct_g_setinfo(jobacctinfo_t *jobacct, 
-			     enum jobacct_data_type type, void *data);
-extern int jobacct_g_getinfo(jobacctinfo_t *jobacct, 
-			     enum jobacct_data_type type, void *data);
-extern void jobacct_g_aggregate(jobacctinfo_t *dest, jobacctinfo_t *from);
-extern void jobacct_g_2_sacct(sacct_t *sacct, jobacctinfo_t *jobacct);
-extern void jobacct_g_pack(jobacctinfo_t *jobacct, Buf buffer);
-extern int jobacct_g_unpack(jobacctinfo_t **jobacct, Buf buffer);
-
-/*functions used in slurmctld */
-extern int jobacct_g_init_slurmctld(char *job_acct_log);
-extern int jobacct_g_fini_slurmctld();
-extern int jobacct_g_job_start_slurmctld(struct job_record *job_ptr);
-extern int jobacct_g_job_complete_slurmctld(struct job_record *job_ptr); 
-extern int jobacct_g_step_start_slurmctld(struct step_record *step);
-extern int jobacct_g_step_complete_slurmctld(struct step_record *step);
-extern int jobacct_g_suspend_slurmctld(struct job_record *job_ptr);
-
-/*functions used in slurmstepd */
-extern int jobacct_g_startpoll(int frequency);
-extern int jobacct_g_endpoll();
-extern int jobacct_g_set_proctrack_container_id(uint32_t id);
-extern int jobacct_g_add_task(pid_t pid, jobacct_id_t *jobacct_id);
+#include "src/common/macros.h"
+#include "src/common/pack.h"
+#include "src/common/list.h"
+#include "src/common/xmalloc.h"
+#include "src/common/jobacct_common.h"
+
+extern int slurm_jobacct_gather_init(void); /* load the plugin */
+extern int slurm_jobacct_gather_fini(void); /* unload the plugin */
+
+extern jobacctinfo_t *jobacct_gather_g_create(jobacct_id_t *jobacct_id);
+extern void jobacct_gather_g_destroy(jobacctinfo_t *jobacct);
+extern int jobacct_gather_g_setinfo(jobacctinfo_t *jobacct, 
+				    enum jobacct_data_type type, void *data);
+extern int jobacct_gather_g_getinfo(jobacctinfo_t *jobacct, 
+				    enum jobacct_data_type type, void *data);
+extern void jobacct_gather_g_pack(jobacctinfo_t *jobacct, Buf buffer);
+extern int jobacct_gather_g_unpack(jobacctinfo_t **jobacct, Buf buffer);
+
+extern void jobacct_gather_g_aggregate(jobacctinfo_t *dest,
+				       jobacctinfo_t *from);
+
+extern void jobacct_gather_g_change_poll(uint16_t frequency);
+extern int  jobacct_gather_g_startpoll(uint16_t frequency);
+extern int  jobacct_gather_g_endpoll();
+extern void jobacct_gather_g_suspend_poll();
+extern void jobacct_gather_g_resume_poll();
+
+extern int jobacct_gather_g_set_proctrack_container_id(uint32_t id);
+extern int jobacct_gather_g_add_task(pid_t pid, jobacct_id_t *jobacct_id);
 /* must free jobacctinfo_t if not NULL */
-extern jobacctinfo_t *jobacct_g_stat_task(pid_t pid);
+extern jobacctinfo_t *jobacct_gather_g_stat_task(pid_t pid);
 /* must free jobacctinfo_t if not NULL */
-extern jobacctinfo_t *jobacct_g_remove_task(pid_t pid);
-extern void jobacct_g_suspend_poll();
-extern void jobacct_g_resume_poll();
-
-/* functions only to be used by the gold plugin in 1.2 since we had to
- * make some mods to get the plugin to work with node states also
- */
-extern int jobacct_g_node_down(struct node_record *node_ptr, time_t event_time,
-			       char *reason);
-extern int jobacct_g_node_up(struct node_record *node_ptr, time_t event_time);
-extern int jobacct_g_cluster_procs(uint32_t procs, time_t event_time);
+extern jobacctinfo_t *jobacct_gather_g_remove_task(pid_t pid);
 
+extern void jobacct_gather_g_2_sacct(sacct_t *sacct, jobacctinfo_t *jobacct);
 
 
-#endif /*__SLURM_JOBACCT_H__*/
+#endif /*__SLURM_JOBACCT_GATHER_H__*/
 
diff --git a/src/common/slurm_jobcomp.c b/src/common/slurm_jobcomp.c
index ce6ae16f40cda71a8eadd0125f9a1b72abb09440..3de84f64ccfb08d3c4f3c5a1c4a302d5cee1490d 100644
--- a/src/common/slurm_jobcomp.c
+++ b/src/common/slurm_jobcomp.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>, Morris Jette <jette1@llnl.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -65,6 +65,9 @@ typedef struct slurm_jobcomp_ops {
 	int          (*job_write) ( struct job_record *job_ptr);
 	int          (*sa_errno)  ( void );
 	char *       (*job_strerror)  ( int errnum );
+	List         (*get_jobs)  ( List selected_steps,
+				    List selected_parts, void *params );
+	void         (*archive)   ( List selected_parts, void *params );
 } slurm_jobcomp_ops_t;
 
 
@@ -146,7 +149,9 @@ _slurm_jobcomp_get_ops( slurm_jobcomp_context_t c )
 		"slurm_jobcomp_set_location",
 		"slurm_jobcomp_log_record",
 		"slurm_jobcomp_get_errno",
-		"slurm_jobcomp_strerror"
+		"slurm_jobcomp_strerror",
+		"slurm_jobcomp_get_jobs",
+		"slurm_jobcomp_archive"
 	};
         int n_syms = sizeof( syms ) / sizeof( char * );
 
@@ -188,6 +193,33 @@ _slurm_jobcomp_get_ops( slurm_jobcomp_context_t c )
         return &c->ops;
 }
 
+extern void 
+jobcomp_destroy_job(void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+	if (job) {
+		xfree(job->partition);
+		xfree(job->start_time);
+		xfree(job->end_time);
+		xfree(job->uid_name);
+		xfree(job->gid_name);
+		xfree(job->nodelist);
+		xfree(job->jobname);
+		xfree(job->state);
+		xfree(job->timelimit);
+#ifdef HAVE_BG
+		xfree(job->blockid);
+		xfree(job->connection);
+		xfree(job->reboot);
+		xfree(job->rotate);
+		xfree(job->geo);
+		xfree(job->bg_start_point);
+#endif
+		xfree(job);
+	}
+}
+
+
 extern int
 g_slurm_jobcomp_init( char *jobcomp_loc )
 {
@@ -281,3 +313,29 @@ g_slurm_jobcomp_strerror(int errnum)
 	slurm_mutex_unlock( &context_lock );
 	return retval;
 }
+
+extern List
+g_slurm_jobcomp_get_jobs(List selected_steps,
+			 List selected_parts, void *params)
+{
+	slurm_mutex_lock( &context_lock );
+	if ( g_context )
+		return (*(g_context->ops.get_jobs))
+			(selected_steps, selected_parts, params);
+	else
+		error ("slurm_jobcomp plugin context not initialized");
+	slurm_mutex_unlock( &context_lock );
+	return NULL ;
+}
+
+extern void
+g_slurm_jobcomp_archive(List selected_parts, void *params)
+{
+	slurm_mutex_lock( &context_lock );
+	if ( g_context )
+		(*(g_context->ops.archive))(selected_parts, params);
+	else
+		error ("slurm_jobcomp plugin context not initialized");
+	slurm_mutex_unlock( &context_lock );
+	return;
+}
diff --git a/src/common/slurm_jobcomp.h b/src/common/slurm_jobcomp.h
index 0397e46b000c6be24513974b57d32230e1ee37b7..b99b7b418fc8608522521fb8d7b1fa583c17d154 100644
--- a/src/common/slurm_jobcomp.h
+++ b/src/common/slurm_jobcomp.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.com> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -54,8 +54,35 @@
 
 #include "src/slurmctld/slurmctld.h"
 
+typedef struct {
+	uint32_t jobid;
+	char *partition;
+	char *start_time;
+	char *end_time;
+	uint32_t uid;
+	char *uid_name;
+	uint32_t gid;
+	char *gid_name;
+	uint32_t node_cnt;
+	char *nodelist;
+	char *jobname;
+	char *state;
+	char *timelimit;
+#ifdef HAVE_BG
+	char *blockid;
+	char *connection;
+	char *reboot;
+	char *rotate;
+	uint32_t max_procs;
+	char *geo;
+	char *bg_start_point;
+#endif
+} jobcomp_job_rec_t;
+
 typedef struct slurm_jobcomp_context * slurm_jobcomp_context_t;
 
+extern void jobcomp_destroy_job(void *object);
+
 /* initialization of job completion logging */
 extern int g_slurm_jobcomp_init(char *jobcomp_loc);
 
@@ -71,5 +98,19 @@ extern int g_slurm_jobcomp_errno(void);
 /* convert job completion logger specific error code to a string */
 extern char *g_slurm_jobcomp_strerror(int errnum);
 
+/* 
+ * get info from the storage 
+ * returns List of jobcomp_job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List g_slurm_jobcomp_get_jobs(List selected_steps,
+				     List selected_parts,
+				     void *params);
+
+/* 
+ * expire old info from the storage 
+ */
+extern void g_slurm_jobcomp_archive(List selected_parts, void *params);
+
 #endif /*__SLURM_JOBCOMP_H__*/
 
diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c
index d8d87d88cd3167e575df0c5987dcfc1ca8ee8ef9..dbf3e2c3b30235710f7eaaf0ffeaedcc4315021a 100644
--- a/src/common/slurm_protocol_api.c
+++ b/src/common/slurm_protocol_api.c
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  slurm_protocol_api.c - high-level slurm communication functions
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -69,6 +70,7 @@
 #include "src/common/xstring.h"
 #include "src/common/log.h"
 #include "src/common/forward.h"
+#include "src/slurmdbd/read_config.h"
 
 /* EXTERNAL VARIABLES */
 
@@ -85,7 +87,12 @@ static slurm_protocol_config_t *proto_conf = &proto_conf_default;
 static int message_timeout = -1;
 
 /* STATIC FUNCTIONS */
-static void _remap_slurmctld_errno(void);
+static char *_global_auth_key(void);
+static void  _remap_slurmctld_errno(void);
+static int   _unpack_msg_uid(Buf buffer);
+
+/* define the slurmdbd_options flag */
+slurm_dbd_conf_t *slurmdbd_conf = NULL;
 
 /**********************************************************************\
  * protocol configuration functions
@@ -182,17 +189,71 @@ void slurm_api_clear_config(void)
 /* 	slurm_mutex_lock(&config_lock); */
 /* } */
 
+/* slurm_get_def_mem_per_task
+ * RET DefMemPerTask value from slurm.conf
+ */
+uint32_t slurm_get_def_mem_per_task(void)
+{
+	uint32_t mem_per_task = 0;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		mem_per_task = conf->def_mem_per_task;
+		slurm_conf_unlock();
+	}
+	return mem_per_task;
+}
+
+/* slurm_get_max_mem_per_task
+ * RET MaxMemPerTask value from slurm.conf
+ */
+uint32_t slurm_get_max_mem_per_task(void)
+{
+	uint32_t mem_per_task = 0;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		mem_per_task = conf->max_mem_per_task;
+		slurm_conf_unlock();
+	}
+	return mem_per_task;
+}
+
+/* slurm_get_epilog_msg_time
+ * RET EpilogMsgTime value from slurm.conf
+ */
+uint32_t slurm_get_epilog_msg_time(void)
+{
+        uint32_t epilog_msg_time = 0;
+        slurm_ctl_conf_t *conf;
+
+ 	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		epilog_msg_time = conf->epilog_msg_time;
+		slurm_conf_unlock();
+	}
+        return epilog_msg_time;
+}
+
 /* slurm_get_env_timeout
  * return default timeout for srun/sbatch --get-user-env option
  */
 int inline slurm_get_env_timeout(void)
 {
-        int timeout;
+        int timeout = 0;
         slurm_ctl_conf_t *conf;
 
-        conf = slurm_conf_lock();
-        timeout = conf->get_env_timeout;
-        slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		timeout = conf->get_env_timeout;
+		slurm_conf_unlock();
+	}
         return timeout;
 }
 
@@ -202,12 +263,15 @@ int inline slurm_get_env_timeout(void)
  */
 char *slurm_get_mpi_default(void)
 {
-	char *mpi_default;
+	char *mpi_default = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	mpi_default = xstrdup(conf->mpi_default);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		mpi_default = xstrdup(conf->mpi_default);
+		slurm_conf_unlock();
+	}
 	return mpi_default;
 }
 
@@ -216,15 +280,19 @@ char *slurm_get_mpi_default(void)
  */
 uint16_t slurm_get_msg_timeout(void)
 {
-        uint16_t msg_timeout;
+        uint16_t msg_timeout = 0;
         slurm_ctl_conf_t *conf;
 
-        conf = slurm_conf_lock();
-        msg_timeout = conf->msg_timeout;
-        slurm_conf_unlock();
+ 	if(slurmdbd_conf) {
+		msg_timeout = slurmdbd_conf->msg_timeout;
+	} else {
+		conf = slurm_conf_lock();
+		msg_timeout = conf->msg_timeout;
+		slurm_conf_unlock();
 #ifdef MEMORY_LEAK_DEBUG
-        msg_timeout *= 4;
+		msg_timeout *= 4;
 #endif
+	}
         return msg_timeout;
 }
 
@@ -234,12 +302,16 @@ uint16_t slurm_get_msg_timeout(void)
  */
 char *slurm_get_plugin_dir(void)
 {
-	char *plugin_dir;
+	char *plugin_dir = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	plugin_dir = xstrdup(conf->plugindir);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+		plugin_dir = xstrdup(slurmdbd_conf->plugindir);
+	} else {
+		conf = slurm_conf_lock();
+		plugin_dir = xstrdup(conf->plugindir);
+		slurm_conf_unlock();
+	}
 	return plugin_dir;
 }
 
@@ -249,12 +321,15 @@ char *slurm_get_plugin_dir(void)
  */
 char *slurm_get_state_save_location(void)
 {
-	char *state_save_loc;
+	char *state_save_loc = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	state_save_loc = xstrdup(conf->state_save_location);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		state_save_loc = xstrdup(conf->state_save_location);
+		slurm_conf_unlock();
+	}
 	return state_save_loc;
 }
 
@@ -264,26 +339,87 @@ char *slurm_get_state_save_location(void)
  */
 char *slurm_get_auth_type(void)
 {
-	char *auth_type;
-	slurm_ctl_conf_t *conf;
+	char *auth_type = NULL;
+	slurm_ctl_conf_t *conf = NULL;
 
-	conf = slurm_conf_lock();
-	auth_type = xstrdup(conf->authtype);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+		auth_type = xstrdup(slurmdbd_conf->auth_type);
+	} else {
+		conf = slurm_conf_lock();
+		auth_type = xstrdup(conf->authtype);
+		slurm_conf_unlock();
+	}
 	return auth_type;
 }
 
+/* slurm_get_checkpoint_type
+ * returns the checkpoint_type from slurmctld_conf object
+ * RET char *    - checkpoint type, MUST be xfreed by caller
+ */
+extern char *slurm_get_checkpoint_type(void)
+{
+	char *checkpoint_type = NULL;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		checkpoint_type = xstrdup(conf->checkpoint_type);
+		slurm_conf_unlock();
+	}
+	return checkpoint_type;
+}
+
+/* slurm_get_cluster_name
+ * returns the cluster name from slurmctld_conf object
+ * RET char *    - cluster name,  MUST be xfreed by caller
+ */
+char *slurm_get_cluster_name(void)
+{
+	char *name = NULL;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		name = xstrdup(conf->cluster_name);
+		slurm_conf_unlock();
+	}
+	return name;	
+}
+
+/* slurm_get_crypto_type
+ * returns the crypto_type from slurmctld_conf object
+ * RET char *    - crypto type, MUST be xfreed by caller
+ */
+extern char *slurm_get_crypto_type(void)
+{
+	char *crypto_type = NULL;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		crypto_type = xstrdup(conf->crypto_type);
+		slurm_conf_unlock();
+	}
+	return crypto_type;
+}
+
 /* slurm_get_propagate_prio_process
  * return the PropagatePrioProcess flag from slurmctld_conf object
  */
 extern uint16_t slurm_get_propagate_prio_process(void)
 {
-        uint16_t propagate_prio;
+        uint16_t propagate_prio = 0;
         slurm_ctl_conf_t *conf;
 
-        conf = slurm_conf_lock();
-        propagate_prio = conf->propagate_prio_process;
-        slurm_conf_unlock();
+ 	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		propagate_prio = conf->propagate_prio_process;
+		slurm_conf_unlock();
+	}
         return propagate_prio;
 }
 
@@ -292,12 +428,15 @@ extern uint16_t slurm_get_propagate_prio_process(void)
  */
 extern uint16_t slurm_get_fast_schedule(void)
 {
-	uint16_t fast_val;
+	uint16_t fast_val = 0;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	fast_val = conf->fast_schedule;
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		fast_val = conf->fast_schedule;
+		slurm_conf_unlock();
+	}
 	return fast_val;
 }
 
@@ -309,26 +448,32 @@ extern int slurm_set_tree_width(uint16_t tree_width)
 {
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	if (tree_width == 0) {
-		error("can't have span count of 0");
-		return SLURM_ERROR;
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		if (tree_width == 0) {
+			error("can't have span count of 0");
+			return SLURM_ERROR;
+		}
+		conf->tree_width = tree_width;
+		slurm_conf_unlock();
 	}
-	conf->tree_width = tree_width;
-	slurm_conf_unlock();
-	return SLURM_SUCCESS;
+	return 0;
 }
 /* slurm_get_tree_width
  * returns the value of tree_width in slurmctld_conf object
  */
 extern uint16_t slurm_get_tree_width(void)
 {
-	uint16_t tree_width;
+	uint16_t tree_width = 0;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	tree_width = conf->tree_width;
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		tree_width = conf->tree_width;
+		slurm_conf_unlock();
+	}
 	return tree_width;
 }
 
@@ -341,85 +486,369 @@ extern int slurm_set_auth_type(char *auth_type)
 {
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	xfree(conf->authtype);
-	conf->authtype = xstrdup(auth_type);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+		xfree(slurmdbd_conf->auth_type);
+		slurmdbd_conf->auth_type = xstrdup(auth_type);		
+	} else {
+		conf = slurm_conf_lock();
+		xfree(conf->authtype);
+		conf->authtype = xstrdup(auth_type);
+		slurm_conf_unlock();
+	}
 	return 0;
 }
 
-/* slurm_get_jobacct_loc
- * returns the job accounting loc from the slurmctld_conf object
- * RET char *    - job accounting loc,  MUST be xfreed by caller
+/* slurm_get_health_check_program
+ * get health_check_program from slurmctld_conf object from slurmctld_conf object
+ * RET char *   - health_check_program, MUST be xfreed by caller
  */
-char *slurm_get_jobacct_loc(void)
+char *slurm_get_health_check_program(void)
 {
-	char *jobacct_logfile;
+	char *health_check_program = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	jobacct_logfile = xstrdup(conf->job_acct_logfile);
-	slurm_conf_unlock();
-	return jobacct_logfile;
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		health_check_program = xstrdup(conf->health_check_program);
+		slurm_conf_unlock();
+	}
+	return health_check_program;
 }
 
-/* slurm_get_jobacct_freq
- * returns the job accounting poll frequency from the slurmctld_conf object
- * RET int    - job accounting frequency
+/* slurm_get_accounting_storage_type
+ * returns the accounting storage type from slurmctld_conf object
+ * RET char *    - accounting storage type,  MUST be xfreed by caller
  */
-uint16_t slurm_get_jobacct_freq(void)
+char *slurm_get_accounting_storage_type(void)
 {
-	uint16_t freq;
+	char *accounting_type;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	freq = conf->job_acct_freq;
-	slurm_conf_unlock();
-	return freq;
+	if(slurmdbd_conf) {
+		accounting_type = xstrdup(slurmdbd_conf->storage_type);
+	} else {
+		conf = slurm_conf_lock();
+		accounting_type = xstrdup(conf->accounting_storage_type);
+		slurm_conf_unlock();
+	}
+	return accounting_type;
+	
 }
 
-/* slurm_get_jobacct_type
+/* slurm_get_accounting_storage_user
+ * returns the storage user from slurmctld_conf object
+ * RET char *    - storage user,  MUST be xfreed by caller
+ */
+char *slurm_get_accounting_storage_user(void)
+{
+	char *storage_user;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+		storage_user = xstrdup(slurmdbd_conf->storage_user);
+	} else {
+		conf = slurm_conf_lock();
+		storage_user = xstrdup(conf->accounting_storage_user);
+		slurm_conf_unlock();
+	}
+	return storage_user;	
+}
+
+/* slurm_get_accounting_storage_host
+ * returns the storage host from slurmctld_conf object
+ * RET char *    - storage host,  MUST be xfreed by caller
+ */
+char *slurm_get_accounting_storage_host(void)
+{
+	char *storage_host;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+		storage_host = xstrdup(slurmdbd_conf->storage_host);
+	} else {
+		conf = slurm_conf_lock();
+		storage_host = xstrdup(conf->accounting_storage_host);
+		slurm_conf_unlock();
+	}
+	return storage_host;	
+}
+
+/* slurm_get_accounting_storage_loc
+ * returns the storage location from slurmctld_conf object
+ * RET char *    - storage location,  MUST be xfreed by caller
+ */
+char *slurm_get_accounting_storage_loc(void)
+{
+	char *storage_loc;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+		storage_loc = xstrdup(slurmdbd_conf->storage_loc);
+	} else {
+		conf = slurm_conf_lock();
+		storage_loc = xstrdup(conf->accounting_storage_loc);
+		slurm_conf_unlock();
+	}
+	return storage_loc;	
+}
+
+/* slurm_set_accounting_storage_loc
+ * IN: char *loc (name of file or database)
+ * RET 0 or error code
+ */
+int slurm_set_accounting_storage_loc(char *loc)
+{
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+		xfree(slurmdbd_conf->storage_loc);
+		slurmdbd_conf->storage_loc = xstrdup(loc);
+	} else {
+		conf = slurm_conf_lock();
+		xfree(conf->accounting_storage_loc);
+		conf->accounting_storage_loc = xstrdup(loc);
+		slurm_conf_unlock();
+	}
+	return 0;	
+}
+
+/* slurm_get_accounting_storage_pass
+ * returns the storage password from slurmctld_conf object
+ * RET char *    - storage password,  MUST be xfreed by caller
+ */
+char *slurm_get_accounting_storage_pass(void)
+{
+	char *storage_pass;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+		storage_pass = xstrdup(slurmdbd_conf->storage_pass);
+	} else {
+		conf = slurm_conf_lock();
+		storage_pass = xstrdup(conf->accounting_storage_pass);
+		slurm_conf_unlock();
+	}
+	return storage_pass;
+}
+
+/* _global_auth_key
+ * returns the storage password from slurmctld_conf or slurmdbd_conf object
+ * cache value in local buffer for best performance
+ * RET char *    - storage password
+ */
+static char *_global_auth_key(void)
+{
+	static bool loaded_storage_pass = false;
+	static char storage_pass[512] = "\0";
+	slurm_ctl_conf_t *conf;
+
+	if(loaded_storage_pass)
+		return storage_pass;
+
+	if(slurmdbd_conf) {
+		if(slurmdbd_conf->storage_pass) {
+			if(strlen(slurmdbd_conf->storage_pass) > 
+			   sizeof(storage_pass))
+				fatal("StoragePass is too long");
+			strncpy(storage_pass, slurmdbd_conf->storage_pass, 
+				sizeof(storage_pass));
+		}
+	} else {
+		conf = slurm_conf_lock();
+		if(conf->accounting_storage_pass) {
+			if(strlen(conf->accounting_storage_pass) > 
+			   sizeof(storage_pass))
+				fatal("AccountingStoragePass is too long");
+			strncpy(storage_pass, conf->accounting_storage_pass, 
+				sizeof(storage_pass));
+		}
+		slurm_conf_unlock();
+	}
+	loaded_storage_pass = true;
+	return storage_pass;
+}
+
+/* slurm_get_accounting_storage_port
+ * returns the storage port from slurmctld_conf object
+ * RET uint32_t   - storage port
+ */
+uint32_t slurm_get_accounting_storage_port(void)
+{
+	uint32_t storage_port;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+		storage_port = slurmdbd_conf->storage_port;
+	} else {
+		conf = slurm_conf_lock();
+		storage_port = conf->accounting_storage_port;
+		slurm_conf_unlock();
+	}
+	return storage_port;
+	
+}
+
+/* slurm_get_jobacct_gather_type
  * returns the job accounting type from the slurmctld_conf object
  * RET char *    - job accounting type,  MUST be xfreed by caller
  */
-char *slurm_get_jobacct_type(void)
+char *slurm_get_jobacct_gather_type(void)
 {
-	char *jobacct_type;
+	char *jobacct_type = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	jobacct_type = xstrdup(conf->job_acct_type);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		jobacct_type = xstrdup(conf->job_acct_gather_type);
+		slurm_conf_unlock();
+	}
 	return jobacct_type;
 }
 
+/* slurm_get_jobacct_freq
+ * returns the job accounting poll frequency from the slurmctld_conf object
+ * RET int    - job accounting frequency
+ */
+uint16_t slurm_get_jobacct_gather_freq(void)
+{
+	uint16_t freq = 0;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		freq = conf->job_acct_gather_freq;
+		slurm_conf_unlock();
+	}
+	return freq;
+}
+
 /* slurm_get_jobcomp_type
  * returns the job completion logger type from slurmctld_conf object
  * RET char *    - job completion type,  MUST be xfreed by caller
  */
 char *slurm_get_jobcomp_type(void)
 {
-	char *jobcomp_type;
+	char *jobcomp_type = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	jobcomp_type = xstrdup(conf->job_comp_type);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		jobcomp_type = xstrdup(conf->job_comp_type);
+		slurm_conf_unlock();
+	}
 	return jobcomp_type;
 }
 
+/* slurm_get_jobcomp_loc
+ * returns the job completion loc from slurmctld_conf object
+ * RET char *    - job completion location,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_loc(void)
+{
+	char *jobcomp_loc = 0;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		jobcomp_loc = xstrdup(conf->job_comp_loc);
+		slurm_conf_unlock();
+	}
+	return jobcomp_loc;	
+}
+
+/* slurm_get_jobcomp_user
+ * returns the storage user from slurmctld_conf object
+ * RET char *    - storage user,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_user(void)
+{
+	char *storage_user = NULL;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		storage_user = xstrdup(conf->job_comp_user);
+		slurm_conf_unlock();
+	}
+	return storage_user;	
+}
+
+/* slurm_get_jobcomp_host
+ * returns the storage host from slurmctld_conf object
+ * RET char *    - storage host,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_host(void)
+{
+	char *storage_host = NULL;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		storage_host = xstrdup(conf->job_comp_host);
+		slurm_conf_unlock();
+	}
+	return storage_host;	
+}
+
+/* slurm_get_jobcomp_pass
+ * returns the storage password from slurmctld_conf object
+ * RET char *    - storage password,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_pass(void)
+{
+	char *storage_pass = NULL;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		storage_pass = xstrdup(conf->job_comp_pass);
+		slurm_conf_unlock();
+	}
+	return storage_pass;	
+}
+
+/* slurm_get_jobcomp_port
+ * returns the storage port from slurmctld_conf object
+ * RET uint32_t   - storage port
+ */
+uint32_t slurm_get_jobcomp_port(void)
+{
+	uint32_t storage_port = 0;
+	slurm_ctl_conf_t *conf;
+
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		storage_port = conf->job_comp_port;
+		slurm_conf_unlock();
+	}
+	return storage_port;
+	
+}
+
 /* slurm_get_proctrack_type
  * get ProctrackType from slurmctld_conf object
  * RET char *   - proctrack type, MUST be xfreed by caller
  */
 char *slurm_get_proctrack_type(void)
 {
-	char *proctrack_type;
+	char *proctrack_type = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	proctrack_type = xstrdup(conf->proctrack_type);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		proctrack_type = xstrdup(conf->proctrack_type);
+		slurm_conf_unlock();
+	}
 	return proctrack_type;
 }
 
@@ -429,12 +858,15 @@ char *slurm_get_proctrack_type(void)
  */
 uint16_t slurm_get_slurmd_port(void)
 {
-	uint16_t slurmd_port;
+	uint16_t slurmd_port = 0;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	slurmd_port = conf->slurmd_port;
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		slurmd_port = conf->slurmd_port;
+		slurm_conf_unlock();
+	}
 	return slurmd_port;
 }
 
@@ -444,12 +876,16 @@ uint16_t slurm_get_slurmd_port(void)
  */
 uint32_t slurm_get_slurm_user_id(void)
 {
-	uint32_t slurm_uid;
+	uint32_t slurm_uid = 0;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	slurm_uid = conf->slurm_user_id;
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+		slurm_uid = slurmdbd_conf->slurm_user_id;
+	} else {
+		conf = slurm_conf_lock();
+		slurm_uid = conf->slurm_user_id;
+		slurm_conf_unlock();
+	}
 	return slurm_uid;
 }
 
@@ -457,24 +893,30 @@ uint32_t slurm_get_slurm_user_id(void)
  * RET uint16_t  - Value of SchedulerRootFilter */
 extern uint16_t slurm_get_root_filter(void)
 {
-        uint16_t root_filter;
+        uint16_t root_filter = 0;
         slurm_ctl_conf_t *conf;
  
-        conf = slurm_conf_lock();
-        root_filter = conf->schedrootfltr;
-        slurm_conf_unlock();
+ 	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		root_filter = conf->schedrootfltr;
+		slurm_conf_unlock();
+	}
         return root_filter;
 }
 /* slurm_get_sched_port
  * RET uint16_t  - Value of SchedulerPort */
 extern uint16_t slurm_get_sched_port(void)
 {
-        uint16_t port;
+        uint16_t port = 0;
         slurm_ctl_conf_t *conf;
 
-        conf = slurm_conf_lock();
-        port = conf->schedport;
-        slurm_conf_unlock();
+ 	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		port = conf->schedport;
+		slurm_conf_unlock();
+	}
         return port;
 }
 
@@ -484,12 +926,15 @@ extern uint16_t slurm_get_sched_port(void)
  */
 char *slurm_get_sched_type(void)
 {
-	char *sched_type;
+	char *sched_type = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	sched_type = xstrdup(conf->schedtype);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		sched_type = xstrdup(conf->schedtype);
+		slurm_conf_unlock();
+	}
 	return sched_type;
 }
 
@@ -499,12 +944,15 @@ char *slurm_get_sched_type(void)
  */
 char *slurm_get_select_type(void)
 {
-	char *select_type;
+	char *select_type = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	select_type = xstrdup(conf->select_type);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		select_type = xstrdup(conf->select_type);
+		slurm_conf_unlock();
+	}
 	return select_type;
 }
 
@@ -514,7 +962,7 @@ char *slurm_get_select_type(void)
  */
 char *slurm_get_switch_type(void)
 {
-	char *switch_type;
+	char *switch_type = NULL;
 	slurm_ctl_conf_t *conf;
 
 	conf = slurm_conf_lock();
@@ -529,12 +977,15 @@ char *slurm_get_switch_type(void)
  */
 uint16_t slurm_get_wait_time(void)
 {
-	uint16_t wait_time;
+	uint16_t wait_time = 0;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	wait_time = conf->wait_time;
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		wait_time = conf->wait_time;
+		slurm_conf_unlock();
+	}
 	return wait_time;
 }
 
@@ -544,12 +995,15 @@ uint16_t slurm_get_wait_time(void)
  */
 char *slurm_get_srun_prolog(void)
 {
-	char *prolog;
+	char *prolog = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	prolog = xstrdup(conf->srun_prolog);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		prolog = xstrdup(conf->srun_prolog);
+		slurm_conf_unlock();
+	}
 	return prolog;
 }
 
@@ -559,12 +1013,15 @@ char *slurm_get_srun_prolog(void)
  */
 char *slurm_get_srun_epilog(void)
 {
-	char *epilog;
+	char *epilog = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-	epilog = xstrdup(conf->srun_epilog);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		epilog = xstrdup(conf->srun_epilog);
+		slurm_conf_unlock();
+	}
 	return epilog;
 }
 
@@ -572,12 +1029,15 @@ char *slurm_get_srun_epilog(void)
  * RET task_epilog name, must be xfreed by caller */
 char *slurm_get_task_epilog(void)
 {
-        char *task_epilog;
+        char *task_epilog = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-        task_epilog = xstrdup(conf->task_epilog);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		task_epilog = xstrdup(conf->task_epilog);
+		slurm_conf_unlock();
+	}
         return task_epilog;
 }
 
@@ -585,12 +1045,15 @@ char *slurm_get_task_epilog(void)
  * RET task_prolog name, must be xfreed by caller */
 char *slurm_get_task_prolog(void)
 {
-        char *task_prolog;
+        char *task_prolog = NULL;
 	slurm_ctl_conf_t *conf;
 
-	conf = slurm_conf_lock();
-        task_prolog = xstrdup(conf->task_prolog);
-	slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		task_prolog = xstrdup(conf->task_prolog);
+		slurm_conf_unlock();
+	}
         return task_prolog;
 }
 
@@ -598,7 +1061,7 @@ char *slurm_get_task_prolog(void)
  * RET task_plugin name, must be xfreed by caller */
 char *slurm_get_task_plugin(void)
 {
-        char *task_plugin;
+        char *task_plugin = NULL;
 	slurm_ctl_conf_t *conf;
 
 	conf = slurm_conf_lock();
@@ -610,12 +1073,15 @@ char *slurm_get_task_plugin(void)
 /* slurm_get_task_plugin_param */
 uint16_t slurm_get_task_plugin_param(void)
 {
-        uint16_t task_plugin_param;
+        uint16_t task_plugin_param = 0;
         slurm_ctl_conf_t *conf;
 
-        conf = slurm_conf_lock();
-        task_plugin_param = conf->task_plugin_param;
-        slurm_conf_unlock();
+	if(slurmdbd_conf) {
+	} else {
+		conf = slurm_conf_lock();
+		task_plugin_param = conf->task_plugin_param;
+		slurm_conf_unlock();
+	}
         return task_plugin_param;
 }
 
@@ -756,12 +1222,19 @@ slurm_fd slurm_open_controller_conn_spec(enum controller_id dest)
 		debug3("Error: Unable to set default config");
 		return SLURM_ERROR;
 	}
-		
-	addr = (dest == PRIMARY_CONTROLLER) ? 
-		  &proto_conf->primary_controller : 
-		  &proto_conf->secondary_controller;
 
-	if (!addr) return SLURM_ERROR;
+	if (dest == PRIMARY_CONTROLLER)
+		addr = &proto_conf->primary_controller;
+	else {	/* (dest == SECONDARY_CONTROLLER) */
+		slurm_ctl_conf_t *conf;
+		addr = NULL;
+		conf = slurm_conf_lock();
+		if (conf->backup_addr)
+			addr = &proto_conf->secondary_controller;
+		slurm_conf_unlock();
+		if (!addr)
+			return SLURM_ERROR;
+	}
 
 	rc = slurm_open_msg_conn(addr);
 	if (rc == -1)
@@ -864,6 +1337,9 @@ int slurm_receive_msg(slurm_fd fd, slurm_msg_t *msg, int timeout)
 	}
 	
 	if (check_header_version(&header) < 0) {
+		int uid = _unpack_msg_uid(buffer);
+		error("Invalid Protocol Version %u from uid=%d", 
+			header.version, uid);
 		free_buf(buffer);
 		rc = SLURM_PROTOCOL_VERSION_ERROR;
 		goto total_return;
@@ -891,7 +1367,11 @@ int slurm_receive_msg(slurm_fd fd, slurm_msg_t *msg, int timeout)
 		rc = ESLURM_PROTOCOL_INCOMPLETE_PACKET;
 		goto total_return;
 	}
-	rc = g_slurm_auth_verify( auth_cred, NULL, 2 );
+	if(header.flags & SLURM_GLOBAL_AUTH_KEY) {
+		rc = g_slurm_auth_verify( auth_cred, NULL, 2, 
+					  _global_auth_key() );
+	} else
+		rc = g_slurm_auth_verify( auth_cred, NULL, 2, NULL );
 	
 	if (rc != SLURM_SUCCESS) {
 		error( "authentication: %s ",
@@ -906,6 +1386,7 @@ int slurm_receive_msg(slurm_fd fd, slurm_msg_t *msg, int timeout)
 	 * Unpack message body 
 	 */
 	msg->msg_type = header.msg_type;
+	msg->flags = header.flags;
 	
 	if ( (header.body_length > remaining_buf(buffer)) ||
 	     (unpack_msg(msg, buffer) != SLURM_SUCCESS) ) {
@@ -1014,6 +1495,9 @@ List slurm_receive_msgs(slurm_fd fd, int steps, int timeout)
 	}
 	
 	if(check_header_version(&header) < 0) {
+		int uid = _unpack_msg_uid(buffer);
+		error("Invalid Protocol Version %u from uid=%d",
+			header.version, uid);
 		free_buf(buffer);
 		rc = SLURM_PROTOCOL_VERSION_ERROR;
 		goto total_return;
@@ -1041,7 +1525,11 @@ List slurm_receive_msgs(slurm_fd fd, int steps, int timeout)
 		rc = ESLURM_PROTOCOL_INCOMPLETE_PACKET;
 		goto total_return;
 	}
-	rc = g_slurm_auth_verify( auth_cred, NULL, 2 );
+	if(header.flags & SLURM_GLOBAL_AUTH_KEY) {
+		rc = g_slurm_auth_verify( auth_cred, NULL, 2, 
+					  _global_auth_key() );
+	} else
+		rc = g_slurm_auth_verify( auth_cred, NULL, 2, NULL );
 	
 	if(rc != SLURM_SUCCESS) {
 		error("authentication: %s ",
@@ -1056,6 +1544,7 @@ List slurm_receive_msgs(slurm_fd fd, int steps, int timeout)
 	 * Unpack message body 
 	 */
 	msg.msg_type = header.msg_type;
+	msg.flags = header.flags;
 	
 	if((header.body_length > remaining_buf(buffer)) ||
 	   (unpack_msg(&msg, buffer) != SLURM_SUCCESS)) {
@@ -1098,6 +1587,21 @@ total_return:
 		
 }
 
+/* try to determine the UID associated with a message with different 
+ * message header version, return -1 if we can't tell */
+static int _unpack_msg_uid(Buf buffer)
+{
+	int uid = -1;
+	void *auth_cred = NULL;
+
+	if ((auth_cred = g_slurm_auth_unpack(buffer)) == NULL)
+		return uid;
+	uid = (int) g_slurm_auth_get_uid(auth_cred, NULL);
+	g_slurm_auth_destroy(auth_cred);
+
+	return uid;
+}
+
 /*
  * NOTE: memory is allocated for the returned msg and the returned list
  *       both must be freed at some point using the slurm_free_functions 
@@ -1174,6 +1678,9 @@ int slurm_receive_msg_and_forward(slurm_fd fd, slurm_addr *orig_addr,
 	}
 	
 	if (check_header_version(&header) < 0) {
+		int uid = _unpack_msg_uid(buffer);
+		error("Invalid Protocol Version %u from uid=%d", 
+			header.version, uid);
 		free_buf(buffer);
 		rc = SLURM_PROTOCOL_VERSION_ERROR;
 		goto total_return;
@@ -1238,7 +1745,11 @@ int slurm_receive_msg_and_forward(slurm_fd fd, slurm_addr *orig_addr,
 		rc = ESLURM_PROTOCOL_INCOMPLETE_PACKET;
 		goto total_return;
 	}
-	rc = g_slurm_auth_verify( auth_cred, NULL, 2 );
+	if(header.flags & SLURM_GLOBAL_AUTH_KEY) {
+		rc = g_slurm_auth_verify( auth_cred, NULL, 2, 
+					  _global_auth_key() );
+	} else
+		rc = g_slurm_auth_verify( auth_cred, NULL, 2, NULL );
 	
 	if (rc != SLURM_SUCCESS) {
 		error( "authentication: %s ",
@@ -1253,6 +1764,7 @@ int slurm_receive_msg_and_forward(slurm_fd fd, slurm_addr *orig_addr,
 	 * Unpack message body 
 	 */
 	msg->msg_type = header.msg_type;
+	msg->flags = header.flags;
 	
 	if ( (header.body_length > remaining_buf(buffer)) ||
 	     (unpack_msg(msg, buffer) != SLURM_SUCCESS) ) {
@@ -1321,11 +1833,16 @@ int slurm_send_node_msg(slurm_fd fd, slurm_msg_t * msg)
 	Buf      buffer;
 	int      rc;
 	void *   auth_cred;
+	uint16_t auth_flags = SLURM_PROTOCOL_NO_FLAGS;
 	
 	/* 
 	 * Initialize header with Auth credential and message type.
 	 */
-	auth_cred = g_slurm_auth_create(NULL, 2);
+	if (msg->flags & SLURM_GLOBAL_AUTH_KEY) {
+		auth_flags = SLURM_GLOBAL_AUTH_KEY;
+		auth_cred = g_slurm_auth_create(NULL, 2, _global_auth_key());
+	} else
+		auth_cred = g_slurm_auth_create(NULL, 2, NULL);
 	if (auth_cred == NULL) {
 		error("authentication: %s",
 		       g_slurm_auth_errstr(g_slurm_auth_errno(NULL)) );
@@ -1338,7 +1855,7 @@ int slurm_send_node_msg(slurm_fd fd, slurm_msg_t * msg)
 	}
 	forward_wait(msg);
 	
-	init_header(&header, msg, SLURM_PROTOCOL_NO_FLAGS);
+	init_header(&header, msg, msg->flags);
 	
 	/*
 	 * Pack header into buffer for transmission
@@ -1660,11 +2177,11 @@ int slurm_unpack_slurm_addr_no_alloc(slurm_addr * slurm_address,
  * returns		- SLURM error code
  */
 void slurm_pack_slurm_addr_array(slurm_addr * slurm_address,
-				 uint16_t size_val, Buf buffer)
+				 uint32_t size_val, Buf buffer)
 {
 	int i = 0;
-	uint16_t nl = htons(size_val);
-	pack16((uint16_t)nl, buffer);
+	uint32_t nl = htonl(size_val);
+	pack32(nl, buffer);
 	
 	for (i = 0; i < size_val; i++) {
 		slurm_pack_slurm_addr(slurm_address + i, buffer);
@@ -1680,14 +2197,14 @@ void slurm_pack_slurm_addr_array(slurm_addr * slurm_address,
  * returns		- SLURM error code
  */
 int slurm_unpack_slurm_addr_array(slurm_addr ** slurm_address,
-			    uint16_t * size_val, Buf buffer)
+			    uint32_t * size_val, Buf buffer)
 {
 	int i = 0;
-	uint16_t nl;
+	uint32_t nl;
 
 	*slurm_address = NULL;
-	safe_unpack16(&nl, buffer);
-	*size_val = ntohs(nl);
+	safe_unpack32(&nl, buffer);
+	*size_val = ntohl(nl);
 	*slurm_address = xmalloc((*size_val) * sizeof(slurm_addr));
 
 	for (i = 0; i < *size_val; i++) {
@@ -1728,6 +2245,7 @@ int slurm_send_rc_msg(slurm_msg_t *msg, int rc)
 	}
 	rc_msg.return_code = rc;
 
+	slurm_msg_t_init(&resp_msg);
 	resp_msg.address  = msg->address;
 	resp_msg.msg_type = RESPONSE_SLURM_RC;
 	resp_msg.data     = &rc_msg;
diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h
index 10c19e124a8906530dddc99c7861f8a2d560673c..8c2fbabefe3d476aff70c5a08f42087de5461515 100644
--- a/src/common/slurm_protocol_api.h
+++ b/src/common/slurm_protocol_api.h
@@ -3,9 +3,10 @@
  *	definitions
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -96,6 +97,21 @@ int inline slurm_set_api_config(slurm_protocol_config_t * protocol_conf);
  */
 inline slurm_protocol_config_t *slurm_get_api_config();
 
+/* slurm_get_def_mem_per_task
+ * RET DefMemPerTask value from slurm.conf
+ */
+uint32_t slurm_get_def_mem_per_task(void);
+
+/* slurm_get_max_mem_per_task
+ * RET MaxMemPerTask value from slurm.conf
+ */
+uint32_t slurm_get_max_mem_per_task(void);
+
+/* slurm_get_epilog_msg_time
+ * RET EpilogMsgTime value from slurm.conf
+ */
+uint32_t slurm_get_epilog_msg_time(void);
+
 /* slurm_get_env_timeout
  * return default timeout for srun/sbatch --get-user-env option
  */
@@ -129,6 +145,24 @@ int inline slurm_api_set_default_config();
  * execute this only at program termination to free all memory */
 void inline slurm_api_clear_config(void);
 
+/* slurm_get_health_check_program
+ * get health_check_program from slurmctld_conf object from slurmctld_conf object
+ * RET char *   - health_check_program, MUST be xfreed by caller
+ */
+char *slurm_get_health_check_program(void);
+
+/* slurm_get_slurmdbd_addr
+ * get slurm_dbd_addr from slurmctld_conf object from slurmctld_conf object
+ * RET char *   - slurmdbd_addr, MUST be xfreed by caller
+ */
+char *slurm_get_slurmdbd_addr(void);
+
+/* slurm_get_slurmdbd_port
+ * get slurm_dbd_port from slurmctld_conf object from slurmctld_conf object
+ * RET uint16_t   - dbd_port
+ */
+uint16_t slurm_get_slurmdbd_port(void);
+
 /* slurm_get_plugin_dir
  * get plugin directory from slurmctld_conf object from slurmctld_conf object 
  * RET char *   - plugin directory, MUST be xfreed by caller
@@ -154,6 +188,24 @@ extern char *slurm_get_auth_type(void);
  */
 extern int slurm_set_auth_type(char *auth_type);
 
+/* slurm_get_checkpoint_type
+ * returns the checkpoint_type from slurmctld_conf object
+ * RET char *    - checkpoint type, MUST be xfreed by caller
+ */
+extern char *slurm_get_checkpoint_type(void);
+
+/* slurm_get_cluster_name
+ * returns the cluster name from slurmctld_conf object
+ * RET char *    - cluster name,  MUST be xfreed by caller
+ */
+char *slurm_get_cluster_name(void);
+
+/* slurm_get_crypto_type
+ * returns the crypto_type from slurmctld_conf object
+ * RET char *    - crypto type, MUST be xfreed by caller
+ */
+extern char *slurm_get_crypto_type(void);
+
 /* slurm_get_fast_schedule
  * returns the value of fast_schedule in slurmctld_conf object
  */
@@ -169,23 +221,59 @@ extern int slurm_set_tree_width(uint16_t tree_width);
  */
 extern uint16_t slurm_get_tree_width(void);
 
-/* slurm_get_jobacct_loc
- * returns the job accounting loc from slurmctld_conf object
- * RET char *    - job accounting location,  MUST be xfreed by caller
+/* slurm_get_accounting_storage_type
+ * returns the accounting storage type from slurmctld_conf object
+ * RET char *    - accounting storage type,  MUST be xfreed by caller
  */
-char *slurm_get_jobacct_loc(void);
+char *slurm_get_accounting_storage_type(void);
 
-/* slurm_get_jobacct_freq
- * returns the job accounting poll frequency from the slurmctld_conf object
- * RET int    - job accounting frequency
+/* slurm_get_accounting_storage_user
+ * returns the storage user from slurmctld_conf object
+ * RET char *    - storage user,  MUST be xfreed by caller
  */
-uint16_t slurm_get_jobacct_freq(void);
+char *slurm_get_accounting_storage_user(void);
 
-/* slurm_get_jobacct_type
+/* slurm_get_accounting_storage_host
+ * returns the storage host from slurmctld_conf object
+ * RET char *    - storage host,  MUST be xfreed by caller
+ */
+char *slurm_get_accounting_storage_host(void);
+
+/* slurm_get_accounting_storage_pass
+ * returns the storage password from slurmctld_conf object
+ * RET char *    - storage location,  MUST be xfreed by caller
+ */
+char *slurm_get_accounting_storage_loc(void);
+
+/* slurm_set_accounting_storage_loc
+ * IN: char *loc (name of file or database)
+ * RET 0 or error code
+ */
+int slurm_set_accounting_storage_loc(char *loc);
+
+/* slurm_get_accounting_storage_pass
+ * returns the storage password from slurmctld_conf object
+ * RET char *    - storage password,  MUST be xfreed by caller
+ */
+char *slurm_get_accounting_storage_pass(void);
+
+/* slurm_get_accounting_storage_port
+ * returns the storage port from slurmctld_conf object
+ * RET uint32_t   - storage port
+ */
+uint32_t slurm_get_accounting_storage_port(void);
+
+/* slurm_get_jobacct_gather_type
  * returns the job accounting type from slurmctld_conf object
  * RET char *    - job accounting type,  MUST be xfreed by caller
  */
-char *slurm_get_jobacct_type(void);
+char *slurm_get_jobacct_gather_type(void);
+
+/* slurm_get_jobacct_gather_freq
+ * returns the job accounting poll frequency from the slurmctld_conf object
+ * RET int    - job accounting frequency
+ */
+uint16_t slurm_get_jobacct_gather_freq(void);
 
 /* slurm_get_jobcomp_type
  * returns the job completion logger type from slurmctld_conf object
@@ -193,6 +281,36 @@ char *slurm_get_jobacct_type(void);
  */
 char *slurm_get_jobcomp_type(void);
 
+/* slurm_get_jobcomp_loc
+ * returns the job completion loc from slurmctld_conf object
+ * RET char *    - job completion location,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_loc(void);
+
+/* slurm_get_jobcomp_user
+ * returns the storage user from slurmctld_conf object
+ * RET char *    - storage user,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_user(void);
+
+/* slurm_get_jobcomp_host
+ * returns the storage host from slurmctld_conf object
+ * RET char *    - storage host,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_host(void);
+
+/* slurm_get_jobcomp_pass
+ * returns the storage password from slurmctld_conf object
+ * RET char *    - storage password,  MUST be xfreed by caller
+ */
+char *slurm_get_jobcomp_pass(void);
+
+/* slurm_get_jobcomp_port
+ * returns the storage port from slurmctld_conf object
+ * RET uint32_t   - storage port
+ */
+uint32_t slurm_get_jobcomp_port(void);
+
 /* slurm_get_propagate_prio_process
  * return the PropagatePrioProcess flag from slurmctld_conf object
  */
@@ -607,7 +725,7 @@ int inline slurm_unpack_slurm_addr_no_alloc(slurm_addr * slurm_address,
  * returns		- SLURM error code
  */
 void inline slurm_pack_slurm_addr_array(slurm_addr * slurm_address,
-					uint16_t size_val, Buf buffer);
+					uint32_t size_val, Buf buffer);
 /* slurm_unpack_slurm_addr_array
  * unpacks an array of slurm_addrs from a buffer
  * OUT slurm_address	- slurm_addr to unpack to
@@ -616,7 +734,7 @@ void inline slurm_pack_slurm_addr_array(slurm_addr * slurm_address,
  * returns		- SLURM error code
  */
 int inline slurm_unpack_slurm_addr_array(slurm_addr ** slurm_address,
-					 uint16_t * size_val, Buf buffer);
+					 uint32_t * size_val, Buf buffer);
 
 /**********************************************************************\
  * simplified communication routines 
diff --git a/src/common/slurm_protocol_common.h b/src/common/slurm_protocol_common.h
index e9308e8243227afd16b3d260c3a21ace031bf466..11efc3867569cb5b07de9dc6dbbfb16086fb4283 100644
--- a/src/common/slurm_protocol_common.h
+++ b/src/common/slurm_protocol_common.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -66,6 +66,7 @@
 
 /* used to set flags to empty */
 #define SLURM_PROTOCOL_NO_FLAGS 0 
+#define SLURM_GLOBAL_AUTH_KEY   1
 
 #if MONGO_IMPLEMENTATION
 #  include <src/common/slurm_protocol_mongo_common.h>
diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c
index d7d27d4a5e4931057b06d5fe63bd7a754a6d871d..c513b3f8b6dde3dbcde4aa37378a3e8729c6c7ff 100644
--- a/src/common/slurm_protocol_defs.c
+++ b/src/common/slurm_protocol_defs.c
@@ -2,13 +2,12 @@
  *  slurm_protocol_defs.c - functions for initializing and releasing 
  *	storage for RPC data structures. these are the functions used by 
  *	the slurm daemons directly, not for user client use.
- *
- *  $Id: slurm_protocol_defs.c 12088 2007-08-22 18:02:24Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -50,14 +49,15 @@
 #include <stdio.h>
 
 #include "src/common/log.h"
-#include "src/common/slurm_jobacct.h"
 #include "src/common/node_select.h"
+#include "src/common/slurm_accounting_storage.h"
 #include "src/common/slurm_cred.h"
 #include "src/common/slurm_protocol_defs.h"
 #include "src/common/switch.h"
 #include "src/common/xmalloc.h"
 #include "src/common/job_options.h"
 #include "src/common/forward.h"
+#include "src/common/slurm_jobacct_gather.h"
 
 static void _free_all_job_info (job_info_msg_t *msg);
 
@@ -104,6 +104,12 @@ extern void slurm_msg_t_copy(slurm_msg_t *dest, slurm_msg_t *src)
 	return;	
 }
 
+extern void slurm_destroy_char(void *object)
+{
+	char *tmp = (char *)object;
+	xfree(tmp);
+}
+
 
 void slurm_free_last_update_msg(last_update_msg_t * msg)
 {
@@ -184,6 +190,7 @@ void slurm_free_job_desc_msg(job_desc_msg_t * msg)
 			xfree(msg->environment[i]);
 		xfree(msg->environment);
 		xfree(msg->features);
+		xfree(msg->licenses);
 		xfree(msg->mail_user);
 		xfree(msg->name);
 		xfree(msg->partition);
@@ -197,11 +204,11 @@ void slurm_free_job_desc_msg(job_desc_msg_t * msg)
 		xfree(msg->in);
 		xfree(msg->out);
 		xfree(msg->work_dir);
-		xfree(msg->alloc_resp_hostname);
-		xfree(msg->other_hostname);
 		xfree(msg->account);
 		xfree(msg->network);
 		xfree(msg->comment);
+		xfree(msg->dependency);
+		xfree(msg->resp_host);
 		xfree(msg->blrtsimage);
 		xfree(msg->linuximage);
 		xfree(msg->mloaderimage);
@@ -268,6 +275,10 @@ void slurm_free_job_info_members(job_info_t * job)
 		xfree(job->exc_node_inx);
 		xfree(job->network);
 		xfree(job->comment);
+		xfree(job->dependency);
+		xfree(job->work_dir);
+		xfree(job->command);
+		xfree(job->licenses);
 	}
 }
 
@@ -275,8 +286,10 @@ void slurm_free_node_registration_status_msg(
 	slurm_node_registration_status_msg_t * msg)
 {
 	if (msg) {
-		xfree(msg->node_name);
+		xfree(msg->arch);
 		xfree(msg->job_id);
+		xfree(msg->node_name);
+		xfree(msg->os);
 		xfree(msg->step_id);
 		if (msg->startup)
 			switch_g_free_node_info(&msg->switch_nodeinfo);
@@ -321,6 +334,7 @@ void slurm_free_job_step_create_request_msg(job_step_create_request_msg_t *
 		xfree(msg->name);
 		xfree(msg->network);
 		xfree(msg->node_list);
+		xfree(msg->ckpt_path);
 		xfree(msg);
 	}
 }
@@ -421,6 +435,8 @@ void slurm_free_launch_tasks_request_msg(launch_tasks_request_msg_t * msg)
 	xfree(msg->task_epilog);
 	xfree(msg->complete_nodelist);
 
+	xfree(msg->ckpt_path);
+
 	if (msg->switch_job)
 		switch_free_jobinfo(msg->switch_job);
 
@@ -432,9 +448,6 @@ void slurm_free_launch_tasks_request_msg(launch_tasks_request_msg_t * msg)
 
 void slurm_free_task_user_managed_io_stream_msg(task_user_managed_io_msg_t *msg)
 {
-	if (msg == NULL)
-		return;
-
 	xfree(msg);
 }
 
@@ -469,6 +482,11 @@ void slurm_free_kill_tasks_msg(kill_tasks_msg_t * msg)
 	xfree(msg);
 }
 
+void slurm_free_checkpoint_tasks_msg(checkpoint_tasks_msg_t * msg)
+{
+	xfree(msg);
+}
+
 void slurm_free_epilog_complete_msg(epilog_complete_msg_t * msg)
 {
 	if (msg) {
@@ -534,6 +552,14 @@ void inline slurm_free_checkpoint_comp_msg(checkpoint_comp_msg_t *msg)
 	}
 }
 
+void inline slurm_free_checkpoint_task_comp_msg(checkpoint_task_comp_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->error_msg);
+		xfree(msg);
+	}
+}
+
 void inline slurm_free_checkpoint_resp_msg(checkpoint_resp_msg_t *msg)
 {
 	if (msg) {
@@ -568,6 +594,10 @@ extern char *job_reason_string(enum job_state_reason inx)
 			return "JobHeld";
 		case WAIT_TIME:
 			return "BeginTime";
+		case WAIT_LICENSES:
+			return "Licenses";
+		case WAIT_ASSOC_LIMIT:
+			return "AssociationLimit";
 		case FAIL_DOWN_PARTITION:
 			return "PartitionDown";
 		case FAIL_DOWN_NODE:
@@ -584,6 +614,8 @@ extern char *job_reason_string(enum job_state_reason inx)
 			return "TimeLimit";
 		case FAIL_INACTIVE_LIMIT:
 			return "InactiveLimit";
+		case FAIL_BANK_ACCOUNT:
+			return "InvalidBankAccount";
 		default:
 			return "?";
 	}
@@ -597,6 +629,14 @@ void inline slurm_free_get_kvs_msg(kvs_get_msg_t *msg)
 	}
 }
 
+void inline slurm_free_will_run_response_msg(will_run_response_msg_t *msg)
+{
+        if (msg) {
+                xfree(msg->node_list);
+                xfree(msg);
+        }
+}
+
 char *job_state_string(enum job_states inx)
 {
 	if (inx & JOB_COMPLETING)
@@ -653,8 +693,9 @@ char *job_state_string_compact(enum job_states inx)
 
 char *node_state_string(enum node_states inx)
 {
-	bool drain_flag   = (inx & NODE_STATE_DRAIN);
 	bool comp_flag    = (inx & NODE_STATE_COMPLETING);
+	bool drain_flag   = (inx & NODE_STATE_DRAIN);
+	bool fail_flag    = (inx & NODE_STATE_FAIL);
 	bool no_resp_flag = (inx & NODE_STATE_NO_RESPOND);
 	bool power_flag   = (inx & NODE_STATE_POWER_SAVE);
 
@@ -671,6 +712,17 @@ char *node_state_string(enum node_states inx)
 			return "DRAINED";
 		}
 	}
+	if (fail_flag) {
+		if (comp_flag || (inx == NODE_STATE_ALLOCATED)) {
+			if (no_resp_flag)
+				return "FAILING*";
+			return "FAILING";
+		} else {
+			if (no_resp_flag)
+				return "FAIL*";
+			return "FAIL";
+		}
+	}
 	if (inx == NODE_STATE_DOWN) {
 		if (no_resp_flag)
 			return "DOWN*";
@@ -705,8 +757,9 @@ char *node_state_string(enum node_states inx)
 
 char *node_state_string_compact(enum node_states inx)
 {
-	bool drain_flag   = (inx & NODE_STATE_DRAIN);
 	bool comp_flag    = (inx & NODE_STATE_COMPLETING);
+	bool drain_flag   = (inx & NODE_STATE_DRAIN);
+	bool fail_flag    = (inx & NODE_STATE_FAIL);
 	bool no_resp_flag = (inx & NODE_STATE_NO_RESPOND);
 	bool power_flag   = (inx & NODE_STATE_POWER_SAVE);
 
@@ -723,6 +776,17 @@ char *node_state_string_compact(enum node_states inx)
 			return "DRAIN";
 		}
 	}
+	if (fail_flag) {
+		if (comp_flag || (inx == NODE_STATE_ALLOCATED)) {
+			if (no_resp_flag)
+				return "FAILG*";
+			return "FAILG";
+		} else {
+			if (no_resp_flag)
+				return "FAIL*";
+			return "FAIL";
+		}
+	}
 	if (inx == NODE_STATE_DOWN) {
 		if (no_resp_flag)
 			return "DOWN*";
@@ -834,37 +898,62 @@ void slurm_free_submit_response_response_msg(submit_response_msg_t * msg)
 void slurm_free_ctl_conf(slurm_ctl_conf_info_msg_t * config_ptr)
 {
 	if (config_ptr) {
+		xfree(config_ptr->accounting_storage_host);
+		xfree(config_ptr->accounting_storage_loc);
+		xfree(config_ptr->accounting_storage_pass);
+		xfree(config_ptr->accounting_storage_type);
+		xfree(config_ptr->accounting_storage_user);
 		xfree(config_ptr->authtype);
 		xfree(config_ptr->backup_addr);
 		xfree(config_ptr->backup_controller);
+		xfree(config_ptr->checkpoint_type);
+		xfree(config_ptr->cluster_name);
 		xfree(config_ptr->control_addr);
 		xfree(config_ptr->control_machine);
+		xfree(config_ptr->crypto_type);
 		xfree(config_ptr->epilog);
-		xfree(config_ptr->job_acct_logfile);
-		xfree(config_ptr->job_acct_type);
+		xfree(config_ptr->health_check_program);
+		xfree(config_ptr->job_acct_gather_type);
+		xfree(config_ptr->job_comp_host);
 		xfree(config_ptr->job_comp_loc);
+		xfree(config_ptr->job_comp_pass);
 		xfree(config_ptr->job_comp_type);
+		xfree(config_ptr->job_comp_user);
 		xfree(config_ptr->job_credential_private_key);
 		xfree(config_ptr->job_credential_public_certificate);
+		xfree(config_ptr->licenses);
 		xfree(config_ptr->mail_prog);
 		xfree(config_ptr->mpi_default);
+		xfree(config_ptr->node_prefix);
 		xfree(config_ptr->plugindir);
+		xfree(config_ptr->plugstack);
 		xfree(config_ptr->proctrack_type);
 		xfree(config_ptr->prolog);
+		xfree(config_ptr->propagate_rlimits);
+		xfree(config_ptr->propagate_rlimits_except);
+		xfree(config_ptr->resume_program);
+		xfree(config_ptr->sched_params);
+		xfree(config_ptr->schedtype);
+		xfree(config_ptr->select_type);
+		xfree(config_ptr->slurm_conf);
 		xfree(config_ptr->slurm_user_name);
 		xfree(config_ptr->slurmctld_pidfile);
 		xfree(config_ptr->slurmctld_logfile);
 		xfree(config_ptr->slurmd_logfile);
 		xfree(config_ptr->slurmd_pidfile);
 		xfree(config_ptr->slurmd_spooldir);
-		xfree(config_ptr->slurm_conf);
-		xfree(config_ptr->state_save_location);
 		xfree(config_ptr->srun_epilog);
 		xfree(config_ptr->srun_prolog);
+		xfree(config_ptr->state_save_location);
+		xfree(config_ptr->suspend_exc_nodes);
+		xfree(config_ptr->suspend_exc_parts);
+		xfree(config_ptr->suspend_program);
+		xfree(config_ptr->switch_type);
 		xfree(config_ptr->task_epilog);
-		xfree(config_ptr->task_prolog);
 		xfree(config_ptr->task_plugin);
+		xfree(config_ptr->task_prolog);
 		xfree(config_ptr->tmp_fs);
+		xfree(config_ptr->unkillable_program);
 		xfree(config_ptr);
 	}
 }
@@ -948,6 +1037,7 @@ static void _slurm_free_job_step_info_members (job_step_info_t * msg)
 	if (msg != NULL) {
 		xfree(msg->partition);
 		xfree(msg->nodes);
+		xfree(msg->ckpt_path);
 	}
 }
 
@@ -984,7 +1074,9 @@ static void _slurm_free_node_info_members(node_info_t * node)
 {
 	if (node) {
 		xfree(node->name);
+		xfree(node->arch);
 		xfree(node->features);
+		xfree(node->os);
 		xfree(node->reason);
 	}
 }
@@ -1033,12 +1125,9 @@ static void _slurm_free_partition_info_members(partition_info_t * part)
 
 extern void slurm_free_file_bcast_msg(file_bcast_msg_t *msg)
 {
-	int i;
-
 	if (msg) {
 		xfree(msg->fname);
-		for (i=0; i<FILE_BLOCKS; i++)
-			xfree(msg->block[i]);
+		xfree(msg->block);
 		xfree(msg);
 	}
 }
@@ -1046,7 +1135,7 @@ extern void slurm_free_file_bcast_msg(file_bcast_msg_t *msg)
 extern void slurm_free_step_complete_msg(step_complete_msg_t *msg)
 {
 	if (msg) {
-		jobacct_g_free(msg->jobacct);
+		jobacct_gather_g_destroy(msg->jobacct);
 		xfree(msg);
 	}
 }
@@ -1054,7 +1143,7 @@ extern void slurm_free_step_complete_msg(step_complete_msg_t *msg)
 extern void slurm_free_stat_jobacct_msg(stat_jobacct_msg_t *msg)
 {
 	if (msg) {
-		jobacct_g_free(msg->jobacct);
+		jobacct_gather_g_destroy(msg->jobacct);
 		xfree(msg);
 	}
 }
@@ -1076,6 +1165,21 @@ void inline slurm_free_trigger_msg(trigger_info_msg_t *msg)
 	xfree(msg);
 }
 
+void slurm_free_set_debug_level_msg(set_debug_level_msg_t *msg)
+{
+	xfree(msg);
+}
+
+
+void inline slurm_free_accounting_update_msg(accounting_update_msg_t *msg)
+{
+	if(msg) {
+		if(msg->update_list)
+			list_destroy(msg->update_list);
+		xfree(msg);
+	}
+}
+
 extern int slurm_free_msg_data(slurm_msg_type_t type, void *data)
 {
 	switch(type) {
@@ -1143,6 +1247,9 @@ extern int slurm_free_msg_data(slurm_msg_type_t type, void *data)
 	case REQUEST_CHECKPOINT_COMP:
 		slurm_free_checkpoint_comp_msg(data);
 		break;
+	case REQUEST_CHECKPOINT_TASK_COMP:
+		slurm_free_checkpoint_task_comp_msg(data);
+		break;
 	case REQUEST_SUSPEND:
 		slurm_free_suspend_msg(data);
 		break;
@@ -1171,6 +1278,9 @@ extern int slurm_free_msg_data(slurm_msg_type_t type, void *data)
 	case REQUEST_TERMINATE_TASKS:
 		slurm_free_kill_tasks_msg(data);
 		break;
+	case REQUEST_CHECKPOINT_TASKS:
+		slurm_free_checkpoint_tasks_msg(data);
+		break;
 	case REQUEST_KILL_TIMELIMIT:
 		slurm_free_timelimit_msg(data);
 		break; 
@@ -1198,6 +1308,9 @@ extern int slurm_free_msg_data(slurm_msg_type_t type, void *data)
 	case RESPONSE_SLURM_RC:
 		slurm_free_return_code_msg(data);
 		break;
+	case REQUEST_SET_DEBUG_LEVEL:
+		slurm_free_set_debug_level_msg(data);
+		break;
 	case SLURM_SUCCESS:		
 	case REQUEST_PING:		
 	case REQUEST_RECONFIGURE:
@@ -1205,9 +1318,12 @@ extern int slurm_free_msg_data(slurm_msg_type_t type, void *data)
 	case REQUEST_SHUTDOWN_IMMEDIATE:
 	case RESPONSE_FORWARD_FAILED:
 	case REQUEST_DAEMON_STATUS:
+	case REQUEST_HEALTH_CHECK:
 		/* No body to free */
 		break;
-
+	case ACCOUNTING_UPDATE_MSG:
+		slurm_free_accounting_update_msg(data);
+		break;
 	default:
 		error("invalid type trying to be freed %u", type);
 		break; 
@@ -1248,3 +1364,10 @@ extern uint32_t slurm_get_return_code(slurm_msg_type_t type, void *data)
 	return rc;
 }
 
+void inline slurm_free_job_notify_msg(job_notify_msg_t * msg)
+{
+	if (msg) {
+		xfree(msg->message);
+		xfree(msg);
+	}
+}
diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h
index 94fab224fadc3a37a3eee753fb5befd9eafef591..799f83ea8e7cd8eaab16b8e724b943b88dee6533 100644
--- a/src/common/slurm_protocol_defs.h
+++ b/src/common/slurm_protocol_defs.h
@@ -1,12 +1,12 @@
 /****************************************************************************\
  *  slurm_protocol_defs.h - definitions used for RPCs
  *
- *  $Id: slurm_protocol_defs.h 12088 2007-08-22 18:02:24Z jette $
+ *  $Id: slurm_protocol_defs.h 13755 2008-04-01 19:12:53Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -64,6 +64,7 @@
 #include "src/common/job_options.h"
 #include "src/common/slurm_step_layout.h"
 #include "src/common/xassert.h"
+//#include "src/common/slurm_jobacct_common.h"
 
 #define MAX_SLURM_NAME 64
 #define FORWARD_INIT 0xfffe
@@ -93,7 +94,9 @@ typedef enum {
 	RESPONSE_SHUTDOWN,
 	REQUEST_PING,
 	REQUEST_CONTROL,
-
+	REQUEST_SET_DEBUG_LEVEL,
+	REQUEST_HEALTH_CHECK,
+	
 	REQUEST_BUILD_INFO = 2001,
 	RESPONSE_BUILD_INFO,
 	REQUEST_JOB_INFO,
@@ -141,6 +144,7 @@ typedef enum {
 	REQUEST_JOB_READY,
 	RESPONSE_JOB_READY,
 	REQUEST_JOB_END_TIME,
+	REQUEST_JOB_NOTIFY,
 
 	REQUEST_JOB_STEP_CREATE = 5001,
 	RESPONSE_JOB_STEP_CREATE,
@@ -153,6 +157,7 @@ typedef enum {
 	REQUEST_CHECKPOINT,
 	RESPONSE_CHECKPOINT,
 	REQUEST_CHECKPOINT_COMP,
+	REQUEST_CHECKPOINT_TASK_COMP,
 	RESPONSE_CHECKPOINT_COMP,
 	REQUEST_SUSPEND,
 	RESPONSE_SUSPEND,
@@ -171,6 +176,7 @@ typedef enum {
 	RESPONSE_LAUNCH_TASKS,
 	MESSAGE_TASK_EXIT,
 	REQUEST_SIGNAL_TASKS,
+	REQUEST_CHECKPOINT_TASKS,
 	REQUEST_TERMINATE_TASKS,
 	REQUEST_REATTACH_TASKS,
 	RESPONSE_REATTACH_TASKS,
@@ -196,7 +202,10 @@ typedef enum {
 
 	RESPONSE_SLURM_RC = 8001,
 
-	RESPONSE_FORWARD_FAILED = 9001
+	RESPONSE_FORWARD_FAILED = 9001,
+
+	ACCOUNTING_UPDATE_MSG = 10001,
+
 } slurm_msg_type_t;
 
 typedef enum {
@@ -254,6 +263,7 @@ typedef struct slurm_protocol_config {
 
 typedef struct slurm_msg {
 	slurm_msg_type_t msg_type;
+	uint16_t flags;
 	slurm_addr address;       
 	slurm_fd conn_fd;
 	void *auth_cred;
@@ -286,6 +296,12 @@ typedef struct job_step_kill_msg {
 	uint16_t batch_flag;
 } job_step_kill_msg_t;
 
+typedef struct job_notify_msg {
+	uint32_t job_id;
+	uint32_t job_step_id;	/* currently not used */
+	char *   message;
+} job_notify_msg_t;
+
 typedef struct job_id_msg {
 	uint32_t job_id;
 } job_id_msg_t;
@@ -356,6 +372,13 @@ typedef struct kill_tasks_msg {
 	uint32_t signal;
 } kill_tasks_msg_t;
 
+typedef struct checkpoint_tasks_msg {
+	uint32_t job_id;
+	uint32_t job_step_id;
+	uint32_t signal;
+	time_t timestamp;
+} checkpoint_tasks_msg_t;
+
 typedef struct epilog_complete_msg {
 	uint32_t job_id;
 	uint32_t return_code;
@@ -371,6 +394,10 @@ typedef struct last_update_msg {
 	time_t last_update;
 } last_update_msg_t;
 
+typedef struct set_debug_level_msg {
+	uint32_t debug_level;
+} set_debug_level_msg_t;
+
 typedef struct job_step_specs {
 	uint32_t job_id;	/* job ID */
 	uint32_t user_id;	/* user the job runs as */
@@ -382,10 +409,16 @@ typedef struct job_step_specs {
 	uint16_t plane_size;	/* plane size when task_dist =
 				   SLURM_DIST_PLANE */
 	uint16_t port;		/* port to contact initiating srun */
+	uint16_t ckpt_interval;	/* checkpoint creation interval (minutes) */
+	uint16_t exclusive;	/* 1 if CPUs not shared with other steps */
+	uint16_t immediate;	/* 1 if allocate to run or fail immediately,
+				 * 0 if to be queued awaiting resources */
+	uint16_t mem_per_task;	/* MB memory required per task, 0=no limit */
 	char *host;		/* host to contact initiating srun */
 	char *node_list;	/* list of required nodes */
 	char *network;		/* network use spec */
 	char *name;		/* name of the job step, default "" */
+	char *ckpt_path;	/* path to store checkpoint image files */
 	uint8_t overcommit;     /* flag, 1 to allow overcommit of processors,
 				   0 to disallow overcommit. default is 0 */
 } job_step_create_request_msg_t;
@@ -406,9 +439,11 @@ typedef struct launch_tasks_request_msg {
 	uint32_t  nprocs;	/* number of processes in this job step   */
 	uint32_t  uid;
 	uint32_t  gid;
+	uint32_t  job_mem;	/* MB of memory reserved by job, 0 if no limit */
+	uint32_t  task_mem;	/* MB of memory reserved per task, 0 if no limit */
 	uint16_t  *tasks_to_launch;
-	uint16_t  envc;
-	uint16_t  argc;
+	uint32_t  envc;
+	uint32_t  argc;
 	uint16_t  multi_prog;
 	uint16_t  *cpus_allocated;
 	uint16_t  max_sockets;
@@ -438,6 +473,9 @@ typedef struct launch_tasks_request_msg {
 	
 	uint16_t user_managed_io; /* 0 for "normal" IO,
 				     1 for "user manged" IO */
+	uint8_t open_mode;	/* stdout/err append or truncate */
+	uint8_t pty;		/* use pseudo tty */
+	uint16_t acctg_freq;	/* accounting polling interval */
 
 	/********** START "normal" IO only options **********/
 	/* These options are ignored if user_managed_io is 1 */
@@ -458,6 +496,7 @@ typedef struct launch_tasks_request_msg {
 	switch_jobinfo_t switch_job;	/* switch credential for the job */
 	job_options_t options;  /* Arbitrary job options */
 	char *complete_nodelist;
+	char *ckpt_path;	/* checkpoint path */
 } launch_tasks_request_msg_t;
 
 typedef struct task_user_managed_io_msg {
@@ -477,8 +516,11 @@ typedef struct return_code_msg {
  * the event of some launch failure or race condition preventing slurmd 
  * from getting the MPIRUN_PARTITION at that time. It is needed for 
  * the job epilog. */
+#define SIG_NODE_FAIL	998	/* Dummy signal value to signify node failure */
+#define SIG_FAILURE     999	/* Dummy signal value to signify sys failure */
 typedef struct kill_job_msg {
 	uint32_t job_id;
+	uint16_t job_state;
 	uint32_t job_uid;
 	time_t   time;		/* slurmctld's time of request */
 	char *nodes;
@@ -531,14 +573,17 @@ typedef struct batch_job_launch_msg {
 	char *in;		/* pathname of stdin */
 	char *out;		/* pathname of stdout */
 	char *work_dir;		/* full pathname of working directory */
-	uint16_t argc;
+	uint32_t argc;
 	char **argv;
-	uint16_t envc;		/* element count in environment */
+	uint32_t envc;		/* element count in environment */
 	char **environment;	/* environment variables to set for job, 
 				 *   name=value pairs, one per line */
 	select_jobinfo_t select_jobinfo;	/* opaque data type */
 	slurm_cred_t cred;
-	uint16_t overcommit;	/* if resources being over subscribed */
+	uint8_t open_mode;	/* stdout/err append or truncate */
+	uint8_t overcommit;	/* if resources being over subscribed */
+	uint16_t acctg_freq;	/* accounting polling interval */
+	uint32_t job_mem;	/* memory limit for job */
 } batch_job_launch_msg_t;
 
 typedef struct job_id_request_msg {
@@ -550,35 +595,13 @@ typedef struct job_id_response_msg {
 	uint32_t return_code;	/* slurm return code */
 } job_id_response_msg_t;
 
-typedef struct srun_ping_msg {
-	uint32_t job_id;	/* slurm job_id */
-	uint32_t step_id;	/* step_id or NO_VAL */
-} srun_ping_msg_t;
-
-typedef struct srun_job_complete_msg {
-        uint32_t job_id;        /* slurm job_id */
-        uint32_t step_id;       /* step_id or NO_VAL */
-} srun_job_complete_msg_t;
-
 typedef struct srun_exec_msg {
 	uint32_t job_id;	/* slurm job_id */
 	uint32_t step_id;	/* step_id or NO_VAL */
-	uint16_t argc;		/* argument count */
+	uint32_t argc;		/* argument count */
 	char **  argv;		/* program arguments */
 } srun_exec_msg_t;
 
-typedef struct srun_node_fail_msg {
-	uint32_t job_id;	/* slurm job_id */
-	uint32_t step_id;	/* step_id or NO_VAL */
-	char *nodelist;		/* name of failed node(s) */
-} srun_node_fail_msg_t;
-
-typedef struct srun_timeout_msg {
-	uint32_t job_id;	/* slurm job_id */
-	uint32_t step_id;	/* step_id or NO_VAL */
-	time_t   timeout;	/* when job scheduled to be killed */
-} srun_timeout_msg_t;
-
 typedef struct checkpoint_msg {
 	uint16_t op;		/* checkpoint operation, see enum check_opts */
 	uint16_t data;		/* operation specific data */
@@ -594,6 +617,15 @@ typedef struct checkpoint_comp_msg {
 	char *   error_msg;	/* error message on failure */
 } checkpoint_comp_msg_t;
 
+typedef struct checkpoint_task_comp_msg {
+	uint32_t job_id;	/* slurm job_id */
+	uint32_t step_id;	/* slurm step_id */
+	uint32_t task_id;	/* task id */
+	time_t   begin_time;	/* time checkpoint began */
+	uint32_t error_code;	/* error code on failure */
+	char *   error_msg;	/* error message on failure */
+} checkpoint_task_comp_msg_t;
+
 typedef struct checkpoint_resp_msg {
 	time_t   event_time;	/* time of checkpoint start/finish */
 	uint32_t error_code;	/* error code on failure */
@@ -605,11 +637,6 @@ typedef struct suspend_msg {
 	uint32_t job_id;        /* slurm job_id */
 } suspend_msg_t;
 
-typedef struct srun_user_msg {
-	uint32_t job_id;	/* slurm job_id */
-	char *msg;		/* message to user's srun */
-} srun_user_msg_t;
-
 typedef struct kvs_get_msg {
 	uint16_t task_id;	/* job step's task id */
 	uint16_t size;		/* count of tasks in job */
@@ -617,7 +644,6 @@ typedef struct kvs_get_msg {
 	char * hostname;	/* hostname to be sent the kvs data */
 } kvs_get_msg_t;
 
-#define FILE_BLOCKS 8
 typedef struct file_bcast_msg {
 	char *fname;		/* name of the destination file */
 	uint16_t block_no;	/* block number of this data */
@@ -628,8 +654,8 @@ typedef struct file_bcast_msg {
 	uint32_t gid;		/* group for destination file */
 	time_t atime;		/* last access time for destination file */
 	time_t mtime;		/* last modification time for dest file */
-	uint32_t block_len[FILE_BLOCKS];/* length of this data block */
-	char *block[FILE_BLOCKS];	/* data for this block, 64k max */
+	uint32_t block_len;	/* length of this data block */
+	char *block;		/* data for this block */
 } file_bcast_msg_t; 
 
 typedef struct multi_core_data {
@@ -655,18 +681,32 @@ typedef struct multi_core_data {
 	uint16_t plane_size;        /* plane size when task_dist = SLURM_DIST_PLANE */
 } multi_core_data_t;
 
+typedef struct pty_winsz {
+	uint16_t cols;
+	uint16_t rows;
+} pty_winsz_t;
+
+typedef struct will_run_response_msg {
+	uint32_t job_id;
+	uint32_t proc_cnt;
+	time_t start_time;
+	char *node_list;
+} will_run_response_msg_t;
+
 /*****************************************************************************\
  * Slurm API Message Types
 \*****************************************************************************/
 typedef struct slurm_node_registration_status_msg {
 	time_t timestamp;
 	char *node_name;
+	char *arch;
+	char *os;
 	uint16_t cpus;
 	uint16_t sockets;
 	uint16_t cores;
 	uint16_t threads;
-	uint32_t real_memory_size;
-	uint32_t temporary_disk_space;
+	uint32_t real_memory;
+	uint32_t tmp_disk;
 	uint32_t job_count;	/* number of associate job_id's */
 	uint32_t *job_id;	/* IDs of running job (if any) */
 	uint16_t *step_id;	/* IDs of running job steps (if any) */
@@ -675,6 +715,15 @@ typedef struct slurm_node_registration_status_msg {
 	switch_node_info_t switch_nodeinfo;	/* set only if startup != 0 */
 } slurm_node_registration_status_msg_t;
 
+
+/*****************************************************************************\
+ *      ACCOUNTING PUSHS
+\*****************************************************************************/
+
+typedef struct {
+	List update_list; /* of type acct_update_object_t *'s */
+} accounting_update_msg_t;
+
 typedef struct slurm_ctl_conf slurm_ctl_conf_info_msg_t;
 /*****************************************************************************\
  *	SLURM MESSAGE INITIALIZATION
@@ -696,7 +745,10 @@ extern void slurm_msg_t_init (slurm_msg_t *msg);
  */
 extern void slurm_msg_t_copy(slurm_msg_t *dest, slurm_msg_t *src);
 
+extern void slurm_destroy_char(void *object);
+
 /* free message functions */
+void inline slurm_free_checkpoint_tasks_msg(checkpoint_tasks_msg_t * msg);
 void inline slurm_free_last_update_msg(last_update_msg_t * msg);
 void inline slurm_free_return_code_msg(return_code_msg_t * msg);
 void inline slurm_free_job_alloc_info_msg(job_alloc_info_msg_t * msg);
@@ -705,6 +757,7 @@ void inline slurm_free_job_step_info_request_msg(
 		job_step_info_request_msg_t *msg);
 void inline slurm_free_node_info_request_msg(node_info_request_msg_t *msg);
 void inline slurm_free_part_info_request_msg(part_info_request_msg_t *msg);
+void inline slurm_free_set_debug_level_msg(set_debug_level_msg_t *msg);
 
 #define	slurm_free_timelimit_msg(msg) \
 	slurm_free_kill_job_msg(msg)
@@ -764,6 +817,7 @@ void inline slurm_free_srun_timeout_msg(srun_timeout_msg_t * msg);
 void inline slurm_free_srun_user_msg(srun_user_msg_t * msg);
 void inline slurm_free_checkpoint_msg(checkpoint_msg_t *msg);
 void inline slurm_free_checkpoint_comp_msg(checkpoint_comp_msg_t *msg);
+void inline slurm_free_checkpoint_task_comp_msg(checkpoint_task_comp_msg_t *msg);
 void inline slurm_free_checkpoint_resp_msg(checkpoint_resp_msg_t *msg);
 void inline slurm_free_suspend_msg(suspend_msg_t *msg);
 void slurm_free_resource_allocation_response_msg (
@@ -780,11 +834,16 @@ void slurm_free_job_step_info_response_msg(
 void slurm_free_node_info_msg(node_info_msg_t * msg);
 void slurm_free_partition_info_msg(partition_info_msg_t * msg);
 void slurm_free_get_kvs_msg(kvs_get_msg_t *msg);
+void slurm_free_will_run_response_msg(will_run_response_msg_t *msg);
 void inline slurm_free_file_bcast_msg(file_bcast_msg_t *msg);
 void inline slurm_free_step_complete_msg(step_complete_msg_t *msg);
 void inline slurm_free_stat_jobacct_msg(stat_jobacct_msg_t *msg);
 void inline slurm_free_node_select_msg(
 		node_info_select_request_msg_t *msg);
+void inline slurm_free_job_notify_msg(job_notify_msg_t * msg);
+
+void inline slurm_free_accounting_update_msg(accounting_update_msg_t *msg);
+
 extern int slurm_free_msg_data(slurm_msg_type_t type, void *data);
 extern uint32_t slurm_get_return_code(slurm_msg_type_t type, void *data);
 
diff --git a/src/common/slurm_protocol_interface.h b/src/common/slurm_protocol_interface.h
index 64bffe2b58370f0ee9b104d63860a6adbef42b1c..036f89db87a4dd6b43de782a10b8b48b2fcf1f52 100644
--- a/src/common/slurm_protocol_interface.h
+++ b/src/common/slurm_protocol_interface.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Chris Dunlap <cdunlap@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_protocol_mongo_common.h b/src/common/slurm_protocol_mongo_common.h
index 666a25cdb9f122e317f4ae48de7a8ca785c6bea5..60e5ef42cfc5b00a99ae028d08392b86fc17c255 100644
--- a/src/common/slurm_protocol_mongo_common.h
+++ b/src/common/slurm_protocol_mongo_common.h
@@ -6,7 +6,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> 
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c
index 9a67b46f56e12ae240500763c641cf82b5ff0683..a0abfea978279ba9d764c3792d2c996ccefe5b56 100644
--- a/src/common/slurm_protocol_pack.c
+++ b/src/common/slurm_protocol_pack.c
@@ -1,12 +1,11 @@
 /****************************************************************************\
  *  slurm_protocol_pack.c - functions to pack and unpack structures for RPCs
- *
- *  $Id: slurm_protocol_pack.c 12814 2007-12-11 23:28:22Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -50,7 +49,8 @@
 #include "src/common/bitstring.h"
 #include "src/common/log.h"
 #include "src/common/node_select.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurm_jobacct_gather.h"
 #include "src/common/pack.h"
 #include "src/common/slurm_auth.h"
 #include "src/common/slurm_cred.h"
@@ -165,6 +165,9 @@ static int _unpack_task_user_managed_io_stream_msg(task_user_managed_io_msg_t **
 static void _pack_cancel_tasks_msg(kill_tasks_msg_t * msg, Buf buffer);
 static int _unpack_cancel_tasks_msg(kill_tasks_msg_t ** msg_ptr, Buf buffer);
 
+static void _pack_checkpoint_tasks_msg(checkpoint_tasks_msg_t * msg, Buf buffer);
+static int _unpack_checkpoint_tasks_msg(checkpoint_tasks_msg_t ** msg_ptr, Buf buffer);
+
 static void _pack_launch_tasks_response_msg(launch_tasks_response_msg_t *
 					    msg, Buf buffer);
 static int _unpack_launch_tasks_response_msg(launch_tasks_response_msg_t **
@@ -188,7 +191,7 @@ static int _unpack_task_exit_msg(task_exit_msg_t ** msg_ptr, Buf buffer);
 
 static void _pack_job_alloc_info_msg(job_alloc_info_msg_t * job_desc_ptr,
 				     Buf buffer);
-static int 
+static int
 _unpack_job_alloc_info_msg(job_alloc_info_msg_t **job_desc_buffer_ptr, 
 			   Buf buffer);
 
@@ -253,9 +256,9 @@ static void _pack_last_update_msg(last_update_msg_t * msg, Buf buffer);
 static int _unpack_last_update_msg(last_update_msg_t ** msg, Buf buffer);
 
 static void _pack_slurm_addr_array(slurm_addr * slurm_address,
-				   uint16_t size_val, Buf buffer);
+				   uint32_t size_val, Buf buffer);
 static int _unpack_slurm_addr_array(slurm_addr ** slurm_address,
-				    uint16_t * size_val, Buf buffer);
+				    uint32_t * size_val, Buf buffer);
 
 static void _pack_ret_list(List ret_list, uint16_t size_val, Buf buffer);
 static int _unpack_ret_list(List *ret_list, uint16_t size_val, Buf buffer);
@@ -300,6 +303,10 @@ static void _pack_checkpoint_comp(checkpoint_comp_msg_t *msg, Buf buffer);
 static int  _unpack_checkpoint_comp(checkpoint_comp_msg_t **msg_ptr, 
 				    Buf buffer);
 
+static void _pack_checkpoint_task_comp(checkpoint_task_comp_msg_t *msg, Buf buffer);
+static int  _unpack_checkpoint_task_comp(checkpoint_task_comp_msg_t **msg_ptr, 
+					 Buf buffer);
+
 static void _pack_suspend_msg(suspend_msg_t *msg, Buf buffer);
 static int  _unpack_suspend_msg(suspend_msg_t **msg_ptr, Buf buffer);
 
@@ -326,6 +333,21 @@ static int  _unpack_trigger_msg(trigger_info_msg_t ** msg_ptr , Buf buffer );
 static void _pack_slurmd_status(slurmd_status_t *msg, Buf buffer);
 static int  _unpack_slurmd_status(slurmd_status_t **msg_ptr, Buf buffer);
 
+static void _pack_job_notify(job_notify_msg_t *msg, Buf buffer);
+static int  _unpack_job_notify(job_notify_msg_t **msg_ptr, Buf buffer);
+
+static void _pack_set_debug_level_msg(set_debug_level_msg_t * msg, Buf buffer);
+static int _unpack_set_debug_level_msg(set_debug_level_msg_t ** msg_ptr, 
+				       Buf buffer);
+
+static void _pack_will_run_response_msg(will_run_response_msg_t *msg, Buf buffer);
+static int  _unpack_will_run_response_msg(will_run_response_msg_t ** msg_ptr, 
+					  Buf buffer);
+
+static void _pack_accounting_update_msg(accounting_update_msg_t *msg, Buf buffer);
+static int _unpack_accounting_update_msg(accounting_update_msg_t **msg,
+					 Buf buffer);
+
 /* pack_header
  * packs a slurm protocol header that proceeds every slurm message
  * IN header - the header structure to pack
@@ -363,7 +385,8 @@ pack_header(header_t * header, Buf buffer)
 int
 unpack_header(header_t * header, Buf buffer)
 {
-	uint16_t uint16_tmp = 0;
+	uint16_t uint16_tmp;
+	uint32_t uint32_tmp = 0;
 
 	memset(header, 0, sizeof(header_t));
 	forward_init(&header->forward, NULL);
@@ -376,7 +399,7 @@ unpack_header(header_t * header, Buf buffer)
 	safe_unpack16(&header->forward.cnt, buffer);
 	if (header->forward.cnt > 0) {		
 		safe_unpackstr_xmalloc(&header->forward.nodelist, 
-				       &uint16_tmp, buffer);
+				       &uint32_tmp, buffer);
 		safe_unpack32(&header->forward.timeout, buffer);
 	} 
 	
@@ -462,6 +485,7 @@ pack_msg(slurm_msg_t const *msg, Buf buffer)
 	case REQUEST_PING:
 	case REQUEST_CONTROL:
 	case REQUEST_DAEMON_STATUS:
+	case REQUEST_HEALTH_CHECK:
 		/* Message contains no body/information */
 		break;
 	case REQUEST_SHUTDOWN:
@@ -473,11 +497,14 @@ pack_msg(slurm_msg_t const *msg, Buf buffer)
 		break;
 	case RESPONSE_JOB_ALLOCATION_INFO_LITE:
 	case RESPONSE_RESOURCE_ALLOCATION:
-	case RESPONSE_JOB_WILL_RUN:
 		_pack_resource_allocation_response_msg
 			((resource_allocation_response_msg_t *) msg->data,
 			 buffer);
 		break;
+	case RESPONSE_JOB_WILL_RUN:
+		_pack_will_run_response_msg((will_run_response_msg_t *)
+					    msg->data, buffer);
+		break;
 	case RESPONSE_JOB_ALLOCATION_INFO:
 		_pack_job_alloc_info_response_msg(
 			(job_alloc_info_response_msg_t *)
@@ -521,6 +548,10 @@ pack_msg(slurm_msg_t const *msg, Buf buffer)
 		_pack_cancel_tasks_msg((kill_tasks_msg_t *) msg->data,
 				       buffer);
 		break;
+	case REQUEST_CHECKPOINT_TASKS:
+		_pack_checkpoint_tasks_msg((checkpoint_tasks_msg_t *) msg->data,
+					   buffer);
+		break;
 	case REQUEST_JOB_STEP_INFO:
 		_pack_job_step_info_req_msg((job_step_info_request_msg_t
 					     *) msg->data, buffer);
@@ -645,6 +676,10 @@ pack_msg(slurm_msg_t const *msg, Buf buffer)
 		_pack_checkpoint_comp((checkpoint_comp_msg_t *)msg->data, 
 				      buffer);
 		break;
+	case REQUEST_CHECKPOINT_TASK_COMP:
+		_pack_checkpoint_task_comp((checkpoint_task_comp_msg_t *)msg->data, 
+				      buffer);
+		break;
 	case RESPONSE_CHECKPOINT:
 	case RESPONSE_CHECKPOINT_COMP:
 		_pack_checkpoint_resp_msg((checkpoint_resp_msg_t *)msg->data, 
@@ -689,6 +724,18 @@ pack_msg(slurm_msg_t const *msg, Buf buffer)
 	case RESPONSE_SLURMD_STATUS:
 		_pack_slurmd_status((slurmd_status_t *) msg->data, buffer);
 		break;
+	case REQUEST_JOB_NOTIFY:
+		_pack_job_notify((job_notify_msg_t *) msg->data, buffer);
+		break;
+	case REQUEST_SET_DEBUG_LEVEL:
+		_pack_set_debug_level_msg(
+			(set_debug_level_msg_t *)msg->data, buffer);
+		break;
+	case ACCOUNTING_UPDATE_MSG:
+		_pack_accounting_update_msg(
+			(accounting_update_msg_t *)msg->data,
+			buffer);
+		break;
 	default:
 		debug("No pack method for msg type %u", msg->msg_type);
 		return EINVAL;
@@ -766,6 +813,7 @@ unpack_msg(slurm_msg_t * msg, Buf buffer)
 	case REQUEST_PING:
 	case REQUEST_CONTROL:
 	case REQUEST_DAEMON_STATUS:
+	case REQUEST_HEALTH_CHECK:
 		/* Message contains no body/information */
 		break;
 	case REQUEST_SHUTDOWN:
@@ -778,11 +826,14 @@ unpack_msg(slurm_msg_t * msg, Buf buffer)
 		break;
 	case RESPONSE_JOB_ALLOCATION_INFO_LITE:
 	case RESPONSE_RESOURCE_ALLOCATION:
-	case RESPONSE_JOB_WILL_RUN:
 		rc = _unpack_resource_allocation_response_msg(
 			(resource_allocation_response_msg_t **)
 			& (msg->data), buffer);
 		break;
+	case RESPONSE_JOB_WILL_RUN:
+		rc = _unpack_will_run_response_msg((will_run_response_msg_t **)
+						   &(msg->data), buffer);
+		break;
 	case RESPONSE_JOB_ALLOCATION_INFO:
 		rc = _unpack_job_alloc_info_response_msg(
 			(job_alloc_info_response_msg_t **)
@@ -829,6 +880,10 @@ unpack_msg(slurm_msg_t * msg, Buf buffer)
 		rc = _unpack_cancel_tasks_msg((kill_tasks_msg_t **) &
 					      (msg->data), buffer);
 		break;
+	case REQUEST_CHECKPOINT_TASKS:
+		rc = _unpack_checkpoint_tasks_msg((checkpoint_tasks_msg_t **) &
+						  (msg->data), buffer);
+		break;
 	case REQUEST_JOB_STEP_INFO:
 		rc = _unpack_job_step_info_req_msg(
 			(job_step_info_request_msg_t **)
@@ -969,6 +1024,10 @@ unpack_msg(slurm_msg_t * msg, Buf buffer)
 		rc = _unpack_checkpoint_comp((checkpoint_comp_msg_t **)
 					     & msg->data, buffer);
 		break;
+	case REQUEST_CHECKPOINT_TASK_COMP:
+		rc = _unpack_checkpoint_task_comp((checkpoint_task_comp_msg_t **)
+						  & msg->data, buffer);
+		break;
 	case RESPONSE_CHECKPOINT:
 	case RESPONSE_CHECKPOINT_COMP:
 		rc = _unpack_checkpoint_resp_msg((checkpoint_resp_msg_t **)
@@ -1020,6 +1079,19 @@ unpack_msg(slurm_msg_t * msg, Buf buffer)
 		rc = _unpack_slurmd_status((slurmd_status_t **)
 					&msg->data, buffer);
 		break;
+	case REQUEST_JOB_NOTIFY:
+		rc =  _unpack_job_notify((job_notify_msg_t **)
+					 &msg->data, buffer);
+		break;
+	case REQUEST_SET_DEBUG_LEVEL:
+		rc = _unpack_set_debug_level_msg(
+			(set_debug_level_msg_t **)&(msg->data), buffer);
+		break;
+	case ACCOUNTING_UPDATE_MSG:
+		_unpack_accounting_update_msg(
+			(accounting_update_msg_t **)&msg->data,
+			buffer);
+		break;
 	default:
 		debug("No unpack method for msg type %u", msg->msg_type);
 		return EINVAL;
@@ -1045,7 +1117,7 @@ _pack_update_node_msg(update_node_msg_t * msg, Buf buffer)
 static int
 _unpack_update_node_msg(update_node_msg_t ** msg, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	update_node_msg_t *tmp_ptr;
 
 	/* alloc memory for structure */
@@ -1053,10 +1125,10 @@ _unpack_update_node_msg(update_node_msg_t ** msg, Buf buffer)
 	tmp_ptr = xmalloc(sizeof(update_node_msg_t));
 	*msg = tmp_ptr;
 
-	safe_unpackstr_xmalloc(&tmp_ptr->node_names, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->node_names, &uint32_tmp, buffer);
 	safe_unpack16(&tmp_ptr->node_state, buffer);
-	safe_unpackstr_xmalloc(&tmp_ptr->features, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&tmp_ptr->reason, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->features, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->reason, &uint32_tmp, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -1078,12 +1150,14 @@ _pack_node_registration_status_msg(slurm_node_registration_status_msg_t *
 	pack_time(msg->timestamp, buffer);
 	pack32((uint32_t)msg->status, buffer);
 	packstr(msg->node_name, buffer);
+	packstr(msg->arch, buffer);
+	packstr(msg->os, buffer);
 	pack16((uint32_t)msg->cpus, buffer);
 	pack16((uint32_t)msg->sockets, buffer);
 	pack16((uint32_t)msg->cores, buffer);
 	pack16((uint32_t)msg->threads, buffer);
-	pack32((uint32_t)msg->real_memory_size, buffer);
-	pack32((uint32_t)msg->temporary_disk_space, buffer);
+	pack32((uint32_t)msg->real_memory, buffer);
+	pack32((uint32_t)msg->tmp_disk, buffer);
 	pack32((uint32_t)msg->job_count, buffer);
 	for (i = 0; i < msg->job_count; i++) {
 		pack32((uint32_t)msg->job_id[i], buffer);
@@ -1100,7 +1174,7 @@ static int
 _unpack_node_registration_status_msg(slurm_node_registration_status_msg_t
 				     ** msg, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	int i;
 	slurm_node_registration_status_msg_t *node_reg_ptr;
 
@@ -1113,13 +1187,15 @@ _unpack_node_registration_status_msg(slurm_node_registration_status_msg_t
 	safe_unpack_time(&node_reg_ptr->timestamp, buffer);
 	/* load the data values */
 	safe_unpack32(&node_reg_ptr->status, buffer);
-	safe_unpackstr_xmalloc(&node_reg_ptr->node_name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_reg_ptr->node_name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_reg_ptr->arch, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_reg_ptr->os, &uint32_tmp, buffer);
 	safe_unpack16(&node_reg_ptr->cpus, buffer);
 	safe_unpack16(&node_reg_ptr->sockets, buffer);
 	safe_unpack16(&node_reg_ptr->cores, buffer);
 	safe_unpack16(&node_reg_ptr->threads, buffer);
-	safe_unpack32(&node_reg_ptr->real_memory_size, buffer);
-	safe_unpack32(&node_reg_ptr->temporary_disk_space, buffer);
+	safe_unpack32(&node_reg_ptr->real_memory, buffer);
+	safe_unpack32(&node_reg_ptr->tmp_disk, buffer);
 	safe_unpack32(&node_reg_ptr->job_count, buffer);
 	node_reg_ptr->job_id =
 		xmalloc(sizeof(uint32_t) * node_reg_ptr->job_count);
@@ -1141,8 +1217,10 @@ _unpack_node_registration_status_msg(slurm_node_registration_status_msg_t
 	return SLURM_SUCCESS;
 
 unpack_error:
-	xfree(node_reg_ptr->node_name);
+	xfree(node_reg_ptr->arch);
 	xfree(node_reg_ptr->job_id);
+	xfree(node_reg_ptr->node_name);
+	xfree(node_reg_ptr->os);
 	xfree(node_reg_ptr->step_id);
 	switch_g_free_node_info(&node_reg_ptr->switch_nodeinfo);
 	xfree(node_reg_ptr);
@@ -1175,7 +1253,6 @@ static int
 _unpack_resource_allocation_response_msg(resource_allocation_response_msg_t
 					 ** msg, Buf buffer)
 {
-	uint16_t uint16_tmp;
 	uint32_t uint32_tmp;
 	resource_allocation_response_msg_t *tmp_ptr;
 
@@ -1187,7 +1264,7 @@ _unpack_resource_allocation_response_msg(resource_allocation_response_msg_t
 	/* load the data values */
 	safe_unpack32(&tmp_ptr->error_code, buffer);
 	safe_unpack32(&tmp_ptr->job_id, buffer);
-	safe_unpackstr_xmalloc(&tmp_ptr->node_list, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->node_list, &uint32_tmp, buffer);
 
 	safe_unpack16(&tmp_ptr->num_cpu_groups, buffer);
 	if (tmp_ptr->num_cpu_groups > 0) {
@@ -1251,7 +1328,6 @@ static int
 _unpack_job_alloc_info_response_msg(job_alloc_info_response_msg_t ** msg, 
 				    Buf buffer)
 {
-	uint16_t uint16_tmp;
 	uint32_t uint32_tmp;
 	job_alloc_info_response_msg_t *tmp_ptr;
 
@@ -1263,7 +1339,7 @@ _unpack_job_alloc_info_response_msg(job_alloc_info_response_msg_t ** msg,
 	/* load the data values */
 	safe_unpack32(&tmp_ptr->error_code, buffer);
 	safe_unpack32(&tmp_ptr->job_id, buffer);
-	safe_unpackstr_xmalloc(&tmp_ptr->node_list, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->node_list, &uint32_tmp, buffer);
 
 	safe_unpack16(&tmp_ptr->num_cpu_groups, buffer);
 	if (tmp_ptr->num_cpu_groups > 0) {
@@ -1285,9 +1361,9 @@ _unpack_job_alloc_info_response_msg(job_alloc_info_response_msg_t ** msg,
 	safe_unpack32(&tmp_ptr->node_cnt, buffer);
 	if (tmp_ptr->node_cnt > 0) {
 		if (_unpack_slurm_addr_array(&(tmp_ptr->node_addr),
-					     &uint16_tmp, buffer))
+					     &uint32_tmp, buffer))
 			goto unpack_error;
-		if (uint16_tmp != tmp_ptr->node_cnt)
+		if (uint32_tmp != tmp_ptr->node_cnt)
 			goto unpack_error;
 	} else
 		tmp_ptr->node_addr = NULL;
@@ -1374,11 +1450,11 @@ unpack_error:
 static int
 _unpack_node_info_members(node_info_t * node, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 
 	xassert(node != NULL);
 
-	safe_unpackstr_xmalloc(&node->name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&node->name, &uint32_tmp, buffer);
 	safe_unpack16(&node->node_state, buffer);
 	safe_unpack16(&node->cpus, buffer);
 	safe_unpack16(&node->sockets, buffer);
@@ -1390,14 +1466,18 @@ _unpack_node_info_members(node_info_t * node, Buf buffer)
 	safe_unpack32(&node->weight, buffer);
 	safe_unpack16(&node->used_cpus, buffer);
 
-	safe_unpackstr_xmalloc(&node->features, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&node->reason, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&node->arch, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node->features, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node->os, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node->reason, &uint32_tmp, buffer);
 
 	return SLURM_SUCCESS;
 
 unpack_error:
 	xfree(node->name);
+	xfree(node->arch);
 	xfree(node->features);
+	xfree(node->os);
 	xfree(node->reason);
 	return SLURM_ERROR;
 }
@@ -1423,16 +1503,17 @@ _pack_update_partition_msg(update_part_msg_t * msg, Buf buffer)
 	packstr(msg->name,         buffer);
 	packstr(msg->nodes,        buffer);
 
-	pack16(msg-> hidden,      buffer);
+	pack16(msg-> hidden,       buffer);
+	pack16(msg-> max_share,    buffer);
+	pack16(msg-> priority,     buffer);
 	pack16(msg-> root_only,    buffer);
-	pack16(msg-> shared,       buffer);
 	pack16(msg-> state_up,     buffer);
 }
 
 static int
 _unpack_update_partition_msg(update_part_msg_t ** msg, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	update_part_msg_t *tmp_ptr;
 
 	xassert(msg != NULL);
@@ -1441,18 +1522,19 @@ _unpack_update_partition_msg(update_part_msg_t ** msg, Buf buffer)
 	tmp_ptr = xmalloc(sizeof(update_part_msg_t));
 	*msg = tmp_ptr;
 
-	safe_unpackstr_xmalloc(&tmp_ptr->allow_groups, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->allow_groups, &uint32_tmp, buffer);
 	safe_unpack16(&tmp_ptr->default_part, buffer);
 	safe_unpack32(&tmp_ptr->max_time, buffer);
 	safe_unpack32(&tmp_ptr->max_nodes, buffer);
 	safe_unpack32(&tmp_ptr->min_nodes, buffer);
-	safe_unpackstr_xmalloc(&tmp_ptr->name, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&tmp_ptr->nodes, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->nodes, &uint32_tmp, buffer);
 
-	safe_unpack16(&tmp_ptr->hidden, buffer);
+	safe_unpack16(&tmp_ptr->hidden,    buffer);
+	safe_unpack16(&tmp_ptr->max_share, buffer);
+	safe_unpack16(&tmp_ptr->priority,  buffer);
 	safe_unpack16(&tmp_ptr->root_only, buffer);
-	safe_unpack16(&tmp_ptr->shared, buffer);
-	safe_unpack16(&tmp_ptr->state_up, buffer);
+	safe_unpack16(&tmp_ptr->state_up,  buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -1475,7 +1557,7 @@ _pack_delete_partition_msg(delete_part_msg_t * msg, Buf buffer)
 static int
 _unpack_delete_partition_msg(delete_part_msg_t ** msg, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	delete_part_msg_t *tmp_ptr;
 
 	xassert(msg != NULL);
@@ -1484,7 +1566,7 @@ _unpack_delete_partition_msg(delete_part_msg_t ** msg, Buf buffer)
 	tmp_ptr = xmalloc(sizeof(delete_part_msg_t));
 	*msg = tmp_ptr;
 
-	safe_unpackstr_xmalloc(&tmp_ptr->name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&tmp_ptr->name, &uint32_tmp, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -1510,11 +1592,16 @@ _pack_job_step_create_request_msg(job_step_create_request_msg_t
 	pack16(msg->task_dist, buffer);
 	pack16(msg->plane_size, buffer);
 	pack16(msg->port, buffer);
+	pack16(msg->ckpt_interval, buffer);
+	pack16(msg->exclusive, buffer);
+	pack16(msg->immediate, buffer);
+	pack16(msg->mem_per_task, buffer);
 
 	packstr(msg->host, buffer);
 	packstr(msg->name, buffer);
 	packstr(msg->network, buffer);
 	packstr(msg->node_list, buffer);
+	packstr(msg->ckpt_path, buffer);
 
 	pack8(msg->overcommit, buffer);
 }
@@ -1523,7 +1610,7 @@ static int
 _unpack_job_step_create_request_msg(job_step_create_request_msg_t ** msg,
 				    Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	job_step_create_request_msg_t *tmp_ptr;
 
 	/* alloc memory for structure */
@@ -1541,11 +1628,16 @@ _unpack_job_step_create_request_msg(job_step_create_request_msg_t ** msg,
 	safe_unpack16(&(tmp_ptr->task_dist), buffer);
 	safe_unpack16(&(tmp_ptr->plane_size), buffer);
 	safe_unpack16(&(tmp_ptr->port), buffer);
+	safe_unpack16(&(tmp_ptr->ckpt_interval), buffer);
+	safe_unpack16(&(tmp_ptr->exclusive), buffer);
+	safe_unpack16(&(tmp_ptr->immediate), buffer);
+	safe_unpack16(&(tmp_ptr->mem_per_task), buffer);
 
-	safe_unpackstr_xmalloc(&(tmp_ptr->host), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(tmp_ptr->name), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(tmp_ptr->network), &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&(tmp_ptr->node_list), &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&(tmp_ptr->host), &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(tmp_ptr->name), &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(tmp_ptr->network), &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(tmp_ptr->node_list), &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&(tmp_ptr->ckpt_path), &uint32_tmp, buffer);
 
 	safe_unpack8(&(tmp_ptr->overcommit), buffer);
 
@@ -1566,8 +1658,9 @@ _pack_kill_job_msg(kill_job_msg_t * msg, Buf buffer)
 {
 	xassert(msg != NULL);
 
-	pack32((uint32_t)msg->job_id,  buffer);
-	pack32((uint32_t)msg->job_uid, buffer);
+	pack32(msg->job_id,  buffer);
+	pack16(msg->job_state, buffer);
+	pack32(msg->job_uid, buffer);
 	pack_time(msg->time, buffer);
 	packstr(msg->nodes, buffer);
 	select_g_pack_jobinfo(msg->select_jobinfo, buffer);
@@ -1576,7 +1669,7 @@ _pack_kill_job_msg(kill_job_msg_t * msg, Buf buffer)
 static int
 _unpack_kill_job_msg(kill_job_msg_t ** msg, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	kill_job_msg_t *tmp_ptr;
 
 	/* alloc memory for structure */
@@ -1585,9 +1678,10 @@ _unpack_kill_job_msg(kill_job_msg_t ** msg, Buf buffer)
 	*msg = tmp_ptr;
 
 	safe_unpack32(&(tmp_ptr->job_id),  buffer);
+	safe_unpack16(&(tmp_ptr->job_state),  buffer);
 	safe_unpack32(&(tmp_ptr->job_uid), buffer);
 	safe_unpack_time(&(tmp_ptr->time), buffer);
-	safe_unpackstr_xmalloc(&(tmp_ptr->nodes), &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&(tmp_ptr->nodes), &uint32_tmp, buffer);
 	if (select_g_alloc_jobinfo (&tmp_ptr->select_jobinfo)
 	    ||  select_g_unpack_jobinfo(tmp_ptr->select_jobinfo, buffer))
 		goto unpack_error;
@@ -1648,7 +1742,7 @@ static int
 _unpack_epilog_comp_msg(epilog_complete_msg_t ** msg, Buf buffer)
 {
 	epilog_complete_msg_t *tmp_ptr;
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 
 	/* alloc memory for structure */
 	xassert(msg);
@@ -1657,7 +1751,7 @@ _unpack_epilog_comp_msg(epilog_complete_msg_t ** msg, Buf buffer)
 
 	safe_unpack32(&(tmp_ptr->job_id), buffer);
 	safe_unpack32(&(tmp_ptr->return_code), buffer);
-	safe_unpackstr_xmalloc(& (tmp_ptr->node_name), &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(& (tmp_ptr->node_name), &uint32_tmp, buffer);
 	if (switch_g_alloc_node_info(&tmp_ptr->switch_nodeinfo)
 	    ||  switch_g_unpack_node_info(tmp_ptr->switch_nodeinfo, buffer))
 		goto unpack_error;
@@ -1789,10 +1883,10 @@ unpack_error:
 static int
 _unpack_partition_info_members(partition_info_t * part, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	char *node_inx_str = NULL;
 
-	safe_unpackstr_xmalloc(&part->name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&part->name, &uint32_tmp, buffer);
 	if (part->name == NULL)
 		part->name = xmalloc(1);	/* part->name = "" implicit */
 	safe_unpack32(&part->max_time,     buffer);
@@ -1803,14 +1897,16 @@ _unpack_partition_info_members(partition_info_t * part, Buf buffer)
 	
 	safe_unpack32(&part->total_cpus,   buffer);
 	safe_unpack16(&part->default_part, buffer);
+	safe_unpack16(&part->disable_root_jobs, buffer);
 	safe_unpack16(&part->hidden,       buffer);
 	safe_unpack16(&part->root_only,    buffer);
-	safe_unpack16(&part->shared,       buffer);
+	safe_unpack16(&part->max_share,    buffer);
+	safe_unpack16(&part->priority,     buffer);
 
 	safe_unpack16(&part->state_up, buffer);
-	safe_unpackstr_xmalloc(&part->allow_groups, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&part->nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&part->allow_groups, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&part->nodes, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_inx_str, &uint32_tmp, buffer);
 	if (node_inx_str == NULL)
 		part->node_inx = bitfmt2int("");
 	else {
@@ -1880,21 +1976,23 @@ unpack_error:
 static int
 _unpack_job_step_info_members(job_step_info_t * step, Buf buffer)
 {
-	uint16_t uint16_tmp = 0;
+	uint32_t uint32_tmp = 0;
 	char *node_inx_str;
 
 	safe_unpack32(&step->job_id, buffer);
 	safe_unpack16(&step->step_id, buffer);
+	safe_unpack16(&step->ckpt_interval, buffer);
 	safe_unpack32(&step->user_id, buffer);
 	safe_unpack32(&step->num_tasks, buffer);
 
 	safe_unpack_time(&step->start_time, buffer);
 	safe_unpack_time(&step->run_time, buffer);
-	safe_unpackstr_xmalloc(&step->partition, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&step->nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&step->name, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&step->network, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&step->partition, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&step->nodes, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&step->name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&step->network, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_inx_str, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&step->ckpt_path, &uint32_tmp, buffer);
 	if (node_inx_str == NULL)
 		step->node_inx = bitfmt2int("");
 	else {
@@ -1987,7 +2085,6 @@ unpack_error:
 static int
 _unpack_job_info_members(job_info_t * job, Buf buffer)
 {
-	uint16_t uint16_tmp;
 	uint32_t uint32_tmp;
 	char *node_inx_str;
 	multi_core_data_t *mc_ptr;
@@ -2010,21 +2107,21 @@ _unpack_job_info_members(job_info_t * job, Buf buffer)
 	safe_unpack_time(&job->pre_sus_time, buffer);
 	safe_unpack32(&job->priority, buffer);
 
-	safe_unpackstr_xmalloc(&job->nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job->partition, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job->account, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job->network, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job->comment, &uint16_tmp, buffer);
-	safe_unpack32(&job->dependency, buffer);
-	safe_unpack32(&job->exit_code, buffer);
+	safe_unpackstr_xmalloc(&job->nodes, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->partition, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->account, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->network, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->comment, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->licenses,   &uint32_tmp, buffer);
 
+	safe_unpack32(&job->exit_code, buffer);
 	safe_unpack16(&job->num_cpu_groups, buffer);
 	safe_unpack32_array(&job->cpus_per_node, &uint32_tmp, buffer);
 	safe_unpack32_array(&job->cpu_count_reps, &uint32_tmp, buffer);
 
-	safe_unpackstr_xmalloc(&job->name, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job->alloc_node, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->alloc_node, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_inx_str, &uint32_tmp, buffer);
 	if (node_inx_str == NULL)
 		job->node_inx = bitfmt2int("");
 	else {
@@ -2038,10 +2135,14 @@ _unpack_job_info_members(job_info_t * job, Buf buffer)
 		goto unpack_error;
 
 	/*** unpack default job details ***/
-	safe_unpackstr_xmalloc(&job->features, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->features,   &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->work_dir,   &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->dependency, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->command,    &uint32_tmp, buffer);
+
 	safe_unpack32(&job->num_nodes, buffer);
 	safe_unpack32(&job->max_nodes, buffer);
-
+	safe_unpack16(&job->requeue,   buffer);
 
 	/*** unpack pending job details ***/
 	safe_unpack16(&job->shared, buffer);
@@ -2050,19 +2151,18 @@ _unpack_job_info_members(job_info_t * job, Buf buffer)
 	safe_unpack16(&job->job_min_procs, buffer);
 
 	safe_unpack32(&job->job_min_memory, buffer);
-	safe_unpack32(&job->job_max_memory, buffer);
 	safe_unpack32(&job->job_min_tmp_disk, buffer);
 
-	safe_unpackstr_xmalloc(&job->req_nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->req_nodes, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_inx_str, &uint32_tmp, buffer);
 	if (node_inx_str == NULL)
 		job->req_node_inx = bitfmt2int("");
 	else {
 		job->req_node_inx = bitfmt2int(node_inx_str);
 		xfree(node_inx_str);
 	}
-	safe_unpackstr_xmalloc(&job->exc_nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&node_inx_str, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job->exc_nodes, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&node_inx_str, &uint32_tmp, buffer);
 	if (node_inx_str == NULL)
 		job->exc_node_inx = bitfmt2int("");
 	else {
@@ -2093,17 +2193,24 @@ unpack_error:
 	xfree(job->nodes);
 	xfree(job->partition);
 	xfree(job->account);
+	xfree(job->network);
+	xfree(job->comment);
+	xfree(job->dependency);
+	xfree(job->cpus_per_node);
+	xfree(job->cpu_count_reps);
 	xfree(job->name);
 	xfree(job->alloc_node);
 	xfree(job->node_inx);
 	select_g_free_jobinfo(&job->select_jobinfo);
 	xfree(job->features);
+	xfree(job->work_dir);
+	xfree(job->command);
+	xfree(job->licenses);
 	xfree(job->req_nodes);
 	xfree(job->req_node_inx);
 	xfree(job->exc_nodes);
 	xfree(job->exc_node_inx);
-	xfree(job->network);
-	xfree(job->comment);
+
 	return SLURM_ERROR;
 }
 
@@ -2111,80 +2218,142 @@ static void
 _pack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t * build_ptr, Buf buffer)
 {
 	pack_time(build_ptr->last_update, buffer);
+
+	pack16(build_ptr->accounting_storage_enforce, buffer);
+	packstr(build_ptr->accounting_storage_host, buffer);
+	packstr(build_ptr->accounting_storage_loc, buffer);
+	packstr(build_ptr->accounting_storage_pass, buffer);
+	pack32(build_ptr->accounting_storage_port, buffer);
+	packstr(build_ptr->accounting_storage_type, buffer);
+	packstr(build_ptr->accounting_storage_user, buffer);
+
 	packstr(build_ptr->authtype, buffer);
+
 	packstr(build_ptr->backup_addr, buffer);
 	packstr(build_ptr->backup_controller, buffer);
-	pack16((uint16_t)build_ptr->cache_groups, buffer);
+	pack_time(build_ptr->boot_time, buffer);
+
+	pack16(build_ptr->cache_groups, buffer);
 	packstr(build_ptr->checkpoint_type, buffer);
+	packstr(build_ptr->cluster_name, buffer);
 	packstr(build_ptr->control_addr, buffer);
 	packstr(build_ptr->control_machine, buffer);
+	packstr(build_ptr->crypto_type, buffer);
+
+	pack32(build_ptr->def_mem_per_task, buffer);
+	pack16(build_ptr->disable_root_jobs, buffer);
+
 	packstr(build_ptr->epilog, buffer);
-	pack16((uint16_t)build_ptr->fast_schedule, buffer);
-	pack32((uint32_t)build_ptr->first_job_id, buffer);
-	pack16((uint16_t)build_ptr->inactive_limit, buffer);
-	packstr(build_ptr->job_acct_logfile, buffer);
-	pack16(build_ptr->job_acct_freq, buffer);
-	packstr(build_ptr->job_acct_type, buffer);
+	pack32(build_ptr->epilog_msg_time, buffer);
+
+	pack16(build_ptr->fast_schedule, buffer);
+	pack32(build_ptr->first_job_id, buffer);
+
+	pack16(build_ptr->get_env_timeout, buffer);
+
+	pack16(build_ptr->health_check_interval, buffer);
+	packstr(build_ptr->health_check_program, buffer);
+
+	pack16(build_ptr->inactive_limit, buffer);
+
+	pack16(build_ptr->job_acct_gather_freq, buffer);
+	packstr(build_ptr->job_acct_gather_type, buffer);
+
+	packstr(build_ptr->job_comp_host, buffer);
 	packstr(build_ptr->job_comp_loc, buffer);
+	packstr(build_ptr->job_comp_pass, buffer);
+	pack32((uint32_t)build_ptr->job_comp_port, buffer);
 	packstr(build_ptr->job_comp_type, buffer);
-	pack16((uint16_t)build_ptr->kill_wait, buffer);
+	packstr(build_ptr->job_comp_user, buffer);
+
+	packstr(build_ptr->job_credential_private_key, buffer);
+	packstr(build_ptr->job_credential_public_certificate, buffer);
+	pack16(build_ptr->job_file_append, buffer);
+	pack16(build_ptr->job_requeue, buffer);
+
+	pack16(build_ptr->kill_wait, buffer);
+
+	packstr(build_ptr->licenses, buffer);
+
 	packstr(build_ptr->mail_prog, buffer);
-	pack16((uint16_t)build_ptr->max_job_cnt, buffer);
-	pack16((uint16_t)build_ptr->min_job_age, buffer);
+	pack16(build_ptr->max_job_cnt, buffer);
+	pack32(build_ptr->max_mem_per_task, buffer);
+	pack16(build_ptr->min_job_age, buffer);
 	packstr(build_ptr->mpi_default, buffer);
-	pack16((uint16_t)build_ptr->msg_timeout, buffer);
-	pack32((uint32_t)build_ptr->next_job_id, buffer);
+	pack16(build_ptr->msg_timeout, buffer);
+
+	pack32(build_ptr->next_job_id, buffer);
+	packstr(build_ptr->node_prefix, buffer);
+
 	packstr(build_ptr->plugindir, buffer);
 	packstr(build_ptr->plugstack, buffer);
+	pack16(build_ptr->private_data, buffer);
 	packstr(build_ptr->proctrack_type, buffer);
 	packstr(build_ptr->prolog, buffer);
 	pack16(build_ptr->propagate_prio_process, buffer);
         packstr(build_ptr->propagate_rlimits, buffer);
         packstr(build_ptr->propagate_rlimits_except, buffer);
-	pack16((uint16_t)build_ptr->ret2service, buffer);
-	pack16((uint16_t)build_ptr->schedport, buffer);
-	pack16((uint16_t)build_ptr->schedrootfltr, buffer);
+
+	packstr(build_ptr->resume_program, buffer);
+	pack16(build_ptr->resume_rate, buffer);
+	pack16(build_ptr->ret2service, buffer);
+
+	packstr(build_ptr->sched_params, buffer);
+	pack16(build_ptr->schedport, buffer);
+	pack16(build_ptr->schedrootfltr, buffer);
+	pack16(build_ptr->sched_time_slice, buffer);
 	packstr(build_ptr->schedtype, buffer);
 	packstr(build_ptr->select_type, buffer);
-	pack16((uint16_t)build_ptr->select_type_param, buffer);
-	pack32((uint32_t)build_ptr->slurm_user_id, buffer);
+	pack16(build_ptr->select_type_param, buffer);
+
+	packstr(build_ptr->slurm_conf, buffer);
+	pack32(build_ptr->slurm_user_id, buffer);
 	packstr(build_ptr->slurm_user_name, buffer);
-	pack16((uint16_t)build_ptr->slurmctld_debug, buffer);
+
+	pack16(build_ptr->slurmctld_debug, buffer);
 	packstr(build_ptr->slurmctld_logfile, buffer);
 	packstr(build_ptr->slurmctld_pidfile, buffer);
-	pack32((uint32_t)build_ptr->slurmctld_port, buffer);
-	pack16((uint16_t)build_ptr->slurmctld_timeout, buffer);
-	pack16((uint16_t)build_ptr->slurmd_debug, buffer);
+	pack32(build_ptr->slurmctld_port, buffer);
+	pack16(build_ptr->slurmctld_timeout, buffer);
+
+	pack16(build_ptr->slurmd_debug, buffer);
 	packstr(build_ptr->slurmd_logfile, buffer);
 	packstr(build_ptr->slurmd_pidfile, buffer);
 #ifndef MULTIPLE_SLURMD
-	pack32((uint32_t)build_ptr->slurmd_port, buffer);
+	pack32(build_ptr->slurmd_port, buffer);
 #endif
 	packstr(build_ptr->slurmd_spooldir, buffer);
-	pack16((uint16_t)build_ptr->slurmd_timeout, buffer);
-	packstr(build_ptr->slurm_conf, buffer);
+	pack16(build_ptr->slurmd_timeout, buffer);
+
+	packstr(build_ptr->srun_epilog, buffer);
+	packstr(build_ptr->srun_prolog, buffer);
 	packstr(build_ptr->state_save_location, buffer);
+	packstr(build_ptr->suspend_exc_nodes, buffer);
+	packstr(build_ptr->suspend_exc_parts, buffer);
+	packstr(build_ptr->suspend_program, buffer);
+	pack16(build_ptr->suspend_rate, buffer);
+	pack16(build_ptr->suspend_time, buffer);
 	packstr(build_ptr->switch_type, buffer);
+
 	packstr(build_ptr->task_epilog, buffer);
 	packstr(build_ptr->task_prolog, buffer);
 	packstr(build_ptr->task_plugin, buffer);
 	pack16(build_ptr->task_plugin_param, buffer);
 	packstr(build_ptr->tmp_fs, buffer);
-	pack16((uint16_t)build_ptr->wait_time, buffer);
-	packstr(build_ptr->job_credential_private_key, buffer);
-	packstr(build_ptr->job_credential_public_certificate, buffer);
-	packstr(build_ptr->srun_prolog, buffer);
-	packstr(build_ptr->srun_epilog, buffer);
-	packstr(build_ptr->node_prefix, buffer);
-	pack16((uint16_t)build_ptr->tree_width, buffer);
+	pack16(build_ptr->tree_width, buffer);
+
 	pack16(build_ptr->use_pam, buffer);
+	packstr(build_ptr->unkillable_program, buffer);
+	pack16(build_ptr->unkillable_timeout, buffer);
+
+	pack16(build_ptr->wait_time, buffer);
 }
 
 static int
 _unpack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t **
 			   build_buffer_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	slurm_ctl_conf_info_msg_t *build_ptr;
 
 	/* alloc memory for structure */
@@ -2194,115 +2363,204 @@ _unpack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t **
 	/* load the data values */
 	/* unpack timestamp of snapshot */
 	safe_unpack_time(&build_ptr->last_update, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->authtype, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->backup_addr, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->backup_controller, &uint16_tmp,
+
+	safe_unpack16(&build_ptr->accounting_storage_enforce, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->accounting_storage_host, 
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->accounting_storage_loc,
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->accounting_storage_pass, 
+			       &uint32_tmp, buffer);
+	safe_unpack32(&build_ptr->accounting_storage_port, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->accounting_storage_type, 
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->accounting_storage_user, 
+			       &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->authtype, &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->backup_addr, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->backup_controller, &uint32_tmp,
 			       buffer);
+	safe_unpack_time(&build_ptr->boot_time, buffer);
+
 	safe_unpack16(&build_ptr->cache_groups, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->checkpoint_type, &uint16_tmp,
+	safe_unpackstr_xmalloc(&build_ptr->checkpoint_type, &uint32_tmp,
+			       buffer);
+	safe_unpackstr_xmalloc(&build_ptr->cluster_name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->control_addr, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->control_machine, &uint32_tmp,
 			       buffer);
-	safe_unpackstr_xmalloc(&build_ptr->control_addr, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->control_machine, &uint16_tmp,
+	safe_unpackstr_xmalloc(&build_ptr->crypto_type, &uint32_tmp,
 			       buffer);
-	safe_unpackstr_xmalloc(&build_ptr->epilog, &uint16_tmp, buffer);
+
+	safe_unpack32(&build_ptr->def_mem_per_task, buffer);
+	safe_unpack16(&build_ptr->disable_root_jobs, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->epilog, &uint32_tmp, buffer);
+	safe_unpack32(&build_ptr->epilog_msg_time, buffer);
+
 	safe_unpack16(&build_ptr->fast_schedule, buffer);
 	safe_unpack32(&build_ptr->first_job_id, buffer);
+
+	safe_unpack16(&build_ptr->get_env_timeout, buffer);
+
+	safe_unpack16(&build_ptr->health_check_interval, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->health_check_program,
+			       &uint32_tmp, buffer);
+
 	safe_unpack16(&build_ptr->inactive_limit, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->job_acct_logfile, &uint16_tmp, 
-			       buffer);
-	safe_unpack16(&build_ptr->job_acct_freq, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->job_acct_type, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->job_comp_loc, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->job_comp_type, &uint16_tmp, buffer);
+
+	safe_unpack16(&build_ptr->job_acct_gather_freq, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->job_acct_gather_type,
+			       &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->job_comp_host, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->job_comp_loc,  &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->job_comp_pass, &uint32_tmp, buffer);
+	safe_unpack32(&build_ptr->job_comp_port, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->job_comp_type, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->job_comp_user, &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->job_credential_private_key,
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->
+			       job_credential_public_certificate,
+			       &uint32_tmp, buffer);
+	safe_unpack16(&build_ptr->job_file_append, buffer);
+	safe_unpack16(&build_ptr->job_requeue, buffer);
+
 	safe_unpack16(&build_ptr->kill_wait, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->mail_prog, &uint16_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->licenses, &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->mail_prog, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->max_job_cnt, buffer);
+	safe_unpack32(&build_ptr->max_mem_per_task, buffer);
 	safe_unpack16(&build_ptr->min_job_age, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->mpi_default, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->mpi_default, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->msg_timeout, buffer);
+
 	safe_unpack32(&build_ptr->next_job_id, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->plugindir, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->plugstack, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->proctrack_type, &uint16_tmp, 
+	safe_unpackstr_xmalloc(&build_ptr->node_prefix, &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->plugindir, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->plugstack, &uint32_tmp, buffer);
+	safe_unpack16(&build_ptr->private_data, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->proctrack_type, &uint32_tmp, 
 			       buffer);
-	safe_unpackstr_xmalloc(&build_ptr->prolog, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->prolog, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->propagate_prio_process, buffer);
         safe_unpackstr_xmalloc(&build_ptr->propagate_rlimits,
-                               &uint16_tmp, buffer);
+                               &uint32_tmp, buffer);
         safe_unpackstr_xmalloc(&build_ptr->propagate_rlimits_except,
-                               &uint16_tmp, buffer);
+                               &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->resume_program,
+			       &uint32_tmp, buffer);
+	safe_unpack16(&build_ptr->resume_rate, buffer);
 	safe_unpack16(&build_ptr->ret2service, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->sched_params, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->schedport, buffer);
 	safe_unpack16(&build_ptr->schedrootfltr, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->schedtype, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->select_type, &uint16_tmp, buffer);
+	safe_unpack16(&build_ptr->sched_time_slice, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->schedtype, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->select_type, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->select_type_param, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->slurm_conf,
+			       &uint32_tmp, buffer);
 	safe_unpack32(&build_ptr->slurm_user_id, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->slurm_user_name,
-			       &uint16_tmp, buffer);
+			       &uint32_tmp, buffer);
+
 	safe_unpack16(&build_ptr->slurmctld_debug, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->slurmctld_logfile,
-			       &uint16_tmp, buffer);
+			       &uint32_tmp, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->slurmctld_pidfile,
-			       &uint16_tmp, buffer);
+			       &uint32_tmp, buffer);
 	safe_unpack32(&build_ptr->slurmctld_port, buffer);
 	safe_unpack16(&build_ptr->slurmctld_timeout, buffer);
+
 	safe_unpack16(&build_ptr->slurmd_debug, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->slurmd_logfile, &uint16_tmp,
+	safe_unpackstr_xmalloc(&build_ptr->slurmd_logfile, &uint32_tmp,
 			       buffer);
-	safe_unpackstr_xmalloc(&build_ptr->slurmd_pidfile, &uint16_tmp,
+	safe_unpackstr_xmalloc(&build_ptr->slurmd_pidfile, &uint32_tmp,
 			       buffer);
 #ifndef MULTIPLE_SLURMD
 	safe_unpack32(&build_ptr->slurmd_port, buffer);
 #endif
-	safe_unpackstr_xmalloc(&build_ptr->slurmd_spooldir, &uint16_tmp,
+	safe_unpackstr_xmalloc(&build_ptr->slurmd_spooldir, &uint32_tmp,
 			       buffer);
 	safe_unpack16(&build_ptr->slurmd_timeout, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->slurm_conf, &uint16_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->srun_epilog, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->srun_prolog, &uint32_tmp, buffer);
 	safe_unpackstr_xmalloc(&build_ptr->state_save_location,
-			       &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->switch_type, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->task_epilog, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->task_prolog, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->task_plugin, &uint16_tmp, buffer);
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->suspend_exc_nodes,
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->suspend_exc_parts,
+			       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->suspend_program,
+			       &uint32_tmp, buffer);
+	safe_unpack16(&build_ptr->suspend_rate, buffer);
+	safe_unpack16(&build_ptr->suspend_time, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->switch_type, &uint32_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&build_ptr->task_epilog, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->task_prolog, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->task_plugin, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->task_plugin_param, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->tmp_fs, &uint16_tmp, buffer);
-	safe_unpack16(&build_ptr->wait_time, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->job_credential_private_key,
-			       &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->
-			       job_credential_public_certificate,
-			       &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->srun_prolog, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->srun_epilog, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&build_ptr->node_prefix, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->tmp_fs, &uint32_tmp, buffer);
 	safe_unpack16(&build_ptr->tree_width, buffer);
+
 	safe_unpack16(&build_ptr->use_pam, buffer);
+	safe_unpackstr_xmalloc(&build_ptr->unkillable_program,
+			       &uint32_tmp, buffer);
+	safe_unpack16(&build_ptr->unkillable_timeout, buffer);
+
+	safe_unpack16(&build_ptr->wait_time, buffer);
 
 	return SLURM_SUCCESS;
 
 unpack_error:
+	xfree(build_ptr->accounting_storage_host);
+	xfree(build_ptr->accounting_storage_loc);
+	xfree(build_ptr->accounting_storage_pass);
+	xfree(build_ptr->accounting_storage_type);
+	xfree(build_ptr->accounting_storage_user);
 	xfree(build_ptr->authtype);
 	xfree(build_ptr->backup_addr);
 	xfree(build_ptr->backup_controller);
 	xfree(build_ptr->checkpoint_type);
+	xfree(build_ptr->cluster_name);
 	xfree(build_ptr->control_addr);
 	xfree(build_ptr->control_machine);
+	xfree(build_ptr->crypto_type);
 	xfree(build_ptr->epilog);
-	xfree(build_ptr->job_acct_logfile);
-	xfree(build_ptr->job_acct_type);
+	xfree(build_ptr->health_check_program);
+	xfree(build_ptr->job_acct_gather_type);
 	xfree(build_ptr->job_comp_loc);
+	xfree(build_ptr->job_comp_pass);
 	xfree(build_ptr->job_comp_type);
+	xfree(build_ptr->job_comp_user);
 	xfree(build_ptr->job_credential_private_key);
 	xfree(build_ptr->job_credential_public_certificate);
+	xfree(build_ptr->health_check_program);
+	xfree(build_ptr->licenses);
 	xfree(build_ptr->mail_prog);
 	xfree(build_ptr->mpi_default);
+	xfree(build_ptr->node_prefix);
 	xfree(build_ptr->plugindir);
 	xfree(build_ptr->plugstack);
 	xfree(build_ptr->proctrack_type);
 	xfree(build_ptr->prolog);
 	xfree(build_ptr->propagate_rlimits);
 	xfree(build_ptr->propagate_rlimits_except);
+	xfree(build_ptr->resume_program);
+	xfree(build_ptr->sched_params);
 	xfree(build_ptr->schedtype);
 	xfree(build_ptr->select_type);
 	xfree(build_ptr->slurm_conf);
@@ -2312,15 +2570,19 @@ unpack_error:
 	xfree(build_ptr->slurmd_logfile);
 	xfree(build_ptr->slurmd_pidfile);
 	xfree(build_ptr->slurmd_spooldir);
+	xfree(build_ptr->srun_epilog);
+	xfree(build_ptr->srun_prolog);
 	xfree(build_ptr->state_save_location);
+	xfree(build_ptr->suspend_exc_nodes);
+	xfree(build_ptr->suspend_exc_parts);
+	xfree(build_ptr->suspend_program);
 	xfree(build_ptr->switch_type);
+	xfree(build_ptr->node_prefix);
 	xfree(build_ptr->task_epilog);
 	xfree(build_ptr->task_prolog);
 	xfree(build_ptr->task_plugin);
 	xfree(build_ptr->tmp_fs);
-	xfree(build_ptr->srun_prolog);
-	xfree(build_ptr->srun_epilog);
-	xfree(build_ptr->node_prefix);
+	xfree(build_ptr->unkillable_program);
 	xfree(build_ptr);
 	*build_buffer_ptr = NULL;
 	return SLURM_ERROR;
@@ -2351,17 +2613,19 @@ _pack_job_desc_msg(job_desc_msg_t * job_desc_ptr, Buf buffer)
 	pack16(job_desc_ptr->job_min_cores, buffer);
 	pack16(job_desc_ptr->job_min_threads, buffer);
 	pack32(job_desc_ptr->job_min_memory, buffer);
-	pack32(job_desc_ptr->job_max_memory, buffer);
 	pack32(job_desc_ptr->job_min_tmp_disk, buffer);
 
 	packstr(job_desc_ptr->partition, buffer);
 	pack32(job_desc_ptr->priority, buffer);
-	pack32(job_desc_ptr->dependency, buffer);
+	packstr(job_desc_ptr->dependency, buffer);
 	packstr(job_desc_ptr->account, buffer);
 	packstr(job_desc_ptr->comment, buffer);
 	pack16(job_desc_ptr->nice, buffer);
-	pack16(job_desc_ptr->overcommit, buffer);
-	pack32(job_desc_ptr->num_tasks, buffer);
+
+	pack8(job_desc_ptr->open_mode,   buffer);
+	pack8(job_desc_ptr->overcommit,  buffer);
+	pack16(job_desc_ptr->acctg_freq, buffer);
+	pack32(job_desc_ptr->num_tasks,  buffer);
 
 	packstr(job_desc_ptr->req_nodes, buffer);
 	packstr(job_desc_ptr->exc_nodes, buffer);
@@ -2376,7 +2640,7 @@ _pack_job_desc_msg(job_desc_msg_t * job_desc_ptr, Buf buffer)
 	packstr(job_desc_ptr->work_dir, buffer);
 
 	pack16(job_desc_ptr->immediate, buffer);
-	pack16(job_desc_ptr->no_requeue, buffer);
+	pack16(job_desc_ptr->requeue, buffer);
 	pack16(job_desc_ptr->shared, buffer);
 	pack16(job_desc_ptr->cpus_per_task, buffer);
 	pack16(job_desc_ptr->ntasks_per_node, buffer);
@@ -2397,12 +2661,11 @@ _pack_job_desc_msg(job_desc_msg_t * job_desc_ptr, Buf buffer)
 	pack32(job_desc_ptr->group_id, buffer);
 
 	pack16(job_desc_ptr->alloc_resp_port, buffer);
-	packstr(job_desc_ptr->alloc_resp_hostname, buffer);
 	pack16(job_desc_ptr->other_port, buffer);
-	packstr(job_desc_ptr->other_hostname, buffer);
 	packstr(job_desc_ptr->network, buffer);
 	pack_time(job_desc_ptr->begin_time, buffer);
 
+	packstr(job_desc_ptr->licenses, buffer);
 	pack16(job_desc_ptr->mail_type, buffer);
 	packstr(job_desc_ptr->mail_user, buffer);
 	if(job_desc_ptr->select_jobinfo)
@@ -2459,7 +2722,7 @@ _pack_job_desc_msg(job_desc_msg_t * job_desc_ptr, Buf buffer)
 static int
 _unpack_job_desc_msg(job_desc_msg_t ** job_desc_buffer_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	job_desc_msg_t *job_desc_ptr;
 
 	/* alloc memory for structure */
@@ -2471,43 +2734,45 @@ _unpack_job_desc_msg(job_desc_msg_t ** job_desc_buffer_ptr, Buf buffer)
 	safe_unpack16(&job_desc_ptr->task_dist, buffer);
 	safe_unpack16(&job_desc_ptr->plane_size, buffer);
 	safe_unpack16(&job_desc_ptr->kill_on_node_fail, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->features, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->features, &uint32_tmp, buffer);
 	safe_unpack32(&job_desc_ptr->job_id, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->name, &uint32_tmp, buffer);
 
-	safe_unpackstr_xmalloc(&job_desc_ptr->alloc_node, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->alloc_node, &uint32_tmp, buffer);
 	safe_unpack32(&job_desc_ptr->alloc_sid, buffer);
 	safe_unpack16(&job_desc_ptr->job_min_procs, buffer);
 	safe_unpack16(&job_desc_ptr->job_min_sockets, buffer);
 	safe_unpack16(&job_desc_ptr->job_min_cores, buffer);
 	safe_unpack16(&job_desc_ptr->job_min_threads, buffer);
 	safe_unpack32(&job_desc_ptr->job_min_memory, buffer);
-	safe_unpack32(&job_desc_ptr->job_max_memory, buffer);
 	safe_unpack32(&job_desc_ptr->job_min_tmp_disk, buffer);
 
-	safe_unpackstr_xmalloc(&job_desc_ptr->partition, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->partition, &uint32_tmp, buffer);
 	safe_unpack32(&job_desc_ptr->priority, buffer);
-	safe_unpack32(&job_desc_ptr->dependency, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->account, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->comment, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->dependency, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->account, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->comment, &uint32_tmp, buffer);
 	safe_unpack16(&job_desc_ptr->nice, buffer);
-	safe_unpack16(&job_desc_ptr->overcommit, buffer);
-	safe_unpack32(&job_desc_ptr->num_tasks, buffer);
 
-	safe_unpackstr_xmalloc(&job_desc_ptr->req_nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->exc_nodes, &uint16_tmp, buffer);
+	safe_unpack8(&job_desc_ptr->open_mode,   buffer);
+	safe_unpack8(&job_desc_ptr->overcommit,  buffer);
+	safe_unpack16(&job_desc_ptr->acctg_freq, buffer);
+	safe_unpack32(&job_desc_ptr->num_tasks,  buffer);
+
+	safe_unpackstr_xmalloc(&job_desc_ptr->req_nodes, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->exc_nodes, &uint32_tmp, buffer);
 	safe_unpackstr_array(&job_desc_ptr->environment,
 			     &job_desc_ptr->env_size, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->script, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->script, &uint32_tmp, buffer);
 	safe_unpackstr_array(&job_desc_ptr->argv, &job_desc_ptr->argc, buffer);
 
-	safe_unpackstr_xmalloc(&job_desc_ptr->err, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->in, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->out, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->work_dir, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->err, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->in, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->out, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->work_dir, &uint32_tmp, buffer);
 
 	safe_unpack16(&job_desc_ptr->immediate, buffer);
-	safe_unpack16(&job_desc_ptr->no_requeue, buffer);
+	safe_unpack16(&job_desc_ptr->requeue, buffer);
 	safe_unpack16(&job_desc_ptr->shared, buffer);
 	safe_unpack16(&job_desc_ptr->cpus_per_task, buffer);
 	safe_unpack16(&job_desc_ptr->ntasks_per_node, buffer);
@@ -2528,16 +2793,13 @@ _unpack_job_desc_msg(job_desc_msg_t ** job_desc_buffer_ptr, Buf buffer)
 	safe_unpack32(&job_desc_ptr->group_id, buffer);
 
 	safe_unpack16(&job_desc_ptr->alloc_resp_port, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->alloc_resp_hostname,
-			       &uint16_tmp, buffer);
 	safe_unpack16(&job_desc_ptr->other_port, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->other_hostname,
-			       &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->network, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->network, &uint32_tmp, buffer);
 	safe_unpack_time(&job_desc_ptr->begin_time, buffer);
 
+	safe_unpackstr_xmalloc(&job_desc_ptr->licenses, &uint32_tmp, buffer);
 	safe_unpack16(&job_desc_ptr->mail_type, buffer);
-	safe_unpackstr_xmalloc(&job_desc_ptr->mail_user, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&job_desc_ptr->mail_user, &uint32_tmp, buffer);
 
 	if (select_g_alloc_jobinfo (&job_desc_ptr->select_jobinfo)
 	    ||  select_g_unpack_jobinfo(job_desc_ptr->select_jobinfo, buffer))
@@ -2555,11 +2817,15 @@ _unpack_job_desc_msg(job_desc_msg_t ** job_desc_buffer_ptr, Buf buffer)
 	return SLURM_SUCCESS;
 
 unpack_error:
-	select_g_free_jobinfo(&job_desc_ptr->select_jobinfo);
+
 	xfree(job_desc_ptr->features);
 	xfree(job_desc_ptr->name);
 	xfree(job_desc_ptr->partition);
+	xfree(job_desc_ptr->dependency);
+	xfree(job_desc_ptr->account);
+	xfree(job_desc_ptr->comment);
 	xfree(job_desc_ptr->req_nodes);
+	xfree(job_desc_ptr->exc_nodes);
 	xfree(job_desc_ptr->environment);
 	xfree(job_desc_ptr->script);
 	xfree(job_desc_ptr->argv);
@@ -2567,10 +2833,10 @@ unpack_error:
 	xfree(job_desc_ptr->in);
 	xfree(job_desc_ptr->out);
 	xfree(job_desc_ptr->work_dir);
-	xfree(job_desc_ptr->alloc_resp_hostname);
-	xfree(job_desc_ptr->other_hostname);
 	xfree(job_desc_ptr->network);
+	xfree(job_desc_ptr->licenses);
 	xfree(job_desc_ptr->mail_user);
+	select_g_free_jobinfo(&job_desc_ptr->select_jobinfo);
 	xfree(job_desc_ptr);
 	*job_desc_buffer_ptr = NULL;
 	return SLURM_ERROR;
@@ -2732,14 +2998,14 @@ _unpack_reattach_tasks_response_msg(reattach_tasks_response_msg_t ** msg_ptr,
 				    Buf buffer)
 {
 	uint32_t ntasks;
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	reattach_tasks_response_msg_t *msg = xmalloc(sizeof(*msg));
 	int i;
 
 	xassert(msg_ptr != NULL);
 	*msg_ptr = msg;
 
-	safe_unpackstr_xmalloc(&msg->node_name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->node_name, &uint32_tmp, buffer);
 	safe_unpack32(&msg->return_code,  buffer);
 	safe_unpack32(&msg->ntasks,       buffer);
 	safe_unpack32_array(&msg->gtids,      &ntasks, buffer);
@@ -2748,7 +3014,7 @@ _unpack_reattach_tasks_response_msg(reattach_tasks_response_msg_t ** msg_ptr,
 		goto unpack_error;
 	msg->executable_names = (char **)xmalloc(sizeof(char *) * msg->ntasks);
 	for (i = 0; i < msg->ntasks; i++) {
-		safe_unpackstr_xmalloc(&(msg->executable_names[i]), &uint16_tmp,
+		safe_unpackstr_xmalloc(&(msg->executable_names[i]), &uint32_tmp,
 				       buffer);
 	}
 	return SLURM_SUCCESS;
@@ -2809,7 +3075,6 @@ static int
 _unpack_launch_tasks_response_msg(launch_tasks_response_msg_t **
 				  msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
 	uint32_t uint32_tmp;
 	launch_tasks_response_msg_t *msg;
 
@@ -2818,7 +3083,7 @@ _unpack_launch_tasks_response_msg(launch_tasks_response_msg_t **
 	*msg_ptr = msg;
 
 	safe_unpack32(&msg->return_code, buffer);
-	safe_unpackstr_xmalloc(&msg->node_name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->node_name, &uint32_tmp, buffer);
 	safe_unpack32(&msg->count_of_pids, buffer);
 	safe_unpack32_array(&msg->local_pids, &uint32_tmp, buffer);
 	if (msg->count_of_pids != uint32_tmp)
@@ -2848,6 +3113,8 @@ _pack_launch_tasks_request_msg(launch_tasks_request_msg_t * msg, Buf buffer)
 	pack32(msg->nprocs, buffer);
 	pack32(msg->uid, buffer);
 	pack32(msg->gid, buffer);
+	pack32(msg->job_mem, buffer);
+	pack32(msg->task_mem, buffer);
 
 	pack32(msg->nnodes, buffer);
 	pack16(msg->max_sockets, buffer);
@@ -2897,13 +3164,17 @@ _pack_launch_tasks_request_msg(launch_tasks_request_msg_t * msg, Buf buffer)
 	switch_pack_jobinfo(msg->switch_job, buffer);
 	job_options_pack(msg->options, buffer);
 	packstr(msg->complete_nodelist, buffer);
+
+	pack8(msg->open_mode, buffer);
+	pack8(msg->pty, buffer);
+	pack16(msg->acctg_freq, buffer);
+	packstr(msg->ckpt_path, buffer);
 }
 
 static int
 _unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **
 				 msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
 	uint32_t uint32_tmp;
 	launch_tasks_request_msg_t *msg;
 	int i=0;
@@ -2917,6 +3188,8 @@ _unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **
 	safe_unpack32(&msg->nprocs, buffer);
 	safe_unpack32(&msg->uid, buffer);
 	safe_unpack32(&msg->gid, buffer);
+	safe_unpack32(&msg->job_mem, buffer);
+	safe_unpack32(&msg->task_mem, buffer);
 
 	safe_unpack32(&msg->nnodes, buffer);
 	safe_unpack16(&msg->max_sockets, buffer);
@@ -2952,19 +3225,19 @@ _unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **
 	}
 	slurm_unpack_slurm_addr_no_alloc(&msg->orig_addr, buffer);
 	safe_unpackstr_array(&msg->env, &msg->envc, buffer);
-	safe_unpackstr_xmalloc(&msg->cwd, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->cwd, &uint32_tmp, buffer);
 	safe_unpack16(&msg->cpu_bind_type, buffer);
-	safe_unpackstr_xmalloc(&msg->cpu_bind, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->cpu_bind, &uint32_tmp, buffer);
 	safe_unpack16(&msg->mem_bind_type, buffer);
-	safe_unpackstr_xmalloc(&msg->mem_bind, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->mem_bind, &uint32_tmp, buffer);
 	safe_unpackstr_array(&msg->argv, &msg->argc, buffer);
 	safe_unpack16(&msg->task_flags, buffer);
 	safe_unpack16(&msg->multi_prog, buffer);
 	safe_unpack16(&msg->user_managed_io, buffer);
 	if (msg->user_managed_io == 0) {
-		safe_unpackstr_xmalloc(&msg->ofname, &uint16_tmp, buffer);
-		safe_unpackstr_xmalloc(&msg->efname, &uint16_tmp, buffer);
-		safe_unpackstr_xmalloc(&msg->ifname, &uint16_tmp, buffer);
+		safe_unpackstr_xmalloc(&msg->ofname, &uint32_tmp, buffer);
+		safe_unpackstr_xmalloc(&msg->efname, &uint32_tmp, buffer);
+		safe_unpackstr_xmalloc(&msg->ifname, &uint32_tmp, buffer);
 		safe_unpack8(&msg->buffered_stdio, buffer);
 		safe_unpack16(&msg->num_io_port, buffer);
 		if (msg->num_io_port > 0) {
@@ -2974,8 +3247,8 @@ _unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **
 				safe_unpack16(&msg->io_port[i], buffer);
 		}
 	}
-	safe_unpackstr_xmalloc(&msg->task_prolog, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&msg->task_epilog, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->task_prolog, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->task_epilog, &uint32_tmp, buffer);
 	safe_unpack16(&msg->slurmd_debug, buffer);
 	
 	switch_alloc_jobinfo(&msg->switch_job);
@@ -2989,7 +3262,12 @@ _unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **
 		error("Unable to unpack extra job options: %m");
 		goto unpack_error;
 	}
-	safe_unpackstr_xmalloc(&msg->complete_nodelist, &uint16_tmp, buffer);	
+	safe_unpackstr_xmalloc(&msg->complete_nodelist, &uint32_tmp, buffer);	
+
+	safe_unpack8(&msg->open_mode, buffer);
+	safe_unpack8(&msg->pty, buffer);
+	safe_unpack16(&msg->acctg_freq, buffer);
+	safe_unpackstr_xmalloc(&msg->ckpt_path, &uint32_tmp, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -3053,6 +3331,35 @@ unpack_error:
 	return SLURM_ERROR;
 }
 
+static void
+_pack_checkpoint_tasks_msg(checkpoint_tasks_msg_t * msg, Buf buffer)
+{
+	pack32((uint32_t)msg->job_id, buffer);
+	pack32((uint32_t)msg->job_step_id, buffer);
+	pack32((uint32_t)msg->signal, buffer);
+	pack_time((time_t)msg->timestamp, buffer);
+}
+
+static int
+_unpack_checkpoint_tasks_msg(checkpoint_tasks_msg_t ** msg_ptr, Buf buffer)
+{
+	checkpoint_tasks_msg_t *msg;
+
+	msg = xmalloc(sizeof(checkpoint_tasks_msg_t));
+	*msg_ptr = msg;
+
+	safe_unpack32(&msg->job_id, buffer);
+	safe_unpack32(&msg->job_step_id, buffer);
+	safe_unpack32(&msg->signal, buffer);
+	safe_unpack_time(&msg->timestamp, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	xfree(msg);
+	*msg_ptr = NULL;
+	return SLURM_ERROR;
+}
+
 static void
 _pack_shutdown_msg(shutdown_msg_t * msg, Buf buffer)
 {
@@ -3159,7 +3466,7 @@ _unpack_complete_batch_script_msg(
 	complete_batch_script_msg_t ** msg_ptr, Buf buffer)
 {
 	complete_batch_script_msg_t *msg;
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 
 	msg = xmalloc(sizeof(complete_batch_script_msg_t));
 	*msg_ptr = msg;
@@ -3167,7 +3474,7 @@ _unpack_complete_batch_script_msg(
 	safe_unpack32(&msg->job_id, buffer);
 	safe_unpack32(&msg->job_rc, buffer);
 	safe_unpack32(&msg->slurm_rc, buffer);
-	safe_unpackstr_xmalloc(&msg->node_name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->node_name, &uint32_tmp, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -3183,7 +3490,7 @@ _pack_stat_jobacct_msg(stat_jobacct_msg_t * msg, Buf buffer)
 	pack32((uint32_t)msg->return_code, buffer);
 	pack32((uint32_t)msg->step_id, buffer);
 	pack32((uint32_t)msg->num_tasks, buffer);
-	jobacct_g_pack(msg->jobacct, buffer);	
+	jobacct_gather_g_pack(msg->jobacct, buffer);	
 }
 
 
@@ -3199,7 +3506,7 @@ _unpack_stat_jobacct_msg(stat_jobacct_msg_t ** msg_ptr, Buf buffer)
 	safe_unpack32(&msg->return_code, buffer);
 	safe_unpack32(&msg->step_id, buffer);
 	safe_unpack32(&msg->num_tasks, buffer);
-	if (jobacct_g_unpack(&msg->jobacct, buffer) != SLURM_SUCCESS)
+	if (jobacct_gather_g_unpack(&msg->jobacct, buffer) != SLURM_SUCCESS)
 		goto unpack_error;
 
 	return SLURM_SUCCESS;
@@ -3248,7 +3555,7 @@ _pack_step_complete_msg(step_complete_msg_t * msg, Buf buffer)
 	pack32((uint32_t)msg->range_first, buffer);
 	pack32((uint32_t)msg->range_last, buffer);
 	pack32((uint32_t)msg->step_rc, buffer);
-	jobacct_g_pack(msg->jobacct, buffer);
+	jobacct_gather_g_pack(msg->jobacct, buffer);
 }
 
 static int
@@ -3264,7 +3571,7 @@ _unpack_step_complete_msg(step_complete_msg_t ** msg_ptr, Buf buffer)
 	safe_unpack32(&msg->range_first, buffer);
 	safe_unpack32(&msg->range_last, buffer);
 	safe_unpack32(&msg->step_rc, buffer);
-	if (jobacct_g_unpack(&msg->jobacct, buffer) != SLURM_SUCCESS)
+	if (jobacct_gather_g_unpack(&msg->jobacct, buffer) != SLURM_SUCCESS)
 		goto unpack_error;
 
 	return SLURM_SUCCESS;
@@ -3406,14 +3713,14 @@ unpack_error:
 
 static void
 _pack_slurm_addr_array(slurm_addr * slurm_address,
-		       uint16_t size_val, Buf buffer)
+		       uint32_t size_val, Buf buffer)
 {
 	slurm_pack_slurm_addr_array(slurm_address, size_val, buffer);
 }
 
 static int
 _unpack_slurm_addr_array(slurm_addr ** slurm_address,
-			 uint16_t * size_val, Buf buffer)
+			 uint32_t * size_val, Buf buffer)
 {
 	return slurm_unpack_slurm_addr_array(slurm_address, size_val, buffer);
 }
@@ -3444,8 +3751,9 @@ static int
 _unpack_ret_list(List *ret_list,
 		 uint16_t size_val, Buf buffer)
 {
-	int i = 0, j = 0;
-	uint16_t nl = 0, uint16_tmp;
+	int i = 0;
+	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	ret_data_info_t *ret_data_info = NULL;
 	slurm_msg_t msg;
 	*ret_list = list_create(destroy_data_info);
@@ -3458,7 +3766,7 @@ _unpack_ret_list(List *ret_list,
 		safe_unpack16(&uint16_tmp, buffer);
 		ret_data_info->type = (slurm_msg_type_t)uint16_tmp;
 		safe_unpackstr_xmalloc(&ret_data_info->node_name, 
-				       &uint16_tmp, buffer);
+				       &uint32_tmp, buffer);
 		msg.msg_type = ret_data_info->type;
 		if (unpack_msg(&msg, buffer) != SLURM_SUCCESS)
 			goto unpack_error;
@@ -3470,7 +3778,7 @@ _unpack_ret_list(List *ret_list,
 unpack_error:
 	if (ret_data_info && ret_data_info->type) {
 		error("_unpack_ret_list: message type %u, record %d of %u", 
-		      ret_data_info->type, j, nl);
+		      ret_data_info->type, i, size_val);
 	}
 	list_destroy(*ret_list);
 	*ret_list = NULL;
@@ -3482,14 +3790,18 @@ _pack_batch_job_launch_msg(batch_job_launch_msg_t * msg, Buf buffer)
 {
 	xassert(msg != NULL);
 
-	pack32((uint32_t)msg->job_id, buffer);
-	pack32((uint32_t)msg->step_id, buffer);
-	pack32((uint32_t)msg->uid, buffer);
-	pack32((uint32_t)msg->gid, buffer);
-	pack32((uint32_t)msg->nprocs, buffer);
+	pack32(msg->job_id, buffer);
+	pack32(msg->step_id, buffer);
+	pack32(msg->uid, buffer);
+	pack32(msg->gid, buffer);
+	pack32(msg->nprocs, buffer);
+
+	pack8(msg->open_mode, buffer);
+	pack8(msg->overcommit, buffer);
+
+	pack16(msg->acctg_freq,     buffer);
+	pack16(msg->num_cpu_groups, buffer);
 
-	pack16((uint16_t)msg->overcommit, buffer);
-	pack16((uint16_t)msg->num_cpu_groups, buffer);
 	pack32_array(msg->cpus_per_node, msg->num_cpu_groups, buffer);
 	pack32_array(msg->cpu_count_reps, msg->num_cpu_groups, buffer);
 
@@ -3501,12 +3813,14 @@ _pack_batch_job_launch_msg(batch_job_launch_msg_t * msg, Buf buffer)
 	packstr(msg->in, buffer);
 	packstr(msg->out, buffer);
 
-	pack16((uint16_t)msg->argc, buffer);
+	pack32(msg->argc, buffer);
 	packstr_array(msg->argv, msg->argc, buffer);
 
-	pack16((uint16_t)msg->envc, buffer);
+	pack32(msg->envc, buffer);
 	packstr_array(msg->environment, msg->envc, buffer);
 
+	pack32(msg->job_mem, buffer);
+
 	slurm_cred_pack(msg->cred, buffer);
 
 	select_g_pack_jobinfo(msg->select_jobinfo, buffer);
@@ -3515,7 +3829,6 @@ _pack_batch_job_launch_msg(batch_job_launch_msg_t * msg, Buf buffer)
 static int
 _unpack_batch_job_launch_msg(batch_job_launch_msg_t ** msg, Buf buffer)
 {
-	uint16_t uint16_tmp;
 	uint32_t uint32_tmp;
 	batch_job_launch_msg_t *launch_msg_ptr;
 
@@ -3529,8 +3842,12 @@ _unpack_batch_job_launch_msg(batch_job_launch_msg_t ** msg, Buf buffer)
 	safe_unpack32(&launch_msg_ptr->gid, buffer);
 	safe_unpack32(&launch_msg_ptr->nprocs, buffer);
 
-	safe_unpack16(&launch_msg_ptr->overcommit, buffer);
+	safe_unpack8(&launch_msg_ptr->open_mode, buffer);
+	safe_unpack8(&launch_msg_ptr->overcommit, buffer);
+
+	safe_unpack16(&launch_msg_ptr->acctg_freq,     buffer);
 	safe_unpack16(&launch_msg_ptr->num_cpu_groups, buffer);
+
 	safe_unpack32_array((uint32_t **) &(launch_msg_ptr->cpus_per_node), 
 			    &uint32_tmp,
 			    buffer);
@@ -3542,23 +3859,24 @@ _unpack_batch_job_launch_msg(batch_job_launch_msg_t ** msg, Buf buffer)
 	if (launch_msg_ptr->num_cpu_groups != uint32_tmp)
 		goto unpack_error;
 	
-	safe_unpackstr_xmalloc(&launch_msg_ptr->nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&launch_msg_ptr->script, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&launch_msg_ptr->work_dir, &uint16_tmp,
-			       buffer);
+	safe_unpackstr_xmalloc(&launch_msg_ptr->nodes,    &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&launch_msg_ptr->script,   &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&launch_msg_ptr->work_dir, &uint32_tmp, buffer);
 
-	safe_unpackstr_xmalloc(&launch_msg_ptr->err, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&launch_msg_ptr->in, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&launch_msg_ptr->out, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&launch_msg_ptr->err, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&launch_msg_ptr->in,  &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&launch_msg_ptr->out, &uint32_tmp, buffer);
 
-	safe_unpack16(&launch_msg_ptr->argc, buffer);
+	safe_unpack32(&launch_msg_ptr->argc, buffer);
 	safe_unpackstr_array(&launch_msg_ptr->argv,
 			     &launch_msg_ptr->argc, buffer);
 
-	safe_unpack16(&launch_msg_ptr->envc, buffer);
+	safe_unpack32(&launch_msg_ptr->envc, buffer);
 	safe_unpackstr_array(&launch_msg_ptr->environment,
 			     &launch_msg_ptr->envc, buffer);
 
+	safe_unpack32(&launch_msg_ptr->job_mem, buffer);
+
 	if (!(launch_msg_ptr->cred = slurm_cred_unpack(buffer)))
 		goto unpack_error;
 
@@ -3703,7 +4021,7 @@ _pack_srun_node_fail_msg(srun_node_fail_msg_t * msg, Buf buffer)
 static int 
 _unpack_srun_node_fail_msg(srun_node_fail_msg_t ** msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	srun_node_fail_msg_t * msg;
 	xassert ( msg_ptr != NULL );
 
@@ -3712,7 +4030,7 @@ _unpack_srun_node_fail_msg(srun_node_fail_msg_t ** msg_ptr, Buf buffer)
 
 	safe_unpack32(&msg->job_id  , buffer ) ;
 	safe_unpack32(&msg->step_id , buffer ) ;
-	safe_unpackstr_xmalloc ( & msg->nodelist, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc ( & msg->nodelist, &uint32_tmp, buffer);
 
 	return SLURM_SUCCESS;
 
@@ -3791,7 +4109,7 @@ _pack_srun_user_msg(srun_user_msg_t * msg, Buf buffer)
 static int
 _unpack_srun_user_msg(srun_user_msg_t ** msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	srun_user_msg_t * msg_user;
 	xassert ( msg_ptr != NULL );
 
@@ -3799,7 +4117,7 @@ _unpack_srun_user_msg(srun_user_msg_t ** msg_ptr, Buf buffer)
 	*msg_ptr = msg_user;
 
 	safe_unpack32(&msg_user->job_id, buffer);
-	safe_unpackstr_xmalloc(&msg_user->msg, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg_user->msg, &uint32_tmp, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -3880,7 +4198,7 @@ _pack_checkpoint_comp(checkpoint_comp_msg_t *msg, Buf buffer)
 static int
 _unpack_checkpoint_comp(checkpoint_comp_msg_t **msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	checkpoint_comp_msg_t * msg;
 	xassert ( msg_ptr != NULL );
 
@@ -3890,7 +4208,45 @@ _unpack_checkpoint_comp(checkpoint_comp_msg_t **msg_ptr, Buf buffer)
 	safe_unpack32(& msg -> job_id  , buffer ) ;
 	safe_unpack32(& msg -> step_id , buffer ) ;
 	safe_unpack32(& msg -> error_code , buffer ) ;
-	safe_unpackstr_xmalloc ( & msg -> error_msg, & uint16_tmp , buffer ) ;
+	safe_unpackstr_xmalloc ( & msg -> error_msg, & uint32_tmp , buffer ) ;
+	safe_unpack_time ( & msg -> begin_time , buffer ) ;
+	return SLURM_SUCCESS;
+
+unpack_error:
+	*msg_ptr = NULL;
+	xfree (msg->error_msg);
+	xfree (msg);
+	return SLURM_ERROR;
+}
+
+static void
+_pack_checkpoint_task_comp(checkpoint_task_comp_msg_t *msg, Buf buffer)
+{
+	xassert ( msg != NULL );
+
+	pack32((uint32_t)msg -> job_id,  buffer ) ;
+	pack32((uint32_t)msg -> step_id, buffer ) ;
+	pack32((uint32_t)msg -> task_id, buffer ) ;
+	pack32((uint32_t)msg -> error_code, buffer ) ;
+	packstr ( msg -> error_msg, buffer ) ;
+	pack_time ( msg -> begin_time, buffer ) ;
+}
+
+static int
+_unpack_checkpoint_task_comp(checkpoint_task_comp_msg_t **msg_ptr, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	checkpoint_task_comp_msg_t * msg;
+	xassert ( msg_ptr != NULL );
+
+	msg = xmalloc ( sizeof (checkpoint_task_comp_msg_t) );
+	*msg_ptr = msg ;
+
+	safe_unpack32(& msg -> job_id  , buffer ) ;
+	safe_unpack32(& msg -> step_id , buffer ) ;
+	safe_unpack32(& msg -> task_id , buffer ) ;
+	safe_unpack32(& msg -> error_code , buffer ) ;
+	safe_unpackstr_xmalloc ( & msg -> error_msg, & uint32_tmp , buffer ) ;
 	safe_unpack_time ( & msg -> begin_time , buffer ) ;
 	return SLURM_SUCCESS;
 
@@ -3915,7 +4271,7 @@ static int
 _unpack_checkpoint_resp_msg(checkpoint_resp_msg_t **msg_ptr, Buf buffer)
 {
 	checkpoint_resp_msg_t * msg;
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	xassert ( msg_ptr != NULL );
 
 	msg = xmalloc ( sizeof (checkpoint_resp_msg_t) ) ;
@@ -3923,7 +4279,7 @@ _unpack_checkpoint_resp_msg(checkpoint_resp_msg_t **msg_ptr, Buf buffer)
 
 	safe_unpack_time ( & msg -> event_time, buffer ) ;
 	safe_unpack32(& msg -> error_code , buffer ) ;
-	safe_unpackstr_xmalloc ( & msg -> error_msg, & uint16_tmp , buffer ) ;
+	safe_unpackstr_xmalloc ( & msg -> error_msg, & uint32_tmp , buffer ) ;
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -3934,12 +4290,9 @@ unpack_error:
 
 static void _pack_file_bcast(file_bcast_msg_t * msg , Buf buffer )
 {
-	int buf_size = 1024, i;
 	xassert ( msg != NULL );
 
-	for (i=0; i<FILE_BLOCKS; i++)
-		buf_size += msg->block_len[i];
-	grow_buf(buffer, buf_size);
+	grow_buf(buffer,  msg->block_len);
 	
 	pack16 ( msg->block_no, buffer );
 	pack16 ( msg->last_block, buffer );
@@ -3953,16 +4306,13 @@ static void _pack_file_bcast(file_bcast_msg_t * msg , Buf buffer )
 	pack_time ( msg->mtime, buffer );
 
 	packstr ( msg->fname, buffer );
-	for (i=0; i<FILE_BLOCKS; i++) {
-		pack32 ( msg->block_len[i], buffer );
-		packmem ( msg->block[i], msg->block_len[i], buffer );
-	}
+	pack32 ( msg->block_len, buffer );
+	packmem ( msg->block, msg->block_len, buffer );
 }
 
 static int _unpack_file_bcast(file_bcast_msg_t ** msg_ptr , Buf buffer )
 {
-	int i;
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	file_bcast_msg_t *msg ;
 
 	xassert ( msg_ptr != NULL );
@@ -3981,19 +4331,16 @@ static int _unpack_file_bcast(file_bcast_msg_t ** msg_ptr , Buf buffer )
 	safe_unpack_time ( & msg->atime, buffer );
 	safe_unpack_time ( & msg->mtime, buffer );
 
-	safe_unpackstr_xmalloc ( & msg->fname, &uint16_tmp, buffer );
-	for (i=0; i<FILE_BLOCKS; i++) {
-		safe_unpack32 ( & msg->block_len[i], buffer );
-		safe_unpackmem_xmalloc ( & msg->block[i], &uint16_tmp , buffer ) ;
-		if ( uint16_tmp != msg->block_len[i] )
-			goto unpack_error;
-	}
+	safe_unpackstr_xmalloc ( & msg->fname, &uint32_tmp, buffer );
+	safe_unpack32 ( & msg->block_len, buffer );
+	safe_unpackmem_xmalloc ( & msg->block, &uint32_tmp , buffer ) ;
+	if ( uint32_tmp != msg->block_len )
+		goto unpack_error;
 	return SLURM_SUCCESS;
 
 unpack_error:
 	xfree( msg -> fname );
-	for (i=0; i<FILE_BLOCKS; i++)
-		xfree( msg -> block[i] );
+	xfree( msg -> block );
 	xfree( msg );
 	*msg_ptr = NULL;
 	return SLURM_ERROR;
@@ -4006,7 +4353,7 @@ static void _pack_trigger_msg(trigger_info_msg_t *msg , Buf buffer)
 	pack32(msg->record_count, buffer);
 	for (i=0; i<msg->record_count; i++) {
 		pack32 (msg->trigger_array[i].trig_id,   buffer);
-		pack8  (msg->trigger_array[i].res_type,  buffer);
+		pack16 (msg->trigger_array[i].res_type,  buffer);
 		packstr(msg->trigger_array[i].res_id,    buffer);
 		pack16 (msg->trigger_array[i].trig_type, buffer);
 		pack16 (msg->trigger_array[i].offset,    buffer);
@@ -4018,7 +4365,7 @@ static void _pack_trigger_msg(trigger_info_msg_t *msg , Buf buffer)
 static int  _unpack_trigger_msg(trigger_info_msg_t ** msg_ptr , Buf buffer)
 {
 	int i;
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	trigger_info_msg_t *msg = xmalloc(sizeof(trigger_info_msg_t));
 
 	safe_unpack32  (&msg->record_count, buffer);
@@ -4026,14 +4373,14 @@ static int  _unpack_trigger_msg(trigger_info_msg_t ** msg_ptr , Buf buffer)
 			msg->record_count);
 	for (i=0; i<msg->record_count; i++) {
 		safe_unpack32(&msg->trigger_array[i].trig_id,   buffer);
-		safe_unpack8 (&msg->trigger_array[i].res_type,  buffer);
+		safe_unpack16(&msg->trigger_array[i].res_type,  buffer);
 		safe_unpackstr_xmalloc(&msg->trigger_array[i].res_id, 
-				&uint16_tmp, buffer);
+				&uint32_tmp, buffer);
 		safe_unpack16(&msg->trigger_array[i].trig_type, buffer);
 		safe_unpack16(&msg->trigger_array[i].offset,    buffer);
 		safe_unpack32(&msg->trigger_array[i].user_id,   buffer);
 		safe_unpackstr_xmalloc(&msg->trigger_array[i].program, 
-				&uint16_tmp, buffer);
+				&uint32_tmp, buffer);
 	}
 	*msg_ptr = msg; 
 	return SLURM_SUCCESS;
@@ -4053,11 +4400,11 @@ static void _pack_kvs_host_rec(struct kvs_hosts *msg_ptr, Buf buffer)
 
 static int _unpack_kvs_host_rec(struct kvs_hosts *msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	
 	safe_unpack16(&msg_ptr->task_id, buffer);
 	safe_unpack16(&msg_ptr->port, buffer);
-	safe_unpackstr_xmalloc(&msg_ptr->hostname, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->hostname, &uint32_tmp, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -4078,21 +4425,21 @@ static void _pack_kvs_rec(struct kvs_comm *msg_ptr, Buf buffer)
 }
 static int  _unpack_kvs_rec(struct kvs_comm **msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	int i;
 	struct kvs_comm *msg;
 
 	msg = xmalloc(sizeof(struct kvs_comm));
 	*msg_ptr = msg;
-	safe_unpackstr_xmalloc(&msg->kvs_name, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->kvs_name, &uint32_tmp, buffer);
 	safe_unpack16(&msg->kvs_cnt, buffer);
 	msg->kvs_keys   = xmalloc(sizeof(char *) * msg->kvs_cnt);
 	msg->kvs_values = xmalloc(sizeof(char *) * msg->kvs_cnt);
 	for (i=0; i<msg->kvs_cnt; i++) {
 		safe_unpackstr_xmalloc(&msg->kvs_keys[i], 
-				       &uint16_tmp, buffer);
+				       &uint32_tmp, buffer);
 		safe_unpackstr_xmalloc(&msg->kvs_values[i], 
-				       &uint16_tmp, buffer);
+				       &uint32_tmp, buffer);
 	}
 	return SLURM_SUCCESS;
 
@@ -4167,7 +4514,7 @@ static void _pack_kvs_get(kvs_get_msg_t *msg_ptr, Buf buffer)
 
 static int  _unpack_kvs_get(kvs_get_msg_t **msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	kvs_get_msg_t *msg;
 
 	msg = xmalloc(sizeof(struct kvs_get_msg));
@@ -4175,7 +4522,7 @@ static int  _unpack_kvs_get(kvs_get_msg_t **msg_ptr, Buf buffer)
 	safe_unpack16(&msg->task_id, buffer);
 	safe_unpack16(&msg->size, buffer);
 	safe_unpack16(&msg->port, buffer);
-	safe_unpackstr_xmalloc(&msg->hostname, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->hostname, &uint32_tmp, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -4271,7 +4618,7 @@ static void _pack_slurmd_status(slurmd_status_t *msg, Buf buffer)
 
 static int _unpack_slurmd_status(slurmd_status_t **msg_ptr, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	slurmd_status_t *msg;
 
 	xassert(msg_ptr);
@@ -4291,10 +4638,10 @@ static int _unpack_slurmd_status(slurmd_status_t **msg_ptr, Buf buffer)
 	safe_unpack32(&msg->actual_tmp_disk, buffer);
 	safe_unpack32(&msg->pid, buffer);
 
-	safe_unpackstr_xmalloc(&msg->hostname, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&msg->slurmd_logfile, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&msg->step_list, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&msg->version, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->hostname,       &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->slurmd_logfile, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->step_list,      &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg->version,        &uint32_tmp, buffer);
 
 	*msg_ptr = msg;
 	return SLURM_SUCCESS;
@@ -4309,6 +4656,141 @@ unpack_error:
 	return SLURM_ERROR;
 }
 
+static void _pack_job_notify(job_notify_msg_t *msg, Buf buffer)
+{
+	xassert(msg);
+
+	pack32(msg->job_id,      buffer);
+	pack32(msg->job_step_id, buffer);
+	packstr(msg->message,    buffer);
+}
+
+static int  _unpack_job_notify(job_notify_msg_t **msg_ptr, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	job_notify_msg_t *msg;
+
+	xassert(msg_ptr);
+
+	msg = xmalloc(sizeof(job_notify_msg_t));
+
+	safe_unpack32(&msg->job_id,      buffer);
+	safe_unpack32(&msg->job_step_id, buffer);
+	safe_unpackstr_xmalloc(&msg->message, &uint32_tmp, buffer);
+
+	*msg_ptr = msg;
+	return SLURM_SUCCESS;
+
+unpack_error:
+	xfree(msg->message);
+	xfree(msg);
+	*msg_ptr = NULL;
+	return SLURM_ERROR;
+}
+
+static void
+_pack_set_debug_level_msg(set_debug_level_msg_t * msg, Buf buffer)
+{
+	pack32(msg->debug_level, buffer);
+}
+
+static int
+_unpack_set_debug_level_msg(set_debug_level_msg_t ** msg_ptr, Buf buffer)
+{
+	set_debug_level_msg_t *msg;
+	
+	msg = xmalloc(sizeof(set_debug_level_msg_t));
+	*msg_ptr = msg;
+	
+	safe_unpack32(&msg->debug_level, buffer);
+	return SLURM_SUCCESS;
+	
+ unpack_error:
+	xfree(msg);
+	*msg_ptr = NULL;
+	return SLURM_ERROR;
+}
+
+static void 
+_pack_will_run_response_msg(will_run_response_msg_t *msg, Buf buffer)
+{
+	pack32(msg->job_id, buffer);
+	pack32(msg->proc_cnt, buffer);
+	pack_time(msg->start_time, buffer);
+	packstr(msg->node_list, buffer);
+}
+
+static int
+_unpack_will_run_response_msg(will_run_response_msg_t ** msg_ptr, Buf buffer)
+{
+	will_run_response_msg_t *msg;
+	uint32_t uint32_tmp;
+
+	msg = xmalloc(sizeof(will_run_response_msg_t));
+	safe_unpack32(&msg->job_id, buffer);
+	safe_unpack32(&msg->proc_cnt, buffer);
+	safe_unpack_time(&msg->start_time, buffer);
+	safe_unpackstr_xmalloc(&msg->node_list, &uint32_tmp, buffer);
+	*msg_ptr = msg;
+	return SLURM_SUCCESS;
+
+  unpack_error:
+	xfree(msg->node_list);
+	xfree(msg);
+	*msg_ptr = NULL;
+	return SLURM_ERROR;
+}
+
+static void _pack_accounting_update_msg(accounting_update_msg_t *msg,
+					Buf buffer)
+{
+	uint32_t count = 0;
+	ListIterator itr = NULL;
+	acct_update_object_t *rec = NULL;
+
+	if(msg->update_list)
+		count = list_count(msg->update_list);
+
+	pack32(count, buffer);
+
+	if(count) {
+		itr = list_iterator_create(msg->update_list);
+		while((rec = list_next(itr))) {
+			pack_acct_update_object(rec, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+}
+
+static int _unpack_accounting_update_msg(accounting_update_msg_t **msg,
+					 Buf buffer)
+{
+	uint32_t count = 0;
+	int i = 0;
+	accounting_update_msg_t *msg_ptr =
+		xmalloc(sizeof(accounting_update_msg_t));
+	acct_update_object_t *rec = NULL;
+
+	*msg = msg_ptr;
+
+	safe_unpack32(&count, buffer);
+	msg_ptr->update_list = list_create(destroy_acct_update_object);
+	for(i=0; i<count; i++) {
+		if((unpack_acct_update_object(&rec, buffer)) == SLURM_ERROR)
+			goto unpack_error;
+		list_append(msg_ptr->update_list, rec);
+	}
+	
+	return SLURM_SUCCESS;
+	
+unpack_error:
+	if(msg_ptr->update_list)
+		list_destroy(msg_ptr->update_list);
+	xfree(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
 /* template 
    void pack_ ( * msg , Buf buffer )
    {
@@ -4322,7 +4804,7 @@ unpack_error:
 
    int unpack_ ( ** msg_ptr , Buf buffer )
    {
-   uint16_t uint16_tmp;
+   uint32_t uint32_tmp;
    * msg ;
 
    xassert ( msg_ptr != NULL );
@@ -4333,7 +4815,7 @@ unpack_error:
    safe_unpack16( & msg -> , buffer ) ;
    safe_unpack32( & msg -> , buffer ) ;
    safe_unpack_time ( & msg -> , buffer ) ;
-   safe_unpackstr_xmalloc ( & msg -> x, & uint16_tmp , buffer ) ;
+   safe_unpackstr_xmalloc ( & msg -> x, & uint32_tmp , buffer ) ;
    return SLURM_SUCCESS;
 
    unpack_error:
diff --git a/src/common/slurm_protocol_pack.h b/src/common/slurm_protocol_pack.h
index dd710790e12183db86ca1bcd2e4477dbd5b77342..aae531ae04367b336038d7062e500fbe14ff6447 100644
--- a/src/common/slurm_protocol_pack.h
+++ b/src/common/slurm_protocol_pack.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_protocol_socket_common.h b/src/common/slurm_protocol_socket_common.h
index ae927579bc32a94e82f78f53c6541c280c4939e9..1f0c9be3a83959b7a6bf003223514dab33e85ddb 100644
--- a/src/common/slurm_protocol_socket_common.h
+++ b/src/common/slurm_protocol_socket_common.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_protocol_socket_implementation.c b/src/common/slurm_protocol_socket_implementation.c
index 023f377b6910e44add0b99c3292cfc2a5efb69db..ea2f01cd40d3159ba56cddd43dff3c34b7417ef9 100644
--- a/src/common/slurm_protocol_socket_implementation.c
+++ b/src/common/slurm_protocol_socket_implementation.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  slurm_protocol_socket_implementation.c - slurm communications interfaces 
  *                                           based upon sockets.
- *  $Id: slurm_protocol_socket_implementation.c 12827 2007-12-14 22:29:30Z da $
+ *  $Id: slurm_protocol_socket_implementation.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -466,8 +466,11 @@ slurm_fd _slurm_open_stream(slurm_addr *addr, bool retry)
         int retry_cnt;
         slurm_fd fd;
 
-        if ( (addr->sin_family == 0) || (addr->sin_port  == 0) ) 
-                return SLURM_SOCKET_ERROR;
+	if ( (addr->sin_family == 0) || (addr->sin_port  == 0) ) {
+		error("Error connecting, bad data: family = %u, port = %u",
+			addr->sin_family, addr->sin_port);
+		return SLURM_SOCKET_ERROR;
+	}
 
         for (retry_cnt=0; ; retry_cnt++) {
                 int rc;
@@ -614,7 +617,7 @@ again:	rc = poll(&ufds, 1, 5000);
 		/* poll failed */
 		if (errno == EINTR) {
 			/* NOTE: connect() is non-interruptible in Linux */
-			debug3("_slurm_connect poll failed: %m");
+			debug2("_slurm_connect poll failed: %m");
 			goto again;
 		} else
 			error("_slurm_connect poll failed: %m");
diff --git a/src/common/slurm_protocol_util.c b/src/common/slurm_protocol_util.c
index ada81c9e40a39dfd9f2a59f5ec1bf1f89ee39f38..d2d8c4c06df4ae3dc897909728cfde3e072369b5 100644
--- a/src/common/slurm_protocol_util.c
+++ b/src/common/slurm_protocol_util.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -53,10 +53,9 @@
  */
 int check_header_version(header_t * header)
 {
-	if (header->version != SLURM_PROTOCOL_VERSION) {
-		debug("Invalid Protocol Version %d", header->version);
+	if (header->version != SLURM_PROTOCOL_VERSION)
 		slurm_seterrno_ret(SLURM_PROTOCOL_VERSION_ERROR);
-	}
+
 	return SLURM_PROTOCOL_SUCCESS;
 }
 
diff --git a/src/common/slurm_protocol_util.h b/src/common/slurm_protocol_util.h
index 3838e8df07b0a18a9de40cd84cd132469e287a2c..b8698de0be465a8c15a9ed9930bb720f591d4a3c 100644
--- a/src/common/slurm_protocol_util.h
+++ b/src/common/slurm_protocol_util.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_resource_info.c b/src/common/slurm_resource_info.c
index 6dfd58ddc2a4b3c7f211c779da8e7de5ef1918e3..572ba109a39293e6c32733a152bbaa170d9d84f2 100644
--- a/src/common/slurm_resource_info.c
+++ b/src/common/slurm_resource_info.c
@@ -4,7 +4,7 @@
  *****************************************************************************
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,12 +56,12 @@
  *	given this number given the number of cpus_per_task and
  *	maximum sockets, cores, threads.  Note that the value of
  *	cpus is the lowest-level logical processor (LLLP).
- * IN mxsockets      - Job requested max sockets
- * IN mxcores        - Job requested max cores
- * IN mxthreads      - Job requested max threads
- * IN minsockets     - Job requested min sockets
- * IN mincores       - Job requested min cores
- * IN cpuspertask    - Job requested cpus per task
+ * IN max_sockets    - Job requested max sockets
+ * IN max_cores      - Job requested max cores
+ * IN max_threads    - Job requested max threads
+ * IN min_sockets    - Job requested min sockets
+ * IN min_cores      - Job requested min cores
+ * IN cpus_per_task  - Job requested cpus per task
  * IN ntaskspernode  - number of tasks per node
  * IN ntaskspersocket- number of tasks per socket
  * IN ntaskspercore  - number of tasks per core
@@ -69,18 +69,17 @@
  * IN/OUT sockets    - Available socket count
  * IN/OUT cores      - Available core count
  * IN/OUT threads    - Available thread count
- * IN alloc_sockets  - Allocated socket count to other jobs
- * IN alloc_lps      - Allocated cpu count to other jobs
+ * IN alloc_cores    - Allocated cores (per socket) count to other jobs
  * IN cr_type        - Consumable Resource type
  *
  * Note: used in both the select/{linear,cons_res} plugins.
  */
-int slurm_get_avail_procs(const uint16_t mxsockets,
-			  const uint16_t mxcores,
-			  const uint16_t mxthreads,
-			  const uint16_t minsockets,
-			  const uint16_t mincores,
-			  const uint16_t cpuspertask,
+int slurm_get_avail_procs(const uint16_t max_sockets,
+			  const uint16_t max_cores,
+			  const uint16_t max_threads,
+			  const uint16_t min_sockets,
+			  const uint16_t min_cores,
+			  uint16_t cpus_per_task,
 			  const uint16_t ntaskspernode,
 			  const uint16_t ntaskspersocket,
 			  const uint16_t ntaskspercore,
@@ -88,21 +87,14 @@ int slurm_get_avail_procs(const uint16_t mxsockets,
 			  uint16_t *sockets, 
 			  uint16_t *cores, 
 			  uint16_t *threads,
-			  const uint16_t alloc_sockets,
 			  const uint16_t *alloc_cores,
-			  const uint16_t alloc_lps,
 			  const select_type_plugin_info_t cr_type,
 			  uint32_t job_id,
 			  char *name)
 {
 	uint16_t avail_cpus = 0, max_cpus = 0;
+	uint16_t allocated_cpus = 0, allocated_cores = 0, allocated_sockets = 0;
 	uint16_t max_avail_cpus = 0xffff;	/* for alloc_* accounting */
-	uint16_t max_sockets   = mxsockets;
-	uint16_t max_cores     = mxcores;
-	uint16_t max_threads   = mxthreads;
-	uint16_t min_sockets   = minsockets;
-	uint16_t min_cores     = mincores;
-	uint16_t cpus_per_task = cpuspertask;
 	int i;
 
         /* pick defaults for any unspecified items */
@@ -114,6 +106,11 @@ int slurm_get_avail_procs(const uint16_t mxsockets,
 	    	*cores = 1;
 	if (*sockets <= 0)
 	    	*sockets = *cpus / *cores / *threads;
+	for (i = 0 ; alloc_cores && i < *sockets; i++) {
+		allocated_cores += alloc_cores[i];
+		if (alloc_cores[i])
+			allocated_sockets++;
+	}
 #if(DEBUG)
 	info("get_avail_procs %u %s MAX User_ sockets %u cores %u threads %u",
 			job_id, name, max_sockets, max_cores, max_threads);
@@ -121,39 +118,33 @@ int slurm_get_avail_procs(const uint16_t mxsockets,
 			job_id, name, min_sockets, min_cores);
 	info("get_avail_procs %u %s HW_   sockets %u cores %u threads %u",
 			job_id, name, *sockets, *cores, *threads);
-        info("get_avail_procs %u %s Ntask node   %u sockets %u core    %u",
-                        job_id, name, ntaskspernode, ntaskspersocket, 
+	info("get_avail_procs %u %s Ntask node   %u sockets %u core   %u",
+			job_id, name, ntaskspernode, ntaskspersocket, 
 			ntaskspercore);
-	info("get_avail_procs %u %s cr_type %d cpus %u Allocated sockets %u lps %u",
-			job_id, name, cr_type, *cpus, alloc_sockets, alloc_lps);
-	if (((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) 
-	&&  (alloc_lps != 0)) {
-		for (i = 0; i < *sockets; i++)
-			info("get_avail_procs %u %s alloc_cores[%d] = %u", 
-			     job_id, name, i, alloc_cores[i]);
-	}
+	info("get_avail_procs %u %s cr_type %d cpus %u  alloc_ c %u s %u",
+			job_id, name, cr_type, *cpus, allocated_cores,
+			allocated_sockets);
+	for (i = 0; alloc_cores && i < *sockets; i++)
+		info("get_avail_procs %u %s alloc_cores[%d] = %u", 
+		     job_id, name, i, alloc_cores[i]);
 #endif
-		
+	allocated_cpus = allocated_cores * (*threads);
 	switch(cr_type) {
 	/* For the following CR types, nodes have no notion of socket, core,
 	   and thread.  Only one level of logical processors */ 
+	case SELECT_TYPE_INFO_NONE:
+		/* Default for select/linear */
 	case CR_CPU:
 	case CR_CPU_MEMORY:
-	case CR_MEMORY:
-		switch(cr_type) { 
-		case CR_CPU:
-		case CR_CPU_MEMORY:
-			if (*cpus >= alloc_lps)
-				*cpus -= alloc_lps;
-			else {
-				*cpus = 0;
-				error("cons_res: *cpus underflow");
-			}
-			break;
-		default:
-			break;
+		
+		if (*cpus >= allocated_cpus)
+			*cpus -= allocated_cpus;
+		else {
+			*cpus = 0;
+			error("cons_res: *cpus underflow");
 		}
 
+	case CR_MEMORY:
 		/*** compute an overall maximum cpu count honoring ntasks* ***/
 		max_cpus  = *cpus;
 		if (ntaskspernode > 0) {
@@ -164,19 +155,21 @@ int slurm_get_avail_procs(const uint16_t mxsockets,
 	/* For all other types, nodes contain sockets, cores, and threads */
 	case CR_CORE:
 	case CR_CORE_MEMORY:
-		if (*cpus >= alloc_lps)
-			*cpus -= alloc_lps;
+		if (*cpus >= allocated_cpus)
+			*cpus -= allocated_cpus;
 		else {
 			*cpus = 0;
 			error("cons_res: *cpus underflow");
 		}
-		if (alloc_lps > 0) {
+		if (allocated_cores > 0) {
 			max_avail_cpus = 0;
 			int tmp_diff = 0;
 			for (i=0; i<*sockets; i++) {
 				tmp_diff = *cores - alloc_cores[i];
-				if (min_cores <= tmp_diff)
+				if (min_cores <= tmp_diff) {
+					tmp_diff *= (*threads);
 					max_avail_cpus += tmp_diff;
+				}
 			}
 		} 
 
@@ -220,14 +213,14 @@ int slurm_get_avail_procs(const uint16_t mxsockets,
 	case CR_SOCKET:
 	case CR_SOCKET_MEMORY:
 	default:
-		if (*sockets >= alloc_sockets)
-			*sockets -= alloc_sockets; /* sockets count */
+		if (*sockets >= allocated_sockets)
+			*sockets -= allocated_sockets; /* sockets count */
 		else {
 			*sockets = 0;
 			error("cons_res: *sockets underflow");
 		}
-		if (*cpus >= alloc_lps)
-			*cpus -= alloc_lps;
+		if (*cpus >= allocated_cpus)
+			*cpus -= allocated_cpus;
 		else {
 			*cpus = 0;
 			error("cons_res: *cpus underflow");
diff --git a/src/common/slurm_resource_info.h b/src/common/slurm_resource_info.h
index 330c876f08767db72e45353f1495ab1b965f9f45..25733ff8e54207fd21709532072228dae86f24b1 100644
--- a/src/common/slurm_resource_info.h
+++ b/src/common/slurm_resource_info.h
@@ -4,7 +4,7 @@
  *****************************************************************************
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,9 +62,7 @@ int slurm_get_avail_procs(const uint16_t mxsockets,
 			  uint16_t *sockets, 
 			  uint16_t *cores, 
 			  uint16_t *threads,
-			  const uint16_t alloc_sockets,
 			  const uint16_t *alloc_cores,
-			  const uint16_t alloc_lps,
 			  const select_type_plugin_info_t cr_type,
 			  uint32_t job_id, char *name);
 
diff --git a/src/common/slurm_selecttype_info.c b/src/common/slurm_selecttype_info.c
index 969adf08d38c9a025bac9f440cb43bd047fa8b0e..baa5213f460f73d3ce264e5be682c600cf940e55 100644
--- a/src/common/slurm_selecttype_info.c
+++ b/src/common/slurm_selecttype_info.c
@@ -4,7 +4,7 @@
  *
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_selecttype_info.h b/src/common/slurm_selecttype_info.h
index b1b046dbf16f9ebffff16069bfba29f4bddcb5a2..f602ca13674ebdb891e5f187036d1d640212a713 100644
--- a/src/common/slurm_selecttype_info.h
+++ b/src/common/slurm_selecttype_info.h
@@ -4,7 +4,7 @@
  *
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/slurm_step_layout.c b/src/common/slurm_step_layout.c
index e49e01dc443aa7cbc81fb2c34d86fb8f5401043f..4d7f2725623f981f19cb6d4478b515e965c87214 100644
--- a/src/common/slurm_step_layout.c
+++ b/src/common/slurm_step_layout.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
  *  Written by Chris Holmes, <cholmes@hp.com>, who borrowed heavily
  *  from other parts of SLURM.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -88,7 +88,7 @@ static int _task_layout_hostfile(slurm_step_layout_t *step_layout,
 slurm_step_layout_t *slurm_step_layout_create(
 	const char *tlist,
 	uint32_t *cpus_per_node, uint32_t *cpu_count_reps, 
-	uint16_t num_hosts, 
+	uint32_t num_hosts, 
 	uint32_t num_tasks,
 	uint16_t task_dist,
 	uint16_t plane_size)
@@ -154,7 +154,7 @@ slurm_step_layout_t *fake_slurm_step_layout_create(
 	const char *tlist,
 	uint32_t *cpus_per_node, 
 	uint32_t *cpu_count_reps,
-	uint16_t node_cnt, 
+	uint32_t node_cnt, 
 	uint32_t task_cnt) 
 {
 	uint32_t cpn = 1;
@@ -287,7 +287,7 @@ extern void pack_slurm_step_layout(slurm_step_layout_t *step_layout,
 	if(!i)
 		return;
 	packstr(step_layout->node_list, buffer);
-	pack16(step_layout->node_cnt, buffer);
+	pack32(step_layout->node_cnt, buffer);
 	pack32(step_layout->task_cnt, buffer);
 /* 	slurm_pack_slurm_addr_array(step_layout->node_addr,  */
 /* 				    step_layout->node_cnt, buffer); */
@@ -301,7 +301,7 @@ extern void pack_slurm_step_layout(slurm_step_layout_t *step_layout,
 extern int unpack_slurm_step_layout(slurm_step_layout_t **layout, Buf buffer)
 {
 	uint16_t uint16_tmp;
-	uint32_t num_tids;
+	uint32_t num_tids, uint32_tmp;
 	slurm_step_layout_t *step_layout = NULL;
 	int i;
 	
@@ -316,17 +316,17 @@ extern int unpack_slurm_step_layout(slurm_step_layout_t **layout, Buf buffer)
 	step_layout->node_cnt = 0;
 	step_layout->tids = NULL;
 	step_layout->tasks = NULL;
-	safe_unpackstr_xmalloc(&step_layout->node_list, &uint16_tmp, buffer);
-	safe_unpack16(&step_layout->node_cnt, buffer);
+	safe_unpackstr_xmalloc(&step_layout->node_list, &uint32_tmp, buffer);
+	safe_unpack32(&step_layout->node_cnt, buffer);
 	safe_unpack32(&step_layout->task_cnt, buffer);
 	
 /* 	if (slurm_unpack_slurm_addr_array(&(step_layout->node_addr),  */
-/* 					  &uint16_tmp, buffer)) */
+/* 					  &uint32_tmp, buffer)) */
 /* 		goto unpack_error; */
-/* 	if (uint16_tmp != step_layout->node_cnt) */
+/* 	if (uint32_tmp != step_layout->node_cnt) */
 /* 		goto unpack_error; */
 	
-	step_layout->tasks = xmalloc(sizeof(uint16_t) * step_layout->node_cnt);
+	step_layout->tasks = xmalloc(sizeof(uint32_t) * step_layout->node_cnt);
 	step_layout->tids = xmalloc(sizeof(uint32_t *) 
 				    * step_layout->node_cnt);
 	for(i = 0; i < step_layout->node_cnt; i++) {
@@ -415,7 +415,7 @@ static int _init_task_layout(slurm_step_layout_t *step_layout,
 	i = hostlist_count(hl);
 	if(step_layout->node_cnt > i)
 		step_layout->node_cnt = i;
-	debug("laying out the %d tasks on %d hosts %s\n", 
+	debug("laying out the %u tasks on %u hosts %s\n", 
 	      step_layout->task_cnt, step_layout->node_cnt,
 	      step_layout->node_list);
 	if(step_layout->node_cnt < 1) {
diff --git a/src/common/slurm_step_layout.h b/src/common/slurm_step_layout.h
index 2a03b6205fcf65f9fbd03af9be55aab0f70d20da..efc8b13b9510e6d43f1f06b1d73cb0b388051529 100644
--- a/src/common/slurm_step_layout.h
+++ b/src/common/slurm_step_layout.h
@@ -6,7 +6,7 @@
  *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
  *  Written by Chris Holmes, <cholmes@hp.com>, who borrowed heavily
  *  from other parts of SLURM.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -63,7 +63,7 @@
 extern slurm_step_layout_t *slurm_step_layout_create(const char *tlist,
 						     uint32_t *cpus_per_node, 
 						     uint32_t *cpu_count_reps,
-						     uint16_t node_cnt, 
+						     uint32_t node_cnt, 
 						     uint32_t task_cnt,
 						     uint16_t task_dist,
 						     uint16_t plane_size);
@@ -86,7 +86,7 @@ extern slurm_step_layout_t *fake_slurm_step_layout_create(
 	const char *tlist,
 	uint32_t *cpus_per_node, 
 	uint32_t *cpu_count_reps,
-	uint16_t node_cnt, 
+	uint32_t node_cnt, 
 	uint32_t task_cnt);
 
 /* copys structure for step layout */
diff --git a/src/common/slurm_xlator.h b/src/common/slurm_xlator.h
index 8e38ed87b90c8d47563ed845d49cbccbe5c8ca5b..4513785d1496a8be5b860533fcc6f43b46d7ecee 100644
--- a/src/common/slurm_xlator.h
+++ b/src/common/slurm_xlator.h
@@ -30,7 +30,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -179,7 +179,7 @@
 #define	list_insert		slurm_list_insert
 #define	list_find		slurm_list_find
 #define	list_remove		slurm_list_remove
-#define	list_delete		slurm_list_delete
+#define	list_delete_item	slurm_list_delete_item
 #define	list_install_fork_handlers slurm_list_install_fork_handlers
 
 /* log.[ch] functions */
diff --git a/src/common/slurmdbd_defs.c b/src/common/slurmdbd_defs.c
new file mode 100644
index 0000000000000000000000000000000000000000..7cec1b4967ea658bf67d026cc4f17743812363e9
--- /dev/null
+++ b/src/common/slurmdbd_defs.c
@@ -0,0 +1,2299 @@
+/****************************************************************************\
+ *  slurmdbd_defs.c - functions for use with Slurm DBD RPCs
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H 
+#  include "config.h"
+#  if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#  else
+#    if HAVE_STDINT_H
+#      include <stdint.h>
+#    endif
+#  endif			/* HAVE_INTTYPES_H */
+#else				/* !HAVE_CONFIG_H */
+#  include <inttypes.h>
+#endif				/*  HAVE_CONFIG_H */
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <sys/poll.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "slurm/slurm_errno.h"
+#include "src/common/fd.h"
+#include "src/common/pack.h"
+#include "src/common/slurmdbd_defs.h"
+#include "src/common/slurm_auth.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurm_jobacct_gather.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xsignal.h"
+#include "src/common/xstring.h"
+
+#define DBD_MAGIC	0xDEAD3219
+#define MAX_AGENT_QUEUE	10000
+#define MAX_DBD_MSG_LEN 16384
+
+static pthread_mutex_t agent_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t  agent_cond = PTHREAD_COND_INITIALIZER;
+static List      agent_list     = (List) NULL;
+static pthread_t agent_tid      = 0;
+static time_t    agent_shutdown = 0;
+
+static pthread_mutex_t slurmdbd_lock = PTHREAD_MUTEX_INITIALIZER;
+static slurm_fd  slurmdbd_fd         = -1;
+static char *    slurmdbd_auth_info  = NULL;
+static bool      rollback_started    = 0;
+
+static void * _agent(void *x);
+static void   _agent_queue_del(void *x);
+static void   _close_slurmdbd_fd(void);
+static void   _create_agent(void);
+static bool   _fd_readable(slurm_fd fd);
+static int    _fd_writeable(slurm_fd fd);
+static int    _get_return_code(void);
+static Buf    _load_dbd_rec(int fd);
+static void   _load_dbd_state(void);
+static void   _open_slurmdbd_fd(void);
+static int    _purge_job_start_req(void);
+static Buf    _recv_msg(void);
+static void   _reopen_slurmdbd_fd(void);
+static int    _save_dbd_rec(int fd, Buf buffer);
+static void   _save_dbd_state(void);
+static int    _send_init_msg(void);
+static int    _send_fini_msg(void);
+static int    _send_msg(Buf buffer);
+static void   _sig_handler(int signal);
+static void   _shutdown_agent(void);
+static void   _slurmdbd_packstr(void *str, Buf buffer);
+static int    _slurmdbd_unpackstr(void **str, Buf buffer);
+static int    _tot_wait (struct timeval *start_time);
+
+/****************************************************************************
+ * Socket open/close/read/write functions
+ ****************************************************************************/
+
+/* Open a socket connection to SlurmDbd
+ * auth_info IN - alternate authentication key
+ * make_agent IN - make agent to process RPCs if set
+ * rollback IN - keep journal and permit rollback if set
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_open_slurmdbd_conn(char *auth_info, bool make_agent, 
+				    bool rollback)
+{
+	slurm_mutex_lock(&agent_lock);
+	if (make_agent && ((agent_tid == 0) || (agent_list == NULL)))
+		_create_agent();
+	slurm_mutex_unlock(&agent_lock);
+
+	slurm_mutex_lock(&slurmdbd_lock);
+	xfree(slurmdbd_auth_info);
+	if (auth_info)
+		slurmdbd_auth_info = xstrdup(auth_info);
+
+	rollback_started = rollback;
+
+	if (slurmdbd_fd < 0)
+		_open_slurmdbd_fd();
+	slurm_mutex_unlock(&slurmdbd_lock);
+
+	return SLURM_SUCCESS;
+}
+
+/* Close the SlurmDBD socket connection */
+extern int slurm_close_slurmdbd_conn(void)
+{
+	/* NOTE: agent_lock not needed for _shutdown_agent() */
+	_shutdown_agent();
+
+	if (rollback_started) {
+		if (_send_fini_msg() != SLURM_SUCCESS)
+			error("slurmdbd: Sending fini msg: %m");
+		else
+			debug("slurmdbd: Sent fini msg");
+	}
+
+	slurm_mutex_lock(&slurmdbd_lock);
+	_close_slurmdbd_fd();
+	xfree(slurmdbd_auth_info);
+	slurm_mutex_unlock(&slurmdbd_lock);
+
+	return SLURM_SUCCESS;
+}
+
+/* Send an RPC to the SlurmDBD and wait for the return code reply.
+ * The RPC will not be queued if an error occurs.
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_send_slurmdbd_recv_rc_msg(slurmdbd_msg_t *req, int *resp_code)
+{
+	int rc;
+	slurmdbd_msg_t *resp;
+
+	xassert(req);
+	xassert(resp_code);
+
+	resp = xmalloc(sizeof(slurmdbd_msg_t));
+	rc = slurm_send_recv_slurmdbd_msg(req, resp);
+	if (rc != SLURM_SUCCESS) {
+		;	/* error message already sent */
+	} else if (resp->msg_type != DBD_RC) {
+		error("slurmdbd: response is type DBD_RC: %d", resp->msg_type);
+		rc = SLURM_ERROR;
+	} else {	/* resp->msg_type == DBD_RC */
+		dbd_rc_msg_t *msg = resp->data;
+		*resp_code = msg->return_code;
+		if(msg->return_code != SLURM_SUCCESS)
+			error("slurmdbd(%d): from %u: %s", msg->return_code, 
+			      msg->sent_type, msg->comment);
+		slurmdbd_free_rc_msg(msg);
+	}
+	xfree(resp);
+
+	return rc;
+}
+
+/* Send an RPC to the SlurmDBD and wait for an arbitrary reply message.
+ * The RPC will not be queued if an error occurs.
+ * The "resp" message must be freed by the caller.
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_send_recv_slurmdbd_msg(slurmdbd_msg_t *req, 
+					slurmdbd_msg_t *resp)
+{
+	int rc = SLURM_SUCCESS;
+	Buf buffer;
+
+	xassert(req);
+	xassert(resp);
+
+	slurm_mutex_lock(&slurmdbd_lock);
+	if (slurmdbd_fd < 0) {
+		/* Either slurm_open_slurmdbd_conn() was not executed or
+		 * the connection to Slurm DBD has been closed */
+		_open_slurmdbd_fd();
+		if (slurmdbd_fd < 0) {
+			slurm_mutex_unlock(&slurmdbd_lock);
+			return SLURM_ERROR;
+		}
+	}
+
+	buffer = pack_slurmdbd_msg(req);
+
+	rc = _send_msg(buffer);
+	free_buf(buffer);
+	if (rc != SLURM_SUCCESS) {
+		error("slurmdbd: Sending message type %u", req->msg_type);
+		slurm_mutex_unlock(&slurmdbd_lock);
+		return SLURM_ERROR;
+	}
+
+	buffer = _recv_msg();
+	if (buffer == NULL) {
+		error("slurmdbd: Getting response to message type %u", 
+		      req->msg_type);
+		slurm_mutex_unlock(&slurmdbd_lock);
+		return SLURM_ERROR;
+	}
+		
+	rc = unpack_slurmdbd_msg(resp, buffer);
+
+	free_buf(buffer);
+	slurm_mutex_unlock(&slurmdbd_lock);
+	return rc;
+}
+
+/* Send an RPC to the SlurmDBD. Do not wait for the reply. The RPC
+ * will be queued and processed later if the SlurmDBD is not responding.
+ * NOTE: slurm_open_slurmdbd_conn() must have been called with make_agent set
+ * 
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_send_slurmdbd_msg(slurmdbd_msg_t *req)
+{
+	Buf buffer;
+	int cnt, rc = SLURM_SUCCESS;
+	static time_t syslog_time = 0;
+
+	
+	buffer = pack_slurmdbd_msg(req);
+
+	slurm_mutex_lock(&agent_lock);
+	if ((agent_tid == 0) || (agent_list == NULL)) {
+		_create_agent();
+		if ((agent_tid == 0) || (agent_list == NULL)) {
+			slurm_mutex_unlock(&agent_lock);
+			free_buf(buffer);
+			return SLURM_ERROR;
+		}
+	}
+	cnt = list_count(agent_list);
+	if ((cnt >= (MAX_AGENT_QUEUE / 2)) &&
+	    (difftime(time(NULL), syslog_time) > 120)) {
+		/* Record critical error every 120 seconds */
+		syslog_time = time(NULL);
+		error("slurmdbd: agent queue filling, RESTART SLURMDBD NOW");
+		syslog(LOG_CRIT, "*** RESTART SLURMDBD NOW ***");
+	}
+	if (cnt == (MAX_AGENT_QUEUE - 1))
+		cnt -= _purge_job_start_req();
+	if (cnt < MAX_AGENT_QUEUE) {
+		if (list_enqueue(agent_list, buffer) == NULL)
+			fatal("list_enqueue: memory allocation failure");
+	} else {
+		error("slurmdbd: agent queue is full, discarding request");
+		rc = SLURM_ERROR;
+	}
+	slurm_mutex_unlock(&agent_lock);
+	pthread_cond_broadcast(&agent_cond);
+	return rc;
+}
+
+/* Open a connection to the Slurm DBD and set slurmdbd_fd */
+static void _open_slurmdbd_fd()
+{
+	slurm_addr dbd_addr;
+	uint16_t slurmdbd_port;
+	char *   slurmdbd_host;
+
+	if (slurmdbd_fd >= 0) {
+		debug("Attempt to re-open slurmdbd socket");
+		return;
+	}
+
+	slurmdbd_host = slurm_get_accounting_storage_host();
+	slurmdbd_port = slurm_get_accounting_storage_port();
+	if ((slurmdbd_host == NULL) || (slurmdbd_port == 0)) {
+		error("Invalid SlurmDbd address %s:%u",
+		      slurmdbd_host, slurmdbd_port);
+		xfree(slurmdbd_host);
+		return;
+	}
+
+	slurm_set_addr(&dbd_addr, slurmdbd_port, slurmdbd_host);
+	if (dbd_addr.sin_port == 0)
+		error("Unable to locate SlurmDBD host %s:%u", 
+		      slurmdbd_host, slurmdbd_port);
+	else {
+		slurmdbd_fd = slurm_open_msg_conn(&dbd_addr);
+		if (slurmdbd_fd < 0)
+			error("slurmdbd: slurm_open_msg_conn: %m");
+		else {
+			fd_set_nonblocking(slurmdbd_fd);
+			if (_send_init_msg() != SLURM_SUCCESS)
+				error("slurmdbd: Sending DdbInit msg: %m");
+			else
+				debug("slurmdbd: Sent DbdInit msg");
+		}
+	}
+	xfree(slurmdbd_host);
+}
+
+extern Buf pack_slurmdbd_msg(slurmdbd_msg_t *req)
+{
+	Buf buffer = init_buf(MAX_DBD_MSG_LEN);
+	pack16(req->msg_type, buffer);
+
+	switch (req->msg_type) {
+	case DBD_ADD_ACCOUNTS:
+	case DBD_ADD_ASSOCS:
+	case DBD_ADD_CLUSTERS:
+	case DBD_ADD_USERS:
+	case DBD_GOT_ACCOUNTS:
+	case DBD_GOT_ASSOCS:
+	case DBD_GOT_CLUSTERS:
+	case DBD_GOT_JOBS:
+	case DBD_GOT_LIST:
+	case DBD_GOT_USERS:
+	case DBD_UPDATE_SHARES_USED:
+		slurmdbd_pack_list_msg(
+			req->msg_type, (dbd_list_msg_t *)req->data, buffer);
+		break;
+	case DBD_ADD_ACCOUNT_COORDS:
+	case DBD_REMOVE_ACCOUNT_COORDS:
+		slurmdbd_pack_acct_coord_msg((dbd_acct_coord_msg_t *)req->data,
+					     buffer);
+		break;
+	case DBD_CLUSTER_PROCS:
+	case DBD_FLUSH_JOBS:
+		slurmdbd_pack_cluster_procs_msg(
+			(dbd_cluster_procs_msg_t *)req->data, buffer);
+		break;
+	case DBD_GET_ACCOUNTS:
+	case DBD_GET_ASSOCS:
+	case DBD_GET_CLUSTERS:
+	case DBD_GET_USERS:
+	case DBD_REMOVE_ACCOUNTS:
+	case DBD_REMOVE_ASSOCS:
+	case DBD_REMOVE_CLUSTERS:
+	case DBD_REMOVE_USERS:
+		slurmdbd_pack_cond_msg(
+			req->msg_type, (dbd_cond_msg_t *)req->data, buffer);
+		break;
+	case DBD_GET_ASSOC_USAGE:
+	case DBD_GOT_ASSOC_USAGE:
+	case DBD_GET_CLUSTER_USAGE:
+	case DBD_GOT_CLUSTER_USAGE:
+		slurmdbd_pack_usage_msg(
+			req->msg_type, (dbd_usage_msg_t *)req->data,
+			buffer);
+		break;
+	case DBD_GET_JOBS:
+		slurmdbd_pack_get_jobs_msg(
+			(dbd_get_jobs_msg_t *)req->data, buffer);
+		break;
+	case DBD_INIT:
+		slurmdbd_pack_init_msg((dbd_init_msg_t *)req->data, buffer, 
+				       slurmdbd_auth_info);
+		break;
+	case DBD_FINI:
+		slurmdbd_pack_fini_msg((dbd_fini_msg_t *)req->data, buffer);
+		break;		
+	case DBD_JOB_COMPLETE:
+		slurmdbd_pack_job_complete_msg((dbd_job_comp_msg_t *)req->data,
+					       buffer);
+		break;
+	case DBD_JOB_START:
+		slurmdbd_pack_job_start_msg((dbd_job_start_msg_t *)req->data, 
+					    buffer);
+		break;
+	case DBD_JOB_START_RC:
+		slurmdbd_pack_job_start_rc_msg(
+			(dbd_job_start_rc_msg_t *)req->data, buffer);
+		break;		
+	case DBD_JOB_SUSPEND:
+		slurmdbd_pack_job_suspend_msg(
+			(dbd_job_suspend_msg_t *)req->data, buffer);
+		break;
+	case DBD_MODIFY_ACCOUNTS:
+	case DBD_MODIFY_ASSOCS:
+	case DBD_MODIFY_CLUSTERS:
+	case DBD_MODIFY_USERS:
+		slurmdbd_pack_modify_msg(
+			req->msg_type, (dbd_modify_msg_t *)req->data, buffer);
+		break;
+	case DBD_NODE_STATE:
+		slurmdbd_pack_node_state_msg(
+			(dbd_node_state_msg_t *)req->data, buffer);
+		break;
+	case DBD_RC:
+		slurmdbd_pack_rc_msg((dbd_rc_msg_t *)req->data, buffer);
+		break;
+	case DBD_STEP_COMPLETE:
+		slurmdbd_pack_step_complete_msg(
+			(dbd_step_comp_msg_t *)req->data, buffer);
+		break;
+	case DBD_STEP_START:
+		slurmdbd_pack_step_start_msg((dbd_step_start_msg_t *)req->data,
+					     buffer);
+		break;
+	case DBD_REGISTER_CTLD:
+		slurmdbd_pack_register_ctld_msg((dbd_register_ctld_msg_t *)
+						req->data, buffer);
+		break;
+	case DBD_ROLL_USAGE:
+		slurmdbd_pack_roll_usage_msg((dbd_roll_usage_msg_t *)
+					     req->data, buffer);
+		break;
+	default:
+		error("slurmdbd: Invalid message type %u", req->msg_type);
+		free_buf(buffer);
+		return NULL;
+	}
+	return buffer;
+}
+
+extern int unpack_slurmdbd_msg(slurmdbd_msg_t *resp, Buf buffer)
+{
+	int rc = SLURM_SUCCESS;
+       
+	safe_unpack16(&resp->msg_type, buffer);
+	
+	switch (resp->msg_type) {
+	case DBD_ADD_ACCOUNTS:
+	case DBD_ADD_ASSOCS:
+	case DBD_ADD_CLUSTERS:
+	case DBD_ADD_USERS:
+	case DBD_GOT_ACCOUNTS:
+	case DBD_GOT_ASSOCS:
+	case DBD_GOT_CLUSTERS:
+	case DBD_GOT_JOBS:
+	case DBD_GOT_LIST:
+	case DBD_GOT_USERS:
+	case DBD_UPDATE_SHARES_USED:
+		rc = slurmdbd_unpack_list_msg(
+			resp->msg_type, (dbd_list_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_ADD_ACCOUNT_COORDS:
+	case DBD_REMOVE_ACCOUNT_COORDS:
+		rc = slurmdbd_unpack_acct_coord_msg(
+			(dbd_acct_coord_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_CLUSTER_PROCS:
+	case DBD_FLUSH_JOBS:
+		rc = slurmdbd_unpack_cluster_procs_msg(
+			(dbd_cluster_procs_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_GET_ACCOUNTS:
+	case DBD_GET_ASSOCS:
+	case DBD_GET_CLUSTERS:
+	case DBD_GET_USERS:
+	case DBD_REMOVE_ACCOUNTS:
+	case DBD_REMOVE_ASSOCS:
+	case DBD_REMOVE_CLUSTERS:
+	case DBD_REMOVE_USERS:
+		rc = slurmdbd_unpack_cond_msg(
+			resp->msg_type, (dbd_cond_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_GET_ASSOC_USAGE:
+	case DBD_GOT_ASSOC_USAGE:
+	case DBD_GET_CLUSTER_USAGE:
+	case DBD_GOT_CLUSTER_USAGE:
+		rc = slurmdbd_unpack_usage_msg(
+			resp->msg_type, (dbd_usage_msg_t **)&resp->data, 
+			buffer);
+		break;
+	case DBD_GET_JOBS:
+		rc = slurmdbd_unpack_get_jobs_msg(
+			(dbd_get_jobs_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_INIT:
+		rc = slurmdbd_unpack_init_msg((dbd_init_msg_t **)&resp->data,
+					      buffer, 
+					      slurmdbd_auth_info);
+		break;
+	case DBD_FINI:
+		rc = slurmdbd_unpack_fini_msg((dbd_fini_msg_t **)&resp->data,
+					      buffer);
+		break;		
+	case DBD_JOB_COMPLETE:
+		rc = slurmdbd_unpack_job_complete_msg(
+			(dbd_job_comp_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_JOB_START:
+		rc = slurmdbd_unpack_job_start_msg(
+			(dbd_job_start_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_JOB_START_RC:
+		rc = slurmdbd_unpack_job_start_rc_msg(
+			(dbd_job_start_rc_msg_t **)&resp->data, buffer);
+		break;		
+	case DBD_JOB_SUSPEND:
+		rc = slurmdbd_unpack_job_suspend_msg(
+			(dbd_job_suspend_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_MODIFY_ACCOUNTS:
+	case DBD_MODIFY_ASSOCS:
+	case DBD_MODIFY_CLUSTERS:
+	case DBD_MODIFY_USERS:
+		rc = slurmdbd_unpack_modify_msg(
+			resp->msg_type, (dbd_modify_msg_t **)&resp->data,
+			buffer);
+		break;
+	case DBD_NODE_STATE:
+		rc = slurmdbd_unpack_node_state_msg(
+			(dbd_node_state_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_RC:
+		rc = slurmdbd_unpack_rc_msg((dbd_rc_msg_t **)&resp->data,
+					    buffer);
+		break;
+	case DBD_STEP_COMPLETE:
+		rc = slurmdbd_unpack_step_complete_msg(
+			(dbd_step_comp_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_STEP_START:
+		rc = slurmdbd_unpack_step_start_msg(
+			(dbd_step_start_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_REGISTER_CTLD:
+		rc = slurmdbd_unpack_register_ctld_msg(
+			(dbd_register_ctld_msg_t **)&resp->data, buffer);
+		break;
+	case DBD_ROLL_USAGE:
+		rc = slurmdbd_unpack_roll_usage_msg(
+			(dbd_roll_usage_msg_t **)&resp->data, buffer);
+		break;
+	default:
+		error("slurmdbd: Invalid message type %u", resp->msg_type);
+		return SLURM_ERROR;
+	}
+	return rc;
+
+unpack_error:
+	return SLURM_ERROR;
+}
+
+static int _send_init_msg(void)
+{
+	int rc;
+	Buf buffer;
+	dbd_init_msg_t req;
+
+	buffer = init_buf(1024);
+	pack16((uint16_t) DBD_INIT, buffer);
+	req.rollback = rollback_started;
+	req.version  = SLURMDBD_VERSION;
+	slurmdbd_pack_init_msg(&req, buffer, slurmdbd_auth_info);
+
+	rc = _send_msg(buffer);
+	free_buf(buffer);
+	if (rc != SLURM_SUCCESS) {
+		error("slurmdbd: Sending DBD_INIT message");
+		return rc;
+	}
+
+	rc = _get_return_code();
+	return rc;
+}
+
+static int _send_fini_msg(void)
+{
+	Buf buffer;
+	dbd_fini_msg_t req;
+
+	buffer = init_buf(1024);
+	pack16((uint16_t) DBD_FINI, buffer);
+	req.commit  = 0;
+	req.close_conn   = 1;
+	slurmdbd_pack_fini_msg(&req, buffer);
+
+	_send_msg(buffer);
+	free_buf(buffer);
+	
+	return SLURM_SUCCESS;
+}
+
+/* Close the SlurmDbd connection */
+static void _close_slurmdbd_fd(void)
+{
+	if (slurmdbd_fd >= 0) {
+		close(slurmdbd_fd);
+		slurmdbd_fd = -1;
+	}
+}
+
+/* Reopen the Slurm DBD connection due to some error */
+static void _reopen_slurmdbd_fd(void)
+{
+	info("slurmdbd: reopening connection");
+	_close_slurmdbd_fd();
+	_open_slurmdbd_fd();
+}
+
+static int _send_msg(Buf buffer)
+{
+	uint32_t msg_size, nw_size;
+	char *msg;
+	ssize_t msg_wrote;
+	int rc, retry_cnt = 0;
+
+	if (slurmdbd_fd < 0)
+		return EAGAIN;
+
+	rc =_fd_writeable(slurmdbd_fd);
+	if (rc == -1) {
+	re_open:	/* SlurmDBD shutdown, try to reopen a connection now */
+		if (retry_cnt++ > 3)
+			return EAGAIN;
+		_reopen_slurmdbd_fd();
+		rc = _fd_writeable(slurmdbd_fd);
+	}
+	if (rc < 1)
+		return EAGAIN;
+
+	msg_size = get_buf_offset(buffer);
+	nw_size = htonl(msg_size);
+	msg_wrote = write(slurmdbd_fd, &nw_size, sizeof(nw_size));
+	if (msg_wrote != sizeof(nw_size))
+		return EAGAIN;
+
+	msg = get_buf_data(buffer);
+	while (msg_size > 0) {
+		rc = _fd_writeable(slurmdbd_fd);
+		if (rc == -1)
+			goto re_open;
+		if (rc < 1)
+			return EAGAIN;
+		msg_wrote = write(slurmdbd_fd, msg, msg_size);
+		if (msg_wrote <= 0)
+			return EAGAIN;
+		msg += msg_wrote;
+		msg_size -= msg_wrote;
+	}
+
+	return SLURM_SUCCESS;
+}
+
+static int _get_return_code(void)
+{
+	Buf buffer;
+	uint16_t msg_type;
+	dbd_rc_msg_t *msg;
+	dbd_job_start_rc_msg_t *js_msg;
+	int rc = SLURM_ERROR;
+
+	buffer = _recv_msg();
+	if (buffer == NULL)
+		return rc;
+
+	safe_unpack16(&msg_type, buffer);
+	switch(msg_type) {
+	case DBD_JOB_START_RC:
+		if (slurmdbd_unpack_job_start_rc_msg(&js_msg, buffer)
+		    == SLURM_SUCCESS) {
+			rc = js_msg->return_code;
+			slurmdbd_free_job_start_rc_msg(js_msg);
+			if (rc != SLURM_SUCCESS)
+				error("slurmdbd: DBD_JOB_START_RC is %d", rc);
+		} else
+			error("slurmdbd: unpack message error");
+		break;
+	case DBD_RC:
+		if (slurmdbd_unpack_rc_msg(&msg, buffer) == SLURM_SUCCESS) {
+			rc = msg->return_code;
+			if (rc != SLURM_SUCCESS)
+				error("slurmdbd: DBD_RC is %d from %u: %s",
+				      rc, msg->sent_type, msg->comment);
+			slurmdbd_free_rc_msg(msg);
+		} else
+			error("slurmdbd: unpack message error");
+		break;
+	default:
+		error("slurmdbd: bad message type %d != DBD_RC", msg_type);
+	}
+
+unpack_error:
+	free_buf(buffer);
+	return rc;
+}
+
+static Buf _recv_msg(void)
+{
+	uint32_t msg_size, nw_size;
+	char *msg;
+	ssize_t msg_read, offset;
+	Buf buffer;
+
+	if (slurmdbd_fd < 0)
+		return NULL;
+
+	if (!_fd_readable(slurmdbd_fd))
+		return NULL;
+	msg_read = read(slurmdbd_fd, &nw_size, sizeof(nw_size));
+	if (msg_read != sizeof(nw_size))
+		return NULL;
+	msg_size = ntohl(nw_size);
+	if ((msg_size < 2) || (msg_size > 1000000)) {
+		error("slurmdbd: Invalid msg_size (%u)");
+		return NULL;
+	}
+
+	msg = xmalloc(msg_size);
+	offset = 0;
+	while (msg_size > offset) {
+		if (!_fd_readable(slurmdbd_fd))
+			break;		/* problem with this socket */
+		msg_read = read(slurmdbd_fd, (msg + offset), 
+				(msg_size - offset));
+		if (msg_read <= 0) {
+			error("slurmdbd: read: %m");
+			break;
+		}
+		offset += msg_read;
+	}
+	if (msg_size != offset) {
+		if (agent_shutdown == 0) {
+			error("slurmdbd: only read %d of %d bytes", 
+			      offset, msg_size);
+		}	/* else in shutdown mode */
+		xfree(msg);
+		return NULL;
+	}
+
+	buffer = create_buf(msg, msg_size);
+	if (buffer == NULL)
+		fatal("create_buf: malloc failure");
+	return buffer;
+}
+
+/* Return time in msec since "start time" */
+static int _tot_wait (struct timeval *start_time)
+{
+	struct timeval end_time;
+	int msec_delay;
+
+	gettimeofday(&end_time, NULL);
+	msec_delay =   (end_time.tv_sec  - start_time->tv_sec ) * 1000;
+	msec_delay += ((end_time.tv_usec - start_time->tv_usec + 500) / 1000);
+	return msec_delay;
+}
+
+/* Wait until a file is readable, 
+ * RET false if can not be read */
+static bool _fd_readable(slurm_fd fd)
+{
+	struct pollfd ufds;
+	static int msg_timeout = -1;
+	int rc, time_left;
+	struct timeval tstart;
+
+	if (msg_timeout == -1)
+		msg_timeout = slurm_get_msg_timeout() * 1000;
+
+	ufds.fd     = fd;
+	ufds.events = POLLIN;
+	gettimeofday(&tstart, NULL);
+	while (agent_shutdown == 0) {
+		time_left = msg_timeout - _tot_wait(&tstart);
+		rc = poll(&ufds, 1, time_left);
+		if (rc == -1) {
+			if ((errno == EINTR) || (errno == EAGAIN))
+				continue;
+			error("poll: %m");
+			return false;
+		}
+		if (rc == 0)
+			return false;
+		if (ufds.revents & POLLHUP) {
+			debug2("SlurmDBD connection closed");
+			return false;
+		}
+		if (ufds.revents & POLLNVAL) {
+			error("SlurmDBD connection is invalid");
+			return false;
+		}
+		if (ufds.revents & POLLERR) {
+			error("SlurmDBD connection experienced an error");
+			return false;
+		}
+		if ((ufds.revents & POLLIN) == 0) {
+			error("SlurmDBD connection %d events %d", 
+			      fd, ufds.revents);
+			return false;
+		}
+		/* revents == POLLIN */
+		return true;
+	}
+	return false;
+}
+
+/* Wait until a file is writable, 
+ * RET 1 if file can be written now,
+ *     0 if can not be written to within 5 seconds
+ *     -1 if file has been closed POLLHUP
+ */
+static int _fd_writeable(slurm_fd fd)
+{
+	struct pollfd ufds;
+	int msg_timeout = 5000;
+	int rc, time_left;
+	struct timeval tstart;
+
+	ufds.fd     = fd;
+	ufds.events = POLLOUT;
+	gettimeofday(&tstart, NULL);
+	while (agent_shutdown == 0) {
+		time_left = msg_timeout - _tot_wait(&tstart);
+		rc = poll(&ufds, 1, time_left);
+		if (rc == -1) {
+			if ((errno == EINTR) || (errno == EAGAIN))
+				continue;
+			error("poll: %m");
+			return -1;
+		}
+		if (rc == 0)
+			return 0;
+		if (ufds.revents & POLLHUP) {
+			debug2("SlurmDBD connection is closed");
+			return -1;
+		}
+		if (ufds.revents & POLLNVAL) {
+			error("SlurmDBD connection is invalid");
+			return 0;
+		}
+		if (ufds.revents & POLLERR) {
+			error("SlurmDBD connection experienced an error: %m");
+			return 0;
+		}
+		if ((ufds.revents & POLLOUT) == 0) {
+			error("SlurmDBD connection %d events %d", 
+			      fd, ufds.revents);
+			return 0;
+		}
+		/* revents == POLLOUT */
+		return 1;
+	}
+	return 0;
+}
+
+/****************************************************************************
+ * Functions for agent to manage queue of pending message for the Slurm DBD
+ ****************************************************************************/
+static void _create_agent(void)
+{
+	if (agent_list == NULL) {
+		agent_list = list_create(_agent_queue_del);
+		if (agent_list == NULL)
+			fatal("list_create: malloc failure");
+		_load_dbd_state();
+	}
+
+	if (agent_tid == 0) {
+		pthread_attr_t agent_attr;
+		slurm_attr_init(&agent_attr);
+		if (pthread_create(&agent_tid, &agent_attr, _agent, NULL) ||
+		    (agent_tid == 0))
+			fatal("pthread_create: %m");
+	}
+}
+
+static void _agent_queue_del(void *x)
+{
+	Buf buffer = (Buf) x;
+	free_buf(buffer);
+}
+
+static void _shutdown_agent(void)
+{
+	int i;
+
+	if (agent_tid) {
+		agent_shutdown = time(NULL);
+		for (i=0; i<50; i++) {	/* up to 5 secs total */
+			pthread_cond_broadcast(&agent_cond);
+			usleep(100000);	/* 0.1 sec per try */
+			if (pthread_kill(agent_tid, SIGUSR1))
+				break;
+
+		}
+		/* On rare occasions agent thread may not end quickly, 
+		 * perhaps due to communication problems with slurmdbd. 
+		 * Cancel it and join before returning or we could remove 
+		 * and leave the agent without valid data */
+		if (pthread_kill(agent_tid, 0) == 0) {
+			error("slurmdbd: agent failed to shutdown gracefully");
+			error("slurmdbd: unable to save pending requests");
+			pthread_cancel(agent_tid);
+		}
+		pthread_join(agent_tid,  NULL);
+		agent_tid = 0;
+	}
+}
+
+static void _slurmdbd_packstr(void *str, Buf buffer)
+{
+	packstr((char *)str, buffer);
+}
+
+static int _slurmdbd_unpackstr(void **str, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	safe_unpackstr_xmalloc((char **)str, &uint32_tmp, buffer);
+	return SLURM_SUCCESS;
+unpack_error:
+	return SLURM_ERROR;
+}
+
+static void *_agent(void *x)
+{
+	int cnt, rc;
+	Buf buffer;
+	struct timespec abs_time;
+	static time_t fail_time = 0;
+	int sigarray[] = {SIGUSR1, 0};
+
+	/* Prepare to catch SIGUSR1 to interrupt pending
+	 * I/O and terminate in a timely fashion. */
+	xsignal(SIGUSR1, _sig_handler);
+	xsignal_unblock(sigarray);
+
+	while (agent_shutdown == 0) {
+
+		slurm_mutex_lock(&slurmdbd_lock);
+		if ((slurmdbd_fd < 0) && 
+		    (difftime(time(NULL), fail_time) >= 10)) {
+			/* The connection to Slurm DBD is not open */
+			_open_slurmdbd_fd();
+			if (slurmdbd_fd < 0)
+				fail_time = time(NULL);
+		}
+
+		slurm_mutex_lock(&agent_lock);
+		if (agent_list && slurmdbd_fd)
+			cnt = list_count(agent_list);
+		else
+			cnt = 0;
+		if ((cnt == 0) || (slurmdbd_fd < 0) ||
+		    (fail_time && (difftime(time(NULL), fail_time) < 10))) {
+			slurm_mutex_unlock(&slurmdbd_lock);
+			abs_time.tv_sec  = time(NULL) + 10;
+			abs_time.tv_nsec = 0;
+			rc = pthread_cond_timedwait(&agent_cond, &agent_lock,
+						    &abs_time);
+			slurm_mutex_unlock(&agent_lock);
+			continue;
+		} else if ((cnt > 0) && ((cnt % 50) == 0))
+			info("slurmdbd: agent queue size %u", cnt);
+		/* Leave item on the queue until processing complete */
+		if (agent_list)
+			buffer = (Buf) list_peek(agent_list);
+		else
+			buffer = NULL;
+		slurm_mutex_unlock(&agent_lock);
+		if (buffer == NULL) {
+			slurm_mutex_unlock(&slurmdbd_lock);
+			continue;
+		}
+
+		/* NOTE: agent_lock is clear here, so we can add more
+		 * requests to the queue while waiting for this RPC to 
+		 * complete. */
+		rc = _send_msg(buffer);
+		if (rc != SLURM_SUCCESS) {
+			if (agent_shutdown)
+				break;
+			error("slurmdbd: Failure sending message");
+		} else {
+			rc = _get_return_code();
+			if (rc == EAGAIN) {
+				if (agent_shutdown)
+					break;
+				error("slurmdbd: Failure with "
+				      "message need to resend");
+			}
+		}
+		slurm_mutex_unlock(&slurmdbd_lock);
+
+		slurm_mutex_lock(&agent_lock);
+		if (agent_list && (rc == SLURM_SUCCESS)) {
+			buffer = (Buf) list_dequeue(agent_list);
+			free_buf(buffer);
+			fail_time = 0;
+		} else {
+			fail_time = time(NULL);
+		}
+		slurm_mutex_unlock(&agent_lock);
+	}
+
+	slurm_mutex_lock(&agent_lock);
+	_save_dbd_state();
+	if (agent_list) {
+		list_destroy(agent_list);
+		agent_list = NULL;
+	}
+	slurm_mutex_unlock(&agent_lock);
+	return NULL;
+}
+
+static void _save_dbd_state(void)
+{
+	char *dbd_fname;
+	Buf buffer;
+	int fd, rc, wrote = 0;
+
+	dbd_fname = slurm_get_state_save_location();
+	xstrcat(dbd_fname, "/dbd.messages");
+	fd = open(dbd_fname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+	if (fd < 0) {
+		error("slurmdbd: Creating state save file %s", dbd_fname);
+	} else if (agent_list) {
+		while ((buffer = list_dequeue(agent_list))) {
+			rc = _save_dbd_rec(fd, buffer);
+			free_buf(buffer);
+			if (rc != SLURM_SUCCESS)
+				break;
+			wrote++;
+		}
+	}
+	if (fd >= 0) {
+		verbose("slurmdbd: saved %d pending RPCs", wrote);
+		(void) close(fd);
+	}
+	xfree(dbd_fname);
+}
+
+static void _load_dbd_state(void)
+{
+	char *dbd_fname;
+	Buf buffer;
+	int fd, recovered = 0;
+
+	dbd_fname = slurm_get_state_save_location();
+	xstrcat(dbd_fname, "/dbd.messages");
+	fd = open(dbd_fname, O_RDONLY);
+	if (fd < 0) {
+		error("slurmdbd: Opening state save file %s", dbd_fname);
+	} else {
+		while (1) {
+			buffer = _load_dbd_rec(fd);
+			if (buffer == NULL)
+				break;
+			if (list_enqueue(agent_list, buffer) == NULL)
+				fatal("slurmdbd: list_enqueue, no memory");
+			recovered++;
+		}
+	}
+	if (fd >= 0) {
+		verbose("slurmdbd: recovered %d pending RPCs", recovered);
+		(void) close(fd);
+		(void) unlink(dbd_fname);	/* clear save state */
+	}
+	xfree(dbd_fname);
+}
+
+static int _save_dbd_rec(int fd, Buf buffer)
+{
+	ssize_t size, wrote;
+	uint32_t msg_size = get_buf_offset(buffer);
+	uint32_t magic = DBD_MAGIC;
+	char *msg = get_buf_data(buffer);
+
+	size = sizeof(msg_size);
+	wrote = write(fd, &msg_size, size);
+	if (wrote != size) {
+		error("slurmdbd: state save error: %m");
+		return SLURM_ERROR;
+	}
+
+	wrote = 0;
+	while (wrote < msg_size) {
+		wrote = write(fd, msg, msg_size);
+		if (wrote > 0) {
+			msg += wrote;
+			msg_size -= wrote;
+		} else if ((wrote == -1) && (errno == EINTR))
+			continue;
+		else {
+			error("slurmdbd: state save error: %m");
+			return SLURM_ERROR;
+		}
+	}	
+
+	size = sizeof(magic);
+	wrote = write(fd, &magic, size);
+	if (wrote != size) {
+		error("slurmdbd: state save error: %m");
+		return SLURM_ERROR;
+	}
+
+	return SLURM_SUCCESS;
+}
+
+static Buf _load_dbd_rec(int fd)
+{
+	ssize_t size, rd_size;
+	uint32_t msg_size, magic;
+	char *msg;
+	Buf buffer;
+
+	size = sizeof(msg_size);
+	rd_size = read(fd, &msg_size, size);
+	if (rd_size == 0)
+		return (Buf) NULL;
+	if (rd_size != size) {
+		error("slurmdbd: state recover error: %m");
+		return (Buf) NULL;
+	}
+	if (msg_size > MAX_DBD_MSG_LEN) {
+		error("slurmdbd: state recover error, msg_size=%u", msg_size);
+		return (Buf) NULL;
+	}
+
+	buffer = init_buf((int) msg_size);
+	if (buffer == NULL)
+		fatal("slurmdbd: create_buf malloc failure");
+	set_buf_offset(buffer, msg_size);
+	msg = get_buf_data(buffer);
+	size = msg_size;
+	while (size) {
+		rd_size = read(fd, msg, size);
+		if (rd_size > 0) {
+			msg += rd_size;
+			size -= rd_size;
+		} else if ((rd_size == -1) && (errno == EINTR))
+			continue;
+		else {
+			error("slurmdbd: state recover error: %m");
+			free_buf(buffer);
+			return (Buf) NULL;
+		}
+	}
+
+	size = sizeof(magic);
+	rd_size = read(fd, &magic, size);
+	if ((rd_size != size) || (magic != DBD_MAGIC)) {
+		error("slurmdbd: state recover error");
+		free_buf(buffer);
+		return (Buf) NULL;
+	}
+
+	return buffer;
+}
+
+static void _sig_handler(int signal)
+{
+}
+
+/* Purge queued job/step start records from the agent queue
+ * RET number of records purged */
+static int _purge_job_start_req(void)
+{
+	int purged = 0;
+	ListIterator iter;
+	uint16_t msg_type;
+	uint32_t offset;
+	Buf buffer;
+
+	iter = list_iterator_create(agent_list);
+	while ((buffer = list_next(iter))) {
+		offset = get_buf_offset(buffer);
+		if (offset < 2)
+			continue;
+		set_buf_offset(buffer, 0);
+		unpack16(&msg_type, buffer);
+		set_buf_offset(buffer, offset);
+		if ((msg_type == DBD_JOB_START) ||
+		    (msg_type == DBD_STEP_START)) {
+			list_remove(iter);
+			purged++;
+		}
+	}
+	list_iterator_destroy(iter);
+	info("slurmdbd: purge %d job/step start records", purged);
+	return purged;
+}
+
+/****************************************************************************\
+ * Free data structures
+\****************************************************************************/
+void inline slurmdbd_free_acct_coord_msg(dbd_acct_coord_msg_t *msg)
+{
+	if(msg) {
+		xfree(msg->acct);
+		destroy_acct_user_cond(msg->cond);
+		xfree(msg);
+	}
+}
+void inline slurmdbd_free_cluster_procs_msg(dbd_cluster_procs_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->cluster_name);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_cond_msg(slurmdbd_msg_type_t type,
+				   dbd_cond_msg_t *msg)
+{
+	void (*my_destroy) (void *object);
+
+	if (msg) {
+		switch(type) {
+		case DBD_GET_ACCOUNTS:
+		case DBD_REMOVE_ACCOUNTS:
+			my_destroy = destroy_acct_account_cond;
+			break;
+		case DBD_GET_ASSOCS:
+		case DBD_REMOVE_ASSOCS:
+			my_destroy = destroy_acct_association_cond;
+			break;
+		case DBD_GET_CLUSTERS:
+		case DBD_REMOVE_CLUSTERS:
+			my_destroy = destroy_acct_cluster_cond;
+			break;
+		case DBD_GET_USERS:
+		case DBD_REMOVE_USERS:
+			my_destroy = destroy_acct_user_cond;
+			break;
+		default:
+			fatal("Unknown cond type");
+			return;
+		}
+		if(msg->cond)
+			(*(my_destroy))(msg->cond);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_get_jobs_msg(dbd_get_jobs_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->cluster_name);
+		if(msg->selected_steps)
+			list_destroy(msg->selected_steps);
+		if(msg->selected_parts)
+			list_destroy(msg->selected_parts);
+		xfree(msg->user);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_init_msg(dbd_init_msg_t *msg)
+{
+	xfree(msg);
+}
+
+void inline slurmdbd_free_fini_msg(dbd_fini_msg_t *msg)
+{
+	xfree(msg);
+}
+
+void inline slurmdbd_free_job_complete_msg(dbd_job_comp_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->nodes);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_job_start_msg(dbd_job_start_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->account);
+		xfree(msg->block_id);
+		xfree(msg->name);
+		xfree(msg->nodes);
+		xfree(msg->partition);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_job_start_rc_msg(dbd_job_start_rc_msg_t *msg)
+{
+	xfree(msg);
+}
+
+void inline slurmdbd_free_job_suspend_msg(dbd_job_suspend_msg_t *msg)
+{
+	xfree(msg);
+}
+
+void inline slurmdbd_free_list_msg(dbd_list_msg_t *msg)
+{
+	if (msg) {
+		if(msg->my_list)
+			list_destroy(msg->my_list);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_modify_msg(slurmdbd_msg_type_t type,
+				     dbd_modify_msg_t *msg)
+{
+	void (*destroy_cond) (void *object);
+	void (*destroy_rec) (void *object);
+	
+	if (msg) {
+		switch(type) {
+		case DBD_MODIFY_ACCOUNTS:
+			destroy_cond = destroy_acct_account_cond;
+			destroy_rec = destroy_acct_account_rec;
+			break;
+		case DBD_MODIFY_ASSOCS:
+			destroy_cond = destroy_acct_association_cond;
+			destroy_rec = destroy_acct_association_rec;
+			break;
+		case DBD_MODIFY_CLUSTERS:
+			destroy_cond = destroy_acct_cluster_cond;
+			destroy_rec = destroy_acct_cluster_rec;
+			break;
+		case DBD_MODIFY_USERS:
+			destroy_cond = destroy_acct_user_cond;
+			destroy_rec = destroy_acct_user_rec;
+			break;
+		default:
+			fatal("Unknown modify type");
+			return;
+		}
+		
+		if(msg->cond)
+			(*(destroy_cond))(msg->cond);
+		if(msg->rec)
+			(*(destroy_rec))(msg->rec);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_node_state_msg(dbd_node_state_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->cluster_name);
+		xfree(msg->hostlist);
+		xfree(msg->reason);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_rc_msg(dbd_rc_msg_t *msg)
+{
+	if(msg) {
+		xfree(msg->comment);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_register_ctld_msg(dbd_register_ctld_msg_t *msg)
+{
+	if(msg) {
+		xfree(msg->cluster_name);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_roll_usage_msg(dbd_roll_usage_msg_t *msg)
+{
+	xfree(msg);
+}
+
+void inline slurmdbd_free_step_complete_msg(dbd_step_comp_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->jobacct);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_step_start_msg(dbd_step_start_msg_t *msg)
+{
+	if (msg) {
+		xfree(msg->name);
+		xfree(msg->nodes);
+		xfree(msg);
+	}
+}
+
+void inline slurmdbd_free_usage_msg(slurmdbd_msg_type_t type,
+				    dbd_usage_msg_t *msg)
+{
+	void (*destroy_rec) (void *object);
+	if (msg) {
+		switch(type) {
+		case DBD_GET_ASSOC_USAGE:
+		case DBD_GOT_ASSOC_USAGE:
+			destroy_rec = destroy_acct_association_rec;
+			break;
+		case DBD_GET_CLUSTER_USAGE:
+		case DBD_GOT_CLUSTER_USAGE:
+			destroy_rec = destroy_acct_cluster_rec;
+			break;
+		default:
+			fatal("Unknown usuage type");
+			return;
+		}
+
+		if(msg->rec)
+			(*(destroy_rec))(msg->rec);
+		xfree(msg);
+	}
+}
+
+/****************************************************************************\
+ * Pack and unpack data structures
+\****************************************************************************/
+void inline
+slurmdbd_pack_acct_coord_msg(dbd_acct_coord_msg_t *msg, Buf buffer)
+{
+	packstr(msg->acct, buffer);
+	pack_acct_user_cond(msg->cond, buffer);
+}
+
+int inline
+slurmdbd_unpack_acct_coord_msg(dbd_acct_coord_msg_t **msg, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	dbd_acct_coord_msg_t *msg_ptr = xmalloc(sizeof(dbd_acct_coord_msg_t));
+	*msg = msg_ptr;
+
+	safe_unpackstr_xmalloc(&msg_ptr->acct, &uint32_tmp, buffer);
+	if(unpack_acct_user_cond((void *)&msg_ptr->cond, buffer) == SLURM_ERROR)
+		goto unpack_error;
+unpack_error:
+	slurmdbd_free_acct_coord_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline
+slurmdbd_pack_cluster_procs_msg(dbd_cluster_procs_msg_t *msg, Buf buffer)
+{
+	packstr(msg->cluster_name, buffer);
+	pack32(msg->proc_count,    buffer);
+	pack_time(msg->event_time, buffer);
+}
+
+int inline
+slurmdbd_unpack_cluster_procs_msg(dbd_cluster_procs_msg_t **msg, Buf buffer)
+{
+	dbd_cluster_procs_msg_t *msg_ptr;
+	uint32_t uint32_tmp;
+
+	msg_ptr = xmalloc(sizeof(dbd_cluster_procs_msg_t));
+	*msg = msg_ptr;
+	safe_unpackstr_xmalloc(&msg_ptr->cluster_name, &uint32_tmp, buffer);
+	safe_unpack32(&msg_ptr->proc_count, buffer);
+	safe_unpack_time(&msg_ptr->event_time, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_cluster_procs_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline slurmdbd_pack_cond_msg(slurmdbd_msg_type_t type,
+				   dbd_cond_msg_t *msg, Buf buffer)
+{
+	void (*my_function) (void *object, Buf buffer);
+
+	switch(type) {
+	case DBD_GET_ACCOUNTS:
+	case DBD_REMOVE_ACCOUNTS:
+		my_function = pack_acct_account_cond;
+		break;
+	case DBD_GET_ASSOCS:
+	case DBD_REMOVE_ASSOCS:
+		my_function = pack_acct_association_cond;
+		break;
+	case DBD_GET_CLUSTERS:
+	case DBD_REMOVE_CLUSTERS:
+		my_function = pack_acct_cluster_cond;
+		break;
+	case DBD_GET_USERS:
+	case DBD_REMOVE_USERS:
+		my_function = pack_acct_user_cond;
+		break;
+	default:
+		fatal("Unknown pack type");
+		return;
+	}
+
+	(*(my_function))(msg->cond, buffer);
+}
+
+int inline slurmdbd_unpack_cond_msg(slurmdbd_msg_type_t type,
+				    dbd_cond_msg_t **msg, Buf buffer)
+{
+	dbd_cond_msg_t *msg_ptr = NULL;
+	int (*my_function) (void **object, Buf buffer);
+
+	switch(type) {
+	case DBD_GET_ACCOUNTS:
+	case DBD_REMOVE_ACCOUNTS:
+		my_function = unpack_acct_account_cond;
+		break;
+	case DBD_GET_ASSOCS:
+	case DBD_REMOVE_ASSOCS:
+		my_function = unpack_acct_association_cond;
+		break;
+	case DBD_GET_CLUSTERS:
+	case DBD_REMOVE_CLUSTERS:
+		my_function = unpack_acct_cluster_cond;
+		break;
+	case DBD_GET_USERS:
+	case DBD_REMOVE_USERS:
+		my_function = unpack_acct_user_cond;
+		break;
+	default:
+		fatal("Unknown unpack type");
+		return SLURM_ERROR;
+	}
+
+	msg_ptr = xmalloc(sizeof(dbd_cond_msg_t));
+	*msg = msg_ptr;
+
+	if((*(my_function))(&msg_ptr->cond, buffer) == SLURM_ERROR)
+		goto unpack_error;
+	
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_cond_msg(type, msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline slurmdbd_pack_get_jobs_msg(dbd_get_jobs_msg_t *msg, Buf buffer)
+{
+	uint32_t i = 0;
+	ListIterator itr = NULL;
+	jobacct_selected_step_t *job = NULL;
+	char *part = NULL;
+
+	packstr(msg->cluster_name, buffer);
+
+	pack16(msg->completion, buffer);
+
+	pack32(msg->gid, buffer);
+
+	pack_time(msg->last_update, buffer);
+
+	if(msg->selected_steps) 
+		i = list_count(msg->selected_steps);
+			
+	pack32(i, buffer);
+	if(i) {
+		itr = list_iterator_create(msg->selected_steps);
+		while((job = list_next(itr))) {
+			pack_jobacct_selected_step(job, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+
+	i = 0;
+	if(msg->selected_parts) 
+		i = list_count(msg->selected_parts);
+			
+	pack32(i, buffer);
+	if(i) {
+		itr = list_iterator_create(msg->selected_parts);
+		while((part = list_next(itr))) {
+			packstr(part, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+	packstr(msg->user, buffer);
+}
+
+int inline slurmdbd_unpack_get_jobs_msg(dbd_get_jobs_msg_t **msg, Buf buffer)
+{
+	int i;
+	uint32_t count = 0;
+	uint32_t uint32_tmp;
+	dbd_get_jobs_msg_t *msg_ptr;
+	jobacct_selected_step_t *job = NULL;
+	char *part = NULL;
+
+	msg_ptr = xmalloc(sizeof(dbd_get_jobs_msg_t));
+	*msg = msg_ptr;
+
+	safe_unpackstr_xmalloc(&msg_ptr->cluster_name, &uint32_tmp, buffer);
+
+	safe_unpack16(&msg_ptr->completion, buffer);
+
+	safe_unpack32(&msg_ptr->gid, buffer);
+
+	safe_unpack_time(&msg_ptr->last_update, buffer);
+
+	safe_unpack32(&count, buffer);
+	if(count) {
+		msg_ptr->selected_steps =
+			list_create(destroy_jobacct_selected_step);
+		for(i=0; i<count; i++) {
+			unpack_jobacct_selected_step(&job, buffer);
+			list_append(msg_ptr->selected_steps, job);
+		}
+	}
+	safe_unpack32(&count, buffer);
+	if(count) {
+		msg_ptr->selected_parts = list_create(slurm_destroy_char);
+		for(i=0; i<count; i++) {
+			safe_unpackstr_xmalloc(&part, &uint32_tmp, buffer);
+			list_append(msg_ptr->selected_parts, part);
+		}
+	}
+
+	safe_unpackstr_xmalloc(&msg_ptr->user, &uint32_tmp, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_get_jobs_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_init_msg(dbd_init_msg_t *msg, Buf buffer, char *auth_info)
+{
+	int rc;
+	void *auth_cred;
+
+	pack16(msg->rollback, buffer);
+	pack16(msg->version, buffer);
+	auth_cred = g_slurm_auth_create(NULL, 2, auth_info);
+	if (auth_cred == NULL) {
+		error("Creating authentication credential: %s",
+		      g_slurm_auth_errstr(g_slurm_auth_errno(NULL)));
+	} else {
+		rc = g_slurm_auth_pack(auth_cred, buffer);
+		(void) g_slurm_auth_destroy(auth_cred);
+		if (rc) {
+			error("Packing authentication credential: %s",
+			      g_slurm_auth_errstr(g_slurm_auth_errno(auth_cred)));
+		}
+	}
+}
+
+int inline 
+slurmdbd_unpack_init_msg(dbd_init_msg_t **msg, Buf buffer, char *auth_info)
+{
+	void *auth_cred;
+
+	dbd_init_msg_t *msg_ptr = xmalloc(sizeof(dbd_init_msg_t));
+	*msg = msg_ptr;
+
+	safe_unpack16(&msg_ptr->rollback, buffer);
+	safe_unpack16(&msg_ptr->version, buffer);
+	auth_cred = g_slurm_auth_unpack(buffer);
+	if (auth_cred == NULL) {
+		error("Unpacking authentication credential: %s",
+		      g_slurm_auth_errstr(g_slurm_auth_errno(NULL)));
+		goto unpack_error;
+	}
+	msg_ptr->uid = g_slurm_auth_get_uid(auth_cred, auth_info);
+	g_slurm_auth_destroy(auth_cred);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_init_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_fini_msg(dbd_fini_msg_t *msg, Buf buffer)
+{
+	pack16(msg->close_conn, buffer);
+	pack16(msg->commit, buffer);
+}
+
+int inline 
+slurmdbd_unpack_fini_msg(dbd_fini_msg_t **msg, Buf buffer)
+{
+	dbd_fini_msg_t *msg_ptr = xmalloc(sizeof(dbd_fini_msg_t));
+	*msg = msg_ptr;
+
+	safe_unpack16(&msg_ptr->close_conn, buffer);
+	safe_unpack16(&msg_ptr->commit, buffer);
+
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_fini_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_job_complete_msg(dbd_job_comp_msg_t *msg, Buf buffer)
+{
+	pack32(msg->assoc_id, buffer);
+	pack32(msg->db_index, buffer);
+	pack_time(msg->end_time, buffer);
+	pack32(msg->exit_code, buffer);
+	pack32(msg->job_id, buffer);
+	pack16(msg->job_state, buffer);
+	packstr(msg->nodes, buffer);
+	pack_time(msg->start_time, buffer);
+	pack_time(msg->submit_time, buffer);
+}
+
+int inline 
+slurmdbd_unpack_job_complete_msg(dbd_job_comp_msg_t **msg, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	dbd_job_comp_msg_t *msg_ptr = xmalloc(sizeof(dbd_job_comp_msg_t));
+	*msg = msg_ptr;
+	safe_unpack32(&msg_ptr->assoc_id, buffer);
+	safe_unpack32(&msg_ptr->db_index, buffer);
+	safe_unpack_time(&msg_ptr->end_time, buffer);
+	safe_unpack32(&msg_ptr->exit_code, buffer);
+	safe_unpack32(&msg_ptr->job_id, buffer);
+	safe_unpack16(&msg_ptr->job_state, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->nodes, &uint32_tmp, buffer);
+	safe_unpack_time(&msg_ptr->start_time, buffer);
+	safe_unpack_time(&msg_ptr->submit_time, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_job_complete_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_job_start_msg(dbd_job_start_msg_t *msg, Buf buffer)
+{
+	packstr(msg->account, buffer);
+	pack32(msg->alloc_cpus, buffer);
+	pack32(msg->assoc_id, buffer);
+	packstr(msg->block_id, buffer);
+	pack32(msg->db_index, buffer);
+	pack_time(msg->eligible_time, buffer);
+	pack32(msg->gid, buffer);
+	pack32(msg->job_id, buffer);
+	pack16(msg->job_state, buffer);
+	packstr(msg->name, buffer);
+	packstr(msg->nodes, buffer);
+	packstr(msg->partition, buffer);
+	pack32(msg->priority, buffer);
+	pack32(msg->req_cpus, buffer);
+	pack_time(msg->start_time, buffer);
+	pack_time(msg->submit_time, buffer);
+	pack32(msg->uid, buffer);
+}
+
+int inline 
+slurmdbd_unpack_job_start_msg(dbd_job_start_msg_t **msg, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	dbd_job_start_msg_t *msg_ptr = xmalloc(sizeof(dbd_job_start_msg_t));
+	*msg = msg_ptr;
+	safe_unpackstr_xmalloc(&msg_ptr->account, &uint32_tmp, buffer);
+	safe_unpack32(&msg_ptr->alloc_cpus, buffer);
+	safe_unpack32(&msg_ptr->assoc_id, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->block_id, &uint32_tmp, buffer);
+	safe_unpack32(&msg_ptr->db_index, buffer);
+	safe_unpack_time(&msg_ptr->eligible_time, buffer);
+	safe_unpack32(&msg_ptr->gid, buffer);
+	safe_unpack32(&msg_ptr->job_id, buffer);
+	safe_unpack16(&msg_ptr->job_state, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->nodes, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->partition, &uint32_tmp, buffer);
+	safe_unpack32(&msg_ptr->priority, buffer);
+	safe_unpack32(&msg_ptr->req_cpus, buffer);
+	safe_unpack_time(&msg_ptr->start_time, buffer);
+	safe_unpack_time(&msg_ptr->submit_time, buffer);
+	safe_unpack32(&msg_ptr->uid, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_job_start_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_job_start_rc_msg(dbd_job_start_rc_msg_t *msg, Buf buffer)
+{
+	pack32(msg->db_index, buffer);
+	pack32(msg->return_code, buffer);
+}
+
+int inline 
+slurmdbd_unpack_job_start_rc_msg(dbd_job_start_rc_msg_t **msg, Buf buffer)
+{
+	dbd_job_start_rc_msg_t *msg_ptr = 
+		xmalloc(sizeof(dbd_job_start_rc_msg_t));
+	*msg = msg_ptr;
+	safe_unpack32(&msg_ptr->db_index, buffer);
+	safe_unpack32(&msg_ptr->return_code, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_job_start_rc_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_job_suspend_msg(dbd_job_suspend_msg_t *msg, Buf buffer)
+{
+	pack32(msg->assoc_id, buffer);
+	pack32(msg->db_index, buffer);
+	pack32(msg->job_id, buffer);
+	pack16(msg->job_state, buffer);
+	pack_time(msg->submit_time, buffer);
+	pack_time(msg->suspend_time, buffer);
+}
+
+int inline 
+slurmdbd_unpack_job_suspend_msg(dbd_job_suspend_msg_t **msg, Buf buffer)
+{
+	dbd_job_suspend_msg_t *msg_ptr = xmalloc(sizeof(dbd_job_suspend_msg_t));
+	*msg = msg_ptr;
+	safe_unpack32(&msg_ptr->assoc_id, buffer);
+	safe_unpack32(&msg_ptr->db_index, buffer);
+	safe_unpack32(&msg_ptr->job_id, buffer);
+	safe_unpack16(&msg_ptr->job_state, buffer);
+	safe_unpack_time(&msg_ptr->submit_time, buffer);
+	safe_unpack_time(&msg_ptr->suspend_time, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_job_suspend_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline slurmdbd_pack_list_msg(slurmdbd_msg_type_t type,
+				   dbd_list_msg_t *msg, Buf buffer)
+{
+	uint32_t count = 0;
+	ListIterator itr = NULL;
+	void *object = NULL;
+	void (*my_function) (void *object, Buf buffer);
+
+	switch(type) {
+	case DBD_ADD_ACCOUNTS:
+	case DBD_GOT_ACCOUNTS:
+		my_function = pack_acct_account_rec;
+		break;
+	case DBD_ADD_ASSOCS:
+	case DBD_GOT_ASSOCS:
+		my_function = pack_acct_association_rec;
+		break;
+	case DBD_ADD_CLUSTERS:
+	case DBD_GOT_CLUSTERS:
+		my_function = pack_acct_cluster_rec;
+		break;
+	case DBD_GOT_JOBS:
+		my_function = pack_jobacct_job_rec;
+		break;
+	case DBD_GOT_LIST:
+		my_function = _slurmdbd_packstr;
+		break;
+	case DBD_ADD_USERS:
+	case DBD_GOT_USERS:
+		my_function = pack_acct_user_rec;
+		break;
+	case DBD_UPDATE_SHARES_USED:
+		my_function = pack_update_shares_used;
+		break;
+	default:
+		fatal("Unknown pack type");
+		return;
+	}
+	if(msg->my_list) {
+		count = list_count(msg->my_list);
+		pack32(count, buffer); 
+	} else {
+		// to let user know there wasn't a list (error)
+		pack32((uint32_t)-1, buffer); 
+	}
+	if(count) {
+		itr = list_iterator_create(msg->my_list);
+		while((object = list_next(itr))) {
+			(*(my_function))(object, buffer);
+		}
+		list_iterator_destroy(itr);
+	}
+}
+
+int inline slurmdbd_unpack_list_msg(slurmdbd_msg_type_t type,
+				    dbd_list_msg_t **msg, Buf buffer)
+{
+	int i;
+	uint32_t count;
+	dbd_list_msg_t *msg_ptr = NULL;
+	void *object = NULL;
+	int (*my_function) (void **object, Buf buffer);
+	void (*my_destroy) (void *object);
+
+	switch(type) {
+	case DBD_ADD_ACCOUNTS:
+	case DBD_GOT_ACCOUNTS:
+		my_function = unpack_acct_account_rec;
+		my_destroy = destroy_acct_account_rec;
+		break;
+	case DBD_ADD_ASSOCS:
+	case DBD_GOT_ASSOCS:
+		my_function = unpack_acct_association_rec;
+		my_destroy = destroy_acct_association_rec;
+		break;
+	case DBD_ADD_CLUSTERS:
+	case DBD_GOT_CLUSTERS:
+		my_function = unpack_acct_cluster_rec;
+		my_destroy = destroy_acct_cluster_rec;
+		break;
+	case DBD_GOT_JOBS:
+		my_function = unpack_jobacct_job_rec;
+		my_destroy = destroy_jobacct_job_rec;
+		break;
+	case DBD_GOT_LIST:
+		my_function = _slurmdbd_unpackstr;
+		my_destroy = slurm_destroy_char;
+		break;
+	case DBD_ADD_USERS:
+	case DBD_GOT_USERS:
+		my_function = unpack_acct_user_rec;
+		my_destroy = destroy_acct_user_rec;
+		break;
+	case DBD_UPDATE_SHARES_USED:
+		my_function = unpack_update_shares_used;
+		my_destroy = destroy_update_shares_rec;
+		break;
+	default:
+		fatal("Unknown unpack type");
+		return SLURM_ERROR;
+	}
+
+	msg_ptr = xmalloc(sizeof(dbd_list_msg_t));
+	*msg = msg_ptr;
+	safe_unpack32(&count, buffer);
+	if((int)count > -1) {
+		/* here we are looking to make the list if -1 or
+		   higher than 0.  If -1 we don't want to have the
+		   list be NULL meaning an error occured.
+		*/
+		msg_ptr->my_list = list_create((*(my_destroy)));
+		for(i=0; i<count; i++) {
+			if(((*(my_function))(&object, buffer)) == SLURM_ERROR)
+				goto unpack_error;
+			list_append(msg_ptr->my_list, object);
+		}
+	}
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_list_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline slurmdbd_pack_modify_msg(slurmdbd_msg_type_t type,
+				     dbd_modify_msg_t *msg, Buf buffer)
+{
+	void (*my_cond) (void *object, Buf buffer);
+	void (*my_rec) (void *object, Buf buffer);
+
+	switch(type) {
+	case DBD_MODIFY_ACCOUNTS:
+		my_cond = pack_acct_account_cond;
+		my_rec = pack_acct_account_rec;
+		break;
+	case DBD_MODIFY_ASSOCS:
+		my_cond = pack_acct_association_cond;
+		my_rec = pack_acct_association_rec;
+		break;
+	case DBD_MODIFY_CLUSTERS:
+		my_cond = pack_acct_cluster_cond;
+		my_rec = pack_acct_cluster_rec;
+		break;
+	case DBD_MODIFY_USERS:
+		my_cond = pack_acct_user_cond;
+		my_rec = pack_acct_user_rec;
+		break;
+	default:
+		fatal("Unknown pack type");
+		return;
+	}
+	(*(my_cond))(msg->cond, buffer);
+	(*(my_rec))(msg->rec, buffer);
+}
+
+int inline slurmdbd_unpack_modify_msg(slurmdbd_msg_type_t type,
+				      dbd_modify_msg_t **msg, Buf buffer)
+{
+	dbd_modify_msg_t *msg_ptr = NULL;
+	int (*my_cond) (void **object, Buf buffer);
+	int (*my_rec) (void **object, Buf buffer);
+
+	msg_ptr = xmalloc(sizeof(dbd_modify_msg_t));
+	*msg = msg_ptr;
+
+	switch(type) {
+	case DBD_MODIFY_ACCOUNTS:
+		my_cond = unpack_acct_account_cond;
+		my_rec = unpack_acct_account_rec;
+		break;
+	case DBD_MODIFY_ASSOCS:
+		my_cond = unpack_acct_association_cond;
+		my_rec = unpack_acct_association_rec;
+		break;
+	case DBD_MODIFY_CLUSTERS:
+		my_cond = unpack_acct_cluster_cond;
+		my_rec = unpack_acct_cluster_rec;
+		break;
+	case DBD_MODIFY_USERS:
+		my_cond = unpack_acct_user_cond;
+		my_rec = unpack_acct_user_rec;
+		break;
+	default:
+		fatal("Unknown unpack type");
+		return SLURM_ERROR;
+	}
+
+	if((*(my_cond))(&msg_ptr->cond, buffer) == SLURM_ERROR)
+		goto unpack_error;
+	if((*(my_rec))(&msg_ptr->rec, buffer) == SLURM_ERROR)
+		goto unpack_error;
+	
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_modify_msg(type, msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_node_state_msg(dbd_node_state_msg_t *msg, Buf buffer)
+{
+	packstr(msg->cluster_name, buffer);
+	pack32(msg->cpu_count, buffer);
+	packstr(msg->hostlist, buffer);
+	packstr(msg->reason, buffer);
+	pack16(msg->new_state, buffer);
+	pack_time(msg->event_time, buffer);
+}
+
+int inline
+slurmdbd_unpack_node_state_msg(dbd_node_state_msg_t **msg, Buf buffer)
+{
+	dbd_node_state_msg_t *msg_ptr;
+	uint32_t uint32_tmp;
+
+	msg_ptr = xmalloc(sizeof(dbd_node_state_msg_t));
+	*msg = msg_ptr;
+	safe_unpackstr_xmalloc(&msg_ptr->cluster_name, &uint32_tmp, buffer);
+	safe_unpack32(&msg_ptr->cpu_count, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->hostlist, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->reason,   &uint32_tmp, buffer);
+	safe_unpack16(&msg_ptr->new_state, buffer);
+	safe_unpack_time(&msg_ptr->event_time, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_node_state_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_rc_msg(dbd_rc_msg_t *msg, Buf buffer)
+{
+	packstr(msg->comment, buffer);
+	pack32(msg->return_code, buffer);
+	pack16(msg->sent_type, buffer);
+}
+
+int inline 
+slurmdbd_unpack_rc_msg(dbd_rc_msg_t **msg, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	dbd_rc_msg_t *msg_ptr = xmalloc(sizeof(dbd_rc_msg_t));
+	*msg = msg_ptr;
+	safe_unpackstr_xmalloc(&msg_ptr->comment, &uint32_tmp, buffer);
+	safe_unpack32(&msg_ptr->return_code, buffer);
+	safe_unpack16(&msg_ptr->sent_type, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_rc_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_register_ctld_msg(dbd_register_ctld_msg_t *msg, Buf buffer)
+{
+	packstr(msg->cluster_name, buffer);
+	pack16(msg->port, buffer);
+}
+
+int inline 
+slurmdbd_unpack_register_ctld_msg(dbd_register_ctld_msg_t **msg, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	dbd_register_ctld_msg_t *msg_ptr = xmalloc(
+		sizeof(dbd_register_ctld_msg_t));
+	*msg = msg_ptr;
+	safe_unpackstr_xmalloc(&msg_ptr->cluster_name, &uint32_tmp, buffer);
+	safe_unpack16(&msg_ptr->port, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_register_ctld_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_roll_usage_msg(dbd_roll_usage_msg_t *msg, Buf buffer)
+{
+	pack_time(msg->start, buffer);
+}
+
+int inline 
+slurmdbd_unpack_roll_usage_msg(dbd_roll_usage_msg_t **msg, Buf buffer)
+{
+	dbd_roll_usage_msg_t *msg_ptr = xmalloc(sizeof(dbd_roll_usage_msg_t));
+
+	*msg = msg_ptr;
+	safe_unpack_time(&msg_ptr->start, buffer);
+	return SLURM_SUCCESS;
+	
+unpack_error:
+	slurmdbd_free_roll_usage_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_step_complete_msg(dbd_step_comp_msg_t *msg, Buf buffer)
+{
+	pack32(msg->assoc_id, buffer);
+	pack32(msg->db_index, buffer);
+	pack_time(msg->end_time, buffer);
+	jobacct_common_pack((struct jobacctinfo *)msg->jobacct, buffer);
+	pack32(msg->job_id, buffer);
+	pack32(msg->req_uid, buffer);
+	pack_time(msg->start_time, buffer);
+	pack_time(msg->job_submit_time, buffer);
+	pack32(msg->step_id, buffer);
+	pack32(msg->total_procs, buffer);
+}
+
+int inline 
+slurmdbd_unpack_step_complete_msg(dbd_step_comp_msg_t **msg, Buf buffer)
+{
+	dbd_step_comp_msg_t *msg_ptr = xmalloc(sizeof(dbd_step_comp_msg_t));
+	*msg = msg_ptr;
+	safe_unpack32(&msg_ptr->assoc_id, buffer);
+	safe_unpack32(&msg_ptr->db_index, buffer);
+	safe_unpack_time(&msg_ptr->end_time, buffer);
+	jobacct_common_unpack((struct jobacctinfo **)&msg_ptr->jobacct, buffer);
+	safe_unpack32(&msg_ptr->job_id, buffer);
+	safe_unpack32(&msg_ptr->req_uid, buffer);
+	safe_unpack_time(&msg_ptr->start_time, buffer);
+	safe_unpack_time(&msg_ptr->job_submit_time, buffer);
+	safe_unpack32(&msg_ptr->step_id, buffer);
+	safe_unpack32(&msg_ptr->total_procs, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_step_complete_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline 
+slurmdbd_pack_step_start_msg(dbd_step_start_msg_t *msg, Buf buffer)
+{
+	pack32(msg->assoc_id, buffer);
+	pack32(msg->db_index, buffer);
+	pack32(msg->job_id, buffer);
+	packstr(msg->name, buffer);
+	packstr(msg->nodes, buffer);
+	pack_time(msg->start_time, buffer);
+	pack_time(msg->job_submit_time, buffer);
+	pack32(msg->step_id, buffer);
+	pack32(msg->total_procs, buffer);
+}
+
+int inline 
+slurmdbd_unpack_step_start_msg(dbd_step_start_msg_t **msg, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	dbd_step_start_msg_t *msg_ptr = xmalloc(sizeof(dbd_step_start_msg_t));
+	*msg = msg_ptr;
+	safe_unpack32(&msg_ptr->assoc_id, buffer);
+	safe_unpack32(&msg_ptr->db_index, buffer);
+	safe_unpack32(&msg_ptr->job_id, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->name, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&msg_ptr->nodes, &uint32_tmp, buffer);
+	safe_unpack_time(&msg_ptr->start_time, buffer);
+	safe_unpack_time(&msg_ptr->job_submit_time, buffer);
+	safe_unpack32(&msg_ptr->step_id, buffer);
+	safe_unpack32(&msg_ptr->total_procs, buffer);
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_step_start_msg(msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
+void inline slurmdbd_pack_usage_msg(slurmdbd_msg_type_t type,
+				    dbd_usage_msg_t *msg, Buf buffer)
+{
+	void (*my_rec) (void *object, Buf buffer);
+
+	switch(type) {
+	case DBD_GET_ASSOC_USAGE:
+	case DBD_GOT_ASSOC_USAGE:
+		my_rec = pack_acct_association_rec;
+		break;
+	case DBD_GET_CLUSTER_USAGE:
+	case DBD_GOT_CLUSTER_USAGE:
+		my_rec = pack_acct_cluster_rec;
+		break;
+	default:
+		fatal("Unknown pack type");
+		return;
+	}
+	
+	(*(my_rec))(msg->rec, buffer);
+	pack_time(msg->start, buffer);
+	pack_time(msg->end, buffer);
+}
+
+int inline slurmdbd_unpack_usage_msg(slurmdbd_msg_type_t type,
+				     dbd_usage_msg_t **msg, Buf buffer)
+{
+	dbd_usage_msg_t *msg_ptr = NULL;
+	int (*my_rec) (void **object, Buf buffer);
+
+	msg_ptr = xmalloc(sizeof(dbd_usage_msg_t));
+	*msg = msg_ptr;
+
+	switch(type) {
+	case DBD_GET_ASSOC_USAGE:
+	case DBD_GOT_ASSOC_USAGE:
+		my_rec = unpack_acct_association_rec;
+		break;
+	case DBD_GET_CLUSTER_USAGE:
+	case DBD_GOT_CLUSTER_USAGE:
+		my_rec = unpack_acct_cluster_rec;
+		break;
+	default:
+		fatal("Unknown pack type");
+		return SLURM_ERROR;
+	}
+
+	if((*(my_rec))(&msg_ptr->rec, buffer) == SLURM_ERROR)
+		goto unpack_error;
+
+	unpack_time(&msg_ptr->start, buffer);
+	unpack_time(&msg_ptr->end, buffer);
+
+	
+	return SLURM_SUCCESS;
+
+unpack_error:
+	slurmdbd_free_usage_msg(type, msg_ptr);
+	*msg = NULL;
+	return SLURM_ERROR;
+}
+
diff --git a/src/common/slurmdbd_defs.h b/src/common/slurmdbd_defs.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e3ff3f7aad3cba3ffed536bfa8e80a941cacff0
--- /dev/null
+++ b/src/common/slurmdbd_defs.h
@@ -0,0 +1,424 @@
+/****************************************************************************\
+ *  slurmdbd_defs.h - definitions used for Slurm DBD RPCs
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _SLURMDBD_DEFS_H
+#define _SLURMDBD_DEFS_H
+
+#if HAVE_CONFIG_H 
+#  include "config.h"
+#  if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#  else
+#    if HAVE_STDINT_H
+#      include <stdint.h>
+#    endif
+#  endif			/* HAVE_INTTYPES_H */
+#else				/* !HAVE_CONFIG_H */
+#  include <inttypes.h>
+#endif				/*  HAVE_CONFIG_H */
+
+#include <slurm/slurm.h>
+
+#include "src/common/pack.h"
+#include "src/common/list.h"
+#include "src/common/slurm_accounting_storage.h"
+
+/* Increment SLURMDBD_VERSION if any of the RPCs change */
+#define SLURMDBD_VERSION 01
+
+/* SLURM DBD message types */
+typedef enum {
+	DBD_INIT = 1400,	/* Connection initialization		*/
+	DBD_FINI,       	/* Connection finalization		*/
+	DBD_ADD_ACCOUNTS,       /* Add new account to the mix           */
+	DBD_ADD_ACCOUNT_COORDS, /* Add new coordinatior to an account   */
+	DBD_ADD_ASSOCS,         /* Add new association to the mix       */
+	DBD_ADD_CLUSTERS,       /* Add new cluster to the mix           */
+	DBD_ADD_USERS,          /* Add new user to the mix              */
+	DBD_CLUSTER_PROCS,	/* Record total processors on cluster	*/
+	DBD_FLUSH_JOBS, 	/* End jobs that are still running
+				 * when a controller is restarted.	*/
+	DBD_GET_ACCOUNTS,	/* Get account information		*/
+	DBD_GET_ASSOCS,         /* Get assocation information   	*/
+	DBD_GET_ASSOC_USAGE,  	/* Get assoc usage information  	*/
+	DBD_GET_CLUSTERS,	/* Get account information		*/
+	DBD_GET_CLUSTER_USAGE, 	/* Get cluster usage information	*/
+	DBD_GET_JOBS,		/* Get job information			*/
+	DBD_GET_USERS,  	/* Get account information		*/
+	DBD_GOT_ACCOUNTS,	/* Response to DBD_GET_ACCOUNTS		*/
+	DBD_GOT_ASSOCS, 	/* Response to DBD_GET_ASSOCS   	*/
+	DBD_GOT_ASSOC_USAGE,  	/* Response to DBD_GET_ASSOC_USAGE    	*/
+	DBD_GOT_CLUSTERS,	/* Response to DBD_GET_CLUSTERS		*/
+	DBD_GOT_CLUSTER_USAGE, 	/* Response to DBD_GET_CLUSTER_USAGE   	*/
+	DBD_GOT_JOBS,		/* Response to DBD_GET_JOBS		*/
+	DBD_GOT_LIST,           /* Response to DBD_MODIFY/REMOVE MOVE_* */
+	DBD_GOT_USERS,  	/* Response to DBD_GET_USERS		*/
+	DBD_JOB_COMPLETE,	/* Record job completion 		*/
+	DBD_JOB_START,		/* Record job starting			*/
+	DBD_JOB_START_RC,	/* return db_index from job insertion 	*/
+	DBD_JOB_SUSPEND,	/* Record job suspension		*/
+	DBD_MODIFY_ACCOUNTS,    /* Modify existing account              */
+	DBD_MODIFY_ASSOCS,      /* Modify existing association          */
+	DBD_MODIFY_CLUSTERS,    /* Modify existing cluster              */
+	DBD_MODIFY_USERS,       /* Modify existing user                 */
+	DBD_NODE_STATE,		/* Record node state transition		*/
+	DBD_RC,			/* Return code from operation		*/
+	DBD_REGISTER_CTLD,	/* Register a slurmctld's comm port	*/
+	DBD_REMOVE_ACCOUNTS,    /* Remove existing account              */
+	DBD_REMOVE_ACCOUNT_COORDS,/* Remove existing coordinatior from
+				   * an account */
+	DBD_REMOVE_ASSOCS,      /* Remove existing association          */
+	DBD_REMOVE_CLUSTERS,    /* Remove existing cluster              */
+	DBD_REMOVE_USERS,       /* Remove existing user                 */
+	DBD_ROLL_USAGE,         /* Roll up usage                        */
+	DBD_STEP_COMPLETE,	/* Record step completion		*/
+	DBD_STEP_START,		/* Record step starting			*/
+	DBD_UPDATE_SHARES_USED	/* Record current share usage		*/
+} slurmdbd_msg_type_t;
+
+/*****************************************************************************\
+ * Slurm DBD protocol data structures
+\*****************************************************************************/
+
+typedef struct slurmdbd_msg {
+	uint16_t msg_type;	/* see slurmdbd_msg_type_t above */
+	void * data;		/* pointer to a message type below */
+} slurmdbd_msg_t;
+
+typedef struct {
+	char *acct;
+	acct_user_cond_t *cond;
+} dbd_acct_coord_msg_t;
+
+typedef struct dbd_cluster_procs_msg {
+	char *cluster_name;	/* name of cluster */
+	uint32_t proc_count;	/* total processor count */
+	time_t event_time;	/* time of transition */
+} dbd_cluster_procs_msg_t;
+
+typedef struct {
+	void *cond; /* this could be anything based on the type types
+		     * are defined in slurm_accounting_storage.h
+		     * *_cond_t */
+} dbd_cond_msg_t;
+
+typedef struct {
+	time_t start;
+} dbd_roll_usage_msg_t;
+
+typedef struct {
+	void *rec;
+	time_t start;
+	time_t end;
+} dbd_usage_msg_t;
+
+typedef struct dbd_get_jobs_msg {
+	char *cluster_name;	/* name of cluster to query */
+	uint16_t completion;	/* get job completion records instead
+				 * of accounting record */
+	uint32_t gid;		/* group id */
+	time_t last_update;	/* time of latest info */
+	List selected_steps;	/* List of jobacct_selected_step_t *'s */
+	List selected_parts;	/* List of char *'s */
+	char *user;		/* user name */
+} dbd_get_jobs_msg_t;
+
+typedef struct dbd_init_msg {
+	uint16_t rollback;      /* to allow rollbacks or not */     
+	uint16_t version;	/* protocol version */
+	uint32_t uid;		/* UID originating connection,
+				 * filled by authtentication plugin*/
+} dbd_init_msg_t;
+
+typedef struct dbd_fini_msg {
+	uint16_t close_conn;  /* to close connection 1, 0 will keep
+				 connection open */
+	uint16_t commit;      /* to rollback(0) or commit(1) changes */     
+} dbd_fini_msg_t;
+
+typedef struct dbd_job_comp_msg {
+	uint32_t assoc_id;	/* accounting association id needed to
+				 * find job record in db */
+	uint32_t db_index;	/* index into the db for this job */
+	time_t   end_time;	/* job termintation time */
+	uint32_t exit_code;	/* job exit code or signal */
+	uint32_t job_id;	/* job ID */
+	uint16_t job_state;	/* job state */
+	char *   nodes;		/* hosts allocated to the job */
+	time_t   start_time;	/* job start time */
+	time_t   submit_time;	/* job submit time needed to find job
+				 * record in db */
+} dbd_job_comp_msg_t;
+
+typedef struct dbd_job_start_msg {
+	char *   account;       /* Account name for those not running
+				 * with associations */
+	uint32_t alloc_cpus;	/* count of allocated processors */
+	uint32_t assoc_id;	/* accounting association id */
+	char *   block_id;      /* Bluegene block id */
+	uint32_t db_index;	/* index into the db for this job */
+	time_t   eligible_time;	/* time job becomes eligible to run */
+	uint32_t gid;	        /* group ID */
+	uint32_t job_id;	/* job ID */
+	uint16_t job_state;	/* job state */
+	char *   name;		/* job name */
+	char *   nodes;		/* hosts allocated to the job */
+	char *   partition;	/* partition job is running on */
+	uint32_t priority;	/* job priority */
+	uint32_t req_cpus;	/* count of req processors */
+	time_t   start_time;	/* job start time */
+	time_t   submit_time;	/* job submit time */
+	uint32_t uid;	        /* user ID if associations are being used */
+} dbd_job_start_msg_t;
+
+typedef struct dbd_job_start_rc_msg {
+	uint32_t db_index;	/* db_index */
+	uint32_t return_code;
+} dbd_job_start_rc_msg_t;
+
+typedef struct dbd_job_suspend_msg {
+	uint32_t assoc_id;	/* accounting association id needed
+				 * to find job record in db */
+	uint32_t db_index;	/* index into the db for this job */
+	uint32_t job_id;	/* job ID needed to find job record
+				 * in db */
+	uint16_t job_state;	/* job state */
+	time_t   submit_time;	/* job submit time needed to find job record
+				 * in db */
+	time_t   suspend_time;	/* job suspend or resume time */
+} dbd_job_suspend_msg_t;
+
+typedef struct {
+	List my_list;		/* this list could be of any type as long as it
+				 * is handled correctly on both ends */
+} dbd_list_msg_t;
+
+typedef struct {
+	void *cond;
+	void *rec;
+} dbd_modify_msg_t;
+
+#define DBD_NODE_STATE_DOWN  1
+#define DBD_NODE_STATE_UP    2
+typedef struct dbd_node_state_msg {
+	char *cluster_name;	/* name of cluster */
+	uint32_t cpu_count;     /* number of cpus on node */
+	time_t event_time;	/* time of transition */
+	char *hostlist;		/* name of hosts */
+	uint16_t new_state;	/* new state of host, see DBD_NODE_STATE_* */
+	char *reason;		/* explanation for the node's state */
+} dbd_node_state_msg_t;
+
+typedef struct dbd_rc_msg {
+	char *   comment;	/* reason for failure */
+	uint32_t return_code;
+	uint16_t sent_type;	/* type of message this is in response to */
+} dbd_rc_msg_t;
+
+typedef struct dbd_register_ctld_msg {
+	char *cluster_name;	/* name of cluster */
+	uint16_t port;		/* slurmctld's comm port */
+} dbd_register_ctld_msg_t;
+
+typedef struct dbd_step_comp_msg {
+	uint32_t assoc_id;	/* accounting association id */
+	uint32_t db_index;	/* index into the db for this job */
+	time_t   end_time;	/* job termintation time */
+	jobacctinfo_t *jobacct; /* status info */
+	uint32_t job_id;	/* job ID */
+	uint32_t req_uid;	/* requester user ID */
+	time_t   start_time;	/* step start time */
+	time_t   job_submit_time;/* job submit time needed to find job record
+				  * in db */
+	uint32_t step_id;	/* step ID */
+	uint32_t total_procs;	/* count of allocated processors */
+} dbd_step_comp_msg_t;
+
+typedef struct dbd_step_start_msg {
+	uint32_t assoc_id;	/* accounting association id */
+	uint32_t db_index;	/* index into the db for this job */
+	uint32_t job_id;	/* job ID */
+	char *   name;		/* step name */
+	char *   nodes;		/* hosts allocated to the step */
+	time_t   start_time;	/* step start time */
+	time_t   job_submit_time;/* job submit time needed to find job record
+				  * in db */
+	uint32_t step_id;	/* step ID */
+	uint32_t total_procs;	/* count of allocated processors */
+} dbd_step_start_msg_t;
+
+/*****************************************************************************\
+ * Slurm DBD message processing functions
+\*****************************************************************************/
+
+/* Open a socket connection to SlurmDbd
+ * auth_info IN - alternate authentication key
+ * make_agent IN - make agent to process RPCs if set
+ * rollback IN - keep journal and permit rollback if set
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_open_slurmdbd_conn(char *auth_info, bool make_agent, 
+				    bool rollback);
+
+/* Close the SlurmDBD socket connection */
+extern int slurm_close_slurmdbd_conn();
+
+/* Send an RPC to the SlurmDBD. Do not wait for the reply. The RPC
+ * will be queued and processed later if the SlurmDBD is not responding.
+ * NOTE: slurm_open_slurmdbd_conn() must have been called with make_agent set
+ * 
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_send_slurmdbd_msg(slurmdbd_msg_t *req);
+
+/* Send an RPC to the SlurmDBD and wait for an arbitrary reply message.
+ * The RPC will not be queued if an error occurs.
+ * The "resp" message must be freed by the caller.
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_send_recv_slurmdbd_msg(slurmdbd_msg_t *req, 
+					slurmdbd_msg_t *resp);
+
+/* Send an RPC to the SlurmDBD and wait for the return code reply.
+ * The RPC will not be queued if an error occurs.
+ * Returns SLURM_SUCCESS or an error code */
+extern int slurm_send_slurmdbd_recv_rc_msg(slurmdbd_msg_t *req, int *rc);
+
+extern Buf pack_slurmdbd_msg(slurmdbd_msg_t *req);
+extern int unpack_slurmdbd_msg(slurmdbd_msg_t *resp, Buf buffer);
+/*****************************************************************************\
+ * Free various SlurmDBD message structures
+\*****************************************************************************/
+void inline slurmdbd_free_acct_coord_msg(dbd_acct_coord_msg_t *msg);
+void inline slurmdbd_free_cluster_procs_msg(dbd_cluster_procs_msg_t *msg);
+void inline slurmdbd_free_cond_msg(slurmdbd_msg_type_t type,
+				   dbd_cond_msg_t *msg);
+void inline slurmdbd_free_get_jobs_msg(dbd_get_jobs_msg_t *msg);
+void inline slurmdbd_free_init_msg(dbd_init_msg_t *msg);
+void inline slurmdbd_free_fini_msg(dbd_fini_msg_t *msg);
+void inline slurmdbd_free_job_complete_msg(dbd_job_comp_msg_t *msg);
+void inline slurmdbd_free_job_start_msg(dbd_job_start_msg_t *msg);
+void inline slurmdbd_free_job_start_rc_msg(dbd_job_start_rc_msg_t *msg);
+void inline slurmdbd_free_job_suspend_msg(dbd_job_suspend_msg_t *msg);
+void inline slurmdbd_free_list_msg(dbd_list_msg_t *msg);
+void inline slurmdbd_free_modify_msg(slurmdbd_msg_type_t type,
+				      dbd_modify_msg_t *msg);
+void inline slurmdbd_free_node_state_msg(dbd_node_state_msg_t *msg);
+void inline slurmdbd_free_rc_msg(dbd_rc_msg_t *msg);
+void inline slurmdbd_free_register_ctld_msg(dbd_register_ctld_msg_t *msg);
+void inline slurmdbd_free_roll_usage_msg(dbd_roll_usage_msg_t *msg);
+void inline slurmdbd_free_step_complete_msg(dbd_step_comp_msg_t *msg);
+void inline slurmdbd_free_step_start_msg(dbd_step_start_msg_t *msg);
+void inline slurmdbd_free_usage_msg(slurmdbd_msg_type_t type,
+				    dbd_usage_msg_t *msg);
+
+/*****************************************************************************\
+ * Pack various SlurmDBD message structures into a buffer
+\*****************************************************************************/
+void inline slurmdbd_pack_acct_coord_msg(dbd_acct_coord_msg_t *msg,
+					  Buf buffer);
+void inline slurmdbd_pack_cluster_procs_msg(dbd_cluster_procs_msg_t *msg,
+					     Buf buffer);
+void inline slurmdbd_pack_cond_msg(slurmdbd_msg_type_t type,
+				    dbd_cond_msg_t *msg, Buf buffer);
+void inline slurmdbd_pack_get_jobs_msg(dbd_get_jobs_msg_t *msg, Buf buffer);
+void inline slurmdbd_pack_init_msg(dbd_init_msg_t *msg, Buf buffer,
+				    char *auth_info);
+void inline slurmdbd_pack_fini_msg(dbd_fini_msg_t *msg, Buf buffer);
+void inline slurmdbd_pack_job_complete_msg(dbd_job_comp_msg_t *msg,
+					    Buf buffer);
+void inline slurmdbd_pack_job_start_msg(dbd_job_start_msg_t *msg,
+					 Buf buffer);
+void inline slurmdbd_pack_job_start_rc_msg(dbd_job_start_rc_msg_t *msg,
+					    Buf buffer);
+void inline slurmdbd_pack_job_suspend_msg(dbd_job_suspend_msg_t *msg,
+					   Buf buffer);
+void inline slurmdbd_pack_list_msg(slurmdbd_msg_type_t type,
+				    dbd_list_msg_t *msg, Buf buffer);
+void inline slurmdbd_pack_modify_msg(slurmdbd_msg_type_t type,
+				      dbd_modify_msg_t *msg, Buf buffer);
+void inline slurmdbd_pack_node_state_msg(dbd_node_state_msg_t *msg,
+					  Buf buffer);
+void inline slurmdbd_pack_rc_msg(dbd_rc_msg_t *msg, Buf buffer);
+void inline slurmdbd_pack_register_ctld_msg(dbd_register_ctld_msg_t *msg,
+					    Buf buffer);
+void inline slurmdbd_pack_roll_usage_msg(dbd_roll_usage_msg_t *msg, Buf buffer);
+void inline slurmdbd_pack_step_complete_msg(dbd_step_comp_msg_t *msg,
+					     Buf buffer);
+void inline slurmdbd_pack_step_start_msg(dbd_step_start_msg_t *msg,
+					  Buf buffer);
+void inline slurmdbd_pack_usage_msg(slurmdbd_msg_type_t type,
+				    dbd_usage_msg_t *msg, Buf buffer);
+
+/*****************************************************************************\
+ * Unpack various SlurmDBD message structures from a buffer
+\*****************************************************************************/
+int inline slurmdbd_unpack_acct_coord_msg(dbd_acct_coord_msg_t **msg,
+					   Buf buffer);
+int inline slurmdbd_unpack_cluster_procs_msg(dbd_cluster_procs_msg_t **msg,
+					      Buf buffer);
+int inline slurmdbd_unpack_cond_msg(slurmdbd_msg_type_t type,
+				     dbd_cond_msg_t **msg, Buf buffer);
+int inline slurmdbd_unpack_get_jobs_msg(dbd_get_jobs_msg_t **msg, Buf buffer);
+int inline slurmdbd_unpack_init_msg(dbd_init_msg_t **msg, Buf buffer,
+				    char *auth_info);
+int inline slurmdbd_unpack_fini_msg(dbd_fini_msg_t **msg, Buf buffer);
+int inline slurmdbd_unpack_job_complete_msg(dbd_job_comp_msg_t **msg,
+					     Buf buffer);
+int inline slurmdbd_unpack_job_start_msg(dbd_job_start_msg_t **msg,
+					  Buf buffer);
+int inline slurmdbd_unpack_job_start_rc_msg(dbd_job_start_rc_msg_t **msg,
+					     Buf buffer);
+int inline slurmdbd_unpack_job_suspend_msg(dbd_job_suspend_msg_t **msg,
+					    Buf buffer);
+int inline slurmdbd_unpack_list_msg(slurmdbd_msg_type_t type,
+				     dbd_list_msg_t **msg, Buf buffer);
+int inline slurmdbd_unpack_modify_msg(slurmdbd_msg_type_t type,
+				       dbd_modify_msg_t **msg, Buf buffer);
+int inline slurmdbd_unpack_node_state_msg(dbd_node_state_msg_t **msg,
+					   Buf buffer);
+int inline slurmdbd_unpack_rc_msg(dbd_rc_msg_t **msg, Buf buffer);
+int inline slurmdbd_unpack_register_ctld_msg(dbd_register_ctld_msg_t **msg, 
+					     Buf buffer);
+int inline slurmdbd_unpack_roll_usage_msg(dbd_roll_usage_msg_t **msg,
+					  Buf buffer);
+int inline slurmdbd_unpack_step_complete_msg(dbd_step_comp_msg_t **msg,
+					     Buf buffer);
+int inline slurmdbd_unpack_step_start_msg(dbd_step_start_msg_t **msg,
+					  Buf buffer);
+int inline slurmdbd_unpack_usage_msg(slurmdbd_msg_type_t type,
+				     dbd_usage_msg_t **msg,
+				     Buf buffer);
+
+#endif	/* !_SLURMDBD_DEFS_H */
diff --git a/src/common/stepd_api.c b/src/common/stepd_api.c
index 57946193e2cf2ad09e69e4822eee8123eaa0f02e..88374de26340dc2f4269b45bed6779eff928363f 100644
--- a/src/common/stepd_api.c
+++ b/src/common/stepd_api.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/common/stepd_api.c - slurmstepd message API
- *  $Id: stepd_api.c 12808 2007-12-11 17:25:08Z jette $
+ *  $Id: stepd_api.c 13695 2008-03-21 21:28:17Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -58,7 +58,7 @@
 #include "src/common/pack.h"
 #include "src/common/slurm_auth.h"
 #include "src/common/slurm_cred.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobacct_gather.h"
 #include "src/common/list.h"
 #include "src/common/slurm_protocol_api.h"
 #include "src/common/read_config.h"
@@ -211,7 +211,7 @@ stepd_connect(const char *directory, const char *nodename,
 
 	buffer = init_buf(0);
 	/* Create an auth credential */
-	auth_cred = g_slurm_auth_create(NULL, 2);
+	auth_cred = g_slurm_auth_create(NULL, 2, NULL);
 	if (auth_cred == NULL) {
 		error("Creating authentication credential: %s",
 		      g_slurm_auth_errstr(g_slurm_auth_errno(NULL)));
@@ -289,6 +289,7 @@ stepd_get_info(int fd)
 	safe_read(fd, &info->jobid, sizeof(uint32_t));
 	safe_read(fd, &info->stepid, sizeof(uint32_t));
 	safe_read(fd, &info->nodeid, sizeof(uint32_t));
+	safe_read(fd, &info->job_mem_limit, sizeof(uint32_t));
 
 	return info;
 rwfail:
@@ -315,6 +316,26 @@ rwfail:
 	return -1;
 }
 
+/*
+ * Send a checkpoint request to all tasks of a job step.
+ */
+int
+stepd_checkpoint(int fd, int signal, time_t timestamp)
+{
+	int req = REQUEST_CHECKPOINT_TASKS;
+	int rc;
+
+	safe_write(fd, &req, sizeof(int));
+	safe_write(fd, &signal, sizeof(int));
+	safe_write(fd, &timestamp, sizeof(time_t));
+
+	/* Receive the return code */
+	safe_read(fd, &rc, sizeof(int));
+	return rc;
+ rwfail:
+	return -1;
+}
+
 /*
  * Send a signal to a single task in a job step.
  */
@@ -647,21 +668,21 @@ rwfail:
 	return (pid_t)-1;
 }
 
-/*
- * Suspend execution of the job step.  Only root or SlurmUser is
- * authorized to use this call.
- *
- * Returns SLURM_SUCCESS is successful.  On error returns SLURM_ERROR
- * and sets errno.
- */
 int
-stepd_suspend(int fd)
+_step_suspend_write(int fd)
 {
 	int req = REQUEST_STEP_SUSPEND;
-	int rc;
-	int errnum = 0;
 
 	safe_write(fd, &req, sizeof(int));
+	return 0;
+rwfail:
+	return -1;
+}
+
+int
+_step_suspend_read(int fd)
+{
+	int rc, errnum = 0;
 
 	/* Receive the return code and errno */
 	safe_read(fd, &rc, sizeof(int));
@@ -673,6 +694,43 @@ rwfail:
 	return -1;
 }
 
+
+/*
+ * Suspend execution of the job step.  Only root or SlurmUser is
+ * authorized to use this call. Since this activity includes a 'sleep 1'
+ * in the slurmstepd, initiate the the "suspend" in parallel
+ *
+ * Returns SLURM_SUCCESS is successful.  On error returns SLURM_ERROR
+ * and sets errno.
+ */
+int
+stepd_suspend(int *fd, int size, uint32_t jobid)
+{
+	int i;
+	int rc = 0;
+
+	for (i = 0; i < size; i++) {
+		debug2("Suspending job %u cached step count %d", jobid, i);
+		if (_step_suspend_write(fd[i]) < 0) {
+			debug("  suspend send failed: job %u (%d): %m",
+				jobid, i);
+			close(fd[i]);
+			fd[i] = -1;
+			rc = -1;
+		}
+	}
+	for (i = 0; i < size; i++) {
+		if (fd[i] == -1)
+			continue;
+		if (_step_suspend_read(fd[i]) < 0) {
+			debug("  resume failed for cached step count %d: %m",
+				i);
+			rc = -1;
+		}
+	}
+	return rc;
+}
+
 /*
  * Resume execution of the job step that has been suspended by a
  * call to stepd_suspend().  Only root or SlurmUser is
@@ -743,7 +801,7 @@ stepd_completion(int fd, step_complete_msg_t *sent)
 	safe_write(fd, &sent->range_first, sizeof(int));
 	safe_write(fd, &sent->range_last, sizeof(int));
 	safe_write(fd, &sent->step_rc, sizeof(int));
-	jobacct_g_setinfo(sent->jobacct, JOBACCT_DATA_PIPE, &fd);	
+	jobacct_gather_g_setinfo(sent->jobacct, JOBACCT_DATA_PIPE, &fd);
 	/* Receive the return code and errno */
 	safe_read(fd, &rc, sizeof(int));
 	safe_read(fd, &errnum, sizeof(int));
@@ -771,15 +829,16 @@ stepd_stat_jobacct(int fd, stat_jobacct_msg_t *sent, stat_jobacct_msg_t *resp)
 	safe_write(fd, &req, sizeof(int));
 	
 	/* Receive the jobacct struct and return */
-	resp->jobacct = jobacct_g_alloc(NULL);
+	resp->jobacct = jobacct_gather_g_create(NULL);
+	
+	rc = jobacct_gather_g_getinfo(resp->jobacct, JOBACCT_DATA_PIPE, &fd);
 	
-	rc = jobacct_g_getinfo(resp->jobacct, JOBACCT_DATA_PIPE, &fd);	
 	safe_read(fd, &tasks, sizeof(int));
 	resp->num_tasks = tasks;
 	return rc;
 rwfail:
 	error("an error occured %d", rc);
-	jobacct_g_free(resp->jobacct);
+	jobacct_gather_g_destroy(resp->jobacct);
 	resp->jobacct = NULL;
 	return rc;
 }
diff --git a/src/common/stepd_api.h b/src/common/stepd_api.h
index 230a3965132ce160a74ba3609a2c9eb368642f58..a160324eaf78914caa61d0d22bf2aebd64361312 100644
--- a/src/common/stepd_api.h
+++ b/src/common/stepd_api.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/common/stepd_api.h - slurmstepd message API
- *  $Id: stepd_api.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: stepd_api.h 13695 2008-03-21 21:28:17Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -44,6 +44,7 @@
 #include "slurm/slurm.h"
 #include "src/common/list.h"
 #include "src/common/slurm_protocol_defs.h"
+#include "src/common/io_hdr.h"
 
 typedef struct step_location {
 	uint32_t jobid;
@@ -83,6 +84,7 @@ typedef struct {
 	uint32_t jobid;
 	uint32_t stepid;
 	uint32_t nodeid;
+	uint32_t job_mem_limit;		/* job's memory limit, MB */
 } slurmstepd_info_t;
 
 typedef struct {
@@ -131,6 +133,11 @@ slurmstepd_info_t *stepd_get_info(int fd);
  */
 int stepd_signal(int fd, int signal);
 
+/*
+ * Send a checkpoint request to all tasks of a job step.
+ */
+int stepd_checkpoint(int fd, int signal, time_t timestamp);
+
 /*
  * Send a signal to a single task in a job step.
  */
@@ -190,7 +197,7 @@ pid_t stepd_daemon_pid(int fd);
  * Returns SLURM_SUCCESS is successful.  On error returns SLURM_ERROR
  * and sets errno.
  */
-int stepd_suspend(int fd);
+int stepd_suspend(int *fd, int size, uint32_t jobid);
 
 /*
  * Resume execution of the job step that has been suspended by a
@@ -212,7 +219,7 @@ int stepd_completion(int fd, step_complete_msg_t *sent);
 /*
  *
  * Returns SLURM_SUCCESS on success or SLURM_ERROR on error.  
- * resp recieves a jobacctinfo_t which must be freed if SUCCESS.
+ * resp receives a jobacctinfo_t which must be freed if SUCCESS.
  */
 int stepd_stat_jobacct(int fd, stat_jobacct_msg_t *sent, 
 		       stat_jobacct_msg_t *resp);
diff --git a/src/common/switch.c b/src/common/switch.c
index 15d3cf321ac1b253a78c223ebc080e9551d7fc4f..e3cc7fdf6eed9c6349eb5879cfc1946bb5b98f7d 100644
--- a/src/common/switch.c
+++ b/src/common/switch.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/switch.h b/src/common/switch.h
index 94280364b9e30467f75b080502ea67dcded390d9..ec574710cbe3e51f34a74aac2a8390c3f0863403 100644
--- a/src/common/switch.h
+++ b/src/common/switch.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/timers.c b/src/common/timers.c
index 06cdec28d09638e656cbe194f399f09414f2c4e1..3f34a4598a32235180be36bfcbe5a655ba3ec69a 100644
--- a/src/common/timers.c
+++ b/src/common/timers.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/timers.h b/src/common/timers.h
index 0404c4e67d4a5344128dceada713d58af930f069..b580270b653ab82f4b2344c2be8725a30cd96e77 100644
--- a/src/common/timers.h
+++ b/src/common/timers.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> and Kevin Tew <tew1@llnl.gov> 
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/uid.c b/src/common/uid.c
index de6f3ef58d72a84d8c1ab35a90e0c65debb6e5df..299c984065f6ca4861dd3c07984abb2eeb1a4504 100644
--- a/src/common/uid.c
+++ b/src/common/uid.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/common/uid.c - uid/gid lookup utility functions
- * $Id: uid.c 10574 2006-12-15 23:38:29Z jette $
+ * $Id: uid.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/uid.h b/src/common/uid.h
index cfc82dbf575761b2739e461802bca4bf438cf207..a7dabb2caf8efb95c6e5cad5cba639159f11be08 100644
--- a/src/common/uid.h
+++ b/src/common/uid.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/common/uid.h - uid/gid lookup utility functions
- * $Id: uid.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: uid.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/unsetenv.c b/src/common/unsetenv.c
index a888df44af5979e0562839b62f79630444624268..5fd8b4cb49961c52205db00ad28dba77b6061810 100644
--- a/src/common/unsetenv.c
+++ b/src/common/unsetenv.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/unsetenv.h b/src/common/unsetenv.h
index 10db70a8e1196555234c5ac8c7094cdfdc27ba8f..4d98de3abd6c8912af3fac40b729c80e0917aa3f 100644
--- a/src/common/unsetenv.h
+++ b/src/common/unsetenv.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/xassert.c b/src/common/xassert.c
index 33b91cafe0c76e8ad33e0bd83d7a4a0a54ef9fa7..2b2d2362c9b42d5d2fb78da27fb5ce1045c1fe64 100644
--- a/src/common/xassert.c
+++ b/src/common/xassert.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  xassert.c - replacement for assert which sends error to log instead 
  *		of stderr
- *  $Id: xassert.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: xassert.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/xassert.h b/src/common/xassert.h
index 45b8bb338cf848aaff15f990b17110a77de5b1d4..2e5e6fb44dfd8ab5e5d532823c9877399fad380a 100644
--- a/src/common/xassert.h
+++ b/src/common/xassert.h
@@ -2,12 +2,12 @@
  *  xassert.h: assert type macro with configurable handling
  *             If NDEBUG is defined, do nothing.
  *             If not, and expression is zero, log an error message and abort.
- *  $Id: xassert.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: xassert.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/xmalloc.c b/src/common/xmalloc.c
index 41a6177186b916bd28bfed938f8ccbf44f043417..30a2075b709fbeb1a53026b9cb253abff38cfe37 100644
--- a/src/common/xmalloc.c
+++ b/src/common/xmalloc.c
@@ -2,13 +2,13 @@
  *  xmalloc.c - enhanced malloc routines
  *  Started with Jim Garlick's xmalloc and tied into slurm log facility.
  *  Also added ability to print file, line, and function of caller.
- *  $Id: xmalloc.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: xmalloc.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick1@llnl.gov> and 
  *	Mark Grondona <mgrondona@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/xmalloc.h b/src/common/xmalloc.h
index 690f9c13a76baafd0deaa00771649b50e6d6ad1f..4d8c796acfb1a5a9f0332d4285a204874c41f3af 100644
--- a/src/common/xmalloc.h
+++ b/src/common/xmalloc.h
@@ -3,13 +3,13 @@
  *  - default: never return if errors are encountered.
  *  - attempt to report file, line, and calling function on assertion failure
  *  - use configurable slurm log facility for reporting errors
- *  $Id: xmalloc.h 11400 2007-04-24 18:50:38Z da $
+ *  $Id: xmalloc.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick1@llnl.gov> and 
  *	Mark Grondona <mgrondona@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/xsignal.c b/src/common/xsignal.c
index 81fa3c31778cd5d250cae3f929589c332ff08c28..fcc5e577f213b866e3d76088bd21d9b7e0e1d9ff 100644
--- a/src/common/xsignal.c
+++ b/src/common/xsignal.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/xsignal.h b/src/common/xsignal.h
index 6734648c17feba3fdacf617fc4e348a3c7c9f4c9..ad66edb77149aad34f1d05f99523fdd6480cff0a 100644
--- a/src/common/xsignal.h
+++ b/src/common/xsignal.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/common/xsignal.h - POSIX signal wrapper functions
- * $Id: xsignal.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: xsignal.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/common/xstring.c b/src/common/xstring.c
index 765ed79285a148d57fff57503471fdbf7b8911da..ec6652814f91c9cb51951abf989880bbe634fa61 100644
--- a/src/common/xstring.c
+++ b/src/common/xstring.c
@@ -7,7 +7,7 @@
  *  Written by Jim Garlick <garlick@llnl.gov>
  *             Mark Grondona <grondona@llnl.gov>, et al.
  *	
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -78,6 +78,7 @@ strong_alias(_xstrftimecat,	slurm_xstrftimecat);
 strong_alias(_xstrfmtcat,	slurm_xstrfmtcat);
 strong_alias(_xmemcat,		slurm_xmemcat);
 strong_alias(xstrdup,		slurm_xstrdup);
+strong_alias(xstrdup_printf,	slurm_xstrdup_printf);
 strong_alias(xstrndup,		slurm_xstrndup);
 strong_alias(xbasename,		slurm_xbasename);
 strong_alias(_xstrsubstitute,   slurm_xstrsubstitute);
@@ -196,6 +197,9 @@ void _xstrftimecat(char **buf, const char *fmt)
  */
 int _xstrfmtcat(char **str, const char *fmt, ...)
 {
+	/* This code is the same as xstrdup_printf, but couldn't
+	 * figure out how to pass the ... so just copied the code
+	 */
 	/* Start out with a size of 100 bytes. */
 	int n, size = 100;
 	char *p = NULL;
@@ -288,6 +292,38 @@ char * xstrdup(const char *str)
 	return result;
 }
 
+/*
+ * Give me a copy of the string as if it were printf.
+ *   fmt (IN)		format of string and args if any
+ *   RETURN		copy of formated string
+ */
+char *xstrdup_printf(const char *fmt, ...)
+{
+	/* Start out with a size of 100 bytes. */
+	int n, size = 100;
+	char *p = NULL;
+	va_list ap;
+	
+	if((p = xmalloc(size)) == NULL)
+		return NULL;
+	while(1) {
+		/* Try to print in the allocated space. */
+		va_start(ap, fmt);
+		n = vsnprintf(p, size, fmt, ap);
+		va_end (ap);
+		/* If that worked, return the string. */
+		if (n > -1 && n < size)
+			return p;
+		/* Else try again with more space. */
+		if (n > -1)               /* glibc 2.1 */
+			size = n + 1;           /* precisely what is needed */
+		else                      /* glibc 2.0 */
+			size *= 2;              /* twice the old size */
+		if ((p = xrealloc(p, size)) == NULL)
+			return NULL;
+	}
+}
+
 /*
  * Duplicate at most "n" characters of a string.
  *   str (IN)		string to duplicate
diff --git a/src/common/xstring.h b/src/common/xstring.h
index b29056c42a557c34032f9a0bace70a51576e29e0..0345b5adbb65a26a5bae1ff387dfb033449fc89a 100644
--- a/src/common/xstring.h
+++ b/src/common/xstring.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -98,6 +98,11 @@ void _xmemcat(char **str, char *start, char *end);
 */
 char *xstrdup(const char *str);
 
+/*
+** strdup formatted which uses xmalloc routines
+*/
+char *xstrdup_printf(const char *fmt, ...);
+
 /*
 ** strndup which uses xmalloc routines
 */
diff --git a/src/database/Makefile.am b/src/database/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..c1538b0517ff120c6a5029c07700e93164d2d15a
--- /dev/null
+++ b/src/database/Makefile.am
@@ -0,0 +1,39 @@
+# Makefile for database library 
+
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+if HAVE_OPENSSL
+
+noinst_LTLIBRARIES =      \
+	libslurm_mysql.la \
+	libslurm_pgsql.la \
+	libslurm_gold.la
+
+libslurm_gold_la_SOURCES = gold_interface.c gold_interface.h \
+	base64.c base64.h
+libslurm_gold_la_LIBADD   = $(SSL_LIBS)
+libslurm_gold_la_LDFLAGS  = $(LIB_LDFLAGS) $(SSL_LDFLAGS)
+libslurm_gold_la_CFLAGS   = $(SSL_CPPFLAGS)
+
+else 
+
+noinst_LTLIBRARIES =      \
+	libslurm_mysql.la \
+	libslurm_pgsql.la
+
+endif
+
+libslurm_mysql_la_SOURCES = mysql_common.c mysql_common.h
+libslurm_pgsql_la_SOURCES = pgsql_common.c pgsql_common.h
+
+libslurm_mysql_la_LIBADD   = $(MYSQL_LIBS) 
+libslurm_pgsql_la_LIBADD   = $(PGSQL_LIBS) 
+
+libslurm_mysql_la_LDFLAGS  = $(LIB_LDFLAGS)
+libslurm_pgsql_la_LDFLAGS  = $(LIB_LDFLAGS)
+
+libslurm_mysql_la_CFLAGS = $(MYSQL_CFLAGS)
+libslurm_pgsql_la_CFLAGS = $(PGSQL_CFLAGS)
+
diff --git a/src/database/Makefile.in b/src/database/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..2861f5f4ef2cc4d60efa820d236485564df4f851
--- /dev/null
+++ b/src/database/Makefile.in
@@ -0,0 +1,604 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for database library 
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/database
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+@HAVE_OPENSSL_TRUE@libslurm_gold_la_DEPENDENCIES =  \
+@HAVE_OPENSSL_TRUE@	$(am__DEPENDENCIES_1)
+am__libslurm_gold_la_SOURCES_DIST = gold_interface.c gold_interface.h \
+	base64.c base64.h
+@HAVE_OPENSSL_TRUE@am_libslurm_gold_la_OBJECTS =  \
+@HAVE_OPENSSL_TRUE@	libslurm_gold_la-gold_interface.lo \
+@HAVE_OPENSSL_TRUE@	libslurm_gold_la-base64.lo
+libslurm_gold_la_OBJECTS = $(am_libslurm_gold_la_OBJECTS)
+libslurm_gold_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libslurm_gold_la_CFLAGS) \
+	$(CFLAGS) $(libslurm_gold_la_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_OPENSSL_TRUE@am_libslurm_gold_la_rpath =
+libslurm_mysql_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_libslurm_mysql_la_OBJECTS = libslurm_mysql_la-mysql_common.lo
+libslurm_mysql_la_OBJECTS = $(am_libslurm_mysql_la_OBJECTS)
+libslurm_mysql_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(libslurm_mysql_la_CFLAGS) $(CFLAGS) \
+	$(libslurm_mysql_la_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_OPENSSL_FALSE@am_libslurm_mysql_la_rpath =
+@HAVE_OPENSSL_TRUE@am_libslurm_mysql_la_rpath =
+libslurm_pgsql_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_libslurm_pgsql_la_OBJECTS = libslurm_pgsql_la-pgsql_common.lo
+libslurm_pgsql_la_OBJECTS = $(am_libslurm_pgsql_la_OBJECTS)
+libslurm_pgsql_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(libslurm_pgsql_la_CFLAGS) $(CFLAGS) \
+	$(libslurm_pgsql_la_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_OPENSSL_FALSE@am_libslurm_pgsql_la_rpath =
+@HAVE_OPENSSL_TRUE@am_libslurm_pgsql_la_rpath =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(libslurm_gold_la_SOURCES) $(libslurm_mysql_la_SOURCES) \
+	$(libslurm_pgsql_la_SOURCES)
+DIST_SOURCES = $(am__libslurm_gold_la_SOURCES_DIST) \
+	$(libslurm_mysql_la_SOURCES) $(libslurm_pgsql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+@HAVE_OPENSSL_FALSE@noinst_LTLIBRARIES = \
+@HAVE_OPENSSL_FALSE@	libslurm_mysql.la \
+@HAVE_OPENSSL_FALSE@	libslurm_pgsql.la
+
+@HAVE_OPENSSL_TRUE@noinst_LTLIBRARIES = \
+@HAVE_OPENSSL_TRUE@	libslurm_mysql.la \
+@HAVE_OPENSSL_TRUE@	libslurm_pgsql.la \
+@HAVE_OPENSSL_TRUE@	libslurm_gold.la
+
+@HAVE_OPENSSL_TRUE@libslurm_gold_la_SOURCES = gold_interface.c gold_interface.h \
+@HAVE_OPENSSL_TRUE@	base64.c base64.h
+
+@HAVE_OPENSSL_TRUE@libslurm_gold_la_LIBADD = $(SSL_LIBS)
+@HAVE_OPENSSL_TRUE@libslurm_gold_la_LDFLAGS = $(LIB_LDFLAGS) $(SSL_LDFLAGS)
+@HAVE_OPENSSL_TRUE@libslurm_gold_la_CFLAGS = $(SSL_CPPFLAGS)
+libslurm_mysql_la_SOURCES = mysql_common.c mysql_common.h
+libslurm_pgsql_la_SOURCES = pgsql_common.c pgsql_common.h
+libslurm_mysql_la_LIBADD = $(MYSQL_LIBS) 
+libslurm_pgsql_la_LIBADD = $(PGSQL_LIBS) 
+libslurm_mysql_la_LDFLAGS = $(LIB_LDFLAGS)
+libslurm_pgsql_la_LDFLAGS = $(LIB_LDFLAGS)
+libslurm_mysql_la_CFLAGS = $(MYSQL_CFLAGS)
+libslurm_pgsql_la_CFLAGS = $(PGSQL_CFLAGS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/database/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/database/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libslurm_gold.la: $(libslurm_gold_la_OBJECTS) $(libslurm_gold_la_DEPENDENCIES) 
+	$(libslurm_gold_la_LINK) $(am_libslurm_gold_la_rpath) $(libslurm_gold_la_OBJECTS) $(libslurm_gold_la_LIBADD) $(LIBS)
+libslurm_mysql.la: $(libslurm_mysql_la_OBJECTS) $(libslurm_mysql_la_DEPENDENCIES) 
+	$(libslurm_mysql_la_LINK) $(am_libslurm_mysql_la_rpath) $(libslurm_mysql_la_OBJECTS) $(libslurm_mysql_la_LIBADD) $(LIBS)
+libslurm_pgsql.la: $(libslurm_pgsql_la_OBJECTS) $(libslurm_pgsql_la_DEPENDENCIES) 
+	$(libslurm_pgsql_la_LINK) $(am_libslurm_pgsql_la_rpath) $(libslurm_pgsql_la_OBJECTS) $(libslurm_pgsql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libslurm_gold_la-base64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libslurm_gold_la-gold_interface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libslurm_mysql_la-mysql_common.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libslurm_pgsql_la-pgsql_common.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+libslurm_gold_la-gold_interface.lo: gold_interface.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_gold_la_CFLAGS) $(CFLAGS) -MT libslurm_gold_la-gold_interface.lo -MD -MP -MF $(DEPDIR)/libslurm_gold_la-gold_interface.Tpo -c -o libslurm_gold_la-gold_interface.lo `test -f 'gold_interface.c' || echo '$(srcdir)/'`gold_interface.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libslurm_gold_la-gold_interface.Tpo $(DEPDIR)/libslurm_gold_la-gold_interface.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='gold_interface.c' object='libslurm_gold_la-gold_interface.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_gold_la_CFLAGS) $(CFLAGS) -c -o libslurm_gold_la-gold_interface.lo `test -f 'gold_interface.c' || echo '$(srcdir)/'`gold_interface.c
+
+libslurm_gold_la-base64.lo: base64.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_gold_la_CFLAGS) $(CFLAGS) -MT libslurm_gold_la-base64.lo -MD -MP -MF $(DEPDIR)/libslurm_gold_la-base64.Tpo -c -o libslurm_gold_la-base64.lo `test -f 'base64.c' || echo '$(srcdir)/'`base64.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libslurm_gold_la-base64.Tpo $(DEPDIR)/libslurm_gold_la-base64.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='base64.c' object='libslurm_gold_la-base64.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_gold_la_CFLAGS) $(CFLAGS) -c -o libslurm_gold_la-base64.lo `test -f 'base64.c' || echo '$(srcdir)/'`base64.c
+
+libslurm_mysql_la-mysql_common.lo: mysql_common.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_mysql_la_CFLAGS) $(CFLAGS) -MT libslurm_mysql_la-mysql_common.lo -MD -MP -MF $(DEPDIR)/libslurm_mysql_la-mysql_common.Tpo -c -o libslurm_mysql_la-mysql_common.lo `test -f 'mysql_common.c' || echo '$(srcdir)/'`mysql_common.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libslurm_mysql_la-mysql_common.Tpo $(DEPDIR)/libslurm_mysql_la-mysql_common.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mysql_common.c' object='libslurm_mysql_la-mysql_common.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_mysql_la_CFLAGS) $(CFLAGS) -c -o libslurm_mysql_la-mysql_common.lo `test -f 'mysql_common.c' || echo '$(srcdir)/'`mysql_common.c
+
+libslurm_pgsql_la-pgsql_common.lo: pgsql_common.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_pgsql_la_CFLAGS) $(CFLAGS) -MT libslurm_pgsql_la-pgsql_common.lo -MD -MP -MF $(DEPDIR)/libslurm_pgsql_la-pgsql_common.Tpo -c -o libslurm_pgsql_la-pgsql_common.lo `test -f 'pgsql_common.c' || echo '$(srcdir)/'`pgsql_common.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libslurm_pgsql_la-pgsql_common.Tpo $(DEPDIR)/libslurm_pgsql_la-pgsql_common.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='pgsql_common.c' object='libslurm_pgsql_la-pgsql_common.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libslurm_pgsql_la_CFLAGS) $(CFLAGS) -c -o libslurm_pgsql_la-pgsql_common.lo `test -f 'pgsql_common.c' || echo '$(srcdir)/'`pgsql_common.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/jobacct/gold/base64.c b/src/database/base64.c
similarity index 97%
rename from src/plugins/jobacct/gold/base64.c
rename to src/database/base64.c
index 803f2b0536463d3fd215a35e42af04c4a0b2d799..92a8d8446c879f512dca538bab30ad72562be985 100644
--- a/src/plugins/jobacct/gold/base64.c
+++ b/src/database/base64.c
@@ -74,7 +74,7 @@ extern unsigned char *encode_base64(const unsigned char* in_str,
 	rlen++; /* for the eol */
 	ret_str = xmalloc(sizeof(unsigned char) * rlen);
 	
-	debug2("encoding %s", in_str);
+	debug4("encoding %s", in_str);
 
 	while (in_len--) {
 		char_array_3[i++] = *(in_str++);
@@ -111,7 +111,7 @@ extern unsigned char *encode_base64(const unsigned char* in_str,
 		
 	}
 
-	debug2("encoded %s", ret_str);
+	debug4("encoded %s", ret_str);
 	
 	return ret_str;
 }
@@ -136,7 +136,7 @@ extern unsigned char *decode_base64(const unsigned char *in_str)
 	int rlen = in_len * 3 / 4; /* always enough, but sometimes too
 				    * much */
        	
-	debug2("decoding %s", in_str);
+	debug4("decoding %s", in_str);
 
 	ret_str = xmalloc(sizeof(unsigned char) * rlen);
 	memset(ret_str, 0, rlen);
@@ -193,7 +193,7 @@ extern unsigned char *decode_base64(const unsigned char *in_str)
 			ret_str[pos++] = char_array_3[j];
 	}
 
-	debug2("decoded %s", ret_str);
+	debug4("decoded %s", ret_str);
 
 	return ret_str;
 }
diff --git a/src/plugins/jobacct/gold/base64.h b/src/database/base64.h
similarity index 100%
rename from src/plugins/jobacct/gold/base64.h
rename to src/database/base64.h
diff --git a/src/plugins/jobacct/gold/gold_interface.c b/src/database/gold_interface.c
similarity index 90%
rename from src/plugins/jobacct/gold/gold_interface.c
rename to src/database/gold_interface.c
index 8ca66f540e88b00f9ee235c7d8eb33ce6a55b64d..f39ad68a090d65261a741e1ff012c85f6689aa68 100644
--- a/src/plugins/jobacct/gold/gold_interface.c
+++ b/src/database/gold_interface.c
@@ -44,10 +44,28 @@
 
 #include "src/common/slurm_protocol_interface.h"
 #include "src/common/slurm_protocol_api.h"
+#include "src/common/uid.h"
 
 #define MAX_RETRY 5
 
-static char *gold_machine = NULL;
+/* This should be updated to match the gold_object_t enum */
+char *GOLD_OBJECT_STR[] = {
+	"Account", 
+	"User", 
+	"Project", 
+	"Machine", 
+	"Job", 
+	"RoleUser", 
+	"EventLog",
+	"MachineHourUsage", 
+	"MachineDayUsage", 
+	"MachineMonthUsage",
+	"AccountHourUsage", 
+	"AccountDayUsage", 
+	"AccountMonthUsage",
+	NULL
+};
+
 static char *gold_key = NULL;
 static char *gold_host = NULL;
 static uint16_t gold_port = 0;
@@ -120,8 +138,8 @@ static gold_response_entry_t *_create_response_entry(char *object,
 			name_val->name = _get_return_name(gold_msg, i);
 			name_val->value = _get_return_value(gold_msg, i);
 			
-			debug3("got %s = %s", name_val->name, name_val->value);
-			list_push(resp_entry->name_val, name_val);
+			debug4("got %s = %s", name_val->name, name_val->value);
+			list_append(resp_entry->name_val, name_val);
 		}
 		(*i)++;
 	}
@@ -181,20 +199,22 @@ static int _end_communication(slurm_fd gold_fd)
 	return rc;
 }
 
-extern int init_gold(char *machine, char *keyfile, char *host, uint16_t port)
+extern int init_gold(char *keyfile, char *host, uint16_t port)
 {
 	int fp;
 	char key[256];
 	int i, bytes_read;
 	
-	if(!keyfile || !host || !machine) {
-		error("init_gold: Either no keyfile or host or machine given");
+	if(!keyfile || !host) {
+		error("init_gold: Either no keyfile or host given");
 		return SLURM_ERROR;
 	}
 
 	fp = open(keyfile, O_RDONLY);
-	bytes_read = read(fp, key, sizeof(key));
-	if ( bytes_read == -1) {
+	if (fp < 0)
+		fatal("Error opening gold keyfile (%s): %m\n", keyfile);
+	bytes_read = read(fp, key, sizeof(key) - 1);
+	if (bytes_read == -1) {
 		fatal("Error reading hash key from keyfile (%s): %m\n",
 		      keyfile);
 	}
@@ -210,7 +230,6 @@ extern int init_gold(char *machine, char *keyfile, char *host, uint16_t port)
 	/* Close the file */
 	close(fp);
 	//debug4("got the tolken as %s\n", key);
-	gold_machine = xstrdup(machine);
 	gold_key = xstrdup(key);
 	gold_host = xstrdup(host);
 	gold_port = port;
@@ -222,7 +241,6 @@ extern int init_gold(char *machine, char *keyfile, char *host, uint16_t port)
 extern int fini_gold()
 {
 	gold_init = 0;
-	xfree(gold_machine);
 	xfree(gold_key);
 	xfree(gold_host);
 	
@@ -268,27 +286,29 @@ extern int gold_request_add_assignment(gold_request_t *gold_request,
 	gold_name_value_t *name_val = xmalloc(sizeof(gold_name_value_t));
 	name_val->name = xstrdup(name);
 	name_val->value = xstrdup(value);
-	list_push(gold_request->assignments, name_val);
+	list_append(gold_request->assignments, name_val);
 		
 	return SLURM_SUCCESS;
 }
 
 extern int gold_request_add_condition(gold_request_t *gold_request, 
 				      char *name, char *value,
-				      gold_operator_t op)
+				      gold_operator_t op,
+				      int or_statement)
 {
 	gold_name_value_t *name_val = xmalloc(sizeof(gold_name_value_t));
 	name_val->name = xstrdup(name);
 	name_val->value = xstrdup(value);
 	name_val->op = op;
-	list_push(gold_request->conditions, name_val);
+	name_val->or_statement = or_statement;
+	list_append(gold_request->conditions, name_val);
 		
 	return SLURM_SUCCESS;
 }
 
 extern int gold_request_add_selection(gold_request_t *gold_request, char *name)
 {
-	list_push(gold_request->selections, xstrdup(name));
+	list_append(gold_request->selections, xstrdup(name));
 	return SLURM_SUCCESS;
 }
 
@@ -326,34 +346,12 @@ extern gold_response_t *get_gold_response(gold_request_t *gold_request)
 	if(!timeout) 
 		timeout = (slurm_get_msg_timeout() * 1000);
 	
-
-	switch(gold_request->object) {
-	case GOLD_OBJECT_ACCOUNT:
-		object = GOLD_OBJECT_ACCOUNT_STR;
-		break;
-	case GOLD_OBJECT_USER:
-		object = GOLD_OBJECT_USER_STR;
-		break;
-	case GOLD_OBJECT_PROJECT:
-		object = GOLD_OBJECT_PROJECT_STR;
-		break;
-	case GOLD_OBJECT_MACHINE:
-		object = GOLD_OBJECT_MACHINE_STR;
-		break;
-	case GOLD_OBJECT_JOB:
-		object = GOLD_OBJECT_JOB_STR;
-		break;
-	case GOLD_OBJECT_EVENT:
-		object = GOLD_OBJECT_EVENT_STR;
-		break;
-	case GOLD_OBJECT_ROLEUSER:
-		object = GOLD_OBJECT_ROLEUSER_STR;
-		break;
-	default:
+	if(gold_request->object >= GOLD_OBJECT_COUNT) {
 		error("get_gold_response: "
 		      "unsupported object %d", gold_request->object);
 		return NULL;
 	}
+	object = GOLD_OBJECT_STR[gold_request->object];
 
 	switch(gold_request->action) {
 	case GOLD_ACTION_QUERY:
@@ -394,6 +392,8 @@ extern gold_response_t *get_gold_response(gold_request_t *gold_request)
 
 	itr = list_iterator_create(gold_request->conditions);
 	while((name_val = list_next(itr))) {
+		xstrfmtcat(innerds, "<Where name=\"%s\"", name_val->name);
+
 		if(name_val->op != GOLD_OPERATOR_NONE) {
 			char *op = NULL;
 			switch (name_val->op) {
@@ -418,20 +418,23 @@ extern gold_response_t *get_gold_response(gold_request_t *gold_request)
 				list_iterator_destroy(itr);
 				return NULL;
 			}
-			xstrfmtcat(innerds,
-				   "<Where name=\"%s\" op=\"%s\">%s</Where>",
-				   name_val->name, op, name_val->value);
-		} else {
-			xstrfmtcat(innerds, "<Where name=\"%s\">%s</Where>",
-				   name_val->name, name_val->value);
-		}
+			
+			xstrfmtcat(innerds, " op=\"%s\"", op);
+		} 
+
+		if(name_val->or_statement == 1) 
+			xstrfmtcat(innerds, " conj=\"Or\" groups=\"-1\"");
+		else if (name_val->or_statement == 2)
+			xstrfmtcat(innerds, " conj=\"And\" groups=\"+1\"");
+
+		xstrfmtcat(innerds, ">%s</Where>", name_val->value);
 	}
 	list_iterator_destroy(itr);
 
 	xstrfmtcat(gold_request->body,
 		   "<Body><Request action=\"%s\" actor=\"%s\">"
 		   "<Object>%s</Object>",
-		   action, "slurm", object);
+		   action, uid_to_string(geteuid()), object);
 	if(innerds) {
 		xstrcat(gold_request->body, innerds);
 		xfree(innerds);
@@ -477,7 +480,7 @@ extern gold_response_t *get_gold_response(gold_request_t *gold_request)
 		goto error;
 	}
 
-	debug2("sending %d '%s'", rc, gold_msg);
+	debug3("sending %d '%s'", rc, gold_msg);
 
 	xstrcat(gold_msg, "0\r\n");
 	rc = _slurm_send_timeout(gold_fd, gold_msg, strlen(gold_msg),
@@ -518,7 +521,7 @@ extern gold_response_t *get_gold_response(gold_request_t *gold_request)
 	tmp_buff[i] = '\0';
 	ret_len = xstrntol(tmp_buff, NULL, i, 16);
 		
-	debug3("got size %d", ret_len);
+	debug4("got size %d", ret_len);
 	
 	gold_msg = xmalloc(ret_len+1);
 	
@@ -528,7 +531,7 @@ extern gold_response_t *get_gold_response(gold_request_t *gold_request)
 		goto error;
 	}
 
-	debug2("got back '%s'", gold_msg);
+	debug3("got back '%s'", gold_msg);
 	if(_slurm_recv_timeout(gold_fd, tmp_buff, 3, 0, timeout) < 0) {
 		error("get_gold_response: "
 		      "couldn't get the end of the message");
@@ -559,7 +562,7 @@ extern gold_response_t *get_gold_response(gold_request_t *gold_request)
 		} else if(!strncmp(gold_msg+i, object, strlen(object))) {
 			gold_response_entry_t *resp_entry =
 				_create_response_entry(object, gold_msg, &i);
-			list_push(gold_response->entries, resp_entry);
+			list_append(gold_response->entries, resp_entry);
 		}
 		i++;	
 	}
diff --git a/src/plugins/jobacct/gold/gold_interface.h b/src/database/gold_interface.h
similarity index 82%
rename from src/plugins/jobacct/gold/gold_interface.h
rename to src/database/gold_interface.h
index 5ee82ef9dd43341c077633a4d4642d06e33a6584..0ed77a11bd33d681080881da5bc4f7591771c683 100644
--- a/src/plugins/jobacct/gold/gold_interface.h
+++ b/src/database/gold_interface.h
@@ -64,29 +64,45 @@
 #define GOLD_ACTION_MODIFY_STR "Modify"
 #define GOLD_ACTION_DELETE_STR "Delete"
 
-#define GOLD_OBJECT_ACCOUNT_STR "Account"
+#define GOLD_OBJECT_ACCT_STR "Account"
 #define GOLD_OBJECT_USER_STR "User"
 #define GOLD_OBJECT_PROJECT_STR "Project"
 #define GOLD_OBJECT_MACHINE_STR "Machine"
 #define GOLD_OBJECT_JOB_STR "Job"
 #define GOLD_OBJECT_ROLEUSER_STR "RoleUser"
 #define GOLD_OBJECT_EVENT_STR "EventLog"
+#define GOLD_OBJECT_MACHINE_HOUR_STR "MachineHourUsage"
+#define GOLD_OBJECT_MACHINE_DAY_STR "MachineDayUsage"
+#define GOLD_OBJECT_MACHINE_MONTH_STR "MachineMonthUsage"
+#define GOLD_OBJECT_ACCT_HOUR_STR "AccountHourUsage"
+#define GOLD_OBJECT_ACCT_DAY_STR "AccountDayUsage"
+#define GOLD_OBJECT_ACCT_MONTH_STR "AccountMonthUsage"
 
 typedef enum {
 	GOLD_ACTION_QUERY,
 	GOLD_ACTION_CREATE,
 	GOLD_ACTION_MODIFY,
-	GOLD_ACTION_DELETE
+	GOLD_ACTION_DELETE,
+	GOLD_ACTION_COUNT
 } gold_action_t;
 
+/* When changing this you would also make GOLD_OBJECT_STR match
+ * defined in gold_interface.c */
 typedef enum {
-	GOLD_OBJECT_ACCOUNT,
+	GOLD_OBJECT_ACCT,
 	GOLD_OBJECT_USER,
 	GOLD_OBJECT_PROJECT,
 	GOLD_OBJECT_MACHINE,
 	GOLD_OBJECT_JOB,
 	GOLD_OBJECT_ROLEUSER,
-	GOLD_OBJECT_EVENT
+	GOLD_OBJECT_EVENT,
+	GOLD_OBJECT_MACHINE_HOUR_USAGE,
+	GOLD_OBJECT_MACHINE_DAY_USAGE,
+	GOLD_OBJECT_MACHINE_MONTH_USAGE,
+	GOLD_OBJECT_ACCT_HOUR_USAGE,
+	GOLD_OBJECT_ACCT_DAY_USAGE,
+	GOLD_OBJECT_ACCT_MONTH_USAGE,
+	GOLD_OBJECT_COUNT
 } gold_object_t;
 
 typedef enum {
@@ -94,13 +110,15 @@ typedef enum {
 	GOLD_OPERATOR_G,
 	GOLD_OPERATOR_GE,
 	GOLD_OPERATOR_L,
-	GOLD_OPERATOR_LE
+	GOLD_OPERATOR_LE,
+	GOLD_OPERATOR_COUNT
 } gold_operator_t;
 
 typedef struct {
 	char *name;
 	char *value;
 	gold_operator_t op;
+	int or_statement; // 0 for nothing 1 for or last 2 for or next
 } gold_name_value_t;
 
 typedef struct {
@@ -125,8 +143,9 @@ typedef struct {
 	int rc;
 } gold_response_t;
 
+extern char *GOLD_OBJECT_STR[];
 
-extern int init_gold(char *machine, char *keyfile, char *host, uint16_t port);
+extern int init_gold(char *keyfile, char *host, uint16_t port);
 extern int fini_gold();
 
 extern gold_request_t *create_gold_request(gold_object_t object,
@@ -137,7 +156,8 @@ extern int gold_request_add_assignment(gold_request_t *gold_request,
 				       char *name, char *value);
 extern int gold_request_add_condition(gold_request_t *gold_request, 
 				      char *name, char *value,
-				      gold_operator_t op);
+				      gold_operator_t op,
+				      int or_statement);
 extern int gold_request_add_selection(gold_request_t *gold_request, char *name);
 
 extern gold_response_t *get_gold_response(gold_request_t *gold_request);
diff --git a/src/database/mysql_common.c b/src/database/mysql_common.c
new file mode 100644
index 0000000000000000000000000000000000000000..24e4de9ec8f25acfe37af0d77a0fc244c023d290
--- /dev/null
+++ b/src/database/mysql_common.c
@@ -0,0 +1,428 @@
+/*****************************************************************************\
+ *  mysql_common.c - common functions for the the mysql storage plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "mysql_common.h"
+#include "src/common/xmalloc.h"
+#include "src/common/timers.h"
+#include "src/common/slurm_protocol_api.h"
+
+pthread_mutex_t mysql_lock = PTHREAD_MUTEX_INITIALIZER;
+
+#ifdef HAVE_MYSQL
+
+static int _clear_results(MYSQL *mysql_db)
+{
+	MYSQL_RES *result = NULL;
+	int rc = 0;
+	do {
+		/* did current statement return data? */
+		if((result = mysql_store_result(mysql_db)))
+			mysql_free_result(result);
+		
+		/* more results? -1 = no, >0 = error, 0 = yes (keep looping) */
+		if ((rc = mysql_next_result(mysql_db)) > 0)
+			error("Could not execute statement %d %s\n",
+			      mysql_errno(mysql_db),
+			      mysql_error(mysql_db));
+	} while (rc == 0);
+	
+	return SLURM_SUCCESS;
+}
+
+static MYSQL_RES *_get_first_result(MYSQL *mysql_db)
+{
+	MYSQL_RES *result = NULL;
+	int rc = 0;
+	do {
+		/* did current statement return data? */
+		if((result = mysql_store_result(mysql_db)))
+			return result;
+		
+		/* more results? -1 = no, >0 = error, 0 = yes (keep looping) */
+		if ((rc = mysql_next_result(mysql_db)) > 0)
+			debug3("error: Could not execute statement %d\n", rc);
+		
+	} while (rc == 0);
+	
+	return NULL;
+}
+
+static MYSQL_RES *_get_last_result(MYSQL *mysql_db)
+{
+	MYSQL_RES *result = NULL;
+	MYSQL_RES *last_result = NULL;
+	int rc = 0;
+	do {
+		/* did current statement return data? */
+		if((result = mysql_store_result(mysql_db))) {
+			if(last_result)
+				mysql_free_result(last_result);
+			last_result = result;
+		}
+		/* more results? -1 = no, >0 = error, 0 = yes (keep looping) */
+		if ((rc = mysql_next_result(mysql_db)) > 0)
+			debug3("error: Could not execute statement %d\n", rc);
+	} while (rc == 0);
+	
+	return last_result;
+}
+
+static int _mysql_make_table_current(MYSQL *mysql_db, char *table_name,
+				     storage_field_t *fields)
+{
+	char *query = NULL;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	int i = 0;
+	List columns = NULL;
+	ListIterator itr = NULL;
+	char *col = NULL;
+	DEF_TIMERS;
+
+	query = xstrdup_printf("show columns from %s", table_name);
+
+	if(!(result = mysql_db_query_ret(mysql_db, query, 0))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+	columns = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		col = xstrdup(row[0]); //Field
+		list_append(columns, col);
+	}
+	mysql_free_result(result);
+	itr = list_iterator_create(columns);
+	query = xstrdup_printf("alter table %s", table_name);
+	START_TIMER;
+	while(fields[i].name) {
+		int found = 0;
+		list_iterator_reset(itr);
+		while((col = list_next(itr))) {
+			if(!strcmp(col, fields[i].name)) {
+				xstrfmtcat(query, " modify %s %s,",
+					   fields[i].name,
+					   fields[i].options);
+				list_delete_item(itr);
+				found = 1;
+				break;
+			}
+		}
+		if(!found) {
+			info("adding column %s after %s", fields[i].name,
+			     fields[i-1].name);
+			xstrfmtcat(query, " add %s %s after %s,",
+				   fields[i].name,
+				   fields[i].options,
+				   fields[i-1].name);
+		}
+
+		i++;
+	}
+	list_iterator_destroy(itr);
+	list_destroy(columns);
+	query[strlen(query)-1] = ';';
+	if(mysql_db_query(mysql_db, query)) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+	
+	END_TIMER2("make table current");
+	return SLURM_SUCCESS;
+}
+
+static int _create_db(char *db_name, mysql_db_info_t *db_info)
+{
+	char create_line[50];
+	MYSQL *mysql_db = NULL;
+
+//	slurm_mutex_lock(&mysql_lock);
+	if(!(mysql_db = mysql_init(mysql_db)))
+		fatal("mysql_init failed: %s", mysql_error(mysql_db));
+	
+	if(mysql_real_connect(mysql_db, db_info->host, db_info->user,
+			      db_info->pass, NULL, db_info->port, NULL, 0)) {
+		snprintf(create_line, sizeof(create_line),
+			 "create database %s", db_name);
+		if(mysql_query(mysql_db, create_line)) {
+			fatal("mysql_real_query failed: %d %s\n%s",
+			      mysql_errno(mysql_db),
+			      mysql_error(mysql_db), create_line);
+		}
+		mysql_close_db_connection(&mysql_db);
+	} else {
+		info("Connection failed to host = %s "
+		     "user = %s pass = %s port = %u",
+		     db_info->host, db_info->user,
+		     db_info->pass, db_info->port);
+		slurm_mutex_unlock(&mysql_lock);
+		fatal("mysql_real_connect failed: %d %s\n",
+		      mysql_errno(mysql_db),
+		      mysql_error(mysql_db));
+	}
+//	slurm_mutex_unlock(&mysql_lock);
+	return SLURM_SUCCESS;
+}
+
+extern int *destroy_mysql_db_info(mysql_db_info_t *db_info)
+{
+	if(db_info) {
+		xfree(db_info->host);
+		xfree(db_info->user);
+		xfree(db_info->pass);
+		xfree(db_info);
+	}
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_get_db_connection(MYSQL **mysql_db, char *db_name,
+				   mysql_db_info_t *db_info)
+{
+	int rc = SLURM_SUCCESS;
+	bool storage_init = false;
+
+	if(!(*mysql_db = mysql_init(*mysql_db)))
+		fatal("mysql_init failed: %s", mysql_error(*mysql_db));
+	else {
+#ifdef MYSQL_OPT_RECONNECT
+{
+		my_bool reconnect = 1;
+		/* make sure reconnect is on */
+		mysql_options(*mysql_db, MYSQL_OPT_RECONNECT, &reconnect);
+}
+#endif
+		while(!storage_init) {
+			if(!mysql_real_connect(*mysql_db, db_info->host,
+					       db_info->user, db_info->pass,
+					       db_name, db_info->port,
+					       NULL, CLIENT_MULTI_STATEMENTS)) {
+				if(mysql_errno(*mysql_db) == ER_BAD_DB_ERROR) {
+					debug("Database %s not created.  "
+					      "Creating", db_name);
+					_create_db(db_name, db_info);
+				} else {
+					fatal("mysql_real_connect failed: "
+					      "%d %s",
+					      mysql_errno(*mysql_db),
+					      mysql_error(*mysql_db));
+				}
+			} else {
+				storage_init = true;
+			}
+		}
+	}
+	return rc;
+}
+
+extern int mysql_close_db_connection(MYSQL **mysql_db)
+{
+	if(mysql_db && *mysql_db) {
+		if(mysql_thread_safe())
+			mysql_thread_end();
+		mysql_close(*mysql_db);
+		*mysql_db = NULL;
+	}
+
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_cleanup()
+{
+	debug3("starting mysql cleaning up");
+
+#ifdef mysql_library_end
+	mysql_library_end();
+#else
+	mysql_server_end();
+#endif
+
+	debug3("finished mysql cleaning up");
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_db_query(MYSQL *mysql_db, char *query)
+{
+	if(!mysql_db)
+		fatal("You haven't inited this storage yet.");
+	slurm_mutex_lock(&mysql_lock);
+
+	/* clear out the old results so we don't get a 2014 error */
+	_clear_results(mysql_db);		
+//try_again:
+	if(mysql_query(mysql_db, query)) {
+		/* if(mysql_errno(mysql_db) == CR_SERVER_GONE_ERROR) { */
+/* 			/\* FIX ME: this means the connection went away *\/ */
+/* 		} */
+
+		error("mysql_query failed: %d %s\n%s",
+		      mysql_errno(mysql_db),
+		      mysql_error(mysql_db), query);
+		errno = mysql_errno(mysql_db);
+		slurm_mutex_unlock(&mysql_lock);
+		return SLURM_ERROR;
+	}
+	slurm_mutex_unlock(&mysql_lock);
+
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_db_ping(MYSQL *mysql_db)
+{
+	/* clear out the old results so we don't get a 2014 error */
+	_clear_results(mysql_db);		
+	return mysql_ping(mysql_db);
+}
+
+extern int mysql_db_commit(MYSQL *mysql_db)
+{
+	//slurm_mutex_lock(&mysql_lock);
+
+	/* clear out the old results so we don't get a 2014 error */
+	_clear_results(mysql_db);		
+	if(mysql_commit(mysql_db)) {
+		error("mysql_commit failed: %d %s",
+		      mysql_errno(mysql_db),
+		      mysql_error(mysql_db));
+		errno = mysql_errno(mysql_db);
+		//slurm_mutex_unlock(&mysql_lock);
+		return SLURM_ERROR;
+	}
+	//slurm_mutex_unlock(&mysql_lock);
+
+	return SLURM_SUCCESS;
+}
+
+extern int mysql_db_rollback(MYSQL *mysql_db)
+{
+	//slurm_mutex_lock(&mysql_lock);
+
+	/* clear out the old results so we don't get a 2014 error */
+	_clear_results(mysql_db);		
+	if(mysql_rollback(mysql_db)) {
+		error("mysql_commit failed: %d %s",
+		      mysql_errno(mysql_db),
+		      mysql_error(mysql_db));
+		errno = mysql_errno(mysql_db);
+		//slurm_mutex_unlock(&mysql_lock);
+		return SLURM_ERROR;
+	}
+	//mysql_db_query(mysql_db, "unlock tables;");
+	//slurm_mutex_unlock(&mysql_lock);
+
+	return SLURM_SUCCESS;
+
+}
+
+extern MYSQL_RES *mysql_db_query_ret(MYSQL *mysql_db, char *query, bool last)
+{
+	MYSQL_RES *result = NULL;
+	
+	if(mysql_db_query(mysql_db, query) != SLURM_ERROR)  {
+		if(last)
+			result = _get_last_result(mysql_db);
+		else
+			result = _get_first_result(mysql_db);
+		if(!result && mysql_field_count(mysql_db)) {
+			/* should have returned data */
+			error("We should have gotten a result: %s", 
+			      mysql_error(mysql_db));
+		}
+	}
+
+	return result;
+}
+
+extern int mysql_insert_ret_id(MYSQL *mysql_db, char *query)
+{
+	int new_id = 0;
+	
+	if(mysql_db_query(mysql_db, query) != SLURM_ERROR)  {
+		new_id = mysql_insert_id(mysql_db);
+		if(!new_id) {
+			/* should have new id */
+			error("We should have gotten a new id: %s", 
+			      mysql_error(mysql_db));
+		}
+	}
+
+	return new_id;
+	
+}
+
+extern int mysql_db_create_table(MYSQL *mysql_db, char *table_name,
+				 storage_field_t *fields, char *ending)
+{
+	char *query = NULL;
+	int i = 0;
+	storage_field_t *first_field = fields;
+
+	if(!fields || !fields->name) {
+		error("Not creating an empty table");
+		return SLURM_ERROR;
+	}
+
+	query = xstrdup_printf("create table if not exists %s (%s %s",
+			       table_name, fields->name, fields->options);
+	i=1;
+	fields++;
+		
+	while(fields && fields->name) {
+		xstrfmtcat(query, ", %s %s", fields->name, fields->options);
+		fields++;
+		i++;
+	}
+	xstrcat(query, ending);
+
+	/* make sure we can do a rollback */
+	xstrcat(query, " engine='innodb'");
+
+	if(mysql_db_query(mysql_db, query) == SLURM_ERROR) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);	
+	
+	return _mysql_make_table_current(mysql_db, table_name, first_field);
+}
+
+
+#endif
+
diff --git a/src/database/mysql_common.h b/src/database/mysql_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..69acb54c49974fab068805149b852bfa9a70e226
--- /dev/null
+++ b/src/database/mysql_common.h
@@ -0,0 +1,98 @@
+/*****************************************************************************\
+ *  mysql_common.h - common functions for the the mysql storage plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#ifndef _HAVE_MYSQL_COMMON_H
+#define _HAVE_MYSQL_COMMON_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <stdio.h>
+#include <slurm/slurm_errno.h>
+#include "src/common/list.h"
+#include "src/common/xstring.h"
+
+#ifdef HAVE_MYSQL
+#include <mysql.h>
+#include <mysqld_error.h>
+
+typedef struct {
+	uint32_t port;	
+	char *host;	
+	char *user;	
+	char *pass;	
+} mysql_db_info_t;
+
+typedef struct {
+	char *name;
+	char *options;
+} storage_field_t;
+
+extern pthread_mutex_t mysql_lock;
+
+extern int *destroy_mysql_db_info(mysql_db_info_t *db_info);
+
+extern int mysql_get_db_connection(MYSQL **mysql_db, char *db_name,
+				   mysql_db_info_t *db_info);
+extern int mysql_close_db_connection(MYSQL **mysql_db);
+extern int mysql_cleanup();
+extern int mysql_db_query(MYSQL *mysql_db, char *query);
+extern int mysql_db_ping(MYSQL *mysql_db);
+extern int mysql_db_commit(MYSQL *mysql_db);
+extern int mysql_db_rollback(MYSQL *mysql_db);
+
+extern MYSQL_RES *mysql_db_query_ret(MYSQL *mysql_db, char *query, bool last);
+
+extern int mysql_insert_ret_id(MYSQL *mysql_db, char *query);
+
+extern int mysql_db_create_table(MYSQL *mysql_db, char *table_name,
+				 storage_field_t *fields, char *ending);
+
+
+#endif
+
+#endif
diff --git a/src/database/pgsql_common.c b/src/database/pgsql_common.c
new file mode 100644
index 0000000000000000000000000000000000000000..819836e83a49b4cd0f7d0074f11f96ff26b4ef0f
--- /dev/null
+++ b/src/database/pgsql_common.c
@@ -0,0 +1,390 @@
+/*****************************************************************************\
+ *  pgsql_common.c - common functions for the the pgsql storage plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include "pgsql_common.h"
+#include <stdlib.h>
+
+pthread_mutex_t pgsql_lock = PTHREAD_MUTEX_INITIALIZER;
+
+#ifdef HAVE_PGSQL
+
+extern int *destroy_pgsql_db_info(pgsql_db_info_t *db_info)
+{
+	if(db_info) {
+		xfree(db_info->host);
+		xfree(db_info->user);
+		xfree(db_info->pass);
+		xfree(db_info);
+	}
+	return SLURM_SUCCESS;
+}
+
+extern int _create_db(char *db_name, pgsql_db_info_t *db_info)
+{
+	char create_line[50];
+	PGconn *pgsql_db = NULL;
+	char *connect_line = xstrdup_printf("dbname = 'postgres'"
+					    " host = '%s'"
+					    " port = '%u'"
+					    " user = '%s'"
+					    " password = '%s'",
+					    db_info->host,
+					    db_info->port,
+					    db_info->user,
+					    db_info->pass);
+
+	pgsql_db = PQconnectdb(connect_line);
+
+	if (PQstatus(pgsql_db) == CONNECTION_OK) {
+		PGresult *result = NULL;
+		snprintf(create_line, sizeof(create_line),
+			 "create database %s", db_name);
+		result = PQexec(pgsql_db, create_line);
+		if (PQresultStatus(result) != PGRES_COMMAND_OK) {
+			fatal("PQexec failed: %d %s\n%s",
+			     PQresultStatus(result), PQerrorMessage(pgsql_db), create_line);
+		}
+		PQclear(result);
+		pgsql_close_db_connection(&pgsql_db);
+	} else {
+		info("Connection failed to %s", connect_line);
+		fatal("Status was: %d %s",
+		      PQstatus(pgsql_db), PQerrorMessage(pgsql_db));
+	}
+	xfree(connect_line);
+
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_get_db_connection(PGconn **pgsql_db, char *db_name,
+				   pgsql_db_info_t *db_info)
+{
+	int rc = SLURM_SUCCESS;
+	bool storage_init = false;
+	char *connect_line = xstrdup_printf("dbname = '%s'"
+					    " host = '%s'"
+					    " port = '%u'"
+					    " user = '%s'"
+					    " password = '%s'",
+					    db_name,
+					    db_info->host,
+					    db_info->port,
+					    db_info->user,
+					    db_info->pass);
+
+	while(!storage_init) {
+		*pgsql_db = PQconnectdb(connect_line);
+		
+		if(PQstatus(*pgsql_db) != CONNECTION_OK) {
+			if(!strcmp(PQerrorMessage(*pgsql_db),
+				   "no password supplied")) {
+				PQfinish(*pgsql_db);
+				fatal("This Postgres connection needs "
+				      "a password.  It doesn't appear to "
+				      "like blank ones");
+			} 
+			
+			info("Database %s not created. Creating", db_name);
+			pgsql_close_db_connection(pgsql_db);
+			_create_db(db_name, db_info);		
+		} else {
+			storage_init = true;
+		} 
+	}
+	xfree(connect_line);
+	return rc;
+}
+
+extern int pgsql_close_db_connection(PGconn **pgsql_db)
+{
+	if(pgsql_db && *pgsql_db) {
+		PQfinish(*pgsql_db);
+		*pgsql_db = NULL;
+	}	      
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_db_query(PGconn *pgsql_db, char *query)
+{
+	PGresult *result = NULL;
+	
+	if(!pgsql_db)
+		fatal("You haven't inited this storage yet.");
+	
+	if(!(result = pgsql_db_query_ret(pgsql_db, query))) 
+		return SLURM_ERROR;
+	
+	PQclear(result);
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_db_commit(PGconn *pgsql_db)
+{
+	return pgsql_db_query(pgsql_db, "COMMIT WORK");	
+}
+
+extern int pgsql_db_rollback(PGconn *pgsql_db)
+{
+	return pgsql_db_query(pgsql_db, "ROLLBACK WORK");
+
+}
+
+extern PGresult *pgsql_db_query_ret(PGconn *pgsql_db, char *query)
+{
+	PGresult *result = NULL;
+	
+	if(!pgsql_db)
+		fatal("You haven't inited this storage yet.");
+
+	result = PQexec(pgsql_db, query);
+
+	if(PQresultStatus(result) != PGRES_COMMAND_OK
+	   && PQresultStatus(result) != PGRES_TUPLES_OK) {
+		error("PQexec failed: %d %s", PQresultStatus(result), 
+		      PQerrorMessage(pgsql_db));
+		info("query was %s", query);
+		PQclear(result);
+		return NULL;
+	}
+	return result;
+}
+
+extern int pgsql_insert_ret_id(PGconn *pgsql_db, char *sequence_name,
+			       char *query)
+{
+	int new_id = 0;
+	PGresult *result = NULL;
+
+	slurm_mutex_lock(&pgsql_lock);
+	if(pgsql_db_query(pgsql_db, query) != SLURM_ERROR)  {
+		char *new_query = xstrdup_printf(
+			"select last_value from %s", sequence_name);
+		
+		if((result = pgsql_db_query_ret(pgsql_db, new_query))) {
+			new_id = atoi(PQgetvalue(result, 0, 0));
+			PQclear(result);		
+		}
+		xfree(new_query);
+		if(!new_id) {
+			/* should have new id */
+			error("We should have gotten a new id: %s", 
+			      PQerrorMessage(pgsql_db));
+		}
+	}
+	slurm_mutex_unlock(&pgsql_lock);
+	
+	return new_id;
+	
+}
+
+extern int pgsql_db_create_table(PGconn *pgsql_db,  
+				 char *table_name, storage_field_t *fields,
+				 char *ending)
+{
+	char *query = NULL;
+	char *tmp = NULL;
+	char *next = NULL;
+	int i = 0;
+
+	query = xstrdup_printf("create table %s (", table_name);
+	i=0;
+	while(fields && fields->name) {
+		next = xstrdup_printf(" %s %s",
+				      fields->name, 
+				      fields->options);
+		if(i) 
+			xstrcat(tmp, ",");
+		xstrcat(tmp, next);
+		xfree(next);
+		fields++;
+		i++;
+	}
+	xstrcat(query, tmp);
+	xfree(tmp);
+	xstrcat(query, ending);
+
+	if(pgsql_db_query(pgsql_db, query) == SLURM_ERROR) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	return SLURM_SUCCESS;
+}
+
+extern int pgsql_db_make_table_current(PGconn *pgsql_db, char *table_name,
+				       storage_field_t *fields)
+{
+	char *query = NULL, *opt_part = NULL, *temp_char = NULL;
+	char *type = NULL;
+	int not_null = 0;
+	char *default_str = NULL;
+	char* original_ptr = NULL;
+	int i = 0;
+	PGresult *result = NULL;
+	List columns = NULL;
+	ListIterator itr = NULL;
+	char *col = NULL;
+
+	DEF_TIMERS;
+
+	query = xstrdup_printf("select column_name from "
+			       "information_schema.columns where "
+			       "table_name='%s'", table_name);
+
+	if(!(result = pgsql_db_query_ret(pgsql_db, query))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+	columns = list_create(slurm_destroy_char);
+	for (i = 0; i < PQntuples(result); i++) {
+		col = xstrdup(PQgetvalue(result, i, 0)); //column_name
+		list_append(columns, col);
+	}
+	PQclear(result);
+	itr = list_iterator_create(columns);
+	query = xstrdup_printf("alter table %s", table_name);
+	START_TIMER;
+	i=0;
+	while(fields[i].name) {
+		int found = 0;
+		if(!strcmp("serial", fields[i].options)) {
+			i++;
+			continue;
+		} 
+		opt_part = xstrdup(fields[i].options);
+		original_ptr = opt_part;
+		opt_part = strtok_r(opt_part, " ", &temp_char);
+		if(opt_part) {
+			type = xstrdup(opt_part);
+			opt_part = temp_char;
+			opt_part = strtok_r(opt_part, " ", &temp_char);
+			while(opt_part) {
+				if(!strcmp("not null", opt_part)) {
+					not_null = 1;
+					opt_part = temp_char;
+					opt_part = strtok_r(opt_part,
+							    " ", &temp_char);
+				} else if(!strcmp("default", opt_part)){
+					opt_part = temp_char;
+					opt_part = strtok_r(opt_part,
+							    " ", &temp_char);
+					default_str = xstrdup(opt_part);
+				}
+				if(opt_part) {
+					opt_part = temp_char;
+					opt_part = strtok_r(opt_part,
+							    " ", &temp_char);
+				}
+			}
+		} else {
+			type = xstrdup(fields[i].options);
+		}
+		xfree(original_ptr);
+		list_iterator_reset(itr);
+		while((col = list_next(itr))) {
+			if(!strcmp(col, fields[i].name)) {
+				list_delete_item(itr);
+				found = 1;
+				break;
+			}
+		}
+		
+		temp_char = NULL;
+		if(!found) {
+			info("adding column %s", fields[i].name);
+			if(default_str) 
+				xstrfmtcat(temp_char,
+					   " default %s", default_str);
+						
+			if(not_null) 
+				xstrcat(temp_char, " not null");
+			
+			xstrfmtcat(query,
+				   " add %s %s",
+				   fields[i].name, type);
+			if(temp_char)
+				xstrcat(query, temp_char);
+			xstrcat(query, ",");
+		} else {
+			if(default_str) 
+				xstrfmtcat(temp_char,
+					   " alter %s set default %s,",
+					   fields[i].name, default_str);
+			else 
+				xstrfmtcat(temp_char,
+					   " alter %s drop default,",
+					   fields[i].name);
+			
+			if(not_null) 
+				xstrfmtcat(temp_char,
+					   " alter %s set not null,",
+					   fields[i].name);
+			else 
+				xstrfmtcat(temp_char,
+					   " alter %s drop not null,",
+					   fields[i].name);
+			xstrfmtcat(query, " alter %s type %s,%s",
+				   fields[i].name, type, temp_char);
+		}
+		xfree(temp_char);
+		xfree(default_str);
+		xfree(type);
+	
+		i++;
+	}
+	list_iterator_destroy(itr);
+	list_destroy(columns);
+	query[strlen(query)-1] = ';';
+
+	if(pgsql_db_query(pgsql_db, query)) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+		
+	END_TIMER2("make table current");
+	return SLURM_SUCCESS;
+}
+
+
+#endif
+
diff --git a/src/database/pgsql_common.h b/src/database/pgsql_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..cc48e8c5fad7acbfa3ee19063278007d118ecae9
--- /dev/null
+++ b/src/database/pgsql_common.h
@@ -0,0 +1,100 @@
+/*****************************************************************************\
+ *  pgsql_common.h - common functions for the the pgsql storage plugin.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#ifndef _HAVE_PGSQL_COMMON_H
+#define _HAVE_PGSQL_COMMON_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <stdio.h>
+#include <slurm/slurm_errno.h>
+#include "src/slurmctld/slurmctld.h"
+#include "src/common/xstring.h"
+
+#ifdef HAVE_PGSQL
+#include <libpq-fe.h>
+
+typedef struct {
+	uint32_t port;	
+	char *host;	
+	char *user;	
+	char *pass;	
+} pgsql_db_info_t;
+
+typedef struct {
+	char *name;
+	char *options;
+} storage_field_t;
+
+extern pthread_mutex_t pgsql_lock;
+
+extern int *destroy_pgsql_db_info(pgsql_db_info_t *db_info);
+
+extern int pgsql_get_db_connection(PGconn **pgsql_db, char *db_name,
+				   pgsql_db_info_t *db_info);
+
+extern int pgsql_close_db_connection(PGconn **pgsql_db);
+
+extern int pgsql_db_query(PGconn *pgsql_db, char *query);
+extern int pgsql_db_commit(PGconn *pgsql_db);
+extern int pgsql_db_rollback(PGconn *pgsql_db);
+
+extern PGresult *pgsql_db_query_ret(PGconn *pgsql_db, char *query);
+
+extern int pgsql_insert_ret_id(PGconn *pgsql_db, 
+			       char *sequence_name, char *query);
+
+extern int pgsql_db_create_table(PGconn *pgsql_db, 
+				 char *table_name, storage_field_t *fields,
+				 char *ending);
+
+extern int pgsql_db_make_table_current(PGconn *pgsql_db, char *table_name,
+				       storage_field_t *fields);
+#endif
+
+#endif
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 25088e401ac43076025482b08e2ee4343f2f69da..a8e77ec42c224cf914b3047a598704194cad4f0f 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -1,2 +1 @@
-
-SUBDIRS = auth checkpoint jobacct jobcomp mpi proctrack sched select switch task
+SUBDIRS = accounting_storage auth checkpoint crypto jobacct_gather jobcomp mpi proctrack sched select switch task
diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in
index 67192790adc6ddb904a109f5ae0f15e22c333c6b..97b1039e4f644c342cfe2ac56e1746295613f4c8 100644
--- a/src/plugins/Makefile.in
+++ b/src/plugins/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -99,6 +101,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -112,10 +115,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -135,7 +141,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -146,6 +155,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -161,6 +172,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -176,6 +188,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -232,7 +245,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = auth checkpoint jobacct jobcomp mpi proctrack sched select switch task
+SUBDIRS = accounting_storage auth checkpoint crypto jobacct_gather jobcomp mpi proctrack sched select switch task
 all: all-recursive
 
 .SUFFIXES:
@@ -347,8 +360,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -373,8 +386,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -384,13 +397,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/accounting_storage/Makefile.am b/src/plugins/accounting_storage/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..c4879b80a208207af8b0cf26f21d70df56678ecd
--- /dev/null
+++ b/src/plugins/accounting_storage/Makefile.am
@@ -0,0 +1,3 @@
+# Makefile for storage plugins
+
+SUBDIRS = filetxt gold mysql pgsql none slurmdbd
diff --git a/src/plugins/accounting_storage/Makefile.in b/src/plugins/accounting_storage/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..251b0d160e3eef535cb5342404930b264d797bc5
--- /dev/null
+++ b/src/plugins/accounting_storage/Makefile.in
@@ -0,0 +1,565 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for storage plugins
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/accounting_storage
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = filetxt gold mysql pgsql none slurmdbd
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/plugins/accounting_storage/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  src/plugins/accounting_storage/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	    distdir=`$(am__cd) $(distdir) && pwd`; \
+	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$top_distdir" \
+	        distdir="$$distdir/$$subdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+	install-strip
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic clean-libtool \
+	ctags ctags-recursive distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/accounting_storage/filetxt/Makefile.am b/src/plugins/accounting_storage/filetxt/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..4ea567fb172c47e94491508348f2f9937b2c8a6f
--- /dev/null
+++ b/src/plugins/accounting_storage/filetxt/Makefile.am
@@ -0,0 +1,14 @@
+# Makefile for accounting_storage/filetxt plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = accounting_storage_filetxt.la
+
+accounting_storage_filetxt_la_SOURCES = accounting_storage_filetxt.c \
+		filetxt_jobacct_process.c filetxt_jobacct_process.h
+accounting_storage_filetxt_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+
diff --git a/src/plugins/accounting_storage/filetxt/Makefile.in b/src/plugins/accounting_storage/filetxt/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..672f6b8873c4008229a237c2477b7812f1ce8613
--- /dev/null
+++ b/src/plugins/accounting_storage/filetxt/Makefile.in
@@ -0,0 +1,559 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for accounting_storage/filetxt plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/accounting_storage/filetxt
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+accounting_storage_filetxt_la_LIBADD =
+am_accounting_storage_filetxt_la_OBJECTS =  \
+	accounting_storage_filetxt.lo filetxt_jobacct_process.lo
+accounting_storage_filetxt_la_OBJECTS =  \
+	$(am_accounting_storage_filetxt_la_OBJECTS)
+accounting_storage_filetxt_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(AM_CFLAGS) $(CFLAGS) \
+	$(accounting_storage_filetxt_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(accounting_storage_filetxt_la_SOURCES)
+DIST_SOURCES = $(accounting_storage_filetxt_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = accounting_storage_filetxt.la
+accounting_storage_filetxt_la_SOURCES = accounting_storage_filetxt.c \
+		filetxt_jobacct_process.c filetxt_jobacct_process.h
+
+accounting_storage_filetxt_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/accounting_storage/filetxt/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/accounting_storage/filetxt/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+accounting_storage_filetxt.la: $(accounting_storage_filetxt_la_OBJECTS) $(accounting_storage_filetxt_la_DEPENDENCIES) 
+	$(accounting_storage_filetxt_la_LINK) -rpath $(pkglibdir) $(accounting_storage_filetxt_la_OBJECTS) $(accounting_storage_filetxt_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_filetxt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filetxt_jobacct_process.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
new file mode 100644
index 0000000000000000000000000000000000000000..1e95e1baea91e962b6b6e912bafa40f76fe1f0ae
--- /dev/null
+++ b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
@@ -0,0 +1,830 @@
+/*****************************************************************************\
+ *  accounting_storage_filetxt.c - account interface to filetxt.
+ *
+ *  $Id: accounting_storage_filetxt.c 13061 2008-01-22 21:23:56Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2008 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include <strings.h>
+#include "src/common/slurm_accounting_storage.h"
+#include "filetxt_jobacct_process.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Accounting storage FileTxt plugin";
+const char plugin_type[] = "accounting_storage/filetxt";
+const uint32_t plugin_version = 100;
+static FILE *		LOGFILE;
+static int		LOGFILE_FD;
+static pthread_mutex_t  logfile_lock = PTHREAD_MUTEX_INITIALIZER;
+static int              storage_init;
+/* Format of the JOB_STEP record */
+const char *_jobstep_format = 
+"%d "
+"%u "	/* stepid */
+"%d "	/* completion status */
+"%u "	/* completion code */
+"%u "	/* nprocs */
+"%u "	/* number of cpus */
+"%u "	/* elapsed seconds */
+"%u "	/* total cputime seconds */
+"%u "	/* total cputime microseconds */
+"%u "	/* user seconds */
+"%u "	/* user microseconds */
+"%u "	/* system seconds */
+"%u "	/* system microseconds */
+"%u "	/* max rss */
+"%u "	/* max ixrss */
+"%u "	/* max idrss */
+"%u "	/* max isrss */
+"%u "	/* max minflt */
+"%u "	/* max majflt */
+"%u "	/* max nswap */
+"%u "	/* total inblock */
+"%u "	/* total outblock */
+"%u "	/* total msgsnd */
+"%u "	/* total msgrcv */
+"%u "	/* total nsignals */
+"%u "	/* total nvcsw */
+"%u "	/* total nivcsw */
+"%u "	/* max vsize */
+"%u "	/* max vsize task */
+"%.2f "	/* ave vsize */
+"%u "	/* max rss */
+"%u "	/* max rss task */
+"%.2f "	/* ave rss */
+"%u "	/* max pages */
+"%u "	/* max pages task */
+"%.2f "	/* ave pages */
+"%.2f "	/* min cpu */
+"%u "	/* min cpu task */
+"%.2f "	/* ave cpu */
+"%s "	/* step process name */
+"%s "	/* step node names */
+"%u "	/* max vsize node */
+"%u "	/* max rss node */
+"%u "	/* max pages node */
+"%u "	/* min cpu node */
+"%s "   /* account */
+"%u";   /* requester user id */
+
+/*
+ * Print the record to the log file.
+ */
+
+static int _print_record(struct job_record *job_ptr, 
+			 time_t time, char *data)
+{ 
+	static int   rc=SLURM_SUCCESS;
+	char *block_id = NULL;
+	if(!job_ptr->details) {
+		error("job_acct: job=%u doesn't exist", job_ptr->job_id);
+		return SLURM_ERROR;
+	}
+	debug2("_print_record, job=%u, \"%s\"",
+	       job_ptr->job_id, data);
+#ifdef HAVE_BG
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_BLOCK_ID, 
+			     &block_id);
+		
+#endif
+	if(!block_id)
+		block_id = xstrdup("-");
+
+	slurm_mutex_lock( &logfile_lock );
+
+	if (fprintf(LOGFILE,
+		    "%u %s %d %d %u %u %s - %s\n",
+		    job_ptr->job_id, job_ptr->partition,
+		    (int)job_ptr->details->submit_time, (int)time, 
+		    job_ptr->user_id, job_ptr->group_id, block_id, data)
+	    < 0)
+		rc=SLURM_ERROR;
+#ifdef HAVE_FDATASYNC
+	fdatasync(LOGFILE_FD);
+#endif
+	slurm_mutex_unlock( &logfile_lock );
+	xfree(block_id);
+
+	return rc;
+}
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	static int first = 1;
+	char *log_file = NULL;	
+	int 		rc = SLURM_SUCCESS;
+	mode_t		prot = 0600;
+	struct stat	statbuf;
+	
+	if(first) {
+		debug2("jobacct_init() called");
+		log_file = slurm_get_accounting_storage_loc();
+		if(!log_file)
+			log_file = xstrdup(DEFAULT_STORAGE_LOC);
+		slurm_mutex_lock( &logfile_lock );
+		if (LOGFILE)
+			fclose(LOGFILE);
+		
+		if (*log_file != '/')
+			fatal("JobAcctLogfile must specify an "
+			      "absolute pathname");
+		if (stat(log_file, &statbuf)==0)/* preserve current file mode */
+			prot = statbuf.st_mode;
+		LOGFILE = fopen(log_file, "a");
+		if (LOGFILE == NULL) {
+			error("open %s: %m", log_file);
+			storage_init = 0;
+			xfree(log_file);
+			slurm_mutex_unlock( &logfile_lock );
+			return SLURM_ERROR;
+		} else
+			chmod(log_file, prot); 
+		
+		xfree(log_file);
+		
+		if (setvbuf(LOGFILE, NULL, _IOLBF, 0))
+			error("setvbuf() failed");
+		LOGFILE_FD = fileno(LOGFILE);
+		slurm_mutex_unlock( &logfile_lock );
+		storage_init = 1;
+		/* since this can be loaded from many different places
+		   only tell us once. */
+		verbose("%s loaded", plugin_name);
+		first = 0;
+	} else {
+		debug4("%s loaded", plugin_name);
+	}
+	return rc;
+}
+
+
+extern int fini ( void )
+{
+	if (LOGFILE)
+		fclose(LOGFILE);
+	return SLURM_SUCCESS;
+}
+
+extern void * acct_storage_p_get_connection(bool make_agent, bool rollback)
+{
+	return NULL;
+}
+
+extern int acct_storage_p_close_connection(void **db_conn)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_commit(void *db_conn, bool commit)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_users(void *db_conn, uint32_t uid,
+				    List user_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_coord(void *db_conn, uint32_t uid,
+				    char *acct, acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_accts(void *db_conn, uint32_t uid,
+				    List acct_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_clusters(void *db_conn, uint32_t uid,
+				       List cluster_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_associations(void *db_conn, uint32_t uid,
+					   List association_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q,
+				       acct_user_rec_t *user)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_accts(void *db_conn, uint32_t uid,
+				       acct_account_cond_t *acct_q,
+				       acct_account_rec_t *acct)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_clusters(void *db_conn, uint32_t uid,
+					  acct_cluster_cond_t *cluster_q,
+					  acct_cluster_rec_t *cluster)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_associations(void *db_conn, uint32_t uid,
+					      acct_association_cond_t *assoc_q,
+					      acct_association_rec_t *assoc)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_coord(void *db_conn, uint32_t uid,
+				       char *acct, acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_accts(void *db_conn, uint32_t uid,
+				       acct_account_cond_t *acct_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_clusters(void *db_conn, uint32_t uid,
+					  acct_account_cond_t *cluster_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_associations(void *db_conn, uint32_t uid,
+					      acct_association_cond_t *assoc_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_get_users(void *db_conn,
+				     acct_user_cond_t *user_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_accts(void *db_conn,
+				     acct_account_cond_t *acct_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_clusters(void *db_conn,
+					acct_account_cond_t *cluster_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_associations(void *db_conn,
+					    acct_association_cond_t *assoc_q)
+{
+	return NULL;
+}
+
+extern int acct_storage_p_get_usage(void *db_conn,
+				    acct_association_rec_t *acct_assoc,
+				    time_t start, time_t end)
+{
+	int rc = SLURM_SUCCESS;
+
+	return rc;
+}
+
+extern int acct_storage_p_roll_usage(void *db_conn, 
+				     time_t sent_start)
+{
+	int rc = SLURM_SUCCESS;
+
+	return rc;
+}
+
+extern int clusteracct_storage_p_node_down(void *db_conn,
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time, char *reason)
+{
+	return SLURM_SUCCESS;
+}
+extern int clusteracct_storage_p_node_up(void *db_conn,
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_register_ctld(char *cluster,
+					       uint16_t port)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_cluster_procs(void *db_conn,
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_get_usage(
+	void *db_conn, 
+	acct_cluster_rec_t *cluster_rec, time_t start, time_t end)
+{
+
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the start of a job
+ */
+extern int jobacct_storage_p_job_start(void *db_conn,
+				       struct job_record *job_ptr)
+{
+	int	i,
+		rc=SLURM_SUCCESS,
+		tmp;
+	char	buf[BUFFER_SIZE], *jname, *account, *nodes;
+	long	priority;
+	int track_steps = 0;
+
+	if(!storage_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+
+	debug2("jobacct_job_start() called");
+
+	if (job_ptr->start_time == 0) {
+		/* This function is called when a job becomes elligible to run
+		 * in order to record reserved time (a measure of system
+		 * over-subscription). We only use this with database
+		 * plugins. */
+		return rc;
+	}
+
+	priority = (job_ptr->priority == NO_VAL) ?
+		-1L : (long) job_ptr->priority;
+
+	if (job_ptr->name && (tmp = strlen(job_ptr->name))) {
+		jname = xmalloc(++tmp);
+		for (i=0; i<tmp; i++) {
+			if (isspace(job_ptr->name[i]))
+				jname[i]='_';
+			else
+				jname[i]=job_ptr->name[i];
+		}
+	} else {
+		jname = xstrdup("allocation");
+		track_steps = 1;
+	}
+
+	if (job_ptr->account && job_ptr->account[0])
+		account = job_ptr->account;
+	else
+		account = "(null)";
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->batch_flag)
+		track_steps = 1;
+
+	job_ptr->requid = -1; /* force to -1 for sacct to know this
+			       * hasn't been set yet */
+
+	tmp = snprintf(buf, BUFFER_SIZE,
+		       "%d %s %d %ld %u %s %s",
+		       JOB_START, jname,
+		       track_steps, priority, job_ptr->total_procs,
+		       nodes, account);
+
+	rc = _print_record(job_ptr, job_ptr->start_time, buf);
+	
+	xfree(jname);
+	return rc;
+}
+
+/* 
+ * load into the storage the end of a job
+ */
+extern int jobacct_storage_p_job_complete(void *db_conn,
+					  struct job_record *job_ptr)
+{
+	char buf[BUFFER_SIZE];
+	if(!storage_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+	
+	debug2("jobacct_job_complete() called");
+	if (job_ptr->end_time == 0) {
+		debug("jobacct: job %u never started", job_ptr->job_id);
+		return SLURM_ERROR;
+	}
+	/* leave the requid as a %d since we want to see if it is -1
+	   in sacct */
+	snprintf(buf, BUFFER_SIZE, "%d %d %d %u %u",
+		 JOB_TERMINATED,
+		 (int) (job_ptr->end_time - job_ptr->start_time),
+		 job_ptr->job_state & (~JOB_COMPLETING),
+		 job_ptr->requid, job_ptr->exit_code);
+	
+	return  _print_record(job_ptr, job_ptr->end_time, buf);
+}
+
+/* 
+ * load into the storage the start of a job step
+ */
+extern int jobacct_storage_p_step_start(void *db_conn,
+					struct step_record *step_ptr)
+{
+	char buf[BUFFER_SIZE];
+	int cpus = 0;
+	char node_list[BUFFER_SIZE];
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	float float_tmp = 0;
+	char *account;
+	
+	if(!storage_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if(ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->total_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s", step_ptr->job_ptr->nodes);
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+	if (step_ptr->job_ptr->account && step_ptr->job_ptr->account[0])
+		account = step_ptr->job_ptr->account;
+	else
+		account = "(null)";
+
+	step_ptr->job_ptr->requid = -1; /* force to -1 for sacct to know this
+				     * hasn't been set yet  */
+
+	snprintf(buf, BUFFER_SIZE, _jobstep_format,
+		 JOB_STEP,
+		 step_ptr->step_id,	/* stepid */
+		 JOB_RUNNING,		/* completion status */
+		 0,     		/* completion code */
+		 cpus,          	/* number of tasks */
+		 cpus,                  /* number of cpus */
+		 0,	        	/* elapsed seconds */
+		 0,                    /* total cputime seconds */
+		 0,    		/* total cputime seconds */
+		 0,	/* user seconds */
+		 0,/* user microseconds */
+		 0,	/* system seconds */
+		 0,/* system microsecs */
+		 0,	/* max rss */
+		 0,	/* max ixrss */
+		 0,	/* max idrss */
+		 0,	/* max isrss */
+		 0,	/* max minflt */
+		 0,	/* max majflt */
+		 0,	/* max nswap */
+		 0,	/* total inblock */
+		 0,	/* total outblock */
+		 0,	/* total msgsnd */
+		 0,	/* total msgrcv */
+		 0,	/* total nsignals */
+		 0,	/* total nvcsw */
+		 0,	/* total nivcsw */
+		 0,	/* max vsize */
+		 0,	/* max vsize task */
+		 float_tmp,	/* ave vsize */
+		 0,	/* max rss */
+		 0,	/* max rss task */
+		 float_tmp,	/* ave rss */
+		 0,	/* max pages */
+		 0,	/* max pages task */
+		 float_tmp,	/* ave pages */
+		 float_tmp,	/* min cpu */
+		 0,	/* min cpu task */
+		 float_tmp,	/* ave cpu */
+		 step_ptr->name,    /* step exe name */
+		 node_list,     /* name of nodes step running on */
+		 0,	/* max vsize node */
+		 0,	/* max rss node */
+		 0,	/* max pages node */
+		 0,	/* min cpu node */
+		 account,
+		 step_ptr->job_ptr->requid); /* requester user id */
+		 
+	return _print_record(step_ptr->job_ptr, step_ptr->start_time, buf);
+}
+
+/* 
+ * load into the storage the end of a job step
+ */
+extern int jobacct_storage_p_step_complete(void *db_conn,
+					   struct step_record *step_ptr)
+{
+	char buf[BUFFER_SIZE];
+	time_t now;
+	int elapsed;
+	int comp_status;
+	int cpus = 0;
+	char node_list[BUFFER_SIZE];
+	struct jobacctinfo *jobacct = (struct jobacctinfo *)step_ptr->jobacct;
+	struct jobacctinfo dummy_jobacct;
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	float ave_vsize = 0, ave_rss = 0, ave_pages = 0;
+	float ave_cpu = 0, ave_cpu2 = 0;
+	char *account;
+
+	if(!storage_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+	
+	now = time(NULL);
+
+	if (jobacct == NULL) {
+		/* JobAcctGather=jobacct_gather/none, no data to process */
+		bzero(&dummy_jobacct, sizeof(dummy_jobacct));
+		jobacct = &dummy_jobacct;
+	}
+	
+	if ((elapsed=now-step_ptr->start_time)<0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	if (step_ptr->exit_code)
+		comp_status = JOB_FAILED;
+	else
+		comp_status = JOB_COMPLETE;
+
+#ifdef HAVE_BG
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if(ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->job_ptr->nodes);
+	
+#else
+	if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->total_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s", step_ptr->job_ptr->nodes);
+	
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+	/* figure out the ave of the totals sent */
+	if(cpus > 0) {
+		ave_vsize = jobacct->tot_vsize;
+		ave_vsize /= cpus;
+		ave_rss = jobacct->tot_rss;
+		ave_rss /= cpus;
+		ave_pages = jobacct->tot_pages;
+		ave_pages /= cpus;
+		ave_cpu = jobacct->tot_cpu;
+		ave_cpu /= cpus;	
+		ave_cpu /= 100;
+	}
+ 
+	if(jobacct->min_cpu != (uint32_t)NO_VAL) {
+		ave_cpu2 = jobacct->min_cpu;
+		ave_cpu2 /= 100;
+	}
+
+	if (step_ptr->job_ptr->account && step_ptr->job_ptr->account[0])
+		account = step_ptr->job_ptr->account;
+	else
+		account = "(null)";
+
+	snprintf(buf, BUFFER_SIZE, _jobstep_format,
+		 JOB_STEP,
+		 step_ptr->step_id,	/* stepid */
+		 comp_status,		/* completion status */
+		 step_ptr->exit_code,	/* completion code */
+		 cpus,          	/* number of tasks */
+		 cpus,                  /* number of cpus */
+		 elapsed,	        /* elapsed seconds */
+		 /* total cputime seconds */
+		 jobacct->user_cpu_sec	
+		 + jobacct->sys_cpu_sec,
+		 /* total cputime seconds */
+		 jobacct->user_cpu_usec	
+		 + jobacct->sys_cpu_usec,
+		 jobacct->user_cpu_sec,	/* user seconds */
+		 jobacct->user_cpu_usec,/* user microseconds */
+		 jobacct->sys_cpu_sec,	/* system seconds */
+		 jobacct->sys_cpu_usec,/* system microsecs */
+		 0,	/* max rss */
+		 0,	/* max ixrss */
+		 0,	/* max idrss */
+		 0,	/* max isrss */
+		 0,	/* max minflt */
+		 0,	/* max majflt */
+		 0,	/* max nswap */
+		 0,	/* total inblock */
+		 0,	/* total outblock */
+		 0,	/* total msgsnd */
+		 0,	/* total msgrcv */
+		 0,	/* total nsignals */
+		 0,	/* total nvcsw */
+		 0,	/* total nivcsw */
+		 jobacct->max_vsize,	/* max vsize */
+		 jobacct->max_vsize_id.taskid,	/* max vsize node */
+		 ave_vsize,	/* ave vsize */
+		 jobacct->max_rss,	/* max vsize */
+		 jobacct->max_rss_id.taskid,	/* max rss node */
+		 ave_rss,	/* ave rss */
+		 jobacct->max_pages,	/* max pages */
+		 jobacct->max_pages_id.taskid,	/* max pages node */
+		 ave_pages,	/* ave pages */
+		 ave_cpu2,	/* min cpu */
+		 jobacct->min_cpu_id.taskid,	/* min cpu node */
+		 ave_cpu,	/* ave cpu */
+		 step_ptr->name,      	/* step exe name */
+		 node_list, /* name of nodes step running on */
+		 jobacct->max_vsize_id.nodeid,	/* max vsize task */
+		 jobacct->max_rss_id.nodeid,	/* max rss task */
+		 jobacct->max_pages_id.nodeid,	/* max pages task */
+		 jobacct->min_cpu_id.nodeid,	/* min cpu task */
+		 account,
+		 step_ptr->job_ptr->requid); /* requester user id */
+		 
+	return _print_record(step_ptr->job_ptr, now, buf);	
+}
+
+/* 
+ * load into the storage a suspention of a job
+ */
+extern int jobacct_storage_p_suspend(void *db_conn,
+				     struct job_record *job_ptr)
+{
+	char buf[BUFFER_SIZE];
+	static time_t	now = 0;
+	static time_t	temp = 0;
+	int elapsed;
+	if(!storage_init) {
+		debug("jobacct init was not called or it failed");
+		return SLURM_ERROR;
+	}
+	
+	/* tell what time has passed */
+	if(!now)
+		now = job_ptr->start_time;
+	temp = now;
+	now = time(NULL);
+	
+	if ((elapsed=now-temp) < 0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	
+	/* here we are really just going for a marker in time to tell when
+	 * the process was suspended or resumed (check job state), we don't 
+	 * really need to keep track of anything else */
+	snprintf(buf, BUFFER_SIZE, "%d %d %d",
+		 JOB_SUSPEND,
+		 elapsed,
+		 job_ptr->job_state & (~JOB_COMPLETING));/* job status */
+		
+	return _print_record(job_ptr, now, buf);
+}
+
+/* 
+ * get info from the storage 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_p_get_jobs(void *db_conn,
+				       List selected_steps,
+				       List selected_parts,
+				       void *params)
+{
+	return filetxt_jobacct_process_get_jobs(selected_steps, selected_parts,
+						params);
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void jobacct_storage_p_archive(void *db_conn,
+				      List selected_parts,
+				      void *params)
+{
+	filetxt_jobacct_process_archive(selected_parts, params);
+	return;
+}
+
+extern int acct_storage_p_update_shares_used(void *db_conn,
+					     List shares_used)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_flush_jobs_on_cluster(
+	void *db_conn, char *cluster, time_t event_time)
+{
+	/* put end times for a clean start */
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..a9d0f7470d6fdc6ff776405baebf2b4e6eaa2a7b
--- /dev/null
+++ b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
@@ -0,0 +1,1450 @@
+/*****************************************************************************\
+ *  filetxt_jobacct_process.c - functions the processing of
+ *                               information from the filetxt jobacct
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+#include "src/common/xstring.h"
+#include "src/common/xmalloc.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/jobacct_common.h"
+#include "src/slurmctld/slurmctld.h"
+#include "src/slurmdbd/read_config.h"
+/* Map field names to positions */
+
+/* slurmd uses "(uint32_t) -2" to track data for batch allocations
+ * which have no logical jobsteps. */
+#define BATCH_JOB_TIMESTAMP 0
+#define EXPIRE_READ_LENGTH 10
+#define MAX_RECORD_FIELDS 100
+
+typedef struct expired_rec {  /* table of expired jobs */
+	uint32_t job;
+	time_t job_submit;
+	char *line;
+} expired_rec_t;
+
+typedef struct header {
+	uint32_t jobnum;
+	char	*partition;
+	char	*blockid;
+	time_t 	job_submit;
+	time_t 	timestamp;
+	uint32_t uid;
+	uint32_t gid;
+	uint16_t rec_type;
+} filetxt_header_t;
+
+typedef struct {
+	uint32_t job_start_seen,		/* useful flags */
+		job_step_seen,
+		job_terminated_seen,
+		jobnum_superseded;	/* older jobnum was reused */
+	filetxt_header_t header;
+	uint16_t show_full;
+	char	*nodes;
+	char	*jobname;
+	uint16_t track_steps;
+	int32_t priority;
+	uint32_t ncpus;
+	uint32_t ntasks;
+	enum job_states	status;
+	int32_t	exitcode;
+	uint32_t elapsed;
+	time_t end;
+	uint32_t tot_cpu_sec;
+	uint32_t tot_cpu_usec;
+	struct rusage rusage;
+	sacct_t sacct;
+	List    steps;
+	char    *account;
+	uint32_t requid;
+} filetxt_job_rec_t;
+
+typedef struct {
+	filetxt_header_t   header;
+	uint32_t	stepnum;	/* job's step number */
+	char	        *nodes;
+	char	        *stepname;
+	enum job_states	status;
+	int32_t	        exitcode;
+	uint32_t	ntasks; 
+	uint32_t        ncpus;
+	uint32_t	elapsed;
+	time_t          end;
+	uint32_t	tot_cpu_sec;
+	uint32_t        tot_cpu_usec;
+	struct rusage   rusage;
+	sacct_t         sacct;
+	char            *account;
+	uint32_t requid;
+} filetxt_step_rec_t;
+
+/* Fields common to all records */
+enum {	F_JOB =	0,
+	F_PARTITION,	
+	F_JOB_SUBMIT,	
+	F_TIMESTAMP,	
+	F_UID,	
+	F_GID,	
+	F_BLOCKID,	
+	F_RESERVED2,	
+	F_RECTYPE,	
+	HEADER_LENGTH
+};
+
+/* JOB_START fields */
+enum {	F_JOBNAME = HEADER_LENGTH,
+	F_TRACK_STEPS,		
+	F_PRIORITY,	
+	F_NCPUS,		
+	F_NODES,
+	F_JOB_ACCOUNT,
+	JOB_START_LENGTH
+};
+
+/* JOB_STEP fields */
+enum {	F_JOBSTEP = HEADER_LENGTH,
+	F_STATUS,
+	F_EXITCODE,
+	F_NTASKS,
+	F_STEPNCPUS,
+	F_ELAPSED,
+	F_CPU_SEC,
+	F_CPU_USEC,
+	F_USER_SEC,
+	F_USER_USEC,
+	F_SYS_SEC,
+	F_SYS_USEC,
+	F_RSS,
+	F_IXRSS,
+	F_IDRSS,
+	F_ISRSS,
+	F_MINFLT,
+	F_MAJFLT,
+	F_NSWAP,
+	F_INBLOCKS,
+	F_OUBLOCKS,
+	F_MSGSND,
+	F_MSGRCV,
+	F_NSIGNALS,
+	F_NVCSW,
+	F_NIVCSW,
+	F_MAX_VSIZE,
+	F_MAX_VSIZE_TASK,
+	F_AVE_VSIZE,
+	F_MAX_RSS,
+	F_MAX_RSS_TASK,
+	F_AVE_RSS,
+	F_MAX_PAGES,
+	F_MAX_PAGES_TASK,
+	F_AVE_PAGES,
+	F_MIN_CPU,
+	F_MIN_CPU_TASK,
+	F_AVE_CPU,
+	F_STEPNAME,
+	F_STEPNODES,
+	F_MAX_VSIZE_NODE,
+	F_MAX_RSS_NODE,
+	F_MAX_PAGES_NODE,
+	F_MIN_CPU_NODE,
+	F_STEP_ACCOUNT,
+	F_STEP_REQUID,
+	JOB_STEP_LENGTH
+};
+
+/* JOB_TERM / JOB_SUSPEND fields */
+enum {	F_TOT_ELAPSED = HEADER_LENGTH,
+	F_TERM_STATUS,
+	F_JOB_REQUID,
+	F_JOB_EXITCODE,
+	JOB_TERM_LENGTH
+};
+
+static void _destroy_exp(void *object)
+{
+	expired_rec_t *exp_rec = (expired_rec_t *)object;
+	if(exp_rec) {
+		xfree(exp_rec->line);
+		xfree(exp_rec);
+	}
+}
+
+static void _free_filetxt_header(void *object)
+{
+	filetxt_header_t *header = (filetxt_header_t *)object;
+	if(header) {
+		xfree(header->partition);
+#ifdef HAVE_BG
+		xfree(header->blockid);
+#endif
+	}
+}
+
+static void _destroy_filetxt_job_rec(void *object)
+{
+	filetxt_job_rec_t *job = (filetxt_job_rec_t *)object;
+	if (job) {
+		if(job->steps)
+			list_destroy(job->steps);
+		_free_filetxt_header(&job->header);
+		xfree(job->jobname);
+		xfree(job->account);
+		xfree(job->nodes);
+		xfree(job);
+	}
+}
+
+static void _destroy_filetxt_step_rec(void *object)
+{
+	filetxt_step_rec_t *step = (filetxt_step_rec_t *)object;
+	if (step) {
+		_free_filetxt_header(&step->header);
+		xfree(step->stepname);
+		xfree(step->nodes);
+		xfree(step->account);
+		xfree(step);
+	}
+}
+
+static jobacct_step_rec_t *_create_jobacct_step_rec(
+	filetxt_step_rec_t *filetxt_step)
+{
+	jobacct_step_rec_t *jobacct_step = create_jobacct_step_rec();
+	
+	jobacct_step->jobid = filetxt_step->header.jobnum;
+	jobacct_step->elapsed = filetxt_step->elapsed;
+	jobacct_step->end = filetxt_step->header.timestamp;
+	jobacct_step->exitcode = filetxt_step->exitcode;
+	jobacct_step->ncpus = filetxt_step->ncpus;
+	jobacct_step->nodes = xstrdup(filetxt_step->nodes);
+	jobacct_step->requid = filetxt_step->requid;
+	memcpy(&jobacct_step->sacct, &filetxt_step->sacct, sizeof(sacct_t));
+	jobacct_step->start = filetxt_step->header.timestamp -
+		jobacct_step->elapsed;
+	jobacct_step->state = filetxt_step->status;
+	jobacct_step->stepid = filetxt_step->stepnum;
+	jobacct_step->stepname = xstrdup(filetxt_step->stepname);
+	jobacct_step->sys_cpu_sec = filetxt_step->rusage.ru_stime.tv_sec;
+	jobacct_step->sys_cpu_usec = filetxt_step->rusage.ru_stime.tv_usec;
+	jobacct_step->tot_cpu_sec = filetxt_step->tot_cpu_sec;
+	jobacct_step->tot_cpu_usec = filetxt_step->tot_cpu_usec;
+	jobacct_step->user_cpu_sec = filetxt_step->rusage.ru_utime.tv_sec;
+	jobacct_step->user_cpu_usec = filetxt_step->rusage.ru_utime.tv_usec;
+
+	return jobacct_step;
+}
+
+static jobacct_job_rec_t *_create_jobacct_job_rec(
+	filetxt_job_rec_t *filetxt_job)
+{
+	jobacct_job_rec_t *jobacct_job = create_jobacct_job_rec();
+	ListIterator itr = NULL;
+	filetxt_step_rec_t *filetxt_step = NULL;
+
+	jobacct_job->associd = 0;
+	jobacct_job->account = xstrdup(filetxt_job->account);
+	jobacct_job->blockid = xstrdup(filetxt_job->header.blockid);
+	jobacct_job->cluster = NULL;
+	jobacct_job->elapsed = filetxt_job->elapsed;
+	jobacct_job->eligible = filetxt_job->header.job_submit;
+	jobacct_job->end = filetxt_job->header.timestamp;
+	jobacct_job->exitcode = filetxt_job->exitcode;
+	jobacct_job->gid = filetxt_job->header.gid;
+	jobacct_job->jobid = filetxt_job->header.jobnum;
+	jobacct_job->jobname = xstrdup(filetxt_job->jobname);
+	jobacct_job->partition = xstrdup(filetxt_job->header.partition);
+	jobacct_job->req_cpus = filetxt_job->ncpus;
+	jobacct_job->alloc_cpus = filetxt_job->ncpus;
+	jobacct_job->nodes = xstrdup(filetxt_job->nodes);
+	jobacct_job->priority = filetxt_job->priority;
+	jobacct_job->requid = filetxt_job->requid;
+	memcpy(&jobacct_job->sacct, &filetxt_job->sacct, sizeof(sacct_t));
+	jobacct_job->start = filetxt_job->header.timestamp -
+		jobacct_job->elapsed;
+	jobacct_job->state = filetxt_job->status;
+
+	jobacct_job->steps = list_create(destroy_jobacct_step_rec);
+	if(filetxt_job->steps) {
+		itr = list_iterator_create(filetxt_job->steps);
+		while((filetxt_step = list_next(itr))) {
+			list_append(jobacct_job->steps,
+				    _create_jobacct_step_rec(filetxt_step));
+		}
+		list_iterator_destroy(itr);
+	}
+	jobacct_job->submit = filetxt_job->header.job_submit;
+	
+	jobacct_job->sys_cpu_sec = filetxt_job->rusage.ru_stime.tv_sec;
+	jobacct_job->sys_cpu_usec = filetxt_job->rusage.ru_stime.tv_usec;
+	jobacct_job->tot_cpu_sec = filetxt_job->tot_cpu_sec;
+	jobacct_job->tot_cpu_usec = filetxt_job->tot_cpu_usec;
+	jobacct_job->track_steps = filetxt_job->track_steps;
+	jobacct_job->uid = filetxt_job->header.uid;
+	jobacct_job->user = NULL;
+	jobacct_job->user_cpu_sec = filetxt_job->rusage.ru_utime.tv_sec;
+	jobacct_job->user_cpu_usec = filetxt_job->rusage.ru_utime.tv_usec;
+	
+	return jobacct_job;
+}
+
+static filetxt_job_rec_t *_create_filetxt_job_rec(filetxt_header_t header)
+{
+	filetxt_job_rec_t *job = xmalloc(sizeof(filetxt_job_rec_t));
+	memcpy(&job->header, &header, sizeof(filetxt_header_t));
+	memset(&job->rusage, 0, sizeof(struct rusage));
+	memset(&job->sacct, 0, sizeof(sacct_t));
+	job->sacct.min_cpu = (float)NO_VAL;
+	job->job_start_seen = 0;
+	job->job_step_seen = 0;
+	job->job_terminated_seen = 0;
+	job->jobnum_superseded = 0;
+	job->jobname = NULL;
+	job->status = JOB_PENDING;
+	job->nodes = NULL;
+	job->jobname = NULL;
+	job->exitcode = 0;
+	job->priority = 0;
+	job->ntasks = 0;
+	job->ncpus = 0;
+	job->elapsed = 0;
+	job->tot_cpu_sec = 0;
+	job->tot_cpu_usec = 0;
+	job->steps = list_create(_destroy_filetxt_step_rec);
+	job->nodes = NULL;
+	job->track_steps = 0;
+	job->account = NULL;
+	job->requid = -1;
+
+      	return job;
+}
+
+static filetxt_step_rec_t *_create_filetxt_step_rec(filetxt_header_t header)
+{
+	filetxt_step_rec_t *step = xmalloc(sizeof(filetxt_job_rec_t));
+	memcpy(&step->header, &header, sizeof(filetxt_header_t));
+	memset(&step->rusage, 0, sizeof(struct rusage));
+	memset(&step->sacct, 0, sizeof(sacct_t));
+	step->stepnum = (uint32_t)NO_VAL;
+	step->nodes = NULL;
+	step->stepname = NULL;
+	step->status = NO_VAL;
+	step->exitcode = NO_VAL;
+	step->ntasks = (uint32_t)NO_VAL;
+	step->ncpus = (uint32_t)NO_VAL;
+	step->elapsed = (uint32_t)NO_VAL;
+	step->tot_cpu_sec = (uint32_t)NO_VAL;
+	step->tot_cpu_usec = (uint32_t)NO_VAL;
+	step->account = NULL;
+	step->requid = -1;
+
+	return step;
+}
+
+/* prefix_filename() -- insert a filename prefix into a path
+ *
+ * IN:	path = fully-qualified path+file name
+ *      prefix = the prefix to insert into the file name
+ * RETURNS: pointer to the updated path+file name
+ */
+
+static char *_prefix_filename(char *path, char *prefix) {
+	char	*out;
+	int     i,
+		plen;
+
+	plen = strlen(path);
+	out = xmalloc(plen+strlen(prefix)+1);
+	for (i=plen-1; i>=0; i--)
+		if (path[i]=='/') {
+			break;
+		}
+	i++;
+	*out = 0;
+	strncpy(out, path, i);
+	out[i] = 0;
+	strcat(out, prefix);
+	strcat(out, path+i);
+	return(out);
+}
+
+/* _open_log_file() -- find the current or specified log file, and open it
+ *
+ * IN:		Nothing
+ * RETURNS:	Nothing
+ *
+ * Side effects:
+ * 	- Sets opt_filein to the current system accounting log unless
+ * 	  the user specified another file.
+ */
+
+static FILE *_open_log_file(char *logfile)
+{
+	FILE *fd = fopen(logfile, "r");
+	if (fd == NULL) {
+		perror(logfile);
+		exit(1);
+	}
+	return fd;
+}
+
+static char *_convert_type(int rec_type)
+{
+	switch(rec_type) {
+	case JOB_START:
+		return "JOB_START";
+	case JOB_STEP:
+		return "JOB_STEP";
+	case JOB_TERMINATED:
+		return "JOB_TERMINATED";
+	default:
+		return "UNKNOWN";
+	}
+}
+
+static int _cmp_jrec(const void *a1, const void *a2) {
+	expired_rec_t *j1 = (expired_rec_t *) a1;
+	expired_rec_t *j2 = (expired_rec_t *) a2;
+
+	if (j1->job <  j2->job)
+		return -1;
+	else if (j1->job == j2->job) {
+		if(j1->job_submit == j2->job_submit)
+			return 0;
+		else 
+			return 1;
+	}
+	return 1;
+}
+
+static void _show_rec(char *f[])
+{
+	int 	i;
+	fprintf(stderr, "rec>");
+	for (i=0; f[i]; i++)
+		fprintf(stderr, " %s", f[i]);
+	fprintf(stderr, "\n");
+	return;
+}
+
+static void _do_fdump(char* f[], int lc)
+{
+	int	i=0, j=0;
+	char **type;
+	char    *header[] = {"job",       /* F_JOB */
+			     "partition", /* F_PARTITION */
+			     "job_submit", /* F_JOB_SUBMIT */
+			     "timestamp", /* F_TIMESTAMP */
+			     "uid",	 /* F_UIDGID */
+			     "gid",	 /* F_UIDGID */
+			     "BlockID",  /* F_BLOCKID */
+			     "reserved-2",/* F_RESERVED1 */
+			     "recordType",/* F_RECTYPE */
+			     NULL};
+
+	char	*start[] = {"jobName",	 /* F_JOBNAME */ 
+			    "TrackSteps", /* F_TRACK_STEPS */
+			    "priority",	 /* F_PRIORITY */
+			    "ncpus",	 /* F_NCPUS */
+			    "nodeList", /* F_NODES */
+			    "account",   /* F_JOB_ACCOUNT */
+			    NULL};
+		
+	char	*step[] = {"jobStep",	 /* F_JOBSTEP */
+			   "status",	 /* F_STATUS */ 
+			   "exitcode",	 /* F_EXITCODE */
+			   "ntasks",	 /* F_NTASKS */
+			   "ncpus",	 /* F_STEPNCPUS */
+			   "elapsed",	 /* F_ELAPSED */
+			   "cpu_sec",	 /* F_CPU_SEC */
+			   "cpu_usec",	 /* F_CPU_USEC */
+			   "user_sec",	 /* F_USER_SEC */
+			   "user_usec",	 /* F_USER_USEC */
+			   "sys_sec",	 /* F_SYS_SEC */
+			   "sys_usec",	 /* F_SYS_USEC */
+			   "rss",	 /* F_RSS */
+			   "ixrss",	 /* F_IXRSS */
+			   "idrss",	 /* F_IDRSS */
+			   "isrss",	 /* F_ISRSS */
+			   "minflt",	 /* F_MINFLT */
+			   "majflt",	 /* F_MAJFLT */
+			   "nswap",	 /* F_NSWAP */
+			   "inblocks",	 /* F_INBLOCKS */
+			   "oublocks",	 /* F_OUTBLOCKS */
+			   "msgsnd",	 /* F_MSGSND */
+			   "msgrcv",	 /* F_MSGRCV */
+			   "nsignals",	 /* F_NSIGNALS */
+			   "nvcsw",	 /* F_VCSW */
+			   "nivcsw",	 /* F_NIVCSW */
+			   "max_vsize",	 /* F_MAX_VSIZE */
+			   "max_vsize_task",	 /* F_MAX_VSIZE_TASK */
+			   "ave_vsize",	 /* F_AVE_VSIZE */
+			   "max_rss",	 /* F_MAX_RSS */
+			   "max_rss_task",	 /* F_MAX_RSS_TASK */
+			   "ave_rss",	 /* F_AVE_RSS */
+			   "max_pages",	 /* F_MAX_PAGES */
+			   "max_pages_task",	 /* F_MAX_PAGES_TASK */
+			   "ave_pages",	 /* F_AVE_PAGES */
+			   "min_cputime",	 /* F_MIN_CPU */
+			   "min_cputime_task",	 /* F_MIN_CPU_TASK */
+			   "ave_cputime",	 /* F_AVE_RSS */
+			   "StepName",	 /* F_STEPNAME */
+			   "StepNodes",	 /* F_STEPNODES */
+			   "max_vsize_node",	 /* F_MAX_VSIZE_NODE */
+			   "max_rss_node",	 /* F_MAX_RSS_NODE */
+			   "max_pages_node",	 /* F_MAX_PAGES_NODE */
+			   "min_cputime_node",	 /* F_MIN_CPU_NODE */
+			   "account",    /* F_STEP_ACCOUNT */
+			   "requid",     /* F_STEP_REQUID */
+			   NULL};
+       
+	char	*suspend[] = {"Suspend/Run time", /* F_TOT_ELAPSED */
+			      "status",	 /* F_STATUS */ 
+			      NULL};	 
+
+	char	*term[] = {"totElapsed", /* F_TOT_ELAPSED */
+			   "status",	 /* F_STATUS */ 
+			   "requid",     /* F_JOB_REQUID */
+			   "exitcode",	 /* F_EXITCODE */
+			   NULL};	 
+		
+	i = atoi(f[F_RECTYPE]);
+	printf("\n------- Line %d %s -------\n", lc, _convert_type(i));
+
+	for(j=0; j < HEADER_LENGTH; j++) 
+		printf("%12s: %s\n", header[j], f[j]);
+	switch(i) {
+	case JOB_START:
+		type = start;
+		j = JOB_START_LENGTH;
+		break;
+	case JOB_STEP:
+		type = step;
+		j = JOB_STEP_LENGTH;
+		break;
+	case JOB_SUSPEND:
+		type = suspend;
+		j = JOB_TERM_LENGTH;
+	case JOB_TERMINATED:
+		type = term;
+		j = JOB_TERM_LENGTH;
+		break;
+	default:
+		while(f[j]) {
+			printf("      Field[%02d]: %s\n", j, f[j]); 
+			j++;
+		}
+		return;
+	}
+	
+	for(i=HEADER_LENGTH; i < j; i++)
+       		printf("%12s: %s\n", type[i-HEADER_LENGTH], f[i]);	
+}
+
+static filetxt_job_rec_t *_find_job_record(List job_list, 
+					   filetxt_header_t header,
+					   int type)
+{
+	filetxt_job_rec_t *job = NULL;
+	ListIterator itr = list_iterator_create(job_list);
+
+	while((job = (filetxt_job_rec_t *)list_next(itr)) != NULL) {
+		if (job->header.jobnum == header.jobnum) {
+			if(job->header.job_submit == 0 && type == JOB_START) {
+				list_remove(itr);
+				_destroy_filetxt_job_rec(job);
+				job = NULL;
+				break;
+			}
+		
+			if(job->header.job_submit == BATCH_JOB_TIMESTAMP) {
+				job->header.job_submit = header.job_submit;
+				break;
+			}
+			
+			if(job->header.job_submit == header.job_submit)
+				break;
+			else {
+				/* If we're looking for a later
+				 * record with this job number, we
+				 * know that this one is an older,
+				 * duplicate record.
+				 *   We assume that the newer record
+				 * will be created if it doesn't
+				 * already exist. */
+				job->jobnum_superseded = 1;
+			}
+		}
+	}
+	list_iterator_destroy(itr);
+	return job;
+}
+
+static int _remove_job_record(List job_list, uint32_t jobnum)
+{
+	filetxt_job_rec_t *job = NULL;
+	int rc = SLURM_ERROR;
+	ListIterator itr = list_iterator_create(job_list);
+
+	while((job = (filetxt_job_rec_t *)list_next(itr)) != NULL) {
+		if (job->header.jobnum == jobnum) {
+			list_remove(itr);
+			_destroy_filetxt_job_rec(job);
+			rc = SLURM_SUCCESS;
+		}
+	}
+	list_iterator_destroy(itr);
+	return rc;
+}
+
+static filetxt_step_rec_t *_find_step_record(filetxt_job_rec_t *job,
+					     long stepnum)
+{
+	filetxt_step_rec_t *step = NULL;
+	ListIterator itr = NULL;
+
+	if(!list_count(job->steps))
+		return step;
+	
+	itr = list_iterator_create(job->steps);
+	while((step = (filetxt_step_rec_t *)list_next(itr)) != NULL) {
+		if (step->stepnum == stepnum)
+			break;
+	}
+	list_iterator_destroy(itr);
+	return step;
+}
+
+static int _parse_header(char *f[], filetxt_header_t *header)
+{
+	header->jobnum = atoi(f[F_JOB]);
+	header->partition = xstrdup(f[F_PARTITION]);
+	header->job_submit = atoi(f[F_JOB_SUBMIT]);
+	header->timestamp = atoi(f[F_TIMESTAMP]);
+	header->uid = atoi(f[F_UID]);
+	header->gid = atoi(f[F_GID]);
+	header->blockid = xstrdup(f[F_BLOCKID]);
+
+	return SLURM_SUCCESS;
+}
+
+static int _parse_line(char *f[], void **data, int len)
+{
+	int i = atoi(f[F_RECTYPE]);
+	filetxt_job_rec_t **job = (filetxt_job_rec_t **)data;
+	filetxt_step_rec_t **step = (filetxt_step_rec_t **)data;
+	filetxt_header_t header;
+	_parse_header(f, &header);
+		
+	switch(i) {
+	case JOB_START:
+		*job = _create_filetxt_job_rec(header);
+		(*job)->jobname = xstrdup(f[F_JOBNAME]);
+		(*job)->track_steps = atoi(f[F_TRACK_STEPS]);
+		(*job)->priority = atoi(f[F_PRIORITY]);
+		(*job)->ncpus = atoi(f[F_NCPUS]);
+		(*job)->nodes = xstrdup(f[F_NODES]);
+		for (i=0; (*job)->nodes[i]; i++) { /* discard trailing <CR> */
+			if (isspace((*job)->nodes[i]))
+				(*job)->nodes[i] = '\0';
+		}
+		if (!strcmp((*job)->nodes, "(null)")) {
+			xfree((*job)->nodes);
+			(*job)->nodes = xstrdup("(unknown)");
+		}
+		if (len > F_JOB_ACCOUNT) {
+			(*job)->account = xstrdup(f[F_JOB_ACCOUNT]);
+			for (i=0; (*job)->account[i]; i++) {
+				/* discard trailing <CR> */
+				if (isspace((*job)->account[i]))
+					(*job)->account[i] = '\0';
+			}
+		}
+		break;
+	case JOB_STEP:
+		*step = _create_filetxt_step_rec(header);
+		(*step)->stepnum = atoi(f[F_JOBSTEP]);
+		(*step)->status = atoi(f[F_STATUS]);
+		(*step)->exitcode = atoi(f[F_EXITCODE]);
+		(*step)->ntasks = atoi(f[F_NTASKS]);
+		(*step)->ncpus = atoi(f[F_STEPNCPUS]);
+		(*step)->elapsed = atoi(f[F_ELAPSED]);
+		(*step)->tot_cpu_sec = atoi(f[F_CPU_SEC]);
+		(*step)->tot_cpu_usec = atoi(f[F_CPU_USEC]);
+		(*step)->rusage.ru_utime.tv_sec = atoi(f[F_USER_SEC]);
+		(*step)->rusage.ru_utime.tv_usec = atoi(f[F_USER_USEC]);
+		(*step)->rusage.ru_stime.tv_sec = atoi(f[F_SYS_SEC]);
+		(*step)->rusage.ru_stime.tv_usec = atoi(f[F_SYS_USEC]);
+		(*step)->rusage.ru_maxrss = atoi(f[F_RSS]);
+		(*step)->rusage.ru_ixrss = atoi(f[F_IXRSS]);
+		(*step)->rusage.ru_idrss = atoi(f[F_IDRSS]);
+		(*step)->rusage.ru_isrss = atoi(f[F_ISRSS]);
+		(*step)->rusage.ru_minflt = atoi(f[F_MINFLT]);
+		(*step)->rusage.ru_majflt = atoi(f[F_MAJFLT]);
+		(*step)->rusage.ru_nswap = atoi(f[F_NSWAP]);
+		(*step)->rusage.ru_inblock = atoi(f[F_INBLOCKS]);
+		(*step)->rusage.ru_oublock = atoi(f[F_OUBLOCKS]);
+		(*step)->rusage.ru_msgsnd = atoi(f[F_MSGSND]);
+		(*step)->rusage.ru_msgrcv = atoi(f[F_MSGRCV]);
+		(*step)->rusage.ru_nsignals = atoi(f[F_NSIGNALS]);
+		(*step)->rusage.ru_nvcsw = atoi(f[F_NVCSW]);
+		(*step)->rusage.ru_nivcsw = atoi(f[F_NIVCSW]);
+		(*step)->sacct.max_vsize = atoi(f[F_MAX_VSIZE]) * 1024;
+		if(len > F_STEPNODES) {
+			(*step)->sacct.max_vsize_id.taskid = 
+				atoi(f[F_MAX_VSIZE_TASK]);
+			(*step)->sacct.ave_vsize = atof(f[F_AVE_VSIZE]) * 1024;
+			(*step)->sacct.max_rss = atoi(f[F_MAX_RSS]) * 1024;
+			(*step)->sacct.max_rss_id.taskid = 
+				atoi(f[F_MAX_RSS_TASK]);
+			(*step)->sacct.ave_rss = atof(f[F_AVE_RSS]) * 1024;
+			(*step)->sacct.max_pages = atoi(f[F_MAX_PAGES]);
+			(*step)->sacct.max_pages_id.taskid = 
+				atoi(f[F_MAX_PAGES_TASK]);
+			(*step)->sacct.ave_pages = atof(f[F_AVE_PAGES]);
+			(*step)->sacct.min_cpu = atof(f[F_MIN_CPU]);
+			(*step)->sacct.min_cpu_id.taskid = 
+				atoi(f[F_MIN_CPU_TASK]);
+			(*step)->sacct.ave_cpu = atof(f[F_AVE_CPU]);
+			(*step)->stepname = xstrdup(f[F_STEPNAME]);
+			(*step)->nodes = xstrdup(f[F_STEPNODES]);
+		} else {
+			(*step)->sacct.max_vsize_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_vsize = (float)NO_VAL;
+			(*step)->sacct.max_rss = (uint32_t)NO_VAL;
+			(*step)->sacct.max_rss_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_rss = (float)NO_VAL;
+			(*step)->sacct.max_pages = (uint32_t)NO_VAL;
+			(*step)->sacct.max_pages_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_pages = (float)NO_VAL;
+			(*step)->sacct.min_cpu = (uint32_t)NO_VAL;
+			(*step)->sacct.min_cpu_id.taskid = (uint16_t)NO_VAL;
+			(*step)->sacct.ave_cpu =  (float)NO_VAL;
+			(*step)->stepname = NULL;
+			(*step)->nodes = NULL;
+		}
+		if(len > F_MIN_CPU_NODE) {
+			(*step)->sacct.max_vsize_id.nodeid = 
+				atoi(f[F_MAX_VSIZE_NODE]);
+			(*step)->sacct.max_rss_id.nodeid = 
+				atoi(f[F_MAX_RSS_NODE]);
+			(*step)->sacct.max_pages_id.nodeid = 
+				atoi(f[F_MAX_PAGES_NODE]);
+			(*step)->sacct.min_cpu_id.nodeid = 
+				atoi(f[F_MIN_CPU_NODE]);
+		} else {
+			(*step)->sacct.max_vsize_id.nodeid = 
+				(uint32_t)NO_VAL;
+			(*step)->sacct.max_rss_id.nodeid = 
+				(uint32_t)NO_VAL;
+			(*step)->sacct.max_pages_id.nodeid = 
+				(uint32_t)NO_VAL;
+			(*step)->sacct.min_cpu_id.nodeid = 
+				(uint32_t)NO_VAL;
+		}
+		if(len > F_STEP_ACCOUNT)
+			(*step)->account = xstrdup(f[F_STEP_ACCOUNT]);
+		if(len > F_STEP_REQUID)
+			(*step)->requid = atoi(f[F_STEP_REQUID]);
+		break;
+	case JOB_SUSPEND:
+	case JOB_TERMINATED:
+		*job = _create_filetxt_job_rec(header);
+		(*job)->elapsed = atoi(f[F_TOT_ELAPSED]);
+		(*job)->status = atoi(f[F_STATUS]);		
+		if(len > F_JOB_REQUID) 
+			(*job)->requid = atoi(f[F_JOB_REQUID]);
+		if(len > F_JOB_EXITCODE) 
+			(*job)->exitcode = atoi(f[F_JOB_EXITCODE]);
+		break;
+	default:
+		printf("UNKOWN TYPE %d",i);
+		break;
+	}
+	return SLURM_SUCCESS;
+}
+
+static void _process_start(List job_list, char *f[], int lc,
+			   int show_full, int len)
+{
+	filetxt_job_rec_t *job = NULL;
+	filetxt_job_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+	job = _find_job_record(job_list, temp->header, JOB_START);
+	if (job) {	/* Hmmm... that's odd */
+		printf("job->header.job_submit = %d",
+		       (int)job->header.job_submit);
+		if(job->header.job_submit == 0)
+			_remove_job_record(job_list, job->header.jobnum);
+		else {
+			fprintf(stderr,
+				"Conflicting JOB_START for job %u at"
+				" line %d -- ignoring it\n",
+				job->header.jobnum, lc);
+			_destroy_filetxt_job_rec(temp);
+			return;
+		}
+	}
+	
+	job = temp;
+	job->show_full = show_full;
+	list_append(job_list, job);
+	job->job_start_seen = 1;
+	
+}
+
+static void _process_step(List job_list, char *f[], int lc,
+			  int show_full, int len,
+			  sacct_parameters_t *params)
+{
+	filetxt_job_rec_t *job = NULL;
+	
+	filetxt_step_rec_t *step = NULL;
+	filetxt_step_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+
+	job = _find_job_record(job_list, temp->header, JOB_STEP);
+	
+	if (temp->stepnum == -2) {
+		_destroy_filetxt_step_rec(temp);
+		return;
+	}
+	if (!job) {	/* fake it for now */
+		job = _create_filetxt_job_rec(temp->header);
+		job->jobname = xstrdup("(unknown)");
+		if (params->opt_verbose > 1) 
+			fprintf(stderr, 
+				"Note: JOB_STEP record %u.%u preceded "
+				"JOB_START record at line %d\n",
+				temp->header.jobnum, temp->stepnum, lc);
+	}
+	job->show_full = show_full;
+	
+	if ((step = _find_step_record(job, temp->stepnum))) {
+		
+		if (temp->status == JOB_RUNNING) {
+			_destroy_filetxt_step_rec(temp);
+			return;/* if "R" record preceded by F or CD; unusual */
+		}
+		if (step->status != JOB_RUNNING) { /* if not JOB_RUNNING */
+			fprintf(stderr,
+				"Conflicting JOB_STEP record for "
+				"jobstep %u.%u at line %d "
+				"-- ignoring it\n",
+				step->header.jobnum, 
+				step->stepnum, lc);
+			_destroy_filetxt_step_rec(temp);
+			return;
+		}
+		step->status = temp->status;
+		step->exitcode = temp->exitcode;
+		step->ntasks = temp->ntasks;
+		step->ncpus = temp->ncpus;
+		step->elapsed = temp->elapsed;
+		step->tot_cpu_sec = temp->tot_cpu_sec;
+		step->tot_cpu_usec = temp->tot_cpu_usec;
+		job->requid = temp->requid;
+		step->requid = temp->requid;
+		memcpy(&step->rusage, &temp->rusage, sizeof(struct rusage));
+		memcpy(&step->sacct, &temp->sacct, sizeof(sacct_t));
+		xfree(step->stepname);
+		step->stepname = xstrdup(temp->stepname);
+		step->end = temp->header.timestamp;
+		_destroy_filetxt_step_rec(temp);
+		goto got_step;
+	}
+	step = temp;
+	temp = NULL;
+	list_append(job->steps, step);
+	if(list_count(job->steps) > 1)
+		job->track_steps = 1;
+	if(job->header.timestamp == 0)
+		job->header.timestamp = step->header.timestamp;
+	job->job_step_seen = 1;
+	job->ntasks += step->ntasks;
+	if(!job->nodes || !strcmp(job->nodes, "(unknown)")) {
+		xfree(job->nodes);
+		job->nodes = xstrdup(step->nodes);
+	}
+	
+got_step:
+	
+		
+	if (job->job_terminated_seen == 0) {	/* If the job is still running,
+						   this is the most recent
+						   status */
+		if ( job->exitcode == 0 )
+			job->exitcode = step->exitcode;
+		job->status = JOB_RUNNING;
+		job->elapsed = step->header.timestamp - job->header.timestamp;
+	}
+}
+
+static void _process_suspend(List job_list, char *f[], int lc,
+			     int show_full, int len)
+{
+	filetxt_job_rec_t *job = NULL;
+	filetxt_job_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+	job = _find_job_record(job_list, temp->header, JOB_SUSPEND);
+	if (!job)  {	/* fake it for now */
+		job = _create_filetxt_job_rec(temp->header);
+		job->jobname = xstrdup("(unknown)");
+	} 
+			
+	job->show_full = show_full;
+	if (job->status == JOB_SUSPENDED) 
+		job->elapsed -= temp->elapsed;
+
+	//job->header.timestamp = temp->header.timestamp;
+	job->status = temp->status;
+	_destroy_filetxt_job_rec(temp);
+}
+	
+static void _process_terminated(List job_list, char *f[], int lc,
+				int show_full, int len,
+				sacct_parameters_t *params)
+{
+	filetxt_job_rec_t *job = NULL;
+	filetxt_job_rec_t *temp = NULL;
+
+	_parse_line(f, (void **)&temp, len);
+	job = _find_job_record(job_list, temp->header, JOB_TERMINATED);
+	if (!job) {	/* fake it for now */
+		job = _create_filetxt_job_rec(temp->header);
+		job->jobname = xstrdup("(unknown)");
+		if (params->opt_verbose > 1) 
+			fprintf(stderr, "Note: JOB_TERMINATED record for job "
+				"%u preceded "
+				"other job records at line %d\n",
+				temp->header.jobnum, lc);
+	} else if (job->job_terminated_seen) {
+		if (temp->status == JOB_NODE_FAIL) {
+			/* multiple node failures - extra TERMINATED records */
+			if (params->opt_verbose > 1)
+				fprintf(stderr, 
+					"Note: Duplicate JOB_TERMINATED "
+					"record (nf) for job %u at "
+					"line %d\n", 
+					temp->header.jobnum, lc);
+			/* JOB_TERMINATED/NF records may be preceded
+			 * by a JOB_TERMINATED/CA record; NF is much
+			 * more interesting.
+			 */
+			job->status = temp->status;
+			goto finished;
+		}
+		
+		fprintf(stderr,
+			"Conflicting JOB_TERMINATED record (%s) for "
+			"job %u at line %d -- ignoring it\n",
+			job_state_string(temp->status), 
+			job->header.jobnum, lc);
+		goto finished;
+	}
+	job->job_terminated_seen = 1;
+	job->elapsed = temp->elapsed;
+	job->end = temp->header.timestamp;
+	job->status = temp->status;
+	job->requid = temp->requid;
+	job->exitcode = temp->exitcode;
+	if(list_count(job->steps) > 1)
+		job->track_steps = 1;
+	job->show_full = show_full;
+	
+finished:
+	_destroy_filetxt_job_rec(temp);
+}
+
+extern List filetxt_jobacct_process_get_jobs(List selected_steps,
+					     List selected_parts,
+					     sacct_parameters_t *params)
+{
+	char line[BUFFER_SIZE];
+	char *f[MAX_RECORD_FIELDS+1];    /* End list with null entry and,
+					    possibly, more data than we
+					    expected */
+	char *fptr;
+	int i;
+	FILE *fd = NULL;
+	int lc = 0;
+	int rec_type = -1;
+	filetxt_job_rec_t *filetxt_job = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	char *selected_part = NULL;
+	ListIterator itr = NULL;
+	int show_full = 0;
+	List ret_job_list = list_create(destroy_jobacct_job_rec);
+	List job_list = list_create(_destroy_filetxt_job_rec);
+
+	if(slurmdbd_conf) {
+		params->opt_filein = slurm_get_accounting_storage_loc();
+	}
+
+	fd = _open_log_file(params->opt_filein);
+	
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		lc++;
+		fptr = line;	/* break the record into NULL-
+				   terminated strings */
+		for (i = 0; i < MAX_RECORD_FIELDS; i++) {
+			f[i] = fptr;
+			fptr = strstr(fptr, " ");
+			if (fptr == NULL) {
+				fptr = strstr(f[i], "\n");
+				if (fptr)
+					*fptr = 0;
+				break; 
+			} else
+				*fptr++ = 0;
+		}
+		f[++i] = 0;
+		
+		if(i < HEADER_LENGTH) {
+			continue;
+		}
+		
+		rec_type = atoi(f[F_RECTYPE]);
+		
+		if (list_count(selected_steps)) {
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if (strcmp(selected_step->job, f[F_JOB]))
+					continue;
+				/* job matches; does the step? */
+				if(selected_step->step == NULL) {
+					show_full = 1;
+					list_iterator_destroy(itr);
+					goto foundjob;
+				} else if (rec_type != JOB_STEP 
+					   || !strcmp(f[F_JOBSTEP], 
+						      selected_step->step)) {
+					list_iterator_destroy(itr);
+					goto foundjob;
+				} 
+			}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		} else {
+			show_full = 1;
+		}
+	foundjob:
+		
+		if (list_count(selected_parts)) {
+			itr = list_iterator_create(selected_parts);
+			while((selected_part = list_next(itr))) 
+				if (!strcasecmp(f[F_PARTITION], 
+						selected_part)) {
+					list_iterator_destroy(itr);
+					goto foundp;
+				}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		}
+	foundp:
+		
+		if (params->opt_fdump) {
+			_do_fdump(f, lc);
+			continue;
+		}
+		
+		/* Build suitable tables with all the data */
+		switch(rec_type) {
+		case JOB_START:
+			if(i < F_JOB_ACCOUNT) {
+				printf("Bad data on a Job Start\n");
+				_show_rec(f);
+			} else 
+				_process_start(job_list, f, lc, show_full, i);
+			break;
+		case JOB_STEP:
+			if(i < F_MAX_VSIZE) {
+				printf("Bad data on a Step entry\n");
+				_show_rec(f);
+			} else
+				_process_step(job_list, f, lc, show_full, i, 
+					      params);
+			break;
+		case JOB_SUSPEND:
+			if(i < F_JOB_REQUID) {
+				printf("Bad data on a Suspend entry\n");
+				_show_rec(f);
+			} else
+				_process_suspend(job_list, f, lc,
+						 show_full, i);
+			break;
+		case JOB_TERMINATED:
+			if(i < F_JOB_REQUID) {
+				printf("Bad data on a Job Term\n");
+				_show_rec(f);
+			} else
+				_process_terminated(job_list, f, lc,
+						    show_full, i, params);
+			break;
+		default:
+			if (params->opt_verbose > 1)
+				fprintf(stderr,
+					"Invalid record at line %d of "
+					"input file\n",
+					lc);
+			if (params->opt_verbose > 2)
+				_show_rec(f);
+			break;
+		}
+	}
+	
+	if (ferror(fd)) {
+		perror(params->opt_filein);
+		exit(1);
+	} 
+	fclose(fd);
+
+	itr = list_iterator_create(job_list);
+	while((filetxt_job = list_next(itr))) {
+		list_append(ret_job_list, _create_jobacct_job_rec(filetxt_job));
+	}
+	list_iterator_destroy(itr);
+	list_destroy(job_list);
+
+	if(slurmdbd_conf) {
+		xfree(params->opt_filein);
+	}
+	return ret_job_list;
+}
+
+extern void filetxt_jobacct_process_archive(List selected_parts,
+					    sacct_parameters_t *params)
+{
+	char	line[BUFFER_SIZE],
+		*f[EXPIRE_READ_LENGTH],
+		*fptr = NULL,
+		*logfile_name = NULL,
+		*old_logfile_name = NULL;
+	int	file_err=0,
+		new_file,
+		i = 0;
+	expired_rec_t *exp_rec = NULL;
+	expired_rec_t *exp_rec2 = NULL;
+	List keep_list = list_create(_destroy_exp);
+	List exp_list = list_create(_destroy_exp);
+	List other_list = list_create(_destroy_exp);
+	struct	stat statbuf;
+	mode_t	prot = 0600;
+	uid_t	uid;
+	gid_t	gid;
+	FILE	*expired_logfile = NULL,
+		*new_logfile = NULL;
+	FILE *fd = NULL;
+	int lc=0;
+	int rec_type = -1;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	char *temp = NULL;
+
+	/* Figure out our expiration date */
+	time_t		expiry;
+
+	if(slurmdbd_conf) {
+		params->opt_filein = slurm_get_accounting_storage_loc();
+	}
+
+	expiry = time(NULL)-params->opt_expire;
+	if (params->opt_verbose)
+		fprintf(stderr, "Purging jobs completed prior to %d\n",
+			(int)expiry);
+
+	/* Open the current or specified logfile, or quit */
+	fd = _open_log_file(params->opt_filein);
+	if (stat(params->opt_filein, &statbuf)) {
+		perror("stat'ing logfile");
+		goto finished;
+	}
+	if ((statbuf.st_mode & S_IFLNK) == S_IFLNK) {
+		fprintf(stderr, "%s is a symbolic link; --expire requires "
+			"a hard-linked file name\n", params->opt_filein);
+		goto finished;
+	}
+	if (!(statbuf.st_mode & S_IFREG)) {
+		fprintf(stderr, "%s is not a regular file; --expire "
+			"only works on accounting log files\n",
+			params->opt_filein);
+		goto finished;
+	}
+	prot = statbuf.st_mode & 0777;
+	gid  = statbuf.st_gid;
+	uid  = statbuf.st_uid;
+	old_logfile_name = _prefix_filename(params->opt_filein, ".old.");
+	if (stat(old_logfile_name, &statbuf)) {
+		if (errno != ENOENT) {
+			fprintf(stderr,"Error checking for %s: ",
+				old_logfile_name);
+			perror("");
+			goto finished;
+		}
+	} else {
+		fprintf(stderr, "Warning! %s exists -- please remove "
+			"or rename it before proceeding\n",
+			old_logfile_name);
+		goto finished;
+	}
+
+	/* create our initial buffer */
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		lc++;
+		fptr = line;	/* break the record into NULL-
+				   terminated strings */
+		exp_rec = xmalloc(sizeof(expired_rec_t));
+		exp_rec->line = xstrdup(line);
+	
+		for (i = 0; i < EXPIRE_READ_LENGTH; i++) {
+			f[i] = fptr;
+			fptr = strstr(fptr, " ");
+			if (fptr == NULL)
+				break; 
+			else
+				*fptr++ = 0;
+		}
+		
+		exp_rec->job = atoi(f[F_JOB]);
+		exp_rec->job_submit = atoi(f[F_JOB_SUBMIT]);
+		
+		rec_type = atoi(f[F_RECTYPE]);
+		/* Odd, but complain some other time */
+		if (rec_type == JOB_TERMINATED) {
+			if (expiry < atoi(f[F_TIMESTAMP])) {
+				list_append(keep_list, exp_rec);
+				continue;				
+			}
+			if (list_count(selected_parts)) {
+				itr = list_iterator_create(selected_parts);
+				while((temp = list_next(itr))) 
+					if(!strcasecmp(f[F_PARTITION], temp)) 
+						break;
+				list_iterator_destroy(itr);
+				if(!temp) {
+					list_append(keep_list, exp_rec);
+					continue;
+				} /* no match */
+			}
+			list_append(exp_list, exp_rec);
+			if (params->opt_verbose > 2)
+				fprintf(stderr, "Selected: %8d %d\n",
+					exp_rec->job,
+					(int)exp_rec->job_submit);
+		} else {
+			list_append(other_list, exp_rec);
+		}
+	}
+	if (!list_count(exp_list)) {
+		printf("No job records were purged.\n");
+		goto finished;
+	}
+	logfile_name = xmalloc(strlen(params->opt_filein)+sizeof(".expired"));
+	sprintf(logfile_name, "%s.expired", params->opt_filein);
+	new_file = stat(logfile_name, &statbuf);
+	if ((expired_logfile = fopen(logfile_name, "a"))==NULL) {
+		fprintf(stderr, "Error while opening %s", 
+			logfile_name);
+		perror("");
+		xfree(logfile_name);
+		goto finished;
+	}
+	
+	if (new_file) {  /* By default, the expired file looks like the log */
+		chmod(logfile_name, prot);
+		chown(logfile_name, uid, gid);
+	}
+	xfree(logfile_name);
+
+	logfile_name = _prefix_filename(params->opt_filein, ".new.");
+	if ((new_logfile = fopen(logfile_name, "w"))==NULL) {
+		fprintf(stderr, "Error while opening %s",
+			logfile_name);
+		perror("");
+		fclose(expired_logfile);
+		goto finished;
+	}
+	chmod(logfile_name, prot);     /* preserve file protection */
+	chown(logfile_name, uid, gid); /* and ownership */
+	/* Use line buffering to allow us to safely write
+	 * to the log file at the same time as slurmctld. */ 
+	if (setvbuf(new_logfile, NULL, _IOLBF, 0)) {
+		perror("setvbuf()");
+		fclose(expired_logfile);
+		goto finished2;
+	}
+
+	list_sort(exp_list, (ListCmpF) _cmp_jrec);
+	list_sort(keep_list, (ListCmpF) _cmp_jrec);
+	
+	if (params->opt_verbose > 2) {
+		fprintf(stderr, "--- contents of exp_list ---");
+		itr = list_iterator_create(exp_list);
+		while((exp_rec = list_next(itr))) {
+			if (!(i%5))
+				fprintf(stderr, "\n");
+			else
+				fprintf(stderr, "\t");
+			fprintf(stderr, "%d", exp_rec->job);
+		}
+		fprintf(stderr, "\n---- end of exp_list ---\n");
+		list_iterator_destroy(itr);
+	}
+	/* write the expired file */
+	itr = list_iterator_create(exp_list);
+	while((exp_rec = list_next(itr))) {
+		itr2 = list_iterator_create(other_list);
+		while((exp_rec2 = list_next(itr2))) {
+			if((exp_rec2->job != exp_rec->job) 
+			   || (exp_rec2->job_submit != exp_rec->job_submit))
+				continue;
+			if (fputs(exp_rec2->line, expired_logfile)<0) {
+				perror("writing expired_logfile");
+				list_iterator_destroy(itr2);
+				list_iterator_destroy(itr);
+				fclose(expired_logfile);
+				goto finished2;
+			}
+			list_remove(itr2);
+			_destroy_exp(exp_rec2);
+		}
+		list_iterator_destroy(itr2);
+		if (fputs(exp_rec->line, expired_logfile)<0) {
+			perror("writing expired_logfile");
+			list_iterator_destroy(itr);
+			fclose(expired_logfile);
+			goto finished2;
+		}		
+	}
+	list_iterator_destroy(itr);
+	fclose(expired_logfile);
+	
+	/* write the new log */
+	itr = list_iterator_create(keep_list);
+	while((exp_rec = list_next(itr))) {
+		itr2 = list_iterator_create(other_list);
+		while((exp_rec2 = list_next(itr2))) {
+			if(exp_rec2->job != exp_rec->job)
+				continue;
+			if (fputs(exp_rec2->line, new_logfile)<0) {
+				perror("writing keep_logfile");
+				list_iterator_destroy(itr2);
+				list_iterator_destroy(itr);
+				goto finished2;
+			}
+			list_remove(itr2);
+			_destroy_exp(exp_rec2);
+		}
+		list_iterator_destroy(itr2);
+		if (fputs(exp_rec->line, new_logfile)<0) {
+			perror("writing keep_logfile");
+			list_iterator_destroy(itr);
+			goto finished2;
+		}		
+	}
+	list_iterator_destroy(itr);
+	
+	if (rename(params->opt_filein, old_logfile_name)) {
+		perror("renaming logfile to .old.");
+		goto finished2;
+	}
+	if (rename(logfile_name, params->opt_filein)) {
+		perror("renaming new logfile");
+		/* undo it? */
+		if (!rename(old_logfile_name, params->opt_filein)) 
+			fprintf(stderr, "Please correct the problem "
+				"and try again");
+		else
+			fprintf(stderr, "SEVERE ERROR: Current accounting "
+				"log may have been renamed %s;\n"
+				"please rename it to \"%s\" if necessary, "
+			        "and try again\n",
+				old_logfile_name, params->opt_filein);
+		goto finished2;
+	}
+	fflush(new_logfile);	/* Flush the buffers before forking */
+	fflush(fd);
+
+	file_err = slurm_reconfigure();
+	if (file_err) {
+		file_err = 1;
+		fprintf(stderr, "Error: Attempt to reconfigure "
+			"SLURM failed.\n");
+		if (rename(old_logfile_name, params->opt_filein)) {
+			perror("renaming logfile from .old.");
+			goto finished2;
+		}
+
+	}
+	if (fseek(fd, 0, SEEK_CUR)) {	/* clear EOF */
+		perror("looking for late-arriving records");
+		goto finished2;
+	}
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		if (fputs(line, new_logfile)<0) {
+			perror("writing final records");
+			goto finished2;
+		}
+	}
+	
+	printf("%d jobs expired.\n", list_count(exp_list));
+finished2:
+	fclose(new_logfile);
+	if (!file_err) {
+		if (unlink(old_logfile_name) == -1)
+			error("Unable to unlink old logfile %s: %m",
+			      old_logfile_name);
+	}
+finished:
+	if(slurmdbd_conf) {
+		xfree(params->opt_filein);
+	}
+	fclose(fd);
+	list_destroy(exp_list);
+	list_destroy(keep_list);
+	list_destroy(other_list);
+	xfree(old_logfile_name);
+	xfree(logfile_name);
+}
diff --git a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.h b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..a5ba22deff7cbd5b5ad616764082da454a84dc19
--- /dev/null
+++ b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.h
@@ -0,0 +1,55 @@
+/*****************************************************************************\
+ *  filetxt_jobacct_process.h - functions the processing of
+ *                               information from the filetxt jobacct
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_FILETXT_JOBACCT_PROCESS_H
+#define _HAVE_FILETXT_JOBACCT_PROCESS_H
+
+#include "src/common/jobacct_common.h"
+#include "src/slurmdbd/read_config.h"
+
+extern List filetxt_jobacct_process_get_jobs(List selected_steps,
+					     List selected_parts,
+					     sacct_parameters_t *params);
+extern void filetxt_jobacct_process_archive(List selected_parts,
+					    sacct_parameters_t *params);
+
+#endif
diff --git a/src/plugins/accounting_storage/gold/Makefile.am b/src/plugins/accounting_storage/gold/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..cd5495140ef4bb55a18c410ba6b9d9bdedd74994
--- /dev/null
+++ b/src/plugins/accounting_storage/gold/Makefile.am
@@ -0,0 +1,31 @@
+# Makefile for accounting_storage/gold plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+if HAVE_OPENSSL
+gold_lib = accounting_storage_gold.la
+else
+gold_lib =
+endif
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = $(gold_lib)
+if HAVE_OPENSSL
+accounting_storage_gold_la_SOURCES = accounting_storage_gold.c
+accounting_storage_gold_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+
+# Add libcommon to provide some symbols that are not
+#  available in slurmctld (create_jobacct_job_rec)
+
+accounting_storage_gold_la_LIBADD  = \
+	$(top_builddir)/src/database/libslurm_gold.la	
+accounting_storage_gold_la_DEPENDENCIES = \
+	$(top_builddir)/src/database/libslurm_gold.la
+
+else
+EXTRA_accounting_storage_gold_la_SOURCES = accounting_storage_gold.c
+endif
+
diff --git a/src/plugins/accounting_storage/gold/Makefile.in b/src/plugins/accounting_storage/gold/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..c70269ee4b54c239cbc5f07eef324c36a502715f
--- /dev/null
+++ b/src/plugins/accounting_storage/gold/Makefile.in
@@ -0,0 +1,575 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for accounting_storage/gold plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/accounting_storage/gold
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__accounting_storage_gold_la_SOURCES_DIST =  \
+	accounting_storage_gold.c
+@HAVE_OPENSSL_TRUE@am_accounting_storage_gold_la_OBJECTS =  \
+@HAVE_OPENSSL_TRUE@	accounting_storage_gold.lo
+am__EXTRA_accounting_storage_gold_la_SOURCES_DIST =  \
+	accounting_storage_gold.c
+accounting_storage_gold_la_OBJECTS =  \
+	$(am_accounting_storage_gold_la_OBJECTS)
+accounting_storage_gold_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(AM_CFLAGS) $(CFLAGS) $(accounting_storage_gold_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+@HAVE_OPENSSL_TRUE@am_accounting_storage_gold_la_rpath = -rpath \
+@HAVE_OPENSSL_TRUE@	$(pkglibdir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(accounting_storage_gold_la_SOURCES) \
+	$(EXTRA_accounting_storage_gold_la_SOURCES)
+DIST_SOURCES = $(am__accounting_storage_gold_la_SOURCES_DIST) \
+	$(am__EXTRA_accounting_storage_gold_la_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+@HAVE_OPENSSL_FALSE@gold_lib = 
+@HAVE_OPENSSL_TRUE@gold_lib = accounting_storage_gold.la
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = $(gold_lib)
+@HAVE_OPENSSL_TRUE@accounting_storage_gold_la_SOURCES = accounting_storage_gold.c
+@HAVE_OPENSSL_TRUE@accounting_storage_gold_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+
+# Add libcommon to provide some symbols that are not
+#  available in slurmctld (create_jobacct_job_rec)
+@HAVE_OPENSSL_TRUE@accounting_storage_gold_la_LIBADD = \
+@HAVE_OPENSSL_TRUE@	$(top_builddir)/src/database/libslurm_gold.la	
+
+@HAVE_OPENSSL_TRUE@accounting_storage_gold_la_DEPENDENCIES = \
+@HAVE_OPENSSL_TRUE@	$(top_builddir)/src/database/libslurm_gold.la
+
+@HAVE_OPENSSL_FALSE@EXTRA_accounting_storage_gold_la_SOURCES = accounting_storage_gold.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/accounting_storage/gold/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/accounting_storage/gold/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+accounting_storage_gold.la: $(accounting_storage_gold_la_OBJECTS) $(accounting_storage_gold_la_DEPENDENCIES) 
+	$(accounting_storage_gold_la_LINK) $(am_accounting_storage_gold_la_rpath) $(accounting_storage_gold_la_OBJECTS) $(accounting_storage_gold_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_gold.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/accounting_storage/gold/accounting_storage_gold.c b/src/plugins/accounting_storage/gold/accounting_storage_gold.c
new file mode 100644
index 0000000000000000000000000000000000000000..1697520cdedaa08710828d1737ec7664b98a9372
--- /dev/null
+++ b/src/plugins/accounting_storage/gold/accounting_storage_gold.c
@@ -0,0 +1,3259 @@
+/*****************************************************************************\
+ *  accounting_storage_gold.c - accounting interface to gold.
+ *
+ *  $Id: accounting_gold.c 13061 2008-01-22 21:23:56Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/stat.h>
+#include <pwd.h>
+
+
+#include "src/common/xmalloc.h"
+#include "src/common/list.h"
+#include "src/common/xstring.h"
+#include "src/common/uid.h"
+#include <src/common/parse_time.h>
+
+#include "src/slurmctld/slurmctld.h"
+#include "src/slurmd/slurmd/slurmd.h"
+#include "src/slurmdbd/read_config.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/jobacct_common.h"
+
+#include "src/database/gold_interface.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Accounting storage GOLD plugin";
+const char plugin_type[] = "accounting_storage/gold";
+const uint32_t plugin_version = 100;
+
+static List local_association_list = NULL;
+
+static int _add_edit_job(struct job_record *job_ptr, gold_object_t action);
+static int _check_for_job(uint32_t jobid, time_t submit);
+static List _get_association_list_from_response(gold_response_t *gold_response);
+/* static int _get_cluster_accounting_list_from_response( */
+/* 	gold_response_t *gold_response,  */
+/* 	acct_cluster_rec_t *cluster_rec); */
+/* static int _get_acct_accounting_list_from_response( */
+/* 	gold_response_t *gold_response, */
+/* 	acct_association_rec_t *account_rec); */
+static List _get_user_list_from_response(gold_response_t *gold_response);
+static List _get_acct_list_from_response(gold_response_t *gold_response);
+static List _get_cluster_list_from_response(gold_response_t *gold_response);
+static int _remove_association_accounting(List id_list);
+
+
+static int _add_edit_job(struct job_record *job_ptr, gold_object_t action)
+{
+	gold_request_t *gold_request = create_gold_request(GOLD_OBJECT_JOB,
+							   action);
+	gold_response_t *gold_response = NULL;
+	char tmp_buff[50];
+	int rc = SLURM_ERROR;
+	char *jname = NULL;
+	char *nodes = "(null)";
+
+	if(!gold_request) 
+		return rc;
+
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	
+	
+//info("total procs is  %d", job_ptr->total_procs);
+	if(action == GOLD_ACTION_CREATE) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u", job_ptr->job_id);
+		gold_request_add_assignment(gold_request, "JobId", tmp_buff);
+		
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 (int)job_ptr->details->submit_time);
+		gold_request_add_assignment(gold_request, "SubmitTime",
+					    tmp_buff);
+	} else if (action == GOLD_ACTION_MODIFY) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u", job_ptr->job_id);
+		gold_request_add_condition(gold_request, "JobId", tmp_buff,
+					   GOLD_OPERATOR_NONE, 0);
+		
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 (int)job_ptr->details->submit_time);
+		gold_request_add_condition(gold_request, "SubmitTime",
+					   tmp_buff,
+					   GOLD_OPERATOR_NONE, 0);
+	} else {
+		destroy_gold_request(gold_request);
+		error("_add_edit_job: bad action given %d", action);		
+		return rc;
+	}
+
+	if (job_ptr->name && job_ptr->name[0]) {
+		int i;
+		jname = xmalloc(strlen(job_ptr->name) + 1);
+		for (i=0; job_ptr->name[i]; i++) {
+			if (isalnum(job_ptr->name[i]))
+				jname[i] = job_ptr->name[i];
+			else
+				jname[i] = '_';
+		}
+	} else
+		jname = xstrdup("allocation");
+
+	gold_request_add_assignment(gold_request, "JobName", jname);
+	xfree(jname);
+	
+	gold_request_add_assignment(gold_request, "Partition",
+				    job_ptr->partition);
+	
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+		 job_ptr->total_procs);
+	gold_request_add_assignment(gold_request, "RequestedCPUCount",
+				    tmp_buff);
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+		 job_ptr->total_procs);
+	gold_request_add_assignment(gold_request, "AllocatedCPUCount",
+				    tmp_buff);
+	
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+		 (int)job_ptr->details->begin_time);
+	gold_request_add_assignment(gold_request, "EligibleTime",
+				    tmp_buff);
+
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u", job_ptr->assoc_id);
+	gold_request_add_assignment(gold_request, "GoldAccountId", tmp_buff);
+
+	gold_request_add_assignment(gold_request, "NodeList", nodes);
+
+	if(job_ptr->job_state >= JOB_COMPLETE) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 (int)job_ptr->end_time);
+		gold_request_add_assignment(gold_request, "EndTime",
+					    tmp_buff);		
+		
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 (int)job_ptr->exit_code);
+		gold_request_add_assignment(gold_request, "ExitCode",
+					    tmp_buff);
+	}
+
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+		 (int)job_ptr->start_time);
+	gold_request_add_assignment(gold_request, "StartTime", tmp_buff);
+		
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+		 job_ptr->job_state & (~JOB_COMPLETING));
+	gold_request_add_assignment(gold_request, "State", tmp_buff);	
+
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("_add_edit_job: no response received");
+		return rc;
+	}
+
+	if(!gold_response->rc) 
+		rc = SLURM_SUCCESS;
+	else {
+		if(gold_response->rc == 720)
+			error("gold_response has non-zero rc(%d): "
+			      "NOT PRINTING MESSAGE: this was a parser error",
+			      gold_response->rc);
+		else
+			error("gold_response has non-zero rc(%d): %s",
+			      gold_response->rc,
+			      gold_response->message);
+		errno = gold_response->rc;
+	}
+	destroy_gold_response(gold_response);
+
+	return rc;
+}
+
+static int _check_for_job(uint32_t jobid, time_t submit) 
+{
+	gold_request_t *gold_request = create_gold_request(GOLD_OBJECT_JOB,
+							   GOLD_ACTION_QUERY);
+	gold_response_t *gold_response = NULL;
+	char tmp_buff[50];
+	int rc = 0;
+
+	if(!gold_request) 
+		return rc;
+
+	gold_request_add_selection(gold_request, "JobId");
+
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u", jobid);
+	gold_request_add_condition(gold_request, "JobId", tmp_buff,
+				   GOLD_OPERATOR_NONE, 0);
+
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)submit);
+	gold_request_add_condition(gold_request, "SubmitTime", tmp_buff,
+				   GOLD_OPERATOR_NONE, 0);
+
+	gold_response = get_gold_response(gold_request);
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("_check_for_job: no response received");
+		return 0;
+	}
+
+	if(gold_response->entry_cnt > 0) 
+		rc = 1;
+	destroy_gold_response(gold_response);
+	
+	return rc;
+}
+
+static List _get_association_list_from_response(gold_response_t *gold_response)
+{
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	List association_list = NULL;
+	acct_association_rec_t *acct_rec = NULL;
+	gold_response_entry_t *resp_entry = NULL;
+	gold_name_value_t *name_val = NULL;
+	
+	association_list = list_create(destroy_acct_association_rec);
+	
+	itr = list_iterator_create(gold_response->entries);
+	while((resp_entry = list_next(itr))) {
+		acct_rec = xmalloc(sizeof(acct_association_rec_t));
+
+		itr2 = list_iterator_create(resp_entry->name_val);
+		while((name_val = list_next(itr2))) {
+			if(!strcmp(name_val->name, "Id")) {
+				acct_rec->id = 
+					atoi(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "FairShare")) {
+				acct_rec->fairshare = 
+					atoi(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "MaxJobs")) {
+				acct_rec->max_jobs = 
+					atoi(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "MaxNodesPerJob")) {
+				acct_rec->max_nodes_per_job = 
+					atoi(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "MaxWallDurationPerJob")) {
+				acct_rec->max_wall_duration_per_job = 
+					atoi(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "MaxProcSecondsPerJob")) {
+				acct_rec->max_cpu_secs_per_job = 
+					atoi(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "User")) {
+				if(strcmp(name_val->name, "NONE"))
+					acct_rec->user = 
+						xstrdup(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "Project")) {
+				acct_rec->acct = 
+					xstrdup(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "Machine")) {
+				acct_rec->cluster = 
+					xstrdup(name_val->value);
+			} else {
+				error("Unknown name val of '%s' = '%s'",
+				      name_val->name, name_val->value);
+			}
+		}
+		list_iterator_destroy(itr2);
+		list_append(association_list, acct_rec);
+	}
+	list_iterator_destroy(itr);
+
+	return association_list;
+}
+
+/* static int _get_cluster_accounting_list_from_response( */
+/* 	gold_response_t *gold_response, */
+/* 	acct_cluster_rec_t *cluster_rec) */
+/* { */
+/* 	ListIterator itr = NULL; */
+/* 	ListIterator itr2 = NULL; */
+/* 	cluster_accounting_rec_t *clusteracct_rec = NULL; */
+/* 	gold_response_entry_t *resp_entry = NULL; */
+/* 	gold_name_value_t *name_val = NULL; */
+	
+/* 	if(gold_response->entry_cnt <= 0) { */
+/* 		debug2("_get_list_from_response: No entries given"); */
+/* 		return SLURM_ERROR; */
+/* 	} */
+/* 	if(!cluster_rec->accounting_list) */
+/* 		cluster_rec->accounting_list =  */
+/* 			list_create(destroy_cluster_accounting_rec); */
+	
+/* 	itr = list_iterator_create(gold_response->entries); */
+/* 	while((resp_entry = list_next(itr))) { */
+/* 		clusteracct_rec = xmalloc(sizeof(cluster_accounting_rec_t)); */
+/* 		itr2 = list_iterator_create(resp_entry->name_val); */
+/* 		while((name_val = list_next(itr2))) { */
+/* 			if(!strcmp(name_val->name, "CPUCount")) { */
+/* 				clusteracct_rec->cpu_count =  */
+/* 					atoi(name_val->value); */
+/* 			} else if(!strcmp(name_val->name,  */
+/* 					  "PeriodStart")) { */
+/* 				clusteracct_rec->period_start =  */
+/* 					atoi(name_val->value); */
+/* 			} else if(!strcmp(name_val->name,  */
+/* 					  "IdleCPUSeconds")) { */
+/* 				clusteracct_rec->idle_secs =  */
+/* 					atoi(name_val->value); */
+/* 			} else if(!strcmp(name_val->name,  */
+/* 					  "DownCPUSeconds")) { */
+/* 				clusteracct_rec->down_secs =  */
+/* 					atoi(name_val->value); */
+/* 			} else if(!strcmp(name_val->name,  */
+/* 					  "AllocatedCPUSeconds")) { */
+/* 				clusteracct_rec->alloc_secs =  */
+/* 					atoi(name_val->value); */
+/* 			} else if(!strcmp(name_val->name,  */
+/* 					  "ReservedCPUSeconds")) { */
+/* 				clusteracct_rec->resv_secs =  */
+/* 					atoi(name_val->value); */
+/* 			} else { */
+/* 				error("Unknown name val of '%s' = '%s'", */
+/* 				      name_val->name, name_val->value); */
+/* 			} */
+/* 		} */
+/* 		list_iterator_destroy(itr2); */
+/* 		list_append(cluster_rec->accounting_list, clusteracct_rec); */
+/* 	} */
+/* 	list_iterator_destroy(itr); */
+
+/* 	return SLURM_SUCCESS; */
+/* } */
+
+/* static int _get_acct_accounting_list_from_response( */
+/* 	gold_response_t *gold_response, */
+/* 	acct_association_rec_t *acct_rec) */
+/* { */
+/* 	ListIterator itr = NULL; */
+/* 	ListIterator itr2 = NULL; */
+/* 	acct_accounting_rec_t *accounting_rec = NULL; */
+/* 	gold_response_entry_t *resp_entry = NULL; */
+/* 	gold_name_value_t *name_val = NULL; */
+	
+/* 	if(!acct_rec->accounting_list) */
+/* 		acct_rec->accounting_list = */
+/* 			list_create(destroy_acct_accounting_rec); */
+	
+/* 	itr = list_iterator_create(gold_response->entries); */
+/* 	while((resp_entry = list_next(itr))) { */
+/* 		accounting_rec = xmalloc(sizeof(acct_accounting_rec_t)); */
+
+/* 		itr2 = list_iterator_create(resp_entry->name_val); */
+/* 		while((name_val = list_next(itr2))) { */
+/* 			if(!strcmp(name_val->name, "PeriodStart")) { */
+/* 				accounting_rec->period_start =  */
+/* 					atoi(name_val->value); */
+/* 			} else if(!strcmp(name_val->name, */
+/* 					  "AllocatedCPUSeconds")) { */
+/* 				accounting_rec->alloc_secs =  */
+/* 					atoi(name_val->value); */
+/* 			} else { */
+/* 				error("Unknown name val of '%s' = '%s'", */
+/* 				      name_val->name, name_val->value); */
+/* 			} */
+/* 		} */
+/* 		list_iterator_destroy(itr2); */
+/* 		list_append(acct_rec->accounting_list, accounting_rec); */
+/* 	} */
+/* 	list_iterator_destroy(itr); */
+
+/* 	return SLURM_SUCCESS; */
+	
+/* } */
+
+static List _get_user_list_from_response(gold_response_t *gold_response)
+{
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	List user_list = NULL;
+	acct_user_rec_t *user_rec = NULL;
+	gold_response_entry_t *resp_entry = NULL;
+	gold_name_value_t *name_val = NULL;
+	
+	user_list = list_create(destroy_acct_user_rec);
+	
+	itr = list_iterator_create(gold_response->entries);
+	while((resp_entry = list_next(itr))) {
+		user_rec = xmalloc(sizeof(acct_user_rec_t));
+
+		itr2 = list_iterator_create(resp_entry->name_val);
+		while((name_val = list_next(itr2))) {
+			if(!strcmp(name_val->name, "Name")) {
+				user_rec->name = 
+					xstrdup(name_val->value);
+			} else if(!strcmp(name_val->name, "Expedite")) {
+				user_rec->qos = 
+					atoi(name_val->value)+1;
+			} else if(!strcmp(name_val->name, "DefaultProject")) {
+				user_rec->default_acct = 
+					xstrdup(name_val->value);
+			} else {
+				error("Unknown name val of '%s' = '%s'",
+				      name_val->name, name_val->value);
+			}
+		}
+		list_iterator_destroy(itr2);
+		list_append(user_list, user_rec);
+	}
+	list_iterator_destroy(itr);
+
+	return user_list;
+}
+
+static List _get_acct_list_from_response(gold_response_t *gold_response)
+{
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	List acct_list = NULL;
+	acct_account_rec_t *acct_rec = NULL;
+	gold_response_entry_t *resp_entry = NULL;
+	gold_name_value_t *name_val = NULL;
+	
+	acct_list = list_create(destroy_acct_account_rec);
+	
+	itr = list_iterator_create(gold_response->entries);
+	while((resp_entry = list_next(itr))) {
+		acct_rec = xmalloc(sizeof(acct_account_rec_t));
+
+		itr2 = list_iterator_create(resp_entry->name_val);
+		while((name_val = list_next(itr2))) {
+			if(!strcmp(name_val->name, "Expedite")) {
+				acct_rec->qos = 
+					atoi(name_val->value)+1;
+			} else if(!strcmp(name_val->name, 
+					  "Name")) {
+				acct_rec->name = 
+					xstrdup(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "Organization")) {
+				acct_rec->organization = 
+					xstrdup(name_val->value);
+			} else if(!strcmp(name_val->name, 
+					  "Description")) {
+				acct_rec->description = 
+					xstrdup(name_val->value);
+			} else {
+				error("Unknown name val of '%s' = '%s'",
+				      name_val->name, name_val->value);
+			}
+		}
+		list_iterator_destroy(itr2);
+		list_append(acct_list, acct_rec);
+	}
+	list_iterator_destroy(itr);
+
+	return acct_list;
+}
+
+static List _get_cluster_list_from_response(gold_response_t *gold_response)
+{
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	List cluster_list = NULL;
+	acct_cluster_rec_t *cluster_rec = NULL;
+	gold_response_entry_t *resp_entry = NULL;
+	gold_name_value_t *name_val = NULL;
+	
+	cluster_list = list_create(destroy_acct_cluster_rec);
+	
+	itr = list_iterator_create(gold_response->entries);
+	while((resp_entry = list_next(itr))) {
+		cluster_rec = xmalloc(sizeof(acct_cluster_rec_t));
+
+		itr2 = list_iterator_create(resp_entry->name_val);
+		while((name_val = list_next(itr2))) {
+			if(!strcmp(name_val->name, 
+					  "Name")) {
+				cluster_rec->name = 
+					xstrdup(name_val->value);
+			} else {
+				error("Unknown name val of '%s' = '%s'",
+				      name_val->name, name_val->value);
+			}
+		}
+		list_iterator_destroy(itr2);
+		list_append(cluster_list, cluster_rec);
+	}
+	list_iterator_destroy(itr);
+
+	return cluster_list;
+}
+
+static int _remove_association_accounting(List id_list)
+{
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	int set = 0;
+	ListIterator itr = NULL;
+
+	gold_request = create_gold_request(GOLD_OBJECT_ACCT_HOUR_USAGE,
+					   GOLD_ACTION_DELETE);
+	if(!gold_request) { 
+		error("couldn't create gold_request");
+		rc = SLURM_ERROR;
+		return rc;
+	}
+	
+	if(id_list && list_count(id_list)) {
+		itr = list_iterator_create(id_list);
+		if(list_count(id_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Acct",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+			       
+	gold_response = get_gold_response(gold_request);	
+
+	if(!gold_response) {
+		error("acct_storage_p_modify_associations: "
+		      "no response received");
+		destroy_gold_request(gold_request);
+		rc = SLURM_ERROR;
+		return rc;
+	}
+		
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		destroy_gold_request(gold_request);
+		destroy_gold_response(gold_response);
+		rc = SLURM_ERROR;
+		return rc;
+	}
+
+	destroy_gold_response(gold_response);
+
+	gold_request->object = GOLD_OBJECT_ACCT_DAY_USAGE;	
+	gold_response = get_gold_response(gold_request);	
+	
+	if(!gold_response) {
+		error("acct_storage_p_modify_associations: "
+		      "no response received");
+		destroy_gold_request(gold_request);
+		rc = SLURM_ERROR;
+		return rc;
+	}
+		
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		destroy_gold_request(gold_request);
+		destroy_gold_response(gold_response);
+		rc = SLURM_ERROR;
+		return rc;
+	}
+	destroy_gold_response(gold_response);
+	
+	gold_request->object = GOLD_OBJECT_ACCT_MONTH_USAGE;	
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+		
+	if(!gold_response) {
+		error("acct_storage_p_modify_associations: "
+		      "no response received");
+		destroy_gold_request(gold_request);
+		rc = SLURM_ERROR;
+		return rc;
+	}
+		
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		rc = SLURM_ERROR;
+	}
+
+	destroy_gold_response(gold_response);		
+
+
+	return rc; 
+}
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	char *keyfile = NULL;
+	char *host = NULL;
+	uint32_t port = 0;
+	struct	stat statbuf;
+
+	if(!(keyfile = slurm_get_accounting_storage_pass()) 
+	   || strlen(keyfile) < 1) {
+		keyfile = xstrdup("/etc/gold/auth_key");
+		debug2("No keyfile specified with AcctStoragePass, "
+		       "gold using default %s", keyfile);
+	}
+	
+
+	if(stat(keyfile, &statbuf)) {
+		fatal("Can't stat key file %s. "
+		      "To run acct_storage/gold you have to set "
+		      "your gold keyfile as "
+		      "AcctStoragePass in your slurm.conf", keyfile);
+	}
+
+
+	if(!(host = slurm_get_accounting_storage_host())) {
+		host = xstrdup("localhost");
+		debug2("No host specified with AcctStorageHost, "
+		       "gold using default %s", host);
+	}
+
+	if(!(port = slurm_get_accounting_storage_port())) {
+		port = 7112;
+		debug2("No port specified with AcctStoragePort, "
+		       "gold using default %u", port);
+	}
+
+	debug2("connecting to gold with keyfile='%s' for %s(%d)",
+	       keyfile, host, port);
+
+	init_gold(keyfile, host, port);
+
+	xfree(keyfile);
+	xfree(host);
+
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	if(local_association_list)
+		list_destroy(local_association_list);
+	fini_gold();
+	return SLURM_SUCCESS;
+}
+
+extern void * acct_storage_p_get_connection(bool make_agent, bool rollback)
+{
+	return NULL;
+}
+
+extern int acct_storage_p_close_connection(void **db_conn)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_commit(void *db_conn, bool commit)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_users(void *db_conn,
+				    List user_list)
+{
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	acct_user_rec_t *object = NULL;
+	char tmp_buff[50];
+
+	itr = list_iterator_create(user_list);
+	while((object = list_next(itr))) {
+		if(!object->name || !object->default_acct) {
+			error("We need a user name and "
+			      "default acct to add.");
+			rc = SLURM_ERROR;
+			continue;
+		}
+		gold_request = create_gold_request(GOLD_OBJECT_USER,
+						   GOLD_ACTION_CREATE);
+		if(!gold_request) { 
+			error("couldn't create gold_request");
+			rc = SLURM_ERROR;
+			break;
+		}
+		gold_request_add_assignment(gold_request, "Name",
+					    object->name);		
+		gold_request_add_assignment(gold_request, "DefaultProject",
+					    object->default_acct);		
+
+		if(object->qos != ACCT_QOS_NOTSET) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+				 object->qos-1);
+			gold_request_add_assignment(gold_request, "Expedite",
+						    tmp_buff);
+		}		
+		gold_response = get_gold_response(gold_request);	
+		destroy_gold_request(gold_request);
+
+		if(!gold_response) {
+			error("acct_storage_p_add_users: "
+			      "no response received");
+			rc = SLURM_ERROR;
+			break;
+		}
+		
+		if(gold_response->rc) {
+			error("gold_response has non-zero rc(%d): %s",
+			      gold_response->rc,
+			      gold_response->message);
+			errno = gold_response->rc;
+			destroy_gold_response(gold_response);
+			rc = SLURM_ERROR;
+			break;
+		}
+		destroy_gold_response(gold_response);		
+	}
+	list_iterator_destroy(itr);
+	
+	return rc;
+}
+
+extern int acct_storage_p_add_coord(void *db_conn,
+				    char *acct,
+				    acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_accts(void *db_conn,
+				    List acct_list)
+{
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	acct_account_rec_t *object = NULL;
+	char tmp_buff[50];
+
+	itr = list_iterator_create(acct_list);
+	while((object = list_next(itr))) {
+		if(!object->name || !object->description
+		   || !object->organization) {
+			error("We need a acct name, description, and "
+			      "organization to add one.");
+			rc = SLURM_ERROR;
+			continue;
+		}
+		gold_request = create_gold_request(GOLD_OBJECT_PROJECT,
+						   GOLD_ACTION_CREATE);
+		if(!gold_request) { 
+			error("couldn't create gold_request");
+			rc = SLURM_ERROR;
+			break;
+		}
+		gold_request_add_assignment(gold_request, "Name",
+					    object->name);		
+		gold_request_add_assignment(gold_request, "Description",
+					    object->description);		
+		gold_request_add_assignment(gold_request, "Organization",
+					    object->organization);		
+		if(object->qos != ACCT_QOS_NOTSET) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+				 object->qos-1);
+			gold_request_add_assignment(gold_request, "Expedite",
+						    tmp_buff);
+		}		
+		gold_response = get_gold_response(gold_request);	
+		destroy_gold_request(gold_request);
+
+		if(!gold_response) {
+			error("acct_storage_p_add_accts: "
+			      "no response received");
+			rc = SLURM_ERROR;
+			break;
+		}
+		
+		if(gold_response->rc) {
+			error("gold_response has non-zero rc(%d): %s",
+			      gold_response->rc,
+			      gold_response->message);
+			errno = gold_response->rc;
+			destroy_gold_response(gold_response);
+			rc = SLURM_ERROR;
+			break;
+		}
+		destroy_gold_response(gold_response);		
+	}
+	list_iterator_destroy(itr);
+	
+	return rc;
+}
+
+extern int acct_storage_p_add_clusters(void *db_conn,
+				       List cluster_list)
+{
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	acct_cluster_rec_t *object = NULL;
+
+	itr = list_iterator_create(cluster_list);
+	while((object = list_next(itr))) {
+		if(!object->name) {
+			error("We need a cluster name to add.");
+			rc = SLURM_ERROR;
+			continue;
+		}
+		gold_request = create_gold_request(GOLD_OBJECT_MACHINE,
+						   GOLD_ACTION_CREATE);
+		if(!gold_request) { 
+			error("couldn't create gold_request");
+			rc = SLURM_ERROR;
+			break;
+		}
+		gold_request_add_assignment(gold_request, "Name",
+					    object->name);		
+
+		gold_response = get_gold_response(gold_request);	
+		destroy_gold_request(gold_request);
+
+		if(!gold_response) {
+			error("acct_storage_p_add_clusters: "
+			      "no response received");
+			rc = SLURM_ERROR;
+			break;
+		}
+		
+		if(gold_response->rc) {
+			error("gold_response has non-zero rc(%d): %s",
+			      gold_response->rc,
+			      gold_response->message);
+			errno = gold_response->rc;
+			destroy_gold_response(gold_response);
+			rc = SLURM_ERROR;
+			break;
+		}
+		destroy_gold_response(gold_response);		
+	}
+	list_iterator_destroy(itr);
+	
+	return rc;
+}
+
+extern int acct_storage_p_add_associations(void *db_conn,
+					   List association_list)
+{
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	acct_association_rec_t *object = NULL;
+	char tmp_buff[50];
+
+	itr = list_iterator_create(association_list);
+	while((object = list_next(itr))) {
+		if(!object->cluster || !object->acct) {
+			error("We need a association cluster and "
+			      "acct to add one.");
+			rc = SLURM_ERROR;
+			continue;
+		}
+		gold_request = create_gold_request(GOLD_OBJECT_ACCT,
+						   GOLD_ACTION_CREATE);
+		if(!gold_request) { 
+			error("couldn't create gold_request");
+			rc = SLURM_ERROR;
+			break;
+		}
+		if(object->user) {
+			gold_request_add_assignment(gold_request, "User",
+						    object->user);		
+			snprintf(tmp_buff, sizeof(tmp_buff), 
+				 "%s on %s for %s",
+				 object->acct,
+				 object->cluster,
+				 object->user);
+		} else if(object->parent_acct)
+			snprintf(tmp_buff, sizeof(tmp_buff), 
+				 "%s of %s on %s",
+				 object->acct,
+				 object->parent_acct,
+				 object->cluster);
+		else
+			snprintf(tmp_buff, sizeof(tmp_buff), 
+				 "%s on %s",
+				 object->acct,
+				 object->cluster);
+			
+		gold_request_add_assignment(gold_request, "Name", tmp_buff);
+
+		gold_request_add_assignment(gold_request, "Project",
+					    object->acct);		
+		gold_request_add_assignment(gold_request, "Machine",
+					    object->cluster);	
+			
+		if(object->fairshare) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+				 object->fairshare);
+			gold_request_add_assignment(gold_request, "FairShare",
+						    tmp_buff);		
+		}
+
+		if(object->max_jobs) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
+				 object->max_jobs);
+			gold_request_add_assignment(gold_request, "MaxJobs",
+						    tmp_buff);
+		}
+		
+		if(object->max_nodes_per_job) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+				 object->max_nodes_per_job);
+			gold_request_add_assignment(gold_request,
+						    "MaxNodesPerJob",
+						    tmp_buff);
+		}
+
+		if(object->max_wall_duration_per_job) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+				 object->max_wall_duration_per_job);
+			gold_request_add_assignment(gold_request,
+						    "MaxWallDurationPerJob",
+						    tmp_buff);		
+		}
+
+		if(object->max_cpu_secs_per_job) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+				 object->max_cpu_secs_per_job);
+			gold_request_add_assignment(gold_request,
+						    "MaxProcSecondsPerJob",
+						    tmp_buff);		
+		}
+
+		gold_response = get_gold_response(gold_request);	
+		destroy_gold_request(gold_request);
+
+		if(!gold_response) {
+			error("acct_storage_p_add_associations: "
+			      "no response received");
+			rc = SLURM_ERROR;
+			break;
+		}
+		
+		if(gold_response->rc) {
+			error("gold_response has non-zero rc(%d): %s",
+			      gold_response->rc,
+			      gold_response->message);
+			errno = gold_response->rc;
+			destroy_gold_response(gold_response);
+			rc = SLURM_ERROR;
+			break;
+		}
+		destroy_gold_response(gold_response);		
+	}
+	list_iterator_destroy(itr);
+	
+	return rc;
+}
+
+extern int acct_storage_p_get_assoc_id(void *db_conn,
+				       acct_association_rec_t *assoc)
+{
+	ListIterator itr = NULL;
+	acct_association_rec_t * found_assoc = NULL;
+	acct_association_rec_t * ret_assoc = NULL;
+
+	if(!local_association_list) 
+		local_association_list = acct_storage_g_get_associations(NULL,
+									 NULL);
+
+	if((!assoc->cluster && !assoc->acct) && !assoc->id) {
+		error("acct_storage_p_get_assoc_id: "
+		      "You need to supply a cluster and account name to get "
+		      "an association.");
+		return SLURM_ERROR;
+	}
+
+	itr = list_iterator_create(local_association_list);
+	while((found_assoc = list_next(itr))) {
+		if(assoc->id) {
+			if(assoc->id == found_assoc->id) {
+				ret_assoc = found_assoc;
+				break;
+			}
+			continue;
+		} else {
+			if((!found_assoc->acct 
+			    || strcasecmp(assoc->acct,
+					  found_assoc->acct))
+			   || (!assoc->cluster 
+			       || strcasecmp(assoc->cluster,
+					     found_assoc->cluster))
+			   || (assoc->user 
+			       && (!found_assoc->user 
+				   || strcasecmp(assoc->user,
+						 found_assoc->user)))
+			   || (!assoc->user && found_assoc->user 
+			       && strcasecmp("none",
+					     found_assoc->user)))
+				continue;
+			if(assoc->partition
+			   && (!assoc->partition 
+			       || strcasecmp(assoc->partition, 
+					     found_assoc->partition))) {
+				ret_assoc = found_assoc;
+				continue;
+			}
+		}
+		ret_assoc = found_assoc;
+		break;
+	}
+	list_iterator_destroy(itr);
+
+	if(!ret_assoc)
+		return SLURM_ERROR;
+
+	assoc->id = ret_assoc->id;
+	if(!assoc->user)
+		assoc->user = ret_assoc->user;
+	if(!assoc->acct)
+		assoc->acct = ret_assoc->acct;
+	if(!assoc->cluster)
+		assoc->cluster = ret_assoc->cluster;
+	if(!assoc->partition)
+		assoc->partition = ret_assoc->partition;
+
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_validate_assoc_id(void *db_conn,
+					    uint32_t assoc_id)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_users(void *db_conn,
+					acct_user_cond_t *user_q,
+					acct_user_rec_t *user)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char *object = NULL;
+	char tmp_buff[50];
+	int set = 0;
+
+	if(!user_q) {
+		error("acct_storage_p_modify_users: "
+		      "we need conditions to modify");
+		return NULL;
+	}
+
+	if(!user) {
+		error("acct_storage_p_modify_users: "
+		      "we need something to change");
+		return NULL;
+	}
+
+	gold_request = create_gold_request(GOLD_OBJECT_USER,
+					   GOLD_ACTION_MODIFY);
+	if(!gold_request) { 
+		error("acct_storage_p_modify_users: "
+		      "couldn't create gold_request");
+		return NULL;
+	}
+
+	if(user_q->user_list && list_count(user_q->user_list)) {
+		itr = list_iterator_create(user_q->user_list);
+		if(list_count(user_q->user_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(user_q->def_acct_list && list_count(user_q->def_acct_list)) {
+		itr = list_iterator_create(user_q->def_acct_list);
+		if(list_count(user_q->def_acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request,
+						   "DefaultProject",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(user->default_acct) 
+		gold_request_add_assignment(gold_request,
+					    "DefaultProject",
+					    user->default_acct);
+	
+	if(user->qos != ACCT_QOS_NOTSET) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 user->qos-1);
+		gold_request_add_assignment(gold_request, "Expedite",
+					    tmp_buff);		
+	}
+
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("acct_storage_p_modify_users: "
+		      "no response received");
+		return NULL;
+	}
+	
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+	}
+
+	destroy_gold_response(gold_response);		
+	
+	return NULL;
+}
+
+extern List acct_storage_p_modify_user_admin_level(void *db_conn,
+						   acct_user_cond_t *user_q)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char *object = NULL;
+	int set = 0;
+
+	if(!user_q || user_q->admin_level == ACCT_ADMIN_NOTSET) {
+		error("acct_storage_p_modify_users: "
+		      "we need conditions to modify");
+		return NULL;
+	}
+
+	if(user_q->admin_level == ACCT_ADMIN_NONE) 
+		gold_request = create_gold_request(GOLD_OBJECT_ROLEUSER,
+						   GOLD_ACTION_DELETE);
+	else 
+		gold_request = create_gold_request(GOLD_OBJECT_ROLEUSER,
+						   GOLD_ACTION_CREATE);
+	
+	if(!gold_request) { 
+		error("couldn't create gold_request");
+		return NULL;
+	}
+
+	if(user_q->admin_level == ACCT_ADMIN_NONE) {
+		gold_request_add_condition(gold_request,
+					   "Role",
+					   "SystemAdmin",
+					   GOLD_OPERATOR_NONE, 2);
+		
+		gold_request_add_condition(gold_request,
+					   "Role",
+					   "Operator",
+					   GOLD_OPERATOR_NONE, 1);
+	} else if(user_q->admin_level == ACCT_ADMIN_SUPER_USER)
+		gold_request_add_assignment(gold_request,
+					    "Role",
+					    "SystemAdmin");
+	else if(user_q->admin_level == ACCT_ADMIN_OPERATOR)
+		gold_request_add_assignment(gold_request,
+					    "Role",
+					    "Operator");
+	else {
+		error("acct_storage_p_modify_user_admin_level: "
+		      "unknown admin level %d", user_q->admin_level);
+		return NULL;
+	}
+
+	if(user_q->user_list && list_count(user_q->user_list)) {
+		itr = list_iterator_create(user_q->user_list);
+		if(list_count(user_q->user_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(user_q->def_acct_list && list_count(user_q->def_acct_list)) {
+		itr = list_iterator_create(user_q->def_acct_list);
+		if(list_count(user_q->def_acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request,
+						   "DefaultProject",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+	
+	if(!gold_response) {
+		error("acct_storage_p_modify_users: "
+		      "no response received");
+		return NULL;
+	}
+	
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		
+	}
+	destroy_gold_response(gold_response);	
+	
+	return NULL;
+}
+
+extern List acct_storage_p_modify_accts(void *db_conn,
+				       acct_account_cond_t *acct_q,
+				       acct_account_rec_t *acct)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char tmp_buff[50];
+	int set = 0;
+	char *object = NULL;
+
+	if(!acct_q) {
+		error("acct_storage_p_modify_accts: "
+		      "we need conditions to modify");
+		return NULL;
+	}
+
+	if(!acct) {
+		error("acct_storage_p_modify_accts: "
+		      "we need something to change");
+		return NULL;
+	}
+	
+	gold_request = create_gold_request(GOLD_OBJECT_ACCT,
+					   GOLD_ACTION_MODIFY);
+	if(!gold_request) { 
+		error("couldn't create gold_request");
+		return NULL;
+	}
+
+	if(acct_q->acct_list && list_count(acct_q->acct_list)) {
+		itr = list_iterator_create(acct_q->acct_list);
+		if(list_count(acct_q->acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct_q->description_list 
+	   && list_count(acct_q->description_list)) {
+		itr = list_iterator_create(acct_q->description_list);
+		if(list_count(acct_q->description_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Description",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct_q->organization_list 
+	   && list_count(acct_q->organization_list)) {
+		itr = list_iterator_create(acct_q->organization_list);
+		if(list_count(acct_q->organization_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Organization",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct->description) 
+		gold_request_add_assignment(gold_request,
+					    "Description",
+					    acct->description);
+	if(acct->organization) 
+		gold_request_add_assignment(gold_request,
+					    "Organization",
+					    acct->organization);
+	
+	if(acct->qos != ACCT_QOS_NOTSET) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 acct->qos-1);
+		gold_request_add_assignment(gold_request, "Expedite",
+					    tmp_buff);		
+	}
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+	
+	if(!gold_response) {
+		error("acct_storage_p_modify_accts: "
+		      "no response received");
+		return NULL;
+	}
+	
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		
+	}
+
+	destroy_gold_response(gold_response);		
+	
+	return NULL;
+}
+
+extern List acct_storage_p_modify_clusters(void *db_conn,
+					  acct_cluster_cond_t *cluster_q,
+					  acct_cluster_rec_t *cluster)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_associations(void *db_conn,
+					      acct_association_cond_t *assoc_q,
+					      acct_association_rec_t *assoc)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char tmp_buff[50];
+	char *object = NULL;
+	int set = 0;
+
+	if(!assoc_q) {
+		error("acct_storage_p_modify_associations: "
+		      "we need conditions to modify");
+		return NULL;
+	}
+
+	if(!assoc) {
+		error("acct_storage_p_modify_associations: "
+		      "we need something to change");
+		return NULL;
+	}
+
+	gold_request = create_gold_request(GOLD_OBJECT_ACCT,
+					   GOLD_ACTION_MODIFY);
+	if(!gold_request) { 
+		error("couldn't create gold_request");
+		return NULL;
+	}
+
+	if(assoc_q->id_list && list_count(assoc_q->id_list)) {
+		itr = list_iterator_create(assoc_q->id_list);
+		if(list_count(assoc_q->id_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Id",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->user_list && list_count(assoc_q->user_list)) {
+		itr = list_iterator_create(assoc_q->user_list);
+		if(list_count(assoc_q->user_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "User",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->acct_list && list_count(assoc_q->acct_list)) {
+		itr = list_iterator_create(assoc_q->acct_list);
+		if(list_count(assoc_q->acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Project",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->cluster_list && list_count(assoc_q->cluster_list)) {
+		itr = list_iterator_create(assoc_q->cluster_list);
+		if(list_count(assoc_q->cluster_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Machine",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc->fairshare) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 assoc->fairshare);
+		gold_request_add_assignment(gold_request, "Fairshare",
+					    tmp_buff);		
+	}
+
+	if(assoc->max_jobs) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
+			 assoc->max_jobs);
+		gold_request_add_assignment(gold_request, "MaxJobs",
+					    tmp_buff);
+	}
+		
+	if(assoc->max_nodes_per_job) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 assoc->max_nodes_per_job);
+		gold_request_add_assignment(gold_request,
+					    "MaxNodesPerJob",
+					    tmp_buff);
+	}
+
+	if(assoc->max_wall_duration_per_job) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 assoc->max_wall_duration_per_job);
+		gold_request_add_assignment(gold_request,
+					    "MaxWallDurationPerJob",
+					    tmp_buff);		
+	}
+
+	if(assoc->max_cpu_secs_per_job) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 assoc->max_cpu_secs_per_job);
+		gold_request_add_assignment(gold_request,
+					    "MaxProcSecondsPerJob",
+					    tmp_buff);		
+	}
+
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("acct_storage_p_modify_associations: "
+		      "no response received");
+		return NULL;
+	}
+		
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		
+	}
+	destroy_gold_response(gold_response);		
+	
+	return NULL;
+}
+
+extern List acct_storage_p_remove_users(void *db_conn,
+				       acct_user_cond_t *user_q)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char *object = NULL;
+	int set = 0;
+
+	if(!user_q) {
+		error("acct_storage_p_remove_users: "
+		      "we need conditions to remove");
+		return NULL;
+	}
+
+	gold_request = create_gold_request(GOLD_OBJECT_USER,
+					   GOLD_ACTION_DELETE);
+	if(!gold_request) { 
+		error("acct_storage_p_remove_users: "
+		      "couldn't create gold_request");
+		return NULL;
+	}
+	
+	if(user_q->user_list && list_count(user_q->user_list)) {
+		itr = list_iterator_create(user_q->user_list);
+		if(list_count(user_q->user_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(user_q->def_acct_list && list_count(user_q->def_acct_list)) {
+		itr = list_iterator_create(user_q->def_acct_list);
+		if(list_count(user_q->def_acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request,
+						   "DefaultProject",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+	
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+	
+	if(!gold_response) {
+		error("acct_storage_p_remove_users: "
+		      "no response received");
+		return NULL;
+	}
+		
+	if(gold_response->rc) {
+		error("acct_storage_p_remove_users: "
+		      "gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		
+	}
+	destroy_gold_response(gold_response);		
+		
+	return NULL;
+}
+
+extern List acct_storage_p_remove_coord(void *db_conn,
+				       char *acct,
+				       acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_accts(void *db_conn,
+				       acct_account_cond_t *acct_q)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char *object = NULL;
+	int set = 0;
+
+	if(!acct_q) {
+		error("acct_storage_p_remove_accts: "
+		      "we need conditions to remove");
+		return NULL;
+	}
+
+	gold_request = create_gold_request(GOLD_OBJECT_PROJECT,
+					   GOLD_ACTION_DELETE);
+	if(!gold_request) { 
+		error("acct_storage_p_remove_accts: "
+		      "couldn't create gold_request");
+		return NULL;
+	}
+	
+	if(acct_q->acct_list && list_count(acct_q->acct_list)) {
+		itr = list_iterator_create(acct_q->acct_list);
+		if(list_count(acct_q->acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct_q->description_list 
+	   && list_count(acct_q->description_list)) {
+		itr = list_iterator_create(acct_q->description_list);
+		if(list_count(acct_q->description_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Description",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct_q->organization_list 
+	   && list_count(acct_q->organization_list)) {
+		itr = list_iterator_create(acct_q->organization_list);
+		if(list_count(acct_q->organization_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Organization",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+	
+	if(!gold_response) {
+		error("acct_storage_p_remove_accts: "
+		      "no response received");
+		return NULL;
+	}
+	
+	if(gold_response->rc) {
+		error("acct_storage_p_remove_accts: "
+		      "gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		
+	}
+	destroy_gold_response(gold_response);		
+		
+	return NULL;
+}
+
+extern List acct_storage_p_remove_clusters(void *db_conn,
+					  acct_cluster_cond_t *cluster_q)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char *object = NULL;
+	int set = 0;
+
+	if(!cluster_q) {
+		error("acct_storage_p_modify_clusters: "
+		      "we need conditions to modify");
+		return NULL;
+	}
+
+	gold_request = create_gold_request(GOLD_OBJECT_MACHINE,
+					   GOLD_ACTION_DELETE);
+	if(!gold_request) { 
+		error("acct_storage_p_remove_clusters: "
+		      "couldn't create gold_request");
+		return NULL;
+	}
+	
+	if(cluster_q->cluster_list && list_count(cluster_q->cluster_list)) {
+		itr = list_iterator_create(cluster_q->cluster_list);
+		if(list_count(cluster_q->cluster_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+		
+	if(!gold_response) {
+		error("acct_storage_p_remove_clusters: "
+		      "no response received");
+		return NULL;
+	}
+	
+	if(gold_response->rc) {
+		error("acct_storage_p_remove_clusters: "
+		      "gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		destroy_gold_response(gold_response);
+		return NULL;
+	}
+	destroy_gold_response(gold_response);
+
+	gold_request = create_gold_request(GOLD_OBJECT_MACHINE_HOUR_USAGE,
+					   GOLD_ACTION_DELETE);
+	if(!gold_request) { 
+		error("acct_storage_p_remove_clusters: "
+		      "couldn't create gold_request");
+		return NULL;
+	}
+	
+	if(cluster_q->cluster_list && list_count(cluster_q->cluster_list)) {
+		itr = list_iterator_create(cluster_q->cluster_list);
+		if(list_count(cluster_q->cluster_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Machine",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+	
+	if(!gold_response) {
+		error("acct_storage_p_remove_clusters: "
+		      "no response received");
+		destroy_gold_request(gold_request);
+		return NULL;
+	}
+		
+	if(gold_response->rc) {
+		error("acct_storage_p_remove_clusters: "
+		      "gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		destroy_gold_request(gold_request);
+		destroy_gold_response(gold_response);
+		return NULL;
+	}
+	destroy_gold_response(gold_response);
+
+	gold_request->object = GOLD_OBJECT_MACHINE_DAY_USAGE;
+	gold_response = get_gold_response(gold_request);	
+	if(!gold_response) {
+		error("acct_storage_p_remove_clusters: "
+		      "no response received");
+		destroy_gold_request(gold_request);
+		return NULL;
+	}
+		
+	if(gold_response->rc) {
+		error("acct_storage_p_remove_clusters: "
+		      "gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		destroy_gold_request(gold_request);
+		destroy_gold_response(gold_response);
+		return NULL;
+	}
+	
+	destroy_gold_response(gold_response);
+
+	gold_request->object = GOLD_OBJECT_MACHINE_MONTH_USAGE;
+	gold_response = get_gold_response(gold_request);	
+	if(!gold_response) {
+		error("acct_storage_p_remove_clusters: "
+		      "no response received");
+		destroy_gold_request(gold_request);
+		return NULL;
+	}
+		
+	if(gold_response->rc) {
+		error("acct_storage_p_remove_clusters: "
+		      "gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		
+	}
+	
+	destroy_gold_request(gold_request);
+	destroy_gold_response(gold_response);
+	
+	return NULL;
+}
+
+extern List acct_storage_p_remove_associations(void *db_conn,
+					      acct_association_cond_t *assoc_q)
+{
+	ListIterator itr = NULL;
+//	int rc = SLURM_SUCCESS;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char *object = NULL;
+	int set = 0;
+
+	if(!assoc_q) {
+		error("acct_storage_p_remove_associations: "
+		      "we need conditions to remove");
+		return NULL;
+	}
+
+	gold_request = create_gold_request(GOLD_OBJECT_ACCT,
+					   GOLD_ACTION_DELETE);
+	if(!gold_request) { 
+		error("couldn't create gold_request");
+		return NULL;
+	}
+
+	if(assoc_q->id_list && list_count(assoc_q->id_list)) {
+		itr = list_iterator_create(assoc_q->id_list);
+		if(list_count(assoc_q->id_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Id",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->user_list && list_count(assoc_q->user_list)) {
+		itr = list_iterator_create(assoc_q->user_list);
+		if(list_count(assoc_q->user_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "User",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->acct_list && list_count(assoc_q->acct_list)) {
+		itr = list_iterator_create(assoc_q->acct_list);
+		if(list_count(assoc_q->acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Project",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->cluster_list && list_count(assoc_q->cluster_list)) {
+		itr = list_iterator_create(assoc_q->cluster_list);
+		if(list_count(assoc_q->cluster_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Machine",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+	
+	if(!gold_response) {
+		error("acct_storage_p_modify_associations: "
+		      "no response received");
+		return NULL;
+	}
+		
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		
+	}
+
+	if(gold_response->entry_cnt > 0) {
+		ListIterator itr = NULL;
+		ListIterator itr2 = NULL;
+		gold_response_entry_t *resp_entry = NULL;
+		gold_name_value_t *name_val = NULL;
+		List id_list = list_create(slurm_destroy_char);
+
+		itr = list_iterator_create(gold_response->entries);
+		while((resp_entry = list_next(itr))) {
+			itr2 = list_iterator_create(
+				resp_entry->name_val);
+			while((name_val = list_next(itr2))) {
+				if(!strcmp(name_val->name, "Id")) {
+					list_push(id_list, name_val->value);
+					break;
+				}
+			}
+			list_iterator_destroy(itr2);			
+		}
+		list_iterator_destroy(itr);
+		_remove_association_accounting(id_list);
+		list_destroy(id_list);
+	} else {
+		debug3("no associations found");
+	}
+	destroy_gold_response(gold_response);		
+
+	return NULL;
+}
+
+extern List acct_storage_p_get_users(void *db_conn,
+				     acct_user_cond_t *user_q)
+{
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	List user_list = NULL;
+	ListIterator itr = NULL;
+	char *object = NULL;
+	int set = 0;
+	char tmp_buff[50];
+
+	gold_request = create_gold_request(GOLD_OBJECT_USER,
+					   GOLD_ACTION_QUERY);
+
+	if(!gold_request) 
+		return NULL;
+
+	if(!user_q) 
+		goto empty;
+
+	if(user_q->user_list && list_count(user_q->user_list)) {
+		itr = list_iterator_create(user_q->user_list);
+		if(list_count(user_q->user_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(user_q->def_acct_list && list_count(user_q->def_acct_list)) {
+		itr = list_iterator_create(user_q->def_acct_list);
+		if(list_count(user_q->def_acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request,
+						   "DefaultProject",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+	
+	if(user_q->qos != ACCT_QOS_NOTSET) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 user_q->qos-1);
+		gold_request_add_condition(gold_request, "Expedite",
+					   tmp_buff,
+					   GOLD_OPERATOR_NONE, 0);		
+	}
+
+empty:
+	gold_request_add_condition(gold_request, "Active",
+				   "True",
+				   GOLD_OPERATOR_NONE,
+				   0);
+
+	gold_request_add_condition(gold_request, "Special",
+				   "False",
+				   GOLD_OPERATOR_NONE,
+				   0);
+
+	gold_request_add_selection(gold_request, "Name");
+	gold_request_add_selection(gold_request, "DefaultProject");
+	gold_request_add_selection(gold_request, "Expedite");
+		
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("acct_storage_p_get_users: no response received");
+		return NULL;
+	}
+
+	user_list = _get_user_list_from_response(gold_response);
+	
+	destroy_gold_response(gold_response);
+
+	return user_list;
+}
+
+extern List acct_storage_p_get_accts(void *db_conn,
+				     acct_account_cond_t *acct_q)
+{
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	List acct_list = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	char *object = NULL;
+	char tmp_buff[50];
+
+
+	gold_request = create_gold_request(GOLD_OBJECT_PROJECT,
+					   GOLD_ACTION_QUERY);
+	if(!gold_request) 
+		return NULL;
+
+	if(!acct_q) 
+		goto empty;
+
+	if(acct_q->acct_list && list_count(acct_q->acct_list)) {
+		itr = list_iterator_create(acct_q->acct_list);
+		if(list_count(acct_q->acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct_q->description_list 
+	   && list_count(acct_q->description_list)) {
+		itr = list_iterator_create(acct_q->description_list);
+		if(list_count(acct_q->description_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Description",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct_q->organization_list 
+	   && list_count(acct_q->organization_list)) {
+		itr = list_iterator_create(acct_q->organization_list);
+		if(list_count(acct_q->organization_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Organization",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(acct_q->qos != ACCT_QOS_NOTSET) {
+		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
+			 acct_q->qos-1);
+		gold_request_add_condition(gold_request, "Expedite",
+					   tmp_buff,
+					   GOLD_OPERATOR_NONE, 0);		
+	}
+empty:
+	gold_request_add_condition(gold_request, "Active",
+				   "True",
+				   GOLD_OPERATOR_NONE,
+				   0);
+
+	gold_request_add_condition(gold_request, "Special",
+				   "False",
+				   GOLD_OPERATOR_NONE,
+				   0);
+
+	gold_request_add_selection(gold_request, "Name");
+	gold_request_add_selection(gold_request, "Organization");
+	gold_request_add_selection(gold_request, "Description");
+	gold_request_add_selection(gold_request, "Expedite");
+		
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("acct_storage_p_get_accts: no response received");
+		return NULL;
+	}
+
+	acct_list = _get_acct_list_from_response(gold_response);
+	
+	destroy_gold_response(gold_response);
+
+	return acct_list;
+}
+
+extern List acct_storage_p_get_clusters(void *db_conn,
+					acct_cluster_cond_t *cluster_q)
+{
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	List cluster_list = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	char *object = NULL;
+
+
+	gold_request = create_gold_request(GOLD_OBJECT_MACHINE,
+					   GOLD_ACTION_QUERY);
+	if(!gold_request) 
+		return NULL;
+
+	if(!cluster_q) 
+		goto empty;
+
+	if(cluster_q->cluster_list && list_count(cluster_q->cluster_list)) {
+		itr = list_iterator_create(cluster_q->cluster_list);
+		if(list_count(cluster_q->cluster_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Name",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+empty:
+	gold_request_add_condition(gold_request, "Active",
+				   "True",
+				   GOLD_OPERATOR_NONE,
+				   0);
+
+	gold_request_add_condition(gold_request, "Special",
+				   "False",
+				   GOLD_OPERATOR_NONE,
+				   0);
+	
+	gold_request_add_selection(gold_request, "Name");
+		
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("acct_storage_p_get_clusters: no response received");
+		return NULL;
+	}
+
+	cluster_list = _get_cluster_list_from_response(gold_response);
+	
+	destroy_gold_response(gold_response);
+
+	return cluster_list;
+}
+
+extern List acct_storage_p_get_associations(void *db_conn,
+					    acct_association_cond_t *assoc_q)
+{
+
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	List association_list = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	char *object = NULL;
+
+	gold_request = create_gold_request(GOLD_OBJECT_ACCT,
+					   GOLD_ACTION_QUERY);
+	
+	if(!gold_request) 
+		return NULL;
+
+	if(!assoc_q) 
+		goto empty;
+	
+	if(assoc_q->id_list && list_count(assoc_q->id_list)) {
+		itr = list_iterator_create(assoc_q->id_list);
+		if(list_count(assoc_q->id_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Id",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->user_list && list_count(assoc_q->user_list)) {
+		itr = list_iterator_create(assoc_q->user_list);
+		if(list_count(assoc_q->user_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "User",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->acct_list && list_count(assoc_q->acct_list)) {
+		itr = list_iterator_create(assoc_q->acct_list);
+		if(list_count(assoc_q->acct_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Project",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(assoc_q->cluster_list && list_count(assoc_q->cluster_list)) {
+		itr = list_iterator_create(assoc_q->cluster_list);
+		if(list_count(assoc_q->cluster_list) > 1)
+			set = 2;
+		else
+			set = 0;
+		
+		while((object = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Machine",
+						   object,
+						   GOLD_OPERATOR_NONE, set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+empty:
+	gold_request_add_selection(gold_request, "Id");
+	gold_request_add_selection(gold_request, "User");
+	gold_request_add_selection(gold_request, "Project");
+	gold_request_add_selection(gold_request, "Machine");
+	gold_request_add_selection(gold_request, "Parent");
+	gold_request_add_selection(gold_request, "FairShare");
+	gold_request_add_selection(gold_request, "MaxJobs");
+	gold_request_add_selection(gold_request, "MaxNodesPerJob");
+	gold_request_add_selection(gold_request, "MaxWallDurationPerJob");
+	gold_request_add_selection(gold_request, "MaxProcSecondsPerJob");
+		
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("acct_storage_p_get_associations: "
+		      "no response received");
+		return NULL;
+	}
+
+	association_list = _get_association_list_from_response(gold_response);
+
+	destroy_gold_response(gold_response);
+
+	return association_list;
+}
+
+extern int acct_storage_p_get_usage(void *db_conn,
+				    acct_association_rec_t *acct_assoc,
+				    time_t start, time_t end)
+{
+	int rc = SLURM_ERROR;
+/* 	gold_request_t *gold_request = NULL; */
+/* 	gold_response_t *gold_response = NULL; */
+/* 	char tmp_buff[50]; */
+/* 	gold_object_t g_object; */
+/* 	char *req_cpu_type = NULL; */
+
+/* 	if(!acct_assoc || acct_assoc->id) { */
+/* 		error("acct_storage_p_get_usage: " */
+/* 		      "We need an id to go off to query off of"); */
+/* 		return rc; */
+/* 	} */
+
+/* 	switch(type) { */
+/* 	case ACCT_USAGE_HOUR: */
+/* 		g_object = GOLD_OBJECT_ACCT_HOUR_USAGE; */
+/* 		req_cpu_type = "AllocatedCPUSeconds"; */
+/* 		break; */
+/* 	case ACCT_USAGE_DAY: */
+/* 		g_object = GOLD_OBJECT_ACCT_DAY_USAGE; */
+/* 		req_cpu_type = "AllocatedCPUSeconds"; */
+/* 		break; */
+/* 	case ACCT_USAGE_MONTH: */
+/* 		g_object = GOLD_OBJECT_ACCT_MONTH_USAGE; */
+/* 		req_cpu_type = "AllocatedCPUHours"; */
+/* 		break; */
+/* 	default: */
+/* 		error("Unknown usage type"); */
+/* 		return rc; */
+/* 	} */
+/* 	gold_request = create_gold_request( */
+/* 		g_object, GOLD_ACTION_QUERY); */
+
+/* 	if(!gold_request)  */
+/* 		return rc; */
+
+/* 	snprintf(tmp_buff, sizeof(tmp_buff), "%u", acct_assoc->id); */
+/* 	gold_request_add_condition(gold_request, "Acct", tmp_buff, */
+/* 				   GOLD_OPERATOR_NONE, 0); */
+
+/* 	if(start) { */
+/* 		snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)start); */
+/* 		gold_request_add_condition(gold_request, "PeriodStart", */
+/* 					   tmp_buff, */
+/* 					   GOLD_OPERATOR_GE, 0); */
+/* 	} */
+/* 	if(end) {	 */
+/* 		snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)end); */
+/* 		gold_request_add_condition(gold_request, "PeriodStart", */
+/* 					   tmp_buff, */
+/* 					   GOLD_OPERATOR_L, 0); */
+/* 	} */
+
+/* 	gold_request_add_selection(gold_request, "PeriodStart"); */
+/* 	gold_request_add_selection(gold_request, req_cpu_type); */
+
+/* 	gold_response = get_gold_response(gold_request);	 */
+/* 	destroy_gold_request(gold_request); */
+
+/* 	if(!gold_response) { */
+/* 		error("acct_storage_p_get_usage: " */
+/* 		      "no response received"); */
+/* 		return rc; */
+/* 	} */
+
+/* 	rc = _get_acct_accounting_list_from_response( */
+/* 		gold_response, acct_assoc); */
+
+/* 	destroy_gold_response(gold_response); */
+
+	return rc;
+}
+
+extern int acct_storage_p_roll_usage(void *db_conn, 
+				     time_t sent_start)
+{
+	int rc = SLURM_ERROR;
+	/* FIX ME: This doesn't do anything now */
+/* 	gold_request_t *gold_request = NULL; */
+/* 	gold_response_t *gold_response = NULL; */
+/* 	char tmp_buff[50]; */
+
+/* 	if(!acct_assoc || acct_assoc->id) { */
+/* 		error("acct_storage_p_roll_usage: " */
+/* 		      "We need an id to go off to query off of"); */
+/* 		return rc; */
+/* 	} */
+
+/* 	switch(type) { */
+/* 	case ACCT_USAGE_HOUR: */
+/* 		g_object = GOLD_OBJECT_ACCT_HOUR_USAGE; */
+/* 		req_cpu_type = "AllocatedCPUSecs"; */
+/* 		break; */
+/* 	case ACCT_USAGE_DAY: */
+/* 		g_object = GOLD_OBJECT_ACCT_DAY_USAGE; */
+/* 		req_cpu_type = "AllocatedCPUSecs"; */
+/* 		break; */
+/* 	case ACCT_USAGE_MONTH: */
+/* 		g_object = GOLD_OBJECT_ACCT_MONTH_USAGE; */
+/* 		req_cpu_type = "AllocatedCPUHours"; */
+/* 		break; */
+/* 	default: */
+/* 		error("Unknown usage type"); */
+/* 		return rc; */
+/* 	} */
+/* 	gold_request = create_gold_request( */
+/* 		GOLD_OBJECT_ACCT_DAY_USAGE, GOLD_ACTION_QUERY); */
+
+/* 	if(!gold_request)  */
+/* 		return rc; */
+
+/* 	snprintf(tmp_buff, sizeof(tmp_buff), "%u", acct_assoc->id); */
+/* 	gold_request_add_condition(gold_request, "Acct", tmp_buff, */
+/* 				   GOLD_OPERATOR_NONE, 0); */
+
+/* 	if(start) { */
+/* 		snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)start); */
+/* 		gold_request_add_condition(gold_request, "PeriodStart", */
+/* 					   tmp_buff, */
+/* 					   GOLD_OPERATOR_GE, 0); */
+/* 	} */
+/* 	if(end) {	 */
+/* 		snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)end); */
+/* 		gold_request_add_condition(gold_request, "PeriodStart", */
+/* 					   tmp_buff, */
+/* 					   GOLD_OPERATOR_L, 0); */
+/* 	} */
+
+/* 	gold_request_add_selection(gold_request, "PeriodStart"); */
+/* 	gold_request_add_selection(gold_request, "AllocatedCPUSecs"); */
+
+/* 	gold_response = get_gold_response(gold_request);	 */
+/* 	destroy_gold_request(gold_request); */
+
+/* 	if(!gold_response) { */
+/* 		error("acct_storage_p_get_daily_usage: " */
+/* 		      "no response received"); */
+/* 		return rc; */
+/* 	} */
+
+/* 	rc = _get_acct_accounting_list_from_response( */
+/* 		gold_response, acct_assoc); */
+
+/* 	destroy_gold_response(gold_response); */
+
+	return rc;
+}
+
+extern int clusteracct_storage_p_node_down(void *db_conn,
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time,
+					   char *reason)
+{
+	uint16_t cpus;
+	int rc = SLURM_ERROR;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char tmp_buff[50];
+	char *my_reason;
+
+	if (slurmctld_conf.fast_schedule && !slurmdbd_conf)
+		cpus = node_ptr->config_ptr->cpus;
+	else
+		cpus = node_ptr->cpus;
+
+	if (reason)
+		my_reason = reason;
+	else
+		my_reason = node_ptr->reason;
+
+#if _DEBUG
+	slurm_make_time_str(&event_time, tmp_buff, sizeof(tmp_buff));
+	info("cluster_acct_down: %s at %s with %u cpus due to %s", 
+	     node_ptr->name, tmp_buff, cpus, reason);
+#endif
+	/* If the node was already down end that record since the
+	 * reason will most likely be different
+	 */
+
+	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
+					   GOLD_ACTION_MODIFY);
+	if(!gold_request) 
+		return rc;
+	
+	gold_request_add_condition(gold_request, "Machine", cluster,
+				   GOLD_OPERATOR_NONE, 0);
+	gold_request_add_condition(gold_request, "EndTime", "0",
+				   GOLD_OPERATOR_NONE, 0);
+	gold_request_add_condition(gold_request, "Name", node_ptr->name,
+				   GOLD_OPERATOR_NONE, 0);
+
+	snprintf(tmp_buff, sizeof(tmp_buff), "%d", ((int)event_time - 1));
+	gold_request_add_assignment(gold_request, "EndTime", tmp_buff);		
+			
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("clusteracct_storage_p_node_down: no response received");
+		return rc;
+	}
+
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		destroy_gold_response(gold_response);
+		return rc;
+	}
+	destroy_gold_response(gold_response);
+
+	/* now add the new one */
+	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
+					   GOLD_ACTION_CREATE);
+	if(!gold_request) 
+		return rc;
+	
+	gold_request_add_assignment(gold_request, "Machine", cluster);
+	snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)event_time);
+	gold_request_add_assignment(gold_request, "StartTime", tmp_buff);
+	gold_request_add_assignment(gold_request, "Name", node_ptr->name);
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u", cpus);
+	gold_request_add_assignment(gold_request, "CPUCount", tmp_buff);
+	gold_request_add_assignment(gold_request, "Reason", my_reason);
+			
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("clusteracct_p_node_down: no response received");
+		return rc;
+	}
+
+	if(!gold_response->rc) 
+		rc = SLURM_SUCCESS;
+	else {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+	}
+	destroy_gold_response(gold_response);
+
+	return rc;
+}
+
+extern int clusteracct_storage_p_node_up(void *db_conn,
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time)
+{
+	int rc = SLURM_ERROR;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char tmp_buff[50];
+
+#if _DEBUG
+	slurm_make_time_str(&event_time, tmp_buff, sizeof(tmp_buff));
+	info("cluster_acct_up: %s at %s", node_ptr->name, tmp_buff);
+#endif
+
+	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
+					   GOLD_ACTION_MODIFY);
+	if(!gold_request) 
+		return rc;
+	
+	gold_request_add_condition(gold_request, "Machine", cluster,
+				   GOLD_OPERATOR_NONE, 0);
+	gold_request_add_condition(gold_request, "EndTime", "0",
+				   GOLD_OPERATOR_NONE, 0);
+	gold_request_add_condition(gold_request, "Name", node_ptr->name,
+				   GOLD_OPERATOR_NONE, 0);
+
+	snprintf(tmp_buff, sizeof(tmp_buff), "%d", ((int)event_time - 1));
+	gold_request_add_assignment(gold_request, "EndTime", tmp_buff);		
+			
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("clusteracct_p_node_up: no response received");
+		return rc;
+	}
+
+	if(gold_response->rc) {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+		destroy_gold_response(gold_response);
+		return rc;
+	}
+	rc = SLURM_SUCCESS;
+	destroy_gold_response(gold_response);
+
+
+	return rc;
+}
+
+extern int clusteracct_storage_p_register_ctld(char *cluster,
+					       uint16_t port)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_cluster_procs(void *db_conn,
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time)
+{
+	static uint32_t last_procs = -1;
+	gold_request_t *gold_request = NULL;
+	gold_response_t *gold_response = NULL;
+	char tmp_buff[50];
+	int rc = SLURM_ERROR;
+	bool no_modify = 0;
+
+	if (procs == last_procs) {
+		debug3("we have the same procs as before no need to "
+		       "query the database.");
+		return SLURM_SUCCESS;
+	}
+	last_procs = procs;
+
+	/* Record the processor count */
+#if _DEBUG
+	slurm_make_time_str(&event_time, tmp_buff, sizeof(tmp_buff));
+	info("cluster_acct_procs: %s has %u total CPUs at %s", 
+	     cluster, procs, tmp_buff);
+#endif
+	
+	/* get the last known one */
+	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
+					   GOLD_ACTION_QUERY);
+	if(!gold_request) 
+		return rc;
+	gold_request_add_condition(gold_request, "Machine", cluster,
+				   GOLD_OPERATOR_NONE, 0);
+	gold_request_add_condition(gold_request, "EndTime", "0",
+				   GOLD_OPERATOR_NONE, 0);
+	gold_request_add_condition(gold_request, "Name", "NULL",
+				   GOLD_OPERATOR_NONE, 0);
+
+	gold_request_add_selection(gold_request, "CPUCount");
+		
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("clusteracct_p_cluster_procs: no response received");
+		return rc;
+	}
+
+	if(gold_response->entry_cnt > 0) {
+		gold_response_entry_t *resp_entry = 
+			list_pop(gold_response->entries);
+		gold_name_value_t *name_val = list_pop(resp_entry->name_val);
+
+		if(procs == atoi(name_val->value)) {
+			debug("System hasn't changed since last entry");
+			destroy_gold_name_value(name_val);
+			destroy_gold_response_entry(resp_entry);
+			destroy_gold_response(gold_response);
+			return SLURM_SUCCESS;
+		} else {
+			debug("System has changed from %s cpus to %d",
+			      name_val->value, procs);   
+		}
+
+		destroy_gold_name_value(name_val);
+		destroy_gold_response_entry(resp_entry);
+	} else {
+		debug("We don't have an entry for this machine "
+		      "most likely a first time running.");
+		no_modify = 1;
+	}
+
+	destroy_gold_response(gold_response);
+	
+	if(no_modify) {
+		gold_request = create_gold_request(GOLD_OBJECT_EVENT,
+						   GOLD_ACTION_MODIFY);
+		if(!gold_request) 
+			return rc;
+		
+		gold_request_add_condition(gold_request, "Machine",
+					   cluster,
+					   GOLD_OPERATOR_NONE, 0);
+		gold_request_add_condition(gold_request, "EndTime", "0",
+					   GOLD_OPERATOR_NONE, 0);
+		gold_request_add_condition(gold_request, "Name", "NULL",
+					   GOLD_OPERATOR_NONE, 0);
+		
+		snprintf(tmp_buff, sizeof(tmp_buff), "%d", 
+			 ((int)event_time - 1));
+		gold_request_add_assignment(gold_request, "EndTime", tmp_buff);	
+		
+		gold_response = get_gold_response(gold_request);	
+		destroy_gold_request(gold_request);
+		
+		if(!gold_response) {
+			error("jobacct_p_cluster_procs: no response received");
+			return rc;
+		}
+		
+		if(gold_response->rc) {
+			error("gold_response has non-zero rc(%d): %s",
+			      gold_response->rc,
+			      gold_response->message);
+			errno = gold_response->rc;
+			destroy_gold_response(gold_response);
+			return rc;
+		}
+		destroy_gold_response(gold_response);
+	}
+
+	/* now add the new one */
+	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
+					   GOLD_ACTION_CREATE);
+	if(!gold_request) 
+		return rc;
+	
+	gold_request_add_assignment(gold_request, "Machine", cluster);
+	snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)event_time);
+	gold_request_add_assignment(gold_request, "StartTime", tmp_buff);
+	snprintf(tmp_buff, sizeof(tmp_buff), "%u", procs);
+	gold_request_add_assignment(gold_request, "CPUCount", tmp_buff);
+			
+	gold_response = get_gold_response(gold_request);	
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("clusteracct_p_cluster_procs: no response received");
+		return rc;
+	}
+
+	if(!gold_response->rc) 
+		rc = SLURM_SUCCESS;
+	else {
+		error("gold_response has non-zero rc(%d): %s",
+		      gold_response->rc,
+		      gold_response->message);
+		errno = gold_response->rc;
+	}
+	destroy_gold_response(gold_response);
+
+	return rc;
+}
+
+extern int clusteracct_storage_p_get_usage(
+	void *db_conn, 
+	acct_cluster_rec_t *cluster_rec, time_t start, 
+	time_t end)
+{
+	int rc = SLURM_ERROR;
+/* 	gold_request_t *gold_request = NULL; */
+/* 	gold_response_t *gold_response = NULL; */
+/* 	char tmp_buff[50]; */
+/* 	gold_object_t g_object; */
+/* 	char *alloc_cpu = NULL; */
+/* 	char *idle_cpu = NULL; */
+/* 	char *down_cpu = NULL; */
+/* 	char *resv_cpu = NULL; */
+
+/* 	if(!cluster_rec || !cluster_rec->name) { */
+/* 		error("clusteracct_storage_p_get_hourly_usage:" */
+/* 		      "no cluster name given to query."); */
+/* 		return rc; */
+/* 	} */
+/* 	switch(type) { */
+/* 	case ACCT_USAGE_HOUR: */
+/* 		g_object = GOLD_OBJECT_MACHINE_HOUR_USAGE; */
+/* 		alloc_cpu = "AllocatedCPUSeconds"; */
+/* 		idle_cpu = "IdleCPUSeconds"; */
+/* 		down_cpu = "DownCPUSeconds"; */
+/* 		resv_cpu = "ReservedCPUSeconds"; */
+/* 		break; */
+/* 	case ACCT_USAGE_DAY: */
+/* 		g_object = GOLD_OBJECT_MACHINE_DAY_USAGE; */
+/* 		alloc_cpu = "AllocatedCPUSeconds"; */
+/* 		idle_cpu = "IdleCPUSeconds"; */
+/* 		down_cpu = "DownCPUSeconds"; */
+/* 		resv_cpu = "ReservedCPUSeconds"; */
+/* 		break; */
+/* 	case ACCT_USAGE_MONTH: */
+/* 		g_object = GOLD_OBJECT_MACHINE_MONTH_USAGE; */
+/* 		alloc_cpu = "AllocatedCPUHours"; */
+/* 		idle_cpu = "IdleCPUHours"; */
+/* 		down_cpu = "DownCPUHours"; */
+/* 		resv_cpu = "ReservedCPUHours"; */
+/* 		break; */
+/* 	default: */
+/* 		error("Unknown usage type"); */
+/* 		return rc; */
+/* 	} */
+/* 	/\* get the last known one *\/ */
+/* 	gold_request = create_gold_request(GOLD_OBJECT_MACHINE_HOUR_USAGE, */
+/* 					   GOLD_ACTION_QUERY); */
+/* 	if(!gold_request)  */
+/* 		return rc; */
+
+/* 	gold_request_add_condition(gold_request, "Machine", cluster_rec->name, */
+/* 				   GOLD_OPERATOR_NONE, 0); */
+/* 	if(start) { */
+/* 		snprintf(tmp_buff, sizeof(tmp_buff), "%d", (int)start); */
+/* 		gold_request_add_condition(gold_request, "PeriodStart", */
+/* 					   tmp_buff, */
+/* 					   GOLD_OPERATOR_GE, 0); */
+/* 	} */
+/* 	if(end) {	 */
+/* 		snprintf(tmp_buff, sizeof(tmp_buff), "%u", (int)end); */
+/* 		gold_request_add_condition(gold_request, "PeriodStart", */
+/* 					   tmp_buff, */
+/* 					   GOLD_OPERATOR_L, 0); */
+/* 	} */
+
+/* 	gold_request_add_selection(gold_request, "CPUCount"); */
+/* 	gold_request_add_selection(gold_request, "PeriodStart"); */
+/* 	gold_request_add_selection(gold_request, idle_cpu); */
+/* 	gold_request_add_selection(gold_request, down_cpu); */
+/* 	gold_request_add_selection(gold_request, alloc_cpu); */
+/* 	gold_request_add_selection(gold_request, resv_cpu); */
+		
+/* 	gold_response = get_gold_response(gold_request);	 */
+/* 	destroy_gold_request(gold_request); */
+
+/* 	if(!gold_response) { */
+/* 		error("clusteracct_p_get_hourly_usage: no response received"); */
+/* 		return rc; */
+/* 	} */
+
+/* 	if(gold_response->entry_cnt > 0) { */
+/* 		rc = _get_cluster_accounting_list_from_response( */
+/* 			gold_response, cluster_rec); */
+/* 	} else { */
+/* 		debug("We don't have an entry for this machine for this time"); */
+/* 	} */
+/* 	destroy_gold_response(gold_response); */
+
+	return rc;
+}
+
+extern int jobacct_storage_p_job_start(void *db_conn,
+				       struct job_record *job_ptr)
+{
+	gold_object_t action = GOLD_ACTION_CREATE;
+	
+	if(_check_for_job(job_ptr->job_id, job_ptr->details->submit_time)) {
+		debug3("It looks like this job is already in GOLD.");
+		action = GOLD_ACTION_MODIFY;
+	}
+
+	return _add_edit_job(job_ptr, action);
+}
+
+extern int jobacct_storage_p_job_complete(void *db_conn,
+					  struct job_record *job_ptr) 
+{
+	gold_object_t action = GOLD_ACTION_MODIFY;
+	
+	if(!_check_for_job(job_ptr->job_id, job_ptr->details->submit_time)) {
+		error("Couldn't find this job entry.  "
+		      "This shouldn't happen, we are going to create one.");
+		action = GOLD_ACTION_CREATE;
+	}
+
+	return _add_edit_job(job_ptr, action);
+}
+
+extern int jobacct_storage_p_step_start(void *db_conn,
+					struct step_record *step)
+{
+	gold_object_t action = GOLD_ACTION_MODIFY;
+	
+	if(!_check_for_job(step->job_ptr->job_id,
+			   step->job_ptr->details->submit_time)) {
+		error("Couldn't find this job entry.  "
+		      "This shouldn't happen, we are going to create one.");
+		action = GOLD_ACTION_CREATE;
+	}
+
+	return _add_edit_job(step->job_ptr, action);
+
+}
+
+extern int jobacct_storage_p_step_complete(void *db_conn,
+					   struct step_record *step)
+{
+	return SLURM_SUCCESS;	
+}
+
+extern int jobacct_storage_p_suspend(void *db_conn,
+				     struct job_record *job_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * get info from the storage 
+ * returns List of jobacct_job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_p_get_jobs(void *db_conn,
+				       List selected_steps,
+				       List selected_parts,
+				       sacct_parameters_t *params)
+{
+	gold_request_t *gold_request = create_gold_request(GOLD_OBJECT_JOB,
+							   GOLD_ACTION_QUERY);
+	gold_response_t *gold_response = NULL;
+	gold_response_entry_t *resp_entry = NULL;
+	gold_name_value_t *name_val = NULL;
+	char tmp_buff[50];
+	int set = 0;
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	jobacct_job_rec_t *job = NULL;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	List job_list = NULL;
+
+	if(!gold_request) 
+		return NULL;
+
+
+	if(selected_steps && list_count(selected_steps)) {
+		itr = list_iterator_create(selected_steps);
+		if(list_count(selected_steps) > 1)
+			set = 2;
+		else
+			set = 0;
+		while((selected_step = list_next(itr))) {
+			snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
+				 selected_step->jobid);
+			gold_request_add_condition(gold_request, "JobId",
+						   tmp_buff,
+						   GOLD_OPERATOR_NONE,
+						   set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		if(list_count(selected_parts) > 1)
+			set = 2;
+		else
+			set = 0;
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			gold_request_add_condition(gold_request, "Partition",
+						   selected_part,
+						   GOLD_OPERATOR_NONE,
+						   set);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+	}
+
+	gold_request_add_selection(gold_request, "JobId");
+	gold_request_add_selection(gold_request, "GoldAccountId");
+	gold_request_add_selection(gold_request, "Partition");
+	gold_request_add_selection(gold_request, "RequestedCPUCount");
+	gold_request_add_selection(gold_request, "AllocatedCPUCount");
+	gold_request_add_selection(gold_request, "NodeList");
+	gold_request_add_selection(gold_request, "JobName");
+	gold_request_add_selection(gold_request, "SubmitTime");
+	gold_request_add_selection(gold_request, "EligibleTime");
+	gold_request_add_selection(gold_request, "StartTime");
+	gold_request_add_selection(gold_request, "EndTime");
+	gold_request_add_selection(gold_request, "Suspended");
+	gold_request_add_selection(gold_request, "State");
+	gold_request_add_selection(gold_request, "ExitCode");
+	gold_request_add_selection(gold_request, "QoS");
+
+	gold_response = get_gold_response(gold_request);
+	destroy_gold_request(gold_request);
+
+	if(!gold_response) {
+		error("_check_for_job: no response received");
+		return NULL;
+	}
+	
+	job_list = list_create(destroy_jobacct_job_rec);
+	if(gold_response->entry_cnt > 0) {
+		itr = list_iterator_create(gold_response->entries);
+		while((resp_entry = list_next(itr))) {
+			job = create_jobacct_job_rec();
+			itr2 = list_iterator_create(resp_entry->name_val);
+			while((name_val = list_next(itr2))) {
+				if(!strcmp(name_val->name, "JobId")) {
+					job->jobid = atoi(name_val->value);
+				} else if(!strcmp(name_val->name, 
+						  "GoldAccountId")) {
+					acct_association_rec_t account_rec;
+					memset(&account_rec, 0,
+					       sizeof(acct_association_rec_t));
+					account_rec.id = atoi(name_val->value);
+					/* FIX ME: We need to get the
+					 * parts of the association from
+					 * gold here
+					 */
+	/* 				if(acct_storage_p_get_assoc_id( */
+/* 						   db_conn, */
+/* 						   &account_rec) == SLURM_ERROR) */
+/* 						error("no assoc found for " */
+/* 						      "id %u", */
+/* 						      account_rec.id); */
+					
+					if(account_rec.cluster) {
+						if(params->opt_cluster &&
+						   strcmp(params->opt_cluster,
+							  account_rec.
+							  cluster)) {
+							destroy_jobacct_job_rec(
+								job);
+							job = NULL;
+							break;
+						}
+						job->cluster =
+							xstrdup(account_rec.
+								cluster);
+					}
+
+					if(account_rec.user) {
+						struct passwd *passwd_ptr =
+							getpwnam(account_rec.
+								 user);
+						job->user = xstrdup(account_rec.
+								    user);
+						if(passwd_ptr) {
+							job->uid =
+								passwd_ptr->
+								pw_uid;
+							job->gid = 
+								passwd_ptr->
+								pw_gid;
+						}
+					}
+					if(account_rec.acct) 
+						job->account =
+							xstrdup(account_rec.
+								acct);
+				} else if(!strcmp(name_val->name,
+						  "Partition")) {
+					job->partition =
+						xstrdup(name_val->value);
+				} else if(!strcmp(name_val->name,
+						  "RequestedCPUCount")) {
+					job->req_cpus = atoi(name_val->value);
+				} else if(!strcmp(name_val->name,
+						  "AllocatedCPUCount")) {
+					job->alloc_cpus = atoi(name_val->value);
+				} else if(!strcmp(name_val->name, "NodeList")) {
+					job->nodes = xstrdup(name_val->value);
+				} else if(!strcmp(name_val->name, "JobName")) {
+					job->jobname = xstrdup(name_val->value);
+				} else if(!strcmp(name_val->name,
+						  "SubmitTime")) {
+					job->submit = atoi(name_val->value);
+				} else if(!strcmp(name_val->name,
+						  "EligibleTime")) {
+					job->eligible = atoi(name_val->value);
+				} else if(!strcmp(name_val->name,
+						  "StartTime")) {
+					job->start = atoi(name_val->value);
+				} else if(!strcmp(name_val->name, "EndTime")) {
+					job->end = atoi(name_val->value);
+				} else if(!strcmp(name_val->name,
+						  "Suspended")) {
+					job->suspended = atoi(name_val->value);
+				} else if(!strcmp(name_val->name, "State")) {
+					job->state = atoi(name_val->value);
+				} else if(!strcmp(name_val->name, "ExitCode")) {
+					job->exitcode = atoi(name_val->value);
+				} else if(!strcmp(name_val->name, "QoS")) {
+					job->qos = atoi(name_val->value);
+				}
+			}
+			list_iterator_destroy(itr2);
+
+			if(!job) 
+				continue;
+
+			job->show_full = 1;
+			job->track_steps = 0;
+			job->priority = 0;
+
+			if (!job->nodes) 
+				job->nodes = xstrdup("(unknown)");
+			
+			list_append(job_list, job);
+		}
+		list_iterator_destroy(itr);		
+	}
+	destroy_gold_response(gold_response);
+	
+	return job_list;
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void jobacct_storage_p_archive(void *db_conn,
+				      List selected_parts,
+				      void *params)
+{
+	info("not implemented");
+	
+	return;
+}
+
+extern int acct_storage_p_update_shares_used(void *db_conn,
+					     List shares_used)
+{
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/accounting_storage/mysql/Makefile.am b/src/plugins/accounting_storage/mysql/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..a34ba8aa8716e77c5ab17b49ab2af51b70d95f00
--- /dev/null
+++ b/src/plugins/accounting_storage/mysql/Makefile.am
@@ -0,0 +1,21 @@
+# Makefile for accounting_storage/mysql plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = accounting_storage_mysql.la
+
+# Mysql storage plugin.
+accounting_storage_mysql_la_SOURCES = accounting_storage_mysql.c \
+		mysql_jobacct_process.c mysql_jobacct_process.h \
+		mysql_rollup.c mysql_rollup.h
+accounting_storage_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+accounting_storage_mysql_la_CFLAGS = $(MYSQL_CFLAGS)
+accounting_storage_mysql_la_LIBADD = \
+	$(top_builddir)/src/database/libslurm_mysql.la $(MYSQL_LIBS)
+accounting_storage_mysql_la_DEPENDENCIES = \
+	$(top_builddir)/src/database/libslurm_mysql.la
+
diff --git a/src/plugins/accounting_storage/mysql/Makefile.in b/src/plugins/accounting_storage/mysql/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..2a69a97b1393b500efd12cb0d950069ebc348c02
--- /dev/null
+++ b/src/plugins/accounting_storage/mysql/Makefile.in
@@ -0,0 +1,593 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for accounting_storage/mysql plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/accounting_storage/mysql
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+am_accounting_storage_mysql_la_OBJECTS =  \
+	accounting_storage_mysql_la-accounting_storage_mysql.lo \
+	accounting_storage_mysql_la-mysql_jobacct_process.lo \
+	accounting_storage_mysql_la-mysql_rollup.lo
+accounting_storage_mysql_la_OBJECTS =  \
+	$(am_accounting_storage_mysql_la_OBJECTS)
+accounting_storage_mysql_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) \
+	$(accounting_storage_mysql_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(accounting_storage_mysql_la_SOURCES)
+DIST_SOURCES = $(accounting_storage_mysql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = accounting_storage_mysql.la
+
+# Mysql storage plugin.
+accounting_storage_mysql_la_SOURCES = accounting_storage_mysql.c \
+		mysql_jobacct_process.c mysql_jobacct_process.h \
+		mysql_rollup.c mysql_rollup.h
+
+accounting_storage_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+accounting_storage_mysql_la_CFLAGS = $(MYSQL_CFLAGS)
+accounting_storage_mysql_la_LIBADD = \
+	$(top_builddir)/src/database/libslurm_mysql.la $(MYSQL_LIBS)
+
+accounting_storage_mysql_la_DEPENDENCIES = \
+	$(top_builddir)/src/database/libslurm_mysql.la
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/accounting_storage/mysql/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/accounting_storage/mysql/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+accounting_storage_mysql.la: $(accounting_storage_mysql_la_OBJECTS) $(accounting_storage_mysql_la_DEPENDENCIES) 
+	$(accounting_storage_mysql_la_LINK) -rpath $(pkglibdir) $(accounting_storage_mysql_la_OBJECTS) $(accounting_storage_mysql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_mysql_la-accounting_storage_mysql.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_mysql_la-mysql_jobacct_process.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+accounting_storage_mysql_la-accounting_storage_mysql.lo: accounting_storage_mysql.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -MT accounting_storage_mysql_la-accounting_storage_mysql.lo -MD -MP -MF $(DEPDIR)/accounting_storage_mysql_la-accounting_storage_mysql.Tpo -c -o accounting_storage_mysql_la-accounting_storage_mysql.lo `test -f 'accounting_storage_mysql.c' || echo '$(srcdir)/'`accounting_storage_mysql.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/accounting_storage_mysql_la-accounting_storage_mysql.Tpo $(DEPDIR)/accounting_storage_mysql_la-accounting_storage_mysql.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='accounting_storage_mysql.c' object='accounting_storage_mysql_la-accounting_storage_mysql.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -c -o accounting_storage_mysql_la-accounting_storage_mysql.lo `test -f 'accounting_storage_mysql.c' || echo '$(srcdir)/'`accounting_storage_mysql.c
+
+accounting_storage_mysql_la-mysql_jobacct_process.lo: mysql_jobacct_process.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -MT accounting_storage_mysql_la-mysql_jobacct_process.lo -MD -MP -MF $(DEPDIR)/accounting_storage_mysql_la-mysql_jobacct_process.Tpo -c -o accounting_storage_mysql_la-mysql_jobacct_process.lo `test -f 'mysql_jobacct_process.c' || echo '$(srcdir)/'`mysql_jobacct_process.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/accounting_storage_mysql_la-mysql_jobacct_process.Tpo $(DEPDIR)/accounting_storage_mysql_la-mysql_jobacct_process.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mysql_jobacct_process.c' object='accounting_storage_mysql_la-mysql_jobacct_process.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -c -o accounting_storage_mysql_la-mysql_jobacct_process.lo `test -f 'mysql_jobacct_process.c' || echo '$(srcdir)/'`mysql_jobacct_process.c
+
+accounting_storage_mysql_la-mysql_rollup.lo: mysql_rollup.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -MT accounting_storage_mysql_la-mysql_rollup.lo -MD -MP -MF $(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Tpo -c -o accounting_storage_mysql_la-mysql_rollup.lo `test -f 'mysql_rollup.c' || echo '$(srcdir)/'`mysql_rollup.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Tpo $(DEPDIR)/accounting_storage_mysql_la-mysql_rollup.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mysql_rollup.c' object='accounting_storage_mysql_la-mysql_rollup.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_mysql_la_CFLAGS) $(CFLAGS) -c -o accounting_storage_mysql_la-mysql_rollup.lo `test -f 'mysql_rollup.c' || echo '$(srcdir)/'`mysql_rollup.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
new file mode 100644
index 0000000000000000000000000000000000000000..21aeaf65d5072b2e53af514cc0525008f097b653
--- /dev/null
+++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
@@ -0,0 +1,5468 @@
+/*****************************************************************************\
+ *  accounting_storage_mysql.c - accounting interface to mysql.
+ *
+ *  $Id: accounting_storage_mysql.c 13061 2008-01-22 21:23:56Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *****************************************************************************
+ * Notes on mysql configuration 
+ *	Assumes mysql is installed as user root
+ *	Assumes SlurmUser is configured as user slurm
+ * # mysqladmin create <db_name>
+ *	The <db_name> goes into slurmdbd.conf as StorageLoc
+ * # mysql --user=root -p
+ * mysql> GRANT ALL ON *.* TO 'slurm'@'localhost' IDENTIFIED BY PASSWORD 'pw';
+ * mysql> GRANT SELECT, INSERT ON *.* TO 'slurm'@'localhost';
+\*****************************************************************************/
+
+#include <strings.h>
+#include "mysql_jobacct_process.h"
+#include "mysql_rollup.h"
+#include "src/common/slurmdbd_defs.h"
+#include "src/common/slurm_auth.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "accounting_storage" for SLURM job completion
+ * logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "accounting_storage/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Accounting storage MYSQL plugin";
+const char plugin_type[] = "accounting_storage/mysql";
+const uint32_t plugin_version = 100;
+
+#ifdef HAVE_MYSQL
+
+static mysql_db_info_t *mysql_db_info = NULL;
+static char *mysql_db_name = NULL;
+
+#define DEFAULT_ACCT_DB "slurm_acct_db"
+#define DELETE_SEC_BACK 86400
+
+char *acct_coord_table = "acct_coord_table";
+char *acct_table = "acct_table";
+char *assoc_day_table = "assoc_day_usage_table";
+char *assoc_hour_table = "assoc_hour_usage_table";
+char *assoc_month_table = "assoc_month_usage_table";
+char *assoc_table = "assoc_table";
+char *cluster_day_table = "cluster_day_usage_table";
+char *cluster_hour_table = "cluster_hour_usage_table";
+char *cluster_month_table = "cluster_month_usage_table";
+char *cluster_table = "cluster_table";
+char *event_table = "cluster_event_table";
+char *job_table = "job_table";
+char *step_table = "step_table";
+char *txn_table = "txn_table";
+char *user_table = "user_table";
+char *last_ran_table = "last_ran_table";
+char *suspend_table = "suspend_table";
+
+extern int acct_storage_p_commit(mysql_conn_t *mysql_conn, bool commit);
+
+extern int acct_storage_p_add_associations(mysql_conn_t *mysql_conn,
+					   uint32_t uid, 
+					   List association_list);
+extern List acct_storage_p_get_associations(mysql_conn_t *mysql_conn, 
+					    acct_association_cond_t *assoc_q);
+
+/* This function will take the object given and free it later so it
+ * needed to be removed from a list if in one before 
+ */
+static int _addto_update_list(List update_list, acct_update_type_t type,
+			      void *object)
+{
+	acct_update_object_t *update_object = NULL;
+	ListIterator itr = NULL;
+	if(!update_list) {
+		error("no update list given");
+		return SLURM_ERROR;
+	}
+
+	itr = list_iterator_create(update_list);
+	while((update_object = list_next(itr))) {
+		if(update_object->type == type)
+			break;
+	}
+	list_iterator_destroy(itr);
+
+	if(update_object) {
+		list_append(update_object->objects, object);
+		return SLURM_SUCCESS;
+	} 
+	update_object = xmalloc(sizeof(acct_update_object_t));
+
+	list_append(update_list, update_object);
+
+	update_object->type = type;
+	
+	switch(type) {
+	case ACCT_MODIFY_USER:
+	case ACCT_ADD_USER:
+	case ACCT_REMOVE_USER:
+		update_object->objects = list_create(destroy_acct_user_rec);
+		break;
+	case ACCT_ADD_ASSOC:
+	case ACCT_MODIFY_ASSOC:
+	case ACCT_REMOVE_ASSOC:
+		update_object->objects = list_create(
+			destroy_acct_association_rec);
+		break;
+	case ACCT_UPDATE_NOTSET:
+	default:
+		error("unknown type set in update_object: %d", type);
+		return SLURM_ERROR;
+	}
+	list_append(update_object->objects, object);
+	return SLURM_SUCCESS;
+}
+
+static int _move_account(mysql_conn_t *mysql_conn, uint32_t lft, uint32_t rgt,
+			 char *cluster,
+			 char *id, char *parent)
+{
+/*
+  tested sql...
+
+  SELECT @parLeft := lft from assoc_table where cluster='name' && acct='new parent' && user='';
+
+  SELECT @oldLeft := lft, @oldRight := rgt, @myWidth := (rgt - lft + 1), @myDiff := (@parLeft+1) - lft FROM assoc_table WHERE id = 'account id';
+
+  update assoc_table set deleted = deleted + 2, lft = lft + @myDiff, rgt = rgt + @myDiff WHERE lft BETWEEN @oldLeft AND @oldRight;
+
+  UPDATE assoc_table SET rgt = rgt + @myWidth WHERE rgt > @parLeft && deleted < 2;
+  UPDATE assoc_table SET lft = lft + @myWidth WHERE lft > @parLeft && deleted < 2;
+
+  UPDATE assoc_table SET rgt = rgt - @myWidth WHERE (@myDiff < 0 && rgt > @oldRight && deleted < 2) || (@myDiff >= 0 && rgt > @oldLeft);
+  UPDATE assoc_table SET lft = lft - @myWidth WHERE (@myDiff < 0 && lft > @oldRight && deleted < 2) || (@myDiff >= 0 && lft > @oldLeft);
+
+  update assoc_table set deleted = deleted - 2 WHERE deleted > 1;
+	   
+  update assoc_table set parent_acct='new parent' where id = 'account id';
+
+*/
+	int rc = SLURM_SUCCESS;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	int par_left = 0;
+	int diff = 0;
+	int width = 0;
+	char *query = xstrdup_printf(
+		"SELECT lft from %s " 
+		"where cluster='%s' && acct='%s' && user='';",
+		assoc_table,
+		cluster, parent);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+	if(!(row = mysql_fetch_row(result))) {
+		error("no row");
+		mysql_free_result(result);
+		return SLURM_ERROR;
+	}
+	par_left = atoi(row[0]);
+	mysql_free_result(result);
+	
+	width = (rgt - lft + 1);
+	diff = ((par_left + 1) - lft);
+	
+	xstrfmtcat(query,
+		   "update %s set deleted = deleted + 2, "
+		   "lft = lft + %d, rgt = rgt + %d "
+		   "WHERE lft BETWEEN %u AND %u;",
+		   assoc_table, diff, diff, lft, rgt);
+
+	xstrfmtcat(query,
+		   "UPDATE %s SET rgt = rgt + %d WHERE "
+		   "rgt > %d && deleted < 2;"
+		   "UPDATE %s SET lft = lft + %d WHERE "
+		   "lft > %d && deleted < 2;",
+		   assoc_table, width,
+		   par_left,
+		   assoc_table, width,
+		   par_left);
+
+	xstrfmtcat(query,
+		   "UPDATE %s SET rgt = rgt - %d WHERE "
+		   "(%d < 0 && rgt > %u && deleted < 2) "
+		   "|| (%d >= 0 && rgt > %u);"
+		   "UPDATE %s SET lft = lft - %d WHERE "
+		   "(%d < 0 && lft > %u && deleted < 2) "
+		   "|| (%d >= 0 && lft > %u);",
+		   assoc_table, width,
+		   diff, rgt,
+		   diff, lft,
+		   assoc_table, width,
+		   diff, rgt,
+		   diff, lft);
+
+	xstrfmtcat(query,
+		   "update %s set deleted = deleted - 2 WHERE deleted > 1;",
+		   assoc_table);
+	xstrfmtcat(query,
+		   "update %s set parent_acct='%s' where id = %s;",
+		   assoc_table, parent, id);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+
+	return rc;
+}
+
+static int _move_parent(mysql_conn_t *mysql_conn, uint32_t lft, uint32_t rgt,
+			char *cluster,
+			char *id, char *old_parent, char *new_parent)
+{
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	char *query = NULL;
+	int rc = SLURM_SUCCESS;
+	List assoc_list = NULL;
+	ListIterator itr = NULL;
+	acct_association_rec_t *assoc = NULL;
+		
+	/* first we need to see if we are
+	 * going to make a child of this
+	 * account the new parent.  If so we
+	 * need to move that child to this
+	 * accounts parent and then do the move 
+	 */
+	query = xstrdup_printf(
+		"select id, lft, rgt from %s where lft between %d and %d "
+		"&& acct='%s' && user='' order by lft;",
+		assoc_table, lft, rgt,
+		new_parent);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = 
+	     mysql_db_query_ret(mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	if((row = mysql_fetch_row(result))) {
+		debug4("%s(%s) %s,%s is a child of %s",
+		       new_parent, row[0], row[1], row[2], id);
+		rc = _move_account(mysql_conn, atoi(row[1]), atoi(row[2]),
+				  cluster, row[0], old_parent);
+	}
+
+	mysql_free_result(result);
+
+	if(rc == SLURM_ERROR) 
+		return rc;
+	
+	/* now move the one we wanted to move in the first place */
+	rc = _move_account(mysql_conn, lft, rgt, cluster, id, new_parent);
+
+	if(rc == SLURM_ERROR) 
+		return rc;
+
+	/* now we need to send the update of the new parents and
+	 * limits, so just to be safe, send the whole tree
+	 */
+	assoc_list = acct_storage_p_get_associations(mysql_conn, NULL);
+	/* NOTE: you can not use list_pop, or list_push
+	   anywhere either, since mysql is
+	   exporting something of the same type as a macro,
+	   which messes everything up (my_list.h is the bad boy).
+	   So we are just going to delete each item as it
+	   comes out since we are moving it to the update_list.
+	*/
+	itr = list_iterator_create(assoc_list);
+	while((assoc = list_next(itr))) {
+		if(_addto_update_list(mysql_conn->update_list, 
+				      ACCT_MODIFY_ASSOC,
+				      assoc) == SLURM_SUCCESS) 
+			list_remove(itr);
+	}
+	list_iterator_destroy(itr);
+	list_destroy(assoc_list);
+	return rc;
+}
+
+static int _last_affected_rows(MYSQL *mysql_db)
+{
+	int status=0, rows=0;
+	MYSQL_RES *result = NULL;
+
+	do {
+		result = mysql_store_result(mysql_db);
+		if (result) 
+			mysql_free_result(result);
+		else 
+			if (mysql_field_count(mysql_db) == 0) {
+				status = mysql_affected_rows(mysql_db);
+				if(status > 0)
+					rows = status;
+			}
+		if ((status = mysql_next_result(mysql_db)) > 0)
+			debug3("Could not execute statement\n");
+	} while (status == 0);
+	
+	return rows;
+}
+
+static int _modify_common(mysql_conn_t *mysql_conn,
+			  uint16_t type,
+			  time_t now,
+			  char *user_name,
+			  char *table,
+			  char *cond_char,
+			  char *vals) 
+{
+	char *query = NULL;
+	int rc = SLURM_SUCCESS;
+
+	xstrfmtcat(query, 
+		   "update %s set mod_time=%d%s "
+		   "where deleted=0 && %s;",
+		   table, now, vals,
+		   cond_char);
+	xstrfmtcat(query, 	
+		   "insert into %s "
+		   "(timestamp, action, name, actor, info) "
+		   "values (%d, %d, \"%s\", '%s', \"%s\");",
+		   txn_table,
+		   now, type, cond_char, user_name, vals);
+	debug3("%d query\n%s", mysql_conn->conn, query);		
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+
+	if(rc != SLURM_SUCCESS) {
+		if(mysql_conn->rollback) {
+			mysql_db_rollback(mysql_conn->acct_mysql_db);
+		}
+		list_flush(mysql_conn->update_list);
+		
+		return SLURM_ERROR;
+	}
+
+	return SLURM_SUCCESS;
+}
+static int _modify_unset_users(mysql_conn_t *mysql_conn,
+			       acct_association_rec_t *assoc,
+			       char *acct,
+			       uint32_t lft, uint32_t rgt,
+			       List ret_list)
+{
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	char *query = NULL, *object = NULL;
+	int i;
+
+	char *assoc_req_inx[] = {
+		"id",
+		"user",
+		"acct",
+		"cluster",
+		"partition",
+		"max_jobs",
+		"max_nodes_per_job",
+		"max_wall_duration_per_job",
+		"max_cpu_secs_per_job",
+		"lft",
+		"rgt"
+	};
+	
+	enum {
+		ASSOC_ID,
+		ASSOC_USER,
+		ASSOC_ACCT,
+		ASSOC_CLUSTER,
+		ASSOC_PART,
+		ASSOC_MJ,
+		ASSOC_MNPJ,
+		ASSOC_MWPJ,
+		ASSOC_MCPJ,
+		ASSOC_LFT,
+		ASSOC_RGT,
+		ASSOC_COUNT
+	};
+
+	if(!ret_list || !acct)
+		return SLURM_ERROR;
+
+	for(i=0; i<ASSOC_COUNT; i++) {
+		if(i) 
+			xstrcat(object, ", ");
+		xstrcat(object, assoc_req_inx[i]);
+	}
+
+	query = xstrdup_printf("select distinct %s from %s where deleted=0 "
+			       "&& lft between %d and %d && "
+			       "((user = '' && parent_acct = '%s') || "
+			       "(user != '' && acct = '%s')) "
+			       "order by lft;",
+			       object, assoc_table, lft, rgt, acct, acct);
+/* 	query = xstrdup_printf("select distinct %s from %s where deleted=0 " */
+/* 			       "&& lft between %d and %d and user != ''" */
+/* 			       "order by lft;", */
+/* 			       object, assoc_table, lft, rgt); */
+	xfree(object);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result =
+	     mysql_db_query_ret(mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	while((row = mysql_fetch_row(result))) {
+		acct_association_rec_t *mod_assoc = NULL;
+		int modified = 0;
+
+		mod_assoc = xmalloc(sizeof(acct_association_rec_t));
+		mod_assoc->id = atoi(row[ASSOC_ID]);
+
+		if(!row[ASSOC_MJ] && assoc->max_jobs != (uint32_t)NO_VAL) {
+			mod_assoc->max_jobs = assoc->max_jobs;
+			modified = 1;
+		} else
+			mod_assoc->max_jobs = (uint32_t)NO_VAL;
+		
+		if(!row[ASSOC_MNPJ] &&
+		   assoc->max_nodes_per_job != (uint32_t)NO_VAL) {
+			mod_assoc->max_nodes_per_job =
+				assoc->max_nodes_per_job;
+			modified = 1;
+		} else 
+			mod_assoc->max_nodes_per_job = (uint32_t)NO_VAL;
+
+		
+		if(!row[ASSOC_MWPJ] && 
+		   assoc->max_wall_duration_per_job != (uint32_t)NO_VAL) {
+			mod_assoc->max_wall_duration_per_job =
+				assoc->max_wall_duration_per_job;
+			modified = 1;
+		} else 
+			mod_assoc->max_wall_duration_per_job = (uint32_t)NO_VAL;
+					
+		if(!row[ASSOC_MCPJ] && 
+		   assoc->max_cpu_secs_per_job != (uint32_t)NO_VAL) {
+			mod_assoc->max_cpu_secs_per_job = 
+				assoc->max_cpu_secs_per_job;
+			modified = 1;
+		} else
+			mod_assoc->max_cpu_secs_per_job = (uint32_t)NO_VAL;
+		
+
+		if(modified) {
+			if(!row[ASSOC_USER][0]) {
+				_modify_unset_users(mysql_conn,
+						    mod_assoc,
+						    row[ASSOC_ACCT],
+						    atoi(row[ASSOC_LFT]),
+						    atoi(row[ASSOC_RGT]),
+						    ret_list);
+				destroy_acct_association_rec(mod_assoc);
+				continue;
+			}
+
+			mod_assoc->fairshare = (uint32_t)NO_VAL;
+			if(row[ASSOC_PART][0]) { 
+				// see if there is a partition name
+				object = xstrdup_printf(
+					"C = %-10s A = %-20s U = %-9s P = %s",
+					row[ASSOC_CLUSTER], row[ASSOC_ACCT],
+					row[ASSOC_USER], row[ASSOC_PART]);
+			} else {
+				object = xstrdup_printf(
+					"C = %-10s A = %-20s U = %-9s",
+					row[ASSOC_CLUSTER], 
+					row[ASSOC_ACCT], 
+					row[ASSOC_USER]);
+			}
+			
+			list_append(ret_list, object);
+			
+			if(_addto_update_list(mysql_conn->update_list, 
+					      ACCT_MODIFY_ASSOC,
+					      mod_assoc) != SLURM_SUCCESS) 
+				error("couldn't add to the update list");
+		} else {
+			xfree(mod_assoc);
+		}
+	}
+	mysql_free_result(result);
+
+	return SLURM_SUCCESS;
+}
+
+
+
+/* Every option in assoc_char should have a 't1.' infront of it. */
+static int _remove_common(mysql_conn_t *mysql_conn,
+			  uint16_t type,
+			  time_t now,
+			  char *user_name,
+			  char *table,
+			  char *name_char,
+			  char *assoc_char) 
+{
+	int rc = SLURM_SUCCESS;
+	char *query = NULL;
+	char *loc_assoc_char = NULL;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	time_t day_old = now - DELETE_SEC_BACK;
+
+	/* we want to remove completely all that is less than a day old */
+	if(table != assoc_table) {
+		query = xstrdup_printf("delete from %s where creation_time>%d "
+				       "&& (%s);",
+				       table, day_old, name_char);
+	}
+
+	xstrfmtcat(query,
+		   "update %s set mod_time=%d, deleted=1 "
+		   "where deleted=0 && (%s);",
+		   table, now, name_char);
+	xstrfmtcat(query, 	
+		   "insert into %s (timestamp, action, name, actor) "
+		   "values (%d, %d, \"%s\", '%s');",
+		   txn_table,
+		   now, type, name_char, user_name);
+
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	if(rc != SLURM_SUCCESS) {
+		if(mysql_conn->rollback) {
+			mysql_db_rollback(mysql_conn->acct_mysql_db);
+		}
+		list_flush(mysql_conn->update_list);
+		
+		return SLURM_ERROR;
+	}
+
+	/* mark deleted=1 or remove completely the
+	   accounting tables
+	*/
+	if(table != assoc_table) {
+		if(!assoc_char) {
+			error("no assoc_char");
+			if(mysql_conn->rollback) {
+				mysql_db_rollback(mysql_conn->acct_mysql_db);
+			}
+			list_destroy(mysql_conn->update_list);
+			mysql_conn->update_list =
+				list_create(destroy_acct_update_object);
+			return SLURM_ERROR;
+		}
+
+		/* If we are doing this on an assoc_table we have
+		   already done this, so don't */
+/* 		query = xstrdup_printf("select lft, rgt " */
+/* 				       "from %s as t2 where %s order by lft;", */
+/* 				       assoc_table, assoc_char); */
+		query = xstrdup_printf("select distinct t1.id "
+				       "from %s as t1, %s as t2 "
+				       "where %s && t1.lft between "
+				       "t2.lft and t2.rgt;",
+				       assoc_table, assoc_table, assoc_char);
+		
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		if(!(result = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			if(mysql_conn->rollback) {
+				mysql_db_rollback(mysql_conn->acct_mysql_db);
+			}
+			list_destroy(mysql_conn->update_list);
+			mysql_conn->update_list =
+				list_create(destroy_acct_update_object);
+			return SLURM_ERROR;
+		}
+		xfree(query);
+
+		rc = 0;
+		loc_assoc_char = NULL;
+		while((row = mysql_fetch_row(result))) {
+			acct_association_rec_t *rem_assoc = NULL;
+			if(!rc) {
+				xstrfmtcat(loc_assoc_char, "id=%s", row[0]);
+				rc = 1;
+			} else {
+				xstrfmtcat(loc_assoc_char,
+					   " || id=%s", row[0]);
+			}
+			rem_assoc = xmalloc(sizeof(acct_association_rec_t));
+			rem_assoc->id = atoi(row[0]);
+			if(_addto_update_list(mysql_conn->update_list, 
+					      ACCT_REMOVE_ASSOC,
+					      rem_assoc) != SLURM_SUCCESS) 
+				error("couldn't add to the update list");
+		}
+		mysql_free_result(result);
+	} else 
+		loc_assoc_char = assoc_char;
+
+/* 	query = xstrdup_printf( */
+/* 		"delete t2 from %s as t2, %s as t1 where t1.creation_time>%d && (%s);" */
+/* 		"delete t2 from %s as t2, %s as t1 where t1.creation_time>%d && (%s);" */
+/* 		"delete t2 from %s as t2, %s as t1 where t1.creation_time>%d && (%s);", */
+/* 		assoc_day_table, assoc_table, day_old, loc_assoc_char, */
+/* 		assoc_hour_table, assoc_table, day_old, loc_assoc_char, */
+/* 		assoc_month_table, assoc_table, day_old, loc_assoc_char); */
+	query = xstrdup_printf(
+		"delete from %s where creation_time>%d && (%s);"
+		"delete from %s where creation_time>%d && (%s);"
+		"delete from %s where creation_time>%d && (%s);",
+		assoc_day_table, day_old, loc_assoc_char,
+		assoc_hour_table, day_old, loc_assoc_char,
+		assoc_month_table, day_old, loc_assoc_char);
+	xstrfmtcat(query,
+		   "update %s set mod_time=%d, deleted=1 where (%s);"
+		   "update %s set mod_time=%d, deleted=1 where (%s);"
+		   "update %s set mod_time=%d, deleted=1 where (%s);",
+		   assoc_day_table, now, loc_assoc_char,
+		   assoc_hour_table, now, loc_assoc_char,
+		   assoc_month_table, now, loc_assoc_char);
+
+	debug3("%d query\n%s %d", mysql_conn->conn, query, strlen(query));
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	if(rc != SLURM_SUCCESS) {
+		if(mysql_conn->rollback) {
+			mysql_db_rollback(mysql_conn->acct_mysql_db);
+		}
+		list_flush(mysql_conn->update_list);
+		return SLURM_ERROR;
+	}
+
+	/* remove completely all the associations for this added in the last
+	 * day, since they are most likely nothing we really wanted in
+	 * the first place.
+	 */
+	query = xstrdup_printf("select id from %s as t1 where "
+			       "creation_time>%d && (%s);",
+			       assoc_table, day_old, loc_assoc_char);
+	
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		if(mysql_conn->rollback) {
+			mysql_db_rollback(mysql_conn->acct_mysql_db);
+		}
+		list_flush(mysql_conn->update_list);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	/* we have to do this one at a time since the lft's and rgt's
+	   change */
+	while((row = mysql_fetch_row(result))) {
+		MYSQL_RES *result2 = NULL;
+		MYSQL_ROW row2;
+		
+		xstrfmtcat(query,
+			   "SELECT lft, rgt, (rgt - lft + 1) "
+			   "FROM %s WHERE id = %s;",
+			   assoc_table, row[0]);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		if(!(result2 = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			rc = SLURM_ERROR;
+			break;
+		}
+		xfree(query);
+		if(!(row2 = mysql_fetch_row(result2))) {
+			mysql_free_result(result2);
+			continue;
+		}
+
+		xstrfmtcat(query,
+			   "delete quick from %s where lft between "
+			   "%s AND %s;",
+			   assoc_table,
+			   row2[0], row2[1]);
+		xstrfmtcat(query,
+			   "UPDATE %s SET rgt = rgt - %s WHERE "
+			   "rgt > %s;"
+			   "UPDATE %s SET lft = lft - %s WHERE "
+			   "lft > %s;",
+			   assoc_table, row2[2],
+			   row2[1],
+			   assoc_table, row2[2], row2[1]);
+
+		mysql_free_result(result2);
+
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("couldn't remove assoc");
+			break;
+		}
+	}
+	mysql_free_result(result);
+	if(rc == SLURM_ERROR) {
+		if(mysql_conn->rollback) {
+			mysql_db_rollback(mysql_conn->acct_mysql_db);
+		}
+		list_flush(mysql_conn->update_list);
+		return rc;
+	}
+	
+	if(table == assoc_table)
+		return SLURM_SUCCESS;
+	
+	/* now update the associations themselves that are still around */
+	query = xstrdup_printf("update %s as t1 set mod_time=%d, deleted=1 "
+			       "where deleted=0 && (%s);",
+			       assoc_table, now,
+			       loc_assoc_char);
+	xfree(loc_assoc_char);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	if(rc != SLURM_SUCCESS) {
+		if(mysql_conn->rollback) {
+			mysql_db_rollback(mysql_conn->acct_mysql_db);
+		}
+		list_flush(mysql_conn->update_list);
+	}
+	
+	return rc;
+}
+
+static int _get_db_index(MYSQL *acct_mysql_db, 
+			 time_t submit, uint32_t jobid, uint32_t associd)
+{
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	int db_index = -1;
+	char *query = xstrdup_printf("select id from %s where "
+				     "submit=%d and jobid=%u and associd=%u",
+				     job_table, (int)submit, jobid, associd);
+
+	if(!(result = mysql_db_query_ret(acct_mysql_db, query, 0))) {
+		xfree(query);
+		return -1;
+	}
+	xfree(query);
+
+	row = mysql_fetch_row(result);
+	if(!row) {
+		mysql_free_result(result);
+		error("We can't get a db_index for this combo, "
+		      "submit=%d and jobid=%u and associd=%u.",
+		      (int)submit, jobid, associd);
+		return -1;
+	}
+	db_index = atoi(row[0]);
+	mysql_free_result(result);
+	
+	return db_index;
+}
+
+static mysql_db_info_t *_mysql_acct_create_db_info()
+{
+	mysql_db_info_t *db_info = xmalloc(sizeof(mysql_db_info_t));
+	db_info->port = slurm_get_accounting_storage_port();
+	if(!db_info->port) 
+		db_info->port = 3306;
+	db_info->host = slurm_get_accounting_storage_host();	
+	db_info->user = slurm_get_accounting_storage_user();	
+	db_info->pass = slurm_get_accounting_storage_pass();	
+	return db_info;
+}
+
+static int _mysql_acct_check_tables(MYSQL *acct_mysql_db)
+{
+	int rc = SLURM_SUCCESS;
+	storage_field_t acct_coord_table_fields[] = {
+		{ "deleted", "tinyint default 0" },
+		{ "acct", "tinytext not null" },
+		{ "user", "tinytext not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t acct_table_fields[] = {
+		{ "creation_time", "int unsigned not null" },
+		{ "mod_time", "int unsigned default 0 not null" },
+		{ "deleted", "tinyint default 0" },
+		{ "name", "tinytext not null" },
+		{ "description", "text not null" },
+		{ "organization", "text not null" },
+		{ "qos", "smallint default 1 not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t assoc_table_fields[] = {
+		{ "creation_time", "int unsigned not null" },
+		{ "mod_time", "int unsigned default 0 not null" },
+		{ "deleted", "tinyint default 0" },
+		{ "id", "int not null auto_increment" },
+		{ "user", "tinytext not null default ''" },
+		{ "acct", "tinytext not null" },
+		{ "cluster", "tinytext not null" },
+		{ "partition", "tinytext not null default ''" },
+		{ "parent_acct", "tinytext not null default ''" },
+		{ "lft", "int not null" },
+		{ "rgt", "int not null" },
+		{ "fairshare", "int default 1 not null" },
+		{ "max_jobs", "int default NULL" },
+		{ "max_nodes_per_job", "int default NULL" },
+		{ "max_wall_duration_per_job", "int default NULL" },
+		{ "max_cpu_secs_per_job", "int default NULL" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t assoc_usage_table_fields[] = {
+		{ "creation_time", "int unsigned not null" },
+		{ "mod_time", "int unsigned default 0 not null" },
+		{ "deleted", "tinyint default 0" },
+		{ "id", "int not null" },
+		{ "period_start", "int unsigned not null" },
+		{ "alloc_cpu_secs", "bigint default 0" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t cluster_table_fields[] = {
+		{ "creation_time", "int unsigned not null" },
+		{ "mod_time", "int unsigned default 0 not null" },
+		{ "deleted", "tinyint default 0" },
+		{ "name", "tinytext not null" },
+		{ "control_host", "tinytext not null default ''" },
+		{ "control_port", "mediumint not null default 0" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t cluster_usage_table_fields[] = {
+		{ "creation_time", "int unsigned not null" },
+		{ "mod_time", "int unsigned default 0 not null" },
+		{ "deleted", "tinyint default 0" },
+		{ "cluster", "tinytext not null" },
+		{ "period_start", "int unsigned not null" },
+		{ "cpu_count", "int default 0" },
+		{ "alloc_cpu_secs", "bigint default 0" },
+		{ "down_cpu_secs", "bigint default 0" },
+		{ "idle_cpu_secs", "bigint default 0" },
+		{ "resv_cpu_secs", "bigint default 0" },
+		{ "over_cpu_secs", "bigint default 0" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t event_table_fields[] = {
+		{ "node_name", "tinytext default '' not null" },
+		{ "cluster", "tinytext not null" },
+		{ "cpu_count", "int not null" },
+		{ "period_start", "int unsigned not null" },
+		{ "period_end", "int unsigned default 0 not null" },
+		{ "reason", "tinytext not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t job_table_fields[] = {
+		{ "id", "int not null auto_increment" },
+		{ "jobid", "mediumint unsigned not null" },
+		{ "associd", "mediumint unsigned not null" },
+		{ "uid", "smallint unsigned not null" },
+		{ "gid", "smallint unsigned not null" },
+		{ "partition", "tinytext not null" },
+		{ "blockid", "tinytext" },
+		{ "account", "tinytext" },
+		{ "eligible", "int unsigned default 0 not null" },
+		{ "submit", "int unsigned default 0 not null" },
+		{ "start", "int unsigned default 0 not null" },
+		{ "end", "int unsigned default 0 not null" },
+		{ "suspended", "int unsigned default 0 not null" },
+		{ "name", "tinytext not null" }, 
+		{ "track_steps", "tinyint not null" },
+		{ "state", "smallint not null" }, 
+		{ "comp_code", "int default 0 not null" },
+		{ "priority", "int unsigned not null" },
+		{ "req_cpus", "mediumint unsigned not null" }, 
+		{ "alloc_cpus", "mediumint unsigned not null" }, 
+		{ "nodelist", "text" },
+		{ "kill_requid", "smallint default -1 not null" },
+		{ "qos", "smallint default 0" },
+		{ NULL, NULL}
+	};
+
+	storage_field_t last_ran_table_fields[] = {
+		{ "hourly_rollup", "int unsigned default 0 not null" },
+		{ "daily_rollup", "int unsigned default 0 not null" },
+		{ "monthly_rollup", "int unsigned default 0 not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t step_table_fields[] = {
+		{ "id", "int not null" },
+		{ "stepid", "smallint not null" },
+		{ "start", "int unsigned default 0 not null" },
+		{ "end", "int unsigned default 0 not null" },
+		{ "suspended", "int unsigned default 0 not null" },
+		{ "name", "text not null" },
+		{ "nodelist", "text not null" },
+		{ "state", "smallint not null" },
+		{ "kill_requid", "smallint default -1 not null" },
+		{ "comp_code", "int default 0 not null" },
+		{ "cpus", "mediumint unsigned not null" },
+		{ "user_sec", "int unsigned default 0 not null" },
+		{ "user_usec", "int unsigned default 0 not null" },
+		{ "sys_sec", "int unsigned default 0 not null" },
+		{ "sys_usec", "int unsigned default 0 not null" },
+		{ "max_vsize", "mediumint unsigned default 0 not null" },
+		{ "max_vsize_task", "smallint unsigned default 0 not null" },
+		{ "max_vsize_node", "mediumint unsigned default 0 not null" },
+		{ "ave_vsize", "float default 0.0 not null" },
+		{ "max_rss", "mediumint unsigned default 0 not null" },
+		{ "max_rss_task", "smallint unsigned default 0 not null" },
+		{ "max_rss_node", "mediumint unsigned default 0 not null" },
+		{ "ave_rss", "float default 0.0 not null" },
+		{ "max_pages", "mediumint unsigned default 0 not null" },
+		{ "max_pages_task", "smallint unsigned default 0 not null" },
+		{ "max_pages_node", "mediumint unsigned default 0 not null" },
+		{ "ave_pages", "float default 0.0 not null" },
+		{ "min_cpu", "mediumint unsigned default 0 not null" },
+		{ "min_cpu_task", "smallint unsigned default 0 not null" },
+		{ "min_cpu_node", "mediumint unsigned default 0 not null" },
+		{ "ave_cpu", "float default 0.0 not null" },
+		{ NULL, NULL}
+	};
+
+	storage_field_t suspend_table_fields[] = {
+		{ "id", "int not null" },
+		{ "associd", "mediumint not null" },
+		{ "start", "int unsigned default 0 not null" },
+		{ "end", "int unsigned default 0 not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t txn_table_fields[] = {
+		{ "id", "int not null auto_increment" },
+		{ "timestamp", "int unsigned default 0 not null" },
+		{ "action", "smallint not null" },
+		{ "name", "tinytext not null" },
+		{ "actor", "tinytext not null" },
+		{ "info", "text" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t user_table_fields[] = {
+		{ "creation_time", "int unsigned not null" },
+		{ "mod_time", "int unsigned default 0 not null" },
+		{ "deleted", "tinyint default 0" },
+		{ "name", "tinytext not null" },
+		{ "default_acct", "tinytext not null" },
+		{ "qos", "smallint default 1 not null" },
+		{ "admin_level", "smallint default 1 not null" },
+		{ NULL, NULL}		
+	};
+
+	char *get_parent_proc = 
+		"drop procedure if exists get_parent_limits; "
+		"create procedure get_parent_limits("
+		"my_table text, acct text, cluster text) "
+		"begin "
+		"set @par_id = NULL; "
+		"set @mj = NULL; "
+		"set @mnpj = NULL; "
+		"set @mwpj = NULL; "
+		"set @mcpj = NULL; "
+		"set @my_acct = acct; "
+		"REPEAT "
+		"set @s = 'select '; "
+		"if @par_id is NULL then set @s = CONCAT("
+		"@s, '@par_id := id, '); "
+		"end if; "
+		"if @mj is NULL then set @s = CONCAT("
+		"@s, '@mj := max_jobs, '); "
+		"end if; "
+		"if @mnpj is NULL then set @s = CONCAT("
+		"@s, '@mnpj := max_nodes_per_job, ') ;"
+		"end if; "
+		"if @mwpj is NULL then set @s = CONCAT("
+		"@s, '@mwpj := max_wall_duration_per_job, '); "
+		"end if; "
+		"if @mcpj is NULL then set @s = CONCAT("
+		"@s, '@mcpj := max_cpu_secs_per_job, '); "
+		"end if; "
+		"set @s = concat(@s, ' @my_acct := parent_acct from ', "
+		"my_table, ' where acct = \"', @my_acct, '\" && "
+		"cluster = \"', cluster, '\" && user=\"\"'); "
+		"prepare query from @s; "
+		"execute query; "
+		"deallocate prepare query; "
+		"UNTIL (@mj != -1 && @mnpj != -1 && @mwpj != -1 "
+		"&& @mcpj != -1) || @my_acct = '' END REPEAT; "
+		"END;";
+	
+	if(mysql_db_create_table(acct_mysql_db, acct_coord_table,
+				 acct_coord_table_fields,
+				 ", primary key (acct(20), user(20)))")
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, acct_table, acct_table_fields,
+				 ", primary key (name(20)))") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, assoc_day_table,
+				 assoc_usage_table_fields,
+				 ", primary key (id, period_start))")
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, assoc_hour_table,
+				 assoc_usage_table_fields,
+				 ", primary key (id, period_start))")
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, assoc_month_table,
+				 assoc_usage_table_fields,
+				 ", primary key (id, period_start))") 
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, assoc_table, assoc_table_fields,
+				 ", primary key (id), "
+				 " unique index (user(20), acct(20), "
+				 "cluster(20), partition(20)))"
+/* 				 " unique index (lft), " */
+/* 				 " unique index (rgt))" */)
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, cluster_day_table,
+				 cluster_usage_table_fields,
+				 ", primary key (cluster(20), period_start))")
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, cluster_hour_table,
+				 cluster_usage_table_fields,
+				 ", primary key (cluster(20), period_start))")
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, cluster_month_table,
+				 cluster_usage_table_fields,
+				 ", primary key (cluster(20), period_start))")
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, cluster_table,
+				 cluster_table_fields,
+				 ", primary key (name(20)))") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, event_table,
+				 event_table_fields,
+				 ", primary key (node_name(20), cluster(20), "
+				 "period_start))") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, job_table, job_table_fields,
+				 ", primary key (id), "
+				 "unique index (jobid, associd, submit))")
+	   == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, last_ran_table,
+				 last_ran_table_fields, 
+				 ")") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, step_table,
+				 step_table_fields, 
+				 ", primary key (id, stepid))") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, suspend_table,
+				 suspend_table_fields, 
+				 ")") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, txn_table, txn_table_fields,
+				 ", primary key (id))") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	if(mysql_db_create_table(acct_mysql_db, user_table, user_table_fields,
+				 ", primary key (name(20)))") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	rc = mysql_db_query(acct_mysql_db, get_parent_proc);
+
+	return rc;
+}
+#endif
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	static int first = 1;
+	int rc = SLURM_SUCCESS;
+#ifdef HAVE_MYSQL
+	MYSQL *acct_mysql_db = NULL;
+	char *location = NULL;
+#else
+	fatal("No MySQL database was found on the machine. "
+	      "Please check the configure log and run again.");
+#endif
+
+	/* since this can be loaded from many different places
+	   only tell us once. */
+	if(!first)
+		return SLURM_SUCCESS;
+
+	first = 0;
+
+#ifdef HAVE_MYSQL
+	mysql_db_info = _mysql_acct_create_db_info();
+
+	location = slurm_get_accounting_storage_loc();
+	if(!location)
+		mysql_db_name = xstrdup(DEFAULT_ACCT_DB);
+	else {
+		int i = 0;
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_ACCT_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) {
+			mysql_db_name = xstrdup(DEFAULT_ACCT_DB);
+			xfree(location);
+		} else
+			mysql_db_name = location;
+	}
+
+	debug2("mysql_connect() called for db %s", mysql_db_name);
+	
+	mysql_get_db_connection(&acct_mysql_db, mysql_db_name, mysql_db_info);
+		
+	rc = _mysql_acct_check_tables(acct_mysql_db);
+
+	mysql_close_db_connection(&acct_mysql_db);
+#endif		
+
+	if(rc == SLURM_SUCCESS)
+		verbose("%s loaded", plugin_name);
+	else 
+		verbose("%s failed", plugin_name);
+	
+	return rc;
+}
+
+extern int fini ( void )
+{
+#ifdef HAVE_MYSQL
+	destroy_mysql_db_info(mysql_db_info);		
+	xfree(mysql_db_name);
+	mysql_cleanup();
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern void *acct_storage_p_get_connection(bool make_agent, bool rollback)
+{
+#ifdef HAVE_MYSQL
+	mysql_conn_t *mysql_conn = xmalloc(sizeof(mysql_conn_t));
+	static int conn = 0;
+	if(!mysql_db_info)
+		init();
+
+	debug2("acct_storage_p_get_connection: request new connection");
+	
+	mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+				mysql_db_name, mysql_db_info);
+	mysql_conn->rollback = rollback;
+	if(rollback) {
+		mysql_autocommit(mysql_conn->acct_mysql_db, 0);
+	}
+	mysql_conn->conn = conn++;
+	mysql_conn->update_list = list_create(destroy_acct_update_object);
+	return (void *)mysql_conn;
+#else
+	return NULL;
+#endif
+}
+
+extern int acct_storage_p_close_connection(mysql_conn_t **mysql_conn)
+{
+#ifdef HAVE_MYSQL
+
+	if(!mysql_conn || !(*mysql_conn))
+		return SLURM_SUCCESS;
+
+	acct_storage_p_commit((*mysql_conn), 0);
+	mysql_close_db_connection(&(*mysql_conn)->acct_mysql_db);
+	list_destroy((*mysql_conn)->update_list);
+	xfree((*mysql_conn));
+
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_commit(mysql_conn_t *mysql_conn, bool commit)
+{
+#ifdef HAVE_MYSQL
+	
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	debug4("got %d commits", list_count(mysql_conn->update_list));
+
+	if(mysql_conn->rollback) {
+		if(!commit) {
+			if(mysql_db_rollback(mysql_conn->acct_mysql_db))
+				error("rollback failed");
+		} else {
+			if(mysql_db_commit(mysql_conn->acct_mysql_db))
+				error("commit failed");
+		}
+	}
+	
+	if(commit && list_count(mysql_conn->update_list)) {
+		int rc;
+		char *query = NULL;
+		MYSQL_RES *result = NULL;
+		MYSQL_ROW row;
+		accounting_update_msg_t msg;
+		slurm_msg_t req;
+		slurm_msg_t resp;
+		ListIterator itr = NULL;
+		acct_update_object_t *object = NULL;
+		
+		slurm_msg_t_init(&req);
+		slurm_msg_t_init(&resp);
+		
+		memset(&msg, 0, sizeof(accounting_update_msg_t));
+		msg.update_list = mysql_conn->update_list;
+		
+		xstrfmtcat(query, "select control_host, control_port from %s "
+			   "where deleted=0 && control_port != 0",
+			   cluster_table);
+		if(!(result = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			goto skip;
+		}
+		xfree(query);
+		while((row = mysql_fetch_row(result))) {
+			info("sending to %s(%s)", row[0], row[1]);
+			slurm_set_addr_char(&req.address, atoi(row[1]), row[0]);
+			req.msg_type = ACCOUNTING_UPDATE_MSG;
+			req.flags = SLURM_GLOBAL_AUTH_KEY;
+			req.data = &msg;			
+			
+			rc = slurm_send_recv_node_msg(&req, &resp, 0);
+			if ((rc != 0) || !resp.auth_cred) {
+				error("update cluster: %m to %s(%s)",
+				      row[0], row[1]);
+				if (resp.auth_cred)
+					g_slurm_auth_destroy(resp.auth_cred);
+				rc = SLURM_ERROR;
+			}
+			if (resp.auth_cred)
+				g_slurm_auth_destroy(resp.auth_cred);
+			
+			switch (resp.msg_type) {
+			case RESPONSE_SLURM_RC:
+				rc = ((return_code_msg_t *)resp.data)->
+					return_code;
+				slurm_free_return_code_msg(resp.data);	
+				break;
+			default:
+				break;
+			}	
+			//info("got rc of %d", rc);
+		}
+		mysql_free_result(result);
+	skip:
+		/* NOTE: you can not use list_pop, or list_push
+		   anywhere either, since mysql is
+		   exporting something of the same type as a macro,
+		   which messes everything up (my_list.h is the bad boy).
+		   So we are just going to delete each item as it
+		   comes out.
+		*/
+		itr = list_iterator_create(mysql_conn->update_list);
+		while((object = list_next(itr))) {
+			if(!object->objects || !list_count(object->objects)) {
+				list_delete_item(itr);
+				continue;
+			}
+			switch(object->type) {
+			case ACCT_MODIFY_USER:
+			case ACCT_ADD_USER:
+			case ACCT_REMOVE_USER:
+				rc = assoc_mgr_update_local_users(object);
+				break;
+			case ACCT_ADD_ASSOC:
+			case ACCT_MODIFY_ASSOC:
+			case ACCT_REMOVE_ASSOC:
+				rc = assoc_mgr_update_local_assocs(object);
+				break;
+			case ACCT_UPDATE_NOTSET:
+			default:
+				error("unknown type set in "
+				      "update_object: %d",
+				      object->type);
+				break;
+			}
+			list_delete_item(itr);
+		}
+		list_iterator_destroy(itr);
+	}
+	list_flush(mysql_conn->update_list);
+
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_add_users(mysql_conn_t *mysql_conn, uint32_t uid,
+				    List user_list)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	acct_user_rec_t *object = NULL;
+	char *cols = NULL, *vals = NULL, *query = NULL, *txn_query = NULL;
+	struct passwd *pw = NULL;
+	time_t now = time(NULL);
+	char *user = NULL;
+	char *extra = NULL;
+	int affect_rows = 0;
+	List assoc_list = list_create(destroy_acct_association_rec);
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user = pw->pw_name;
+	}
+
+	itr = list_iterator_create(user_list);
+	while((object = list_next(itr))) {
+		if(!object->name || !object->default_acct) {
+			error("We need a user name and "
+			      "default acct to add.");
+			rc = SLURM_ERROR;
+			continue;
+		}
+		xstrcat(cols, "creation_time, mod_time, name, default_acct");
+		xstrfmtcat(vals, "%d, %d, '%s', '%s'", 
+			   now, now, object->name, object->default_acct); 
+		xstrfmtcat(extra, ", default_acct='%s'", object->default_acct);
+		if(object->qos != ACCT_QOS_NOTSET) {
+			xstrcat(cols, ", qos");
+			xstrfmtcat(vals, ", %u", object->qos); 		
+			xstrfmtcat(extra, ", qos=%u", object->qos); 		
+		}
+
+		if(object->admin_level != ACCT_ADMIN_NOTSET) {
+			xstrcat(cols, ", admin_level");
+			xstrfmtcat(vals, ", %u", object->admin_level);
+		}
+
+		query = xstrdup_printf(
+			"insert into %s (%s) values (%s) "
+			"on duplicate key update deleted=0, mod_time=%d %s;",
+			user_table, cols, vals,
+			now, extra);
+
+		xfree(cols);
+		xfree(vals);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add user %s", object->name);
+			xfree(extra);
+			continue;
+		}
+
+		affect_rows = _last_affected_rows(mysql_conn->acct_mysql_db);
+		if(!affect_rows) {
+			debug("nothing changed");
+			xfree(extra);
+			continue;
+		}
+
+		if(_addto_update_list(mysql_conn->update_list, ACCT_ADD_USER,
+				      object) == SLURM_SUCCESS) 
+			list_remove(itr);
+			
+
+		if(txn_query)
+			xstrfmtcat(txn_query, 	
+				   ", (%d, %u, '%s', '%s', \"%s\")",
+				   now, DBD_ADD_USERS, object->name,
+				   user, extra);
+		else
+			xstrfmtcat(txn_query, 	
+				   "insert into %s "
+				   "(timestamp, action, name, actor, info) "
+				   "values (%d, %u, '%s', '%s', \"%s\")",
+				   txn_table,
+				   now, DBD_ADD_USERS, object->name,
+				   user, extra);
+		xfree(extra);
+		
+		if(!object->assoc_list)
+			continue;
+
+		list_transfer(assoc_list, object->assoc_list);
+	}
+	list_iterator_destroy(itr);
+
+	if(rc != SLURM_ERROR) {
+		if(txn_query) {
+			xstrcat(txn_query, ";");
+			rc = mysql_db_query(mysql_conn->acct_mysql_db,
+					    txn_query);
+			xfree(txn_query);
+			if(rc != SLURM_SUCCESS) {
+				error("Couldn't add txn");
+				rc = SLURM_SUCCESS;
+			}
+		}
+	} else
+		xfree(txn_query);
+
+	if(list_count(assoc_list)) {
+		if(acct_storage_p_add_associations(mysql_conn, uid, assoc_list)
+		   == SLURM_ERROR) {
+			error("Problem adding user associations");
+			rc = SLURM_ERROR;
+		}
+	}
+	list_destroy(assoc_list);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_add_coord(mysql_conn_t *mysql_conn, uint32_t uid, 
+				    char *acct, acct_user_cond_t *user_q)
+{
+#ifdef HAVE_MYSQL
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_add_accts(mysql_conn_t *mysql_conn, uint32_t uid, 
+				    List acct_list)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	acct_account_rec_t *object = NULL;
+	char *cols = NULL, *vals = NULL, *query = NULL, *txn_query = NULL;
+	struct passwd *pw = NULL;
+	time_t now = time(NULL);
+	char *user = NULL;
+	char *extra = NULL;
+	int affect_rows = 0;
+	List assoc_list = list_create(destroy_acct_association_rec);
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user = pw->pw_name;
+	}
+
+	itr = list_iterator_create(acct_list);
+	while((object = list_next(itr))) {
+		if(!object->name || !object->description
+		   || !object->organization) {
+			error("We need an account name, description, and "
+			      "organization to add. %s %s %s", 
+			      object->name, object->description,
+			      object->organization);
+			rc = SLURM_ERROR;
+			continue;
+		}
+		xstrcat(cols, "creation_time, mod_time, name, "
+			"description, organization");
+		xstrfmtcat(vals, "%d, %d, '%s', '%s', '%s'", 
+			   now, now, object->name, 
+			   object->description, object->organization); 
+		xstrfmtcat(extra, ", description='%s', organization='%s'",
+			   object->description, object->organization); 		
+		
+		if(object->qos != ACCT_QOS_NOTSET) {
+			xstrcat(cols, ", qos");
+			xstrfmtcat(vals, ", %u", object->qos); 		
+			xstrfmtcat(extra, ", qos=%u", object->qos); 		
+		}
+
+		query = xstrdup_printf(
+			"insert into %s (%s) values (%s) "
+			"on duplicate key update deleted=0, mod_time=%d %s;",
+			acct_table, cols, vals,
+			now, extra);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(cols);
+		xfree(vals);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add acct");
+			xfree(extra);
+			continue;
+		}
+		affect_rows = _last_affected_rows(mysql_conn->acct_mysql_db);
+/* 		debug3("affected %d", affect_rows); */
+
+		if(!affect_rows) {
+			debug3("nothing changed");
+			xfree(extra);
+			continue;
+		}
+
+		if(txn_query)
+			xstrfmtcat(txn_query, 	
+				   ", (%d, %u, '%s', '%s', \"%s\")",
+				   now, DBD_ADD_ACCOUNTS, object->name,
+				   user, extra);
+		else
+			xstrfmtcat(txn_query, 	
+				   "insert into %s "
+				   "(timestamp, action, name, actor, info) "
+				   "values (%d, %u, '%s', '%s', \"%s\")",
+				   txn_table,
+				   now, DBD_ADD_ACCOUNTS, object->name,
+				   user, extra);
+		xfree(extra);
+		
+		if(!object->assoc_list)
+			continue;
+
+		list_transfer(assoc_list, object->assoc_list);
+	}
+	list_iterator_destroy(itr);
+	
+	if(rc != SLURM_ERROR) {
+		if(txn_query) {
+			xstrcat(txn_query, ";");
+			rc = mysql_db_query(mysql_conn->acct_mysql_db,
+					    txn_query);
+			xfree(txn_query);
+			if(rc != SLURM_SUCCESS) {
+				error("Couldn't add txn");
+				rc = SLURM_SUCCESS;
+			}
+		}
+	} else
+		xfree(txn_query);
+
+	if(list_count(assoc_list)) {
+		if(acct_storage_p_add_associations(mysql_conn, uid, assoc_list)
+		   == SLURM_ERROR) {
+			error("Problem adding user associations");
+			rc = SLURM_ERROR;
+		}
+	}
+	list_destroy(assoc_list);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_add_clusters(mysql_conn_t *mysql_conn, uint32_t uid, 
+				       List cluster_list)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	acct_cluster_rec_t *object = NULL;
+	char *cols = NULL, *vals = NULL, *extra = NULL, *query = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user = NULL;
+	int affect_rows = 0;
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user = pw->pw_name;
+	}
+
+	itr = list_iterator_create(cluster_list);
+	while((object = list_next(itr))) {
+		if(!object->name) {
+			error("We need a cluster name to add.");
+			rc = SLURM_ERROR;
+			continue;
+		}
+
+		xstrcat(cols, "creation_time, mod_time, acct, cluster");
+		xstrfmtcat(vals, "%d, %d, 'root', '%s'",
+			   now, now, object->name);
+		xstrfmtcat(extra, ", mod_time=%d", now);
+	
+		if((int)object->default_fairshare >= 0) {
+			xstrcat(cols, ", fairshare");
+			xstrfmtcat(vals, ", %u", object->default_fairshare);
+			xstrfmtcat(extra, ", fairshare=%u",
+				   object->default_fairshare);
+		} else if ((int)object->default_fairshare == -1) {
+			xstrcat(cols, ", fairshare");
+			xstrfmtcat(vals, ", NULL");
+			xstrfmtcat(extra, ", fairshare=NULL");		
+		}
+
+		if((int)object->default_max_cpu_secs_per_job >= 0) {
+			xstrcat(cols, ", max_cpu_secs_per_job");
+			xstrfmtcat(vals, ", %u",
+				   object->default_max_cpu_secs_per_job);
+			xstrfmtcat(extra, ", max_cpu_secs_per_job=%u",
+				   object->default_max_cpu_secs_per_job);
+		} else if((int)object->default_max_cpu_secs_per_job == -1) {
+			xstrcat(cols, ", max_cpu_secs_per_job");
+			xstrfmtcat(vals, ", NULL");
+			xstrfmtcat(extra, ", max_cpu_secs_per_job=NULL");
+		}
+		
+		if((int)object->default_max_jobs >= 0) {
+			xstrcat(cols, ", max_jobs");
+			xstrfmtcat(vals, ", %u", object->default_max_jobs);
+			xstrfmtcat(extra, ", max_jobs=%u",
+				   object->default_max_jobs);
+		} else if((int)object->default_max_jobs == -1) {
+			xstrcat(cols, ", max_jobs");
+			xstrfmtcat(vals, ", NULL");
+			xstrfmtcat(extra, ", max_jobs=NULL");		
+		}
+
+		if((int)object->default_max_nodes_per_job >= 0) {
+			xstrcat(cols, ", max_nodes_per_job");
+			xstrfmtcat(vals, ", %u", 
+				   object->default_max_nodes_per_job);
+			xstrfmtcat(extra, ", max_nodes_per_job=%u",
+				   object->default_max_nodes_per_job);
+		} else if((int)object->default_max_nodes_per_job == -1) {
+			xstrcat(cols, ", max_nodes_per_job");
+			xstrfmtcat(vals, ", NULL");
+			xstrfmtcat(extra, ", max_nodes_per_job=NULL");
+		}
+
+		if((int)object->default_max_wall_duration_per_job >= 0) {
+			xstrcat(cols, ", max_wall_duration_per_job");
+			xstrfmtcat(vals, ", %u",
+				   object->default_max_wall_duration_per_job);
+			xstrfmtcat(extra, ", max_wall_duration_per_job=%u",
+				   object->default_max_wall_duration_per_job);
+		} else if((int)object->default_max_wall_duration_per_job
+			  == -1) {
+			xstrcat(cols, ", max_wall_duration_per_job");
+			xstrfmtcat(vals, ", NULL");
+			xstrfmtcat(extra, ", max_duration_per_job=NULL");
+		}
+
+		xstrfmtcat(query, 
+			   "insert into %s (creation_time, mod_time, name) "
+			   "values (%d, %d, '%s') "
+			   "on duplicate key update deleted=0, mod_time=%d;",
+			   cluster_table, 
+			   now, now, object->name,
+			   now);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add cluster %s", object->name);
+			xfree(extra);
+			xfree(cols);
+			xfree(vals);
+			continue;
+		}
+
+		affect_rows = _last_affected_rows(mysql_conn->acct_mysql_db);
+
+		if(!affect_rows) {
+			debug2("nothing changed %d", affect_rows);
+			xfree(extra);
+			xfree(cols);
+			xfree(vals);
+			continue;
+		}
+
+		xstrfmtcat(query,
+			   "SELECT @MyMax := coalesce(max(rgt), 0) FROM %s "
+			   "FOR UPDATE;",
+			   assoc_table);
+		xstrfmtcat(query,
+			   "insert into %s (%s, lft, rgt) "
+			   "values (%s, @MyMax+1, @MyMax+2) "
+			   "on duplicate key update deleted=0, "
+			   "id=LAST_INSERT_ID(id)%s;",
+			   assoc_table, cols,
+			   vals,
+			   extra);
+		
+		xfree(cols);
+		xfree(vals);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add cluster root assoc");
+			xfree(extra);
+			continue;
+		}
+		xstrfmtcat(query,
+			   "insert into %s "
+			   "(timestamp, action, name, actor, info) "
+			   "values (%d, %u, '%s', '%s', \"%s\");",
+			   txn_table,
+			   now, DBD_ADD_CLUSTERS, object->name, user, extra);
+		xfree(extra);			
+		debug4("query\n%s",query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add txn");
+		}
+	}
+	list_iterator_destroy(itr);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_add_associations(mysql_conn_t *mysql_conn,
+					   uint32_t uid, 
+					   List association_list)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	int rc = SLURM_SUCCESS;
+	int i=0;
+	acct_association_rec_t *object = NULL;
+	char *cols = NULL, *vals = NULL, *txn_query = NULL,
+		*extra = NULL, *query = NULL, *update = NULL;
+	char *parent = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user = NULL;
+	char *tmp_char = NULL;
+	int assoc_id = 0;
+	int incr = 0, my_left = 0;
+	int affect_rows = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	char *old_parent = NULL, *old_cluster = NULL;
+	char *massoc_req_inx[] = {
+		"id",
+		"parent_acct",
+		"lft",
+		"rgt",
+		"deleted"
+	};
+	
+	enum {
+		MASSOC_ID,
+		MASSOC_PACCT,
+		MASSOC_LFT,
+		MASSOC_RGT,
+		MASSOC_DELETED,
+		MASSOC_COUNT
+	};
+
+	if(!association_list) {
+		error("No association list given");
+		return SLURM_ERROR;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user = pw->pw_name;
+	}
+
+	itr = list_iterator_create(association_list);
+	while((object = list_next(itr))) {
+		if(!object->cluster || !object->acct) {
+			error("We need a association cluster and "
+			      "acct to add one.");
+			rc = SLURM_ERROR;
+			continue;
+		}
+
+		if(object->parent_acct) {
+			parent = object->parent_acct;
+		} else if(object->user) {
+			parent = object->acct;
+		} else {
+			parent = "root";
+		}
+
+		xstrcat(cols, "creation_time, mod_time, cluster, acct");
+		xstrfmtcat(vals, "%d, %d, '%s', '%s'", 
+			   now, now, object->cluster, object->acct); 
+		xstrfmtcat(update, "where id>=0 && cluster='%s' && acct='%s'",
+			   object->cluster, object->acct); 
+
+		xstrfmtcat(extra, ", mod_time=%d", now);
+		if(!object->user) {
+			xstrcat(cols, ", parent_acct");
+			xstrfmtcat(vals, ", '%s'", parent);
+			xstrfmtcat(extra, ", parent_acct='%s'", parent);
+			xstrfmtcat(update, " && user=''"); 
+		}
+		
+		if(object->user) {
+			xstrcat(cols, ", user");
+			xstrfmtcat(vals, ", '%s'", object->user); 		
+			xstrfmtcat(extra, ", user='%s'", object->user);
+			xstrfmtcat(update, " && user='%s'",
+				   object->user); 
+			
+			if(object->partition) {
+				xstrcat(cols, ", partition");
+				xstrfmtcat(vals, ", '%s'", object->partition);
+				xstrfmtcat(extra, ", partition='%s'",
+					   object->partition);
+				xstrfmtcat(update, " && partition='%s'",
+					   object->partition);
+			}
+		}
+
+		if((int)object->fairshare >= 0) {
+			xstrcat(cols, ", fairshare");
+			xstrfmtcat(vals, ", %d", object->fairshare);
+			xstrfmtcat(extra, ", fairshare=%d",
+				   object->fairshare);
+		}
+
+		if((int)object->max_jobs >= 0) {
+			xstrcat(cols, ", max_jobs");
+			xstrfmtcat(vals, ", %d", object->max_jobs);
+			xstrfmtcat(extra, ", max_jobs=%d",
+				   object->max_jobs);
+		}
+
+		if((int)object->max_nodes_per_job >= 0) {
+			xstrcat(cols, ", max_nodes_per_job");
+			xstrfmtcat(vals, ", %d", object->max_nodes_per_job);
+			xstrfmtcat(extra, ", max_nodes_per_job=%d",
+				   object->max_nodes_per_job);
+		}
+
+		if((int)object->max_wall_duration_per_job >= 0) {
+			xstrcat(cols, ", max_wall_duration_per_job");
+			xstrfmtcat(vals, ", %d",
+				   object->max_wall_duration_per_job);
+			xstrfmtcat(extra, ", max_wall_duration_per_job=%d",
+				   object->max_wall_duration_per_job);
+		}
+
+		if((int)object->max_cpu_secs_per_job >= 0) {
+			xstrcat(cols, ", max_cpu_secs_per_job");
+			xstrfmtcat(vals, ", %d", object->max_cpu_secs_per_job);
+			xstrfmtcat(extra, ", max_cpu_secs_per_job=%d",
+				   object->max_cpu_secs_per_job);
+		}
+
+		for(i=0; i<MASSOC_COUNT; i++) {
+			if(i) 
+				xstrcat(tmp_char, ", ");
+			xstrcat(tmp_char, massoc_req_inx[i]);
+		}
+		
+		xstrfmtcat(query, 
+			   "select distinct %s from %s %s  order by lft "
+			   "FOR UPDATE;",
+			   tmp_char, assoc_table, update);
+		xfree(tmp_char);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		if(!(result = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			xfree(cols);
+			xfree(vals);
+			xfree(extra);
+			xfree(update);
+			error("couldn't query the database");
+			rc = SLURM_ERROR;
+			break;
+		}
+		xfree(query);
+
+		assoc_id = 0;
+		if(!(row = mysql_fetch_row(result))) {
+			if(!old_parent || !old_cluster
+			   || strcasecmp(parent, old_parent) 
+			   || strcasecmp(object->cluster, old_cluster)) {
+				char *sel_query = xstrdup_printf(
+					"SELECT lft FROM %s WHERE "
+					"acct = '%s' and cluster = '%s' "
+					"and user = '' order by lft;",
+					assoc_table,
+					parent, object->cluster);
+				MYSQL_RES *sel_result = NULL;
+				
+				if(incr) {
+					char *up_query = xstrdup_printf(
+						"UPDATE %s SET rgt = rgt+%d "
+						"WHERE rgt > %d && deleted < 2;"
+						"UPDATE %s SET lft = lft+%d "
+						"WHERE lft > %d "
+						"&& deleted < 2;"
+						"UPDATE %s SET deleted = 0 "
+						"WHERE deleted = 2;",
+						assoc_table, incr,
+						my_left,
+						assoc_table, incr,
+						my_left,
+						assoc_table);
+					debug3("%d query\n%s", mysql_conn->conn,
+					       up_query);
+					rc = mysql_db_query(
+						mysql_conn->acct_mysql_db,
+						up_query);
+					xfree(up_query);
+					if(rc != SLURM_SUCCESS) {
+						error("Couldn't do update");
+						xfree(cols);
+						xfree(vals);
+						xfree(update);
+						xfree(extra);
+						xfree(sel_query);
+						break;
+					}
+				}
+
+				debug3("%d query\n%s", mysql_conn->conn,
+				       sel_query);
+				if(!(sel_result = mysql_db_query_ret(
+					     mysql_conn->acct_mysql_db,
+					     sel_query, 0))) {
+					xfree(cols);
+					xfree(vals);
+					xfree(update);
+					xfree(extra);
+					xfree(sel_query);
+					rc = SLURM_ERROR;
+					break;
+				}
+				
+				if(!(row = mysql_fetch_row(sel_result))) {
+					error("Couldn't get left from query\n",
+					      sel_query);
+					mysql_free_result(sel_result);
+					xfree(cols);
+					xfree(vals);
+					xfree(update);
+					xfree(extra);
+					xfree(sel_query);
+					rc = SLURM_ERROR;
+					break;
+				}
+				xfree(sel_query);
+
+				my_left = atoi(row[0]);
+				mysql_free_result(sel_result);
+				//info("left is %d", my_left);
+				xfree(old_parent);
+				xfree(old_cluster);
+				old_parent = xstrdup(parent);
+				old_cluster = xstrdup(object->cluster);
+				incr = 0;
+			}
+			incr += 2;
+			xstrfmtcat(query,
+				   "insert into %s (%s, lft, rgt, deleted) "
+				   "values (%s, %d, %d, 2);",
+				   assoc_table, cols,
+				   vals, my_left+(incr-1), my_left+incr);
+			
+			/* definantly works but slow */
+/* 			xstrfmtcat(query, */
+/* 				   "SELECT @myLeft := lft FROM %s WHERE " */
+/* 				   "acct = '%s' " */
+/* 				   "and cluster = '%s' and user = '';", */
+/* 				   assoc_table, */
+/* 				   parent, */
+/* 				   object->cluster); */
+/* 			xstrfmtcat(query, */
+/* 				   "UPDATE %s SET rgt = rgt+2 " */
+/* 				   "WHERE rgt > @myLeft;" */
+/* 				   "UPDATE %s SET lft = lft+2 " */
+/* 				   "WHERE lft > @myLeft;", */
+/* 				   assoc_table, */
+/* 				   assoc_table); */
+/* 			xstrfmtcat(query, */
+/* 				   "insert into %s (%s, lft, rgt) " */
+/* 				   "values (%s, @myLeft+1, @myLeft+2);", */
+/* 				   assoc_table, cols, */
+/* 				   vals); */
+		} else if(!atoi(row[MASSOC_DELETED])) {
+			debug("This account was added already");
+			xfree(cols);
+			xfree(vals);
+			xfree(update);
+			mysql_free_result(result);
+			xfree(extra);
+			continue;
+		} else {
+			assoc_id = atoi(row[MASSOC_ID]);
+			if(object->parent_acct 
+			   && strcasecmp(object->parent_acct,
+					 row[MASSOC_PACCT])) {
+				
+				/* We need to move the parent! */
+				if(_move_parent(mysql_conn,
+						atoi(row[MASSOC_LFT]),
+						atoi(row[MASSOC_RGT]),
+						object->cluster,
+						row[MASSOC_ID],
+						row[MASSOC_PACCT],
+						object->parent_acct)
+				   == SLURM_ERROR)
+					continue;
+			}
+
+
+			affect_rows = 2;
+			xstrfmtcat(query,
+				   "update %s set deleted=0, "
+				   "id=LAST_INSERT_ID(id)%s %s;",
+				   assoc_table, 
+				   extra, update);
+		}
+		mysql_free_result(result);
+
+		xfree(cols);
+		xfree(vals);
+		xfree(update);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add assoc");
+			xfree(extra);
+			break;
+		}
+		/* see if this was an insert or update.  On an update
+		 * the assoc_id will already be set
+		 */
+		if(!assoc_id) {
+			affect_rows = _last_affected_rows(
+				mysql_conn->acct_mysql_db);
+			assoc_id = mysql_insert_id(mysql_conn->acct_mysql_db);
+			//info("last id was %d", assoc_id);
+		}
+
+		object->id = assoc_id;
+
+		if(_addto_update_list(mysql_conn->update_list, ACCT_ADD_ASSOC,
+				      object) == SLURM_SUCCESS) {
+			list_remove(itr);
+		}
+
+		if(txn_query)
+			xstrfmtcat(txn_query, 	
+				   ", (%d, %d, '%d', '%s', \"%s\")",
+				   now, DBD_ADD_ASSOCS, assoc_id, user, extra);
+		else
+			xstrfmtcat(txn_query, 	
+				   "insert into %s "
+				   "(timestamp, action, name, actor, info) "
+				   "values (%d, %d, '%d', '%s', \"%s\")",
+				   txn_table,
+				   now, DBD_ADD_ASSOCS, assoc_id, user, extra);
+		xfree(extra);
+	}
+	list_iterator_destroy(itr);
+	if(incr) {
+		char *up_query = xstrdup_printf(
+			"UPDATE %s SET rgt = rgt+%d "
+			"WHERE rgt > %d && deleted < 2;"
+			"UPDATE %s SET lft = lft+%d "
+			"WHERE lft > %d "
+			"&& deleted < 2;"
+			"UPDATE %s SET deleted = 0 "
+			"WHERE deleted = 2;",
+			assoc_table, incr,
+			my_left,
+			assoc_table, incr,
+			my_left,
+			assoc_table);
+		debug3("%d query\n%s", mysql_conn->conn, up_query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, up_query);
+		xfree(up_query);
+		if(rc != SLURM_SUCCESS) 
+			error("Couldn't do update 2");
+		
+	}
+
+	if(rc != SLURM_ERROR) {
+		if(txn_query) {
+			xstrcat(txn_query, ";");
+			rc = mysql_db_query(mysql_conn->acct_mysql_db,
+					    txn_query);
+			xfree(txn_query);
+			if(rc != SLURM_SUCCESS) {
+				error("Couldn't add txn");
+				rc = SLURM_SUCCESS;
+			}
+		}
+	} else
+		xfree(txn_query);
+	
+	xfree(old_parent);
+	xfree(old_cluster);
+					
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern List acct_storage_p_modify_users(mysql_conn_t *mysql_conn, uint32_t uid, 
+					acct_user_cond_t *user_q,
+					acct_user_rec_t *user)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *vals = NULL, *extra = NULL, *query = NULL, *name_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user_name = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	if(!user_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(!mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					    mysql_db_name, mysql_db_info))
+			return NULL;
+	}
+
+	if((pw=getpwuid(uid))) {
+		user_name = pw->pw_name;
+	}
+
+	xstrcat(extra, "where deleted=0");
+	if(user_q->user_list && list_count(user_q->user_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(user_q->user_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(user_q->def_acct_list && list_count(user_q->def_acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(user_q->def_acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "default_acct='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(user_q->qos != ACCT_QOS_NOTSET) {
+		xstrfmtcat(extra, " && qos=%u", user_q->qos);
+	}
+
+	if(user_q->admin_level != ACCT_ADMIN_NOTSET) {
+		xstrfmtcat(extra, " && admin_level=%u", user_q->admin_level);
+	}
+
+	if(user->default_acct)
+		xstrfmtcat(vals, ", default_acct='%s'", user->default_acct);
+
+	if(user->qos != ACCT_QOS_NOTSET)
+		xstrfmtcat(vals, ", qos=%u", user->qos);
+
+	if(user->admin_level != ACCT_ADMIN_NOTSET)
+		xstrfmtcat(vals, ", admin_level=%u", user->admin_level);
+
+	if(!extra || !vals) {
+		error("Nothing to change");
+		return NULL;
+	}
+	query = xstrdup_printf("select name from %s %s;", user_table, extra);
+	xfree(extra);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	rc = 0;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		object = xstrdup(row[0]);
+		list_append(ret_list, object);
+		if(!rc) {
+			xstrfmtcat(name_char, "(name='%s'", object);
+			rc = 1;
+		} else  {
+			xstrfmtcat(name_char, " || name='%s'", object);
+		}
+	}
+	mysql_free_result(result);
+
+	if(!list_count(ret_list)) {
+		debug3("didn't effect anything");
+		xfree(vals);
+		return ret_list;
+	}
+	xstrcat(name_char, ")");
+
+	if(_modify_common(mysql_conn, DBD_MODIFY_USERS, now,
+			  user_name, user_table, name_char, vals)
+	   == SLURM_ERROR) {
+		error("Couldn't modify users");
+		list_destroy(ret_list);
+		ret_list = NULL;
+	}
+
+	xfree(name_char);
+	xfree(vals);
+				
+	return ret_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_modify_accts(mysql_conn_t *mysql_conn, uint32_t uid, 
+					acct_account_cond_t *acct_q,
+					acct_account_rec_t *acct)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *vals = NULL, *extra = NULL, *query = NULL, *name_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	if(!acct_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user = pw->pw_name;
+	}
+
+	xstrcat(extra, "where deleted=0");
+	if(acct_q->acct_list && list_count(acct_q->acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(acct_q->description_list && list_count(acct_q->description_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->description_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "description='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(acct_q->organization_list && list_count(acct_q->organization_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->organization_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "organization='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(acct_q->qos != ACCT_QOS_NOTSET) {
+		xstrfmtcat(extra, " && qos=%u", acct_q->qos);
+	}
+
+	if(acct->description)
+		xstrfmtcat(vals, ", description='%s'", acct->description);
+	if(acct->organization)
+		xstrfmtcat(vals, ", organization='%u'", acct->organization);
+	if(acct->qos != ACCT_QOS_NOTSET)
+		xstrfmtcat(vals, ", qos='%u'", acct->qos);
+
+	if(!extra || !vals) {
+		error("Nothing to change");
+		return NULL;
+	}
+
+	query = xstrdup_printf("select name from %s %s;", acct_table, extra);
+	xfree(extra);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		xfree(vals);
+		return NULL;
+	}
+	xfree(query);
+
+	rc = 0;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		object = xstrdup(row[0]);
+		list_append(ret_list, object);
+		if(!rc) {
+			xstrfmtcat(name_char, "(name='%s'", object);
+			rc = 1;
+		} else  {
+			xstrfmtcat(name_char, " || name='%s'", object);
+		}
+
+	}
+	mysql_free_result(result);
+
+	if(!list_count(ret_list)) {
+		debug3("didn't effect anything");
+		xfree(vals);
+		return ret_list;
+	}
+	xstrcat(name_char, ")");
+
+	if(_modify_common(mysql_conn, DBD_MODIFY_ACCOUNTS, now,
+			  user, acct_table, name_char, vals)
+	   == SLURM_ERROR) {
+		error("Couldn't modify accounts");
+		list_destroy(ret_list);
+		ret_list = NULL;
+	}
+		
+	xfree(name_char);
+	xfree(vals);
+
+	return ret_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_modify_clusters(mysql_conn_t *mysql_conn, 
+					   uint32_t uid, 
+					   acct_cluster_cond_t *cluster_q,
+					   acct_cluster_rec_t *cluster)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *vals = NULL, *extra = NULL, *query = NULL,
+		*name_char = NULL, *assoc_char= NULL, *send_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	/* If you need to alter the default values of the cluster use
+	 * modify_associations since this is used only for registering
+	 * the controller when it loads 
+	 */
+
+	if(!cluster_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user = pw->pw_name;
+	}
+
+	xstrcat(extra, "where deleted=0");
+	if(cluster_q->cluster_list && list_count(cluster_q->cluster_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(cluster_q->cluster_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+		
+	if(cluster->control_host) {
+		xstrfmtcat(vals, ", control_host='%s'", cluster->control_host);
+	}
+	if(cluster->control_port) {
+		xstrfmtcat(vals, ", control_port=%u", cluster->control_port);
+	}
+
+	if(!vals) {
+		error("Nothing to change");
+		return NULL;
+	}
+
+	xstrfmtcat(query, "select name from %s %s;", cluster_table, extra);
+	xfree(extra);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		xfree(vals);
+		error("no result given for %s", extra);
+		return NULL;
+	}
+	xfree(query);
+	
+	rc = 0;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		object = xstrdup(row[0]);
+		list_append(ret_list, object);
+		if(!rc) {
+			xstrfmtcat(name_char, "name='%s'", object);
+			rc = 1;
+		} else  {
+			xstrfmtcat(name_char, " || name='%s'", object);
+		}
+	}
+	mysql_free_result(result);
+
+	if(!list_count(ret_list)) {
+		debug3("didn't effect anything");
+		xfree(vals);
+		return ret_list;
+	}
+
+	if(vals) {
+		send_char = xstrdup_printf("(%s)", name_char);
+		if(_modify_common(mysql_conn, DBD_MODIFY_CLUSTERS, now,
+				  user, cluster_table, send_char, vals)
+		   == SLURM_ERROR) {
+			error("Couldn't modify cluster 1");
+			list_destroy(ret_list);
+			ret_list = NULL;
+			goto end_it;
+		}
+	}
+
+end_it:
+	xfree(name_char);
+	xfree(assoc_char);
+	xfree(vals);
+	xfree(send_char);
+
+	return ret_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_modify_associations(mysql_conn_t *mysql_conn, 
+					       uint32_t uid, 
+					       acct_association_cond_t *assoc_q,
+					       acct_association_rec_t *assoc)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *vals = NULL, *extra = NULL, *query = NULL, *name_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user = NULL;
+	int set = 0, i = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	char *massoc_req_inx[] = {
+		"id",
+		"acct",
+		"parent_acct",
+		"cluster",
+		"user",
+		"partition",
+		"lft",
+		"rgt"
+	};
+	
+	enum {
+		MASSOC_ID,
+		MASSOC_ACCT,
+		MASSOC_PACCT,
+		MASSOC_CLUSTER,
+		MASSOC_USER,
+		MASSOC_PART,
+		MASSOC_LFT,
+		MASSOC_RGT,
+		MASSOC_COUNT
+	};
+
+	if(!assoc_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user = pw->pw_name;
+	}
+
+	if(assoc_q->acct_list && list_count(assoc_q->acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "acct='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->cluster_list && list_count(assoc_q->cluster_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->cluster_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "cluster='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->user_list && list_count(assoc_q->user_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->user_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "user='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	} else {
+		info("no user specified");
+		xstrcat(extra, " && user = '' ");
+	}
+
+	if(assoc_q->id_list && list_count(assoc_q->id_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->id_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "id=%s", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(assoc_q->parent_acct) {
+		xstrfmtcat(extra, " && parent_acct='%s'", assoc_q->parent_acct);
+	}
+
+	if((int)assoc->fairshare >= 0) 
+		xstrfmtcat(vals, ", fairshare=%u", assoc->fairshare);
+	else if((int)assoc->fairshare == -1) 
+		xstrfmtcat(vals, ", fairshare=1");
+       		
+	if((int)assoc->max_cpu_secs_per_job >= 0) 
+		xstrfmtcat(vals, ", max_cpu_secs_per_job=%u",
+			   assoc->max_cpu_secs_per_job);
+	else if((int)assoc->max_cpu_secs_per_job == -1) 
+		xstrfmtcat(vals, ", max_cpu_secs_per_job=NULL");
+
+	if((int)assoc->max_jobs >= 0) 
+		xstrfmtcat(vals, ", max_jobs=%u", assoc->max_jobs);
+	else if((int)assoc->max_jobs == -1)
+		xstrfmtcat(vals, ", max_jobs=NULL");
+		
+	if((int)assoc->max_nodes_per_job >= 0) 
+		xstrfmtcat(vals, ", max_nodes_per_job=%u",
+			   assoc->max_nodes_per_job);
+	else if((int)assoc->max_nodes_per_job == -1)
+		xstrfmtcat(vals, ", max_nodes_per_job=NULL");
+
+	if((int)assoc->max_wall_duration_per_job >= 0) 
+		xstrfmtcat(vals, ", max_wall_duration_per_job=%u",
+			   assoc->max_wall_duration_per_job);
+	else if((int)assoc->max_wall_duration_per_job == -1) 
+		xstrfmtcat(vals, ", max_wall_duration_per_job=NULL");
+		
+	if(!extra || (!vals && !assoc->parent_acct)) {
+		error("Nothing to change");
+		return NULL;
+	}
+
+	for(i=0; i<MASSOC_COUNT; i++) {
+		if(i) 
+			xstrcat(object, ", ");
+		xstrcat(object, massoc_req_inx[i]);
+	}
+
+	query = xstrdup_printf("select distinct %s from %s where deleted=0%s "
+			       "order by lft FOR UPDATE;",
+			       object, assoc_table, extra);
+	xfree(object);
+	xfree(extra);
+
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	rc = SLURM_SUCCESS;
+	set = 0;
+	extra = NULL;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		acct_association_rec_t *mod_assoc = NULL;
+		int account_type=0;
+/* 		MYSQL_RES *result2 = NULL; */
+/* 		MYSQL_ROW row2; */
+		if(row[MASSOC_PART][0]) { 
+			// see if there is a partition name
+			object = xstrdup_printf(
+				"C = %-10s A = %-20s U = %-9s P = %s",
+				row[MASSOC_CLUSTER], row[MASSOC_ACCT],
+				row[MASSOC_USER], row[MASSOC_PART]);
+		} else if(row[MASSOC_USER][0]){
+			object = xstrdup_printf(
+				"C = %-10s A = %-20s U = %-9s",
+				row[MASSOC_CLUSTER], row[MASSOC_ACCT], 
+				row[MASSOC_USER]);
+		} else {
+			if(row[MASSOC_PACCT][0]) {
+				object = xstrdup_printf(
+					"C = %-10s A = %s of %s",
+					row[MASSOC_CLUSTER], row[MASSOC_ACCT],
+					row[MASSOC_PACCT]);
+			} else {
+				object = xstrdup_printf(
+					"C = %-10s A = %s",
+					row[MASSOC_CLUSTER], row[MASSOC_ACCT]);
+			}
+			if(assoc->parent_acct) {
+				if(!strcasecmp(row[MASSOC_ACCT],
+					       assoc->parent_acct)) {
+					error("You can't make an account be a "
+					      "child of it's self");
+					xfree(object);
+					continue;
+				}
+
+				if(_move_parent(mysql_conn,
+						atoi(row[MASSOC_LFT]),
+						atoi(row[MASSOC_RGT]),
+						row[MASSOC_CLUSTER],
+						row[MASSOC_ID],
+						row[MASSOC_PACCT],
+						assoc->parent_acct)
+				   == SLURM_ERROR)
+					break;
+			}
+			account_type = 1;
+		}
+		list_append(ret_list, object);
+
+		if(!set) {
+			xstrfmtcat(name_char, "(id=%s", row[MASSOC_ID]);
+			set = 1;
+		} else {
+			xstrfmtcat(name_char, " || id=%s", row[MASSOC_ID]);
+		}
+		
+		mod_assoc = xmalloc(sizeof(acct_association_rec_t));
+		mod_assoc->id = atoi(row[MASSOC_ID]);
+
+		mod_assoc->max_cpu_secs_per_job = assoc->max_cpu_secs_per_job;
+		mod_assoc->fairshare = assoc->fairshare;
+		mod_assoc->max_jobs = assoc->max_jobs;
+		mod_assoc->max_nodes_per_job = assoc->max_nodes_per_job;
+		mod_assoc->max_wall_duration_per_job = 
+			assoc->max_wall_duration_per_job;
+		if(!row[MASSOC_USER][0])
+			mod_assoc->parent_acct = xstrdup(assoc->parent_acct);
+
+		if(_addto_update_list(mysql_conn->update_list, 
+				      ACCT_MODIFY_ASSOC,
+				      mod_assoc) != SLURM_SUCCESS) 
+			error("couldn't add to the update list");
+		if(account_type) {
+			_modify_unset_users(mysql_conn,
+					    mod_assoc,
+					    row[MASSOC_ACCT],
+					    atoi(row[MASSOC_LFT]),
+					    atoi(row[MASSOC_RGT]),
+					    ret_list);
+		}
+	}
+	mysql_free_result(result);
+
+	if(assoc->parent_acct) {
+		if(rc != SLURM_SUCCESS) {
+			if(mysql_conn->rollback) {
+				mysql_db_rollback(mysql_conn->acct_mysql_db);
+			}
+			list_destroy(mysql_conn->update_list);
+			mysql_conn->update_list =
+				list_create(destroy_acct_update_object);
+			list_destroy(ret_list);
+			xfree(vals);
+			return NULL;
+		}
+	}
+
+
+	if(!list_count(ret_list)) {
+		debug3("didn't effect anything");
+		xfree(vals);
+		return ret_list;
+	}
+	xstrcat(name_char, ")");
+
+	if(vals) {
+		if(_modify_common(mysql_conn, DBD_MODIFY_ASSOCS, now,
+				  user, assoc_table, name_char, vals)
+		   == SLURM_ERROR) {
+			error("Couldn't modify associations");
+			list_destroy(ret_list);
+			ret_list = NULL;
+			goto end_it;
+		}
+	}
+
+end_it:
+	xfree(name_char);
+	xfree(vals);
+
+	return ret_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_remove_users(mysql_conn_t *mysql_conn, uint32_t uid, 
+					acct_user_cond_t *user_q)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *extra = NULL, *query = NULL,
+		*name_char = NULL, *assoc_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user_name = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	if(!user_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user_name = pw->pw_name;
+	}
+
+	xstrcat(extra, "where deleted=0");
+
+	if(user_q->user_list && list_count(user_q->user_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(user_q->user_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(user_q->def_acct_list && list_count(user_q->def_acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(user_q->def_acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "default_acct='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(user_q->qos != ACCT_QOS_NOTSET) {
+		xstrfmtcat(extra, " && qos=%u", user_q->qos);
+	}
+
+	if(user_q->admin_level != ACCT_ADMIN_NOTSET) {
+		xstrfmtcat(extra, " && admin_level=%u", user_q->admin_level);
+	}
+
+	if(!extra) {
+		error("Nothing to remove");
+		return NULL;
+	}
+
+	query = xstrdup_printf("select name from %s %s;", user_table, extra);
+	xfree(extra);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	rc = 0;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		char *object = xstrdup(row[0]);
+		list_append(ret_list, object);
+		if(!rc) {
+			xstrfmtcat(name_char, "name='%s'", object);
+			xstrfmtcat(assoc_char, "t2.user='%s'", object);
+			rc = 1;
+		} else {
+			xstrfmtcat(name_char, " || name='%s'", object);
+			xstrfmtcat(assoc_char, " || t2.user='%s'", object);
+		}
+	}
+	mysql_free_result(result);
+
+	if(!list_count(ret_list)) {
+		debug3("didn't effect anything");
+		return ret_list;
+	}
+	
+	if(_remove_common(mysql_conn, DBD_REMOVE_USERS, now,
+			  user_name, user_table, name_char, assoc_char)
+	   == SLURM_ERROR) {
+		list_destroy(ret_list);
+		xfree(name_char);
+		xfree(assoc_char);
+		return NULL;
+	}
+	xfree(name_char);
+	xfree(assoc_char);
+
+	return ret_list;
+
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_remove_coord(mysql_conn_t *mysql_conn, uint32_t uid, 
+					char *acct, acct_user_cond_t *user_q)
+{
+#ifdef HAVE_MYSQL
+	return NULL;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_remove_accts(mysql_conn_t *mysql_conn, uint32_t uid, 
+					acct_account_cond_t *acct_q)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *extra = NULL, *query = NULL,
+		*name_char = NULL, *assoc_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user_name = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	if(!acct_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if((pw=getpwuid(uid))) {
+		user_name = pw->pw_name;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	xstrcat(extra, "where deleted=0");
+	if(acct_q->acct_list && list_count(acct_q->acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(acct_q->description_list && list_count(acct_q->description_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->description_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "description='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(acct_q->organization_list && list_count(acct_q->organization_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->organization_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "organization='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(acct_q->qos != ACCT_QOS_NOTSET) {
+		xstrfmtcat(extra, " && qos=%u", acct_q->qos);
+	}
+
+	if(!extra) {
+		error("Nothing to remove");
+		return NULL;
+	}
+
+	query = xstrdup_printf("select name from %s %s;", acct_table, extra);
+	xfree(extra);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	rc = 0;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		char *object = xstrdup(row[0]);
+		list_append(ret_list, object);
+		if(!rc) {
+			xstrfmtcat(name_char, "name='%s'", object);
+			xstrfmtcat(assoc_char, "t2.acct='%s'", object);
+			rc = 1;
+		} else  {
+			xstrfmtcat(name_char, " || name='%s'", object);
+			xstrfmtcat(assoc_char, " || t2.acct='%s'", object);
+		}
+	}
+	mysql_free_result(result);
+
+	if(!list_count(ret_list)) {
+		debug3("didn't effect anything");
+		return ret_list;
+	}
+
+	if(_remove_common(mysql_conn, DBD_REMOVE_ACCOUNTS, now,
+			  user_name, acct_table, name_char, assoc_char)
+	   == SLURM_ERROR) {
+		list_destroy(ret_list);
+		xfree(name_char);
+		xfree(assoc_char);
+		return NULL;
+	}
+	xfree(name_char);
+	xfree(assoc_char);
+
+	return ret_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_remove_clusters(mysql_conn_t *mysql_conn,
+					   uint32_t uid, 
+					   acct_cluster_cond_t *cluster_q)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *extra = NULL, *query = NULL,
+		*name_char = NULL, *assoc_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user_name = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	int day_old = now - DELETE_SEC_BACK;
+
+	if(!cluster_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	if((pw=getpwuid(uid))) {
+		user_name = pw->pw_name;
+	}
+	xstrcat(extra, "where deleted=0");
+	if(cluster_q->cluster_list && list_count(cluster_q->cluster_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(cluster_q->cluster_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(!extra) {
+		error("Nothing to remove");
+		return NULL;
+	}
+
+	query = xstrdup_printf("select name from %s %s;", cluster_table, extra);
+	xfree(extra);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	rc = 0;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		char *object = xstrdup(row[0]);
+		list_append(ret_list, object);
+		if(!rc) {
+			xstrfmtcat(name_char, "name='%s'", object);
+			xstrfmtcat(extra, "t2.cluster='%s'", object);
+			xstrfmtcat(assoc_char, "cluster='%s'", object);
+			rc = 1;
+		} else  {
+			xstrfmtcat(name_char, " || name='%s'", object);
+			xstrfmtcat(extra, " || t2.cluster='%s'", object);
+			xstrfmtcat(assoc_char, " || cluster='%s'", object);
+		}
+	}
+	mysql_free_result(result);
+
+	if(!list_count(ret_list)) {
+		debug3("didn't effect anything\n%s", query);
+		xfree(query);
+		return ret_list;
+	}
+	xfree(query);
+
+	/* if this is a cluster update the machine usage tables as well */
+	query = xstrdup_printf("delete from %s where creation_time>%d && (%s);"
+			       "delete from %s where creation_time>%d && (%s);"
+			       "delete from %s where creation_time>%d && (%s);",
+			       cluster_day_table, day_old, assoc_char,
+			       cluster_hour_table, day_old, assoc_char,
+			       cluster_month_table, day_old, assoc_char);
+	xstrfmtcat(query,
+		   "update %s set mod_time=%d, deleted=1 where (%s);"
+		   "update %s set mod_time=%d, deleted=1 where (%s);"
+		   "update %s set mod_time=%d, deleted=1 where (%s);",
+		   cluster_day_table, now, assoc_char,
+		   cluster_hour_table, now, assoc_char,
+		   cluster_month_table, now, assoc_char);
+	xfree(assoc_char);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	if(rc != SLURM_SUCCESS) {
+		if(mysql_conn->rollback) {
+			mysql_db_rollback(mysql_conn->acct_mysql_db);
+		}
+		list_flush(mysql_conn->update_list);
+		list_destroy(ret_list);
+		xfree(name_char);
+		xfree(extra);
+		return NULL;
+	}
+
+	assoc_char = xstrdup_printf("t2.acct='root' && (%s)", extra);
+	xfree(extra);
+
+	if(_remove_common(mysql_conn, DBD_REMOVE_CLUSTERS, now,
+			  user_name, cluster_table, name_char, assoc_char)
+	   == SLURM_ERROR) {
+		list_destroy(ret_list);
+		xfree(name_char);
+		xfree(assoc_char);
+		return NULL;
+	}
+	xfree(name_char);
+	xfree(assoc_char);
+
+	return ret_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_remove_associations(mysql_conn_t *mysql_conn,
+					       uint32_t uid, 
+					       acct_association_cond_t *assoc_q)
+{
+#ifdef HAVE_MYSQL
+	ListIterator itr = NULL;
+	List ret_list = NULL;
+	int rc = SLURM_SUCCESS;
+	char *object = NULL;
+	char *extra = NULL, *query = NULL,
+		*name_char = NULL, *assoc_char = NULL;
+	time_t now = time(NULL);
+	struct passwd *pw = NULL;
+	char *user_name = NULL;
+	int set = 0, i = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is step_table */
+	char *rassoc_req_inx[] = {
+		"id",
+		"acct",
+		"parent_acct",
+		"cluster",
+		"user",
+		"partition"
+	};
+	
+	enum {
+		RASSOC_ID,
+		RASSOC_ACCT,
+		RASSOC_PACCT,
+		RASSOC_CLUSTER,
+		RASSOC_USER,
+		RASSOC_PART,
+		RASSOC_COUNT
+	};
+
+	if(!assoc_q) {
+		error("we need something to change");
+		return NULL;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	xstrcat(extra, "where id>0 && deleted=0");
+
+	if((pw=getpwuid(uid))) {
+		user_name = pw->pw_name;
+	}
+
+	if(assoc_q->acct_list && list_count(assoc_q->acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "acct='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->cluster_list && list_count(assoc_q->cluster_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->cluster_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "cluster='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->user_list && list_count(assoc_q->user_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->user_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "user='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->id_list && list_count(assoc_q->id_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->id_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "id=%s", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(assoc_q->parent_acct) {
+		xstrfmtcat(extra, " && parent_acct='%s'",
+			   assoc_q->parent_acct);
+	}
+
+	for(i=0; i<RASSOC_COUNT; i++) {
+		if(i) 
+			xstrcat(object, ", ");
+		xstrcat(object, rassoc_req_inx[i]);
+	}
+
+	query = xstrdup_printf("select lft, rgt from %s %s order by lft "
+			       "FOR UPDATE;",
+			       assoc_table, extra);
+	xfree(extra);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+		
+	rc = 0;
+	while((row = mysql_fetch_row(result))) {
+		if(!rc) {
+			xstrfmtcat(name_char, "lft between %s and %s",
+				   row[0], row[1]);
+			rc = 1;
+		} else {
+			xstrfmtcat(name_char, " || lft between %s and %s",
+				   row[0], row[1]);
+		}
+	}
+	mysql_free_result(result);
+
+	if(!name_char) {
+		debug3("didn't effect anything\n%s", query);
+		xfree(query);
+		return ret_list;
+	}
+
+	xfree(query);
+	query = xstrdup_printf("select distinct %s "
+			       "from %s where (%s) order by lft;",
+			       object,
+			       assoc_table, name_char);
+	xfree(extra);
+	xfree(object);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		xfree(name_char);
+		return NULL;
+	}
+
+	rc = 0;
+	ret_list = list_create(slurm_destroy_char);
+	while((row = mysql_fetch_row(result))) {
+		acct_association_rec_t *rem_assoc = NULL;
+
+		if(row[RASSOC_PART][0]) { 
+			// see if there is a partition name
+			object = xstrdup_printf(
+				"C = %-10s A = %-10s U = %-9s P = %s",
+				row[RASSOC_CLUSTER], row[RASSOC_ACCT],
+				row[RASSOC_USER], row[RASSOC_PART]);
+		} else if(row[RASSOC_USER][0]){
+			object = xstrdup_printf(
+				"C = %-10s A = %-10s U = %-9s",
+				row[RASSOC_CLUSTER], row[RASSOC_ACCT], 
+				row[RASSOC_USER]);
+		} else {
+			if(row[RASSOC_PACCT][0]) {
+				object = xstrdup_printf(
+					"C = %-10s A = %s of %s",
+					row[RASSOC_CLUSTER], row[RASSOC_ACCT],
+					row[RASSOC_PACCT]);
+			} else {
+				object = xstrdup_printf(
+					"C = %-10s A = %s",
+					row[RASSOC_CLUSTER], row[RASSOC_ACCT]);
+			}
+		}
+		list_append(ret_list, object);
+		if(!rc) {
+			xstrfmtcat(assoc_char, "id=%s", row[RASSOC_ID]);
+			rc = 1;
+		} else {
+			xstrfmtcat(assoc_char, " || id=%s", row[RASSOC_ID]);
+		}
+
+		rem_assoc = xmalloc(sizeof(acct_association_rec_t));
+		rem_assoc->id = atoi(row[RASSOC_ID]);
+		if(_addto_update_list(mysql_conn->update_list, 
+				      ACCT_REMOVE_ASSOC,
+				      rem_assoc) != SLURM_SUCCESS) 
+			error("couldn't add to the update list");
+
+	}
+	mysql_free_result(result);
+
+	if(_remove_common(mysql_conn, DBD_REMOVE_ASSOCS, now,
+			  user_name, assoc_table, name_char, assoc_char)
+	   == SLURM_ERROR) {
+		list_destroy(ret_list);
+		xfree(name_char);
+		xfree(assoc_char);
+		return NULL;
+	}
+	xfree(name_char);
+	xfree(assoc_char);
+
+	return ret_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_get_users(mysql_conn_t *mysql_conn, 
+				     acct_user_cond_t *user_q)
+{
+#ifdef HAVE_MYSQL
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	List user_list = NULL;
+	ListIterator itr = NULL;
+	char *object = NULL;
+	int set = 0;
+	int i=0;
+	MYSQL_RES *result = NULL, *coord_result = NULL;
+	MYSQL_ROW row, coord_row;
+
+	/* if this changes you will need to edit the corresponding enum */
+	char *user_req_inx[] = {
+		"name",
+		"default_acct",
+		"qos",
+		"admin_level"
+	};
+	enum {
+		USER_REQ_NAME,
+		USER_REQ_DA,
+		USER_REQ_EX,
+		USER_REQ_AL,
+		USER_REQ_COUNT
+	};
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	xstrcat(extra, "where deleted=0");
+
+	if(!user_q) 
+		goto empty;
+
+	if(user_q->user_list && list_count(user_q->user_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(user_q->user_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(user_q->def_acct_list && list_count(user_q->def_acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(user_q->def_acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "default_acct='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(user_q->qos != ACCT_QOS_NOTSET) {
+		if(extra)
+			xstrfmtcat(extra, " && qos=%u", user_q->qos);
+		else
+			xstrfmtcat(extra, " where qos=%u",
+				   user_q->qos);
+			
+	}
+
+	if(user_q->admin_level != ACCT_ADMIN_NOTSET) {
+		if(extra)
+			xstrfmtcat(extra, " && admin_level=%u",
+				   user_q->admin_level);
+		else
+			xstrfmtcat(extra, " where admin_level=%u",
+				   user_q->admin_level);
+	}
+empty:
+
+	xfree(tmp);
+	xstrfmtcat(tmp, "%s", user_req_inx[i]);
+	for(i=1; i<USER_REQ_COUNT; i++) {
+		xstrfmtcat(tmp, ", %s", user_req_inx[i]);
+	}
+
+	query = xstrdup_printf("select %s from %s %s", tmp, user_table, extra);
+	xfree(tmp);
+	xfree(extra);
+	
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	user_list = list_create(destroy_acct_user_rec);
+
+	while((row = mysql_fetch_row(result))) {
+		acct_user_rec_t *user = xmalloc(sizeof(acct_user_rec_t));
+		struct passwd *passwd_ptr = NULL;
+		list_append(user_list, user);
+
+		user->name =  xstrdup(row[USER_REQ_NAME]);
+		user->default_acct = xstrdup(row[USER_REQ_DA]);
+		user->admin_level = atoi(row[USER_REQ_AL]);
+		user->qos = atoi(row[USER_REQ_EX]);
+
+		passwd_ptr = getpwnam(user->name);
+		if(passwd_ptr) 
+			user->uid = passwd_ptr->pw_uid;
+		
+		user->coord_accts = list_create(destroy_acct_coord_rec);
+		query = xstrdup_printf("select acct from %s where user='%s' "
+				       "&& deleted=0",
+				       acct_coord_table, user->name);
+
+		if(!(coord_result =
+		     mysql_db_query_ret(mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			continue;
+		}
+		xfree(query);
+		
+		while((coord_row = mysql_fetch_row(coord_result))) {
+			acct_coord_rec_t *coord =
+				xmalloc(sizeof(acct_coord_rec_t));
+			list_append(user->coord_accts, coord);
+			coord->acct_name = xstrdup(coord_row[0]);
+			coord->sub_acct = 0;
+		}
+		mysql_free_result(coord_result);
+		/* FIX ME: ADD SUB projects here from assoc list lft
+		 * rgt */
+		
+		if(user_q && user_q->with_assocs) {
+			acct_association_cond_t *assoc_q = NULL;
+			if(!user_q->assoc_cond) {
+				user_q->assoc_cond = xmalloc(
+					sizeof(acct_association_cond_t));
+			}
+			assoc_q = user_q->assoc_cond;
+			if(assoc_q->user_list)
+				list_destroy(assoc_q->user_list);
+
+			assoc_q->user_list = list_create(NULL);
+			list_append(assoc_q->user_list, user->name);
+			user->assoc_list = acct_storage_p_get_associations(
+				mysql_conn, assoc_q);
+			list_destroy(assoc_q->user_list);
+			assoc_q->user_list = NULL;
+		}
+	}
+	mysql_free_result(result);
+
+	return user_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_get_accts(mysql_conn_t *mysql_conn, 
+				     acct_account_cond_t *acct_q)
+{
+#ifdef HAVE_MYSQL
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	List acct_list = NULL;
+	ListIterator itr = NULL;
+	char *object = NULL;
+	int set = 0;
+	int i=0;
+	MYSQL_RES *result = NULL, *coord_result = NULL;
+	MYSQL_ROW row, coord_row;
+
+	/* if this changes you will need to edit the corresponding enum */
+	char *acct_req_inx[] = {
+		"name",
+		"description",
+		"qos",
+		"organization"
+	};
+	enum {
+		ACCT_REQ_NAME,
+		ACCT_REQ_DESC,
+		ACCT_REQ_QOS,
+		ACCT_REQ_ORG,
+		ACCT_REQ_COUNT
+	};
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	xstrcat(extra, "where deleted=0");
+	if(!acct_q) 
+		goto empty;
+
+	if(acct_q->acct_list && list_count(acct_q->acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(acct_q->description_list && list_count(acct_q->description_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->description_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "description='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(acct_q->organization_list && list_count(acct_q->organization_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(acct_q->organization_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "organization='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(acct_q->qos != ACCT_QOS_NOTSET) {
+		if(extra)
+			xstrfmtcat(extra, " && qos=%u", acct_q->qos);
+		else
+			xstrfmtcat(extra, " where qos=%u",
+				   acct_q->qos);
+	}
+
+empty:
+
+	xfree(tmp);
+	xstrfmtcat(tmp, "%s", acct_req_inx[i]);
+	for(i=1; i<ACCT_REQ_COUNT; i++) {
+		xstrfmtcat(tmp, ", %s", acct_req_inx[i]);
+	}
+
+	query = xstrdup_printf("select %s from %s %s", tmp, acct_table, extra);
+	xfree(tmp);
+	xfree(extra);
+	
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	acct_list = list_create(destroy_acct_account_rec);
+
+	while((row = mysql_fetch_row(result))) {
+		acct_account_rec_t *acct = xmalloc(sizeof(acct_account_rec_t));
+		list_append(acct_list, acct);
+
+		acct->name =  xstrdup(row[ACCT_REQ_NAME]);
+		acct->description = xstrdup(row[ACCT_REQ_DESC]);
+		acct->organization = xstrdup(row[ACCT_REQ_ORG]);
+		acct->qos = atoi(row[ACCT_REQ_QOS]);
+
+		acct->coordinators = list_create(slurm_destroy_char);
+		query = xstrdup_printf("select user from %s where acct='%s' "
+				       "&& deleted=0;",
+				       acct_coord_table, acct->name);
+
+		if(!(coord_result =
+		     mysql_db_query_ret(mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			continue;
+		}
+		xfree(query);
+		
+		while((coord_row = mysql_fetch_row(coord_result))) {
+			object = xstrdup(coord_row[0]);
+			list_append(acct->coordinators, object);
+		}
+		mysql_free_result(coord_result);
+
+		if(acct_q && acct_q->with_assocs) {
+			acct_association_cond_t *assoc_q = NULL;
+			if(!acct_q->assoc_cond) {
+				acct_q->assoc_cond = xmalloc(
+					sizeof(acct_association_cond_t));
+			}
+			assoc_q = acct_q->assoc_cond;
+			if(assoc_q->acct_list)
+				list_destroy(assoc_q->acct_list);
+
+			assoc_q->acct_list = list_create(NULL);
+			list_append(assoc_q->acct_list, acct->name);
+			acct->assoc_list = acct_storage_p_get_associations(
+				mysql_conn, assoc_q);
+			list_destroy(assoc_q->acct_list);
+			assoc_q->acct_list = NULL;
+		}
+
+	}
+	mysql_free_result(result);
+
+	return acct_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_get_clusters(mysql_conn_t *mysql_conn, 
+					acct_cluster_cond_t *cluster_q)
+{
+#ifdef HAVE_MYSQL
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	List cluster_list = NULL;
+	ListIterator itr = NULL;
+	char *object = NULL;
+	int set = 0;
+	int i=0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	/* if this changes you will need to edit the corresponding enum */
+	char *cluster_req_inx[] = {
+		"name",
+		"control_host",
+		"control_port"
+	};
+	enum {
+		CLUSTER_REQ_NAME,
+		CLUSTER_REQ_CH,
+		CLUSTER_REQ_CP,
+		CLUSTER_REQ_COUNT
+	};
+	char *assoc_req_inx[] = {
+		"fairshare",
+		"max_jobs",
+		"max_nodes_per_job",
+		"max_wall_duration_per_job",
+		"max_cpu_secs_per_job",
+	};
+	enum {
+		ASSOC_REQ_FS,
+		ASSOC_REQ_MJ,
+		ASSOC_REQ_MNPJ,
+		ASSOC_REQ_MWPJ,
+		ASSOC_REQ_MCPJ,
+		ASSOC_REQ_COUNT
+	};
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	xstrcat(extra, "where deleted=0");
+		
+	if(!cluster_q) 
+		goto empty;
+
+	if(cluster_q->cluster_list && list_count(cluster_q->cluster_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(cluster_q->cluster_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "name='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+empty:
+
+	xfree(tmp);
+	i=0;
+	xstrfmtcat(tmp, "%s", cluster_req_inx[i]);
+	for(i=1; i<CLUSTER_REQ_COUNT; i++) {
+		xstrfmtcat(tmp, ", %s", cluster_req_inx[i]);
+	}
+
+	query = xstrdup_printf("select %s from %s %s", 
+			       tmp, cluster_table, extra);
+	xfree(tmp);
+	xfree(extra);
+	
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	i=0;
+	xstrfmtcat(tmp, "%s", assoc_req_inx[i]);
+	for(i=1; i<ASSOC_REQ_COUNT; i++) {
+		xstrfmtcat(tmp, ", %s", assoc_req_inx[i]);
+	}
+
+	cluster_list = list_create(destroy_acct_cluster_rec);
+
+	while((row = mysql_fetch_row(result))) {
+		acct_cluster_rec_t *cluster =
+			xmalloc(sizeof(acct_cluster_rec_t));
+		MYSQL_RES *result2 = NULL;
+		MYSQL_ROW row2;
+		list_append(cluster_list, cluster);
+
+		cluster->name =  xstrdup(row[CLUSTER_REQ_NAME]);
+		cluster->control_host = xstrdup(row[CLUSTER_REQ_CH]);
+		cluster->control_port = atoi(row[CLUSTER_REQ_CP]);
+		query = xstrdup_printf("select %s from %s where cluster='%s' "
+				       "&& acct='root'", 
+				       tmp, assoc_table, cluster->name);
+		if(!(result2 = mysql_db_query_ret(mysql_conn->acct_mysql_db,
+						  query, 1))) {
+			xfree(query);
+			break;
+		}
+		xfree(query);
+		row2 = mysql_fetch_row(result2);
+
+		if(row2[ASSOC_REQ_FS])
+			cluster->default_fairshare = atoi(row2[ASSOC_REQ_FS]);
+		else
+			cluster->default_fairshare = 1;
+
+		if(row2[ASSOC_REQ_MJ])
+			cluster->default_max_jobs = atoi(row2[ASSOC_REQ_MJ]);
+		else
+			cluster->default_max_jobs = -1;
+		
+		if(row2[ASSOC_REQ_MNPJ])
+			cluster->default_max_nodes_per_job =
+				atoi(row2[ASSOC_REQ_MNPJ]);
+		else
+			cluster->default_max_nodes_per_job = -1;
+		
+		if(row2[ASSOC_REQ_MWPJ])
+			cluster->default_max_wall_duration_per_job = 
+				atoi(row2[ASSOC_REQ_MWPJ]);
+		else
+			cluster->default_max_wall_duration_per_job = -1;
+		
+		if(row2[ASSOC_REQ_MCPJ])
+			cluster->default_max_cpu_secs_per_job = 
+				atoi(row2[ASSOC_REQ_MCPJ]);
+		else 
+			cluster->default_max_cpu_secs_per_job = -1;
+		mysql_free_result(result2);
+	}
+	mysql_free_result(result);
+	xfree(tmp);
+
+	return cluster_list;
+#else
+	return NULL;
+#endif
+}
+
+extern List acct_storage_p_get_associations(mysql_conn_t *mysql_conn, 
+					    acct_association_cond_t *assoc_q)
+{
+#ifdef HAVE_MYSQL
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	List assoc_list = NULL;
+	ListIterator itr = NULL;
+	char *object = NULL;
+	int set = 0;
+	int i=0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	int parent_mj = -1;
+	int parent_mnpj = -1;
+	int parent_mwpj = -1;
+	int parent_mcpj = -1;
+	char *last_acct = NULL;
+	char *last_acct_parent = NULL;
+	char *last_cluster = NULL;
+	uint32_t user_parent_id = 0;
+	uint32_t acct_parent_id = 0;
+
+	/* if this changes you will need to edit the corresponding enum */
+	char *assoc_req_inx[] = {
+		"id",
+		"user",
+		"acct",
+		"cluster",
+		"partition",
+		"parent_acct",
+		"fairshare",
+		"max_jobs",
+		"max_nodes_per_job",
+		"max_wall_duration_per_job",
+		"max_cpu_secs_per_job",
+	};
+	enum {
+		ASSOC_REQ_ID,
+		ASSOC_REQ_USER,
+		ASSOC_REQ_ACCT,
+		ASSOC_REQ_CLUSTER,
+		ASSOC_REQ_PART,
+		ASSOC_REQ_PARENT,
+		ASSOC_REQ_FS,
+		ASSOC_REQ_MJ,
+		ASSOC_REQ_MNPJ,
+		ASSOC_REQ_MWPJ,
+		ASSOC_REQ_MCPJ,
+		ASSOC_REQ_COUNT
+	};
+	enum {
+		ASSOC2_REQ_PARENT_ID,
+		ASSOC2_REQ_MJ,
+		ASSOC2_REQ_MNPJ,
+		ASSOC2_REQ_MWPJ,
+		ASSOC2_REQ_MCPJ
+	};
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+
+	xstrcat(extra, "where deleted=0");
+	if(!assoc_q) 
+		goto empty;
+
+	if(assoc_q->acct_list && list_count(assoc_q->acct_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->acct_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "acct='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->cluster_list && list_count(assoc_q->cluster_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->cluster_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "cluster='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->user_list && list_count(assoc_q->user_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->user_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "user='%s'", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(assoc_q->id_list && list_count(assoc_q->id_list)) {
+		set = 0;
+		xstrcat(extra, " && (");
+		itr = list_iterator_create(assoc_q->id_list);
+		while((object = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			xstrfmtcat(extra, "id=%s", object);
+			set = 1;
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	if(assoc_q->parent_acct) {
+		xstrfmtcat(extra, " && parent_acct='%s'", assoc_q->parent_acct);
+	}
+empty:
+	xfree(tmp);
+	xstrfmtcat(tmp, "%s", assoc_req_inx[i]);
+	for(i=1; i<ASSOC_REQ_COUNT; i++) {
+		xstrfmtcat(tmp, ", %s", assoc_req_inx[i]);
+	}
+
+	query = xstrdup_printf("select %s from %s %s order by lft;", 
+			       tmp, assoc_table, extra);
+	xfree(tmp);
+	xfree(extra);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+
+	assoc_list = list_create(destroy_acct_association_rec);
+	
+	while((row = mysql_fetch_row(result))) {
+		acct_association_rec_t *assoc =
+			xmalloc(sizeof(acct_association_rec_t));
+		MYSQL_RES *result2 = NULL;
+		MYSQL_ROW row2;
+
+		list_append(assoc_list, assoc);
+		
+		assoc->id =  atoi(row[ASSOC_REQ_ID]);
+		
+		if(row[ASSOC_REQ_USER][0])
+			assoc->user = xstrdup(row[ASSOC_REQ_USER]);
+		assoc->acct = xstrdup(row[ASSOC_REQ_ACCT]);
+		assoc->cluster = xstrdup(row[ASSOC_REQ_CLUSTER]);
+		
+		if(row[ASSOC_REQ_PARENT][0]) {
+			if(!last_acct_parent || !last_cluster 
+			   || strcmp(row[ASSOC_REQ_PARENT], last_acct_parent)
+			   || strcmp(row[ASSOC_REQ_CLUSTER], last_cluster)) {
+			
+			query = xstrdup_printf(
+					"select id from %s where user='' "
+					"and deleted = 0 and acct='%s' "
+					"and cluster='%s';", 
+					assoc_table, row[ASSOC_REQ_PARENT],
+					row[ASSOC_REQ_CLUSTER]);
+			
+				if(!(result2 = mysql_db_query_ret(
+					     mysql_conn->acct_mysql_db,
+					     query, 1))) {
+					xfree(query);
+					break;
+				}
+				xfree(query);
+				row2 = mysql_fetch_row(result2);
+				last_acct_parent = row[ASSOC_REQ_PARENT];
+				last_cluster = row[ASSOC_REQ_CLUSTER];
+				acct_parent_id = atoi(row2[0]);	
+				mysql_free_result(result2);
+			}
+			assoc->parent_acct = xstrdup(row[ASSOC_REQ_PARENT]);
+			assoc->parent_id = acct_parent_id;
+		} 
+
+		if(row[ASSOC_REQ_PART][0])
+			assoc->partition = xstrdup(row[ASSOC_REQ_PART]);
+		if(row[ASSOC_REQ_FS])
+			assoc->fairshare = atoi(row[ASSOC_REQ_FS]);
+		else
+			assoc->fairshare = 1;
+
+		if(!last_acct || !last_cluster 
+		   || strcmp(row[ASSOC_REQ_ACCT], last_acct)
+		   || strcmp(row[ASSOC_REQ_CLUSTER], last_cluster)) {
+			query = xstrdup_printf(
+				"call get_parent_limits('%s', '%s', '%s');"
+				"select @par_id, @mj, @mnpj, @mwpj, @mcpj;", 
+				assoc_table, row[ASSOC_REQ_ACCT],
+				row[ASSOC_REQ_CLUSTER]);
+			
+			if(!(result2 = mysql_db_query_ret(
+				     mysql_conn->acct_mysql_db, query, 1))) {
+				xfree(query);
+				break;
+			}
+			xfree(query);
+			
+			row2 = mysql_fetch_row(result2);
+			user_parent_id = atoi(row2[ASSOC2_REQ_PARENT_ID]);
+			
+			if(row2[ASSOC2_REQ_MJ])
+				parent_mj = atoi(row2[ASSOC2_REQ_MJ]);
+			else
+				parent_mj = -1;
+			
+			if(row2[ASSOC2_REQ_MNPJ])
+				parent_mnpj = atoi(row2[ASSOC2_REQ_MNPJ]);
+			else
+				parent_mwpj = -1;
+			
+			if(row2[ASSOC2_REQ_MWPJ])
+				parent_mwpj = atoi(row2[ASSOC2_REQ_MWPJ]);
+			else
+				parent_mwpj = -1;
+			
+			if(row2[ASSOC2_REQ_MCPJ])
+				parent_mcpj = atoi(row2[ASSOC2_REQ_MCPJ]);
+			else 
+				parent_mcpj = -1;
+			
+			last_acct = row[ASSOC_REQ_ACCT];
+			last_cluster = row[ASSOC_REQ_CLUSTER];
+			mysql_free_result(result2);
+		}
+		if(row[ASSOC_REQ_MJ])
+			assoc->max_jobs = atoi(row[ASSOC_REQ_MJ]);
+		else
+			assoc->max_jobs = parent_mj;
+		if(row[ASSOC_REQ_MNPJ])
+			assoc->max_nodes_per_job = 
+				atoi(row[ASSOC_REQ_MNPJ]);
+		else
+			assoc->max_nodes_per_job = parent_mnpj;
+		if(row[ASSOC_REQ_MWPJ])
+			assoc->max_wall_duration_per_job = 
+				atoi(row[ASSOC_REQ_MWPJ]);
+		else
+			assoc->max_wall_duration_per_job = parent_mwpj;
+		if(row[ASSOC_REQ_MCPJ])
+			assoc->max_cpu_secs_per_job = 
+				atoi(row[ASSOC_REQ_MCPJ]);
+		else
+			assoc->max_cpu_secs_per_job = parent_mcpj;
+
+		if(assoc->parent_id != acct_parent_id)
+			assoc->parent_id = user_parent_id;
+		//info("parent id is %d", assoc->parent_id);
+		//log_assoc_rec(assoc);
+	}
+	mysql_free_result(result);
+
+	return assoc_list;
+#else
+	return NULL;
+#endif
+}
+
+extern int acct_storage_p_get_usage(mysql_conn_t *mysql_conn,
+				    acct_association_rec_t *acct_assoc,
+				    time_t start, time_t end)
+{
+#ifdef HAVE_MYSQL
+	int rc = SLURM_SUCCESS;
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_roll_usage(mysql_conn_t *mysql_conn, 
+				     time_t sent_start)
+{
+#ifdef HAVE_MYSQL
+	int rc = SLURM_SUCCESS;
+	int i = 0;
+	time_t my_time = time(NULL);
+	struct tm start_tm;
+	struct tm end_tm;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	char *query = NULL;
+	char *tmp = NULL;
+	time_t last_hour = sent_start;
+	time_t last_day = sent_start;
+	time_t last_month = sent_start;
+	time_t start_time = 0;
+  	time_t end_time = 0;
+	DEF_TIMERS;
+
+	char *update_req_inx[] = {
+		"hourly_rollup",
+		"daily_rollup",
+		"monthly_rollup"
+	};
+	
+	enum {
+		UPDATE_HOUR,
+		UPDATE_DAY,
+		UPDATE_MONTH,
+		UPDATE_COUNT
+	};
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	if(!sent_start) {
+		i=0;
+		xstrfmtcat(tmp, "%s", update_req_inx[i]);
+		for(i=1; i<UPDATE_COUNT; i++) {
+			xstrfmtcat(tmp, ", %s", update_req_inx[i]);
+		}
+		query = xstrdup_printf("select %s from %s",
+				       tmp, last_ran_table);
+		xfree(tmp);
+		
+		if(!(result = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			return SLURM_ERROR;
+		}
+		
+		xfree(query);
+		row = mysql_fetch_row(result);
+		if(row) {
+			last_hour = atoi(row[UPDATE_HOUR]);
+			last_day = atoi(row[UPDATE_DAY]);
+			last_month = atoi(row[UPDATE_MONTH]);		
+			mysql_free_result(result);
+		} else {
+			query = xstrdup_printf(
+				"select @PS := period_start from %s limit 1;"
+				"insert into %s "
+				"(hourly_rollup, daily_rollup, monthly_rollup) "
+				"values (@PS, @PS, @PS);",
+				event_table, last_ran_table);
+			
+			mysql_free_result(result);
+			if(!(result = mysql_db_query_ret(
+				     mysql_conn->acct_mysql_db, query, 0))) {
+				xfree(query);
+				return SLURM_ERROR;
+			}
+			xfree(query);
+			row = mysql_fetch_row(result);
+			if(!row) {
+				debug("No clusters have been added "
+				      "not doing rollup");
+				mysql_free_result(result);
+				return SLURM_SUCCESS;
+			}
+			
+			last_hour = last_day = last_month = atoi(row[0]);
+			mysql_free_result(result);
+		}
+	}
+/* 	last_hour = 1211475599; */
+/* 	last_day = 1211475599; */
+/* 	last_month = 1211475599; */
+
+//	last_hour = 1211403599;
+	//	last_hour = 1206946800;
+//	last_day = 1207033199;
+//	last_day = 1197033199;
+//	last_month = 1204358399;
+
+	if(!localtime_r(&last_hour, &start_tm)) {
+		error("Couldn't get localtime from hour start %d", last_hour);
+		return SLURM_ERROR;
+	}
+	
+	if(!localtime_r(&my_time, &end_tm)) {
+		error("Couldn't get localtime from hour end %d", my_time);
+		return SLURM_ERROR;
+	}
+
+	/* below and anywhere in a rollup plugin when dealing with
+	 * epoch times we need to set the tm_isdst = -1 so we don't
+	 * have to worry about the time changes.  Not setting it to -1
+	 * will cause problems in the month with the date change.
+	 */
+
+	start_tm.tm_sec = 0;
+	start_tm.tm_min = 0;
+	start_tm.tm_hour++;
+	start_tm.tm_isdst = -1;
+	start_time = mktime(&start_tm);
+	end_tm.tm_sec = 59;
+	end_tm.tm_min = 59;
+	end_tm.tm_hour--;
+	end_tm.tm_isdst = -1;
+	end_time = mktime(&end_tm);
+	if(end_time-start_time > 0) {
+		START_TIMER;
+		if((rc = mysql_hourly_rollup(mysql_conn, start_time, end_time)) 
+		   != SLURM_SUCCESS)
+			return rc;
+		END_TIMER2("hourly_rollup");
+		query = xstrdup_printf("update %s set hourly_rollup=%d",
+				       last_ran_table, end_time);
+	} else {
+		debug2("no need to run this hour %d < %d", 
+		       end_time, start_time);
+	}
+
+	if(!localtime_r(&last_day, &start_tm)) {
+		error("Couldn't get localtime from day %d", last_day);
+		return SLURM_ERROR;
+	}
+	start_tm.tm_sec = 0;
+	start_tm.tm_min = 0;
+	start_tm.tm_hour = 0;
+	start_tm.tm_mday++;
+	start_tm.tm_isdst = -1;
+	start_time = mktime(&start_tm);
+	end_tm.tm_hour = 23;
+	end_tm.tm_mday--;
+	end_tm.tm_isdst = -1;
+	end_time = mktime(&end_tm);
+	if(end_time-start_time > 0) {
+		START_TIMER;
+		if((rc = mysql_daily_rollup(mysql_conn, start_time, end_time)) 
+		   != SLURM_SUCCESS)
+			return rc;
+		END_TIMER2("daily_rollup");
+		if(query) 
+			xstrfmtcat(query, ", daily_rollup=%d", end_time);
+		else 
+			query = xstrdup_printf("update %s set daily_rollup=%d",
+					       last_ran_table, end_time);
+	} else {
+		debug2("no need to run this day %d < %d", end_time, start_time);
+	}
+
+	if(!localtime_r(&last_month, &start_tm)) {
+		error("Couldn't get localtime from month %d", last_month);
+		return SLURM_ERROR;
+	}
+
+	start_tm.tm_sec = 0;
+	start_tm.tm_min = 0;
+	start_tm.tm_hour = 0;
+	start_tm.tm_mday = 1;
+	start_tm.tm_mon++;
+	start_tm.tm_isdst = -1;
+	start_time = mktime(&start_tm);
+	end_tm.tm_sec = -1;
+	end_tm.tm_min = 0;
+	end_tm.tm_hour = 0;
+	end_tm.tm_mday = 1;
+	end_tm.tm_isdst = -1;
+	end_time = mktime(&end_tm);
+	if(end_time-start_time > 0) {
+		START_TIMER;
+		if((rc = mysql_monthly_rollup(
+			    mysql_conn, start_time, end_time)) != SLURM_SUCCESS)
+			return rc;
+		END_TIMER2("monthly_rollup");
+
+		if(query) 
+			xstrfmtcat(query, ", montly_rollup=%d", end_time);
+		else 
+			query = xstrdup_printf(
+				"update %s set monthly_rollup=%d",
+				last_ran_table, end_time);
+	} else {
+		debug2("no need to run this month %d < %d",
+		       end_time, start_time);
+	}
+	
+	if(query) {
+		debug3("%s", query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+	}
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int clusteracct_storage_p_node_down(mysql_conn_t *mysql_conn, 
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time, char *reason)
+{
+#ifdef HAVE_MYSQL
+	uint16_t cpus;
+	int rc = SLURM_SUCCESS;
+	char *query = NULL;
+	char *my_reason;
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	if (slurmctld_conf.fast_schedule && !slurmdbd_conf)
+		cpus = node_ptr->config_ptr->cpus;
+	else
+		cpus = node_ptr->cpus;
+
+	if (reason)
+		my_reason = reason;
+	else
+		my_reason = node_ptr->reason;
+	
+	debug2("inserting %s(%s) with %u cpus", node_ptr->name, cluster, cpus);
+
+	query = xstrdup_printf(
+		"update %s set period_end=%d where cluster='%s' "
+		"and period_end=0 and node_name='%s';",
+		event_table, (event_time-1), cluster, node_ptr->name);
+	xstrfmtcat(query,
+		   "insert into %s "
+		   "(node_name, cluster, cpu_count, period_start, reason) "
+		   "values ('%s', '%s', %u, %d, '%s');",
+		   event_table, node_ptr->name, cluster, 
+		   cpus, event_time, my_reason);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+extern int clusteracct_storage_p_node_up(mysql_conn_t *mysql_conn, 
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time)
+{
+#ifdef HAVE_MYSQL
+	char* query;
+	int rc = SLURM_SUCCESS;
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	query = xstrdup_printf(
+		"update %s set period_end=%d where cluster='%s' "
+		"and period_end=0 and node_name='%s';",
+		event_table, (event_time-1), cluster, node_ptr->name);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int clusteracct_storage_p_register_ctld(char *cluster,
+					       uint16_t port)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_cluster_procs(mysql_conn_t *mysql_conn, 
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time)
+{
+#ifdef HAVE_MYSQL
+	static uint32_t last_procs = -1;
+	char* query;
+	int rc = SLURM_SUCCESS;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+
+	if (procs == last_procs) {
+		debug3("we have the same procs as before no need to "
+		       "update the database.");
+		return SLURM_SUCCESS;
+	}
+	last_procs = procs;
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	/* Record the processor count */
+	query = xstrdup_printf(
+		"select cpu_count from %s where cluster='%s' "
+		"and period_end=0 and node_name=''",
+		event_table, cluster);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	/* we only are checking the first one here */
+	if(!(row = mysql_fetch_row(result))) {
+		debug("We don't have an entry for this machine %s "
+		      "most likely a first time running.", cluster);
+		goto add_it;
+	}
+
+	if(atoi(row[0]) == procs) {
+		debug("%s hasn't changed since last entry", cluster);
+		goto end_it;
+	}
+	debug("%s has changed from %s cpus to %u", cluster, row[0], procs);   
+
+	query = xstrdup_printf(
+		"update %s set period_end=%d where cluster='%s' "
+		"and period_end=0 and node_name=''",
+		event_table, (event_time-1), cluster);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	if(rc != SLURM_SUCCESS)
+		goto end_it;
+add_it:
+	query = xstrdup_printf(
+		"insert into %s (cluster, cpu_count, period_start) "
+		"values ('%s', %u, %d)",
+		event_table, cluster, procs, event_time);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+
+end_it:
+	mysql_free_result(result);
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int clusteracct_storage_p_get_usage(
+	mysql_conn_t *mysql_conn,
+	acct_cluster_rec_t *cluster_rec, time_t start, time_t end)
+{
+#ifdef HAVE_MYSQL
+
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage the start of a job
+ */
+extern int jobacct_storage_p_job_start(mysql_conn_t *mysql_conn, 
+				       struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	int	rc=SLURM_SUCCESS;
+	char	*jname, *nodes;
+	long	priority;
+	int track_steps = 0;
+	char *block_id = NULL;
+	char *query = NULL;
+	int reinit = 0;
+
+	if (!job_ptr->details || !job_ptr->details->submit_time) {
+		error("jobacct_storage_p_job_start: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+	
+	debug2("mysql_jobacct_job_start() called");
+	priority = (job_ptr->priority == NO_VAL) ?
+		-1L : (long) job_ptr->priority;
+
+	if (job_ptr->name && job_ptr->name[0]) {
+		int i;
+		jname = xmalloc(strlen(job_ptr->name) + 1);
+		for (i=0; job_ptr->name[i]; i++) {
+			if (isalnum(job_ptr->name[i]))
+				jname[i] = job_ptr->name[i];
+			else
+				jname[i] = '_';
+		}
+	} else {
+		jname = xstrdup("allocation");
+		track_steps = 1;
+	}
+
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->batch_flag)
+		track_steps = 1;
+
+	if(slurmdbd_conf) {
+		block_id = xstrdup(job_ptr->comment);
+	} else {
+		select_g_get_jobinfo(job_ptr->select_jobinfo, 
+				     SELECT_DATA_BLOCK_ID, 
+				     &block_id);
+	}
+
+	job_ptr->requid = -1; /* force to -1 for sacct to know this
+			       * hasn't been set yet */
+	if(!job_ptr->db_index) {
+		query = xstrdup_printf(
+			"insert into %s "
+			"(jobid, account, associd, uid, gid, partition, "
+			"blockid, eligible, submit, start, name, track_steps, "
+			"state, priority, req_cpus, alloc_cpus, nodelist) "
+			"values (%u, '%s', %u, %u, %u, '%s', '%s', "
+			"%d, %d, %d, '%s', %u, "
+			"%u, %u, %u, %u, '%s') "
+			"on duplicate key update id=LAST_INSERT_ID(id)",
+			job_table, job_ptr->job_id, job_ptr->account, 
+			job_ptr->assoc_id,
+			job_ptr->user_id, job_ptr->group_id,
+			job_ptr->partition, block_id,
+			(int)job_ptr->details->begin_time,
+			(int)job_ptr->details->submit_time,
+			(int)job_ptr->start_time,
+			jname, track_steps,
+			job_ptr->job_state & (~JOB_COMPLETING),
+			priority, job_ptr->num_procs,
+			job_ptr->total_procs, nodes);
+
+	try_again:
+		if(!(job_ptr->db_index = mysql_insert_ret_id(
+			     mysql_conn->acct_mysql_db, query))) {
+			if(!reinit) {
+				error("It looks like the storage has gone "
+				      "away trying to reconnect");
+				mysql_close_db_connection(
+					&mysql_conn->acct_mysql_db);
+				mysql_get_db_connection(
+					&mysql_conn->acct_mysql_db,
+					mysql_db_name, mysql_db_info);
+				reinit = 1;
+				goto try_again;
+			} else
+				rc = SLURM_ERROR;
+		}
+	} else {
+		query = xstrdup_printf(
+			"update %s set partition='%s', blockid='%s', start=%d, "
+			"name='%s', state=%u, alloc_cpus=%u, nodelist='%s', "
+			"account='%s' where id=%d",
+			job_table, job_ptr->partition, block_id,
+			(int)job_ptr->start_time,
+			jname, 
+			job_ptr->job_state & (~JOB_COMPLETING),
+			job_ptr->total_procs, nodes, 
+			job_ptr->account, job_ptr->db_index);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	}
+
+	xfree(block_id);
+	xfree(jname);
+
+	xfree(query);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage the end of a job
+ */
+extern int jobacct_storage_p_job_complete(mysql_conn_t *mysql_conn, 
+					  struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	char *query = NULL, *nodes = NULL;
+	int rc=SLURM_SUCCESS;
+	
+	if (!job_ptr->db_index 
+	    && (!job_ptr->details || !job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_job_complete: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+	debug2("mysql_jobacct_job_complete() called");
+	if (job_ptr->end_time == 0) {
+		debug("mysql_jobacct: job %u never started", job_ptr->job_id);
+		return SLURM_ERROR;
+	}	
+	
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(!job_ptr->db_index) {
+		job_ptr->db_index = _get_db_index(mysql_conn->acct_mysql_db,
+						  job_ptr->details->submit_time,
+						  job_ptr->job_id,
+						  job_ptr->assoc_id);
+		if(job_ptr->db_index == (uint32_t)-1) {
+			
+		}
+	}
+	query = xstrdup_printf("update %s set start=%u, end=%u, state=%d, "
+			       "nodelist='%s', comp_code=%u, "
+			       "kill_requid=%u where id=%u",
+			       job_table, (int)job_ptr->start_time,
+			       (int)job_ptr->end_time, 
+			       job_ptr->job_state & (~JOB_COMPLETING),
+			       nodes, job_ptr->exit_code,
+			       job_ptr->requid, job_ptr->db_index);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	
+	return  rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage the start of a job step
+ */
+extern int jobacct_storage_p_step_start(mysql_conn_t *mysql_conn, 
+					struct step_record *step_ptr)
+{
+#ifdef HAVE_MYSQL
+	int cpus = 0;
+	int rc=SLURM_SUCCESS;
+	char node_list[BUFFER_SIZE];
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	char *query = NULL;
+	
+	if (!step_ptr->job_ptr->db_index 
+	    && (!step_ptr->job_ptr->details
+		|| !step_ptr->job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_step_start: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+	if(slurmdbd_conf) {
+		cpus = step_ptr->job_ptr->total_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	} else {
+#ifdef HAVE_BG
+		cpus = step_ptr->job_ptr->num_procs;
+		select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+				     SELECT_DATA_IONODES, 
+				     &ionodes);
+		if(ionodes) {
+			snprintf(node_list, BUFFER_SIZE, 
+				 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+			xfree(ionodes);
+		} else
+			snprintf(node_list, BUFFER_SIZE, "%s",
+				 step_ptr->job_ptr->nodes);
+		
+#else
+		if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+			cpus = step_ptr->job_ptr->total_procs;
+			snprintf(node_list, BUFFER_SIZE, "%s",
+				 step_ptr->job_ptr->nodes);
+		} else {
+			cpus = step_ptr->step_layout->task_cnt;
+			snprintf(node_list, BUFFER_SIZE, "%s", 
+				 step_ptr->step_layout->node_list);
+		}
+#endif
+	}
+
+	step_ptr->job_ptr->requid = -1; /* force to -1 for sacct to know this
+					 * hasn't been set yet  */
+
+	if(!step_ptr->job_ptr->db_index) {
+		step_ptr->job_ptr->db_index = 
+			_get_db_index(mysql_conn->acct_mysql_db,
+				      step_ptr->job_ptr->details->submit_time,
+				      step_ptr->job_ptr->job_id,
+				      step_ptr->job_ptr->assoc_id);
+		if(step_ptr->job_ptr->db_index == (uint32_t)-1) 
+			return SLURM_ERROR;
+	}
+	/* we want to print a -1 for the requid so leave it a
+	   %d */
+	query = xstrdup_printf(
+		"insert into %s (id, stepid, start, name, state, "
+		"cpus, nodelist) "
+		"values (%d, %u, %d, '%s', %d, %u, '%s') "
+		"on duplicate key update cpus=%u",
+		step_table, step_ptr->job_ptr->db_index,
+		step_ptr->step_id, 
+		(int)step_ptr->start_time, step_ptr->name,
+		JOB_RUNNING, cpus, node_list, cpus);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage the end of a job step
+ */
+extern int jobacct_storage_p_step_complete(mysql_conn_t *mysql_conn, 
+					   struct step_record *step_ptr)
+{
+#ifdef HAVE_MYSQL
+	time_t now;
+	int elapsed;
+	int comp_status;
+	int cpus = 0;
+	struct jobacctinfo *jobacct = (struct jobacctinfo *)step_ptr->jobacct;
+	struct jobacctinfo dummy_jobacct;
+	float ave_vsize = 0, ave_rss = 0, ave_pages = 0;
+	float ave_cpu = 0, ave_cpu2 = 0;
+	char *query = NULL;
+	int rc =SLURM_SUCCESS;
+	
+	if (!step_ptr->job_ptr->db_index 
+	    && (!step_ptr->job_ptr->details
+		|| !step_ptr->job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_step_complete: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if (jobacct == NULL) {
+		/* JobAcctGather=jobacct_gather/none, no data to process */
+		bzero(&dummy_jobacct, sizeof(dummy_jobacct));
+		jobacct = &dummy_jobacct;
+	}
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	if(slurmdbd_conf) {
+		now = step_ptr->job_ptr->end_time;
+		cpus = step_ptr->job_ptr->total_procs;
+
+	} else {
+		now = time(NULL);
+#ifdef HAVE_BG
+		cpus = step_ptr->job_ptr->num_procs;
+		
+#else
+		if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt)
+			cpus = step_ptr->job_ptr->total_procs;
+		else 
+			cpus = step_ptr->step_layout->task_cnt;
+#endif
+	}
+	
+	if ((elapsed=now-step_ptr->start_time)<0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	if (step_ptr->exit_code)
+		comp_status = JOB_FAILED;
+	else
+		comp_status = JOB_COMPLETE;
+
+	/* figure out the ave of the totals sent */
+	if(cpus > 0) {
+		ave_vsize = jobacct->tot_vsize;
+		ave_vsize /= cpus;
+		ave_rss = jobacct->tot_rss;
+		ave_rss /= cpus;
+		ave_pages = jobacct->tot_pages;
+		ave_pages /= cpus;
+		ave_cpu = jobacct->tot_cpu;
+		ave_cpu /= cpus;	
+		ave_cpu /= 100;
+	}
+ 
+	if(jobacct->min_cpu != (uint32_t)NO_VAL) {
+		ave_cpu2 = jobacct->min_cpu;
+		ave_cpu2 /= 100;
+	}
+
+	if(!step_ptr->job_ptr->db_index) {
+		step_ptr->job_ptr->db_index = 
+			_get_db_index(mysql_conn->acct_mysql_db,
+				      step_ptr->job_ptr->details->submit_time,
+				      step_ptr->job_ptr->job_id,
+				      step_ptr->job_ptr->assoc_id);
+		if(step_ptr->job_ptr->db_index == -1) 
+			return SLURM_ERROR;
+	}
+
+	query = xstrdup_printf(
+		"update %s set end=%d, state=%d, "
+		"kill_requid=%u, comp_code=%u, "
+		"user_sec=%ld, user_usec=%ld, "
+		"sys_sec=%ld, sys_usec=%ld, "
+		"max_vsize=%u, max_vsize_task=%u, "
+		"max_vsize_node=%u, ave_vsize=%.2f, "
+		"max_rss=%u, max_rss_task=%u, "
+		"max_rss_node=%u, ave_rss=%.2f, "
+		"max_pages=%u, max_pages_task=%u, "
+		"max_pages_node=%u, ave_pages=%.2f, "
+		"min_cpu=%.2f, min_cpu_task=%u, "
+		"min_cpu_node=%u, ave_cpu=%.2f "
+		"where id=%u and stepid=%u",
+		step_table, (int)now,
+		comp_status,
+		step_ptr->job_ptr->requid, 
+		step_ptr->exit_code,
+		/* user seconds */
+		jobacct->user_cpu_sec,	
+		/* user microseconds */
+		jobacct->user_cpu_usec,
+		/* system seconds */
+		jobacct->sys_cpu_sec,
+		/* system microsecs */
+		jobacct->sys_cpu_usec,
+		jobacct->max_vsize,	/* max vsize */
+		jobacct->max_vsize_id.taskid,	/* max vsize task */
+		jobacct->max_vsize_id.nodeid,	/* max vsize node */
+		ave_vsize,	/* ave vsize */
+		jobacct->max_rss,	/* max vsize */
+		jobacct->max_rss_id.taskid,	/* max rss task */
+		jobacct->max_rss_id.nodeid,	/* max rss node */
+		ave_rss,	/* ave rss */
+		jobacct->max_pages,	/* max pages */
+		jobacct->max_pages_id.taskid,	/* max pages task */
+		jobacct->max_pages_id.nodeid,	/* max pages node */
+		ave_pages,	/* ave pages */
+		ave_cpu2,	/* min cpu */
+		jobacct->min_cpu_id.taskid,	/* min cpu task */
+		jobacct->min_cpu_id.nodeid,	/* min cpu node */
+		ave_cpu,	/* ave cpu */
+		step_ptr->job_ptr->db_index, step_ptr->step_id);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	 
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage a suspention of a job
+ */
+extern int jobacct_storage_p_suspend(mysql_conn_t *mysql_conn, 
+				     struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	char *query = NULL;
+	int rc = SLURM_SUCCESS;
+	bool suspended = false;
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+	if(!job_ptr->db_index) {
+		job_ptr->db_index = _get_db_index(mysql_conn->acct_mysql_db,
+						  job_ptr->details->submit_time,
+						  job_ptr->job_id,
+						  job_ptr->assoc_id);
+		if(job_ptr->db_index == -1) 
+			return SLURM_ERROR;
+	}
+
+	if (job_ptr->job_state == JOB_SUSPENDED)
+		suspended = true;
+
+	xstrfmtcat(query,
+		   "update %s set suspended=%d-suspended, state=%d "
+		   "where id=%u;",
+		   job_table, (int)job_ptr->suspend_time, 
+		   job_ptr->job_state & (~JOB_COMPLETING),
+		   job_ptr->db_index);
+	if(suspended)
+		xstrfmtcat(query,
+			   "insert into %s (id, associd, start, end) "
+			   "values (%u, %u, %d, 0);",
+			   suspend_table, job_ptr->db_index, job_ptr->assoc_id,
+			   (int)job_ptr->suspend_time);
+	else
+		xstrfmtcat(query,
+			   "update %s set end=%d where id=%u && end=0;",
+			   suspend_table, (int)job_ptr->suspend_time, 
+			   job_ptr->db_index);
+	debug3("%d query\n%s", mysql_conn->conn, query);
+				
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+
+	xfree(query);
+	if(rc != SLURM_ERROR) {
+		xstrfmtcat(query,
+			   "update %s set suspended=%u-suspended, "
+			   "state=%d where id=%u and end=0",
+			   step_table, (int)job_ptr->suspend_time, 
+			   job_ptr->job_state, job_ptr->db_index);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+	}
+	
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * get info from the storage 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_p_get_jobs(mysql_conn_t *mysql_conn, 
+				       List selected_steps,
+				       List selected_parts,
+				       void *params)
+{
+	List job_list = NULL;
+#ifdef HAVE_MYSQL
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return NULL;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return NULL;
+		}
+	}
+	job_list = mysql_jobacct_process_get_jobs(mysql_conn,
+						  selected_steps,
+						  selected_parts,
+						  params);	
+#endif
+	return job_list;
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void jobacct_storage_p_archive(mysql_conn_t *mysql_conn, 
+				      List selected_parts,
+				      void *params)
+{
+#ifdef HAVE_MYSQL
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(!mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					    mysql_db_name, mysql_db_info))
+			return;
+	}
+	mysql_jobacct_process_archive(mysql_conn,
+				      selected_parts, params);
+#endif
+	return;
+}
+
+extern int acct_storage_p_update_shares_used(mysql_conn_t *mysql_conn, 
+					     List shares_used)
+{
+	/* This definitely needs to be fleshed out.
+	 * Go through the list of shares_used_object_t objects and store them */
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_flush_jobs_on_cluster(
+	mysql_conn_t *mysql_conn, char *cluster, time_t event_time)
+{
+	int rc = SLURM_SUCCESS;
+#ifdef HAVE_MYSQL
+	/* put end times for a clean start */
+	char *query = NULL;
+
+	if(!mysql_conn) {
+		error("We need a connection to run this");
+		return SLURM_ERROR;
+	} else if(!mysql_conn->acct_mysql_db
+		  || mysql_db_ping(mysql_conn->acct_mysql_db) != 0) {
+		if(mysql_get_db_connection(&mysql_conn->acct_mysql_db,
+					   mysql_db_name, mysql_db_info)
+			   != SLURM_SUCCESS) {
+			error("unable to re-connect to mysql database");
+			return SLURM_ERROR;
+		}
+	}
+
+	query = xstrdup_printf("update %s as t1, %s as t2 set "
+			       "t1.state=%u, t1.end=%u where "
+			       "t2.id=t1.associd and t2.cluster='%s' "
+			       "&& t1.end=0;",
+			       job_table, assoc_table, JOB_CANCELLED, 
+			       event_time, cluster);
+
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+#endif
+
+	return rc;
+}
diff --git a/src/plugins/accounting_storage/mysql/mysql_jobacct_process.c b/src/plugins/accounting_storage/mysql/mysql_jobacct_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..359c1926ff760c4f64392121e59e65cb76d4d0a4
--- /dev/null
+++ b/src/plugins/accounting_storage/mysql/mysql_jobacct_process.c
@@ -0,0 +1,463 @@
+/*****************************************************************************\
+ *  mysql_jobacct_process.c - functions the processing of
+ *                               information from the mysql jobacct
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "src/common/xstring.h"
+#include "mysql_jobacct_process.h"
+
+#ifdef HAVE_MYSQL
+static void _do_fdump(List job_list)
+{
+	info("fdump option not applicable from mysql plugin");
+	return;
+}
+
+extern List mysql_jobacct_process_get_jobs(mysql_conn_t *mysql_conn,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL, *step_result = NULL;
+	MYSQL_ROW row, step_row;
+	int i;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
+	time_t now = time(NULL);
+	List job_list = list_create(destroy_jobacct_job_rec);
+		
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is job_table */
+	char *job_req_inx[] = {
+		"t1.id",
+		"t1.jobid",
+		"t1.associd",
+		"t1.uid",
+		"t1.gid",
+		"t1.partition",
+		"t1.blockid",
+		"t1.account",
+		"t1.eligible",
+		"t1.submit",
+		"t1.start",
+		"t1.end",
+		"t1.suspended",
+		"t1.name",
+		"t1.track_steps",
+		"t1.state",
+		"t1.comp_code",
+		"t1.priority",
+		"t1.req_cpus",
+		"t1.alloc_cpus",
+		"t1.nodelist",
+		"t1.kill_requid",
+		"t1.qos"
+	};
+
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is step_table */
+	char *step_req_inx[] = {
+		"t1.stepid",
+		"t1.start",
+		"t1.end",
+		"t1.suspended",
+		"t1.name",
+		"t1.nodelist",
+		"t1.state",
+		"t1.kill_requid",
+		"t1.comp_code",
+		"t1.cpus",
+		"t1.user_sec",
+		"t1.user_usec",
+		"t1.sys_sec",
+		"t1.sys_usec",
+		"t1.max_vsize",
+		"t1.max_vsize_task",
+		"t1.max_vsize_node",
+		"t1.ave_vsize",
+		"t1.max_rss",
+		"t1.max_rss_task",
+		"t1.max_rss_node",
+		"t1.ave_rss",
+		"t1.max_pages",
+		"t1.max_pages_task",
+		"t1.max_pages_node",
+		"t1.ave_pages",
+		"t1.min_cpu",
+		"t1.min_cpu_task",
+		"t1.min_cpu_node",
+		"t1.ave_cpu"
+	};
+
+	enum {
+		JOB_REQ_ID,
+		JOB_REQ_JOBID,
+		JOB_REQ_ASSOCID,
+		JOB_REQ_UID,
+		JOB_REQ_GID,
+		JOB_REQ_PARTITION,
+		JOB_REQ_BLOCKID,
+		JOB_REQ_ACCOUNT,
+		JOB_REQ_ELIGIBLE,
+		JOB_REQ_SUBMIT,
+		JOB_REQ_START,
+		JOB_REQ_END,
+		JOB_REQ_SUSPENDED,
+		JOB_REQ_NAME,
+		JOB_REQ_TRACKSTEPS,
+		JOB_REQ_STATE,
+		JOB_REQ_COMP_CODE,
+		JOB_REQ_PRIORITY,
+		JOB_REQ_REQ_CPUS,
+		JOB_REQ_ALLOC_CPUS,
+		JOB_REQ_NODELIST,
+		JOB_REQ_KILL_REQUID,
+		JOB_REQ_QOS,
+		JOB_REQ_COUNT		
+	};
+	enum {
+		STEP_REQ_STEPID,
+		STEP_REQ_START,
+		STEP_REQ_END,
+		STEP_REQ_SUSPENDED,
+		STEP_REQ_NAME,
+		STEP_REQ_NODELIST,
+		STEP_REQ_STATE,
+		STEP_REQ_KILL_REQUID,
+		STEP_REQ_COMP_CODE,
+		STEP_REQ_CPUS,
+		STEP_REQ_USER_SEC,
+		STEP_REQ_USER_USEC,
+		STEP_REQ_SYS_SEC,
+		STEP_REQ_SYS_USEC,
+		STEP_REQ_MAX_VSIZE,
+		STEP_REQ_MAX_VSIZE_TASK,
+		STEP_REQ_MAX_VSIZE_NODE,
+		STEP_REQ_AVE_VSIZE,
+		STEP_REQ_MAX_RSS,
+		STEP_REQ_MAX_RSS_TASK,
+		STEP_REQ_MAX_RSS_NODE,
+		STEP_REQ_AVE_RSS,
+		STEP_REQ_MAX_PAGES,
+		STEP_REQ_MAX_PAGES_TASK,
+		STEP_REQ_MAX_PAGES_NODE,
+		STEP_REQ_AVE_PAGES,
+		STEP_REQ_MIN_CPU,
+		STEP_REQ_MIN_CPU_TASK,
+		STEP_REQ_MIN_CPU_NODE,
+		STEP_REQ_AVE_CPU,
+		STEP_REQ_COUNT
+	};
+
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		if(extra)
+			xstrcat(extra, " && (");
+		else
+			xstrcat(extra, " where (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("t1.jobid=%u",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		if(extra)
+			xstrcat(extra, " && (");
+		else
+			xstrcat(extra, " where (");
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("t1.partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	for(i=0; i<JOB_REQ_COUNT; i++) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, job_req_inx[i]);
+	}
+	
+	query = xstrdup_printf("select %s from %s t1",
+			       tmp, job_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result = mysql_db_query_ret(
+		     mysql_conn->acct_mysql_db, query, 0))) {
+		xfree(query);
+		list_destroy(job_list);
+		return NULL;
+	}
+	xfree(query);
+
+	while((row = mysql_fetch_row(result))) {
+		char *id = row[JOB_REQ_ID];
+		acct_association_rec_t account_rec;
+		memset(&account_rec, 0, sizeof(acct_association_rec_t));
+		job = create_jobacct_job_rec();
+
+		job->alloc_cpus = atoi(row[JOB_REQ_ALLOC_CPUS]);
+		account_rec.id = job->associd = atoi(row[JOB_REQ_ASSOCID]);
+		assoc_mgr_fill_in_assoc(mysql_conn, &account_rec, 0, NULL);
+		if(account_rec.cluster) {
+			if(params->opt_cluster &&
+			   strcmp(params->opt_cluster, account_rec.cluster)) {
+				destroy_jobacct_job_rec(job);
+				job = NULL;
+				continue;
+			}
+			job->cluster = xstrdup(account_rec.cluster);
+		}
+
+		if(account_rec.user) 
+			job->user = xstrdup(account_rec.user);
+		else 
+			job->uid = atoi(row[JOB_REQ_UID]);
+		if(account_rec.acct) 
+			job->account = xstrdup(account_rec.acct);
+		else
+			job->account = xstrdup(row[JOB_REQ_ACCOUNT]);
+	
+		job->blockid = xstrdup(row[JOB_REQ_BLOCKID]);
+
+		job->eligible = atoi(row[JOB_REQ_ELIGIBLE]);
+		job->submit = atoi(row[JOB_REQ_SUBMIT]);
+		job->start = atoi(row[JOB_REQ_START]);
+		job->end = atoi(row[JOB_REQ_END]);
+		job->suspended = atoi(row[JOB_REQ_SUSPENDED]);
+		if(!job->end) {
+			job->elapsed = now - job->start;
+		} else {
+			job->elapsed = job->end - job->start;
+		}
+		job->elapsed -= job->suspended;
+
+		job->jobid = atoi(row[JOB_REQ_JOBID]);
+		job->jobname = xstrdup(row[JOB_REQ_NAME]);
+		job->gid = atoi(row[JOB_REQ_GID]);
+		job->exitcode = atoi(row[JOB_REQ_COMP_CODE]);
+		job->partition = xstrdup(row[JOB_REQ_PARTITION]);
+		job->nodes = xstrdup(row[JOB_REQ_NODELIST]);
+		if (!strcmp(job->nodes, "(null)")) {
+			xfree(job->nodes);
+			job->nodes = xstrdup("(unknown)");
+		}
+			
+		job->track_steps = atoi(row[JOB_REQ_TRACKSTEPS]);
+		job->state = atoi(row[JOB_REQ_STATE]);
+		job->priority = atoi(row[JOB_REQ_PRIORITY]);
+		job->req_cpus = atoi(row[JOB_REQ_REQ_CPUS]);
+		job->requid = atoi(row[JOB_REQ_KILL_REQUID]);
+		job->qos = atoi(row[JOB_REQ_QOS]);
+		job->show_full = 1;
+					
+		list_append(job_list, job);
+
+		if(selected_steps && list_count(selected_steps)) {
+			set = 0;
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if(selected_step->jobid != job->jobid) {
+					continue;
+				} else if (selected_step->stepid
+					   == (uint32_t)NO_VAL) {
+					job->show_full = 1;
+					break;
+				}
+				
+				if(set) 
+					xstrcat(extra, " || ");
+				else 
+					xstrcat(extra, " && (");
+			
+				tmp = xstrdup_printf("t1.stepid=%u",
+						     selected_step->stepid);
+				xstrcat(extra, tmp);
+				set = 1;
+				xfree(tmp);
+				job->show_full = 0;
+			}
+			list_iterator_destroy(itr);
+			if(set)
+				xstrcat(extra, ")");
+		}
+		for(i=0; i<STEP_REQ_COUNT; i++) {
+			if(i) 
+				xstrcat(tmp, ", ");
+			xstrcat(tmp, step_req_inx[i]);
+		}
+		query =	xstrdup_printf("select %s from %s t1 where t1.id=%s",
+				       tmp, step_table, id);
+		xfree(tmp);
+		
+		if(extra) {
+			xstrcat(query, extra);
+			xfree(extra);
+		}
+		
+		//info("query = %s", query);
+		if(!(step_result = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			list_destroy(job_list);
+			return NULL;
+		}
+		xfree(query);
+		while ((step_row = mysql_fetch_row(step_result))) {
+			step = create_jobacct_step_rec();
+			step->jobid = job->jobid;
+			list_append(job->steps, step);
+			step->stepid = atoi(step_row[STEP_REQ_STEPID]);
+			/* info("got step %u.%u", */
+/* 			     job->header.jobnum, step->stepnum); */
+			step->state = atoi(step_row[STEP_REQ_STATE]);
+			step->exitcode = atoi(step_row[STEP_REQ_COMP_CODE]);
+			step->ncpus = atoi(step_row[STEP_REQ_CPUS]);
+			step->start = atoi(step_row[JOB_REQ_START]);
+			
+			step->end = atoi(step_row[STEP_REQ_END]);
+			/* figure this out by start stop */
+			step->suspended = atoi(step_row[STEP_REQ_SUSPENDED]);
+			if(!step->end) {
+				step->elapsed = now - step->start;
+			} else {
+				step->elapsed = step->end - step->start;
+			}
+			step->elapsed -= step->suspended;
+			step->user_cpu_sec = atoi(step_row[STEP_REQ_USER_SEC]);
+			step->user_cpu_usec =
+				atoi(step_row[STEP_REQ_USER_USEC]);
+			step->sys_cpu_sec = atoi(step_row[STEP_REQ_SYS_SEC]);
+			step->sys_cpu_usec = atoi(step_row[STEP_REQ_SYS_USEC]);
+			job->tot_cpu_sec += 
+				step->tot_cpu_sec += 
+				step->user_cpu_sec + step->sys_cpu_sec;
+			job->tot_cpu_usec += 
+				step->tot_cpu_usec += 
+				step->user_cpu_usec + step->sys_cpu_usec;
+			step->sacct.max_vsize =
+				atoi(step_row[STEP_REQ_MAX_VSIZE]) * 1024;
+			step->sacct.max_vsize_id.taskid = 
+				atoi(step_row[STEP_REQ_MAX_VSIZE_TASK]);
+			step->sacct.ave_vsize = 
+				atof(step_row[STEP_REQ_AVE_VSIZE]) * 1024;
+			step->sacct.max_rss =
+				atoi(step_row[STEP_REQ_MAX_RSS]) * 1024;
+			step->sacct.max_rss_id.taskid = 
+				atoi(step_row[STEP_REQ_MAX_RSS_TASK]);
+			step->sacct.ave_rss = 
+				atof(step_row[STEP_REQ_AVE_RSS]) * 1024;
+			step->sacct.max_pages =
+				atoi(step_row[STEP_REQ_MAX_PAGES]);
+			step->sacct.max_pages_id.taskid = 
+				atoi(step_row[STEP_REQ_MAX_PAGES_TASK]);
+			step->sacct.ave_pages =
+				atof(step_row[STEP_REQ_AVE_PAGES]);
+			step->sacct.min_cpu =
+				atof(step_row[STEP_REQ_MIN_CPU]);
+			step->sacct.min_cpu_id.taskid = 
+				atoi(step_row[STEP_REQ_MIN_CPU_TASK]);
+			step->sacct.ave_cpu = atof(step_row[STEP_REQ_AVE_CPU]);
+			step->stepname = xstrdup(step_row[STEP_REQ_NAME]);
+			step->nodes = xstrdup(step_row[STEP_REQ_NODELIST]);
+			step->sacct.max_vsize_id.nodeid = 
+				atoi(step_row[STEP_REQ_MAX_VSIZE_NODE]);
+			step->sacct.max_rss_id.nodeid = 
+				atoi(step_row[STEP_REQ_MAX_RSS_NODE]);
+			step->sacct.max_pages_id.nodeid = 
+				atoi(step_row[STEP_REQ_MAX_PAGES_NODE]);
+			step->sacct.min_cpu_id.nodeid = 
+				atoi(step_row[STEP_REQ_MIN_CPU_NODE]);
+	
+			step->requid = atoi(step_row[STEP_REQ_KILL_REQUID]);
+		}
+		mysql_free_result(step_result);
+		
+		if(list_count(job->steps) > 1)
+			job->track_steps = 1;
+	}
+	mysql_free_result(result);
+
+	if (params && params->opt_fdump) 
+		_do_fdump(job_list);
+
+	return job_list;
+}
+
+extern void mysql_jobacct_process_archive(mysql_conn_t *mysql_conn,
+					  List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/accounting_storage/mysql/mysql_jobacct_process.h b/src/plugins/accounting_storage/mysql/mysql_jobacct_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..e9def5417a691a45d6ddf564e04a12befb16e008
--- /dev/null
+++ b/src/plugins/accounting_storage/mysql/mysql_jobacct_process.h
@@ -0,0 +1,82 @@
+/*****************************************************************************\
+ *  mysql_jobacct_process.h - functions the processing of
+ *                               information from the mysql jobacct
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_MYSQL_JOBACCT_PROCESS_H
+#define _HAVE_MYSQL_JOBACCT_PROCESS_H
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include "src/common/assoc_mgr.h"
+#include "src/common/jobacct_common.h"
+#include "src/slurmdbd/read_config.h"
+#include "src/slurmctld/slurmctld.h"
+#include "src/database/mysql_common.h"
+#include "src/common/slurm_accounting_storage.h"
+
+#ifndef HAVE_MYSQL
+typedef void mysql_conn_t;
+#else
+
+typedef struct {
+	MYSQL *acct_mysql_db;
+	bool rollback;
+	List update_list;
+	int conn;
+} mysql_conn_t;
+
+//extern int acct_db_init;
+
+extern char *job_table;
+extern char *step_table;
+
+extern List mysql_jobacct_process_get_jobs(mysql_conn_t *mysql_conn,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void mysql_jobacct_process_archive(mysql_conn_t *mysql_conn,
+					  List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/accounting_storage/mysql/mysql_rollup.c b/src/plugins/accounting_storage/mysql/mysql_rollup.c
new file mode 100644
index 0000000000000000000000000000000000000000..4fe1d41c120c6a67709742dde47fc5e385d65144
--- /dev/null
+++ b/src/plugins/accounting_storage/mysql/mysql_rollup.c
@@ -0,0 +1,762 @@
+/*****************************************************************************\
+ *  mysql_rollup.c - functions for rolling up data for associations
+ *                   and machines from the mysql storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "mysql_rollup.h"
+
+#ifdef HAVE_MYSQL
+
+typedef struct {
+	int assoc_id;
+	int a_cpu;
+} local_assoc_usage_t;
+
+typedef struct {
+	char *name;
+	int total_time;
+	int a_cpu;
+	int cpu_count;
+	int d_cpu;
+	int i_cpu;
+	int o_cpu;
+	int r_cpu;
+	time_t start;
+	time_t end;
+} local_cluster_usage_t;
+
+
+extern void _destroy_local_assoc_usage(void *object)
+{
+	local_assoc_usage_t *a_usage = (local_assoc_usage_t *)object;
+	if(a_usage) {
+		xfree(a_usage);
+	}
+}
+
+extern void _destroy_local_cluster_usage(void *object)
+{
+	local_cluster_usage_t *c_usage = (local_cluster_usage_t *)object;
+	if(c_usage) {
+		xfree(c_usage->name);
+		xfree(c_usage);
+	}
+}
+
+extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn,
+			       time_t start, time_t end)
+{
+	int rc = SLURM_SUCCESS;
+	int add_sec = 3600;
+	int i=0;
+	time_t now = time(NULL);
+	time_t curr_start = start;
+	time_t curr_end = curr_start + add_sec;
+	char *query = NULL;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	ListIterator a_itr = NULL;
+	ListIterator c_itr = NULL;
+	List assoc_usage_list = list_create(_destroy_local_assoc_usage);
+	List cluster_usage_list = list_create(_destroy_local_cluster_usage);
+	char *event_req_inx[] = {
+		"node_name",
+		"cluster",
+		"cpu_count",
+		"period_start",
+		"period_end"
+	};
+	char *event_str = NULL;
+	enum {
+		EVENT_REQ_NAME,
+		EVENT_REQ_CLUSTER,
+		EVENT_REQ_CPU,
+		EVENT_REQ_START,
+		EVENT_REQ_END,
+		EVENT_REQ_COUNT
+	};
+	char *job_req_inx[] = {
+		"t1.id",
+		"jobid",
+		"associd",
+		"cluster",
+		"eligible",
+		"start",
+		"end",
+		"suspended",
+		"alloc_cpus",
+		"req_cpus"
+	};
+	char *job_str = NULL;
+	enum {
+		JOB_REQ_DB_INX,
+		JOB_REQ_JOBID,
+		JOB_REQ_ASSOCID,
+		JOB_REQ_CLUSTER,
+		JOB_REQ_ELG,
+		JOB_REQ_START,
+		JOB_REQ_END,
+		JOB_REQ_SUSPENDED,
+		JOB_REQ_ACPU,
+		JOB_REQ_RCPU,
+		JOB_REQ_COUNT
+	};
+	char *suspend_req_inx[] = {
+		"start",
+		"end"
+	};
+	char *suspend_str = NULL;
+	enum {
+		SUSPEND_REQ_START,
+		SUSPEND_REQ_END,
+		SUSPEND_REQ_COUNT
+	};
+
+	i=0;
+	xstrfmtcat(event_str, "%s", event_req_inx[i]);
+	for(i=1; i<EVENT_REQ_COUNT; i++) {
+		xstrfmtcat(event_str, ", %s", event_req_inx[i]);
+	}
+
+	i=0;
+	xstrfmtcat(job_str, "%s", job_req_inx[i]);
+	for(i=1; i<JOB_REQ_COUNT; i++) {
+		xstrfmtcat(job_str, ", %s", job_req_inx[i]);
+	}
+
+	i=0;
+	xstrfmtcat(suspend_str, "%s", suspend_req_inx[i]);
+	for(i=1; i<SUSPEND_REQ_COUNT; i++) {
+		xstrfmtcat(suspend_str, ", %s", suspend_req_inx[i]);
+	}
+
+/* 	info("begin start %s", ctime(&curr_start)); */
+/* 	info("begin end %s", ctime(&curr_end)); */
+	a_itr = list_iterator_create(assoc_usage_list);
+	c_itr = list_iterator_create(cluster_usage_list);
+	while(curr_start < end) {
+		int last_id = 0;
+		int seconds = 0;
+		local_cluster_usage_t *c_usage = NULL;
+		local_assoc_usage_t *a_usage = NULL;
+		debug3("curr hour is now %d-%d", curr_start, curr_end);
+/* 		info("start %s", ctime(&curr_start)); */
+/* 		info("end %s", ctime(&curr_end)); */
+		
+		// first get the events during this time
+		query = xstrdup_printf("select %s from %s where "
+				       "(period_start < %d "
+				       "&& (period_end >= %d "
+				       "|| period_end = 0)) "
+				       "order by node_name, period_start",
+				       event_str, event_table,
+				       curr_end, curr_start);
+
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		if(!(result = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			return SLURM_ERROR;
+		}
+		xfree(query);
+		
+		while((row = mysql_fetch_row(result))) {
+			int row_start = atoi(row[EVENT_REQ_START]);
+			int row_end = atoi(row[EVENT_REQ_END]);
+			int row_cpu = atoi(row[EVENT_REQ_CPU]);
+					
+			if(row_start < curr_start)
+				row_start = curr_start;
+		
+			if(!row_end || row_end > curr_end) 
+				row_end = curr_end;
+
+			/* Don't worry about it if the time is less
+			 * than 1 second.
+			 */
+			if((row_end - row_start) < 1)
+				continue;
+
+			if(!row[EVENT_REQ_NAME][0]) {
+				list_iterator_reset(c_itr);
+				while((c_usage = list_next(c_itr))) {
+					if(!strcmp(c_usage->name,
+					   row[EVENT_REQ_CLUSTER])) {
+						break;
+					}
+				}
+				/* if the cpu count changes we will
+				 * only care about the last cpu count but
+				 * we will keep a total of the time for
+				 * all cpus to get the correct cpu time
+				 * for the entire period.
+				 */
+				if(!c_usage) {
+					c_usage = xmalloc(
+						sizeof(local_cluster_usage_t));
+					c_usage->name = 
+						xstrdup(row[EVENT_REQ_CLUSTER]);
+					c_usage->cpu_count = row_cpu;
+					c_usage->total_time =
+						(row_end - row_start) * row_cpu;
+					c_usage->start = row_start;
+					c_usage->end = row_end;
+					list_append(cluster_usage_list, 
+						    c_usage);
+				} else {
+					c_usage->cpu_count = row_cpu;
+					c_usage->total_time +=
+						(row_end - row_start) * row_cpu;
+					c_usage->end = row_end;
+				}
+				continue;
+			}
+
+			list_iterator_reset(c_itr);
+			while((c_usage = list_next(c_itr))) {
+				if(!strcmp(c_usage->name,
+					   row[EVENT_REQ_CLUSTER])) {
+					int local_start = row_start;
+					int local_end = row_end;
+					if(c_usage->start > local_start)
+						local_start = c_usage->start;
+					if(c_usage->end < local_end)
+						local_end = c_usage->end;
+
+					if((local_end - local_start) < 1)
+						continue;
+
+					seconds = (local_end - local_start);
+
+/* 					info("node %s adds " */
+/* 					     "(%d)(%d-%d) * %d = %d " */
+/* 					     "to %d", */
+/* 					     row[EVENT_REQ_NAME], */
+/* 					     seconds, */
+/* 					     local_end, local_start, */
+/* 					     row_cpu,  */
+/* 					     seconds * row_cpu,  */
+/* 					     row_cpu); */
+					c_usage->d_cpu += seconds * row_cpu;
+					
+					break;
+				}				   
+			}
+		}
+		mysql_free_result(result);
+
+		query = xstrdup_printf("select %s from %s as t1, "
+				       "%s as t2 where "
+				       "(eligible < %d && (end >= %d "
+				       "|| end = 0)) && associd=t2.id "
+				       "order by associd, eligible",
+				       job_str, job_table, assoc_table,
+				       curr_end, curr_start, curr_start);
+
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		if(!(result = mysql_db_query_ret(
+			     mysql_conn->acct_mysql_db, query, 0))) {
+			xfree(query);
+			return SLURM_ERROR;
+		}
+		xfree(query);
+		
+		while((row = mysql_fetch_row(result))) {
+			int job_id = atoi(row[JOB_REQ_JOBID]);
+			int assoc_id = atoi(row[JOB_REQ_ASSOCID]);
+			int row_eligible = atoi(row[JOB_REQ_ELG]);
+			int row_start = atoi(row[JOB_REQ_START]);
+			int row_end = atoi(row[JOB_REQ_END]);
+			int row_acpu = atoi(row[JOB_REQ_ACPU]);
+			int row_rcpu = atoi(row[JOB_REQ_RCPU]);
+			seconds = 0;
+		       
+			if(row_start && (row_start < curr_start))
+				row_start = curr_start;
+
+			if(!row_start && row_end)
+				row_start = row_end;
+
+			if(!row_end || row_end > curr_end) 
+				row_end = curr_end;
+			
+			if(last_id != assoc_id) {
+				a_usage =
+					xmalloc(sizeof(local_cluster_usage_t));
+				a_usage->assoc_id = assoc_id;
+				list_append(assoc_usage_list, a_usage);
+				last_id = assoc_id;
+			}
+
+
+			if(!row_start || ((row_end - row_start) < 1)) 
+				goto calc_cluster;
+
+			seconds = (row_end - row_start);
+
+			if(row[JOB_REQ_SUSPENDED]) {
+				MYSQL_RES *result2 = NULL;
+				MYSQL_ROW row2;
+				/* get the suspended time for this job */
+				query = xstrdup_printf(
+					"select %s from %s where "
+					"(start < %d && (end >= %d "
+					"|| end = 0)) && id=%s "
+					"order by start",
+					suspend_str, suspend_table,
+					curr_end, curr_start,
+					row[JOB_REQ_DB_INX]);
+				
+				debug4("%d query\n%s", mysql_conn->conn, query);
+				if(!(result2 = mysql_db_query_ret(
+					     mysql_conn->acct_mysql_db,
+					     query, 0))) {
+					xfree(query);
+					return SLURM_ERROR;
+				}
+				xfree(query);
+				while((row2 = mysql_fetch_row(result2))) {
+					int local_start =
+						atoi(row2[SUSPEND_REQ_START]);
+					int local_end = 
+						atoi(row2[SUSPEND_REQ_END]);
+
+					if(!local_start)
+						continue;
+
+					if(row_start > local_start)
+						local_start = row_start;
+					if(row_end < local_end)
+						local_end = row_end;
+
+					if((local_end - local_start) < 1)
+						continue;
+					
+					seconds -= (local_end - local_start);
+				}
+				mysql_free_result(result2);			
+
+			}
+			if(seconds < 1) {
+				debug4("This job (%u) was suspended "
+				       "the entire hour", job_id);
+				continue;
+			}
+
+
+			a_usage->a_cpu += seconds * row_acpu;
+
+		calc_cluster:
+			if(!row[JOB_REQ_CLUSTER]) 
+				continue;
+			
+			list_iterator_reset(c_itr);
+			while((c_usage = list_next(c_itr))) {
+				if(!strcmp(c_usage->name,
+					   row[JOB_REQ_CLUSTER])) {
+					if(!row_start || seconds < 1)
+						goto calc_resv;
+
+/* 					info("%d assoc %d adds " */
+/* 					     "(%d)(%d-%d) * %d = %d " */
+/* 					     "to %d", */
+/* 					     job_id, */
+/* 					     a_usage->assoc_id, */
+/* 					     seconds, */
+/* 					     row_end, row_start, */
+/* 					     row_acpu, */
+/* 					     seconds * row_acpu, */
+/* 					     row_acpu); */
+
+					c_usage->a_cpu += seconds * row_acpu;
+
+				calc_resv:
+					/* now reserved time */
+					if(row_start && 
+					   row_start < c_usage->start)
+						continue;
+					
+					row_end = row_start;
+					row_start = row_eligible;
+					if(c_usage->start > row_start)
+						row_start = c_usage->start;
+					if(c_usage->end < row_end)
+						row_end = c_usage->end;
+					
+					if((row_end - row_start) < 1)
+						continue;
+					
+					seconds = (row_end - row_start);
+
+/* 					info("%d assoc %d reserved " */
+/* 					     "(%d)(%d-%d) * %d = %d " */
+/* 					     "to %d", */
+/* 					     job_id, */
+/* 					     assoc_id, */
+/* 					     seconds, */
+/* 					     row_end, row_start, */
+/* 					     row_rcpu, */
+/* 					     seconds * row_rcpu, */
+/* 					     row_rcpu); */
+					c_usage->r_cpu += seconds * row_rcpu;
+
+					break;
+				}
+			}
+		}
+		mysql_free_result(result);
+
+		list_iterator_reset(c_itr);
+		while((c_usage = list_next(c_itr))) {
+			c_usage->i_cpu = c_usage->total_time - c_usage->a_cpu -
+				c_usage->d_cpu - c_usage->r_cpu;
+			/* sanity check just to make sure we have a
+			 * legitimate time after we calulated
+			 * idle/reserved time put extra in the over
+			 * commit field
+			 */
+			
+			if(c_usage->i_cpu < 0) {
+				c_usage->r_cpu += c_usage->i_cpu;
+				c_usage->o_cpu -= c_usage->i_cpu;
+				c_usage->i_cpu = 0;
+			}
+			
+/* 			info("cluster %s(%d) down %d alloc %d " */
+/* 			     "resv %d idle %d over %d " */
+/* 			     "total= %d = %d from %s", */
+/* 			     c_usage->name, */
+/* 			     c_usage->cpu_count, c_usage->d_cpu, */
+/* 			     c_usage->a_cpu, */
+/* 			     c_usage->r_cpu, c_usage->i_cpu, c_usage->o_cpu, */
+/* 			     c_usage->d_cpu + c_usage->a_cpu + */
+/* 			     c_usage->r_cpu + c_usage->i_cpu, */
+/* 			     c_usage->total_time, */
+/* 			     ctime(&c_usage->start)); */
+/* 			info("to %s", ctime(&c_usage->end)); */
+			if(query) {
+				xstrfmtcat(query, 
+					   ", (%d, %d, '%s', %d, %d, "
+					   "%d, %d, %d, %d, %d) "
+					   "on duplicate key update "
+					   "mod_time=%d, cpu_count=%d, "
+					   "alloc_cpu_secs=%d, "
+					   "down_cpu_secs=%d, "
+					   "idle_cpu_secs=%d, "
+					   "over_cpu_secs=%d, resv_cpu_secs=%d",
+					   now, now, 
+					   c_usage->name, c_usage->start, 
+					   c_usage->cpu_count, c_usage->a_cpu,
+					   c_usage->d_cpu, c_usage->i_cpu,
+					   c_usage->o_cpu, c_usage->r_cpu,
+					   now, 
+					   c_usage->cpu_count, c_usage->a_cpu,
+					   c_usage->d_cpu, c_usage->i_cpu,
+					   c_usage->o_cpu, c_usage->r_cpu); 
+			} else {
+				xstrfmtcat(query, 
+					   "insert into %s (creation_time, "
+					   "mod_time, cluster, period_start, "
+					   "cpu_count, alloc_cpu_secs, "
+					   "down_cpu_secs, idle_cpu_secs, "
+					   "over_cpu_secs, resv_cpu_secs) "
+					   "values (%d, %d, '%s', %d, %d, "
+					   "%d, %d, %d, %d, %d) "
+					   "on duplicate key update "
+					   "mod_time=%d, cpu_count=%d, "
+					   "alloc_cpu_secs=%d, "
+					   "down_cpu_secs=%d, "
+					   "idle_cpu_secs=%d, "
+					   "over_cpu_secs=%d, resv_cpu_secs=%d",
+					   cluster_hour_table, now, now, 
+					   c_usage->name, c_usage->start, 
+					   c_usage->cpu_count, c_usage->a_cpu,
+					   c_usage->d_cpu, c_usage->i_cpu,
+					   c_usage->o_cpu, c_usage->r_cpu,
+					   now,
+					   c_usage->cpu_count, c_usage->a_cpu,
+					   c_usage->d_cpu, c_usage->i_cpu,
+					   c_usage->o_cpu, c_usage->r_cpu); 
+			}
+		}
+		if(query) {
+			rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+			xfree(query);
+			if(rc != SLURM_SUCCESS) {
+				error("Couldn't add cluster hour rollup");
+				goto end_it;
+			}
+		}
+
+		list_iterator_reset(a_itr);
+		while((a_usage = list_next(a_itr))) {
+/* 			info("association (%d) %d alloc %d", */
+/* 			     a_usage->assoc_id, last_id, */
+/* 			     a_usage->a_cpu); */
+			if(query) {
+				xstrfmtcat(query, 
+					   ", (%d, %d, %d, %d, %d, "
+					   "%d, %d, %d, %d) "
+					   "on duplicate key update "
+					   "mod_time=%d, alloc_cpu_secs=%d",
+					   now, now, 
+					   a_usage->assoc_id, curr_start,
+					   a_usage->a_cpu,
+					   now, a_usage->a_cpu); 
+			} else {
+				xstrfmtcat(query, 
+					   "insert into %s (creation_time, "
+					   "mod_time, id, period_start, "
+					   "alloc_cpu_secs) values "
+					   "(%d, %d, %d, %d, %d) "
+					   "on duplicate key update "
+					   "mod_time=%d, alloc_cpu_secs=%d",
+					   assoc_hour_table, now, now, 
+					   a_usage->assoc_id, curr_start,
+					   a_usage->a_cpu,
+					   now, a_usage->a_cpu); 
+			}
+		}
+		
+		if(query) {
+			debug3("%d query\n%s", mysql_conn->conn, query);
+			rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+			xfree(query);
+			if(rc != SLURM_SUCCESS) {
+				error("Couldn't add assoc hour rollup");
+				goto end_it;
+			}
+		}
+		list_flush(assoc_usage_list);
+		list_flush(cluster_usage_list);
+		curr_start = curr_end;
+		curr_end = curr_start + add_sec;
+	}
+end_it:
+	xfree(suspend_str);	
+	xfree(event_str);	
+	xfree(job_str);
+	list_iterator_destroy(a_itr);
+	list_iterator_destroy(c_itr);
+		
+	list_destroy(assoc_usage_list);
+	list_destroy(cluster_usage_list);
+/* 	info("stop start %s", ctime(&curr_start)); */
+/* 	info("stop end %s", ctime(&curr_end)); */
+	return rc;
+}
+extern int mysql_daily_rollup(mysql_conn_t *mysql_conn, 
+			      time_t start, time_t end)
+{
+	/* can't just add 86400 since daylight savings starts and ends every
+	 * once in a while
+	 */
+	int rc = SLURM_SUCCESS;
+	struct tm start_tm;
+	time_t curr_start = start;
+	time_t curr_end;
+	time_t now = time(NULL);
+	char *query = NULL;
+
+	if(!localtime_r(&curr_start, &start_tm)) {
+		error("Couldn't get localtime from day start %d", curr_start);
+		return SLURM_ERROR;
+	}
+	start_tm.tm_sec = 0;
+	start_tm.tm_min = 0;
+	start_tm.tm_hour = 0;
+	start_tm.tm_mday++;
+	start_tm.tm_isdst = -1;
+	curr_end = mktime(&start_tm);
+
+	while(curr_start < end) {
+		debug3("curr day is now %d-%d", curr_start, curr_end);
+/* 	info("start %s", ctime(&curr_start)); */
+/* 	info("end %s", ctime(&curr_end)); */
+		query = xstrdup_printf(
+			"insert into %s (creation_time, mod_time, id, "
+			"period_start, alloc_cpu_secs) select %d, %d, id, "
+			"%d, @ASUM:=SUM(alloc_cpu_secs) from %s where "
+			"(period_start < %d && period_start >= %d) "
+			"group by id on duplicate key update mod_time=%d, "
+			"alloc_cpu_secs=@ASUM;",
+			assoc_day_table, now, now, curr_start,
+			assoc_hour_table,
+			curr_end, curr_start, now);
+		xstrfmtcat(query,
+			   "insert into %s (creation_time, "
+			   "mod_time, cluster, period_start, cpu_count, "
+			   "alloc_cpu_secs, down_cpu_secs, idle_cpu_secs, "
+			   "over_cpu_secs, resv_cpu_secs) "
+			   "select %d, %d, cluster, "
+			   "%d, @CPU:=MAX(cpu_count), "
+			   "@ASUM:=SUM(alloc_cpu_secs), "
+			   "@DSUM:=SUM(down_cpu_secs), "
+			   "@ISUM:=SUM(idle_cpu_secs), "
+			   "@OSUM:=SUM(over_cpu_secs), "
+			   "@RSUM:=SUM(resv_cpu_secs) from %s where "
+			   "(period_start < %d && period_start >= %d) "
+			   "group by cluster on duplicate key update "
+			   "mod_time=%d, cpu_count=@CPU, "
+			   "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, "
+			   "idle_cpu_secs=@ISUM, over_cpu_secs=@OSUM, "
+			   "resv_cpu_secs=@RSUM;",
+			   cluster_day_table, now, now, curr_start,
+			   cluster_hour_table,
+			   curr_end, curr_start, now);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add day rollup");
+			return SLURM_ERROR;
+		}
+
+		curr_start = curr_end;
+		if(!localtime_r(&curr_start, &start_tm)) {
+			error("Couldn't get localtime from day start %d",
+			      curr_start);
+			return SLURM_ERROR;
+		}
+		start_tm.tm_sec = 0;
+		start_tm.tm_min = 0;
+		start_tm.tm_hour = 0;
+		start_tm.tm_mday++;
+		start_tm.tm_isdst = -1;
+		curr_end = mktime(&start_tm);
+	}
+	/* remove all data from suspend table that was older than
+	 * start. 
+	 */
+	query = xstrdup_printf("delete from %s where end < %d && end != 0",
+			       suspend_table, start);
+	rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+	xfree(query);
+	if(rc != SLURM_SUCCESS) {
+		error("Couldn't remove old suspend data");
+		return SLURM_ERROR;
+	}
+			       
+
+/* 	info("stop start %s", ctime(&curr_start)); */
+/* 	info("stop end %s", ctime(&curr_end)); */
+
+	return SLURM_SUCCESS;
+}
+extern int mysql_monthly_rollup(mysql_conn_t *mysql_conn,
+			       time_t start, time_t end)
+{
+	int rc = SLURM_SUCCESS;
+	struct tm start_tm;
+	time_t curr_start = start;
+	time_t curr_end;
+	time_t now = time(NULL);
+	char *query = NULL;
+
+	if(!localtime_r(&curr_start, &start_tm)) {
+		error("Couldn't get localtime from month start %d", curr_start);
+		return SLURM_ERROR;
+	}
+	start_tm.tm_sec = 0;
+	start_tm.tm_min = 0;
+	start_tm.tm_hour = 0;
+	start_tm.tm_mday = 1;
+	start_tm.tm_mon++;
+	start_tm.tm_isdst = -1;
+	curr_end = mktime(&start_tm);
+
+	while(curr_start < end) {
+		debug3("curr month is now %d-%d", curr_start, curr_end);
+/* 	info("start %s", ctime(&curr_start)); */
+/* 	info("end %s", ctime(&curr_end)); */
+		query = xstrdup_printf(
+			"insert into %s (creation_time, mod_time, id, "
+			"period_start, alloc_cpu_secs) select %d, %d, id, "
+			"%d, @ASUM:=SUM(alloc_cpu_secs) from %s where "
+			"(period_start < %d && period_start >= %d) "
+			"group by id on duplicate key update mod_time=%d, "
+			"alloc_cpu_secs=@ASUM;",
+			assoc_month_table, now, now, curr_start,
+			assoc_day_table,
+			curr_end, curr_start, now);
+		xstrfmtcat(query,
+			   "insert into %s (creation_time, "
+			   "mod_time, cluster, period_start, cpu_count, "
+			   "alloc_cpu_secs, down_cpu_secs, idle_cpu_secs, "
+			   "over_cpu_secs, resv_cpu_secs) "
+			   "select %d, %d, cluster, "
+			   "%d, @CPU:=MAX(cpu_count), "
+			   "@ASUM:=SUM(alloc_cpu_secs), "
+			   "@DSUM:=SUM(down_cpu_secs), "
+			   "@ISUM:=SUM(idle_cpu_secs), "
+			   "@OSUM:=SUM(over_cpu_secs), "
+			   "@RSUM:=SUM(resv_cpu_secs) from %s where "
+			   "(period_start < %d && period_start >= %d) "
+			   "group by cluster on duplicate key update "
+			   "mod_time=%d, cpu_count=@CPU, "
+			   "alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, "
+			   "idle_cpu_secs=@ISUM, over_cpu_secs=@OSUM, "
+			   "resv_cpu_secs=@RSUM;",
+			   cluster_month_table, now, now, curr_start,
+			   cluster_day_table,
+			   curr_end, curr_start, now);
+		debug3("%d query\n%s", mysql_conn->conn, query);
+		rc = mysql_db_query(mysql_conn->acct_mysql_db, query);
+		xfree(query);
+		if(rc != SLURM_SUCCESS) {
+			error("Couldn't add day rollup");
+			return SLURM_ERROR;
+		}
+
+		curr_start = curr_end;
+		if(!localtime_r(&curr_start, &start_tm)) {
+			error("Couldn't get localtime from month start %d",
+			      curr_start);
+		}
+		start_tm.tm_sec = 0;
+		start_tm.tm_min = 0;
+		start_tm.tm_hour = 0;
+		start_tm.tm_mday = 1;
+		start_tm.tm_mon++;
+		start_tm.tm_isdst = -1;
+		curr_end = mktime(&start_tm);
+	}
+	return SLURM_SUCCESS;
+}
+
+#endif
diff --git a/src/srun/launch.h b/src/plugins/accounting_storage/mysql/mysql_rollup.h
similarity index 65%
rename from src/srun/launch.h
rename to src/plugins/accounting_storage/mysql/mysql_rollup.h
index d0bd2bb1b8cffacd126f150616024ecb811e7961..bc48a2814458b4067911dd73c6fc9297e4c8b55c 100644
--- a/src/srun/launch.h
+++ b/src/plugins/accounting_storage/mysql/mysql_rollup.h
@@ -1,10 +1,13 @@
 /*****************************************************************************\
- * src/srun/launch.h - header for srun launch thread
+ *  mysql_rollup.h - functions for rolling up data for associations
+ *                   and machines from the mysql storage.
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -15,7 +18,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -35,33 +38,29 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#ifndef _HAVE_LAUNCH_H
-#define _HAVE_LAUNCH_H
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
+#ifndef _HAVE_MYSQL_ROLLUP_H
+#define _HAVE_MYSQL_ROLLUP_H
 
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif
+#include "mysql_jobacct_process.h"
 
-#include "src/common/macros.h"
-#include "src/common/slurm_protocol_api.h"
+#ifdef HAVE_MYSQL
+extern char *assoc_table;
+extern char *assoc_day_table;
+extern char *assoc_hour_table;
+extern char *assoc_month_table;
+extern char *cluster_day_table;
+extern char *cluster_hour_table;
+extern char *cluster_month_table;
+extern char *event_table;
+extern char *suspend_table;
 
-#include "src/srun/opt.h"
-#include "src/srun/srun_job.h"
+extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn,
+			       time_t start, time_t end);
+extern int mysql_daily_rollup(mysql_conn_t *mysql_conn,
+			      time_t start, time_t end);
+extern int mysql_monthly_rollup(mysql_conn_t *mysql_conn,
+			       time_t start, time_t end);
 
-typedef struct launch_thr {
-	pthread_t	thread;
-	pthread_attr_t  attr;
-	char            *host;	       /* name of host on which to run       */
-	int             ntasks;	       /* number of tasks to initiate on host*/
-	int 		*taskid;       /* list of global task ids            */
-	int 		i;	       /* temporary index into array	     */
-} launch_thr_t;
-
-int    launch_thr_create(srun_job_t *job);
-void * launch(void *arg);
+#endif
 
-#endif /* !_HAVE_LAUNCH_H */
+#endif
diff --git a/src/plugins/accounting_storage/none/Makefile.am b/src/plugins/accounting_storage/none/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..122e92c28f1c84fc6c31f28300b60910399e18f5
--- /dev/null
+++ b/src/plugins/accounting_storage/none/Makefile.am
@@ -0,0 +1,12 @@
+# Makefile for accounting_storage/none plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = accounting_storage_none.la
+
+accounting_storage_none_la_SOURCES = accounting_storage_none.c
+accounting_storage_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/accounting_storage/none/Makefile.in b/src/plugins/accounting_storage/none/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..4d62249e97da58dbc98ed5cd730baff406bfb940
--- /dev/null
+++ b/src/plugins/accounting_storage/none/Makefile.in
@@ -0,0 +1,555 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for accounting_storage/none plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/accounting_storage/none
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+accounting_storage_none_la_LIBADD =
+am_accounting_storage_none_la_OBJECTS = accounting_storage_none.lo
+accounting_storage_none_la_OBJECTS =  \
+	$(am_accounting_storage_none_la_OBJECTS)
+accounting_storage_none_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(AM_CFLAGS) $(CFLAGS) $(accounting_storage_none_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(accounting_storage_none_la_SOURCES)
+DIST_SOURCES = $(accounting_storage_none_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = accounting_storage_none.la
+accounting_storage_none_la_SOURCES = accounting_storage_none.c
+accounting_storage_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/accounting_storage/none/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/accounting_storage/none/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+accounting_storage_none.la: $(accounting_storage_none_la_OBJECTS) $(accounting_storage_none_la_DEPENDENCIES) 
+	$(accounting_storage_none_la_LINK) -rpath $(pkglibdir) $(accounting_storage_none_la_OBJECTS) $(accounting_storage_none_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_none.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/accounting_storage/none/accounting_storage_none.c b/src/plugins/accounting_storage/none/accounting_storage_none.c
new file mode 100644
index 0000000000000000000000000000000000000000..0701440e26b77f8f7577cd08981bfe852ce8e520
--- /dev/null
+++ b/src/plugins/accounting_storage/none/accounting_storage_none.c
@@ -0,0 +1,349 @@
+/*****************************************************************************\
+ *  accounting_storage_none.c - account interface to none.
+ *
+ *  $Id: accounting_storage_none.c 13061 2008-01-22 21:23:56Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/common/slurm_accounting_storage.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Accounting storage NOT INVOKED plugin";
+const char plugin_type[] = "accounting_storage/none";
+const uint32_t plugin_version = 100;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	return SLURM_SUCCESS;
+}
+
+extern void * acct_storage_p_get_connection(bool make_agent, bool rollback)
+{
+	return NULL;
+}
+
+extern int acct_storage_p_close_connection(void **db_conn)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_commit(void *db_conn, bool commit)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_users(void *db_conn, uint32_t uid,
+				    List user_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_coord(void *db_conn, uint32_t uid,
+				    char *acct, acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_accts(void *db_conn, uint32_t uid,
+				    List acct_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_clusters(void *db_conn, uint32_t uid,
+				       List cluster_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_associations(void *db_conn, uint32_t uid,
+					   List association_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q,
+				       acct_user_rec_t *user)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_accts(void *db_conn, uint32_t uid,
+				       acct_account_cond_t *acct_q,
+				       acct_account_rec_t *acct)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_clusters(void *db_conn, uint32_t uid,
+					  acct_cluster_cond_t *cluster_q,
+					  acct_cluster_rec_t *cluster)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_associations(void *db_conn, uint32_t uid,
+					      acct_association_cond_t *assoc_q,
+					      acct_association_rec_t *assoc)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_coord(void *db_conn, uint32_t uid,
+				       char *acct, acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_accts(void *db_conn, uint32_t uid,
+				       acct_account_cond_t *acct_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_clusters(void *db_conn, uint32_t uid,
+					  acct_account_cond_t *cluster_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_associations(void *db_conn, uint32_t uid,
+					      acct_association_cond_t *assoc_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_get_users(void *db_conn,
+				     acct_user_cond_t *user_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_accts(void *db_conn,
+				     acct_account_cond_t *acct_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_clusters(void *db_conn,
+					acct_account_cond_t *cluster_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_associations(void *db_conn,
+					    acct_association_cond_t *assoc_q)
+{
+	return NULL;
+}
+
+extern int acct_storage_p_get_usage(void *db_conn,
+				    acct_association_rec_t *acct_assoc,
+				    time_t start, time_t end)
+{
+	int rc = SLURM_SUCCESS;
+
+	return rc;
+}
+
+extern int acct_storage_p_roll_usage(void *db_conn, 
+				     time_t sent_start)
+{
+	int rc = SLURM_SUCCESS;
+
+	return rc;
+}
+
+extern int clusteracct_storage_p_node_down(void *db_conn,
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time, char *reason)
+{
+	return SLURM_SUCCESS;
+}
+extern int clusteracct_storage_p_node_up(void *db_conn,
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_register_ctld(char *cluster,
+					       uint16_t port)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_cluster_procs(void *db_conn,
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_get_usage(
+	void *db_conn,
+	acct_cluster_rec_t *cluster_rec, time_t start, time_t end)
+{
+
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the start of a job
+ */
+extern int jobacct_storage_p_job_start(void *db_conn,
+				       struct job_record *job_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the end of a job
+ */
+extern int jobacct_storage_p_job_complete(void *db_conn,
+					  struct job_record *job_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the start of a job step
+ */
+extern int jobacct_storage_p_step_start(void *db_conn,
+					struct step_record *step_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the end of a job step
+ */
+extern int jobacct_storage_p_step_complete(void *db_conn,
+					   struct step_record *step_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage a suspention of a job
+ */
+extern int jobacct_storage_p_suspend(void *db_conn,
+				     struct job_record *job_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * get info from the storage 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_p_get_jobs(void *db_conn,
+				       List selected_steps,
+				       List selected_parts,
+				       void *params)
+{
+	return NULL;
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void jobacct_storage_p_archive(void *db_conn,
+				      List selected_parts,
+				      void *params)
+{
+	return;
+}
+
+extern int acct_storage_p_update_shares_used(void *db_conn,
+					     List shares_used)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_flush_jobs_on_cluster(
+	void *db_conn, char *cluster, time_t event_time)
+{
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/accounting_storage/pgsql/Makefile.am b/src/plugins/accounting_storage/pgsql/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..3c0a2833acbd9046fe8b071fb91978cd813deb48
--- /dev/null
+++ b/src/plugins/accounting_storage/pgsql/Makefile.am
@@ -0,0 +1,20 @@
+# Makefile for accounting_storage/pgsql plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = accounting_storage_pgsql.la
+
+# Pgsql storage plugin.
+accounting_storage_pgsql_la_SOURCES = accounting_storage_pgsql.c \
+		pgsql_jobacct_process.c pgsql_jobacct_process.h
+accounting_storage_pgsql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+accounting_storage_pgsql_la_CFLAGS = $(PGSQL_CFLAGS)
+accounting_storage_pgsql_la_LIBADD = \
+	$(top_builddir)/src/database/libslurm_pgsql.la $(PGSQL_LIBS)
+accounting_storage_pgsql_la_DEPENDENCIES = \
+	$(top_builddir)/src/database/libslurm_pgsql.la
+
diff --git a/src/plugins/accounting_storage/pgsql/Makefile.in b/src/plugins/accounting_storage/pgsql/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..c7c14a43882f4936b19fdaf6efaf7331d642a00f
--- /dev/null
+++ b/src/plugins/accounting_storage/pgsql/Makefile.in
@@ -0,0 +1,583 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for accounting_storage/pgsql plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/accounting_storage/pgsql
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+am_accounting_storage_pgsql_la_OBJECTS =  \
+	accounting_storage_pgsql_la-accounting_storage_pgsql.lo \
+	accounting_storage_pgsql_la-pgsql_jobacct_process.lo
+accounting_storage_pgsql_la_OBJECTS =  \
+	$(am_accounting_storage_pgsql_la_OBJECTS)
+accounting_storage_pgsql_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(accounting_storage_pgsql_la_CFLAGS) $(CFLAGS) \
+	$(accounting_storage_pgsql_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(accounting_storage_pgsql_la_SOURCES)
+DIST_SOURCES = $(accounting_storage_pgsql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = accounting_storage_pgsql.la
+
+# Pgsql storage plugin.
+accounting_storage_pgsql_la_SOURCES = accounting_storage_pgsql.c \
+		pgsql_jobacct_process.c pgsql_jobacct_process.h
+
+accounting_storage_pgsql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+accounting_storage_pgsql_la_CFLAGS = $(PGSQL_CFLAGS)
+accounting_storage_pgsql_la_LIBADD = \
+	$(top_builddir)/src/database/libslurm_pgsql.la $(PGSQL_LIBS)
+
+accounting_storage_pgsql_la_DEPENDENCIES = \
+	$(top_builddir)/src/database/libslurm_pgsql.la
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/accounting_storage/pgsql/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/accounting_storage/pgsql/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+accounting_storage_pgsql.la: $(accounting_storage_pgsql_la_OBJECTS) $(accounting_storage_pgsql_la_DEPENDENCIES) 
+	$(accounting_storage_pgsql_la_LINK) -rpath $(pkglibdir) $(accounting_storage_pgsql_la_OBJECTS) $(accounting_storage_pgsql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_pgsql_la-accounting_storage_pgsql.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_pgsql_la-pgsql_jobacct_process.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+accounting_storage_pgsql_la-accounting_storage_pgsql.lo: accounting_storage_pgsql.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_pgsql_la_CFLAGS) $(CFLAGS) -MT accounting_storage_pgsql_la-accounting_storage_pgsql.lo -MD -MP -MF $(DEPDIR)/accounting_storage_pgsql_la-accounting_storage_pgsql.Tpo -c -o accounting_storage_pgsql_la-accounting_storage_pgsql.lo `test -f 'accounting_storage_pgsql.c' || echo '$(srcdir)/'`accounting_storage_pgsql.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/accounting_storage_pgsql_la-accounting_storage_pgsql.Tpo $(DEPDIR)/accounting_storage_pgsql_la-accounting_storage_pgsql.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='accounting_storage_pgsql.c' object='accounting_storage_pgsql_la-accounting_storage_pgsql.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_pgsql_la_CFLAGS) $(CFLAGS) -c -o accounting_storage_pgsql_la-accounting_storage_pgsql.lo `test -f 'accounting_storage_pgsql.c' || echo '$(srcdir)/'`accounting_storage_pgsql.c
+
+accounting_storage_pgsql_la-pgsql_jobacct_process.lo: pgsql_jobacct_process.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_pgsql_la_CFLAGS) $(CFLAGS) -MT accounting_storage_pgsql_la-pgsql_jobacct_process.lo -MD -MP -MF $(DEPDIR)/accounting_storage_pgsql_la-pgsql_jobacct_process.Tpo -c -o accounting_storage_pgsql_la-pgsql_jobacct_process.lo `test -f 'pgsql_jobacct_process.c' || echo '$(srcdir)/'`pgsql_jobacct_process.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/accounting_storage_pgsql_la-pgsql_jobacct_process.Tpo $(DEPDIR)/accounting_storage_pgsql_la-pgsql_jobacct_process.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='pgsql_jobacct_process.c' object='accounting_storage_pgsql_la-pgsql_jobacct_process.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(accounting_storage_pgsql_la_CFLAGS) $(CFLAGS) -c -o accounting_storage_pgsql_la-pgsql_jobacct_process.lo `test -f 'pgsql_jobacct_process.c' || echo '$(srcdir)/'`pgsql_jobacct_process.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c
new file mode 100644
index 0000000000000000000000000000000000000000..0219e9517cda9b8fb6586246efe41598626ad738
--- /dev/null
+++ b/src/plugins/accounting_storage/pgsql/accounting_storage_pgsql.c
@@ -0,0 +1,1566 @@
+/*****************************************************************************\
+ *  accounting_storage_pgsql.c - accounting interface to pgsql.
+ *
+ *  $Id: accounting_storage_pgsql.c 13061 2008-01-22 21:23:56Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include <strings.h>
+#include "pgsql_jobacct_process.h"
+#include "src/common/slurmdbd_defs.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Accounting storage PGSQL plugin";
+const char plugin_type[] = "accounting_storage/pgsql";
+const uint32_t plugin_version = 100;
+#ifndef HAVE_PGSQL
+typedef void PGconn;
+#else
+#define DEFAULT_ACCT_DB "slurm_acct_db"
+
+static pgsql_db_info_t *pgsql_db_info = NULL;
+static char *pgsql_db_name = NULL;
+		
+char *acct_coord_table = "acct_coord_table";
+char *acct_table = "acct_table";
+char *assoc_day_table = "assoc_day_usage_table";
+char *assoc_hour_table = "assoc_hour_usage_table";
+char *assoc_month_table = "assoc_month_usage_table";
+char *assoc_table = "assoc_table";
+char *cluster_day_table = "cluster_day_usage_table";
+char *cluster_hour_table = "cluster_hour_usage_table";
+char *cluster_month_table = "cluster_month_usage_table";
+char *cluster_table = "cluster_table";
+char *event_table = "cluster_event_table";
+char *job_table = "job_table";
+char *step_table = "step_table";
+char *txn_table = "txn_table";
+char *user_table = "user_table";
+char *last_ran_table = "last_ran_table";
+char *suspend_table = "suspend_table";
+
+static int _get_db_index(PGconn *acct_pgsql_db,
+			 time_t submit, uint32_t jobid, uint32_t associd)
+{
+	PGresult *result = NULL;
+	int db_index = -1;
+	char *query = xstrdup_printf("select id from %s where "
+				     "submit=%u and jobid=%u and associd=%u",
+				     job_table, (int)submit, jobid, associd);
+
+	if(!(result = pgsql_db_query_ret(acct_pgsql_db, query))) {
+		xfree(query);
+		return -1;
+	 }
+
+	xfree(query);
+	
+	if(!PQntuples(result)) {
+		PQclear(result);
+		error("We can't get a db_index for this combo, "
+		      "submit=%u and jobid=%u and associd=%u.",
+		      (int)submit, jobid, associd);
+		return -1;
+	}
+	db_index = atoi(PQgetvalue(result, 0, 0));	
+	PQclear(result);
+	
+	return db_index;
+}
+
+
+static pgsql_db_info_t *_pgsql_acct_create_db_info()
+{
+	pgsql_db_info_t *db_info = xmalloc(sizeof(pgsql_db_info_t));
+	db_info->port = slurm_get_accounting_storage_port();
+	/* it turns out it is better if using defaults to let postgres
+	   handle them on it's own terms */
+	if(!db_info->port)
+		db_info->port = 5432;
+	db_info->host = slurm_get_accounting_storage_host();
+	if(!db_info->host)
+		db_info->host = xstrdup("localhost");
+	db_info->user = slurm_get_accounting_storage_user();	
+	db_info->pass = slurm_get_accounting_storage_pass();	
+	return db_info;
+}
+
+static int _pgsql_acct_check_tables(PGconn *acct_pgsql_db,
+				    char *user)
+{
+	storage_field_t acct_coord_table_fields[] = {
+		{ "deleted", "smallint default 0" },
+		{ "acct", "text not null" },
+		{ "user_name", "text not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t acct_table_fields[] = {
+		{ "creation_time", "bigint not null" },
+		{ "mod_time", "bigint default 0" },
+		{ "deleted", "smallint default 0" },
+		{ "name", "text not null" },
+		{ "description", "text not null" },
+		{ "organization", "text not null" },
+		{ "qos", "smallint default 1 not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t assoc_table_fields[] = {
+		{ "creation_time", "bigint not null" },
+		{ "mod_time", "bigint default 0" },
+		{ "deleted", "smallint default 0" },
+		{ "id", "serial" },
+		{ "user_name", "text not null default ''" },
+		{ "acct", "text not null" },
+		{ "cluster", "text not null" },
+		{ "partition", "text not null default ''" },
+		{ "parent", "int not null" },
+		{ "lft", "int not null" },
+		{ "rgt", "int not null" },
+		{ "fairshare", "int default 1 not null" },
+		{ "max_jobs", "int default NULL" },
+		{ "max_nodes_per_job", "int default NULL" },
+		{ "max_wall_duration_per_job", "int default NULL" },
+		{ "max_cpu_seconds_per_job", "int default NULL" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t assoc_usage_table_fields[] = {
+		{ "creation_time", "bigint not null" },
+		{ "mod_time", "bigint default 0" },
+		{ "deleted", "smallint default 0" },
+		{ "associd", "int not null" },
+		{ "period_start", "bigint not null" },
+		{ "alloc_cpu_secs", "bigint default 0" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t cluster_table_fields[] = {
+		{ "creation_time", "bigint not null" },
+		{ "mod_time", "bigint default 0" },
+		{ "deleted", "smallint default 0" },
+		{ "name", "text not null" },
+		{ "control_host", "text not null" },
+		{ "control_port", "int not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t cluster_usage_table_fields[] = {
+		{ "creation_time", "bigint not null" },
+		{ "mod_time", "bigint default 0" },
+		{ "deleted", "smallint default 0" },
+		{ "cluster", "text not null" },
+		{ "period_start", "bigint not null" },
+		{ "cpu_count", "bigint default 0" },
+		{ "alloc_cpu_secs", "bigint default 0" },
+		{ "down_cpu_secs", "bigint default 0" },
+		{ "idle_cpu_secs", "bigint default 0" },
+		{ "resv_cpu_secs", "bigint default 0" },
+		{ "over_cpu_secs", "bigint default 0" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t event_table_fields[] = {
+		{ "node_name", "text default '' not null" },
+		{ "cluster", "text not null" },
+		{ "cpu_count", "int not null" },
+		{ "period_start", "bigint not null" },
+		{ "period_end", "bigint default 0 not null" },
+		{ "reason", "text not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t job_table_fields[] = {
+		{ "id", "serial" },
+		{ "jobid", "integer not null" },
+		{ "associd", "bigint not null" },
+		{ "uid", "smallint not null" },
+		{ "gid", "smallint not null" },
+		{ "partition", "text not null" },
+		{ "blockid", "text" },
+		{ "account", "text" },
+		{ "submit", "bigint not null" },
+		{ "eligible", "bigint default 0 not null" },
+		{ "start", "bigint default 0 not null" },
+		{ "endtime", "bigint default 0 not null" },
+		{ "suspended", "bigint default 0 not null" },
+		{ "name", "text not null" }, 
+		{ "track_steps", "smallint not null" },
+		{ "state", "smallint not null" }, 
+		{ "comp_code", "int default 0 not null" },
+		{ "priority", "bigint not null" },
+		{ "req_cpus", "int not null" }, 
+		{ "alloc_cpus", "int not null" }, 
+		{ "nodelist", "text" },
+		{ "kill_requid", "smallint default -1 not null" },
+		{ "qos", "smallint default 0" },
+		{ NULL, NULL}
+	};
+
+	storage_field_t last_ran_table_fields[] = {
+		{ "hourly_rollup", "bigint default 0 not null" },
+		{ "daily_rollup", "bigint default 0 not null" },
+		{ "monthly_rollup", "bigint default 0 not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t step_table_fields[] = {
+		{ "id", "int not null" },
+		{ "stepid", "smallint not null" },
+		{ "start", "bigint default 0 not null" },
+		{ "endtime", "bigint default 0 not null" },
+		{ "suspended", "bigint default 0 not null" },
+		{ "name", "text not null" },
+		{ "nodelist", "text not null" },
+		{ "state", "smallint not null" },
+		{ "kill_requid", "smallint default -1 not null" },
+		{ "comp_code", "int default 0 not null" },
+		{ "cpus", "int not null" },
+		{ "user_sec", "bigint default 0 not null" },
+		{ "user_usec", "bigint default 0 not null" },
+		{ "sys_sec", "bigint default 0 not null" },
+		{ "sys_usec", "bigint default 0 not null" },
+		{ "max_vsize", "integer default 0 not null" },
+		{ "max_vsize_task", "smallint default 0 not null" },
+		{ "max_vsize_node", "integer default 0 not null" },
+		{ "ave_vsize", "float default 0.0 not null" },
+		{ "max_rss", "integer default 0 not null" },
+		{ "max_rss_task", "smallint default 0 not null" },
+		{ "max_rss_node", "integer default 0 not null" },
+		{ "ave_rss", "float default 0.0 not null" },
+		{ "max_pages", "integer default 0 not null" },
+		{ "max_pages_task", "smallint default 0 not null" },
+		{ "max_pages_node", "integer default 0 not null" },
+		{ "ave_pages", "float default 0.0 not null" },
+		{ "min_cpu", "integer default 0 not null" },
+		{ "min_cpu_task", "smallint default 0 not null" },
+		{ "min_cpu_node", "integer default 0 not null" },
+		{ "ave_cpu", "float default 0.0 not null" },
+		{ NULL, NULL}
+	};
+
+	storage_field_t suspend_table_fields[] = {
+		{ "id", "int not null" },
+		{ "associd", "bigint not null" },
+		{ "start", "bigint default 0 not null" },
+		{ "endtime", "bigint default 0 not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t txn_table_fields[] = {
+		{ "id", "serial" },
+		{ "timestamp", "bigint default 0" },
+		{ "action", "smallint not null" },
+		{ "name", "text not null" },
+		{ "actor", "text not null" },
+		{ "info", "text not null" },
+		{ NULL, NULL}		
+	};
+
+	storage_field_t user_table_fields[] = {
+		{ "creation_time", "bigint not null" },
+		{ "mod_time", "bigint default 0" },
+		{ "deleted", "smallint default 0" },
+		{ "name", "text not null" },
+		{ "default_acct", "text not null" },
+		{ "qos", "smallint default 1 not null" },
+		{ "admin_level", "smallint default 1 not null" },
+		{ NULL, NULL}		
+	};
+
+	int i = 0, job_found = 0;
+	int step_found = 0, txn_found = 0, event_found = 0;
+	int user_found = 0, acct_found = 0, acct_coord_found = 0;
+	int cluster_found = 0, cluster_hour_found = 0,
+		cluster_day_found = 0, cluster_month_found = 0;
+	int assoc_found = 0, assoc_hour_found = 0,
+		assoc_day_found = 0, assoc_month_found = 0;
+	int suspend_found = 0, last_ran_found = 0;
+
+	PGresult *result = NULL;
+	char *query = xstrdup_printf("select tablename from pg_tables "
+				     "where tableowner='%s' "
+				     "and tablename !~ '^pg_+'", user);
+
+	if(!(result =
+	     pgsql_db_query_ret(acct_pgsql_db, query))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	for (i = 0; i < PQntuples(result); i++) {
+		if(!acct_coord_found &&
+		   !strcmp(acct_coord_table, PQgetvalue(result, i, 0))) 
+			acct_coord_found = 1;
+		else if(!acct_found &&
+			!strcmp(acct_table, PQgetvalue(result, i, 0))) 
+			acct_found = 1;
+		else if(!assoc_found &&
+			!strcmp(assoc_table, PQgetvalue(result, i, 0))) 
+			assoc_found = 1;
+		else if(!assoc_day_found &&
+			!strcmp(assoc_day_table, PQgetvalue(result, i, 0))) 
+			assoc_day_found = 1;
+		else if(!assoc_hour_found &&
+			!strcmp(assoc_hour_table, PQgetvalue(result, i, 0))) 
+			assoc_hour_found = 1;
+		else if(!assoc_month_found &&
+			!strcmp(assoc_month_table, PQgetvalue(result, i, 0))) 
+			assoc_month_found = 1;
+		else if(!cluster_found &&
+			!strcmp(cluster_table, PQgetvalue(result, i, 0))) 
+			cluster_found = 1;
+		else if(!cluster_day_found &&
+			!strcmp(cluster_day_table, PQgetvalue(result, i, 0))) 
+			cluster_day_found = 1;
+		else if(!cluster_hour_found &&
+			!strcmp(cluster_hour_table, PQgetvalue(result, i, 0))) 
+			cluster_hour_found = 1;
+		else if(!cluster_month_found &&
+			!strcmp(cluster_month_table, PQgetvalue(result, i, 0))) 
+			cluster_month_found = 1;
+		else if(!event_found &&
+			!strcmp(event_table, PQgetvalue(result, i, 0))) 
+			event_found = 1;
+		else if(!job_found &&
+			!strcmp(job_table, PQgetvalue(result, i, 0))) 
+			job_found = 1;
+		else if(!last_ran_found &&
+			!strcmp(last_ran_table, PQgetvalue(result, i, 0))) 
+			last_ran_found = 1;
+		else if(!step_found &&
+			!strcmp(step_table, PQgetvalue(result, i, 0))) 
+			step_found = 1;
+		else if(!suspend_found &&
+			!strcmp(suspend_table, PQgetvalue(result, i, 0))) 
+			suspend_found = 1;
+		else if(!txn_found &&
+			!strcmp(txn_table, PQgetvalue(result, i, 0))) 
+			txn_found = 1;
+		else if(!user_found &&
+			!strcmp(user_table, PQgetvalue(result, i, 0))) 
+			user_found = 1;
+	}
+	PQclear(result);
+
+	if(!acct_coord_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 acct_coord_table, 
+					 acct_coord_table_fields,
+					 ", unique (acct, user_name))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       acct_coord_table,
+					       acct_coord_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!acct_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 acct_table, acct_table_fields,
+					 ", unique (name))") 
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       acct_table,
+					       acct_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!assoc_day_found) {
+		if(pgsql_db_create_table(
+			   acct_pgsql_db, 
+			   assoc_day_table,
+			   assoc_usage_table_fields,
+			   ", unique (associd, period_start))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       assoc_day_table,
+					       assoc_usage_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!assoc_hour_found) {
+		if(pgsql_db_create_table(
+			   acct_pgsql_db, 
+			   assoc_hour_table,
+			   assoc_usage_table_fields,
+			   ", unique (associd, period_start))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       assoc_hour_table,
+					       assoc_usage_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!assoc_month_found) {
+		if(pgsql_db_create_table(
+			   acct_pgsql_db, 
+			   assoc_month_table,
+			   assoc_usage_table_fields,
+			   ", unique (associd, period_start))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       assoc_month_table,
+					       assoc_usage_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!assoc_found) {
+		if(pgsql_db_create_table(
+			   acct_pgsql_db, 
+			   assoc_table, assoc_table_fields,
+			   ", unique (user_name, acct, cluster, partition))") 
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       assoc_table,
+					       assoc_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!cluster_day_found) {
+		if(pgsql_db_create_table(
+			   acct_pgsql_db, 
+			   cluster_day_table, 
+			   cluster_usage_table_fields,
+			   ", unique (cluster, period_start))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       cluster_day_table,
+					       cluster_usage_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!cluster_hour_found) {
+		if(pgsql_db_create_table(
+			   acct_pgsql_db, 
+			   cluster_hour_table, 
+			   cluster_usage_table_fields,
+			   ", unique (cluster, period_start))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       cluster_hour_table,
+					       cluster_usage_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!cluster_month_found) {
+		if(pgsql_db_create_table(
+			   acct_pgsql_db, 
+			   cluster_month_table, 
+			   cluster_usage_table_fields,
+			   ", unique (cluster, period_start))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       cluster_month_table,
+					       cluster_usage_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!cluster_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 cluster_table, cluster_table_fields,
+					 ", unique (name))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       cluster_table,
+					       cluster_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!event_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 event_table, event_table_fields,
+					 ", unique (node_name, "
+					 "cluster, period_start))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       event_table,
+					       event_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!job_found) {
+		if(pgsql_db_create_table(acct_pgsql_db,  
+					 job_table, job_table_fields,
+					 ", unique (jobid, associd, submit))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       job_table,
+					       job_table_fields))
+			return SLURM_ERROR;
+	}
+	
+	if(!last_ran_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 last_ran_table, last_ran_table_fields,
+					 ")")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       last_ran_table,
+					       last_ran_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!step_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 step_table, step_table_fields,
+					 ", unique (id, stepid))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       step_table,
+					       step_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!suspend_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 suspend_table, suspend_table_fields,
+					 ")")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       suspend_table,
+					       suspend_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!txn_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 txn_table, txn_table_fields,
+					 ", unique (id))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       txn_table,
+					       txn_table_fields))
+			return SLURM_ERROR;
+	}
+
+	if(!user_found) {
+		if(pgsql_db_create_table(acct_pgsql_db, 
+					 user_table, user_table_fields,
+					 ", unique (name))")
+		   == SLURM_ERROR)
+			return SLURM_ERROR;
+	} else {
+		if(pgsql_db_make_table_current(acct_pgsql_db,  
+					       user_table,
+					       user_table_fields))
+			return SLURM_ERROR;
+	}
+
+	return SLURM_SUCCESS;
+}
+#endif
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	static int first = 1;
+	int rc = SLURM_SUCCESS;
+#ifdef HAVE_PGSQL
+	PGconn *acct_pgsql_db = NULL;
+	char *location = NULL;
+#else
+	fatal("No Postgres database was found on the machine. "
+	      "Please check the configure log and run again.");	
+#endif
+	/* since this can be loaded from many different places
+	   only tell us once. */
+	if(!first)
+		return SLURM_SUCCESS;
+
+	first = 0;
+
+#ifdef HAVE_PGSQL
+	pgsql_db_info = _pgsql_acct_create_db_info();		
+
+	location = slurm_get_accounting_storage_loc();
+	if(!location)
+		pgsql_db_name = xstrdup(DEFAULT_ACCT_DB);
+	else {
+		int i = 0;
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_ACCT_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) {
+			pgsql_db_name = xstrdup(DEFAULT_ACCT_DB);
+			xfree(location);
+		} else
+			pgsql_db_name = location;
+	}
+
+	debug2("pgsql_connect() called for db %s", pgsql_db_name);
+		
+	pgsql_get_db_connection(&acct_pgsql_db, pgsql_db_name, pgsql_db_info);
+		
+	rc = _pgsql_acct_check_tables(acct_pgsql_db, pgsql_db_info->user);
+	pgsql_close_db_connection(&acct_pgsql_db);
+#endif
+	/* since this can be loaded from many different places
+	   only tell us once. */
+	if(rc == SLURM_SUCCESS)
+		verbose("%s loaded", plugin_name);
+	else 
+		verbose("%s failed", plugin_name);
+	
+	return rc;
+}
+
+extern int fini ( void )
+{
+#ifdef HAVE_PGSQL
+	destroy_pgsql_db_info(pgsql_db_info);		
+	xfree(pgsql_db_name);
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern void *acct_storage_p_get_connection(bool make_agent, bool rollback)
+{
+#ifdef HAVE_PGSQL
+	PGconn *acct_pgsql_db = NULL;
+	
+	if(!pgsql_db_info)
+		init();
+	
+	debug2("acct_storage_p_get_connection: request new connection");
+	
+	pgsql_get_db_connection(&acct_pgsql_db, pgsql_db_name, pgsql_db_info);
+	
+	return (void *)acct_pgsql_db;
+#else
+	return NULL;
+#endif
+}
+
+extern int acct_storage_p_close_connection(PGconn **acct_pgsql_db)
+{
+#ifdef HAVE_PGSQL
+	if(acct_pgsql_db && *acct_pgsql_db)
+		pgsql_close_db_connection(acct_pgsql_db);
+	
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int acct_storage_p_commit(void *db_conn, bool commit)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_users(PGconn *acct_pgsql_db, uint32_t uid,
+				    List user_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_coord(PGconn *acct_pgsql_db, uint32_t uid,
+				    char *acct, acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_accts(PGconn *acct_pgsql_db, uint32_t uid,
+				    List acct_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_clusters(PGconn *acct_pgsql_db, uint32_t uid, 
+				       List cluster_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_add_associations(PGconn *acct_pgsql_db, uint32_t uid,
+					   List association_list)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_users(PGconn *acct_pgsql_db, uint32_t uid,
+					   acct_user_cond_t *user_q,
+				       acct_user_rec_t *user)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_accts(PGconn *acct_pgsql_db, uint32_t uid,
+				       acct_account_cond_t *acct_q,
+				       acct_account_rec_t *acct)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_clusters(PGconn *acct_pgsql_db, uint32_t uid,
+					   acct_cluster_cond_t *cluster_q,
+					  acct_cluster_rec_t *cluster)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_modify_associations(PGconn *acct_pgsql_db,
+					      uint32_t uid,
+					      acct_association_cond_t *assoc_q,
+					      acct_association_rec_t *assoc)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_users(PGconn *acct_pgsql_db, uint32_t uid,
+					   acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_coord(PGconn *acct_pgsql_db, uint32_t uid,
+					   char *acct, acct_user_cond_t *user_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_accts(PGconn *acct_pgsql_db, uint32_t uid,
+					   acct_account_cond_t *acct_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_clusters(PGconn *acct_pgsql_db, uint32_t uid,
+					   acct_account_cond_t *cluster_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_remove_associations(PGconn *acct_pgsql_db, 
+					      uint32_t uid,
+					      acct_association_cond_t *assoc_q)
+{
+	return SLURM_SUCCESS;
+}
+
+extern List acct_storage_p_get_users(PGconn *acct_pgsql_db,
+					   acct_user_cond_t *user_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_accts(PGconn *acct_pgsql_db,
+					   acct_account_cond_t *acct_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_clusters(PGconn *acct_pgsql_db,
+					   acct_account_cond_t *cluster_q)
+{
+	return NULL;
+}
+
+extern List acct_storage_p_get_associations(PGconn *acct_pgsql_db,
+					   acct_association_cond_t *assoc_q)
+{
+	return NULL;
+}
+
+extern int acct_storage_p_get_usage(PGconn *acct_pgsql_db,
+				    acct_association_rec_t *acct_assoc,
+				    time_t start, time_t end)
+{
+	int rc = SLURM_SUCCESS;
+
+	return rc;
+}
+
+extern int acct_storage_p_roll_usage(PGconn *acct_pgsql_db, 
+				     time_t sent_start)
+{
+	int rc = SLURM_SUCCESS;
+
+	return rc;
+}
+
+extern int clusteracct_storage_p_node_down(PGconn *acct_pgsql_db,
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time, char *reason)
+{
+#ifdef HAVE_PGSQL
+	uint16_t cpus;
+	int rc = SLURM_ERROR;
+	char *query = NULL;
+	char *my_reason;
+
+	if (slurmctld_conf.fast_schedule && !slurmdbd_conf)
+		cpus = node_ptr->config_ptr->cpus;
+	else
+		cpus = node_ptr->cpus;
+
+	if (reason)
+		my_reason = reason;
+	else
+		my_reason = node_ptr->reason;
+	
+	query = xstrdup_printf(
+		"update %s set period_end=%d where cluster='%s' "
+		"and period_end=0 and node_name='%s'",
+		event_table, (event_time-1), cluster, node_ptr->name);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+
+	debug2("inserting %s(%s) with %u cpus", node_ptr->name, cluster, cpus);
+
+	query = xstrdup_printf(
+		"insert into %s "
+		"(node_name, cluster, cpu_count, period_start, reason) "
+		"values ('%s', '%s', %u, %d, '%s')",
+		event_table, node_ptr->name, cluster, 
+		cpus, event_time, my_reason);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+extern int clusteracct_storage_p_node_up(PGconn *acct_pgsql_db,
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time)
+{
+#ifdef HAVE_PGSQL
+	char* query;
+	int rc = SLURM_ERROR;
+
+	query = xstrdup_printf(
+		"update %s set period_end=%d where cluster='%s' "
+		"and period_end=0 and node_name='%s'",
+		event_table, (event_time-1), cluster, node_ptr->name);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int clusteracct_storage_p_register_ctld(char *cluster,
+					       uint16_t port)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_cluster_procs(PGconn *acct_pgsql_db,
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time)
+{
+#ifdef HAVE_PGSQL
+	static uint32_t last_procs = -1;
+	char* query;
+	int rc = SLURM_SUCCESS;
+	PGresult *result = NULL;
+	int got_procs = 0;
+
+	if (procs == last_procs) {
+		debug3("we have the same procs as before no need to "
+		       "update the database.");
+		return SLURM_SUCCESS;
+	}
+	last_procs = procs;
+
+	/* Record the processor count */
+#if _DEBUG
+	slurm_make_time_str(&event_time, tmp_buff, sizeof(tmp_buff));
+	info("cluster_acct_procs: %s has %u total CPUs at %s", 
+	     cluster, procs, tmp_buff);
+#endif
+	query = xstrdup_printf(
+		"select cpu_count from %s where cluster='%s' "
+		"and period_end=0 and node_name=''",
+		event_table, cluster);
+	if(!(result = pgsql_db_query_ret(acct_pgsql_db, query))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	/* we only are checking the first one here */
+	if(!PQntuples(result)) {
+		debug("We don't have an entry for this machine %s "
+		      "most likely a first time running.", cluster);
+		goto add_it;
+	}
+	got_procs = atoi(PQgetvalue(result, 0, 0));
+	if(got_procs == procs) {
+		debug("%s hasn't changed since last entry", cluster);
+		goto end_it;
+	}
+	debug("%s has changed from %d cpus to %u", cluster, got_procs, procs);
+
+	query = xstrdup_printf(
+		"update %s set period_end=%u where cluster='%s' "
+		"and period_end=0 and node_name=''",
+		event_table, (event_time-1), cluster);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+	if(rc != SLURM_SUCCESS)
+		goto end_it;
+add_it:
+	query = xstrdup_printf(
+		"insert into %s (cluster, cpu_count, period_start) "
+		"values ('%s', %u, %d)",
+		event_table, cluster, procs, event_time);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+
+end_it:
+	PQclear(result);
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int clusteracct_storage_p_get_usage(
+	void *db_conn,
+	acct_cluster_rec_t *cluster_rec, time_t start, time_t end)
+{
+
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the start of a job
+ */
+extern int jobacct_storage_p_job_start(PGconn *acct_pgsql_db, 
+				       struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	int	rc=SLURM_SUCCESS;
+	char	*jname, *nodes;
+	long	priority;
+	int track_steps = 0;
+	char *block_id = NULL;
+	char *query = NULL;
+	int reinit = 0;
+
+	if (!job_ptr->details || !job_ptr->details->submit_time) {
+		error("jobacct_storage_p_job_start: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if(!acct_pgsql_db || PQstatus(acct_pgsql_db) != CONNECTION_OK) {
+		if(!pgsql_get_db_connection(&acct_pgsql_db,
+					    pgsql_db_name, pgsql_db_info))
+			return SLURM_ERROR;
+	}
+
+	debug3("pgsql_jobacct_job_start() called");
+	priority = (job_ptr->priority == NO_VAL) ?
+		-1L : (long) job_ptr->priority;
+
+	if (job_ptr->name && job_ptr->name[0]) {
+		int i;
+		jname = xmalloc(strlen(job_ptr->name) + 1);
+		for (i=0; job_ptr->name[i]; i++) {
+			if (isalnum(job_ptr->name[i]))
+				jname[i] = job_ptr->name[i];
+			else
+				jname[i] = '_';
+		}
+	} else {
+		jname = xstrdup("allocation");
+		track_steps = 1;
+	}
+
+	
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(job_ptr->batch_flag)
+		track_steps = 1;
+
+	if(slurmdbd_conf) {
+		block_id = xstrdup(job_ptr->comment);
+	} else {
+		select_g_get_jobinfo(job_ptr->select_jobinfo, 
+				     SELECT_DATA_BLOCK_ID, 
+				     &block_id);
+	}
+	job_ptr->requid = -1; /* force to -1 for sacct to know this
+			       * hasn't been set yet */
+
+	if(!job_ptr->db_index) {
+		query = xstrdup_printf(
+			"insert into %s "
+			"(jobid, account, associd, uid, gid, partition, "
+			"blockid, eligible, submit, start, name, track_steps, "
+			"state, priority, req_cpus, alloc_cpus, nodelist) "
+			"values (%u, '%s', %u, %u, %u, '%s', '%s', "
+			"%d, %d, %d, '%s', %u, "
+			"%u, %u, %u, %u, '%s')",
+			job_table, job_ptr->job_id, job_ptr->account, 
+			job_ptr->assoc_id,
+			job_ptr->user_id, job_ptr->group_id,
+			job_ptr->partition, block_id,
+			(int)job_ptr->details->begin_time,
+			(int)job_ptr->details->submit_time,
+			(int)job_ptr->start_time,
+			jname, track_steps,
+			job_ptr->job_state & (~JOB_COMPLETING),
+			priority, job_ptr->num_procs,
+			job_ptr->total_procs, nodes);
+	try_again:
+		if(!(job_ptr->db_index = pgsql_insert_ret_id(acct_pgsql_db,  
+							     "job_table_id_seq",
+							     query))) {
+			if(!reinit) {
+				error("It looks like the storage has gone "
+				      "away trying to reconnect");
+				pgsql_close_db_connection(&acct_pgsql_db);
+				pgsql_get_db_connection(&acct_pgsql_db,
+							pgsql_db_name,
+							pgsql_db_info);
+				reinit = 1;
+				goto try_again;
+			} else
+				rc = SLURM_ERROR;
+		}
+	} else {
+		query = xstrdup_printf(
+			"update %s set partition='%s', blockid='%s', start=%d, "
+			"name='%s', state=%u, alloc_cpus=%u, nodelist='%s', "
+			"account='%s' where id=%d",
+			job_table, job_ptr->partition, block_id,
+			(int)job_ptr->start_time,
+			jname, 
+			job_ptr->job_state & (~JOB_COMPLETING),
+			job_ptr->total_procs, nodes,
+			job_ptr->account, job_ptr->db_index);
+		rc = pgsql_db_query(acct_pgsql_db, query);
+	}
+	xfree(block_id);
+	xfree(jname);
+
+	xfree(query);
+	
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage the end of a job
+ */
+extern int jobacct_storage_p_job_complete(PGconn *acct_pgsql_db,
+					  struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	char *query = NULL, *nodes = NULL;
+	int rc=SLURM_SUCCESS;
+	
+	if (!job_ptr->db_index 
+	    && (!job_ptr->details || !job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_job_complete: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if(!acct_pgsql_db || PQstatus(acct_pgsql_db) != CONNECTION_OK) {
+		if(!pgsql_get_db_connection(&acct_pgsql_db,
+					    pgsql_db_name, pgsql_db_info))
+			return SLURM_ERROR;
+	}
+	
+	debug3("pgsql_jobacct_job_complete() called");
+	if (job_ptr->end_time == 0) {
+		debug("pgsql_jobacct: job %u never started", job_ptr->job_id);
+		return SLURM_ERROR;
+	}	
+	
+	if (job_ptr->nodes && job_ptr->nodes[0])
+		nodes = job_ptr->nodes;
+	else
+		nodes = "(null)";
+
+	if(!job_ptr->db_index) {
+		job_ptr->db_index = _get_db_index(acct_pgsql_db,
+						  job_ptr->details->submit_time,
+						  job_ptr->job_id,
+						  job_ptr->assoc_id);
+		if(job_ptr->db_index == -1) 
+			return SLURM_ERROR;
+	}
+	query = xstrdup_printf("update %s set start=%u, endtime=%u, state=%d, "
+			       "nodelist='%s', comp_code=%u, "
+			       "kill_requid=%u where id=%u",
+			       job_table, (int)job_ptr->start_time,
+			       (int)job_ptr->end_time, 
+			       job_ptr->job_state & (~JOB_COMPLETING),
+			       nodes, job_ptr->exit_code,
+			       job_ptr->requid, job_ptr->db_index);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+
+	return  rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage the start of a job step
+ */
+extern int jobacct_storage_p_step_start(PGconn *acct_pgsql_db,
+					struct step_record *step_ptr)
+{
+#ifdef HAVE_PGSQL
+	int cpus = 0;
+	int rc=SLURM_SUCCESS;
+	char node_list[BUFFER_SIZE];
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+#endif
+	char *query = NULL;
+	
+	if (!step_ptr->job_ptr->db_index 
+	    && (!step_ptr->job_ptr->details
+		|| !step_ptr->job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_step_start: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if(!acct_pgsql_db || PQstatus(acct_pgsql_db) != CONNECTION_OK) {
+		if(!pgsql_get_db_connection(&acct_pgsql_db,
+					    pgsql_db_name, pgsql_db_info))
+			return SLURM_ERROR;
+	}
+
+	if(slurmdbd_conf) {
+		cpus = step_ptr->job_ptr->total_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	} else {
+#ifdef HAVE_BG
+		cpus = step_ptr->job_ptr->num_procs;
+		select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+				     SELECT_DATA_IONODES, 
+				     &ionodes);
+		if(ionodes) {
+			snprintf(node_list, BUFFER_SIZE, 
+				 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+			xfree(ionodes);
+		} else
+			snprintf(node_list, BUFFER_SIZE, "%s",
+				 step_ptr->job_ptr->nodes);
+		
+#else
+		if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+			cpus = step_ptr->job_ptr->total_procs;
+			snprintf(node_list, BUFFER_SIZE, "%s",
+				 step_ptr->job_ptr->nodes);
+		} else {
+			cpus = step_ptr->step_layout->task_cnt;
+			snprintf(node_list, BUFFER_SIZE, "%s", 
+				 step_ptr->step_layout->node_list);
+		}
+#endif
+	}
+
+	step_ptr->job_ptr->requid = -1; /* force to -1 for sacct to know this
+					 * hasn't been set yet  */
+
+	if(!step_ptr->job_ptr->db_index) {
+		step_ptr->job_ptr->db_index = 
+			_get_db_index(acct_pgsql_db,
+				      step_ptr->job_ptr->details->submit_time,
+				      step_ptr->job_ptr->job_id,
+				      step_ptr->job_ptr->assoc_id);
+		if(step_ptr->job_ptr->db_index == -1) 
+			return SLURM_ERROR;
+	}
+	/* we want to print a -1 for the requid so leave it a
+	   %d */
+	query = xstrdup_printf(
+		"insert into %s (id, stepid, start, name, state, "
+		"cpus, nodelist) "
+		"values (%d, %u, %u, '%s', %d, %u, '%s')",
+		step_table, step_ptr->job_ptr->db_index,
+		step_ptr->step_id, 
+		(int)step_ptr->start_time, step_ptr->name,
+		JOB_RUNNING, cpus, node_list);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage the end of a job step
+ */
+extern int jobacct_storage_p_step_complete(PGconn *acct_pgsql_db,
+					   struct step_record *step_ptr)
+{
+#ifdef HAVE_PGSQL
+	time_t now;
+	int elapsed;
+	int comp_status;
+	int cpus = 0;
+	struct jobacctinfo *jobacct = (struct jobacctinfo *)step_ptr->jobacct;
+	struct jobacctinfo dummy_jobacct;
+	float ave_vsize = 0, ave_rss = 0, ave_pages = 0;
+	float ave_cpu = 0, ave_cpu2 = 0;
+	char *query = NULL;
+	int rc =SLURM_SUCCESS;
+	
+	if (!step_ptr->job_ptr->db_index 
+	    && (!step_ptr->job_ptr->details
+		|| !step_ptr->job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_step_complete: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	if(!acct_pgsql_db || PQstatus(acct_pgsql_db) != CONNECTION_OK) {
+		if(!pgsql_get_db_connection(&acct_pgsql_db,
+					    pgsql_db_name, pgsql_db_info))
+			return SLURM_ERROR;
+	}
+	
+	if (jobacct == NULL) {
+		/* JobAcctGather=jobacct_gather/none, no data to process */
+		bzero(&dummy_jobacct, sizeof(dummy_jobacct));
+		jobacct = &dummy_jobacct;
+	}
+
+	if(slurmdbd_conf) {
+		now = step_ptr->job_ptr->end_time;
+		cpus = step_ptr->job_ptr->total_procs;
+
+	} else {
+		now = time(NULL);
+#ifdef HAVE_BG
+		cpus = step_ptr->job_ptr->num_procs;
+		
+#else
+		if(!step_ptr->step_layout || !step_ptr->step_layout->task_cnt)
+			cpus = step_ptr->job_ptr->total_procs;
+		else 
+			cpus = step_ptr->step_layout->task_cnt;
+#endif
+	}
+
+	if ((elapsed=now-step_ptr->start_time)<0)
+		elapsed=0;	/* For *very* short jobs, if clock is wrong */
+	if (step_ptr->exit_code)
+		comp_status = JOB_FAILED;
+	else
+		comp_status = JOB_COMPLETE;
+
+	/* figure out the ave of the totals sent */
+	if(cpus > 0) {
+		ave_vsize = jobacct->tot_vsize;
+		ave_vsize /= cpus;
+		ave_rss = jobacct->tot_rss;
+		ave_rss /= cpus;
+		ave_pages = jobacct->tot_pages;
+		ave_pages /= cpus;
+		ave_cpu = jobacct->tot_cpu;
+		ave_cpu /= cpus;	
+		ave_cpu /= 100;
+	}
+ 
+	if(jobacct->min_cpu != (uint32_t)NO_VAL) {
+		ave_cpu2 = jobacct->min_cpu;
+		ave_cpu2 /= 100;
+	}
+
+	if(!step_ptr->job_ptr->db_index) {
+		step_ptr->job_ptr->db_index = 
+			_get_db_index(acct_pgsql_db,
+				      step_ptr->job_ptr->details->submit_time,
+				      step_ptr->job_ptr->job_id,
+				      step_ptr->job_ptr->assoc_id);
+		if(step_ptr->job_ptr->db_index == -1) 
+			return SLURM_ERROR;
+	}
+
+	query = xstrdup_printf(
+		"update %s set endtime=%u, state=%d, "
+		"kill_requid=%u, comp_code=%u, "
+		"user_sec=%ld, user_usec=%ld, "
+		"sys_sec=%ld, sys_usec=%ld, "
+		"max_vsize=%u, max_vsize_task=%u, "
+		"max_vsize_node=%u, ave_vsize=%.2f, "
+		"max_rss=%u, max_rss_task=%u, "
+		"max_rss_node=%u, ave_rss=%.2f, "
+		"max_pages=%u, max_pages_task=%u, "
+		"max_pages_node=%u, ave_pages=%.2f, "
+		"min_cpu=%.2f, min_cpu_task=%u, "
+		"min_cpu_node=%u, ave_cpu=%.2f "
+		"where id=%u and stepid=%u",
+		step_table, (int)now,
+		comp_status,
+		step_ptr->job_ptr->requid, 
+		step_ptr->exit_code, 
+		/* user seconds */
+		jobacct->user_cpu_sec,	
+		/* user microseconds */
+		jobacct->user_cpu_usec,
+		/* system seconds */
+		jobacct->sys_cpu_sec,
+		/* system microsecs */
+		jobacct->sys_cpu_usec,
+		jobacct->max_vsize,	/* max vsize */
+		jobacct->max_vsize_id.taskid,	/* max vsize task */
+		jobacct->max_vsize_id.nodeid,	/* max vsize node */
+		ave_vsize,	/* ave vsize */
+		jobacct->max_rss,	/* max vsize */
+		jobacct->max_rss_id.taskid,	/* max rss task */
+		jobacct->max_rss_id.nodeid,	/* max rss node */
+		ave_rss,	/* ave rss */
+		jobacct->max_pages,	/* max pages */
+		jobacct->max_pages_id.taskid,	/* max pages task */
+		jobacct->max_pages_id.nodeid,	/* max pages node */
+		ave_pages,	/* ave pages */
+		ave_cpu2,	/* min cpu */
+		jobacct->min_cpu_id.taskid,	/* min cpu task */
+		jobacct->min_cpu_id.nodeid,	/* min cpu node */
+		ave_cpu,	/* ave cpu */
+		step_ptr->job_ptr->db_index, step_ptr->step_id);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	xfree(query);
+		 
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * load into the storage a suspention of a job
+ */
+extern int jobacct_storage_p_suspend(PGconn *acct_pgsql_db,
+				     struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	char query[1024];
+	int rc = SLURM_SUCCESS;
+	
+	if(!acct_pgsql_db || PQstatus(acct_pgsql_db) != CONNECTION_OK) {
+		if(!pgsql_get_db_connection(&acct_pgsql_db,
+					    pgsql_db_name, pgsql_db_info))
+			return SLURM_ERROR;
+	}
+	
+	if(!job_ptr->db_index) {
+		job_ptr->db_index = _get_db_index(acct_pgsql_db,
+						  job_ptr->details->submit_time,
+						  job_ptr->job_id,
+						  job_ptr->assoc_id);
+		if(job_ptr->db_index == -1) 
+			return SLURM_ERROR;
+	}
+
+	snprintf(query, sizeof(query),
+		 "update %s set suspended=%u-suspended, state=%d "
+		 "where id=%u",
+		 job_table, (int)job_ptr->suspend_time, 
+		 job_ptr->job_state & (~JOB_COMPLETING),
+		 job_ptr->db_index);
+	rc = pgsql_db_query(acct_pgsql_db, query);
+	if(rc != SLURM_ERROR) {
+		snprintf(query, sizeof(query),
+			 "update %s set suspended=%u-suspended, "
+			 "state=%d where id=%u and endtime=0",
+			 step_table, (int)job_ptr->suspend_time, 
+			 job_ptr->job_state, job_ptr->db_index);
+		rc = pgsql_db_query(acct_pgsql_db, query);			
+	}
+	
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+/* 
+ * get info from the storage 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_p_get_jobs(PGconn *acct_pgsql_db,
+				       List selected_steps,
+				       List selected_parts,
+				       void *params)
+{
+	List job_list = NULL;
+#ifdef HAVE_PGSQL
+	if(!acct_pgsql_db || PQstatus(acct_pgsql_db) != CONNECTION_OK) {
+		if(!pgsql_get_db_connection(&acct_pgsql_db,
+					    pgsql_db_name, pgsql_db_info))
+			return job_list;
+	}
+
+	job_list = pgsql_jobacct_process_get_jobs(acct_pgsql_db,
+						  selected_steps, 
+						  selected_parts,
+						  params);
+#endif
+	return job_list;
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void jobacct_storage_p_archive(PGconn *acct_pgsql_db,
+				      List selected_parts,
+				      void *params)
+{
+#ifdef HAVE_PGSQL
+	if(!acct_pgsql_db || PQstatus(acct_pgsql_db) != CONNECTION_OK) {
+		if(!pgsql_get_db_connection(&acct_pgsql_db,
+					    pgsql_db_name, pgsql_db_info))
+			return;
+	}
+
+	pgsql_jobacct_process_archive(acct_pgsql_db, selected_parts, params);
+#endif
+	return;
+}
+
+extern int acct_storage_p_update_shares_used(void *db_conn,
+					     List shares_used)
+{
+	/* This definitely needs to be fleshed out.
+	 * Go through the list of shares_used_object_t objects and store them */
+	return SLURM_SUCCESS;
+}
+
+extern int acct_storage_p_flush_jobs_on_cluster(
+	void *db_conn, char *cluster, time_t event_time)
+{
+	/* put end times for a clean start */
+
+
+
+
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/accounting_storage/pgsql/pgsql_jobacct_process.c b/src/plugins/accounting_storage/pgsql/pgsql_jobacct_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..c1ff95fb8f8046343f1c1356f5d1835a9a764ee6
--- /dev/null
+++ b/src/plugins/accounting_storage/pgsql/pgsql_jobacct_process.c
@@ -0,0 +1,491 @@
+/*****************************************************************************\
+ *  pgsql_jobacct_process.c - functions the processing of
+ *                               information from the pgsql jobacct
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "pgsql_jobacct_process.h"
+
+#ifdef HAVE_PGSQL
+static void _do_fdump(List job_list)
+{
+	info("fdump option not applicable from pgsql plugin");
+	return;
+}
+
+extern List pgsql_jobacct_process_get_jobs(PGconn *acct_pgsql_db,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	PGresult *result = NULL, *step_result = NULL;
+	int i, j;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
+	time_t now = time(NULL);
+	List job_list = list_create(destroy_jobacct_job_rec);
+		
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is job_table */
+	char *job_req_inx[] = {
+		"t1.id",
+		"t1.jobid",
+		"t1.associd",
+		"t1.uid",
+		"t1.gid",
+		"t1.partition",
+		"t1.blockid",
+		"t1.account",
+		"t1.eligible",
+		"t1.submit",
+		"t1.start",
+		"t1.endtime",
+		"t1.suspended",
+		"t1.name",
+		"t1.track_steps",
+		"t1.state",
+		"t1.comp_code",
+		"t1.priority",
+		"t1.req_cpus",
+		"t1.alloc_cpus",
+		"t1.nodelist",
+		"t1.kill_requid",
+		"t1.qos",
+	};
+
+	/* if this changes you will need to edit the corresponding 
+	 * enum below also t1 is step_table */
+	char *step_req_inx[] = {
+		"t1.stepid",
+		"t1.start",
+		"t1.endtime",
+		"t1.suspended",
+		"t1.name",
+		"t1.nodelist",
+		"t1.state",
+		"t1.kill_requid",
+		"t1.comp_code",
+		"t1.cpus",
+		"t1.user_sec",
+		"t1.user_usec",
+		"t1.sys_sec",
+		"t1.sys_usec",
+		"t1.max_vsize",
+		"t1.max_vsize_task",
+		"t1.max_vsize_node",
+		"t1.ave_vsize",
+		"t1.max_rss",
+		"t1.max_rss_task",
+		"t1.max_rss_node",
+		"t1.ave_rss",
+		"t1.max_pages",
+		"t1.max_pages_task",
+		"t1.max_pages_node",
+		"t1.ave_pages",
+		"t1.min_cpu",
+		"t1.min_cpu_task",
+		"t1.min_cpu_node",
+		"t1.ave_cpu",
+	};
+
+	enum {
+		JOB_REQ_ID,
+		JOB_REQ_JOBID,
+		JOB_REQ_ASSOCID,
+		JOB_REQ_UID,
+		JOB_REQ_GID,
+		JOB_REQ_PARTITION,
+		JOB_REQ_BLOCKID,
+		JOB_REQ_ACCOUNT,
+		JOB_REQ_ELIGIBLE,
+		JOB_REQ_SUBMIT,
+		JOB_REQ_START,
+		JOB_REQ_ENDTIME,
+		JOB_REQ_SUSPENDED,
+		JOB_REQ_NAME,
+		JOB_REQ_TRACKSTEPS,
+		JOB_REQ_STATE,
+		JOB_REQ_COMP_CODE,
+		JOB_REQ_PRIORITY,
+		JOB_REQ_REQ_CPUS,
+		JOB_REQ_ALLOC_CPUS,
+		JOB_REQ_NODELIST,
+		JOB_REQ_KILL_REQUID,
+		JOB_REQ_QOS,
+		JOB_REQ_COUNT		
+	};
+	enum {
+		STEP_REQ_STEPID,
+		STEP_REQ_START,
+		STEP_REQ_ENDTIME,
+		STEP_REQ_SUSPENDED,
+		STEP_REQ_NAME,
+		STEP_REQ_NODELIST,
+		STEP_REQ_STATE,
+		STEP_REQ_KILL_REQUID,
+		STEP_REQ_COMP_CODE,
+		STEP_REQ_CPUS,
+		STEP_REQ_USER_SEC,
+		STEP_REQ_USER_USEC,
+		STEP_REQ_SYS_SEC,
+		STEP_REQ_SYS_USEC,
+		STEP_REQ_MAX_VSIZE,
+		STEP_REQ_MAX_VSIZE_TASK,
+		STEP_REQ_MAX_VSIZE_NODE,
+		STEP_REQ_AVE_VSIZE,
+		STEP_REQ_MAX_RSS,
+		STEP_REQ_MAX_RSS_TASK,
+		STEP_REQ_MAX_RSS_NODE,
+		STEP_REQ_AVE_RSS,
+		STEP_REQ_MAX_PAGES,
+		STEP_REQ_MAX_PAGES_TASK,
+		STEP_REQ_MAX_PAGES_NODE,
+		STEP_REQ_AVE_PAGES,
+		STEP_REQ_MIN_CPU,
+		STEP_REQ_MIN_CPU_TASK,
+		STEP_REQ_MIN_CPU_NODE,
+		STEP_REQ_AVE_CPU,
+		STEP_REQ_COUNT
+	};
+
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		xstrcat(extra, " and (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " or ");
+			tmp = xstrdup_printf("t1.jobid=%u",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		xstrcat(extra, " and (");
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " or ");
+			tmp = xstrdup_printf("t1.partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+	
+	for(i=0; i<JOB_REQ_COUNT; i++) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, job_req_inx[i]);
+	}
+	
+	query = xstrdup_printf("select %s from %s t1",
+			       tmp, job_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result = pgsql_db_query_ret(acct_pgsql_db, query))) {
+		xfree(query);
+		list_destroy(job_list);
+		return NULL;
+	}
+	xfree(query);
+
+	for (i = 0; i < PQntuples(result); i++) {
+		char *id = PQgetvalue(result, i, JOB_REQ_ID);
+		acct_association_rec_t account_rec;
+		memset(&account_rec, 0, sizeof(acct_association_rec_t));
+		job = create_jobacct_job_rec();
+
+		job->alloc_cpus = atoi(PQgetvalue(result, i, 
+						  JOB_REQ_ALLOC_CPUS));
+		job->associd = atoi(PQgetvalue(result, i, JOB_REQ_ASSOCID));
+		account_rec.id = job->associd;
+		assoc_mgr_fill_in_assoc(acct_pgsql_db, &account_rec, 0, NULL);
+		if(account_rec.cluster) {
+			if(params->opt_cluster &&
+			   strcmp(params->opt_cluster, account_rec.cluster)) {
+				destroy_jobacct_job_rec(job);
+				job = NULL;
+				continue;
+			}
+			job->cluster = xstrdup(account_rec.cluster);
+		}
+		if(account_rec.user) 
+			job->user = xstrdup(account_rec.user);
+		else 
+			job->uid = atoi(PQgetvalue(result, i, JOB_REQ_UID));
+		if(account_rec.acct) 
+			job->account = xstrdup(account_rec.acct);
+		else
+			job->account = xstrdup(PQgetvalue(result, i,
+							  JOB_REQ_ACCOUNT));
+		job->blockid = xstrdup(PQgetvalue(result, i,
+						    JOB_REQ_BLOCKID));
+		job->eligible = atoi(PQgetvalue(result, i, JOB_REQ_SUBMIT));
+		job->submit = atoi(PQgetvalue(result, i, JOB_REQ_SUBMIT));
+		job->start = atoi(PQgetvalue(result, i, JOB_REQ_START));
+		job->end = atoi(PQgetvalue(result, i, JOB_REQ_ENDTIME));
+		job->suspended = atoi(PQgetvalue(result, i, JOB_REQ_SUSPENDED));
+		if(!job->end) {
+			job->elapsed = now - job->start;
+		} else {
+			job->elapsed = job->end - job->start;
+		}
+		job->elapsed -= job->suspended;
+
+		job->jobid = atoi(PQgetvalue(result, i, JOB_REQ_JOBID));
+		job->jobname = xstrdup(PQgetvalue(result, i, JOB_REQ_NAME));
+		job->gid = atoi(PQgetvalue(result, i, JOB_REQ_GID));
+		job->exitcode = atoi(PQgetvalue(result, i, JOB_REQ_COMP_CODE));
+		job->partition = xstrdup(PQgetvalue(result, i,
+						      JOB_REQ_PARTITION));
+		job->nodes = xstrdup(PQgetvalue(result, i, JOB_REQ_NODELIST));
+		if (!strcmp(job->nodes, "(null)")) {
+			xfree(job->nodes);
+			job->nodes = xstrdup("(unknown)");
+		}
+
+		job->track_steps = atoi(PQgetvalue(result, i,
+						   JOB_REQ_TRACKSTEPS));
+		job->state = atoi(PQgetvalue(result, i, JOB_REQ_STATE));
+		job->priority = atoi(PQgetvalue(result, i, JOB_REQ_PRIORITY));
+		job->req_cpus = atoi(PQgetvalue(result, i, JOB_REQ_REQ_CPUS));
+		job->requid = atoi(PQgetvalue(result, i, JOB_REQ_KILL_REQUID));
+		job->qos = atoi(PQgetvalue(result, i, JOB_REQ_QOS));
+		job->show_full = 1;
+
+		list_append(job_list, job);
+
+		if(selected_steps && list_count(selected_steps)) {
+			set = 0;
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if(selected_step->jobid != job->jobid) {
+					continue;
+				} else if (selected_step->stepid
+					   == (uint32_t)NO_VAL) {
+					job->show_full = 1;
+					break;
+				}
+				
+				if(set) 
+					xstrcat(extra, " or ");
+				else 
+					xstrcat(extra, " and (");
+			
+				tmp = xstrdup_printf("t1.stepid=%u",
+						     selected_step->stepid);
+				xstrcat(extra, tmp);
+				set = 1;
+				xfree(tmp);
+				job->show_full = 0;
+			}
+			list_iterator_destroy(itr);
+			if(set)
+				xstrcat(extra, ")");
+		}
+		for(j=0; j<STEP_REQ_COUNT; j++) {
+			if(j) 
+				xstrcat(tmp, ", ");
+			xstrcat(tmp, step_req_inx[j]);
+		}
+		
+		query =	xstrdup_printf("select %s from %s t1 where t1.id=%s",
+				       tmp, step_table, id);
+		xfree(tmp);
+		
+		if(extra) {
+			xstrcat(query, extra);
+			xfree(extra);
+		}
+		
+		//info("query = %s", query);
+		if(!(step_result = pgsql_db_query_ret(acct_pgsql_db, query))) {
+			xfree(query);
+			list_destroy(job_list);
+			return NULL;
+		}
+		xfree(query);
+		for(j = 0; j < PQntuples(step_result); j++) {
+			step = create_jobacct_step_rec();
+			step->jobid = job->jobid;
+			list_append(job->steps, step);
+			step->stepid = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_STEPID));
+			/* info("got step %u.%u", */
+/* 			     job->header.jobnum, step->stepnum); */
+			step->state = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_STATE));
+			step->exitcode = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_COMP_CODE));
+			step->ncpus = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_CPUS));
+			step->start = atoi(
+				PQgetvalue(step_result, j, JOB_REQ_START));
+			step->end = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_ENDTIME));
+			/* figure this out by start stop */
+			step->suspended = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_SUSPENDED));
+			if(!step->end) {
+				step->elapsed = now - step->start;
+			} else {
+				step->elapsed = step->end - step->start;
+			}
+			step->elapsed -= step->suspended;
+			step->user_cpu_sec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_USER_SEC));
+			step->user_cpu_usec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_USER_USEC));
+			step->sys_cpu_sec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_SYS_SEC));
+			step->sys_cpu_usec = atoi(
+				PQgetvalue(step_result, j, STEP_REQ_SYS_USEC));
+			job->tot_cpu_sec += 
+				step->tot_cpu_sec += 
+				step->user_cpu_sec + step->sys_cpu_sec;
+			job->tot_cpu_usec += 
+				step->tot_cpu_usec += 
+				step->user_cpu_usec + step->sys_cpu_usec;
+			step->sacct.max_vsize = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_VSIZE)) * 1024;
+			step->sacct.max_vsize_id.taskid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_VSIZE_TASK));
+			step->sacct.ave_vsize = atof(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_AVE_VSIZE)) * 1024;
+			step->sacct.max_rss = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS)) * 1024;
+			step->sacct.max_rss_id.taskid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS_TASK));
+			step->sacct.max_rss = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS)) * 1024;
+			step->sacct.max_rss_id.taskid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS_TASK));
+			step->sacct.ave_rss = atof(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_AVE_RSS)) * 1024;
+			step->sacct.max_pages = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_PAGES));
+			step->sacct.max_pages_id.taskid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_PAGES_TASK));
+			step->sacct.ave_pages = atof(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_AVE_PAGES));
+			step->sacct.min_cpu = atof(
+				PQgetvalue(step_result, j, STEP_REQ_MIN_CPU));
+			step->sacct.min_cpu_id.taskid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MIN_CPU_TASK));
+			step->sacct.ave_cpu = atof(
+				PQgetvalue(step_result, j, STEP_REQ_AVE_CPU));
+			step->stepname = xstrdup(
+				PQgetvalue(step_result, j, STEP_REQ_NAME));
+			step->nodes = xstrdup(
+				PQgetvalue(step_result, j, STEP_REQ_NODELIST));
+			step->sacct.max_vsize_id.nodeid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_VSIZE_NODE));
+			step->sacct.max_rss_id.nodeid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_RSS_NODE));
+			step->sacct.max_pages_id.nodeid = atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MAX_PAGES_NODE));
+			step->sacct.min_cpu_id.nodeid =	atoi(
+				PQgetvalue(step_result, j,
+					   STEP_REQ_MIN_CPU_NODE));
+	
+			step->requid = atoi(PQgetvalue(step_result, j,
+						       STEP_REQ_KILL_REQUID));
+		}
+		PQclear(step_result);
+
+		if(list_count(job->steps) > 1)
+			job->track_steps = 1;
+	}
+	PQclear(result);
+	
+	if (params && params->opt_fdump) 
+		_do_fdump(job_list);
+	
+	return job_list;
+}
+
+extern void pgsql_jobacct_process_archive(PGconn *acct_pgsql_db,
+					  List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/accounting_storage/pgsql/pgsql_jobacct_process.h b/src/plugins/accounting_storage/pgsql/pgsql_jobacct_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..255f1a9d78a35770f0e8d18634212f3a4a389e98
--- /dev/null
+++ b/src/plugins/accounting_storage/pgsql/pgsql_jobacct_process.h
@@ -0,0 +1,71 @@
+/*****************************************************************************\
+ *  pgsql_jobacct_process.h - functions the processing of
+ *                               information from the pgsql jobacct
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_PGSQL_JOBACCT_PROCESS_H
+#define _HAVE_PGSQL_JOBACCT_PROCESS_H
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include "src/common/assoc_mgr.h"
+#include "src/common/jobacct_common.h"
+#include "src/slurmdbd/read_config.h"
+#include "src/slurmctld/slurmctld.h"
+#include "src/database/pgsql_common.h"
+#include "src/common/slurm_accounting_storage.h"
+
+#ifdef HAVE_PGSQL
+
+extern char *job_table;
+extern char *step_table;
+
+extern List pgsql_jobacct_process_get_jobs(PGconn *acct_pgsql_db,
+					   List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void pgsql_jobacct_process_archive(PGconn *acct_pgsql_db,
+					  List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/accounting_storage/slurmdbd/Makefile.am b/src/plugins/accounting_storage/slurmdbd/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..ab90155fed30a942090b1b298e9c2ea31573f626
--- /dev/null
+++ b/src/plugins/accounting_storage/slurmdbd/Makefile.am
@@ -0,0 +1,16 @@
+# Makefile for accounting_storage/slurmdbd plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = accounting_storage_slurmdbd.la
+
+# Null job completion logging plugin.
+accounting_storage_slurmdbd_la_SOURCES = accounting_storage_slurmdbd.c
+accounting_storage_slurmdbd_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+
+
+
diff --git a/src/plugins/accounting_storage/slurmdbd/Makefile.in b/src/plugins/accounting_storage/slurmdbd/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..66483726fc5fa9fcdceeae86a822a3c285db0891
--- /dev/null
+++ b/src/plugins/accounting_storage/slurmdbd/Makefile.in
@@ -0,0 +1,558 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for accounting_storage/slurmdbd plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/accounting_storage/slurmdbd
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+accounting_storage_slurmdbd_la_LIBADD =
+am_accounting_storage_slurmdbd_la_OBJECTS =  \
+	accounting_storage_slurmdbd.lo
+accounting_storage_slurmdbd_la_OBJECTS =  \
+	$(am_accounting_storage_slurmdbd_la_OBJECTS)
+accounting_storage_slurmdbd_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(AM_CFLAGS) $(CFLAGS) \
+	$(accounting_storage_slurmdbd_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(accounting_storage_slurmdbd_la_SOURCES)
+DIST_SOURCES = $(accounting_storage_slurmdbd_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = accounting_storage_slurmdbd.la
+
+# Null job completion logging plugin.
+accounting_storage_slurmdbd_la_SOURCES = accounting_storage_slurmdbd.c
+accounting_storage_slurmdbd_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/accounting_storage/slurmdbd/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/accounting_storage/slurmdbd/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+accounting_storage_slurmdbd.la: $(accounting_storage_slurmdbd_la_OBJECTS) $(accounting_storage_slurmdbd_la_DEPENDENCIES) 
+	$(accounting_storage_slurmdbd_la_LINK) -rpath $(pkglibdir) $(accounting_storage_slurmdbd_la_OBJECTS) $(accounting_storage_slurmdbd_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accounting_storage_slurmdbd.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
new file mode 100644
index 0000000000000000000000000000000000000000..3dd41ad223dd35fdee5027640a23c45642f576b5
--- /dev/null
+++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
@@ -0,0 +1,1233 @@
+/*****************************************************************************\
+ *  accounting_storage_slurmdbd.c - accounting interface to slurmdbd.
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+#include <slurm/slurm_errno.h>
+
+#include "src/common/jobacct_common.h"
+#include "src/common/read_config.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurmdbd_defs.h"
+#include "src/common/xstring.h"
+#include "src/slurmctld/slurmctld.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Accounting storage SLURMDBD plugin";
+const char plugin_type[] = "accounting_storage/slurmdbd";
+const uint32_t plugin_version = 100;
+
+static char *slurmdbd_auth_info = NULL;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	static int first = 1;
+	char *cluster_name = NULL;
+
+	if (first) {
+		/* since this can be loaded from many different places
+		   only tell us once. */
+		if (!(cluster_name = slurm_get_cluster_name()))
+			fatal("%s requires ClusterName in slurm.conf",
+			      plugin_name);
+		xfree(cluster_name);
+		slurmdbd_auth_info = slurm_get_accounting_storage_pass();
+		if(!slurmdbd_auth_info)			
+			verbose("%s loaded AuthInfo=%s",
+				plugin_name, slurmdbd_auth_info);
+		first = 0;
+	} else {
+		debug4("%s loaded", plugin_name);
+	}
+
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	xfree(slurmdbd_auth_info);
+
+	return SLURM_SUCCESS;
+}
+
+extern void *acct_storage_p_get_connection(bool make_agent, bool rollback)
+{
+	if(!slurmdbd_auth_info)	
+		init();
+	slurm_open_slurmdbd_conn(slurmdbd_auth_info, make_agent, rollback);
+
+	return NULL;
+}
+
+extern int acct_storage_p_close_connection(void **db_conn)
+{
+	return slurm_close_slurmdbd_conn();
+}
+
+extern int acct_storage_p_commit(void *db_conn, bool commit)
+{
+	slurmdbd_msg_t req;
+	dbd_fini_msg_t get_msg;
+	int rc, resp_code;
+
+	memset(&get_msg, 0, sizeof(dbd_fini_msg_t));
+
+	get_msg.close_conn = 0;
+	get_msg.commit = (uint16_t)commit;
+
+	req.msg_type = DBD_FINI;
+	req.data = &get_msg;
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS)
+		rc = resp_code;
+
+	return rc;
+}
+
+extern int acct_storage_p_add_users(void *db_conn, uint32_t uid, List user_list)
+{
+	slurmdbd_msg_t req;
+	dbd_list_msg_t get_msg;
+	int rc, resp_code;
+
+	get_msg.my_list = user_list;
+
+	req.msg_type = DBD_ADD_USERS;
+	req.data = &get_msg;
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS)
+		rc = resp_code;
+
+	return rc;
+}
+
+extern int acct_storage_p_add_coord(void *db_conn, uint32_t uid,
+				    char *acct, acct_user_cond_t *user_q)
+{
+	slurmdbd_msg_t req;
+	dbd_acct_coord_msg_t get_msg;
+	int rc, resp_code;
+
+	get_msg.acct = acct;
+	get_msg.cond = user_q;
+
+	req.msg_type = DBD_ADD_ACCOUNT_COORDS;
+	req.data = &get_msg;
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS)
+		rc = resp_code;
+
+	return rc;
+}
+
+extern int acct_storage_p_add_accts(void *db_conn, uint32_t uid, List acct_list)
+{
+	slurmdbd_msg_t req;
+	dbd_list_msg_t get_msg;
+	int rc, resp_code;
+
+	get_msg.my_list = acct_list;
+
+	req.msg_type = DBD_ADD_ACCOUNTS;
+	req.data = &get_msg;
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS)
+		rc = resp_code;
+
+	return rc;
+}
+
+extern int acct_storage_p_add_clusters(void *db_conn, uint32_t uid, List cluster_list)
+{
+	slurmdbd_msg_t req;
+	dbd_list_msg_t get_msg;
+	int rc, resp_code;
+
+	get_msg.my_list = cluster_list;
+
+	req.msg_type = DBD_ADD_CLUSTERS;
+	req.data = &get_msg;
+
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS) {
+		rc = resp_code;
+	}
+	return rc;
+}
+
+extern int acct_storage_p_add_associations(void *db_conn, uint32_t uid,
+					   List association_list)
+{
+	slurmdbd_msg_t req;
+	dbd_list_msg_t get_msg;
+	int rc, resp_code;
+
+	get_msg.my_list = association_list;
+
+	req.msg_type = DBD_ADD_ASSOCS;
+	req.data = &get_msg;
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS)
+		rc = resp_code;
+
+	return rc;
+}
+
+extern List acct_storage_p_modify_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q,
+				       acct_user_rec_t *user)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_modify_msg_t get_msg;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+	int rc;
+
+	get_msg.cond = user_q;
+	get_msg.rec = user;
+
+	req.msg_type = DBD_MODIFY_USERS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_MODIFY_USERS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_modify_accts(void *db_conn, uint32_t uid,
+				       acct_account_cond_t *acct_q,
+				       acct_account_rec_t *acct)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_modify_msg_t get_msg;
+	dbd_list_msg_t *got_msg;
+	int rc;
+	List ret_list = NULL;
+
+	get_msg.cond = acct_q;
+	get_msg.rec = acct;
+
+	req.msg_type = DBD_MODIFY_ACCOUNTS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_MODIFY_ACCOUNTS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_modify_clusters(void *db_conn, uint32_t uid,
+					  acct_cluster_cond_t *cluster_q,
+					  acct_cluster_rec_t *cluster)
+{
+	slurmdbd_msg_t req;
+	dbd_modify_msg_t get_msg;
+	int rc;
+	slurmdbd_msg_t resp;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+
+	get_msg.cond = cluster_q;
+	get_msg.rec = cluster;
+
+	req.msg_type = DBD_MODIFY_CLUSTERS;
+	req.data = &get_msg;
+
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_MODIFY_CLUSTERS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_modify_associations(void *db_conn, uint32_t uid,
+					       acct_association_cond_t *assoc_q,
+					       acct_association_rec_t *assoc)
+{
+	slurmdbd_msg_t req;
+	dbd_modify_msg_t get_msg;
+	int rc;
+	slurmdbd_msg_t resp;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+
+
+	get_msg.cond = assoc_q;
+	get_msg.rec = assoc;
+
+	req.msg_type = DBD_MODIFY_ASSOCS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_MODIFY_ASSOCS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_remove_users(void *db_conn, uint32_t uid,
+				       acct_user_cond_t *user_q)
+{
+	slurmdbd_msg_t req;
+	dbd_cond_msg_t get_msg;
+	int rc;
+	slurmdbd_msg_t resp;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+
+
+	get_msg.cond = user_q;
+
+	req.msg_type = DBD_REMOVE_USERS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_REMOVE_USERS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_remove_coord(void *db_conn, uint32_t uid,
+				       char *acct, acct_user_cond_t *user_q)
+{
+	slurmdbd_msg_t req;
+	dbd_acct_coord_msg_t get_msg;
+	int rc;
+	slurmdbd_msg_t resp;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+
+
+	get_msg.acct = acct;
+	get_msg.cond = user_q;
+
+	req.msg_type = DBD_REMOVE_ACCOUNT_COORDS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_REMOVE_ACCOUNT_COORDS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_remove_accts(void *db_conn, uint32_t uid,
+				       acct_account_cond_t *acct_q)
+{
+	slurmdbd_msg_t req;
+	dbd_cond_msg_t get_msg;
+	int rc;
+	slurmdbd_msg_t resp;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+
+
+	get_msg.cond = acct_q;
+
+	req.msg_type = DBD_REMOVE_ACCOUNTS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_REMOVE_ACCTS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_remove_clusters(void *db_conn, uint32_t uid,
+					  acct_account_cond_t *cluster_q)
+{
+	slurmdbd_msg_t req;
+	dbd_cond_msg_t get_msg;
+	int rc;
+	slurmdbd_msg_t resp;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+
+
+	get_msg.cond = cluster_q;
+
+	req.msg_type = DBD_REMOVE_CLUSTERS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_REMOVE_CLUSTERS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_remove_associations(void *db_conn, uint32_t uid,
+					      acct_association_cond_t *assoc_q)
+{
+	slurmdbd_msg_t req;
+	dbd_cond_msg_t get_msg;
+	int rc;
+	slurmdbd_msg_t resp;
+	dbd_list_msg_t *got_msg;
+	List ret_list = NULL;
+
+
+	get_msg.cond = assoc_q;
+
+	req.msg_type = DBD_REMOVE_ASSOCS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_REMOVE_ASSOCS failure: %m");
+	else if (resp.msg_type != DBD_GOT_LIST) {
+		error("slurmdbd: response type not DBD_GOT_LIST: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_get_users(void *db_conn,
+				     acct_user_cond_t *user_q)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_cond_msg_t get_msg;
+	dbd_list_msg_t *got_msg;
+	int rc;
+	List ret_list = NULL;
+
+	get_msg.cond = user_q;
+	
+	req.msg_type = DBD_GET_USERS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_GET_USERS failure: %m");
+	else if (resp.msg_type != DBD_GOT_USERS) {
+		error("slurmdbd: response type not DBD_GOT_USERS: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return ret_list;
+}
+
+extern List acct_storage_p_get_accts(void *db_conn,
+				     acct_account_cond_t *acct_q)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_cond_msg_t get_msg;
+	dbd_list_msg_t *got_msg;
+	int rc;
+	List ret_list = NULL;
+
+	get_msg.cond = acct_q;
+	
+	req.msg_type = DBD_GET_ACCOUNTS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_GET_ACCOUNTS failure: %m");
+	else if (resp.msg_type != DBD_GOT_ACCOUNTS) {
+		error("slurmdbd: response type not DBD_GOT_ACCOUNTS: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+
+	return ret_list;
+}
+
+extern List acct_storage_p_get_clusters(void *db_conn,
+					acct_account_cond_t *cluster_q)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_cond_msg_t get_msg;
+	dbd_list_msg_t *got_msg;
+	int rc;
+	List ret_list = NULL;
+
+	get_msg.cond = cluster_q;
+	
+	req.msg_type = DBD_GET_CLUSTERS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_GET_CLUSTERS failure: %m");
+	else if (resp.msg_type != DBD_GOT_CLUSTERS) {
+		error("slurmdbd: response type not DBD_GOT_CLUSTERS: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+
+	return ret_list;
+}
+
+extern List acct_storage_p_get_associations(void *db_conn,
+					    acct_association_cond_t *assoc_q)
+{
+	
+	slurmdbd_msg_t req, resp;
+	dbd_cond_msg_t get_msg;
+	dbd_list_msg_t *got_msg;
+	int rc;
+	List ret_list = NULL;
+
+	get_msg.cond = assoc_q;
+	
+	req.msg_type = DBD_GET_ASSOCS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_GET_ASSOCS failure: %m");
+	else if (resp.msg_type != DBD_GOT_ASSOCS) {
+		error("slurmdbd: response type not DBD_GOT_ASSOCS: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		ret_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+
+	return ret_list;
+}
+
+extern int acct_storage_p_get_usage(void *db_conn,
+				    acct_association_rec_t *acct_assoc,
+				    time_t start, time_t end)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_usage_msg_t get_msg;
+	dbd_usage_msg_t *got_msg;
+	acct_association_rec_t *got_rec;
+	int rc;
+
+	get_msg.rec = acct_assoc;
+	get_msg.start = start;
+	get_msg.end = end;
+	req.msg_type = DBD_GET_ASSOC_USAGE;
+	
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_GET_ASSOC_USAGE failure: %m");
+	else if (resp.msg_type != DBD_GOT_ASSOC_USAGE) {
+		error("slurmdbd: response type not DBD_GOT_ASSOC_USAGE: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_usage_msg_t *) resp.data;
+		got_rec = (acct_association_rec_t *)got_msg->rec;
+		acct_assoc->accounting_list = got_rec->accounting_list;
+		got_rec->accounting_list = NULL;
+		slurmdbd_free_usage_msg(resp.msg_type, got_msg);
+	}
+
+
+	return rc;
+}
+
+extern int acct_storage_p_roll_usage(void *db_conn, 
+				     time_t sent_start)
+{
+	slurmdbd_msg_t req;
+	dbd_roll_usage_msg_t get_msg;
+	int rc, resp_code;
+	
+	get_msg.start = sent_start;
+
+	req.msg_type = DBD_ROLL_USAGE;
+
+	req.data = &get_msg;
+
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS)
+		rc = resp_code;
+	
+	return rc;
+}
+
+extern int clusteracct_storage_p_node_down(void *db_conn,
+					   char *cluster,
+					   struct node_record *node_ptr,
+					   time_t event_time, char *reason)
+{
+	slurmdbd_msg_t msg;
+	dbd_node_state_msg_t req;
+	uint16_t cpus;
+	char *my_reason;
+
+	if (slurmctld_conf.fast_schedule)
+		cpus = node_ptr->config_ptr->cpus;
+	else
+		cpus = node_ptr->cpus;
+
+	if (reason)
+		my_reason = reason;
+	else
+		my_reason = node_ptr->reason;
+
+	req.cluster_name = cluster;
+	req.cpu_count = cpus;
+	req.hostlist   = node_ptr->name;
+	req.new_state  = DBD_NODE_STATE_DOWN;
+	req.event_time = event_time;
+	req.reason     = my_reason;
+	msg.msg_type   = DBD_NODE_STATE;
+	msg.data       = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+extern int clusteracct_storage_p_node_up(void *db_conn,
+					 char *cluster,
+					 struct node_record *node_ptr,
+					 time_t event_time)
+{
+	slurmdbd_msg_t msg;
+	dbd_node_state_msg_t req;
+
+	req.cluster_name = cluster;
+	req.hostlist   = node_ptr->name;
+	req.new_state  = DBD_NODE_STATE_UP;
+	req.event_time = event_time;
+	req.reason     = NULL;
+	msg.msg_type   = DBD_NODE_STATE;
+	msg.data       = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_cluster_procs(void *db_conn,
+					       char *cluster,
+					       uint32_t procs,
+					       time_t event_time)
+{
+	slurmdbd_msg_t msg;
+	dbd_cluster_procs_msg_t req;
+	info("sending info for cluster %s", cluster);
+	req.cluster_name = cluster;
+	req.proc_count   = procs;
+	req.event_time   = event_time;
+	msg.msg_type     = DBD_CLUSTER_PROCS;
+	msg.data         = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_register_ctld(char *cluster,
+					       uint16_t port)
+{
+	slurmdbd_msg_t msg;
+	dbd_register_ctld_msg_t req;
+	info("registering slurmctld for cluster %s at port %u", cluster, port);
+	req.cluster_name = cluster;
+	req.port         = port;
+	msg.msg_type     = DBD_REGISTER_CTLD;
+	msg.data         = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+extern int clusteracct_storage_p_get_usage(
+	void *db_conn,
+	acct_cluster_rec_t *cluster_rec,
+	time_t start, time_t end)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_usage_msg_t get_msg;
+	dbd_usage_msg_t *got_msg;
+	acct_cluster_rec_t *got_rec;
+	int rc;
+
+	get_msg.rec = cluster_rec;
+	get_msg.start = start;
+	get_msg.end = end;
+
+	req.msg_type = DBD_GET_CLUSTER_USAGE;
+	
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_GET_CLUSTER_USAGE failure: %m");
+	else if (resp.msg_type != DBD_GOT_CLUSTER_USAGE) {
+		error("slurmdbd: response type not DBD_GOT_CLUSTER_USAGE: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_usage_msg_t *) resp.data;
+		got_rec = (acct_cluster_rec_t *)got_msg->rec;
+		cluster_rec->accounting_list = got_rec->accounting_list;
+		got_rec->accounting_list = NULL;
+		slurmdbd_free_usage_msg(resp.msg_type, got_msg);
+	}
+
+
+	return rc;
+}
+
+/* 
+ * load into the storage the start of a job
+ */
+extern int jobacct_storage_p_job_start(void *db_conn,
+				       struct job_record *job_ptr)
+{
+	slurmdbd_msg_t msg, msg_rc;
+	dbd_job_start_msg_t req;
+	dbd_job_start_rc_msg_t *resp;
+	char *block_id = NULL;
+	int rc = SLURM_SUCCESS;
+
+	if (!job_ptr->details || !job_ptr->details->submit_time) {
+		error("jobacct_storage_p_job_start: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	req.alloc_cpus    = job_ptr->total_procs;
+	req.account       = job_ptr->account;
+	req.assoc_id      = job_ptr->assoc_id;
+#ifdef HAVE_BG
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_BLOCK_ID, 
+			     &block_id);
+#endif
+	req.block_id      = block_id;
+	req.db_index      = job_ptr->db_index;
+	if (job_ptr->details) 
+		req.eligible_time = job_ptr->details->begin_time;
+	req.gid           = job_ptr->group_id;
+	req.job_id        = job_ptr->job_id;
+	req.job_state     = job_ptr->job_state & (~JOB_COMPLETING);
+	req.name          = job_ptr->name;
+	req.nodes         = job_ptr->nodes;
+	req.partition     = job_ptr->partition;
+	req.req_cpus      = job_ptr->num_procs;
+	req.priority      = job_ptr->priority;
+	req.start_time    = job_ptr->start_time;
+	if (job_ptr->details)
+		req.submit_time   = job_ptr->details->submit_time;
+	req.uid           = job_ptr->user_id;
+
+	msg.msg_type      = DBD_JOB_START;
+	msg.data          = &req;
+
+	/* if we already have the db_index don't wait around for it
+	 * again just send the message 
+	 */
+	if(req.db_index) {
+		if (slurm_send_slurmdbd_msg(&msg) < 0) {
+			xfree(block_id);
+			return SLURM_ERROR;
+		}
+		xfree(block_id);
+		return SLURM_SUCCESS;
+	} 
+
+	/* If we don't have the db_index we need to wait for it to be
+	 * used in the other submissions for this job.
+	 */
+	rc = slurm_send_recv_slurmdbd_msg(&msg, &msg_rc);
+	if (rc != SLURM_SUCCESS) {
+		if (slurm_send_slurmdbd_msg(&msg) < 0) {
+			xfree(block_id);
+			return SLURM_ERROR;
+		}
+	} else if (msg_rc.msg_type != DBD_JOB_START_RC) {
+		error("slurmdbd: response type not DBD_GOT_JOBS: %u", 
+		      msg_rc.msg_type);
+	} else {
+		resp = (dbd_job_start_rc_msg_t *) msg_rc.data;
+		job_ptr->db_index = resp->db_index;
+		slurmdbd_free_job_start_rc_msg(resp);
+	}
+	xfree(block_id);
+	
+	return rc;
+}
+
+/* 
+ * load into the storage the end of a job
+ */
+extern int jobacct_storage_p_job_complete(void *db_conn,
+					  struct job_record *job_ptr)
+{
+	slurmdbd_msg_t msg;
+	dbd_job_comp_msg_t req;
+
+	if (!job_ptr->db_index 
+	    && (!job_ptr->details || !job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_job_complete: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	req.assoc_id    = job_ptr->assoc_id;
+	req.db_index    = job_ptr->db_index;
+	req.end_time    = job_ptr->end_time;
+	req.exit_code   = job_ptr->exit_code;
+	req.job_id      = job_ptr->job_id;
+	req.job_state   = job_ptr->job_state & (~JOB_COMPLETING);
+	req.nodes       = job_ptr->nodes;
+	req.start_time  = job_ptr->start_time;
+	if (job_ptr->details)
+		req.submit_time   = job_ptr->details->submit_time;
+
+	msg.msg_type    = DBD_JOB_COMPLETE;
+	msg.data        = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the start of a job step
+ */
+extern int jobacct_storage_p_step_start(void *db_conn,
+					struct step_record *step_ptr)
+{
+	uint32_t cpus = 0;
+	char node_list[BUFFER_SIZE];
+	slurmdbd_msg_t msg;
+	dbd_step_start_msg_t req;
+
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if (ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else {
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	}
+	
+#else
+	if (!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->total_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+
+	if (!step_ptr->job_ptr->db_index 
+	    && (!step_ptr->job_ptr->details
+		|| !step_ptr->job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_step_start: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	req.assoc_id    = step_ptr->job_ptr->assoc_id;
+	req.db_index    = step_ptr->job_ptr->db_index;
+	req.job_id      = step_ptr->job_ptr->job_id;
+	req.name        = step_ptr->name;
+	req.nodes       = node_list;
+	req.start_time  = step_ptr->start_time;
+	if (step_ptr->job_ptr->details)
+		req.job_submit_time   = step_ptr->job_ptr->details->submit_time;
+	req.step_id     = step_ptr->step_id;
+	req.total_procs = cpus;
+
+	msg.msg_type    = DBD_STEP_START;
+	msg.data        = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage the end of a job step
+ */
+extern int jobacct_storage_p_step_complete(void *db_conn,
+					   struct step_record *step_ptr)
+{
+	uint32_t cpus = 0;
+	char node_list[BUFFER_SIZE];
+	slurmdbd_msg_t msg;
+	dbd_step_comp_msg_t req;
+
+#ifdef HAVE_BG
+	char *ionodes = NULL;
+
+	cpus = step_ptr->job_ptr->num_procs;
+	select_g_get_jobinfo(step_ptr->job_ptr->select_jobinfo, 
+			     SELECT_DATA_IONODES, 
+			     &ionodes);
+	if (ionodes) {
+		snprintf(node_list, BUFFER_SIZE, 
+			 "%s[%s]", step_ptr->job_ptr->nodes, ionodes);
+		xfree(ionodes);
+	} else {
+		snprintf(node_list, BUFFER_SIZE, "%s",
+			 step_ptr->job_ptr->nodes);
+	}
+	
+#else
+	if (!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
+		cpus = step_ptr->job_ptr->total_procs;
+		snprintf(node_list, BUFFER_SIZE, "%s", step_ptr->job_ptr->nodes);
+	} else {
+		cpus = step_ptr->step_layout->task_cnt;
+		snprintf(node_list, BUFFER_SIZE, "%s", 
+			 step_ptr->step_layout->node_list);
+	}
+#endif
+
+	if (!step_ptr->job_ptr->db_index 
+	    && (!step_ptr->job_ptr->details
+		|| !step_ptr->job_ptr->details->submit_time)) {
+		error("jobacct_storage_p_step_complete: "
+		      "Not inputing this job, it has no submit time.");
+		return SLURM_ERROR;
+	}
+
+	req.assoc_id    = step_ptr->job_ptr->assoc_id;
+	req.db_index    = step_ptr->job_ptr->db_index;
+	req.end_time    = time(NULL);	/* called at step completion */
+	req.jobacct     = step_ptr->jobacct;
+	req.job_id      = step_ptr->job_ptr->job_id;
+	req.req_uid     = step_ptr->job_ptr->requid;
+	req.start_time  = step_ptr->start_time;
+	if (step_ptr->job_ptr->details)
+		req.job_submit_time   = step_ptr->job_ptr->details->submit_time;
+	req.step_id     = step_ptr->step_id;
+	req.total_procs = cpus;
+
+	msg.msg_type    = DBD_STEP_COMPLETE;
+	msg.data        = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * load into the storage a suspention of a job
+ */
+extern int jobacct_storage_p_suspend(void *db_conn,
+				     struct job_record *job_ptr)
+{
+	slurmdbd_msg_t msg;
+	dbd_job_suspend_msg_t req;
+
+	req.assoc_id     = job_ptr->assoc_id;
+	req.job_id       = job_ptr->job_id;
+	req.db_index     = job_ptr->db_index;
+	req.job_state    = job_ptr->job_state & (~JOB_COMPLETING);
+	if (job_ptr->details)
+		req.submit_time   = job_ptr->details->submit_time;
+	req.suspend_time = job_ptr->suspend_time;
+	msg.msg_type     = DBD_JOB_SUSPEND;
+	msg.data         = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+/* 
+ * get info from the storage 
+ * returns List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List jobacct_storage_p_get_jobs(void *db_conn,
+				       List selected_steps,
+				       List selected_parts,
+				       sacct_parameters_t *params)
+{
+	slurmdbd_msg_t req, resp;
+	dbd_get_jobs_msg_t get_msg;
+	dbd_list_msg_t *got_msg;
+	int rc;
+	List job_list = NULL;
+	struct passwd *pw = NULL;
+
+	get_msg.selected_steps = selected_steps;
+	get_msg.selected_parts = selected_parts;
+	get_msg.cluster_name = params->opt_cluster;
+	get_msg.gid = params->opt_gid;
+	
+	if (params->opt_uid >=0 && (pw=getpwuid(params->opt_uid)))
+		get_msg.user = pw->pw_name;
+	else
+		get_msg.user = NULL;
+
+	req.msg_type = DBD_GET_JOBS;
+	req.data = &get_msg;
+	rc = slurm_send_recv_slurmdbd_msg(&req, &resp);
+
+	if (rc != SLURM_SUCCESS)
+		error("slurmdbd: DBD_GET_JOBS failure: %m");
+	else if (resp.msg_type != DBD_GOT_JOBS) {
+		error("slurmdbd: response type not DBD_GOT_JOBS: %u", 
+		      resp.msg_type);
+	} else {
+		got_msg = (dbd_list_msg_t *) resp.data;
+		job_list = got_msg->my_list;
+		got_msg->my_list = NULL;
+		slurmdbd_free_list_msg(got_msg);
+	}
+
+	return job_list;
+}
+
+/* 
+ * Expire old info from the storage
+ * Not applicable for any database
+ */
+extern void jobacct_storage_p_archive(void *db_conn,
+				      List selected_parts,
+				      void *params)
+{
+	return;
+}
+
+extern int acct_storage_p_update_shares_used(void *db_conn,
+					     List shares_used)
+{
+	slurmdbd_msg_t req;
+	dbd_list_msg_t shares_used_msg;
+	int rc, resp_code;
+
+	shares_used_msg.my_list = shares_used;
+
+	req.msg_type = DBD_UPDATE_SHARES_USED;
+	req.data = &shares_used_msg;
+	rc = slurm_send_slurmdbd_recv_rc_msg(&req, &resp_code);
+
+	if(resp_code != SLURM_SUCCESS)
+		rc = resp_code;
+
+	return rc;
+}
+
+extern int acct_storage_p_flush_jobs_on_cluster(void *db_conn, char *cluster,
+						time_t event_time)
+{
+	slurmdbd_msg_t msg;
+	dbd_cluster_procs_msg_t req;
+
+	info("Ending any jobs in accounting that were running when controller "
+	     "went down on cluster %s", cluster);
+	req.cluster_name = cluster;
+	req.proc_count   = 0;
+	req.event_time   = event_time;
+	msg.msg_type     = DBD_FLUSH_JOBS;
+	msg.data         = &req;
+
+	if (slurm_send_slurmdbd_msg(&msg) < 0)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/auth/Makefile.in b/src/plugins/auth/Makefile.in
index 97f40a1cc1b17c4b378efba112d6de929780b3dc..c4610851ebc73148d9fd90c612b9b4aefbd37d0f 100644
--- a/src/plugins/auth/Makefile.in
+++ b/src/plugins/auth/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/auth/authd/Makefile.in b/src/plugins/auth/authd/Makefile.in
index 388e2677cac7ca40f4bd157e915179ff0b71124f..8c37e3d26f43ae3a68b21f491a2b2e55fe290b76 100644
--- a/src/plugins/auth/authd/Makefile.in
+++ b/src/plugins/auth/authd/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -80,7 +82,7 @@ auth_authd_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(auth_authd_la_LDFLAGS) $(LDFLAGS) -o $@
 @WITH_AUTHD_TRUE@am_auth_authd_la_rpath = -rpath $(pkglibdir)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -120,6 +122,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +136,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +162,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +176,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +193,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +209,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -304,8 +317,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -313,8 +326,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -368,8 +381,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -381,8 +394,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -392,13 +405,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/auth/authd/auth_authd.c b/src/plugins/auth/authd/auth_authd.c
index afef1f77629e597f61c737cdc37c1eecc156fb5e..06ef977592111e53db082f9f50abbeaa91ce97c4 100644
--- a/src/plugins/auth/authd/auth_authd.c
+++ b/src/plugins/auth/authd/auth_authd.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -119,7 +119,7 @@ extern int fini ( void )
 }
 
 slurm_auth_credential_t *
-slurm_auth_create( void *argv[] )
+slurm_auth_create( void *argv[], char *auth_info )
 {
 	int ttl;	
 	int rc;
@@ -178,7 +178,7 @@ slurm_auth_destroy( slurm_auth_credential_t *cred )
 }
 
 int
-slurm_auth_verify( slurm_auth_credential_t *cred, void *argv[] )
+slurm_auth_verify( slurm_auth_credential_t *cred, void *argv[], char *auth_info )
 {
 	int rc;
 	time_t now;
@@ -206,7 +206,7 @@ slurm_auth_verify( slurm_auth_credential_t *cred, void *argv[] )
 
 
 uid_t
-slurm_auth_get_uid( slurm_auth_credential_t *cred )
+slurm_auth_get_uid( slurm_auth_credential_t *cred, char *auth_info )
 {
 	if ( cred == NULL ) {
 		plugin_errno = SLURM_AUTH_BADARG;
@@ -217,7 +217,7 @@ slurm_auth_get_uid( slurm_auth_credential_t *cred )
 
 
 gid_t
-slurm_auth_get_gid( slurm_auth_credential_t *cred )
+slurm_auth_get_gid( slurm_auth_credential_t *cred, char *auth_info )
 {
 	if ( cred == NULL ) {
 		plugin_errno = SLURM_AUTH_BADARG;
@@ -258,7 +258,7 @@ slurm_auth_pack( slurm_auth_credential_t *cred, Buf buf )
 slurm_auth_credential_t *
 slurm_auth_unpack( Buf buf )
 {
-	slurm_auth_credential_t *cred;
+	slurm_auth_credential_t *cred = NULL;
 	uint16_t sig_size; /* ignored */
 	uint32_t version, tmpint;	
 	char *data;
@@ -270,19 +270,13 @@ slurm_auth_unpack( Buf buf )
 
 	
 	/* Check the plugin type. */
-	if ( unpackmem_ptr( &data, &sig_size, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		return NULL;
-	}
+	safe_unpackmem_ptr( &data, &sig_size, buf );
 	if ( strcmp( data, plugin_type ) != 0 ) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
 	}
 
-	if ( unpack32( &version, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		return NULL;
-	}
+	safe_unpack32( &version, buf );
 	if( version != plugin_version ) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
@@ -293,33 +287,19 @@ slurm_auth_unpack( Buf buf )
 		xmalloc( sizeof( slurm_auth_credential_t ) );
 	cred->cr_errno = SLURM_SUCCESS;
 
-	if ( unpack32( &tmpint, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		goto unpack_error;
-	}
+	safe_unpack32( &tmpint, buf );
 	cred->cred.uid = tmpint;
-	if ( unpack32( &tmpint, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		goto unpack_error;
-	}
+	safe_unpack32( &tmpint, buf );
 	cred->cred.gid = tmpint;
-	if ( unpack_time( &cred->cred.valid_from, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		goto unpack_error;
-	}
-	if ( unpack_time( &cred->cred.valid_to, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		goto unpack_error;
-	}
-	if ( unpackmem_ptr( &data, &sig_size, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		goto unpack_error;
-	}
+	safe_unpack_time( &cred->cred.valid_from, buf );
+	safe_unpack_time( &cred->cred.valid_to, buf );
+	safe_unpackmem_ptr( &data, &sig_size, buf );
 	memcpy( cred->sig.data, data, sizeof( signature ) );
 
 	return cred;
 
  unpack_error:
+	plugin_errno = SLURM_AUTH_UNPACK;
 	xfree( cred );
 	return NULL;
 }
diff --git a/src/plugins/auth/munge/Makefile.in b/src/plugins/auth/munge/Makefile.in
index a891850efb1c180d5d9808ee764129692ea79a4c..850d9f69e406e9b30e6cb54a799f1db92d39cc89 100644
--- a/src/plugins/auth/munge/Makefile.in
+++ b/src/plugins/auth/munge/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -81,7 +83,7 @@ auth_munge_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(auth_munge_la_LDFLAGS) $(LDFLAGS) -o $@
 @WITH_MUNGE_TRUE@am_auth_munge_la_rpath = -rpath $(pkglibdir)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -121,6 +123,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -134,10 +137,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -157,7 +163,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -168,6 +177,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -183,6 +194,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -198,6 +210,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -305,8 +318,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -314,8 +327,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -369,8 +382,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -382,8 +395,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -393,13 +406,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/auth/munge/auth_munge.c b/src/plugins/auth/munge/auth_munge.c
index 7d9e41e40c8500d05bd684f2daf8503b697e20d4..1a5a7f51754b5f9891b77923b3b555fcb393d869 100644
--- a/src/plugins/auth/munge/auth_munge.c
+++ b/src/plugins/auth/munge/auth_munge.c
@@ -1,11 +1,12 @@
 /*****************************************************************************\
  *  auth_munge.c - SLURM auth implementation via Chris Dunlap's Munge
- *  $Id: auth_munge.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: auth_munge.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov> 
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -122,7 +123,7 @@ static munge_info_t * cred_info_create(munge_ctx_t ctx);
 static void           cred_info_destroy(munge_info_t *);
 static void           _print_cred_info(munge_info_t *mi);
 static void           _print_cred(munge_ctx_t ctx);
-static int            _decode_cred(slurm_auth_credential_t *c);
+static int            _decode_cred(slurm_auth_credential_t *c, char *socket);
 
 
 /*
@@ -146,7 +147,7 @@ int init ( void )
  * data at this time is implementation-dependent.
  */
 slurm_auth_credential_t *
-slurm_auth_create( void *argv[] )
+slurm_auth_create( void *argv[], char *socket )
 {
 	int retry = 2;
 	slurm_auth_credential_t *cred = NULL;
@@ -159,6 +160,24 @@ slurm_auth_create( void *argv[] )
 		return NULL;
 	}
 
+#if 0
+	/* This logic can be used to determine what socket is used by default.
+	 * A typical name is "/var/run/munge/munge.socket.2" */
+{
+	char *old_socket;
+	if (munge_ctx_get(ctx, MUNGE_OPT_SOCKET, &old_socket) != EMUNGE_SUCCESS)
+		error("munge_ctx_get failure");
+	else
+		info("Default Munge socket is %s", old_socket);
+}
+#endif
+	if (socket &&
+	    (munge_ctx_set(ctx, MUNGE_OPT_SOCKET, socket) != EMUNGE_SUCCESS)) {
+		error("munge_ctx_set failure");
+		munge_ctx_destroy(ctx);
+		return NULL;
+	}
+
 	cred = xmalloc(sizeof(*cred));
 	cred->verified = false;
 	cred->m_str    = NULL;
@@ -226,7 +245,7 @@ slurm_auth_destroy( slurm_auth_credential_t *cred )
  * Return SLURM_SUCCESS if the credential is in order and valid.
  */
 int
-slurm_auth_verify( slurm_auth_credential_t *c, void *argv )
+slurm_auth_verify( slurm_auth_credential_t *c, void *argv, char *socket )
 {
 	if (!c) {
 		plugin_errno = SLURM_AUTH_BADARG;
@@ -238,7 +257,7 @@ slurm_auth_verify( slurm_auth_credential_t *c, void *argv )
 	if (c->verified) 
 		return SLURM_SUCCESS;
 
-	if (_decode_cred(c) < 0) 
+	if (_decode_cred(c, socket) < 0) 
 		return SLURM_ERROR;
 
 	return SLURM_SUCCESS;
@@ -249,13 +268,13 @@ slurm_auth_verify( slurm_auth_credential_t *c, void *argv )
  * is not assured until slurm_auth_verify() has been called for it.
  */
 uid_t
-slurm_auth_get_uid( slurm_auth_credential_t *cred )
+slurm_auth_get_uid( slurm_auth_credential_t *cred, char *socket )
 {
 	if (cred == NULL) {
 		plugin_errno = SLURM_AUTH_BADARG;
 		return SLURM_AUTH_NOBODY;
 	}
-	if ((!cred->verified) && (_decode_cred(cred) < 0)) {
+	if ((!cred->verified) && (_decode_cred(cred, socket) < 0)) {
 		cred->cr_errno = SLURM_AUTH_INVALID;
 		return SLURM_AUTH_NOBODY;
 	}
@@ -270,13 +289,13 @@ slurm_auth_get_uid( slurm_auth_credential_t *cred )
  * above for details on correct behavior.
  */
 gid_t
-slurm_auth_get_gid( slurm_auth_credential_t *cred )
+slurm_auth_get_gid( slurm_auth_credential_t *cred, char *socket )
 {
 	if (cred == NULL) {
 		plugin_errno = SLURM_AUTH_BADARG;
 		return SLURM_AUTH_NOBODY;
 	}
-	if ((!cred->verified) && (_decode_cred(cred) < 0)) {
+	if ((!cred->verified) && (_decode_cred(cred, socket) < 0)) {
 		cred->cr_errno = SLURM_AUTH_INVALID;
 		return SLURM_AUTH_NOBODY;
 	}
@@ -325,9 +344,9 @@ slurm_auth_pack( slurm_auth_credential_t *cred, Buf buf )
 slurm_auth_credential_t *
 slurm_auth_unpack( Buf buf )
 {
-	slurm_auth_credential_t *cred;
+	slurm_auth_credential_t *cred = NULL;
 	char    *type;
-	uint16_t size;
+	uint32_t size;
 	uint32_t version;
 	
 	if ( buf == NULL ) {
@@ -338,20 +357,14 @@ slurm_auth_unpack( Buf buf )
 	/*
 	 * Get the authentication type.
 	 */
-	if ( unpackmem_ptr( &type, &size, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		return NULL;
-	}
+	safe_unpackmem_ptr( &type, &size, buf );
 	
 	if (( type == NULL )
 	||  ( strcmp( type, plugin_type ) != 0 )) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
 	}
-	if ( unpack32( &version, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		return NULL;
-	}	
+	safe_unpack32( &version, buf );
 	if ( version != plugin_version ) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
@@ -367,13 +380,11 @@ slurm_auth_unpack( Buf buf )
 
 	xassert(cred->magic = MUNGE_MAGIC);
 
-	if (unpackstr_malloc(&cred->m_str, &size, buf) < 0) {
-		plugin_errno = SLURM_AUTH_UNPACK;
-		goto unpack_error;
-	}
+	safe_unpackstr_malloc(&cred->m_str, &size, buf);
 	return cred;
 
  unpack_error:
+	plugin_errno = SLURM_AUTH_UNPACK;
 	xfree( cred );
 	return NULL;
 }
@@ -439,7 +450,7 @@ slurm_auth_errstr( int slurm_errno )
  * into slurm credential `c'
  */
 static int 
-_decode_cred(slurm_auth_credential_t *c)
+_decode_cred(slurm_auth_credential_t *c, char *socket)
 {
 	int retry = 2;
 	munge_err_t e;
@@ -457,6 +468,12 @@ _decode_cred(slurm_auth_credential_t *c)
 		error("munge_ctx_create failure");
 		return SLURM_ERROR;
 	}
+	if (socket &&
+	    (munge_ctx_set(ctx, MUNGE_OPT_SOCKET, socket) != EMUNGE_SUCCESS)) {
+		error("munge_ctx_set failure");
+		munge_ctx_destroy(ctx);
+		return SLURM_ERROR;
+	}
 
     again:
 	if ((e = munge_decode(c->m_str, ctx, &c->buf, &c->len, &c->uid, &c->gid))) {
diff --git a/src/plugins/auth/none/Makefile.in b/src/plugins/auth/none/Makefile.in
index eeaefacd364aed527ff9fff077a24eff6d94725a..8ef4b2079050a652a8138825c723655dd64a20b4 100644
--- a/src/plugins/auth/none/Makefile.in
+++ b/src/plugins/auth/none/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ auth_none_la_OBJECTS = $(am_auth_none_la_OBJECTS)
 auth_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(auth_none_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/auth/none/auth_none.c b/src/plugins/auth/none/auth_none.c
index 42a5579755763b4562abfce6428759c8e8020215..307fcb2bbe3f95c94f4959be2d04dd648402db0f 100644
--- a/src/plugins/auth/none/auth_none.c
+++ b/src/plugins/auth/none/auth_none.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -144,9 +144,7 @@ static int plugin_errno = SLURM_SUCCESS;
  * the general ones.
  */
 enum {
-	SLURM_AUTH_UNPACK_TYPE = SLURM_AUTH_FIRST_LOCAL_ERROR,
-	SLURM_AUTH_UNPACK_VERSION,
-	SLURM_AUTH_UNPACK_CRED
+	SLURM_AUTH_UNPACK
 };
 
 /*
@@ -174,7 +172,7 @@ extern int fini ( void )
  * NULL if it cannot allocate a credential.
  */
 slurm_auth_credential_t *
-slurm_auth_create( void *argv[] )
+slurm_auth_create( void *argv[], char *auth_info )
 {
 	slurm_auth_credential_t *cred;
 
@@ -207,7 +205,7 @@ slurm_auth_destroy( slurm_auth_credential_t *cred )
  * Return SLURM_SUCCESS if the credential is in order and valid.
  */
 int
-slurm_auth_verify( slurm_auth_credential_t *cred, void *argv[] )
+slurm_auth_verify( slurm_auth_credential_t *cred, void *argv[], char *auth_info )
 {
 	return SLURM_SUCCESS;
 }
@@ -217,7 +215,7 @@ slurm_auth_verify( slurm_auth_credential_t *cred, void *argv[] )
  * is not assured until slurm_auth_verify() has been called for it.
  */
 uid_t
-slurm_auth_get_uid( slurm_auth_credential_t *cred )
+slurm_auth_get_uid( slurm_auth_credential_t *cred, char *auth_info )
 {
 	if ( cred == NULL ) {
 		plugin_errno = SLURM_AUTH_BADARG;
@@ -232,7 +230,7 @@ slurm_auth_get_uid( slurm_auth_credential_t *cred )
  * above for details on correct behavior.
  */
 gid_t
-slurm_auth_get_gid( slurm_auth_credential_t *cred )
+slurm_auth_get_gid( slurm_auth_credential_t *cred, char *auth_info )
 {
 	if ( cred == NULL ) {
 		plugin_errno = SLURM_AUTH_BADARG;
@@ -276,11 +274,11 @@ slurm_auth_pack( slurm_auth_credential_t *cred, Buf buf )
 slurm_auth_credential_t *
 slurm_auth_unpack( Buf buf )
 {
-	slurm_auth_credential_t *cred;
+	slurm_auth_credential_t *cred = NULL;
 	char *tmpstr;
 	uint32_t tmpint;
 	uint32_t version;
-	uint16_t size;
+	uint32_t size;
 	
 	if ( buf == NULL ) {
 		plugin_errno = SLURM_AUTH_BADARG;
@@ -290,19 +288,13 @@ slurm_auth_unpack( Buf buf )
 	/*
 	 * Get the authentication type.
 	 */
-	if ( unpackmem_ptr( &tmpstr, &size, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK_TYPE;
-		return NULL;
-	}
+	safe_unpackmem_ptr( &tmpstr, &size, buf );
 	if (( tmpstr == NULL )
 	||  ( strcmp( tmpstr, plugin_type ) != 0 )) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
 	}
-	if ( unpack32( &version, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK_VERSION;
-		return NULL;
-	}
+	safe_unpack32( &version, buf );
 	if ( version != plugin_version ) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
@@ -321,20 +313,17 @@ slurm_auth_unpack( Buf buf )
 	 * clobbering if they really aren't.  This technique ensures a
 	 * warning at compile time if the sizes are incompatible.
 	 */
-	if ( unpack32( &tmpint, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK_CRED;
-		xfree( cred );
-		return NULL;
-	}
+	safe_unpack32( &tmpint, buf );
 	cred->uid = tmpint;
-	if ( unpack32( &tmpint, buf ) != SLURM_SUCCESS ) {
-		plugin_errno = SLURM_AUTH_UNPACK_CRED;
-		xfree( cred );
-		return NULL;
-	}
+	safe_unpack32( &tmpint, buf );
 	cred->gid = tmpint;
 
 	return cred;
+
+  unpack_error:
+	plugin_errno = SLURM_AUTH_UNPACK;
+	xfree( cred );
+	return NULL;
 }
 
 /*
@@ -386,9 +375,7 @@ slurm_auth_errstr( int slurm_errno )
 		int err;
 		char *msg;
 	} tbl[] = {
-		{ SLURM_AUTH_UNPACK_TYPE, "cannot unpack authentication type" },
-		{ SLURM_AUTH_UNPACK_VERSION, "cannot unpack credential version" },
-		{ SLURM_AUTH_UNPACK_CRED, "cannot unpack credential" },
+		{ SLURM_AUTH_UNPACK, "cannot unpack credential" },
 		{ 0, NULL }
 	};
 
diff --git a/src/plugins/checkpoint/Makefile.am b/src/plugins/checkpoint/Makefile.am
index 3ce36725a720416ff8f69f40fd7df8097b474d59..0527fc065beed577bd95a06deaf5f48eb6f045b7 100644
--- a/src/plugins/checkpoint/Makefile.am
+++ b/src/plugins/checkpoint/Makefile.am
@@ -1,3 +1,3 @@
 # Makefile for checkpoint plugins
 
-SUBDIRS = aix none ompi
+SUBDIRS = aix none ompi xlch
diff --git a/src/plugins/checkpoint/Makefile.in b/src/plugins/checkpoint/Makefile.in
index c195f945d99a20d13959de9fcfc0873bb858c778..6a27134d73a51d00596df1da1c6af0827a6ffacc 100644
--- a/src/plugins/checkpoint/Makefile.in
+++ b/src/plugins/checkpoint/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -234,7 +247,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = aix none ompi
+SUBDIRS = aix none ompi xlch
 all: all-recursive
 
 .SUFFIXES:
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/checkpoint/aix/Makefile.in b/src/plugins/checkpoint/aix/Makefile.in
index e7c8bbf0d895044962751e23c13bb02dd20dd50a..73c445d25589cdcb30f6576b7a6dd9f1b1216734 100644
--- a/src/plugins/checkpoint/aix/Makefile.in
+++ b/src/plugins/checkpoint/aix/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -82,7 +84,7 @@ checkpoint_aix_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(checkpoint_aix_la_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_AIX_TRUE@am_checkpoint_aix_la_rpath = -rpath $(pkglibdir)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -124,6 +126,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -137,10 +140,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -160,7 +166,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -171,6 +180,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -186,6 +197,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -201,6 +213,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -305,8 +318,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -314,8 +327,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -369,8 +382,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -382,8 +395,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -393,13 +406,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/checkpoint/aix/checkpoint_aix.c b/src/plugins/checkpoint/aix/checkpoint_aix.c
index 71229d03f5d044465db7ff851d0c6b04521994da..fef01c9f3dd7cecff104ae4215d68edff5ea8b69 100644
--- a/src/plugins/checkpoint/aix/checkpoint_aix.c
+++ b/src/plugins/checkpoint/aix/checkpoint_aix.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  checkpoint_aix.c - AIX slurm checkpoint plugin.
- *  $Id: checkpoint_aix.c 12088 2007-08-22 18:02:24Z jette $
+ *  $Id: checkpoint_aix.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -318,7 +318,7 @@ extern int slurm_ckpt_pack_job(check_jobinfo_t jobinfo, Buf buffer)
 
 extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	struct check_job_info *check_ptr =
 		(struct check_job_info *)jobinfo;
 
@@ -328,7 +328,7 @@ extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer)
 	safe_unpack16(&check_ptr->wait_time, buffer);
 
 	safe_unpack32(&check_ptr->error_code, buffer);
-	safe_unpackstr_xmalloc(&check_ptr->error_msg, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&check_ptr->error_msg, &uint32_tmp, buffer);
 	safe_unpack_time(&check_ptr->time_stamp, buffer);
 	
 	return SLURM_SUCCESS; 
@@ -433,7 +433,7 @@ static void *_ckpt_agent_thr(void *arg)
 			info("checkpoint timeout for %u.%u", 
 				rec->job_id, rec->step_id);
 			_ckpt_signal_step(rec);
-			list_delete(iter);
+			list_delete_item(iter);
 		}
 		slurm_mutex_unlock(&ckpt_agent_mutex);
 		list_iterator_destroy(iter);
@@ -499,7 +499,7 @@ static void _ckpt_dequeue_timeout(uint32_t job_id, uint32_t step_id,
 		||  (start_time && (rec->start_time != start_time)))
 			continue;
 		/* debug("dequeue %u.%u", job_id, step_id); */
-		list_delete(iter);
+		list_delete_item(iter);
 		break;
 	}
 	list_iterator_destroy(iter);
@@ -507,3 +507,8 @@ static void _ckpt_dequeue_timeout(uint32_t job_id, uint32_t step_id,
 	slurm_mutex_unlock(&ckpt_agent_mutex);
 }
 
+extern int slurm_ckpt_task_comp ( struct step_record * step_ptr, uint32_t task_id,
+				  time_t event_time, uint32_t error_code, char *error_msg )
+{
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/checkpoint/none/Makefile.in b/src/plugins/checkpoint/none/Makefile.in
index 3a430589277944eea908fb4bb74fa8abf8b56c5a..af3c69428e33702070015951bfe24243019979dc 100644
--- a/src/plugins/checkpoint/none/Makefile.in
+++ b/src/plugins/checkpoint/none/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ checkpoint_none_la_OBJECTS = $(am_checkpoint_none_la_OBJECTS)
 checkpoint_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(checkpoint_none_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/checkpoint/none/checkpoint_none.c b/src/plugins/checkpoint/none/checkpoint_none.c
index 17cec046850a73b74ce34954f4137d313bbafe4f..78a441782275b6127c83816361123ff3da347ae0 100644
--- a/src/plugins/checkpoint/none/checkpoint_none.c
+++ b/src/plugins/checkpoint/none/checkpoint_none.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -134,3 +134,10 @@ extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer)
 {
 	return SLURM_SUCCESS;
 }
+
+extern int slurm_ckpt_task_comp ( struct step_record * step_ptr, uint32_t task_id,
+				  time_t event_time, uint32_t error_code, char *error_msg )
+{
+	return SLURM_SUCCESS;
+}
+
diff --git a/src/plugins/checkpoint/ompi/Makefile.in b/src/plugins/checkpoint/ompi/Makefile.in
index a62dcd8954779ebcd3ac7eed58f2d59383465706..d2a48ab724e284a9811ea13ae1afbbb47ca11cc6 100644
--- a/src/plugins/checkpoint/ompi/Makefile.in
+++ b/src/plugins/checkpoint/ompi/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ checkpoint_ompi_la_OBJECTS = $(am_checkpoint_ompi_la_OBJECTS)
 checkpoint_ompi_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(checkpoint_ompi_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/checkpoint/ompi/checkpoint_ompi.c b/src/plugins/checkpoint/ompi/checkpoint_ompi.c
index 7f344cff8f1de3907141e50915c2db95347fb7a7..37a60f63a926a9cfa1f9a34c761c63f182815651 100644
--- a/src/plugins/checkpoint/ompi/checkpoint_ompi.c
+++ b/src/plugins/checkpoint/ompi/checkpoint_ompi.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -257,7 +257,7 @@ extern int slurm_ckpt_pack_job(check_jobinfo_t jobinfo, Buf buffer)
 
 extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer)
 {
-	uint16_t uint16_tmp;
+	uint32_t uint32_tmp;
 	struct check_job_info *check_ptr =
 		(struct check_job_info *)jobinfo;
 
@@ -266,7 +266,7 @@ extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer)
 	safe_unpack16(&check_ptr->wait_time, buffer);
 
 	safe_unpack32(&check_ptr->error_code, buffer);
-	safe_unpackstr_xmalloc(&check_ptr->error_msg, &uint16_tmp, buffer);
+	safe_unpackstr_xmalloc(&check_ptr->error_msg, &uint32_tmp, buffer);
 	safe_unpack_time(&check_ptr->time_stamp, buffer);
 	
 	return SLURM_SUCCESS; 
@@ -307,3 +307,10 @@ static int _ckpt_step(struct step_record * step_ptr, uint16_t wait, int vacate)
 		job_ptr->job_id, step_ptr->step_id);
 	return SLURM_SUCCESS;
 }
+
+extern int slurm_ckpt_task_comp ( struct step_record * step_ptr, uint32_t task_id,
+				  time_t event_time, uint32_t error_code, char *error_msg )
+{
+	return SLURM_SUCCESS;
+}
+
diff --git a/src/plugins/checkpoint/xlch/Makefile.am b/src/plugins/checkpoint/xlch/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..5bcc9bae2f2eeff3df9f57a68a11f0cbc61607b4
--- /dev/null
+++ b/src/plugins/checkpoint/xlch/Makefile.am
@@ -0,0 +1,24 @@
+# Makefile for checkpoint/xlch plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = checkpoint_xlch.la
+checkpoint_xlch_la_SOURCES = checkpoint_xlch.c config.c
+checkpoint_xlch_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+
+convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
+
+checkpoint_xlch_la_LIBADD = $(convenience_libs)
+
+config.c: Makefile
+	@( echo "char *scch_path = \"$(prefix)/sbin/scch\";"\
+         ) > config.c
+
+force:
+
+$(checkpoint_xlch_LDADD) : force
+	@cd `dirname $@` && $(MAKE) `basename $@`
diff --git a/src/plugins/checkpoint/xlch/Makefile.in b/src/plugins/checkpoint/xlch/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..bece591cd6f51eb43264672faa87aa309fe163e0
--- /dev/null
+++ b/src/plugins/checkpoint/xlch/Makefile.in
@@ -0,0 +1,565 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for checkpoint/xlch plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/checkpoint/xlch
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+checkpoint_xlch_la_DEPENDENCIES = $(convenience_libs)
+am_checkpoint_xlch_la_OBJECTS = checkpoint_xlch.lo config.lo
+checkpoint_xlch_la_OBJECTS = $(am_checkpoint_xlch_la_OBJECTS)
+checkpoint_xlch_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(checkpoint_xlch_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(checkpoint_xlch_la_SOURCES)
+DIST_SOURCES = $(checkpoint_xlch_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = checkpoint_xlch.la
+checkpoint_xlch_la_SOURCES = checkpoint_xlch.c config.c
+checkpoint_xlch_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
+checkpoint_xlch_la_LIBADD = $(convenience_libs)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/checkpoint/xlch/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/checkpoint/xlch/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+checkpoint_xlch.la: $(checkpoint_xlch_la_OBJECTS) $(checkpoint_xlch_la_DEPENDENCIES) 
+	$(checkpoint_xlch_la_LINK) -rpath $(pkglibdir) $(checkpoint_xlch_la_OBJECTS) $(checkpoint_xlch_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpoint_xlch.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+
+config.c: Makefile
+	@( echo "char *scch_path = \"$(prefix)/sbin/scch\";"\
+         ) > config.c
+
+force:
+
+$(checkpoint_xlch_LDADD) : force
+	@cd `dirname $@` && $(MAKE) `basename $@`
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/checkpoint/xlch/checkpoint_xlch.c b/src/plugins/checkpoint/xlch/checkpoint_xlch.c
new file mode 100644
index 0000000000000000000000000000000000000000..6089588cb435612a9997e97c00f071603b004584
--- /dev/null
+++ b/src/plugins/checkpoint/xlch/checkpoint_xlch.c
@@ -0,0 +1,696 @@
+/*****************************************************************************\
+ *  checkpoint_xlch.c - XLCH slurm checkpoint plugin.
+ *  $Id: checkpoint_xlch.c 0001 2006-10-31 10:55:11Z hjcao $
+ *****************************************************************************
+ *  Copied from checkpoint_aix.c
+ *  
+ *  Copyright (C) 2004 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+#ifdef WITH_PTHREADS
+#  include <pthread.h>
+#endif
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <slurm/slurm.h>
+#include <slurm/slurm_errno.h>
+
+#include "src/common/list.h"
+#include "src/common/log.h"
+#include "src/common/pack.h"
+#include "src/common/xassert.h"
+#include "src/common/xstring.h"
+#include "src/common/xmalloc.h"
+#include "src/slurmctld/agent.h"
+#include "src/slurmctld/slurmctld.h"
+
+#define SIGCKPT 20
+
+struct check_job_info {
+	uint16_t disabled;	/* counter, checkpointable only if zero */
+	uint16_t task_cnt;
+	uint16_t reply_cnt;
+	uint16_t wait_time;
+	time_t   time_stamp;	/* begin or end checkpoint time */
+	uint32_t error_code;
+	char    *error_msg;
+	uint16_t sig_done;
+	bitstr_t *replied;	/* which task has replied the checkpoint.
+				   XXX: only valid if in operation */
+	pthread_mutex_t mutex;
+};
+
+static void _send_sig(uint32_t job_id, uint32_t step_id, uint16_t signal, 
+		      char *nodelist);
+static void _send_ckpt(uint32_t job_id, uint32_t step_id, uint16_t signal, 
+		       time_t timestamp, char *nodelist);
+static int _step_ckpt(struct step_record * step_ptr, uint16_t wait, 
+		      uint16_t signal, uint16_t sig_timeout);
+
+/* checkpoint request timeout processing */
+static pthread_t	ckpt_agent_tid = 0;
+static pthread_mutex_t	ckpt_agent_mutex = PTHREAD_MUTEX_INITIALIZER;
+static List		ckpt_timeout_list = NULL;
+struct ckpt_timeout_info {
+	uint32_t   job_id;
+	uint32_t   step_id;
+	uint16_t   signal;
+	time_t     start_time;
+	time_t     end_time;
+	char*      nodelist;
+};
+static void *_ckpt_agent_thr(void *arg);
+static void _ckpt_enqueue_timeout(uint32_t job_id, uint32_t step_id, 
+				  time_t start_time, uint16_t signal,
+				  uint16_t wait_time, char *nodelist);
+static void  _ckpt_dequeue_timeout(uint32_t job_id, uint32_t step_id,
+				   time_t start_time);
+static void  _ckpt_timeout_free(void *rec);
+static void  _ckpt_signal_step(struct ckpt_timeout_info *rec);
+
+static int _on_ckpt_complete(struct step_record *step_ptr, uint32_t error_code);
+
+extern char *scch_path;
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "checkpoint" for SLURM checkpoint) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load checkpoint plugins if the plugin_type string has a 
+ * prefix of "checkpoint/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the checkpoint API matures.
+ */
+const char plugin_name[]       	= "XLCH checkpoint plugin";
+const char plugin_type[]       	= "checkpoint/xlch";
+const uint32_t plugin_version	= 10;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	pthread_attr_t attr;
+
+	slurm_attr_init(&attr);
+	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
+		error("pthread_attr_setdetachstate: %m");
+	if (pthread_create(&ckpt_agent_tid, &attr, _ckpt_agent_thr, NULL)) {
+		error("pthread_create: %m");
+		return SLURM_ERROR;
+	}
+	slurm_attr_destroy(&attr);
+
+	return SLURM_SUCCESS;
+}
+
+
+extern int fini ( void )
+{
+	int i;
+
+	if (!ckpt_agent_tid)
+		return SLURM_SUCCESS;
+
+	for (i=0; i<4; i++) {
+		if (pthread_cancel(ckpt_agent_tid)) {
+			ckpt_agent_tid = 0;
+			return SLURM_SUCCESS;
+		}
+		usleep(1000);
+	}
+	error("Could not kill checkpoint pthread");
+	return SLURM_ERROR;
+}
+
+/*
+ * The remainder of this file implements the standard SLURM checkpoint API.
+ */
+
+extern int slurm_ckpt_op ( uint16_t op, uint16_t data,
+			   struct step_record * step_ptr, time_t * event_time, 
+			   uint32_t *error_code, char **error_msg )
+{
+	int rc = SLURM_SUCCESS;
+	struct check_job_info *check_ptr;
+
+	xassert(step_ptr);
+	check_ptr = (struct check_job_info *) step_ptr->check_job;
+	check_ptr->task_cnt = step_ptr->step_layout->task_cnt; /* set it early */
+	xassert(check_ptr);
+
+	slurm_mutex_lock (&check_ptr->mutex);
+	
+	switch (op) {
+		case CHECK_ABLE:
+			if (check_ptr->disabled)
+				rc = ESLURM_DISABLED;
+			else {
+				if (check_ptr->reply_cnt < check_ptr->task_cnt)
+					*event_time = check_ptr->time_stamp;
+				rc = SLURM_SUCCESS;
+			}
+			break;
+		case CHECK_DISABLE:
+			check_ptr->disabled++;
+			break;
+		case CHECK_ENABLE:
+			check_ptr->disabled--;
+			break;
+		case CHECK_CREATE:
+			if (check_ptr->time_stamp != 0) {
+				rc = EALREADY;
+				break;
+			}
+			check_ptr->time_stamp = time(NULL);
+			check_ptr->reply_cnt = 0;
+			check_ptr->replied = bit_alloc(check_ptr->task_cnt);
+			check_ptr->error_code = 0;
+			check_ptr->sig_done = 0;
+			xfree(check_ptr->error_msg);
+			rc = _step_ckpt(step_ptr, data, SIGCKPT, SIGKILL);
+			break;
+		case CHECK_VACATE:
+			if (check_ptr->time_stamp != 0) {
+				rc = EALREADY;
+				break;
+			}
+			check_ptr->time_stamp = time(NULL);
+			check_ptr->reply_cnt = 0;
+			check_ptr->replied = bit_alloc(check_ptr->task_cnt);
+			check_ptr->error_code = 0;
+			check_ptr->sig_done = SIGTERM; /* exit elegantly */
+			xfree(check_ptr->error_msg);
+			rc = _step_ckpt(step_ptr, data, SIGCKPT, SIGKILL);
+			break;
+		case CHECK_RESTART:
+			rc = ESLURM_NOT_SUPPORTED;
+			break;
+		case CHECK_ERROR:
+			xassert(error_code);
+			xassert(error_msg);
+			*error_code = check_ptr->error_code;
+			xfree(*error_msg);
+			*error_msg = xstrdup(check_ptr->error_msg);
+			break;
+		default:
+			error("Invalid checkpoint operation: %d", op);
+			rc = EINVAL;
+	}
+
+	slurm_mutex_unlock (&check_ptr->mutex);
+
+	return rc;
+}
+
+/* this function will not be called by us */
+extern int slurm_ckpt_comp ( struct step_record * step_ptr, time_t event_time,
+		uint32_t error_code, char *error_msg )
+{
+	error("checkpoint/xlch: slurm_ckpt_comp not implemented");
+	return SLURM_FAILURE; 
+}
+
+extern int slurm_ckpt_task_comp ( struct step_record * step_ptr, uint32_t task_id,
+				  time_t event_time, uint32_t error_code, char *error_msg )
+{
+	struct check_job_info *check_ptr;
+	int rc = SLURM_SUCCESS;
+
+	xassert(step_ptr);
+	check_ptr = (struct check_job_info *) step_ptr->check_job;
+	xassert(check_ptr);
+
+	/* XXX: we need a mutex here, since in proc_req only JOB_READ locked */
+	debug3("slurm_ckpt_task_comp: job %u.%hu, task %u, error %d",
+	       step_ptr->job_ptr->job_id, step_ptr->step_id, task_id,
+	       error_code);
+
+	slurm_mutex_lock (&check_ptr->mutex);
+
+	/*
+	 * for now we do not use event_time to identify operation and always 
+	 * set it 0
+	 * TODO: consider send event_time to the task via sigqueue().
+	 */
+	if (event_time && (event_time != check_ptr->time_stamp)) {
+		rc = ESLURM_ALREADY_DONE;
+		goto out;
+	}
+
+	if (!check_ptr->replied || bit_test (check_ptr->replied, task_id)) {
+		rc = ESLURM_ALREADY_DONE;
+		goto out;
+	}
+	
+	if ((uint16_t)task_id >= check_ptr->task_cnt) {
+		error("invalid task_id %u, task_cnt: %hu", task_id, 
+		      check_ptr->task_cnt);
+		rc = EINVAL;
+		goto out;
+	}
+	bit_set (check_ptr->replied, task_id);
+	check_ptr->reply_cnt ++;
+
+	/* TODO: check the error_code */
+	if (error_code > check_ptr->error_code) {
+		info("slurm_ckpt_task_comp error %u: %s", error_code, error_msg);
+		check_ptr->error_code = error_code;
+		xfree(check_ptr->error_msg);
+		check_ptr->error_msg = xstrdup(error_msg);
+	}
+
+	/* We need an error-free reply from each task to note completion */
+	if (check_ptr->reply_cnt == check_ptr->task_cnt) { /* all tasks done */
+		time_t now = time(NULL);
+		long delay = (long) difftime(now, check_ptr->time_stamp);
+		info("Checkpoint complete for job %u.%u in %ld seconds",
+		     step_ptr->job_ptr->job_id, step_ptr->step_id,
+		     delay);
+		/* remove the timeout */
+		_ckpt_dequeue_timeout(step_ptr->job_ptr->job_id,
+				      step_ptr->step_id, check_ptr->time_stamp);
+		/* free the replied bitstr */
+		FREE_NULL_BITMAP (check_ptr->replied);
+
+		if (check_ptr->sig_done) {
+			info ("checkpoint step %u.%hu done, sending signal %hu", 
+			      step_ptr->job_ptr->job_id,
+			      step_ptr->step_id, check_ptr->sig_done);
+			_send_sig(step_ptr->job_ptr->job_id, step_ptr->step_id,
+				  check_ptr->sig_done, 
+				  step_ptr->step_layout->node_list);
+		}
+
+		_on_ckpt_complete(step_ptr, check_ptr->error_code); /* how about we execute a program? */
+
+		check_ptr->time_stamp = 0; /* this enables checkpoint again */
+	}
+
+ out:
+	slurm_mutex_unlock (&check_ptr->mutex);
+	return rc; 
+}
+
+extern int slurm_ckpt_alloc_job(check_jobinfo_t *jobinfo)
+{
+	struct check_job_info *check_ptr;
+
+	check_ptr = xmalloc(sizeof(struct check_job_info));
+	slurm_mutex_init (&check_ptr->mutex);
+	*jobinfo = (check_jobinfo_t) check_ptr;
+	return SLURM_SUCCESS;
+}
+
+extern int slurm_ckpt_free_job(check_jobinfo_t jobinfo)
+{
+	struct check_job_info *check_ptr = (struct check_job_info *)jobinfo;
+	if (check_ptr) {
+		xfree (check_ptr->error_msg);
+		FREE_NULL_BITMAP (check_ptr->replied);
+	}
+	xfree(jobinfo);
+	return SLURM_SUCCESS;
+}
+
+extern int slurm_ckpt_pack_job(check_jobinfo_t jobinfo, Buf buffer)
+{
+	struct check_job_info *check_ptr = 
+		(struct check_job_info *)jobinfo;
+ 
+	pack16(check_ptr->disabled, buffer);
+	pack16(check_ptr->task_cnt, buffer);
+	pack16(check_ptr->reply_cnt, buffer);
+	pack16(check_ptr->wait_time, buffer);
+	pack_bit_fmt(check_ptr->replied, buffer);
+
+	pack32(check_ptr->error_code, buffer);
+	packstr(check_ptr->error_msg, buffer);
+	pack_time(check_ptr->time_stamp, buffer);
+
+	return SLURM_SUCCESS;
+}
+
+extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer)
+{
+	uint32_t uint32_tmp;
+	char *task_inx_str;
+	struct check_job_info *check_ptr =
+		(struct check_job_info *)jobinfo;
+
+	safe_unpack16(&check_ptr->disabled, buffer);
+	safe_unpack16(&check_ptr->task_cnt, buffer);
+	safe_unpack16(&check_ptr->reply_cnt, buffer);
+	safe_unpack16(&check_ptr->wait_time, buffer);
+	safe_unpackstr_xmalloc(&task_inx_str, &uint32_tmp, buffer);
+	if (task_inx_str == NULL)
+		check_ptr->replied = NULL;
+	else {
+		check_ptr->replied = bit_alloc(check_ptr->task_cnt);
+		bit_unfmt(check_ptr->replied, task_inx_str);
+		xfree(task_inx_str);
+	}
+
+	safe_unpack32(&check_ptr->error_code, buffer);
+	safe_unpackstr_xmalloc(&check_ptr->error_msg, &uint32_tmp, buffer);
+	safe_unpack_time(&check_ptr->time_stamp, buffer);
+	
+	return SLURM_SUCCESS; 
+
+    unpack_error:
+	xfree(check_ptr->error_msg);
+	return SLURM_ERROR;
+}
+
+/* Send a checkpoint RPC to a specific job step */
+static void _send_ckpt(uint32_t job_id, uint32_t step_id, uint16_t signal, 
+		       time_t timestamp, char *nodelist)
+{
+	agent_arg_t *agent_args;
+	checkpoint_tasks_msg_t *ckpt_tasks_msg;
+
+	ckpt_tasks_msg = xmalloc(sizeof(checkpoint_tasks_msg_t));
+	ckpt_tasks_msg->job_id		= job_id;
+	ckpt_tasks_msg->job_step_id	= step_id;
+	ckpt_tasks_msg->signal		= signal;
+	ckpt_tasks_msg->timestamp       = timestamp;
+
+	agent_args = xmalloc(sizeof(agent_arg_t));
+	agent_args->msg_type		= REQUEST_CHECKPOINT_TASKS;
+	agent_args->retry		= 1; /* keep retrying until all nodes receives the request */
+	agent_args->msg_args		= ckpt_tasks_msg;
+	agent_args->hostlist 		= hostlist_create(nodelist);
+	agent_args->node_count		= hostlist_count(agent_args->hostlist);
+
+	agent_queue_request(agent_args);
+}
+
+/* Send a signal RPC to a list of nodes */
+static void _send_sig(uint32_t job_id, uint32_t step_id, uint16_t signal, 
+		      char *nodelist)
+{
+	agent_arg_t *agent_args;
+	kill_tasks_msg_t *kill_tasks_msg;
+
+	kill_tasks_msg = xmalloc(sizeof(kill_tasks_msg_t));
+	kill_tasks_msg->job_id		= job_id;
+	kill_tasks_msg->job_step_id	= step_id;
+	kill_tasks_msg->signal		= signal;
+
+	agent_args = xmalloc(sizeof(agent_arg_t));
+	agent_args->msg_type		= REQUEST_SIGNAL_TASKS;
+	agent_args->retry		= 1;
+	agent_args->msg_args		= kill_tasks_msg;
+	agent_args->hostlist            = hostlist_create(nodelist);
+	agent_args->node_count		= hostlist_count(agent_args->hostlist);
+
+	agent_queue_request(agent_args);
+}
+
+/* Send checkpoint request to the processes of a job step.
+ * If the request times out, send sig_timeout. */
+static int _step_ckpt(struct step_record * step_ptr, uint16_t wait, 
+		      uint16_t signal, uint16_t sig_timeout)
+{
+	struct check_job_info *check_ptr;
+	struct job_record *job_ptr;
+
+	xassert(step_ptr);
+	check_ptr = (struct check_job_info *) step_ptr->check_job;
+	xassert(check_ptr);
+	job_ptr = step_ptr->job_ptr;
+	xassert(job_ptr);
+
+	if (IS_JOB_FINISHED(job_ptr))
+		return ESLURM_ALREADY_DONE;
+
+	if (check_ptr->disabled)
+		return ESLURM_DISABLED;
+
+	if (!check_ptr->task_cnt) {
+		error("_step_ckpt: job %u.%u has no tasks to checkpoint", 
+			job_ptr->job_id,
+			step_ptr->step_id);
+		return ESLURM_INVALID_NODE_NAME;
+	}
+	char* nodelist = xstrdup (step_ptr->step_layout->node_list);
+	check_ptr->wait_time  = wait; /* TODO: how about change wait_time according to task_cnt? */
+
+	_send_ckpt(step_ptr->job_ptr->job_id, step_ptr->step_id,
+		   signal, check_ptr->time_stamp, nodelist);
+
+	_ckpt_enqueue_timeout(step_ptr->job_ptr->job_id, 
+			      step_ptr->step_id, check_ptr->time_stamp, 
+			      sig_timeout, check_ptr->wait_time, nodelist);  
+	
+	info("checkpoint requested for job %u.%u", job_ptr->job_id,
+	     step_ptr->step_id);
+	xfree (nodelist);
+	return SLURM_SUCCESS;
+}
+
+
+static void _ckpt_signal_step(struct ckpt_timeout_info *rec)
+{
+	/* debug("signal %u.%u %u", rec->job_id, rec->step_id, rec->signal); */
+	_send_sig(rec->job_id, rec->step_id, rec->signal, rec->nodelist);
+}
+
+/* Checkpoint processing pthread
+ * Never returns, but is cancelled on plugin termiantion */
+static void *_ckpt_agent_thr(void *arg)
+{
+	ListIterator iter;
+	struct ckpt_timeout_info *rec;
+	time_t now;
+
+	while (1) {
+		sleep(1);
+		if (!ckpt_timeout_list)
+			continue;
+
+		now = time(NULL);
+		iter = list_iterator_create(ckpt_timeout_list);
+		slurm_mutex_lock(&ckpt_agent_mutex);
+		/* look for and process any timeouts */
+		while ((rec = list_next(iter))) {
+			if (rec->end_time > now)
+				continue;
+			info("checkpoint timeout for %u.%u", 
+				rec->job_id, rec->step_id);
+			_ckpt_signal_step(rec);
+			list_delete_item(iter);
+		}
+		slurm_mutex_unlock(&ckpt_agent_mutex);
+		list_iterator_destroy(iter);
+	}
+}
+
+/* Queue a checkpoint request timeout */
+static void _ckpt_enqueue_timeout(uint32_t job_id, uint32_t step_id, 
+				  time_t start_time, uint16_t signal,
+				  uint16_t wait_time, char *nodelist)
+{
+	struct ckpt_timeout_info *rec;
+
+	if ((wait_time == 0) || (signal == 0)) /* if signal == 0, don't enqueue it */
+		return;
+
+	slurm_mutex_lock(&ckpt_agent_mutex);
+	if (!ckpt_timeout_list)
+		ckpt_timeout_list = list_create(_ckpt_timeout_free);
+	rec = xmalloc(sizeof(struct ckpt_timeout_info));
+	rec->job_id	= job_id;
+	rec->step_id	= step_id;
+	rec->signal     = signal;
+	rec->start_time	= start_time;
+	rec->end_time	= start_time + wait_time;
+	rec->nodelist	= xstrdup(nodelist);
+	/* debug("enqueue %u.%u %u", job_id, step_id, wait_time); */
+	list_enqueue(ckpt_timeout_list, rec);
+	slurm_mutex_unlock(&ckpt_agent_mutex);
+}
+
+static void _ckpt_timeout_free(void *rec)
+{
+	struct ckpt_timeout_info *ckpt_rec = (struct ckpt_timeout_info *)rec;
+	
+	if (ckpt_rec) {
+		xfree(ckpt_rec->nodelist);
+		xfree(ckpt_rec);
+	}
+}
+
+/* De-queue a checkpoint timeout request. The operation completed */
+static void _ckpt_dequeue_timeout(uint32_t job_id, uint32_t step_id,
+		time_t start_time)
+{
+	ListIterator iter;
+	struct ckpt_timeout_info *rec;
+
+	slurm_mutex_lock(&ckpt_agent_mutex);
+	if (!ckpt_timeout_list)
+		goto fini;
+	iter = list_iterator_create(ckpt_timeout_list);
+	while ((rec = list_next(iter))) {
+		if ((rec->job_id != job_id) || (rec->step_id != step_id)
+		    ||  (start_time && (rec->start_time != start_time)))
+			continue;
+		/* debug("dequeue %u.%u", job_id, step_id); */
+		list_delete_item(iter);
+		break;
+	}
+	list_iterator_destroy(iter);
+ fini:
+	slurm_mutex_unlock(&ckpt_agent_mutex);
+}
+
+
+/* a checkpoint completed, process the images files */
+static int _on_ckpt_complete(struct step_record *step_ptr, uint32_t error_code)
+{
+	int status;
+	pid_t cpid;
+
+	if (access(scch_path, R_OK | X_OK) < 0) {
+		info("Access denied for %s: %m", scch_path);
+		return SLURM_ERROR;
+	}
+
+	if ((cpid = fork()) < 0) {
+		error ("_on_ckpt_complete: fork: %m");
+		return SLURM_ERROR;
+	}
+	
+	if (cpid == 0) {
+		/*
+		 * We don't fork and wait the child process because the job 
+		 * read lock is held. It could take minutes to delete/move 
+		 * the checkpoint image files. So there is a race condition
+		 * of the user requesting another checkpoint before SCCH
+		 * finishes.
+		 */
+		/* fork twice to avoid zombies */
+		if ((cpid = fork()) < 0) {
+			error ("_on_ckpt_complete: second fork: %m");
+			exit(127);
+		}
+		/* grand child execs */
+		if (cpid == 0) {
+			char *args[6];
+			char str_job[11];
+			char str_step[11];
+			char str_err[11];
+		
+			/*
+			 * XXX: if slurmctld is running as root, we must setuid here.
+			 * But what if slurmctld is running as SlurmUser?
+			 * How about we make scch setuid and pass the user/group to it?
+			 */
+			if (geteuid() == 0) { /* root */
+				if (setgid(step_ptr->job_ptr->group_id) < 0) {
+					error ("_on_ckpt_complete: failed to "
+						"setgid: %m");
+					exit(127);
+				}
+				if (setuid(step_ptr->job_ptr->user_id) < 0) {
+					error ("_on_ckpt_complete: failed to "
+						"setuid: %m");
+					exit(127);
+				}
+			}
+			snprintf(str_job,  sizeof(str_job),  "%u",  
+				 step_ptr->job_ptr->job_id);
+			snprintf(str_step, sizeof(str_step), "%hu", 
+				 step_ptr->step_id);
+			snprintf(str_err,  sizeof(str_err),  "%u",  
+				 error_code);
+
+			args[0] = scch_path;
+			args[1] = str_job;
+			args[2] = str_step;
+			args[3] = str_err;
+			args[4] = step_ptr->ckpt_path;
+			args[5] = NULL;
+
+			execv(scch_path, args);
+			error("help! %m");
+			exit(127);
+		}
+		/* child just exits */
+		exit(0);
+	}
+
+	while(1) {
+		if (waitpid(cpid, &status, 0) < 0 && errno == EINTR)
+			continue;
+		break;
+	}
+
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/crypto/Makefile.am b/src/plugins/crypto/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..c86ce2759649fabbf2fe4f180b8c097657c5ce51
--- /dev/null
+++ b/src/plugins/crypto/Makefile.am
@@ -0,0 +1,3 @@
+# Makefile for crypto plugins
+
+SUBDIRS = munge openssl
diff --git a/src/plugins/crypto/Makefile.in b/src/plugins/crypto/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..87447b84779ce653213486d099aae72d4e1339d0
--- /dev/null
+++ b/src/plugins/crypto/Makefile.in
@@ -0,0 +1,565 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for crypto plugins
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/crypto
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = munge openssl
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/plugins/crypto/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  src/plugins/crypto/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	    distdir=`$(am__cd) $(distdir) && pwd`; \
+	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$top_distdir" \
+	        distdir="$$distdir/$$subdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+	install-strip
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic clean-libtool \
+	ctags ctags-recursive distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/crypto/munge/Makefile.am b/src/plugins/crypto/munge/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..319f41728d5c94ba66e108700f6d2e75f09116e4
--- /dev/null
+++ b/src/plugins/crypto/munge/Makefile.am
@@ -0,0 +1,19 @@
+# Makefile for crypto/munge plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common $(MUNGE_CPPFLAGS)
+
+# Add your plugin to this line, following the naming conventions.
+if WITH_MUNGE
+MUNGE = crypto_munge.la
+endif
+
+pkglib_LTLIBRARIES = $(MUNGE)
+
+# Munge crypto plugin
+crypto_munge_la_SOURCES = crypto_munge.c
+crypto_munge_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) $(MUNGE_LDFLAGS)
+crypto_munge_la_LIBADD =  $(MUNGE_LIBS)
diff --git a/src/plugins/crypto/munge/Makefile.in b/src/plugins/crypto/munge/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..16c4f449fc32264dab1d05957194c3438bbebdd1
--- /dev/null
+++ b/src/plugins/crypto/munge/Makefile.in
@@ -0,0 +1,561 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for crypto/munge plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/crypto/munge
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+crypto_munge_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_crypto_munge_la_OBJECTS = crypto_munge.lo
+crypto_munge_la_OBJECTS = $(am_crypto_munge_la_OBJECTS)
+crypto_munge_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(crypto_munge_la_LDFLAGS) $(LDFLAGS) -o $@
+@WITH_MUNGE_TRUE@am_crypto_munge_la_rpath = -rpath $(pkglibdir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(crypto_munge_la_SOURCES)
+DIST_SOURCES = $(crypto_munge_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common $(MUNGE_CPPFLAGS)
+
+# Add your plugin to this line, following the naming conventions.
+@WITH_MUNGE_TRUE@MUNGE = crypto_munge.la
+pkglib_LTLIBRARIES = $(MUNGE)
+
+# Munge crypto plugin
+crypto_munge_la_SOURCES = crypto_munge.c
+crypto_munge_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) $(MUNGE_LDFLAGS)
+crypto_munge_la_LIBADD = $(MUNGE_LIBS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/crypto/munge/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/crypto/munge/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+crypto_munge.la: $(crypto_munge_la_OBJECTS) $(crypto_munge_la_DEPENDENCIES) 
+	$(crypto_munge_la_LINK) $(am_crypto_munge_la_rpath) $(crypto_munge_la_OBJECTS) $(crypto_munge_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypto_munge.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/crypto/munge/crypto_munge.c b/src/plugins/crypto/munge/crypto_munge.c
new file mode 100644
index 0000000000000000000000000000000000000000..99d4c28d2f3725f75874896575714952e06a4166
--- /dev/null
+++ b/src/plugins/crypto/munge/crypto_munge.c
@@ -0,0 +1,211 @@
+/*****************************************************************************\
+ *  crypto_munge.c - Munge based cryptographic signature plugin
+ *****************************************************************************
+ *  Copyright (C) 2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Mark A. Grondona <mgrondona@llnl.gov>.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#  if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#  else /* ! HAVE_INTTYPES_H */
+#    if HAVE_STDINT_H
+#      include <stdint.h>
+#    endif
+#  endif /* HAVE_INTTYPES_H */
+#else /* ! HAVE_CONFIG_H */
+#  include <stdint.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define GPL_LICENSED 1
+#include <munge.h>
+
+#include <slurm/slurm_errno.h>
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/xassert.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "auth" for SLURM authentication) and <method> is a
+ * description of how this plugin satisfies that application.  SLURM will
+ * only load authentication plugins if the plugin_type string has a prefix
+ * of "auth/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the authentication API matures.
+ */
+const char plugin_name[]        = "Munge cryptographic signature plugin";
+const char plugin_type[]        = "crypto/munge";
+const uint32_t plugin_version   = 90;
+
+static munge_err_t munge_err;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+/*
+ * fini() is called when the plugin is unloaded, 
+ * free any global memory allocations here to avoid memory leaks.
+ */
+extern int fini ( void )
+{
+	verbose("%s unloaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern void
+crypto_destroy_key(void *key)
+{
+	munge_ctx_destroy((munge_ctx_t) key);
+	return;
+}
+
+extern void *
+crypto_read_private_key(const char *path)
+{
+	return (void *) munge_ctx_create();
+}
+
+
+extern void *
+crypto_read_public_key(const char *path)
+{
+	return (void *) munge_ctx_create();
+}
+
+extern char *
+crypto_str_error(void)
+{
+	return (char *) munge_strerror(munge_err); 
+}
+
+/* NOTE: Caller must xfree the signature returned by sig_pp */
+extern int
+crypto_sign(void * key, char *buffer, int buf_size, char **sig_pp, 
+		unsigned int *sig_size_p) 
+{
+	char *cred;
+
+	munge_err = munge_encode(&cred, (munge_ctx_t) key,
+				 buffer, buf_size);
+
+	if (munge_err != EMUNGE_SUCCESS)
+		return SLURM_ERROR;
+
+	*sig_size_p = strlen(cred) + 1;
+	*sig_pp = xstrdup(cred);
+	free(cred); 
+	return SLURM_SUCCESS;
+}
+
+extern int
+crypto_verify_sign(void * key, char *buffer, unsigned int buf_size, 
+		char *signature, unsigned int sig_size)
+{
+	static uid_t slurm_user = 0;
+	static int got_slurm_user = 0;
+	uid_t uid;
+	gid_t gid;
+	void *buf_out;
+	int   buf_out_size;
+
+	munge_err = munge_decode(signature, (munge_ctx_t) key,
+				 &buf_out, &buf_out_size, 
+				 &uid, &gid);
+
+	if (munge_err != EMUNGE_SUCCESS)
+		return SLURM_ERROR;
+
+	if (!got_slurm_user) {
+		slurm_user = slurm_get_slurm_user_id();
+		got_slurm_user = 1;
+	}
+
+	if ((uid != slurm_user) && (uid != 0)) {
+		error("crypto/munge: bad user id (%d != %d)", 
+			(int) slurm_user, (int) uid);
+		munge_err = EMUNGE_CRED_UNAUTHORIZED;
+		free(buf_out);
+		return SLURM_ERROR;
+	}
+
+	if (buf_size != buf_out_size) {
+		error("crypto/munge: buf_size bad");
+		munge_err = EMUNGE_CRED_INVALID;
+		free(buf_out);
+		return SLURM_ERROR;
+	}
+
+	if (memcmp(buffer, buf_out, buf_size)) {
+		error("crypto/munge: buffers different");
+		munge_err = EMUNGE_CRED_INVALID;
+		free(buf_out);
+		return SLURM_ERROR;
+	}
+
+	free(buf_out);
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/crypto/openssl/Makefile.am b/src/plugins/crypto/openssl/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..b55b6a3449bc00035c2928481e981a9c7d898ac2
--- /dev/null
+++ b/src/plugins/crypto/openssl/Makefile.am
@@ -0,0 +1,25 @@
+# Makefile for crypto/openssl plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+if HAVE_OPENSSL
+openssl_lib = crypto_openssl.la
+else
+openssl_lib =
+endif
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = $(openssl_lib)
+
+if HAVE_OPENSSL
+crypto_openssl_la_SOURCES = crypto_openssl.c
+
+crypto_openssl_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) $(SSL_LDFLAGS)
+crypto_openssl_la_LIBADD   = $(SSL_LIBS)
+
+else
+EXTRA_crypto_openssl_la_SOURCES = crypto_openssl.c
+endif
diff --git a/src/plugins/crypto/openssl/Makefile.in b/src/plugins/crypto/openssl/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..6c06edf1c093346f33b1a5ab4f4b1b01f901b321
--- /dev/null
+++ b/src/plugins/crypto/openssl/Makefile.in
@@ -0,0 +1,564 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for crypto/openssl plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/crypto/openssl
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+@HAVE_OPENSSL_TRUE@crypto_openssl_la_DEPENDENCIES =  \
+@HAVE_OPENSSL_TRUE@	$(am__DEPENDENCIES_1)
+am__crypto_openssl_la_SOURCES_DIST = crypto_openssl.c
+@HAVE_OPENSSL_TRUE@am_crypto_openssl_la_OBJECTS = crypto_openssl.lo
+am__EXTRA_crypto_openssl_la_SOURCES_DIST = crypto_openssl.c
+crypto_openssl_la_OBJECTS = $(am_crypto_openssl_la_OBJECTS)
+crypto_openssl_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(crypto_openssl_la_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_OPENSSL_TRUE@am_crypto_openssl_la_rpath = -rpath $(pkglibdir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(crypto_openssl_la_SOURCES) \
+	$(EXTRA_crypto_openssl_la_SOURCES)
+DIST_SOURCES = $(am__crypto_openssl_la_SOURCES_DIST) \
+	$(am__EXTRA_crypto_openssl_la_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+@HAVE_OPENSSL_FALSE@openssl_lib = 
+@HAVE_OPENSSL_TRUE@openssl_lib = crypto_openssl.la
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = $(openssl_lib)
+@HAVE_OPENSSL_TRUE@crypto_openssl_la_SOURCES = crypto_openssl.c
+@HAVE_OPENSSL_TRUE@crypto_openssl_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) $(SSL_LDFLAGS)
+@HAVE_OPENSSL_TRUE@crypto_openssl_la_LIBADD = $(SSL_LIBS)
+@HAVE_OPENSSL_FALSE@EXTRA_crypto_openssl_la_SOURCES = crypto_openssl.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/crypto/openssl/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/crypto/openssl/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+crypto_openssl.la: $(crypto_openssl_la_OBJECTS) $(crypto_openssl_la_DEPENDENCIES) 
+	$(crypto_openssl_la_LINK) $(am_crypto_openssl_la_rpath) $(crypto_openssl_la_OBJECTS) $(crypto_openssl_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypto_openssl.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/crypto/openssl/crypto_openssl.c b/src/plugins/crypto/openssl/crypto_openssl.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d37e14d4bb6405aa75218d216885eacea139ea7
--- /dev/null
+++ b/src/plugins/crypto/openssl/crypto_openssl.c
@@ -0,0 +1,230 @@
+/*****************************************************************************\
+ *  crypto_openssl.c - OpenSSL based cryptographic signature plugin
+ *****************************************************************************
+ *  Copyright (C) 2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Mark A. Grondona <mgrondona@llnl.gov>.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#  if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#  else /* ! HAVE_INTTYPES_H */
+#    if HAVE_STDINT_H
+#      include <stdint.h>
+#    endif
+#  endif /* HAVE_INTTYPES_H */
+#else /* ! HAVE_CONFIG_H */
+#  include <stdint.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+
+/*
+ * OpenSSL includes
+ */
+#include <openssl/evp.h>
+#include <openssl/pem.h>
+#include <openssl/err.h>
+
+#include <slurm/slurm_errno.h>
+#include "src/common/xassert.h"
+#include "src/common/xmalloc.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "auth" for SLURM authentication) and <method> is a
+ * description of how this plugin satisfies that application.  SLURM will
+ * only load authentication plugins if the plugin_type string has a prefix
+ * of "auth/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the authentication API matures.
+ */
+const char plugin_name[]        = "OpenSSL cryptographic signature plugin";
+const char plugin_type[]        = "crypto/openssl";
+const uint32_t plugin_version   = 90;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+/*
+ * fini() is called when the plugin is unloaded, 
+ * free any global memory allocations here to avoid memory leaks.
+ */
+extern int fini ( void )
+{
+	verbose("%s unloaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern void
+crypto_destroy_key(void *key)
+{
+	if (key)
+		EVP_PKEY_free((EVP_PKEY *) key);
+}
+
+extern void *
+crypto_read_private_key(const char *path)
+{
+	FILE     *fp = NULL;
+	EVP_PKEY *pk = NULL;
+
+	xassert(path != NULL);
+
+	if (!(fp = fopen(path, "r")))
+		return NULL;
+
+	if (!PEM_read_PrivateKey(fp, &pk, NULL, NULL)) {
+		fclose(fp);
+		return NULL;
+	}
+	fclose(fp);
+
+	return (void *) pk;
+}
+
+
+extern void *
+crypto_read_public_key(const char *path)
+{
+	FILE     *fp = NULL;
+	EVP_PKEY *pk = NULL;
+
+	xassert(path != NULL);
+
+	if ((fp = fopen(path, "r")) == NULL)
+		return NULL;
+
+	if (!PEM_read_PUBKEY(fp, &pk, NULL, NULL)) {
+		fclose(fp);
+		return NULL;
+	} 
+	fclose(fp);
+
+	return (void *) pk;
+}
+
+extern char *
+crypto_str_error(void)
+{
+	static int loaded = 0;
+
+	if (loaded == 0) {
+		ERR_load_crypto_strings();
+		loaded = 1;
+	}
+
+	return (char *) ERR_reason_error_string(ERR_get_error()); 
+}
+
+/* NOTE: Caller must xfree the signature returned by sig_pp */
+extern int
+crypto_sign(void * key, char *buffer, int buf_size, char **sig_pp, 
+		unsigned int *sig_size_p) 
+{
+	EVP_MD_CTX    ectx;
+	int           rc    = SLURM_SUCCESS;
+	int           ksize = EVP_PKEY_size((EVP_PKEY *) key);
+
+	/*
+	 * Allocate memory for signature: at most EVP_PKEY_size() bytes
+	 */
+	*sig_pp = xmalloc(ksize * sizeof(unsigned char));
+
+	EVP_SignInit(&ectx, EVP_sha1());
+	EVP_SignUpdate(&ectx, buffer, buf_size);
+
+	if (!(EVP_SignFinal(&ectx, (unsigned char *)*sig_pp, sig_size_p, 
+			(EVP_PKEY *) key))) {
+		rc = SLURM_ERROR;
+	}
+
+#ifdef HAVE_EVP_MD_CTX_CLEANUP
+	/* Note: Likely memory leak if this function is absent */
+	EVP_MD_CTX_cleanup(&ectx);
+#endif
+
+	return rc;
+}
+
+extern int
+crypto_verify_sign(void * key, char *buffer, unsigned int buf_size, 
+		char *signature, unsigned int sig_size)
+{
+	EVP_MD_CTX     ectx;
+	int            rc;
+
+	EVP_VerifyInit(&ectx, EVP_sha1());
+	EVP_VerifyUpdate(&ectx, buffer, buf_size);
+
+	rc = EVP_VerifyFinal(&ectx, (unsigned char *) signature, 
+		sig_size, (EVP_PKEY *) key);
+	if (!rc)
+		rc = SLURM_ERROR;
+	else
+		rc = SLURM_SUCCESS;
+
+#ifdef HAVE_EVP_MD_CTX_CLEANUP
+	/* Note: Likely memory leak if this function is absent */
+	EVP_MD_CTX_cleanup(&ectx);
+#endif
+
+	return rc;
+}
diff --git a/src/plugins/jobacct/aix/Makefile.am b/src/plugins/jobacct/aix/Makefile.am
deleted file mode 100644
index 0c59144ddc68b4b871af9edd02e500e865eff601..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/aix/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-# Makefile for jobacct/aix plugin
-
-AUTOMAKE_OPTIONS = foreign
-
-PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
-
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-
-pkglib_LTLIBRARIES = jobacct_aix.la
-
-# Null job completion logging plugin.
-jobacct_aix_la_SOURCES = jobacct_aix.c \
-	$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c \
-	$(top_builddir)/src/slurmd/common/proctrack.c \
-	$(top_builddir)/src/slurmd/common/proctrack.h 
-
-jobacct_aix_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/jobacct/common/common_slurmctld.c b/src/plugins/jobacct/common/common_slurmctld.c
deleted file mode 100644
index 24dec3a7968dc311628c970f356299f4637bd003..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/common/common_slurmctld.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/*****************************************************************************\
- *  jobacct_common.c - common functions for almost all jobacct plugins.
- *****************************************************************************
- *
- *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
- *  Written by Danny Auble, <da@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
- *
- *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
- *  Copyright (C) 2002 The Regents of the University of California.
-\*****************************************************************************/
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include "jobacct_common.h"
-
-static FILE *		LOGFILE;
-static int		LOGFILE_FD;
-static pthread_mutex_t  logfile_lock = PTHREAD_MUTEX_INITIALIZER;
-static char *		log_file = NULL;
-static int              init;
-/* Format of the JOB_STEP record */
-const char *_jobstep_format = 
-"%d "
-"%u "	/* stepid */
-"%d "	/* completion status */
-"%u "	/* completion code */
-"%u "	/* nprocs */
-"%u "	/* number of cpus */
-"%u "	/* elapsed seconds */
-"%u "	/* total cputime seconds */
-"%u "	/* total cputime microseconds */
-"%u "	/* user seconds */
-"%u "	/* user microseconds */
-"%u "	/* system seconds */
-"%u "	/* system microseconds */
-"%u "	/* max rss */
-"%u "	/* max ixrss */
-"%u "	/* max idrss */
-"%u "	/* max isrss */
-"%u "	/* max minflt */
-"%u "	/* max majflt */
-"%u "	/* max nswap */
-"%u "	/* total inblock */
-"%u "	/* total outblock */
-"%u "	/* total msgsnd */
-"%u "	/* total msgrcv */
-"%u "	/* total nsignals */
-"%u "	/* total nvcsw */
-"%u "	/* total nivcsw */
-"%u "	/* max vsize */
-"%u "	/* max vsize task */
-"%.2f "	/* ave vsize */
-"%u "	/* max rss */
-"%u "	/* max rss task */
-"%.2f "	/* ave rss */
-"%u "	/* max pages */
-"%u "	/* max pages task */
-"%.2f "	/* ave pages */
-"%.2f "	/* min cpu */
-"%u "	/* min cpu task */
-"%.2f "	/* ave cpu */
-"%s "	/* step process name */
-"%s "	/* step node names */
-"%u "	/* max vsize node */
-"%u "	/* max rss node */
-"%u "	/* max pages node */
-"%u "	/* min cpu node */
-"%s "   /* account */
-"%u";   /* requester user id */
-
-/*
- * Print the record to the log file.
- */
-
-static int _print_record(struct job_record *job_ptr, 
-			 time_t time, char *data)
-{ 
-	static int   rc=SLURM_SUCCESS;
-	char *block_id = NULL;
-	if(!job_ptr->details) {
-		error("job_acct: job=%u doesn't exist", job_ptr->job_id);
-		return SLURM_ERROR;
-	}
-	debug2("_print_record, job=%u, \"%s\"",
-	       job_ptr->job_id, data);
-#ifdef HAVE_BG
-	select_g_get_jobinfo(job_ptr->select_jobinfo, 
-			     SELECT_DATA_BLOCK_ID, 
-			     &block_id);
-		
-#endif
-	if(!block_id)
-		block_id = xstrdup("-");
-
-	slurm_mutex_lock( &logfile_lock );
-
-	if (fprintf(LOGFILE,
-		    "%u %s %u %u %d %d %s - %s\n",
-		    job_ptr->job_id, job_ptr->partition,
-		    (int)job_ptr->details->submit_time, (int)time, 
-		    job_ptr->user_id, job_ptr->group_id, block_id, data)
-	    < 0)
-		rc=SLURM_ERROR;
-#ifdef HAVE_FDATASYNC
-	fdatasync(LOGFILE_FD);
-#endif
-	slurm_mutex_unlock( &logfile_lock );
-	xfree(block_id);
-
-	return rc;
-}
-
-extern int common_init_slurmctld(char *job_acct_log)
-{
-	int 		rc = SLURM_SUCCESS;
-	mode_t		prot = 0600;
-	struct stat	statbuf;
-
-	debug2("jobacct_init() called");
-	slurm_mutex_lock( &logfile_lock );
-	if (LOGFILE)
-		fclose(LOGFILE);
-	log_file=job_acct_log;
-	if (*log_file != '/')
-		fatal("JobAcctLogfile must specify an absolute pathname");
-	if (stat(log_file, &statbuf)==0)       /* preserve current file mode */
-		prot = statbuf.st_mode;
-	LOGFILE = fopen(log_file, "a");
-	if (LOGFILE == NULL) {
-		error("open %s: %m", log_file);
-		init = 0;
-		slurm_mutex_unlock( &logfile_lock );
-		return SLURM_ERROR;
-	} else
-		chmod(log_file, prot); 
-	if (setvbuf(LOGFILE, NULL, _IOLBF, 0))
-		error("setvbuf() failed");
-	LOGFILE_FD = fileno(LOGFILE);
-	slurm_mutex_unlock( &logfile_lock );
-	init = 1;
-	return rc;
-}
-
-extern int common_fini_slurmctld()
-{
-	if (LOGFILE)
-		fclose(LOGFILE);
-	return SLURM_SUCCESS;
-}
-
-extern int common_job_start_slurmctld(struct job_record *job_ptr)
-{
-	int	i,
-		ncpus=0,
-		rc=SLURM_SUCCESS,
-		tmp;
-	char	buf[BUFFER_SIZE], *jname, *account, *nodes;
-	long	priority;
-	int track_steps = 0;
-
-	if(!init) {
-		debug("jobacct init was not called or it failed");
-		return SLURM_ERROR;
-	}
-
-	debug2("jobacct_job_start() called");
-
-	if (job_ptr->start_time == 0) {
-		/* This function is called when a job becomes elligible to run
-		 * in order to record reserved time (a measure of system 
-		 * over-subscription). We only use this in the Gold plugin. */
-		return SLURM_SUCCESS;
-	}
-
-	for (i=0; i < job_ptr->num_cpu_groups; i++)
-		ncpus += (job_ptr->cpus_per_node[i])
-			* (job_ptr->cpu_count_reps[i]);
-	priority = (job_ptr->priority == NO_VAL) ?
-		-1L : (long) job_ptr->priority;
-
-	if ((tmp = strlen(job_ptr->name))) {
-		jname = xmalloc(++tmp);
-		for (i=0; i<tmp; i++) {
-			if (isspace(job_ptr->name[i]))
-				jname[i]='_';
-			else
-				jname[i]=job_ptr->name[i];
-		}
-	} else {
-		jname = xstrdup("allocation");
-		track_steps = 1;
-	}
-
-	if (job_ptr->account && job_ptr->account[0])
-		account = job_ptr->account;
-	else
-		account = "(null)";
-	if (job_ptr->nodes && job_ptr->nodes[0])
-		nodes = job_ptr->nodes;
-	else
-		nodes = "(null)";
-
-	if(job_ptr->batch_flag)
-		track_steps = 1;
-
-	job_ptr->requid = -1; /* force to -1 for sacct to know this
-			       * hasn't been set yet */
-
-	tmp = snprintf(buf, BUFFER_SIZE,
-		       "%d %s %d %ld %u %s %s",
-		       JOB_START, jname,
-		       track_steps, priority, job_ptr->num_procs,
-		       nodes, account);
-
-	rc = _print_record(job_ptr, job_ptr->start_time, buf);
-	
-	xfree(jname);
-	return rc;
-}
-
-extern int common_job_complete_slurmctld(struct job_record *job_ptr)
-{
-	char buf[BUFFER_SIZE];
-	if(!init) {
-		debug("jobacct init was not called or it failed");
-		return SLURM_ERROR;
-	}
-	
-	debug2("jobacct_job_complete() called");
-	if (job_ptr->end_time == 0) {
-		debug("jobacct: job %u never started", job_ptr->job_id);
-		return SLURM_ERROR;
-	}
-	/* leave the requid as a %d since we want to see if it is -1
-	   in sacct */
-	snprintf(buf, BUFFER_SIZE, "%d %u %d %u",
-		 JOB_TERMINATED,
-		 (int) (job_ptr->end_time - job_ptr->start_time),
-		 job_ptr->job_state & (~JOB_COMPLETING),
-		 job_ptr->requid);
-	
-	return  _print_record(job_ptr, job_ptr->end_time, buf);
-}
-
-extern int common_step_start_slurmctld(struct step_record *step)
-{
-	char buf[BUFFER_SIZE];
-	int cpus = 0;
-	char node_list[BUFFER_SIZE];
-#ifdef HAVE_BG
-	char *ionodes = NULL;
-#endif
-	float float_tmp = 0;
-	char *account;
-	
-	if(!init) {
-		debug("jobacct init was not called or it failed");
-		return SLURM_ERROR;
-	}
-
-#ifdef HAVE_BG
-	cpus = step->job_ptr->num_procs;
-	select_g_get_jobinfo(step->job_ptr->select_jobinfo, 
-			     SELECT_DATA_IONODES, 
-			     &ionodes);
-	if(ionodes) {
-		snprintf(node_list, BUFFER_SIZE, 
-			 "%s[%s]", step->job_ptr->nodes, ionodes);
-		xfree(ionodes);
-	} else
-		snprintf(node_list, BUFFER_SIZE, "%s",
-			 step->job_ptr->nodes);
-	
-#else
-	if(!step->step_layout || !step->step_layout->task_cnt) {
-		cpus = step->job_ptr->num_procs;
-		snprintf(node_list, BUFFER_SIZE, "%s", step->job_ptr->nodes);
-	} else {
-		cpus = step->step_layout->task_cnt;
-		snprintf(node_list, BUFFER_SIZE, "%s", 
-			 step->step_layout->node_list);
-	}
-#endif
-	if (step->job_ptr->account && step->job_ptr->account[0])
-		account = step->job_ptr->account;
-	else
-		account = "(null)";
-
-	step->job_ptr->requid = -1; /* force to -1 for sacct to know this
-				     * hasn't been set yet  */
-
-	snprintf(buf, BUFFER_SIZE, _jobstep_format,
-		 JOB_STEP,
-		 step->step_id,	/* stepid */
-		 JOB_RUNNING,		/* completion status */
-		 0,     		/* completion code */
-		 cpus,          	/* number of tasks */
-		 cpus,                  /* number of cpus */
-		 0,	        	/* elapsed seconds */
-		 0,                    /* total cputime seconds */
-		 0,    		/* total cputime seconds */
-		 0,	/* user seconds */
-		 0,/* user microseconds */
-		 0,	/* system seconds */
-		 0,/* system microsecs */
-		 0,	/* max rss */
-		 0,	/* max ixrss */
-		 0,	/* max idrss */
-		 0,	/* max isrss */
-		 0,	/* max minflt */
-		 0,	/* max majflt */
-		 0,	/* max nswap */
-		 0,	/* total inblock */
-		 0,	/* total outblock */
-		 0,	/* total msgsnd */
-		 0,	/* total msgrcv */
-		 0,	/* total nsignals */
-		 0,	/* total nvcsw */
-		 0,	/* total nivcsw */
-		 0,	/* max vsize */
-		 0,	/* max vsize task */
-		 float_tmp,	/* ave vsize */
-		 0,	/* max rss */
-		 0,	/* max rss task */
-		 float_tmp,	/* ave rss */
-		 0,	/* max pages */
-		 0,	/* max pages task */
-		 float_tmp,	/* ave pages */
-		 float_tmp,	/* min cpu */
-		 0,	/* min cpu task */
-		 float_tmp,	/* ave cpu */
-		 step->name,    /* step exe name */
-		 node_list,     /* name of nodes step running on */
-		 0,	/* max vsize node */
-		 0,	/* max rss node */
-		 0,	/* max pages node */
-		 0,	/* min cpu node */
-		 account,
-		 step->job_ptr->requid); /* requester user id */
-		 
-	return _print_record(step->job_ptr, step->start_time, buf);
-}
-
-extern int common_step_complete_slurmctld(struct step_record *step)
-{
-		char buf[BUFFER_SIZE];
-	time_t now;
-	int elapsed;
-	int comp_status;
-	int cpus = 0;
-	char node_list[BUFFER_SIZE];
-	struct jobacctinfo *jobacct = (struct jobacctinfo *)step->jobacct;
-#ifdef HAVE_BG
-	char *ionodes = NULL;
-#endif
-	float ave_vsize = 0, ave_rss = 0, ave_pages = 0;
-	float ave_cpu = 0, ave_cpu2 = 0;
-	char *account;
-
-	if(!init) {
-		debug("jobacct init was not called or it failed");
-		return SLURM_ERROR;
-	}
-	
-	now = time(NULL);
-	
-	if ((elapsed=now-step->start_time)<0)
-		elapsed=0;	/* For *very* short jobs, if clock is wrong */
-	if (step->exit_code)
-		comp_status = JOB_FAILED;
-	else
-		comp_status = JOB_COMPLETE;
-
-#ifdef HAVE_BG
-	cpus = step->job_ptr->num_procs;
-	select_g_get_jobinfo(step->job_ptr->select_jobinfo, 
-			     SELECT_DATA_IONODES, 
-			     &ionodes);
-	if(ionodes) {
-		snprintf(node_list, BUFFER_SIZE, 
-			 "%s[%s]", step->job_ptr->nodes, ionodes);
-		xfree(ionodes);
-	} else
-		snprintf(node_list, BUFFER_SIZE, "%s", 
-			 step->job_ptr->nodes);
-	
-#else
-	if(!step->step_layout || !step->step_layout->task_cnt) {
-		cpus = step->job_ptr->num_procs;
-		snprintf(node_list, BUFFER_SIZE, "%s", step->job_ptr->nodes);
-	
-	} else {
-		cpus = step->step_layout->task_cnt;
-		snprintf(node_list, BUFFER_SIZE, "%s", 
-			 step->step_layout->node_list);
-	}
-#endif
-	/* figure out the ave of the totals sent */
-	if(cpus > 0) {
-		ave_vsize = jobacct->tot_vsize;
-		ave_vsize /= cpus;
-		ave_rss = jobacct->tot_rss;
-		ave_rss /= cpus;
-		ave_pages = jobacct->tot_pages;
-		ave_pages /= cpus;
-		ave_cpu = jobacct->tot_cpu;
-		ave_cpu /= cpus;	
-		ave_cpu /= 100;
-	}
- 
-	if(jobacct->min_cpu != (uint32_t)NO_VAL) {
-		ave_cpu2 = jobacct->min_cpu;
-		ave_cpu2 /= 100;
-	}
-
-	if (step->job_ptr->account && step->job_ptr->account[0])
-		account = step->job_ptr->account;
-	else
-		account = "(null)";
-
-	snprintf(buf, BUFFER_SIZE, _jobstep_format,
-		 JOB_STEP,
-		 step->step_id,	/* stepid */
-		 comp_status,		/* completion status */
-		 step->exit_code,	/* completion code */
-		 cpus,          	/* number of tasks */
-		 cpus,                  /* number of cpus */
-		 elapsed,	        /* elapsed seconds */
-		 /* total cputime seconds */
-		 jobacct->rusage.ru_utime.tv_sec	
-		 + jobacct->rusage.ru_stime.tv_sec,
-		 /* total cputime seconds */
-		 jobacct->rusage.ru_utime.tv_usec	
-		 + jobacct->rusage.ru_stime.tv_usec,
-		 jobacct->rusage.ru_utime.tv_sec,	/* user seconds */
-		 jobacct->rusage.ru_utime.tv_usec,/* user microseconds */
-		 jobacct->rusage.ru_stime.tv_sec,	/* system seconds */
-		 jobacct->rusage.ru_stime.tv_usec,/* system microsecs */
-		 jobacct->rusage.ru_maxrss,	/* max rss */
-		 jobacct->rusage.ru_ixrss,	/* max ixrss */
-		 jobacct->rusage.ru_idrss,	/* max idrss */
-		 jobacct->rusage.ru_isrss,	/* max isrss */
-		 jobacct->rusage.ru_minflt,	/* max minflt */
-		 jobacct->rusage.ru_majflt,	/* max majflt */
-		 jobacct->rusage.ru_nswap,	/* max nswap */
-		 jobacct->rusage.ru_inblock,	/* total inblock */
-		 jobacct->rusage.ru_oublock,	/* total outblock */
-		 jobacct->rusage.ru_msgsnd,	/* total msgsnd */
-		 jobacct->rusage.ru_msgrcv,	/* total msgrcv */
-		 jobacct->rusage.ru_nsignals,	/* total nsignals */
-		 jobacct->rusage.ru_nvcsw,	/* total nvcsw */
-		 jobacct->rusage.ru_nivcsw,	/* total nivcsw */
-		 jobacct->max_vsize,	/* max vsize */
-		 jobacct->max_vsize_id.taskid,	/* max vsize node */
-		 ave_vsize,	/* ave vsize */
-		 jobacct->max_rss,	/* max vsize */
-		 jobacct->max_rss_id.taskid,	/* max rss node */
-		 ave_rss,	/* ave rss */
-		 jobacct->max_pages,	/* max pages */
-		 jobacct->max_pages_id.taskid,	/* max pages node */
-		 ave_pages,	/* ave pages */
-		 ave_cpu2,	/* min cpu */
-		 jobacct->min_cpu_id.taskid,	/* min cpu node */
-		 ave_cpu,	/* ave cpu */
-		 step->name,      	/* step exe name */
-		 node_list, /* name of nodes step running on */
-		 jobacct->max_vsize_id.nodeid,	/* max vsize task */
-		 jobacct->max_rss_id.nodeid,	/* max rss task */
-		 jobacct->max_pages_id.nodeid,	/* max pages task */
-		 jobacct->min_cpu_id.nodeid,	/* min cpu task */
-		 account,
-		 step->job_ptr->requid); /* requester user id */
-		 
-	return _print_record(step->job_ptr, now, buf);	
-}
-
-extern int common_suspend_slurmctld(struct job_record *job_ptr)
-{
-	char buf[BUFFER_SIZE];
-	static time_t	now = 0;
-	static time_t	temp = 0;
-	int elapsed;
-	if(!init) {
-		debug("jobacct init was not called or it failed");
-		return SLURM_ERROR;
-	}
-	
-	/* tell what time has passed */
-	if(!now)
-		now = job_ptr->start_time;
-	temp = now;
-	now = time(NULL);
-	
-	if ((elapsed=now-temp) < 0)
-		elapsed=0;	/* For *very* short jobs, if clock is wrong */
-	
-	/* here we are really just going for a marker in time to tell when
-	 * the process was suspended or resumed (check job state), we don't 
-	 * really need to keep track of anything else */
-	snprintf(buf, BUFFER_SIZE, "%d %u %d",
-		 JOB_SUSPEND,
-		 elapsed,
-		 job_ptr->job_state & (~JOB_COMPLETING));/* job status */
-		
-	return _print_record(job_ptr, now, buf);
-
-}
diff --git a/src/plugins/jobacct/common/common_slurmstepd.c b/src/plugins/jobacct/common/common_slurmstepd.c
deleted file mode 100644
index 22b1222cf34b5796f4ca9a2944297323f81afdea..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/common/common_slurmstepd.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*****************************************************************************\
- *  jobacct_common.c - common functions for almost all jobacct plugins.
- *****************************************************************************
- *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
- *  Written by Danny Auble, <da@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
- *
- *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
- *  Copyright (C) 2002 The Regents of the University of California.
-\*****************************************************************************/
-
-#include "jobacct_common.h"
-
-bool jobacct_shutdown = false;
-bool suspended = false;
-List task_list = NULL;
-pthread_mutex_t jobacct_lock = PTHREAD_MUTEX_INITIALIZER;
-uint32_t cont_id = (uint32_t)NO_VAL;
-bool pgid_plugin = false;
-
-extern int common_endpoll()
-{
-	jobacct_shutdown = true;
-
-	return SLURM_SUCCESS;
-}
-
-extern int common_set_proctrack_container_id(uint32_t id)
-{
-	if(pgid_plugin)
-		return SLURM_SUCCESS;
-
-	if(cont_id != (uint32_t)NO_VAL) 
-		info("Warning: jobacct: set_proctrack_container_id: "
-		     "cont_id is already set to %d you are setting it to %d",
-		     cont_id, id);
-	if((int)id <= 0) {
-		error("jobacct: set_proctrack_container_id: "
-		      "I was given most likely an unset cont_id %d",
-		      id);
-		return SLURM_ERROR;
-	}
-	cont_id = id;
-
-	return SLURM_SUCCESS;
-}
-
-extern int common_add_task(pid_t pid, jobacct_id_t *jobacct_id)
-{
-	struct jobacctinfo *jobacct = common_alloc_jobacct(jobacct_id);
-	
-	slurm_mutex_lock(&jobacct_lock);
-	if(pid <= 0) {
-		error("invalid pid given (%d) for task acct", pid);
-		goto error;
-	} else if (!task_list) {
-		error("no task list created!");
-		goto error;
-	}
-
-	jobacct->pid = pid;
-	jobacct->min_cpu = 0;
-	debug2("adding task %u pid %d on node %u to jobacct", 
-	       jobacct_id->taskid, pid, jobacct_id->nodeid);
-	list_push(task_list, jobacct);
-	slurm_mutex_unlock(&jobacct_lock);
-
-	return SLURM_SUCCESS;
-error:
-	slurm_mutex_unlock(&jobacct_lock);
-	common_free_jobacct(jobacct);
-	return SLURM_ERROR;
-}
-
-extern struct jobacctinfo *common_stat_task(pid_t pid)
-{
-	struct jobacctinfo *jobacct = NULL;
-	struct jobacctinfo *ret_jobacct = NULL;
-	ListIterator itr = NULL;
-	
-	slurm_mutex_lock(&jobacct_lock);
-	if (!task_list) {
-		error("no task list created!");
-		goto error;
-	}
-
-	itr = list_iterator_create(task_list);
-	while((jobacct = list_next(itr))) { 
-		if(jobacct->pid == pid)
-			break;
-	}
-	list_iterator_destroy(itr);
-	ret_jobacct = xmalloc(sizeof(struct jobacctinfo));
-	memcpy(ret_jobacct, jobacct, sizeof(struct jobacctinfo));
-error:
-	slurm_mutex_unlock(&jobacct_lock);
-	return ret_jobacct;
-}
-
-extern struct jobacctinfo *common_remove_task(pid_t pid)
-{
-	struct jobacctinfo *jobacct = NULL;
-	struct jobacctinfo *ret_jobacct = NULL;
-	ListIterator itr = NULL;
-
-	slurm_mutex_lock(&jobacct_lock);
-	if (!task_list) {
-		error("no task list created!");
-		goto error;
-	}
-
-	itr = list_iterator_create(task_list);
-	while((jobacct = list_next(itr))) { 
-		if(jobacct->pid == pid) {
-			list_remove(itr);
-			break;
-		}
-	}
-	list_iterator_destroy(itr);
-	if(jobacct) {
-		debug2("removing task %u pid %d from jobacct", 
-		       jobacct->max_vsize_id.taskid, jobacct->pid);
-		ret_jobacct = xmalloc(sizeof(struct jobacctinfo));
-		memcpy(ret_jobacct, jobacct, sizeof(struct jobacctinfo));
-		common_free_jobacct(jobacct);
-	} else {
-		error("pid(%d) not being watched in jobacct!", pid);
-	}
-error:
-	slurm_mutex_unlock(&jobacct_lock);
-	return ret_jobacct;
-}
-
-extern void common_suspend_poll()
-{
-	suspended = true;
-}
-
-extern void common_resume_poll()
-{
-	suspended = false;
-}
diff --git a/src/plugins/jobacct/common/jobacct_common.c b/src/plugins/jobacct/common/jobacct_common.c
deleted file mode 100644
index afa63b949d397a0fc9dc1130d9c8a874183501b8..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/common/jobacct_common.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/*****************************************************************************\
- *  jobacct_common.c - common functions for almost all jobacct plugins.
- *****************************************************************************
- *
- *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
- *  Written by Danny Auble, <da@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
- *
- *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
- *  Copyright (C) 2002 The Regents of the University of California.
-\*****************************************************************************/
-
-#include "jobacct_common.h"
-
-static void _pack_jobacct_id(jobacct_id_t *jobacct_id, Buf buffer)
-{
-	pack32((uint32_t)jobacct_id->nodeid, buffer);
-	pack16((uint16_t)jobacct_id->taskid, buffer);
-}
-
-static int _unpack_jobacct_id(jobacct_id_t *jobacct_id, Buf buffer)
-{
-	safe_unpack32(&jobacct_id->nodeid, buffer);
-	safe_unpack16(&jobacct_id->taskid, buffer);
-	return SLURM_SUCCESS;
-unpack_error:
-	return SLURM_ERROR;
-}
-
-extern int common_init_struct(struct jobacctinfo *jobacct, 
-			      jobacct_id_t *jobacct_id)
-{
-	if(!jobacct_id) {
-		jobacct_id_t temp_id;
-		temp_id.taskid = (uint16_t)NO_VAL;
-		temp_id.nodeid = (uint32_t)NO_VAL;
-		jobacct_id = &temp_id;
-	}
-	jobacct->rusage.ru_utime.tv_sec = 0;
-	jobacct->rusage.ru_utime.tv_usec = 0;
-	jobacct->rusage.ru_stime.tv_sec = 0;
-	jobacct->rusage.ru_stime.tv_usec = 0;
-	jobacct->rusage.ru_maxrss = 0;
-	jobacct->rusage.ru_ixrss = 0;
-	jobacct->rusage.ru_idrss = 0;
-	jobacct->rusage.ru_isrss = 0;
-	jobacct->rusage.ru_minflt = 0;
-	jobacct->rusage.ru_majflt = 0;
-	jobacct->rusage.ru_nswap = 0;
-	jobacct->rusage.ru_inblock = 0;
-	jobacct->rusage.ru_oublock = 0;
-	jobacct->rusage.ru_msgsnd = 0;
-	jobacct->rusage.ru_msgrcv = 0;
-	jobacct->rusage.ru_nsignals = 0;
-	jobacct->rusage.ru_nvcsw = 0;
-	jobacct->rusage.ru_nivcsw = 0;
-
-	jobacct->max_vsize = 0;
-	memcpy(&jobacct->max_vsize_id, jobacct_id, sizeof(jobacct_id_t));
-	jobacct->tot_vsize = 0;
-	jobacct->max_rss = 0;
-	memcpy(&jobacct->max_rss_id, jobacct_id, sizeof(jobacct_id_t));
-	jobacct->tot_rss = 0;
-	jobacct->max_pages = 0;
-	memcpy(&jobacct->max_pages_id, jobacct_id, sizeof(jobacct_id_t));
-	jobacct->tot_pages = 0;
-	jobacct->min_cpu = (uint32_t)NO_VAL;
-	memcpy(&jobacct->min_cpu_id, jobacct_id, sizeof(jobacct_id_t));
-	jobacct->tot_cpu = 0;
-	
-	return SLURM_SUCCESS;
-}
-
-extern struct jobacctinfo *common_alloc_jobacct(jobacct_id_t *jobacct_id)
-{
-	struct jobacctinfo *jobacct = xmalloc(sizeof(struct jobacctinfo));
-	common_init_struct(jobacct, jobacct_id);
-	return jobacct;
-}
-
-extern void common_free_jobacct(void *object)
-{
-	struct jobacctinfo *jobacct = (struct jobacctinfo *)object;
-	xfree(jobacct);
-	jobacct = NULL;
-}
-
-extern int common_setinfo(struct jobacctinfo *jobacct, 
-			  enum jobacct_data_type type, void *data)
-{
-	int rc = SLURM_SUCCESS;
-	int *fd = (int *)data;
-	uint32_t *uint32 = (uint32_t *) data;
-	jobacct_id_t *jobacct_id = (jobacct_id_t *) data;
-	struct rusage *rusage = (struct rusage *) data;
-	struct jobacctinfo *send = (struct jobacctinfo *) data;
-
-	slurm_mutex_lock(&jobacct_lock);
-	switch (type) {
-	case JOBACCT_DATA_TOTAL:
-		memcpy(jobacct, send, sizeof(struct jobacctinfo));
-		break;
-	case JOBACCT_DATA_PIPE:
-		safe_write(*fd, jobacct, sizeof(struct jobacctinfo));
-		break;
-	case JOBACCT_DATA_RUSAGE:
-		memcpy(&jobacct->rusage, rusage, sizeof(struct rusage));
-		break;
-	case JOBACCT_DATA_MAX_RSS:
-		jobacct->max_rss = *uint32;
-		break;
-	case JOBACCT_DATA_MAX_RSS_ID:
-		jobacct->max_rss_id = *jobacct_id;
-		break;
-	case JOBACCT_DATA_TOT_RSS:
-		jobacct->tot_rss = *uint32;
-		break;
-	case JOBACCT_DATA_MAX_VSIZE:
-		jobacct->max_vsize = *uint32;
-		break;
-	case JOBACCT_DATA_MAX_VSIZE_ID:
-		jobacct->max_vsize_id = *jobacct_id;
-		break;
-	case JOBACCT_DATA_TOT_VSIZE:
-		jobacct->tot_vsize = *uint32;
-		break;
-	case JOBACCT_DATA_MAX_PAGES:
-		jobacct->max_pages = *uint32;
-		break;
-	case JOBACCT_DATA_MAX_PAGES_ID:
-		jobacct->max_pages_id = *jobacct_id;
-		break;
-	case JOBACCT_DATA_TOT_PAGES:
-		jobacct->tot_pages = *uint32;
-		break;
-	case JOBACCT_DATA_MIN_CPU:
-		jobacct->min_cpu = *uint32;
-		break;
-	case JOBACCT_DATA_MIN_CPU_ID:
-		jobacct->min_cpu_id = *jobacct_id;
-		break;
-	case JOBACCT_DATA_TOT_CPU:
-		jobacct->tot_cpu = *uint32;
-		break;
-	default:
-		debug("jobacct_g_set_setinfo data_type %d invalid", 
-		      type);
-	}
-	slurm_mutex_unlock(&jobacct_lock);
-	return rc;
-rwfail:
-	slurm_mutex_unlock(&jobacct_lock);
-	return SLURM_ERROR;
-	
-}
-
-extern int common_getinfo(struct jobacctinfo *jobacct, 
-			  enum jobacct_data_type type, void *data)
-{
-	int rc = SLURM_SUCCESS;
-	int *fd = (int *)data;
-	uint32_t *uint32 = (uint32_t *) data;
-	jobacct_id_t *jobacct_id = (jobacct_id_t *) data;
-	struct rusage *rusage = (struct rusage *) data;
-	struct jobacctinfo *send = (struct jobacctinfo *) data;
-
-	slurm_mutex_lock(&jobacct_lock);
-	switch (type) {
-	case JOBACCT_DATA_TOTAL:
-		memcpy(send, jobacct, sizeof(struct jobacctinfo));
-		break;
-	case JOBACCT_DATA_PIPE:
-		safe_read(*fd, jobacct, sizeof(struct jobacctinfo));
-		break;
-	case JOBACCT_DATA_RUSAGE:
-		memcpy(rusage, &jobacct->rusage, sizeof(struct rusage));
-		break;
-	case JOBACCT_DATA_MAX_RSS:
-		*uint32 = jobacct->max_rss;
-		break;
-	case JOBACCT_DATA_MAX_RSS_ID:
-		*jobacct_id = jobacct->max_rss_id;
-		break;
-	case JOBACCT_DATA_TOT_RSS:
-		*uint32 = jobacct->tot_rss;
-		break;
-	case JOBACCT_DATA_MAX_VSIZE:
-		*uint32 = jobacct->max_vsize;
-		break;
-	case JOBACCT_DATA_MAX_VSIZE_ID:
-		*jobacct_id = jobacct->max_vsize_id;
-		break;
-	case JOBACCT_DATA_TOT_VSIZE:
-		*uint32 = jobacct->tot_vsize;
-		break;
-	case JOBACCT_DATA_MAX_PAGES:
-		*uint32 = jobacct->max_pages;
-		break;
-	case JOBACCT_DATA_MAX_PAGES_ID:
-		*jobacct_id = jobacct->max_pages_id;
-		break;
-	case JOBACCT_DATA_TOT_PAGES:
-		*uint32 = jobacct->tot_pages;
-		break;
-	case JOBACCT_DATA_MIN_CPU:
-		*uint32 = jobacct->min_cpu;
-		break;
-	case JOBACCT_DATA_MIN_CPU_ID:
-		*jobacct_id = jobacct->min_cpu_id;
-		break;
-	case JOBACCT_DATA_TOT_CPU:
-		*uint32 = jobacct->tot_cpu;
-		break;
-	default:
-		debug("jobacct_g_set_setinfo data_type %d invalid", 
-		      type);
-	}
-	slurm_mutex_unlock(&jobacct_lock);
-	return rc;
-rwfail:
-	slurm_mutex_unlock(&jobacct_lock);
-	return SLURM_ERROR;
-
-}
-
-extern void common_aggregate(struct jobacctinfo *dest, 
-			     struct jobacctinfo *from)
-{
-	xassert(dest);
-	xassert(from);
-
-	slurm_mutex_lock(&jobacct_lock);
-	if(dest->max_vsize < from->max_vsize) {
-		dest->max_vsize = from->max_vsize;
-		dest->max_vsize_id = from->max_vsize_id;
-	}
-	dest->tot_vsize += from->tot_vsize;
-	
-	if(dest->max_rss < from->max_rss) {
-		dest->max_rss = from->max_rss;
-		dest->max_rss_id = from->max_rss_id;
-	}
-	dest->tot_rss += from->tot_rss;
-	
-	if(dest->max_pages < from->max_pages) {
-		dest->max_pages = from->max_pages;
-		dest->max_pages_id = from->max_pages_id;
-	}
-	dest->tot_pages += from->tot_pages;
-	if((dest->min_cpu > from->min_cpu) 
-	   || (dest->min_cpu == (uint32_t)NO_VAL)) {
-		if(from->min_cpu == (uint32_t)NO_VAL)
-			from->min_cpu = 0;
-		dest->min_cpu = from->min_cpu;
-		dest->min_cpu_id = from->min_cpu_id;
-	}
-	dest->tot_cpu += from->tot_cpu;
-		
-	if(dest->max_vsize_id.taskid == (uint16_t)NO_VAL)
-		dest->max_vsize_id = from->max_vsize_id;
-
-	if(dest->max_rss_id.taskid == (uint16_t)NO_VAL)
-		dest->max_rss_id = from->max_rss_id;
-
-	if(dest->max_pages_id.taskid == (uint16_t)NO_VAL)
-		dest->max_pages_id = from->max_pages_id;
-
-	if(dest->min_cpu_id.taskid == (uint16_t)NO_VAL)
-		dest->min_cpu_id = from->min_cpu_id;
-
-	/* sum up all rusage stuff */
-	dest->rusage.ru_utime.tv_sec	+= from->rusage.ru_utime.tv_sec;
-	dest->rusage.ru_utime.tv_usec	+= from->rusage.ru_utime.tv_usec;
-	while (dest->rusage.ru_utime.tv_usec >= 1E6) {
-		dest->rusage.ru_utime.tv_sec++;
-		dest->rusage.ru_utime.tv_usec -= 1E6;
-	}
-	dest->rusage.ru_stime.tv_sec	+= from->rusage.ru_stime.tv_sec;
-	dest->rusage.ru_stime.tv_usec	+= from->rusage.ru_stime.tv_usec;
-	while (dest->rusage.ru_stime.tv_usec >= 1E6) {
-		dest->rusage.ru_stime.tv_sec++;
-		dest->rusage.ru_stime.tv_usec -= 1E6;
-	}
-
-	dest->rusage.ru_maxrss		+= from->rusage.ru_maxrss;
-	dest->rusage.ru_ixrss		+= from->rusage.ru_ixrss;
-	dest->rusage.ru_idrss		+= from->rusage.ru_idrss;
-	dest->rusage.ru_isrss		+= from->rusage.ru_isrss;
-	dest->rusage.ru_minflt		+= from->rusage.ru_minflt;
-	dest->rusage.ru_majflt		+= from->rusage.ru_majflt;
-	dest->rusage.ru_nswap		+= from->rusage.ru_nswap;
-	dest->rusage.ru_inblock		+= from->rusage.ru_inblock;
-	dest->rusage.ru_oublock		+= from->rusage.ru_oublock;
-	dest->rusage.ru_msgsnd		+= from->rusage.ru_msgsnd;
-	dest->rusage.ru_msgrcv		+= from->rusage.ru_msgrcv;
-	dest->rusage.ru_nsignals	+= from->rusage.ru_nsignals;
-	dest->rusage.ru_nvcsw		+= from->rusage.ru_nvcsw;
-	dest->rusage.ru_nivcsw		+= from->rusage.ru_nivcsw;
-	slurm_mutex_unlock(&jobacct_lock);	
-}
-
-extern void common_2_sacct(sacct_t *sacct, struct jobacctinfo *jobacct)
-{
-	xassert(jobacct);
-	xassert(sacct);
-	slurm_mutex_lock(&jobacct_lock);
-	sacct->max_vsize = jobacct->max_vsize;
-	sacct->max_vsize_id = jobacct->max_vsize_id;
-	sacct->ave_vsize = jobacct->tot_vsize;
-	sacct->max_rss = jobacct->max_rss;
-	sacct->max_rss_id = jobacct->max_rss_id;
-	sacct->ave_rss = jobacct->tot_rss;
-	sacct->max_pages = jobacct->max_pages;
-	sacct->max_pages_id = jobacct->max_pages_id;
-	sacct->ave_pages = jobacct->tot_pages;
-	sacct->min_cpu = jobacct->min_cpu;
-	sacct->min_cpu_id = jobacct->min_cpu_id;
-	sacct->ave_cpu = jobacct->tot_cpu;
-	slurm_mutex_unlock(&jobacct_lock);
-}
-
-extern void common_pack(struct jobacctinfo *jobacct, Buf buffer)
-{
-	int i=0;
-
-	if(!jobacct) {
-		for(i=0; i<26; i++)
-			pack32((uint32_t) 0, buffer);
-		for(i=0; i<4; i++)
-			pack16((uint16_t) 0, buffer);
-		return;
-	} 
-	slurm_mutex_lock(&jobacct_lock);
-	pack32((uint32_t)jobacct->rusage.ru_utime.tv_sec, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_utime.tv_usec, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_stime.tv_sec, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_stime.tv_usec, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_maxrss, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_ixrss, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_idrss, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_isrss, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_minflt, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_majflt, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_nswap, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_inblock, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_oublock, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_msgsnd, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_msgrcv, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_nsignals, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_nvcsw, buffer);
-	pack32((uint32_t)jobacct->rusage.ru_nivcsw, buffer);
-	pack32((uint32_t)jobacct->max_vsize, buffer);
-	pack32((uint32_t)jobacct->tot_vsize, buffer);
-	pack32((uint32_t)jobacct->max_rss, buffer);
-	pack32((uint32_t)jobacct->tot_rss, buffer);
-	pack32((uint32_t)jobacct->max_pages, buffer);
-	pack32((uint32_t)jobacct->tot_pages, buffer);
-	pack32((uint32_t)jobacct->min_cpu, buffer);
-	pack32((uint32_t)jobacct->tot_cpu, buffer);
-	_pack_jobacct_id(&jobacct->max_vsize_id, buffer);
-	_pack_jobacct_id(&jobacct->max_rss_id, buffer);
-	_pack_jobacct_id(&jobacct->max_pages_id, buffer);
-	_pack_jobacct_id(&jobacct->min_cpu_id, buffer);
-	slurm_mutex_unlock(&jobacct_lock);
-}
-
-/* you need to xfree this */
-extern int common_unpack(struct jobacctinfo **jobacct, Buf buffer)
-{
-	uint32_t uint32_tmp;
-	*jobacct = xmalloc(sizeof(struct jobacctinfo));
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_utime.tv_sec = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_utime.tv_usec = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_stime.tv_sec = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_stime.tv_usec = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_maxrss = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_ixrss = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_idrss = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_isrss = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_minflt = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_majflt = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_nswap = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_inblock = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_oublock = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_msgsnd = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_msgrcv = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_nsignals = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_nvcsw = uint32_tmp;
-	safe_unpack32(&uint32_tmp, buffer);
-	(*jobacct)->rusage.ru_nivcsw = uint32_tmp;
-	safe_unpack32(&(*jobacct)->max_vsize, buffer);
-	safe_unpack32(&(*jobacct)->tot_vsize, buffer);
-	safe_unpack32(&(*jobacct)->max_rss, buffer);
-	safe_unpack32(&(*jobacct)->tot_rss, buffer);
-	safe_unpack32(&(*jobacct)->max_pages, buffer);
-	safe_unpack32(&(*jobacct)->tot_pages, buffer);
-	safe_unpack32(&(*jobacct)->min_cpu, buffer);
-	safe_unpack32(&(*jobacct)->tot_cpu, buffer);
-	if(_unpack_jobacct_id(&(*jobacct)->max_vsize_id, buffer) 
-	   != SLURM_SUCCESS)
-		goto unpack_error;
-	if(_unpack_jobacct_id(&(*jobacct)->max_rss_id, buffer)
-	   != SLURM_SUCCESS)
-		goto unpack_error;
-	if(_unpack_jobacct_id(&(*jobacct)->max_pages_id, buffer)
-	   != SLURM_SUCCESS)
-		goto unpack_error;
-	if(_unpack_jobacct_id(&(*jobacct)->min_cpu_id, buffer)
-	   != SLURM_SUCCESS)
-		goto unpack_error;
-	return SLURM_SUCCESS;
-
-unpack_error:
-	xfree(*jobacct);
-       	return SLURM_ERROR;
-}
diff --git a/src/plugins/jobacct/common/jobacct_common.h b/src/plugins/jobacct/common/jobacct_common.h
deleted file mode 100644
index 47fc72ee1620e44eb0f4b4f8f42f1bc7053e0ff0..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/common/jobacct_common.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*****************************************************************************\
- *  jobacct_common.h - common functions for almost all jobacct plugins.
- *****************************************************************************
- *
- *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
- *  Written by Danny Auble, <da@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
- *
- *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
- *  Copyright (C) 2002 The Regents of the University of California.
-\*****************************************************************************/
-
-#ifndef _HAVE_JOBACCT_COMMON_H
-#define _HAVE_JOBACCT_COMMON_H
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <dirent.h>
-#include <sys/stat.h>
-
-#include "src/common/slurm_jobacct.h"
-#include "src/common/xmalloc.h"
-#include "src/common/list.h"
-#include "src/common/xstring.h"
-#include "src/common/node_select.h"
-
-#include "src/slurmd/common/proctrack.h"
-
-#include <ctype.h>
-
-#define BUFFER_SIZE 4096
-
-struct jobacctinfo {
-	pid_t pid;
-	struct rusage rusage; /* returned by wait3 */
-	uint32_t max_vsize; /* max size of virtual memory */
-	jobacct_id_t max_vsize_id; /* contains which task number it was on */
-	uint32_t tot_vsize; /* total virtual memory 
-			       (used to figure out ave later) */
-	uint32_t max_rss; /* max Resident Set Size */
-	jobacct_id_t max_rss_id; /* contains which task it was on */
-	uint32_t tot_rss; /* total rss 
-			     (used to figure out ave later) */
-	uint32_t max_pages; /* max pages */
-	jobacct_id_t max_pages_id; /* contains which task it was on */
-	uint32_t tot_pages; /* total pages
-			     (used to figure out ave later) */ 
-	uint32_t min_cpu; /* min cpu time */
-	jobacct_id_t min_cpu_id; /* contains which task it was on */
-	uint32_t tot_cpu; /* total cpu time 
-				 (used to figure out ave later) */
-};
-
-/* Define jobacctinfo_t below to avoid including extraneous slurm headers */
-#ifndef __jobacctinfo_t_defined
-#  define  __jobacctinfo_t_defined
-   typedef struct jobacctinfo *jobacctinfo_t;     /* opaque data type */
-#endif
-
-
-/* in jobacct_common.c */
-extern int common_init_struct(struct jobacctinfo *jobacct, 
-			      jobacct_id_t *jobacct_id);
-extern struct jobacctinfo *common_alloc_jobacct(jobacct_id_t *jobacct_id);
-extern void common_free_jobacct(void *object);
-extern int common_setinfo(struct jobacctinfo *jobacct, 
-			  enum jobacct_data_type type, void *data);
-extern int common_getinfo(struct jobacctinfo *jobacct, 
-			  enum jobacct_data_type type, void *data);
-extern void common_aggregate(struct jobacctinfo *dest, 
-			     struct jobacctinfo *from);
-extern void common_2_sacct(sacct_t *sacct, struct jobacctinfo *jobacct);
-extern void common_pack(struct jobacctinfo *jobacct, Buf buffer);
-extern int common_unpack(struct jobacctinfo **jobacct, Buf buffer);
-
-/* in common_slurmctld.c */
-extern int common_init_slurmctld(char *job_acct_log);
-extern int common_fini_slurmctld();
-extern int common_job_start_slurmctld(struct job_record *job_ptr);
-extern int common_job_complete_slurmctld(struct job_record *job_ptr);
-extern int common_step_start_slurmctld(struct step_record *step);
-extern int common_step_complete_slurmctld(struct step_record *step);
-extern int common_suspend_slurmctld(struct job_record *job_ptr);
-
-/* in common_slurmstepd.c */
-extern int common_endpoll();
-extern int common_set_proctrack_container_id(uint32_t id);
-extern int common_add_task(pid_t pid, jobacct_id_t *jobacct_id);
-extern struct jobacctinfo *common_stat_task(pid_t pid);
-extern struct jobacctinfo *common_remove_task(pid_t pid);
-extern void common_suspend_poll();
-extern void common_resume_poll();
-
-/* defined in common_slurmstepd.c */
-extern bool jobacct_shutdown;
-extern bool suspended;
-extern List task_list;
-extern pthread_mutex_t jobacct_lock;
-extern uint32_t cont_id;
-extern bool pgid_plugin;
-
-#endif
diff --git a/src/plugins/jobacct/gold/Makefile.am b/src/plugins/jobacct/gold/Makefile.am
deleted file mode 100644
index 8352b6cfe46e3e3e82ba168eaf6ff9423bb3bec1..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/gold/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
-# Makefile for jobacct/none plugin
-
-AUTOMAKE_OPTIONS = foreign
-
-PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
-
-# Gold job completion logging plugin.
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-
-pkglib_LTLIBRARIES = jobacct_gold.la
-jobacct_gold_la_SOURCES = \
-			agent.c agent.h \
-			base64.c base64.h \
-			gold_interface.c gold_interface.h \
-			jobacct_gold.c
-jobacct_gold_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-
-
diff --git a/src/plugins/jobacct/gold/agent.c b/src/plugins/jobacct/gold/agent.c
deleted file mode 100644
index 5e4ce97a5840fe18c9f1498c39799ca6342ee14b..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/gold/agent.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/****************************************************************************\
- *  agent.c - Agent to queue and process pending Gold requests
- *  Largely copied from src/common/slurmdbd_defs.c in Slurm v1.3
- *****************************************************************************
- *  Copyright (C) 2008 Lawrence Livermore National Security.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H 
-#  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
-
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <syslog.h>
-#include <sys/poll.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "agent.h"
-#include "slurm/slurm_errno.h"
-#include "src/common/fd.h"
-#include "src/common/pack.h"
-#include "src/common/slurm_auth.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xsignal.h"
-#include "src/common/xstring.h"
-
-#define _DEBUG		0
-#define GOLD_MAGIC	0xDEAD3219
-#define MAX_AGENT_QUEUE	10000
-#define MAX_GOLD_MSG_LEN 16384
-
-static pthread_mutex_t agent_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  agent_cond = PTHREAD_COND_INITIALIZER;
-static List      agent_list     = (List) NULL;
-static pthread_t agent_tid      = 0;
-static time_t    agent_shutdown = 0;
-
-static void * _agent(void *x);
-static void   _agent_queue_del(void *x);
-static void   _create_agent(void);
-static Buf    _load_gold_rec(int fd);
-static void   _load_gold_state(void);
-static int    _process_msg(Buf buffer);
-static int    _save_gold_rec(int fd, Buf buffer);
-static void   _save_gold_state(void);
-static void   _sig_handler(int signal);
-static void   _shutdown_agent(void);
-
-/****************************************************************************
- * External APIs for use by jobacct_gold.c
- ****************************************************************************/
-
-/* Initiated a Gold message agent. Recover any saved RPCs. */
-extern int gold_agent_init(void)
-{
-	slurm_mutex_lock(&agent_lock);
-	if ((agent_tid == 0) || (agent_list == NULL))
-		_create_agent();
-	slurm_mutex_unlock(&agent_lock);
-
-	return SLURM_SUCCESS;
-}
-
-/* Terminate a Gold message agent. Save any pending RPCs. */
-extern int gold_agent_fini(void)
-{
-	/* NOTE: agent_lock not needed for _shutdown_agent() */
-	_shutdown_agent();
-
-	return SLURM_SUCCESS;
-}
-
-/* Send an RPC to the Gold. Do not wait for the reply. The RPC
- * will be queued and processed later if Gold is not responding.
- * Returns SLURM_SUCCESS or an error code */
-extern int gold_agent_xmit(gold_agent_msg_t *req)
-{
-	Buf buffer;
-	int cnt, rc = SLURM_SUCCESS;
-	static time_t syslog_time = 0;
-
-	buffer = init_buf(MAX_GOLD_MSG_LEN);
-	pack16(req->msg_type, buffer);
-	switch (req->msg_type) {
-		case GOLD_MSG_CLUSTER_PROCS:
-			gold_agent_pack_cluster_procs_msg(
-				(gold_cluster_procs_msg_t *) req->data, buffer);
-			break;
-		case GOLD_MSG_JOB_COMPLETE:
-			gold_agent_pack_job_info_msg(
-				(gold_job_info_msg_t *) req->data, buffer);
-			break;
-		case GOLD_MSG_JOB_START:
-			gold_agent_pack_job_info_msg(
-				(gold_job_info_msg_t *) req->data, buffer);
-			break;
-		case GOLD_MSG_NODE_DOWN:
-			gold_agent_pack_node_down_msg(
-				(gold_node_down_msg_t *) req->data, buffer);
-			break;
-		case GOLD_MSG_NODE_UP:
-			gold_agent_pack_node_up_msg(
-				(gold_node_up_msg_t *) req->data, buffer);
-			break;
-		case GOLD_MSG_STEP_START:
-			gold_agent_pack_job_info_msg(
-				(gold_job_info_msg_t *) req->data, buffer);
-			break;
-		default:
-			error("gold: Invalid message send type %u",
-			      req->msg_type);
-			free_buf(buffer);
-			return SLURM_ERROR;
-	}
-
-	slurm_mutex_lock(&agent_lock);
-	if ((agent_tid == 0) || (agent_list == NULL)) {
-		_create_agent();
-		if ((agent_tid == 0) || (agent_list == NULL)) {
-			slurm_mutex_unlock(&agent_lock);
-			free_buf(buffer);
-			return SLURM_ERROR;
-		}
-	}
-	cnt = list_count(agent_list);
-#if _DEBUG
-        info("gold agent: queuing msg_type %u queue_len %d", 
-	     req->msg_type, cnt);
-#endif
-	if ((cnt >= (MAX_AGENT_QUEUE / 2)) &&
-	    (difftime(time(NULL), syslog_time) > 120)) {
-		/* Log critical error every 120 seconds */
-		syslog_time = time(NULL);
-		error("gold: agent queue filling, RESTART GOLD NOW");
-		syslog(LOG_CRIT, "*** RESTART GOLD NOW ***");
-	}
-	if (cnt < MAX_AGENT_QUEUE) {
-		if (list_enqueue(agent_list, buffer) == NULL)
-			fatal("list_enqueue: memory allocation failure");
-	} else {
-		error("gold: agent queue is full, discarding request");
-		rc = SLURM_ERROR;
-	}
-	slurm_mutex_unlock(&agent_lock);
-	pthread_cond_broadcast(&agent_cond);
-	return rc;
-}
-
-/****************************************************************************
- * Functions for agent to manage queue of pending message for Gold
- ****************************************************************************/
-static void _create_agent(void)
-{
-	if (agent_list == NULL) {
-		agent_list = list_create(_agent_queue_del);
-		if (agent_list == NULL)
-			fatal("list_create: malloc failure");
-		_load_gold_state();
-	}
-
-	if (agent_tid == 0) {
-		pthread_attr_t agent_attr;
-		slurm_attr_init(&agent_attr);
-		pthread_attr_setdetachstate(&agent_attr, 
-					    PTHREAD_CREATE_DETACHED);
-		if (pthread_create(&agent_tid, &agent_attr, _agent, NULL) ||
-		    (agent_tid == 0))
-			fatal("pthread_create: %m");
-	}
-}
-
-static void _agent_queue_del(void *x)
-{
-	Buf buffer = (Buf) x;
-	free_buf(buffer);
-}
-
-static void _shutdown_agent(void)
-{
-	int i;
-
-	if (agent_tid) {
-		agent_shutdown = time(NULL);
-		pthread_cond_broadcast(&agent_cond);
-		for (i=0; ((i<10) && agent_tid); i++) {
-			sleep(1);
-			pthread_cond_broadcast(&agent_cond);
-			if (pthread_kill(agent_tid, SIGUSR1))
-				agent_tid = 0;
-		}
-		if (agent_tid) {
-			error("gold: agent failed to shutdown gracefully");
-		} else
-			agent_shutdown = 0;
-	}
-}
-
-static void *_agent(void *x)
-{
-	int cnt, rc;
-	Buf buffer;
-	struct timespec abs_time;
-	static time_t fail_time = 0;
-	int sigarray[] = {SIGUSR1, 0};
-
-	/* Prepare to catch SIGUSR1 to interrupt pending
-	 * I/O and terminate in a timely fashion. */
-	xsignal(SIGUSR1, _sig_handler);
-	xsignal_unblock(sigarray);
-
-	while (agent_shutdown == 0) {
-		slurm_mutex_lock(&agent_lock);
-		if (agent_list)
-			cnt = list_count(agent_list);
-		else
-			cnt = 0;
-		if ((cnt == 0) ||
-		    (fail_time && (difftime(time(NULL), fail_time) < 10))) {
-			abs_time.tv_sec  = time(NULL) + 10;
-			abs_time.tv_nsec = 0;
-			rc = pthread_cond_timedwait(&agent_cond, &agent_lock,
-						    &abs_time);
-			slurm_mutex_unlock(&agent_lock);
-			continue;
-		} else if ((cnt > 0) && ((cnt % 50) == 0))
-			info("gold: agent queue size %u", cnt);
-		/* Leave item on the queue until processing complete */
-		if (agent_list)
-			buffer = (Buf) list_peek(agent_list);
-		else
-			buffer = NULL;
-		slurm_mutex_unlock(&agent_lock);
-		if (buffer == NULL)
-			continue;
-
-		/* NOTE: agent_lock is clear here, so we can add more
-		 * requests to the queue while waiting for this RPC to 
-		 * complete. */
-		rc = _process_msg(buffer);
-		if (rc != SLURM_SUCCESS) {
-			if (agent_shutdown)
-				break;
-			error("gold: Failure sending message");
-		}
-
-		slurm_mutex_lock(&agent_lock);
-		if (agent_list && (rc != EAGAIN)) {
-			buffer = (Buf) list_dequeue(agent_list);
-			free_buf(buffer);
-			fail_time = 0;
-		} else {
-			fail_time = time(NULL);
-		}
-		slurm_mutex_unlock(&agent_lock);
-	}
-
-	slurm_mutex_lock(&agent_lock);
-	_save_gold_state();
-	if (agent_list) {
-		list_destroy(agent_list);
-		agent_list = NULL;
-	}
-	slurm_mutex_unlock(&agent_lock);
-	return NULL;
-}
-
-static int _process_msg(Buf buffer)
-{
-	int rc;
-	uint16_t msg_type;
-	uint32_t msg_size;
-
-	/* We save the full buffer size in case the RPC fails 
-	 * and we need to save state for later recovery. */ 
-	msg_size = get_buf_offset(buffer);
-	set_buf_offset(buffer, 0);
-	safe_unpack16(&msg_type, buffer);
-#if _DEBUG
-	info("gold agent: processing msg_type %u", msg_type);
-#endif
-	switch (msg_type) {
-		case GOLD_MSG_CLUSTER_PROCS:
-			rc = agent_cluster_procs(buffer);
-			break;
-		case GOLD_MSG_JOB_COMPLETE:
-			rc = agent_job_complete(buffer);
-			break;
-		case GOLD_MSG_JOB_START:
-			rc = agent_job_start(buffer);
-			break;
-		case GOLD_MSG_NODE_DOWN:
-			rc = agent_node_down(buffer);
-			break;
-		case GOLD_MSG_NODE_UP:
-			rc = agent_node_up(buffer);
-			break;
-		case GOLD_MSG_STEP_START:
-			rc = agent_step_start(buffer);
-			break;
-		default:
-			error("gold: Invalid send message type %u", msg_type);
-			rc = SLURM_ERROR;	/* discard entry and continue */
-	}
-	set_buf_offset(buffer, msg_size);	/* restore buffer size */
-	return rc;
-
-unpack_error:
-	/* If the message format is bad return SLURM_SUCCESS to get
-	 * it off of the queue since we can't work with it anyway */
-	error("gold agent: message unpack error");
-	return SLURM_ERROR;
-}
-
-static void _save_gold_state(void)
-{
-	char *gold_fname;
-	Buf buffer;
-	int fd, rc, wrote = 0;
-
-	gold_fname = slurm_get_state_save_location();
-	xstrcat(gold_fname, "/gold.messages");
-	fd = open(gold_fname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-	if (fd < 0) {
-		error("gold: Creating state save file %s", gold_fname);
-	} else if (agent_list) {
-		while ((buffer = list_dequeue(agent_list))) {
-			rc = _save_gold_rec(fd, buffer);
-			free_buf(buffer);
-			if (rc != SLURM_SUCCESS)
-				break;
-			wrote++;
-		}
-	}
-	if (fd >= 0) {
-		verbose("gold: saved %d pending RPCs", wrote);
-		(void) close(fd);
-	}
-	xfree(gold_fname);
-}
-
-static void _load_gold_state(void)
-{
-	char *gold_fname;
-	Buf buffer;
-	int fd, recovered = 0;
-
-	gold_fname = slurm_get_state_save_location();
-	xstrcat(gold_fname, "/gold.messages");
-	fd = open(gold_fname, O_RDONLY);
-	if (fd < 0) {
-		error("gold: Opening state save file %s", gold_fname);
-	} else {
-		while (1) {
-			buffer = _load_gold_rec(fd);
-			if (buffer == NULL)
-				break;
-			if (list_enqueue(agent_list, buffer) == NULL)
-				fatal("gold: list_enqueue, no memory");
-			recovered++;
-		}
-	}
-	if (fd >= 0) {
-		verbose("gold: recovered %d pending RPCs", recovered);
-		(void) close(fd);
-		(void) unlink(gold_fname);	/* clear save state */
-	}
-	xfree(gold_fname);
-}
-
-static int _save_gold_rec(int fd, Buf buffer)
-{
-	ssize_t size, wrote;
-	uint32_t msg_size = get_buf_offset(buffer);
-	uint32_t magic = GOLD_MAGIC;
-	char *msg = get_buf_data(buffer);
-
-	size = sizeof(msg_size);
-	wrote = write(fd, &msg_size, size);
-	if (wrote != size) {
-		error("gold: state save error: %m");
-		return SLURM_ERROR;
-	}
-
-	wrote = 0;
-	while (wrote < msg_size) {
-		wrote = write(fd, msg, msg_size);
-		if (wrote > 0) {
-			msg += wrote;
-			msg_size -= wrote;
-		} else if ((wrote == -1) && (errno == EINTR))
-			continue;
-		else {
-			error("gold: state save error: %m");
-			return SLURM_ERROR;
-		}
-	}	
-
-	size = sizeof(magic);
-	wrote = write(fd, &magic, size);
-	if (wrote != size) {
-		error("gold: state save error: %m");
-		return SLURM_ERROR;
-	}
-
-	return SLURM_SUCCESS;
-}
-
-static Buf _load_gold_rec(int fd)
-{
-	ssize_t size, rd_size;
-	uint32_t msg_size, magic;
-	char *msg;
-	Buf buffer;
-
-	size = sizeof(msg_size);
-	rd_size = read(fd, &msg_size, size);
-	if (rd_size == 0)
-		return (Buf) NULL;
-	if (rd_size != size) {
-		error("gold: state recover error: %m");
-		return (Buf) NULL;
-	}
-	if (msg_size > MAX_GOLD_MSG_LEN) {
-		error("gold: state recover error, msg_size=%u", msg_size);
-		return (Buf) NULL;
-	}
-
-	buffer = init_buf((int) msg_size);
-	if (buffer == NULL)
-		fatal("gold: create_buf malloc failure");
-	set_buf_offset(buffer, msg_size);
-	msg = get_buf_data(buffer);
-	size = msg_size;
-	while (size) {
-		rd_size = read(fd, msg, size);
-		if (rd_size > 0) {
-			msg += rd_size;
-			size -= rd_size;
-		} else if ((rd_size == -1) && (errno == EINTR))
-			continue;
-		else {
-			error("gold: state recover error: %m");
-			free_buf(buffer);
-			return (Buf) NULL;
-		}
-	}
-
-	size = sizeof(magic);
-	rd_size = read(fd, &magic, size);
-	if ((rd_size != size) || (magic != GOLD_MAGIC)) {
-		error("gold: state recover error");
-		free_buf(buffer);
-		return (Buf) NULL;
-	}
-
-	return buffer;
-}
-
-static void _sig_handler(int signal)
-{
-}
-
-/****************************************************************************\
- * Free data structures
-\****************************************************************************/
-void inline gold_agent_free_cluster_procs_msg(gold_cluster_procs_msg_t *msg)
-{
-	xfree(msg);
-}
-
-void inline gold_agent_free_job_info_msg(gold_job_info_msg_t *msg)
-{
-	if (msg) {
-		xfree(msg->account);
-		xfree(msg->name);
-		xfree(msg->nodes);
-		xfree(msg->partition);
-		xfree(msg);
-	}
-}
-
-void inline gold_agent_free_node_down_msg(gold_node_down_msg_t *msg)
-{
-	if (msg) {
-		xfree(msg->hostlist);
-		xfree(msg->reason);
-		xfree(msg);
-	}
-}
-
-void inline gold_agent_free_node_up_msg(gold_node_up_msg_t *msg)
-{
-	if (msg) {
-		xfree(msg->hostlist);
-		xfree(msg);
-	}
-}
-
-/****************************************************************************\
- * Pack and unpack data structures
-\****************************************************************************/
-void inline
-gold_agent_pack_cluster_procs_msg(gold_cluster_procs_msg_t *msg, Buf buffer)
-{
-	pack32(msg->proc_count,    buffer);
-	pack_time(msg->event_time, buffer);
-}
-int inline
-gold_agent_unpack_cluster_procs_msg(gold_cluster_procs_msg_t **msg, Buf buffer)
-{
-	gold_cluster_procs_msg_t *msg_ptr;
-
-	msg_ptr = xmalloc(sizeof(gold_cluster_procs_msg_t));
-	*msg = msg_ptr;
-	safe_unpack32(&msg_ptr->proc_count, buffer);
-	safe_unpack_time(&msg_ptr->event_time, buffer);
-	return SLURM_SUCCESS;
-
-unpack_error:
-	xfree(msg_ptr);
-	*msg = NULL;
-	return SLURM_ERROR;
-}
-
-void inline 
-gold_agent_pack_job_info_msg(gold_job_info_msg_t *msg, Buf buffer)
-{
-	packstr(msg->account, buffer);
-	pack_time(msg->begin_time, buffer);
-	pack_time(msg->end_time, buffer);
-	pack32(msg->exit_code, buffer);
-	pack32(msg->job_id, buffer);
-	pack16(msg->job_state, buffer);
-	packstr(msg->name, buffer);
-	packstr(msg->nodes, buffer);
-	packstr(msg->partition, buffer);
-	pack_time(msg->start_time, buffer);
-	pack_time(msg->submit_time, buffer);
-	pack32(msg->total_procs, buffer);
-	pack32(msg->user_id, buffer);
-}
-
-int inline 
-gold_agent_unpack_job_info_msg(gold_job_info_msg_t **msg, Buf buffer)
-{
-	uint16_t uint16_tmp;
-	gold_job_info_msg_t *msg_ptr = xmalloc(sizeof(gold_job_info_msg_t));
-	*msg = msg_ptr;
-	safe_unpackstr_xmalloc(&msg_ptr->account, &uint16_tmp, buffer);
-	safe_unpack_time(&msg_ptr->begin_time, buffer);
-	safe_unpack_time(&msg_ptr->end_time, buffer);
-	safe_unpack32(&msg_ptr->exit_code, buffer);
-	safe_unpack32(&msg_ptr->job_id, buffer);
-	safe_unpack16(&msg_ptr->job_state, buffer);
-	safe_unpackstr_xmalloc(&msg_ptr->name, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&msg_ptr->nodes, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&msg_ptr->partition, &uint16_tmp, buffer);
-	safe_unpack_time(&msg_ptr->start_time, buffer);
-	safe_unpack_time(&msg_ptr->submit_time, buffer);
-	safe_unpack32(&msg_ptr->total_procs, buffer);
-	safe_unpack32(&msg_ptr->user_id, buffer);
-	return SLURM_SUCCESS;
-
-unpack_error:
-	xfree(msg_ptr->account);
-	xfree(msg_ptr->name);
-	xfree(msg_ptr->nodes);
-	xfree(msg_ptr->partition);
-	xfree(msg_ptr);
-	*msg = NULL;
-	return SLURM_ERROR;
-}
-
-void inline 
-gold_agent_pack_node_down_msg(gold_node_down_msg_t *msg, Buf buffer)
-{
-	pack16(msg->cpus, buffer);
-	pack_time(msg->event_time, buffer);
-	packstr(msg->hostlist, buffer);
-	packstr(msg->reason, buffer);
-}
-
-int inline
-gold_agent_unpack_node_down_msg(gold_node_down_msg_t **msg, Buf buffer)
-{
-	gold_node_down_msg_t *msg_ptr;
-	uint16_t uint16_tmp;
-
-	msg_ptr = xmalloc(sizeof(gold_node_down_msg_t));
-	*msg = msg_ptr;
-	safe_unpack16(&msg_ptr->cpus, buffer);
-	safe_unpack_time(&msg_ptr->event_time, buffer);
-	safe_unpackstr_xmalloc(&msg_ptr->hostlist, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&msg_ptr->reason,   &uint16_tmp, buffer);
-	return SLURM_SUCCESS;
-
-unpack_error:
-	xfree(msg_ptr->hostlist);
-	xfree(msg_ptr->reason);
-	xfree(msg_ptr);
-	*msg = NULL;
-	return SLURM_ERROR;
-}
-
-void inline 
-gold_agent_pack_node_up_msg(gold_node_up_msg_t *msg, Buf buffer)
-{
-	pack_time(msg->event_time, buffer);
-	packstr(msg->hostlist, buffer);
-}
-
-int inline
-gold_agent_unpack_node_up_msg(gold_node_up_msg_t **msg, Buf buffer)
-{
-	gold_node_up_msg_t *msg_ptr;
-	uint16_t uint16_tmp;
-
-	msg_ptr = xmalloc(sizeof(gold_node_up_msg_t));
-	*msg = msg_ptr;
-	safe_unpack_time(&msg_ptr->event_time, buffer);
-	safe_unpackstr_xmalloc(&msg_ptr->hostlist, &uint16_tmp, buffer);
-	return SLURM_SUCCESS;
-
-unpack_error:
-	xfree(msg_ptr->hostlist);
-	xfree(msg_ptr);
-	*msg = NULL;
-	return SLURM_ERROR;
-}
diff --git a/src/plugins/jobacct/gold/agent.h b/src/plugins/jobacct/gold/agent.h
deleted file mode 100644
index 13df748262204265c1d3218cb9fc24070700caf7..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/gold/agent.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************\
- *  agent.h - Definitions used to queue and process pending Gold requests
- *  Largely copied from src/common/slurmdbd_defs.h in Slurm v1.3
- *****************************************************************************
- *  Copyright (C) 2008 Lawrence Livermore National Security.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#ifndef _GOLD_AGENT_H
-#define _GOLD_AGENT_H
-
-#if HAVE_CONFIG_H 
-#  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
-
-#include "src/common/pack.h"
-
-/* Increment SLURM_DBD_VERSION if any of the RPCs change */
-#define SLURM_DBD_VERSION 01
-
-/* SLURM DBD message types */
-typedef enum {
-	GOLD_MSG_INIT = 1400,	/* Connection initialization		*/
-	GOLD_MSG_CLUSTER_PROCS,	/* Record tota processors on cluster	*/
-	GOLD_MSG_JOB_COMPLETE,	/* Record job completion 		*/
-	GOLD_MSG_JOB_START,	/* Record job starting			*/
-	GOLD_MSG_NODE_DOWN,	/* Record node state going DOWN		*/
-	GOLD_MSG_NODE_UP,	/* Record node state coming UP		*/
-	GOLD_MSG_STEP_START	/* Record step starting			*/
-} slurm_gold_msg_type_t;
-
-/*****************************************************************************\
- * Slurm DBD protocol data structures
-\*****************************************************************************/
-
-typedef struct gold_agent_msg {
-	uint16_t msg_type;	/* see gold_agent_msg_type_t above */
-	void * data;		/* pointer to a message type below */
-} gold_agent_msg_t;
-
-typedef struct gold_cluster_procs_msg {
-	uint32_t proc_count;	/* total processor count */
-	time_t event_time;	/* time of transition */
-} gold_cluster_procs_msg_t;
-
-typedef struct gold_job_info_msg {
-	char *   account;	/* bank account for job */
-	time_t   begin_time;	/* time job becomes eligible to run */
-	time_t   end_time;	/* job termintation time */
-	uint32_t exit_code;	/* job exit code or signal */
-	uint32_t job_id;	/* job ID */
-	uint16_t job_state;	/* job state */
-	char *   name;		/* job name */
-	char *   nodes;		/* hosts allocated to the job */
-	char *   partition;	/* job's partition */
-	time_t   start_time;	/* job start time */
-	time_t   submit_time;	/* job submit time */
-	uint32_t total_procs;	/* count of allocated processors */
-	uint32_t user_id;	/* owner's UID */
-} gold_job_info_msg_t;
-
-typedef struct gold_node_down_msg {
-	uint16_t cpus;		/* processors on the node */
-	time_t event_time;	/* time of transition */
-	char *hostlist;		/* name of hosts */
-	char *reason;		/* explanation for the node's state */
-} gold_node_down_msg_t;
-
-
-typedef struct gold_node_up_msg {
-	time_t event_time;	/* time of transition */
-	char *hostlist;		/* name of hosts */
-} gold_node_up_msg_t;
-
-/*****************************************************************************\
- * Slurm DBD message processing functions
-\*****************************************************************************/
-
-/* Initiated a Gold message agent. Recover any saved RPCs. */
-extern int gold_agent_init(void);
-
-/* Terminate a Gold message agent. Save any pending RPCs. */
-extern int gold_agent_fini(void);
-
-/* Send an RPC to the Gold. Do not wait for the reply. The RPC
- * will be queued and processed later if Gold is not responding.
- * Returns SLURM_SUCCESS or an error code */
-extern int gold_agent_xmit(gold_agent_msg_t *req);
-
-/*****************************************************************************\
- * Functions for processing the Gold requests, located in jobacct_gold.c
-\*****************************************************************************/
-/* For all functions below
- * RET SLURM_SUCCESS on success 
- *     SLURM_ERROR on non-recoverable error (e.g. invalid account ID)
- *     EAGAIN on recoverable error (e.g. Gold not responding) */
-extern int agent_cluster_procs(Buf buffer);
-extern int agent_job_start(Buf buffer);
-extern int agent_job_complete(Buf buffer);
-extern int agent_step_start(Buf buffer);
-extern int agent_node_down(Buf buffer);
-extern int agent_node_up(Buf buffer);
-
-/*****************************************************************************\
- * Free various Gold message structures
-\*****************************************************************************/
-void inline gold_agent_free_cluster_procs_msg(gold_cluster_procs_msg_t *msg);
-void inline gold_agent_free_job_info_msg(gold_job_info_msg_t *msg);
-void inline gold_agent_free_node_down_msg(gold_node_down_msg_t *msg);
-void inline gold_agent_free_node_up_msg(gold_node_up_msg_t *msg);
-
-/*****************************************************************************\
- * Pack various Gold message structures into a buffer
-\*****************************************************************************/
-void inline gold_agent_pack_cluster_procs_msg(gold_cluster_procs_msg_t *msg,
-								     Buf buffer);
-void inline gold_agent_pack_job_info_msg(gold_job_info_msg_t *msg,   Buf buffer);
-void inline gold_agent_pack_node_down_msg(gold_node_down_msg_t *msg, Buf buffer);
-void inline gold_agent_pack_node_up_msg(gold_node_up_msg_t *msg,     Buf buffer);
-
-/*****************************************************************************\
- * Unpack various Gold message structures from a buffer
-\*****************************************************************************/
-int inline gold_agent_unpack_cluster_procs_msg(gold_cluster_procs_msg_t **msg,
-								     Buf buffer);
-int inline gold_agent_unpack_job_info_msg(gold_job_info_msg_t **msg, Buf buffer);
-int inline gold_agent_unpack_node_down_msg(gold_node_down_msg_t **msg, 
-								     Buf buffer);
-int inline gold_agent_unpack_node_up_msg(gold_node_up_msg_t **msg,   Buf buffer);
-
-#endif	/* !_GOLD_AGENT_H */
diff --git a/src/plugins/jobacct/gold/jobacct_gold.c b/src/plugins/jobacct/gold/jobacct_gold.c
deleted file mode 100644
index bfea65a6e7c549ee9467b77ddc4eabf8d6e8edf9..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/gold/jobacct_gold.c
+++ /dev/null
@@ -1,1133 +0,0 @@
-/*****************************************************************************\
- *  jobacct_gold.c - jobacct interface to gold.
- *****************************************************************************
- *  Copyright (C) 2004-2007 The Regents of the University of California.
- *  Copyright (C) 2008 Lawrence Livermore National Security.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Danny Auble <da@llnl.gov>
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-#include "gold_interface.h"
-#include "agent.h"
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-
-#include "src/common/list.h"
-#include "src/common/parse_time.h"
-#include "src/common/slurm_jobacct.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/uid.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/slurmctld/slurmctld.h"
-#include "src/slurmd/slurmd/slurmd.h"
-
-typedef struct {
-	char *user;
-	char *project;
-	char *machine;
-	char *gold_id;
-} gold_account_t;
-
-static int _add_edit_job(gold_job_info_msg_t *job_ptr, gold_object_t action);
-
-/*
- * These variables are required by the generic plugin interface.  If they
- * are not found in the plugin, the plugin loader will ignore it.
- *
- * plugin_name - a string giving a human-readable description of the
- * plugin.  There is no maximum length, but the symbol must refer to
- * a valid string.
- *
- * plugin_type - a string suggesting the type of the plugin or its
- * applicability to a particular form of data or method of data handling.
- * If the low-level plugin API is used, the contents of this string are
- * unimportant and may be anything.  SLURM uses the higher-level plugin
- * interface which requires this string to be of the form
- *
- *	<application>/<method>
- *
- * where <application> is a description of the intended application of
- * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
- * is a description of how this plugin satisfies that application.  SLURM will
- * only load job completion logging plugins if the plugin_type string has a 
- * prefix of "jobacct/".
- *
- * plugin_version - an unsigned 32-bit integer giving the version number
- * of the plugin.  If major and minor revisions are desired, the major
- * version number may be multiplied by a suitable magnitude constant such
- * as 100 or 1000.  Various SLURM versions will likely require a certain
- * minimum versions for their plugins as the job accounting API 
- * matures.
- */
-const char plugin_name[] = "Job accounting GOLD plugin";
-const char plugin_type[] = "jobacct/gold";
-const uint32_t plugin_version = 100;
-
-/* for this first draft we are only supporting one cluster per slurm
- * 1.3 will probably do better than this.
- */
-
-static char *cluster_name = NULL;
-static List gold_account_list = NULL;
-
-/* _check_for_job 
- * IN jobid - job id to check for 
- * IN submit - timestamp for submit time of job
- * RET 0 for not found 1 for found
- */
-
-static void _destroy_gold_account(void *object)
-{
-	gold_account_t *gold_account = (gold_account_t *) object;
-	if(gold_account) {
-		xfree(gold_account->user);
-		xfree(gold_account->project);
-		xfree(gold_account->machine);
-		xfree(gold_account->gold_id);
-		xfree(gold_account);
-	}
-}
-
-static int _check_for_job(uint32_t jobid, time_t submit) 
-{
-	gold_request_t *gold_request = create_gold_request(GOLD_OBJECT_JOB,
-							   GOLD_ACTION_QUERY);
-	gold_response_t *gold_response = NULL;
-	char tmp_buff[50];
-	int rc = 0;
-
-	if(!gold_request) 
-		return rc;
-
-	gold_request_add_selection(gold_request, "JobId");
-
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", jobid);
-	gold_request_add_condition(gold_request, "JobId", tmp_buff,
-				   GOLD_OPERATOR_NONE);
-
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", (uint32_t)submit);
-	gold_request_add_condition(gold_request, "SubmitTime", tmp_buff,
-				   GOLD_OPERATOR_NONE);
-
-	gold_response = get_gold_response(gold_request);
-	destroy_gold_request(gold_request);
-
-	if(!gold_response) {
-		error("_check_for_job: no response received");
-		return 0;
-	}
-
-	if(gold_response->entry_cnt > 0) 
-		rc = 1;
-	destroy_gold_response(gold_response);
-	
-	return rc;
-}
-
-/*
- * Get an account ID for some user/project/machine
- * RET the account ID   OR
- *     NULL on Gold communcation failure   OR
- *     "0" if there is no valid account
- */
-static char *_get_account_id(char *user, char *project, char *machine)
-{
-	gold_request_t *gold_request = NULL;
-	gold_response_t *gold_response = NULL;
-	char *gold_account_id = NULL;
-	gold_response_entry_t *resp_entry = NULL;
-	gold_name_value_t *name_val = NULL;
-	gold_account_t *gold_account = NULL;
-	ListIterator itr = list_iterator_create(gold_account_list);
-
-	while((gold_account = list_next(itr))) {
-		if(user && strcmp(gold_account->user, user))
-			continue;
-		if(project && strcmp(gold_account->project, project))
-			continue;
-		gold_account_id = xstrdup(gold_account->gold_id);
-		break;
-	}
-	list_iterator_destroy(itr);
-
-	if(gold_account_id) 
-		return gold_account_id;
-	
-	gold_request = create_gold_request(GOLD_OBJECT_ACCOUNT,
-					   GOLD_ACTION_QUERY);
-
-	gold_request_add_selection(gold_request, "Id");
-	gold_request_add_condition(gold_request, "User", user,
-				   GOLD_OPERATOR_NONE);
-	if(project)
-		gold_request_add_condition(gold_request, "Project", project,
-					   GOLD_OPERATOR_NONE);
-	gold_request_add_condition(gold_request, "Machine", machine,
-				   GOLD_OPERATOR_NONE);
-		
-	gold_response = get_gold_response(gold_request);
-	destroy_gold_request(gold_request);
-
-	if(!gold_response) {
-		error("_get_account_id: no response received");
-		return NULL;
-	}
-
-	if(gold_response->entry_cnt > 0) {
-		resp_entry = list_pop(gold_response->entries);
-		name_val = list_pop(resp_entry->name_val);
-
-		gold_account_id = xstrdup(name_val->value);
-
-		destroy_gold_name_value(name_val);
-		destroy_gold_response_entry(resp_entry);
-		/* no need to keep track of machine since this is
-		 * always going to be on the same machine.
-		 */
-		gold_account = xmalloc(sizeof(gold_account_t));
-		gold_account->user = xstrdup(user);
-		gold_account->gold_id = xstrdup(gold_account_id);
-		if(project)
-			gold_account->project = xstrdup(project);
-		list_push(gold_account_list, gold_account);
-	} else {
-		error("no account found returning 0");
-		gold_account_id = xstrdup("0");
-	}
-
-	destroy_gold_response(gold_response);
-
-	return gold_account_id;
-}
-
-/*
- * init() is called when the plugin is loaded, before any other functions
- * are called.  Put global initialization here.
- */
-extern int init ( void )
-{
-	verbose("%s loaded", plugin_name);
-	return SLURM_SUCCESS;
-}
-
-extern int fini ( void )
-{
-	return SLURM_SUCCESS;
-}
-
-/*
- * The following routines are called by slurmctld
- */
-
-/*
- * The following routines are called by slurmd
- */
-int jobacct_p_init_struct(struct jobacctinfo *jobacct, 
-			  jobacct_id_t *jobacct_id)
-{
-	return SLURM_SUCCESS;
-}
-
-struct jobacctinfo *jobacct_p_alloc(jobacct_id_t *jobacct_id)
-{
-	return NULL;
-}
-
-void jobacct_p_free(struct jobacctinfo *jobacct)
-{
-	return;
-}
-
-int jobacct_p_setinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
-{
-	return SLURM_SUCCESS;
-	
-}
-
-int jobacct_p_getinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
-{
-	return SLURM_SUCCESS;
-}
-
-void jobacct_p_aggregate(struct jobacctinfo *dest, struct jobacctinfo *from)
-{
-	return;
-}
-
-void jobacct_p_2_sacct(sacct_t *sacct, struct jobacctinfo *jobacct)
-{
-	return;
-}
-
-void jobacct_p_pack(struct jobacctinfo *jobacct, Buf buffer)
-{
-	return;
-}
-
-int jobacct_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
-{
-	return SLURM_SUCCESS;
-}
-
-
-int jobacct_p_init_slurmctld(char *gold_info)
-{
-	char *total = "localhost:/etc/gold/auth_key:localhost:7112";
-	int found = 0;
-	int i=0, j=0;
-	char *host = NULL;
-	char *keyfile = NULL;
-	uint16_t port = 0;
-
-	debug2("jobacct_init() called");
-	if(cluster_name) {
-		info("already called init");
-		return SLURM_SUCCESS;
-	}
-	if(gold_info) 
-		total = gold_info;
-
-	if(!gold_account_list) 
-		gold_account_list = list_create(_destroy_gold_account);
-
-	
-	i = 0;
-	while(total[j]) {
-		if(total[j] == ':') {
-			switch(found) {
-			case 0: // cluster_name name
-			        cluster_name = xstrndup(total+i, j-i);
-				break;
-			case 1: // keyfile name
-				keyfile = xstrndup(total+i, j-i);
-				break;
-			case 2: // host name
-				host = xstrndup(total+i, j-i);
-				break;
-			case 3: // port
-				port = atoi(total+i);
-				break;
-			}
-			found++;
-			i = j+1;	
-		}
-		j++;
-	}
-	if(!port) 
-		port = atoi(total+i);
-
-	if(!cluster_name)
-		fatal("JobAcctLogfile should be in the format of "
-		      "cluster_name:gold_auth_key_file_path:"
-		      "goldd_host:goldd_port "
-		      "bad cluster_name");
-	if (!keyfile || *keyfile != '/')
-		fatal("JobAcctLogfile should be in the format of "
-		      "cluster_name:gold_auth_key_file_path:"
-		      "goldd_host:goldd_port "
-		      "bad key file");
-	if(!host)
-		fatal("JobAcctLogfile should be in the format of "
-		      "cluster_name:gold_auth_key_file_path:"
-		      "goldd_host:goldd_port "
-		      "bad host");
-	if(!port) 
-		fatal("JobAcctLogfile should be in the format of "
-		      "cluster_name:gold_auth_key_file_path:"
-		      "goldd_host:goldd_port "
-		      "bad port");
-	
-	debug2("connecting from %s to gold with keyfile='%s' for %s(%d)",
-	       cluster_name, keyfile, host, port);
-
-	init_gold(cluster_name, keyfile, host, port);
-	gold_agent_init();
-	xfree(keyfile);
-	xfree(host);
-
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_fini_slurmctld()
-{
-	gold_agent_fini();
-	xfree(cluster_name);
-	if(gold_account_list) 
-		list_destroy(gold_account_list);
-	fini_gold();
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_job_start_slurmctld(struct job_record *job_ptr)
-{
-	gold_agent_msg_t msg;
-	gold_job_info_msg_t req;
-
-	req.account       = job_ptr->account;
-	req.begin_time    = job_ptr->details->begin_time;
-	req.end_time      = job_ptr->end_time;
-	req.exit_code     = job_ptr->exit_code;
-	req.job_id        = job_ptr->job_id;
-	req.job_state     = job_ptr->job_state;
-	req.name          = job_ptr->name;
-	req.nodes         = job_ptr->nodes;
-	req.partition     = job_ptr->partition;
-	req.start_time    = job_ptr->start_time;
-	req.submit_time   = job_ptr->details->submit_time;
-	req.total_procs   = job_ptr->details->total_procs;
-	req.user_id       = job_ptr->user_id;
-	msg.msg_type      = GOLD_MSG_JOB_START;
-	msg.data          = &req;
-
-	if (gold_agent_xmit(&msg) < 0)
-		return SLURM_ERROR;
-
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
-{
-	gold_agent_msg_t msg;
-	gold_job_info_msg_t req;
-
-	req.account       = job_ptr->account;
-	req.begin_time    = job_ptr->details->begin_time;
-	req.end_time      = job_ptr->end_time;
-	req.exit_code     = job_ptr->exit_code;
-	req.job_id        = job_ptr->job_id;
-	req.job_state     = job_ptr->job_state;
-	req.name          = job_ptr->name;
-	req.nodes         = job_ptr->nodes;
-	req.partition     = job_ptr->partition;
-	req.start_time    = job_ptr->start_time;
-	req.submit_time   = job_ptr->details->submit_time;
-	req.total_procs   = job_ptr->details->total_procs;
-	req.user_id       = job_ptr->user_id;
-	msg.msg_type      = GOLD_MSG_JOB_COMPLETE;
-	msg.data          = &req;
-
-	if (gold_agent_xmit(&msg) < 0)
-		return SLURM_ERROR;
-
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_step_start_slurmctld(struct step_record *step)
-{
-	gold_agent_msg_t msg;
-	gold_job_info_msg_t req;
-	struct job_record *job_ptr = step->job_ptr;
-
-	req.account       = job_ptr->account;
-	req.begin_time    = job_ptr->details->begin_time;
-	req.end_time      = job_ptr->end_time;
-	req.exit_code     = job_ptr->exit_code;
-	req.job_id        = job_ptr->job_id;
-	req.job_state     = job_ptr->job_state;
-	req.name          = job_ptr->name;
-	req.nodes         = job_ptr->nodes;
-	req.partition     = job_ptr->partition;
-	req.start_time    = job_ptr->start_time;
-	req.submit_time   = job_ptr->details->submit_time;
-	req.total_procs   = job_ptr->details->total_procs;
-	req.user_id       = job_ptr->user_id;
-	msg.msg_type      = GOLD_MSG_STEP_START;
-	msg.data          = &req;
-
-	if (gold_agent_xmit(&msg) < 0)
-		return SLURM_ERROR;
-
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_step_complete_slurmctld(struct step_record *step)
-{
-	return SLURM_SUCCESS;	
-}
-
-int jobacct_p_suspend_slurmctld(struct job_record *job_ptr)
-{
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_startpoll(int frequency)
-{
-	info("jobacct GOLD plugin loaded");
-	debug3("slurmd_jobacct_init() called");
-	
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_endpoll()
-{
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_set_proctrack_container_id(uint32_t id)
-{
-	return SLURM_SUCCESS;
-}
-
-int jobacct_p_add_task(pid_t pid, jobacct_id_t *jobacct_id)
-{
-	return SLURM_SUCCESS;
-}
-
-struct jobacctinfo *jobacct_p_stat_task(pid_t pid)
-{
-	return NULL;
-}
-
-struct jobacctinfo *jobacct_p_remove_task(pid_t pid)
-{
-	return NULL;
-}
-
-void jobacct_p_suspend_poll()
-{
-	return;
-}
-
-void jobacct_p_resume_poll()
-{
-	return;
-}
-
-#define _DEBUG 0
-
-extern int jobacct_p_node_down(struct node_record *node_ptr, time_t event_time,
-			       char *reason)
-{
-	gold_agent_msg_t msg;
-	gold_node_down_msg_t req;
-	uint16_t cpus;
-
-	if (slurmctld_conf.fast_schedule)
-		cpus = node_ptr->config_ptr->cpus;
-	else
-		cpus = node_ptr->cpus;
-	if (reason == NULL)
-		reason = node_ptr->reason;
-#if _DEBUG
-{
-	char tmp_buff[50];
-	slurm_make_time_str(&event_time, tmp_buff, sizeof(tmp_buff));
-	info("jobacct_p_node_down: %s at %s with %u cpus due to %s", 
-	     node_ptr->name, tmp_buff, cpus, reason);
-}
-#endif
-	req.cpus         = cpus;
-	req.event_time   = event_time;
-	req.hostlist     = node_ptr->name;
-	req.reason       = reason;
-	msg.msg_type     = GOLD_MSG_NODE_DOWN;
-	msg.data         = &req;
-
-	if (gold_agent_xmit(&msg) < 0)
-		return SLURM_ERROR;
-
-	return SLURM_SUCCESS;
-}
-
-extern int jobacct_p_node_up(struct node_record *node_ptr, time_t event_time)
-{
-	gold_agent_msg_t msg;
-	gold_node_up_msg_t req;
-
-#if _DEBUG
-{
-	char tmp_buff[50];
-	slurm_make_time_str(&event_time, tmp_buff, sizeof(tmp_buff));
-	info("jobacct_p_node_up: %s at %s", node_ptr->name, tmp_buff);
-}
-#endif
-
-	req.hostlist     = node_ptr->name;
-	req.event_time   = event_time;
-	msg.msg_type     = GOLD_MSG_NODE_UP;
-	msg.data         = &req;
-
-	if (gold_agent_xmit(&msg) < 0)
-		return SLURM_ERROR;
-
-	return SLURM_SUCCESS;
-}
-
-extern int jobacct_p_cluster_procs(uint32_t procs, time_t event_time)
-{
-	static uint32_t last_procs = 0;
-	gold_agent_msg_t msg;
-	gold_cluster_procs_msg_t req;
-
-#if _DEBUG
-{
-	char tmp_buff[50];
-	slurm_make_time_str(&event_time, tmp_buff, sizeof(tmp_buff));
-	info("jobacct_p_cluster_procs: %s has %u total CPUs at %s", 
-	     cluster_name, procs, tmp_buff);
-}
-#endif
-	if (procs == last_procs) {
-		debug3("jobacct_p_cluster_procs: no change in proc count");
-		return SLURM_SUCCESS;
-	}
-	last_procs = procs;
-
-	req.proc_count		= procs;
-	req.event_time		= event_time;
-	msg.msg_type		= GOLD_MSG_CLUSTER_PROCS;
-	msg.data		= &req;
-
-	if (gold_agent_xmit(&msg) < 0)
-		return SLURM_ERROR;
-
-	return SLURM_SUCCESS;
-}
-
-/*
- * Functions that process queued Gold requests
- */
-extern int agent_job_start(Buf buffer)
-{
-	int rc;
-	gold_job_info_msg_t *job_info_msg;
-	gold_object_t action;
-
-	if (gold_agent_unpack_job_info_msg(&job_info_msg, buffer) !=
-	    SLURM_SUCCESS) {
-		error("Failed to unpack GOLD_MSG_JOB_START message");
-		return SLURM_ERROR;
-	}
-
-	if (_check_for_job(job_info_msg->job_id, 
-			   job_info_msg->submit_time)) {
-		error("Job %u is already in GOLD, overwrite old info",
-		      job_info_msg->job_id);
-		action = GOLD_ACTION_MODIFY;
-	} else {
-		action = GOLD_ACTION_CREATE;
-	}
-
-	rc = _add_edit_job(job_info_msg, action);
-	gold_agent_free_job_info_msg(job_info_msg);
-	return rc;
-}
-
-extern int agent_job_complete(Buf buffer)
-{
-	int rc;
-	gold_job_info_msg_t *job_info_msg;
-	gold_object_t action;
-
-	if (gold_agent_unpack_job_info_msg(&job_info_msg, buffer) !=
-	    SLURM_SUCCESS) {
-		error("Failed to unpack GOLD_MSG_JOB_COMPLETE message");
-		return SLURM_ERROR;
-	}
-
-	if (_check_for_job(job_info_msg->job_id, 
-			   job_info_msg->submit_time)) {
-		action = GOLD_ACTION_MODIFY;
-	} else {
-		error("Job %u is missing from GOLD, creating new record",
-		      job_info_msg->job_id);
-		action = GOLD_ACTION_CREATE;
-	}
-
-	rc = _add_edit_job(job_info_msg, action);
-	gold_agent_free_job_info_msg(job_info_msg);
-	return rc;
-}
-
-extern int agent_step_start(Buf buffer)
-{
-	int rc;
-	gold_job_info_msg_t *job_info_msg;
-	gold_object_t action;
-
-	if (gold_agent_unpack_job_info_msg(&job_info_msg, buffer) !=
-	    SLURM_SUCCESS) {
-		error("Failed to unpack GOLD_MSG_STEP_START message");
-		return SLURM_ERROR;
-	}
-
-	if (_check_for_job(job_info_msg->job_id, 
-			   job_info_msg->submit_time)) {
-		action = GOLD_ACTION_MODIFY;
-	} else {
-		error("Job %u is missing from GOLD, creating new record",
-		      job_info_msg->job_id);
-		action = GOLD_ACTION_CREATE;
-	}
-
-	rc = _add_edit_job(job_info_msg, action);
-	gold_agent_free_job_info_msg(job_info_msg);
-	return rc;
-}
-
-/*
- * Update a job entry
- * RET SLURM_SUCCESS on success 
- *     SLURM_ERROR on non-recoverable error (e.g. invalid account ID)
- *     EAGAIN on recoverable error (e.g. Gold not responding)
- */
-static int _add_edit_job(gold_job_info_msg_t *job_ptr, gold_object_t action)
-{
-	gold_request_t *gold_request = create_gold_request(GOLD_OBJECT_JOB,
-							   action);
-	gold_response_t *gold_response = NULL;
-	char tmp_buff[50];
-	int rc = SLURM_ERROR;
-	char *gold_account_id = NULL;
-	char *user = uid_to_string((uid_t)job_ptr->user_id);
-	char *jname = NULL;
-	int tmp = 0, i = 0;
-	char *account = NULL;
-	char *nodes = "(null)";
-
-	if (!gold_request) 
-		return SLURM_ERROR;
-
-	if (action == GOLD_ACTION_CREATE) {
-		snprintf(tmp_buff, sizeof(tmp_buff), "%u", job_ptr->job_id);
-		gold_request_add_assignment(gold_request, "JobId", tmp_buff);
-		
-		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
-			 (uint32_t)job_ptr->submit_time);
-		gold_request_add_assignment(gold_request, "SubmitTime",
-					    tmp_buff);
-		
-		gold_account_id = _get_account_id(user, account, 
-						  cluster_name);
-		if ((gold_account_id == NULL) ||
-		    ((gold_account_id[0] == '0') && (gold_account_id[1] == '\0'))) {
-			destroy_gold_request(gold_request);
-			if (gold_account_id) {
-				xfree(gold_account_id);
-				return SLURM_ERROR;	/* Invalid account */
-			}
-			return EAGAIN;			/* Gold not responding */
-		}
-		gold_request_add_assignment(gold_request, "GoldAccountId",
-					    gold_account_id);
-		xfree(gold_account_id);
-		
-	} else if (action == GOLD_ACTION_MODIFY) {
-		snprintf(tmp_buff, sizeof(tmp_buff), "%u", job_ptr->job_id);
-		gold_request_add_condition(gold_request, "JobId", tmp_buff,
-					   GOLD_OPERATOR_NONE);
-		
-		snprintf(tmp_buff, sizeof(tmp_buff), "%u",
-			 (uint32_t)job_ptr->submit_time);
-		gold_request_add_condition(gold_request, "SubmitTime",
-					   tmp_buff,
-					   GOLD_OPERATOR_NONE);
-	} else {
-		destroy_gold_request(gold_request);
-		error("_add_edit_job: bad action given %d", 
-		      action);		
-		return SLURM_ERROR;
-	}
-
-	if ((tmp = strlen(job_ptr->name))) {
-		jname = xmalloc(++tmp);
-		for (i=0; i<tmp; i++) {
-			if (isspace(job_ptr->name[i]))
-				jname[i]='_';
-			else
-				jname[i]=job_ptr->name[i];
-		}
-	} else
-		jname = xstrdup("allocation");
-	gold_request_add_assignment(gold_request, "JobName", jname);
-	xfree(jname);
-
-	if (job_ptr->account && job_ptr->account[0])
-		account = job_ptr->account;
-	
-	if (job_ptr->nodes && job_ptr->nodes[0])
-		nodes = job_ptr->nodes;
-
-	gold_request_add_assignment(gold_request, "Partition",
-				    job_ptr->partition);
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", job_ptr->total_procs);
-	gold_request_add_assignment(gold_request, "RequestedCPUCount",
-				    tmp_buff);
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", job_ptr->total_procs);
-	gold_request_add_assignment(gold_request, "AllocatedCPUCount",
-				    tmp_buff);
-	gold_request_add_assignment(gold_request, "NodeList", nodes);
-
-	
-	if (job_ptr->job_state >= JOB_COMPLETE) {
-		snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-			 (uint32_t)job_ptr->end_time);
-		gold_request_add_assignment(gold_request, "EndTime", 
-					    tmp_buff);
-		
-		snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-			 job_ptr->exit_code);
-		gold_request_add_assignment(gold_request, "ExitCode", 
-					    tmp_buff);
-	}
-
-
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-		 (uint32_t)job_ptr->begin_time);
-	gold_request_add_assignment(gold_request, "EligibleTime", tmp_buff);
-
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-		 (uint32_t)job_ptr->start_time);
-	gold_request_add_assignment(gold_request, "StartTime", tmp_buff);
-		
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u",
-		 job_ptr->job_state & (~JOB_COMPLETING));
-	gold_request_add_assignment(gold_request, "State", tmp_buff);	
-
-	gold_response = get_gold_response(gold_request);	
-	destroy_gold_request(gold_request);
-
-	if (!gold_response) {
-		error("_add_edit_job: no response received");
-		return EAGAIN;
-	}
-
-	if (!gold_response->rc) 
-		rc = SLURM_SUCCESS;
-	else {
-		error("gold_response has non-zero rc(%d): %s",
-		      gold_response->rc,
-		      gold_response->message);
-		rc = SLURM_ERROR;
-	}
-	destroy_gold_response(gold_response);
-
-	return rc;
-}
-
-extern int agent_node_up(Buf buffer)
-{
-	int rc = SLURM_ERROR;
-	gold_request_t *gold_request = NULL;
-	gold_response_t *gold_response = NULL;
-	char tmp_buff[50];
-	gold_node_up_msg_t *node_up_msg;
-	time_t event_time;
-
-	if (gold_agent_unpack_node_up_msg(&node_up_msg, buffer) !=
-	    SLURM_SUCCESS) {
-		error("Failed to unpack GOLD_MSG_NODE_UP message");
-		return SLURM_ERROR;
-	}
-
-	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
-					   GOLD_ACTION_MODIFY);
-	if (!gold_request) 
-		goto fini;
-	
-	gold_request_add_condition(gold_request, "Machine", 
-				   cluster_name, GOLD_OPERATOR_NONE);
-	gold_request_add_condition(gold_request, "EndTime", "0",
-				   GOLD_OPERATOR_NONE);
-	gold_request_add_condition(gold_request, "Name", 
-				   node_up_msg->hostlist,
-				   GOLD_OPERATOR_NONE);
-	event_time = node_up_msg->event_time;
-	if (event_time)
-		event_time--;
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", (uint32_t)event_time);
-	gold_request_add_assignment(gold_request, "EndTime", 
-				    tmp_buff);		
-			
-	gold_response = get_gold_response(gold_request);	
-	destroy_gold_request(gold_request);
-
-	if (!gold_response) {
-		error("agent_node_up: no response received");
-		rc = EAGAIN;
-		goto fini;
-	}
-
-	if (gold_response->rc) {
-		error("gold_response has non-zero rc(%d): %s",
-		      gold_response->rc,
-		      gold_response->message);
-		destroy_gold_response(gold_response);
-		goto fini;
-	}
-	destroy_gold_response(gold_response);
-	rc = SLURM_SUCCESS;
-
- fini:	gold_agent_free_node_up_msg(node_up_msg);
-	return rc;
-}
-
-extern int agent_node_down(Buf buffer)
-{
-	int rc = SLURM_ERROR;
-	gold_request_t *gold_request = NULL;
-	gold_response_t *gold_response = NULL;
-	char tmp_buff[50];
-	gold_node_down_msg_t *node_down_msg;
-	time_t event_time;
-
-	if (gold_agent_unpack_node_down_msg(&node_down_msg, buffer) !=
-	    SLURM_SUCCESS) {
-		error("Failed to unpack GOLD_MSG_NODE_DOWN message");
-		return SLURM_ERROR;
-	}
-
-	/*
-	 * If the node was already down end that record since the
-	 * reason will most likely be different
-	 */
-	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
-					   GOLD_ACTION_MODIFY);
-	if (!gold_request) 
-		goto fini;
-	
-	gold_request_add_condition(gold_request, "Machine", 
-				   cluster_name, GOLD_OPERATOR_NONE);
-	gold_request_add_condition(gold_request, "EndTime", "0",
-				   GOLD_OPERATOR_NONE);
-	gold_request_add_condition(gold_request, "Name", 
-				   node_down_msg->hostlist,
-				   GOLD_OPERATOR_NONE);
-	event_time = node_down_msg->event_time;
-	if (event_time)
-		event_time--;
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", (uint32_t)event_time);
-	gold_request_add_assignment(gold_request, "EndTime", 
-				    tmp_buff);		
-			
-	gold_response = get_gold_response(gold_request);	
-	destroy_gold_request(gold_request);
-
-	if (!gold_response) {
-		error("jobacct_p_node_down: no response received");
-		rc = EAGAIN;
-		goto fini;
-	}
-
-	if (gold_response->rc) {
-		error("gold_response has non-zero rc(%d): %s",
-		      gold_response->rc,
-		      gold_response->message);
-		destroy_gold_response(gold_response);
-		goto fini;
-	}
-	destroy_gold_response(gold_response);
-
-	/* now add the new one */
-	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
-					   GOLD_ACTION_CREATE);
-	if (!gold_request) 
-		goto fini;
-	
-	gold_request_add_assignment(gold_request, "Machine", cluster_name);
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-		 (uint32_t)node_down_msg->event_time);
-	gold_request_add_assignment(gold_request, "StartTime", tmp_buff);
-	gold_request_add_assignment(gold_request, "Name", 
-				    node_down_msg->hostlist);
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", node_down_msg->cpus);
-	gold_request_add_assignment(gold_request, "CPUCount", tmp_buff);
-	gold_request_add_assignment(gold_request, "Reason", 
-				    node_down_msg->reason);
-			
-	gold_response = get_gold_response(gold_request);	
-	destroy_gold_request(gold_request);
-
-	if (!gold_response) {
-		error("jobacct_p_node_down: no response received");
-		rc = EAGAIN;
-		goto fini;
-	}
-
-	if (!gold_response->rc) 
-		rc = SLURM_SUCCESS;
-	else {
-		error("gold_response has non-zero rc(%d): %s",
-		      gold_response->rc,
-		      gold_response->message);
-	}
-	destroy_gold_response(gold_response);
-
- fini:	gold_agent_free_node_down_msg(node_down_msg);
-	return rc;
-}
-
-extern int agent_cluster_procs(Buf buffer)
-{
-	gold_cluster_procs_msg_t *cluster_procs_msg;
-	gold_request_t *gold_request = NULL;
-	gold_response_t *gold_response = NULL;
-	char tmp_buff[50];
-	int rc = SLURM_ERROR;
-	bool no_modify = 0;
-	time_t event_time;
-
-	if (gold_agent_unpack_cluster_procs_msg(&cluster_procs_msg, buffer) !=
-	    SLURM_SUCCESS) {
-		error("Failed to unpack GOLD_MSG_CLUSTER_PROCS message");
-		return SLURM_ERROR;
-	}
-	
-	/* get the last known processor count */
-	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
-					   GOLD_ACTION_QUERY);
-	if (!gold_request) 
-		goto fini;
-	gold_request_add_condition(gold_request, "Machine", 
-				   cluster_name, GOLD_OPERATOR_NONE);
-	gold_request_add_condition(gold_request, "EndTime", "0",
-				   GOLD_OPERATOR_NONE);
-	gold_request_add_condition(gold_request, "Name", "NULL",
-				   GOLD_OPERATOR_NONE);
-
-	gold_request_add_selection(gold_request, "CPUCount");
-		
-	gold_response = get_gold_response(gold_request);	
-	destroy_gold_request(gold_request);
-
-	if (!gold_response) {
-		error("jobacct_p_cluster_procs: no response received");
-		rc = EAGAIN;
-		goto fini;
-	}
-
-	if (gold_response->entry_cnt > 0) {
-		gold_response_entry_t *resp_entry = 
-			list_pop(gold_response->entries);
-		gold_name_value_t *name_val = list_pop(resp_entry->name_val);
-
-		if (cluster_procs_msg->proc_count == atoi(name_val->value)) {
-			debug("System hasn't changed since last entry");
-			destroy_gold_name_value(name_val);
-			destroy_gold_response_entry(resp_entry);
-			destroy_gold_response(gold_response);
-			rc = SLURM_SUCCESS;
-			goto fini;
-		} else {
-			debug("System has changed from %s cpus to %u",
-			      name_val->value, cluster_procs_msg->proc_count);
-		}
-
-		destroy_gold_name_value(name_val);
-		destroy_gold_response_entry(resp_entry);
-	} else {
-		debug("We don't have an entry for this machine "
-		      "most likely a first time running.");
-		no_modify = 1;
-	}
-
-	destroy_gold_response(gold_response);
-	
-	if (no_modify) {
-		gold_request = create_gold_request(GOLD_OBJECT_EVENT,
-						   GOLD_ACTION_MODIFY);
-		if (!gold_request) 
-			goto fini;
-		
-		gold_request_add_condition(gold_request, "Machine",
-					   cluster_name, GOLD_OPERATOR_NONE);
-		gold_request_add_condition(gold_request, "EndTime", "0",
-					   GOLD_OPERATOR_NONE);
-		gold_request_add_condition(gold_request, "Name", "NULL",
-					   GOLD_OPERATOR_NONE);
-
-		event_time = cluster_procs_msg->event_time;
-		if (event_time)
-			event_time--;
-		snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-			 (uint32_t)event_time);
-		gold_request_add_assignment(gold_request, "EndTime", 
-					    tmp_buff);
-		
-		gold_response = get_gold_response(gold_request);	
-		destroy_gold_request(gold_request);
-		
-		if (!gold_response) {
-			error("jobacct_p_cluster_procs: no response "
-			      "received");
-			rc = EAGAIN;
-			goto fini;
-		}
-		
-		if (gold_response->rc) {
-			error("gold_response has non-zero rc(%d): %s",
-			      gold_response->rc,
-			      gold_response->message);
-			destroy_gold_response(gold_response);
-			goto fini;
-		}
-		destroy_gold_response(gold_response);
-	}
-
-	/* now add the new processor count */
-	gold_request = create_gold_request(GOLD_OBJECT_EVENT,
-					   GOLD_ACTION_CREATE);
-	if (!gold_request) 
-		goto fini;
-	
-	gold_request_add_assignment(gold_request, "Machine", cluster_name);
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-		 (uint32_t)cluster_procs_msg->event_time);
-	gold_request_add_assignment(gold_request, "StartTime", tmp_buff);
-	snprintf(tmp_buff, sizeof(tmp_buff), "%u", 
-		 cluster_procs_msg->proc_count);
-	gold_request_add_assignment(gold_request, "CPUCount", tmp_buff);
-			
-	gold_response = get_gold_response(gold_request);	
-	destroy_gold_request(gold_request);
-
-	if (!gold_response) {
-		error("jobacct_p_cluster_procs: no response received");
-		rc = EAGAIN;
-		goto fini;
-	}
-
-	if (!gold_response->rc) 
-		rc = SLURM_SUCCESS;
-	else {
-		error("gold_response has non-zero rc(%d): %s",
-		      gold_response->rc,
-		      gold_response->message);
-	}
-	destroy_gold_response(gold_response);
-
- fini:	gold_agent_free_cluster_procs_msg(cluster_procs_msg);
-	return rc;
-}
diff --git a/src/plugins/jobacct/linux/Makefile.am b/src/plugins/jobacct/linux/Makefile.am
deleted file mode 100644
index abf998966aed3800df8479acc255b4a0334ecb0f..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/linux/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-# Makefile for jobacct/linux plugin
-
-AUTOMAKE_OPTIONS = foreign
-
-PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
-
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-
-pkglib_LTLIBRARIES = jobacct_linux.la
-
-# Null job completion logging plugin.
-jobacct_linux_la_SOURCES = jobacct_linux.c \
-	$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c \
-	$(top_builddir)/src/slurmd/common/proctrack.c \
-	$(top_builddir)/src/slurmd/common/proctrack.h 
-
-jobacct_linux_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/jobacct/none/Makefile.am b/src/plugins/jobacct/none/Makefile.am
deleted file mode 100644
index 4d6584b310844055f5799230ed073751bb281efa..0000000000000000000000000000000000000000
--- a/src/plugins/jobacct/none/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for jobacct/none plugin
-
-AUTOMAKE_OPTIONS = foreign
-
-PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
-
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-
-pkglib_LTLIBRARIES = jobacct_none.la
-
-# Null job completion logging plugin.
-jobacct_none_la_SOURCES = jobacct_none.c
-jobacct_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/jobacct/Makefile.am b/src/plugins/jobacct_gather/Makefile.am
similarity index 51%
rename from src/plugins/jobacct/Makefile.am
rename to src/plugins/jobacct_gather/Makefile.am
index 1412b0808e59c31f0cef88d3f41b88ddde85262b..1039e1ad8067eceb6ad7ec002c938c0cc457ecc8 100644
--- a/src/plugins/jobacct/Makefile.am
+++ b/src/plugins/jobacct_gather/Makefile.am
@@ -1,3 +1,3 @@
 # Makefile for jobacct plugins
 
-SUBDIRS = linux aix none gold
+SUBDIRS = linux aix none
diff --git a/src/plugins/jobacct/Makefile.in b/src/plugins/jobacct_gather/Makefile.in
similarity index 94%
rename from src/plugins/jobacct/Makefile.in
rename to src/plugins/jobacct_gather/Makefile.in
index 4fa1bb9b966bf6c2b3017416376598243dd2133a..81976b36f5d8465f986e3490b66e340cb78a6acd 100644
--- a/src/plugins/jobacct/Makefile.in
+++ b/src/plugins/jobacct_gather/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -34,7 +34,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-subdir = src/plugins/jobacct
+subdir = src/plugins/jobacct_gather
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -234,7 +247,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = linux aix none gold
+SUBDIRS = linux aix none
 all: all-recursive
 
 .SUFFIXES:
@@ -247,9 +260,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/plugins/jobacct/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/plugins/jobacct_gather/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu  src/plugins/jobacct/Makefile
+	  $(AUTOMAKE) --gnu  src/plugins/jobacct_gather/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobacct_gather/aix/Makefile.am b/src/plugins/jobacct_gather/aix/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..4ceb3a62bfe41d5e2dfc7b1875b2eb976271b7ca
--- /dev/null
+++ b/src/plugins/jobacct_gather/aix/Makefile.am
@@ -0,0 +1,17 @@
+# Makefile for jobacct_gather/aix plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = jobacct_gather_aix.la
+
+# Null job completion logging plugin.
+jobacct_gather_aix_la_SOURCES = jobacct_gather_aix.c \
+	$(top_builddir)/src/slurmd/common/proctrack.c \
+	$(top_builddir)/src/slurmd/common/proctrack.h 
+
+jobacct_gather_aix_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+
diff --git a/src/plugins/jobacct/aix/Makefile.in b/src/plugins/jobacct_gather/aix/Makefile.in
similarity index 74%
rename from src/plugins/jobacct/aix/Makefile.in
rename to src/plugins/jobacct_gather/aix/Makefile.in
index 9ddd082c1681927b3506f84f98927be0793c0948..2e74f286ef016ce2d896995d0c73cefc808677e2 100644
--- a/src/plugins/jobacct/aix/Makefile.in
+++ b/src/plugins/jobacct_gather/aix/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# Makefile for jobacct/aix plugin
+# Makefile for jobacct_gather/aix plugin
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -35,7 +35,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-subdir = src/plugins/jobacct/aix
+subdir = src/plugins/jobacct_gather/aix
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,14 +75,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-jobacct_aix_la_LIBADD =
-am_jobacct_aix_la_OBJECTS = jobacct_aix.lo jobacct_common.lo \
-	common_slurmctld.lo common_slurmstepd.lo proctrack.lo
-jobacct_aix_la_OBJECTS = $(am_jobacct_aix_la_OBJECTS)
-jobacct_aix_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+jobacct_gather_aix_la_LIBADD =
+am_jobacct_gather_aix_la_OBJECTS = jobacct_gather_aix.lo proctrack.lo
+jobacct_gather_aix_la_OBJECTS = $(am_jobacct_gather_aix_la_OBJECTS)
+jobacct_gather_aix_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(jobacct_aix_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+	$(jobacct_gather_aix_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -92,8 +93,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(jobacct_aix_la_SOURCES)
-DIST_SOURCES = $(jobacct_aix_la_SOURCES)
+SOURCES = $(jobacct_gather_aix_la_SOURCES)
+DIST_SOURCES = $(jobacct_gather_aix_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -120,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -256,17 +268,14 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-pkglib_LTLIBRARIES = jobacct_aix.la
+pkglib_LTLIBRARIES = jobacct_gather_aix.la
 
 # Null job completion logging plugin.
-jobacct_aix_la_SOURCES = jobacct_aix.c \
-	$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c \
+jobacct_gather_aix_la_SOURCES = jobacct_gather_aix.c \
 	$(top_builddir)/src/slurmd/common/proctrack.c \
 	$(top_builddir)/src/slurmd/common/proctrack.h 
 
-jobacct_aix_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobacct_gather_aix_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -280,9 +289,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobacct/aix/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobacct_gather/aix/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/plugins/jobacct/aix/Makefile
+	  $(AUTOMAKE) --foreign  src/plugins/jobacct_gather/aix/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -306,8 +315,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -315,8 +324,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -327,8 +336,8 @@ clean-pkglibLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-jobacct_aix.la: $(jobacct_aix_la_OBJECTS) $(jobacct_aix_la_DEPENDENCIES) 
-	$(jobacct_aix_la_LINK) -rpath $(pkglibdir) $(jobacct_aix_la_OBJECTS) $(jobacct_aix_la_LIBADD) $(LIBS)
+jobacct_gather_aix.la: $(jobacct_gather_aix_la_OBJECTS) $(jobacct_gather_aix_la_DEPENDENCIES) 
+	$(jobacct_gather_aix_la_LINK) -rpath $(pkglibdir) $(jobacct_gather_aix_la_OBJECTS) $(jobacct_gather_aix_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -336,10 +345,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_slurmctld.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_slurmstepd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_aix.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_common.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_gather_aix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proctrack.Plo@am__quote@
 
 .c.o:
@@ -363,27 +369,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
-jobacct_common.lo: $(top_builddir)/src/plugins/jobacct/common/jobacct_common.c
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT jobacct_common.lo -MD -MP -MF $(DEPDIR)/jobacct_common.Tpo -c -o jobacct_common.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/jobacct_common.Tpo $(DEPDIR)/jobacct_common.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c' object='jobacct_common.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o jobacct_common.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c
-
-common_slurmctld.lo: $(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common_slurmctld.lo -MD -MP -MF $(DEPDIR)/common_slurmctld.Tpo -c -o common_slurmctld.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/common_slurmctld.Tpo $(DEPDIR)/common_slurmctld.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c' object='common_slurmctld.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common_slurmctld.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c
-
-common_slurmstepd.lo: $(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common_slurmstepd.lo -MD -MP -MF $(DEPDIR)/common_slurmstepd.Tpo -c -o common_slurmstepd.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/common_slurmstepd.Tpo $(DEPDIR)/common_slurmstepd.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c' object='common_slurmstepd.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common_slurmstepd.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c
-
 proctrack.lo: $(top_builddir)/src/slurmd/common/proctrack.c
 @am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT proctrack.lo -MD -MP -MF $(DEPDIR)/proctrack.Tpo -c -o proctrack.lo `test -f '$(top_builddir)/src/slurmd/common/proctrack.c' || echo '$(srcdir)/'`$(top_builddir)/src/slurmd/common/proctrack.c
 @am__fastdepCC_TRUE@	mv -f $(DEPDIR)/proctrack.Tpo $(DEPDIR)/proctrack.Plo
@@ -402,8 +387,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -415,8 +400,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -426,13 +411,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobacct/aix/jobacct_aix.c b/src/plugins/jobacct_gather/aix/jobacct_gather_aix.c
similarity index 75%
rename from src/plugins/jobacct/aix/jobacct_aix.c
rename to src/plugins/jobacct_gather/aix/jobacct_gather_aix.c
index 98b6545e743f232a6445c08674016f5a57a869f0..dc0b0ca354b12b0e73cfd8d4b4a3bbbd53b8a117 100644
--- a/src/plugins/jobacct/aix/jobacct_aix.c
+++ b/src/plugins/jobacct_gather/aix/jobacct_gather_aix.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
- *  jobacct_aix.c - slurm job accounting plugin for AIX.
+ *  jobacct_gather_aix.c - slurm job accounting gather plugin for AIX.
  *****************************************************************************
  *
  *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
  *  Written by Andy Riebs, <andy.riebs@hp.com>, who borrowed heavily
  *  from other parts of SLURM, and Danny Auble, <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -39,7 +39,11 @@
  *  Copyright (C) 2002 The Regents of the University of California.
 \*****************************************************************************/
 
-#include "src/plugins/jobacct/common/jobacct_common.h"
+#include <signal.h>
+#include "src/common/jobacct_common.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_protocol_defs.h"
+#include "src/slurmd/common/proctrack.h"
 
 #ifdef HAVE_AIX
 #include <procinfo.h>
@@ -77,8 +81,8 @@
  * minimum versions for their plugins as the job accounting API 
  * matures.
  */
-const char plugin_name[] = "Job accounting AIX plugin";
-const char plugin_type[] = "jobacct/aix";
+const char plugin_name[] = "Job accounting gather AIX plugin";
+const char plugin_type[] = "jobacct_gather/aix";
 const uint32_t plugin_version = 100;
 	
 /* Other useful declarations */
@@ -97,6 +101,7 @@ static int freq = 0;
 static int pagesize = 0;
 /* Finally, pre-define all the routines. */
 
+static void _acct_kill_job(void);
 static void _get_offspring_data(List prec_list, prec_t *ancestor, pid_t pid);
 static void _get_process_data();
 static void *_watch_tasks(void *arg);
@@ -109,222 +114,6 @@ extern int getprocs(struct procsinfo *procinfo, int, struct fdsinfo *,
     /* nproc:      number of user procinfo struct */
     /* sizproc:    size of expected procinfo structure */
 
-#endif
-
-/*
- * init() is called when the plugin is loaded, before any other functions
- * are called.  Put global initialization here.
- */
-extern int init ( void )
-{
-	char *proctrack = slurm_get_proctrack_type();
-	if(!strcasecmp(proctrack, "proctrack/pgid")) {
-		info("WARNING: We will use a much slower algorithm with "
-		     "proctrack/pgid, use Proctracktype=proctrack/aix "
-		     "with %s", plugin_name);
-		pgid_plugin = true;
-	}
-	xfree(proctrack);
-
-	verbose("%s loaded", plugin_name);
-	return SLURM_SUCCESS;
-}
-
-extern int fini ( void )
-{
-	return SLURM_SUCCESS;
-}
-
-/*
- * The following routine is called by the slurmd mainline
- */
-
-int jobacct_p_init_struct(struct jobacctinfo *jobacct, 
-			  jobacct_id_t *jobacct_id)
-{
-	return common_init_struct(jobacct, jobacct_id);
-}
-
-struct jobacctinfo *jobacct_p_alloc(jobacct_id_t *jobacct_id)
-{
-	return common_alloc_jobacct(jobacct_id);
-}
-
-void jobacct_p_free(struct jobacctinfo *jobacct)
-{
-	common_free_jobacct(jobacct);
-}
-
-int jobacct_p_setinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
-{
-	return common_setinfo(jobacct, type, data);
-	
-}
-
-int jobacct_p_getinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
-{
-	return common_getinfo(jobacct, type, data);
-}
-
-void jobacct_p_aggregate(struct jobacctinfo *dest, struct jobacctinfo *from)
-{
-	common_aggregate(dest, from);
-}
-
-void jobacct_p_2_sacct(sacct_t *sacct, struct jobacctinfo *jobacct)
-{
-	common_2_sacct(sacct, jobacct);
-}
-
-void jobacct_p_pack(struct jobacctinfo *jobacct, Buf buffer)
-{
-	common_pack(jobacct, buffer);
-}
-
-int jobacct_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
-{
-	return common_unpack(jobacct, buffer);
-}
-
-
-int jobacct_p_init_slurmctld(char *job_acct_log)
-{
-	return common_init_slurmctld(job_acct_log);
-}
-
-int jobacct_p_fini_slurmctld()
-{
-	return common_fini_slurmctld();
-}
-
-int jobacct_p_job_start_slurmctld(struct job_record *job_ptr)
-{
-	return common_job_start_slurmctld(job_ptr);
-}
-
-int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
-{
-	return  common_job_complete_slurmctld(job_ptr);
-}
-
-int jobacct_p_step_start_slurmctld(struct step_record *step)
-{
-	return common_step_start_slurmctld(step);	
-}
-
-int jobacct_p_step_complete_slurmctld(struct step_record *step)
-{
-	return common_step_complete_slurmctld(step);	
-}
-
-int jobacct_p_suspend_slurmctld(struct job_record *job_ptr)
-{
-	return common_suspend_slurmctld(job_ptr);
-}
-/*
- * jobacct_startpoll() is called when the plugin is loaded by
- * slurmd, before any other functions are called.  Put global
- * initialization here.
- */
-
-int jobacct_p_startpoll(int frequency)
-{
-	int rc = SLURM_SUCCESS;
-	
-#ifdef HAVE_AIX
-	pthread_attr_t attr;
-	pthread_t _watch_tasks_thread_id;
-
-	debug("jobacct AIX plugin loaded");
-	
-	debug("jobacct: frequency = %d", frequency);
-		
-	jobacct_shutdown = false;
-	
-	if (frequency == 0) {	/* don't want dynamic monitoring? */
-		debug2("jobacct AIX dynamic logging disabled");
-		return rc;
-	}
-
-	freq = frequency;
-	pagesize = getpagesize()/1024;
-	task_list = list_create(common_free_jobacct);
-	
-	/* create polling thread */
-	slurm_attr_init(&attr);
-	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
-		error("pthread_attr_setdetachstate error %m");
-	
-	if  (pthread_create(&_watch_tasks_thread_id, &attr,
-			    &_watch_tasks, NULL)) {
-		debug("jobacct failed to create _watch_tasks "
-		      "thread: %m");
-		frequency = 0;
-	}
-	else 
-		debug3("jobacct AIX dynamic logging enabled");
-	slurm_attr_destroy(&attr);
-#else
-	error("jobacct AIX not loaded, not an aix system, check slurm.conf");
-#endif
-	return rc;
-}
-
-int jobacct_p_endpoll()
-{
-	return common_endpoll();
-}
-
-int jobacct_p_set_proctrack_container_id(uint32_t id)
-{
-	return common_set_proctrack_container_id(id);
-}
-
-int jobacct_p_add_task(pid_t pid, jobacct_id_t *jobacct_id)
-{
-	return common_add_task(pid, jobacct_id);
-}
-
-struct jobacctinfo *jobacct_p_stat_task(pid_t pid)
-{
-#ifdef HAVE_AIX
-	_get_process_data();
-#endif
-	return common_stat_task(pid);
-}
-
-struct jobacctinfo *jobacct_p_remove_task(pid_t pid)
-{
-	return common_remove_task(pid);
-}
-
-void jobacct_p_suspend_poll()
-{
-	common_suspend_poll();
-}
-
-void jobacct_p_resume_poll()
-{
-	common_resume_poll();
-}
-
-extern int jobacct_p_node_down(struct node_record *node_ptr,
-			       time_t event_time, char *reason)
-{
-	return SLURM_SUCCESS;
-}
-extern int jobacct_p_node_up(struct node_record *node_ptr, time_t event_time)
-{
-	return SLURM_SUCCESS;
-}
-extern int jobacct_p_cluster_procs(uint32_t procs, time_t event_time)
-{
-	return SLURM_SUCCESS;
-}
-
-#ifdef HAVE_AIX
 
 /* 
  * _get_offspring_data() -- collect memory usage data for the offspring
@@ -390,9 +179,8 @@ static void _get_process_data()
 	struct procsinfo proc;
 	pid_t *pids = NULL;
 	int npids = 0;
-
 	int i;
-
+	uint32_t total_job_mem = 0;
 	int pid = 0;
 	static int processing = 0;
 	prec_t *prec = NULL;
@@ -483,6 +271,7 @@ static void _get_process_data()
 				/* tally their usage */
 				jobacct->max_rss = jobacct->tot_rss = 
 					MAX(jobacct->max_rss, (int)prec->rss);
+				total_job_mem += jobacct->max_rss;
 				jobacct->max_vsize = jobacct->tot_vsize = 
 					MAX(jobacct->max_vsize, 
 					    (int)prec->vsize);
@@ -502,6 +291,18 @@ static void _get_process_data()
 	}
 	list_iterator_destroy(itr);	
 	slurm_mutex_unlock(&jobacct_lock);
+
+	if (job_mem_limit) {
+		debug("Job %u memory used:%u limit:%u KB", 
+		      acct_job_id, total_job_mem, job_mem_limit);
+	}
+	if (acct_job_id && job_mem_limit &&
+	    (total_job_mem > job_mem_limit)) {
+		error("Job %u exceeded %u KB memory limit, being killed",
+		       acct_job_id, job_mem_limit);
+		_acct_kill_job();
+	}
+
 finished:
 	list_destroy(prec_list);
 	processing = 0;	
@@ -509,6 +310,25 @@ finished:
 	return;
 }
 
+/* _acct_kill_job() issue RPC to kill a slurm job */
+static void _acct_kill_job(void)
+{
+	slurm_msg_t msg;
+	job_step_kill_msg_t req;
+
+	slurm_msg_t_init(&msg);
+	/* 
+	 * Request message:
+	 */
+	req.job_id      = acct_job_id;
+	req.job_step_id = NO_VAL;
+	req.signal      = SIGKILL;
+	req.batch_flag  = 0;
+	msg.msg_type    = REQUEST_CANCEL_JOB_STEP;
+	msg.data        = &req;
+
+	slurm_send_only_controller_msg(&msg);
+}
 
 /* _watch_tasks() -- monitor slurm jobs and track their memory usage
  *
@@ -519,7 +339,7 @@ static void *_watch_tasks(void *arg)
 {
 
 	while(!jobacct_shutdown) {	/* Do this until shutdown is requested */
-		if(!suspended) {
+		if(!jobacct_suspended) {
 			_get_process_data();	/* Update the data */ 
 		}
 		sleep(freq);
@@ -536,3 +356,179 @@ static void _destroy_prec(void *object)
 }
 
 #endif
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	char *temp = slurm_get_proctrack_type();
+	if(!strcasecmp(temp, "proctrack/pgid")) {
+		info("WARNING: We will use a much slower algorithm with "
+		     "proctrack/pgid, use Proctracktype=proctrack/aix "
+		     "with %s", plugin_name);
+		pgid_plugin = true;
+	}
+	xfree(temp);
+	temp = slurm_get_accounting_storage_type();
+	if(!strcasecmp(temp, ACCOUNTING_STORAGE_TYPE_NONE)) {
+		error("WARNING: Even though we are collecting accounting "
+		      "information you have asked for it not to be stored "
+		      "(%s) if this is not what you have in mind you will "
+		      "need to change it.", ACCOUNTING_STORAGE_TYPE_NONE);
+	}
+	xfree(temp);
+
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	return SLURM_SUCCESS;
+}
+
+extern struct jobacctinfo *jobacct_gather_p_create(jobacct_id_t *jobacct_id)
+{
+	return jobacct_common_alloc_jobacct(jobacct_id);
+}
+
+extern void jobacct_gather_p_destroy(struct jobacctinfo *jobacct)
+{
+	jobacct_common_free_jobacct(jobacct);
+}
+
+extern int jobacct_gather_p_setinfo(struct jobacctinfo *jobacct, 
+				    enum jobacct_data_type type, void *data)
+{
+	return jobacct_common_setinfo(jobacct, type, data);
+	
+}
+
+extern int jobacct_gather_p_getinfo(struct jobacctinfo *jobacct, 
+				    enum jobacct_data_type type, void *data)
+{
+	return jobacct_common_getinfo(jobacct, type, data);
+}
+
+extern void jobacct_gather_p_pack(struct jobacctinfo *jobacct, Buf buffer)
+{
+	jobacct_common_pack(jobacct, buffer);
+}
+
+extern int jobacct_gather_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
+{
+	return jobacct_common_unpack(jobacct, buffer);
+}
+
+extern void jobacct_gather_p_aggregate(struct jobacctinfo *dest,
+				       struct jobacctinfo *from)
+{
+	jobacct_common_aggregate(dest, from);
+}
+
+/*
+ * jobacct_startpoll() is called when the plugin is loaded by
+ * slurmd, before any other functions are called.  Put global
+ * initialization here.
+ */
+
+extern int jobacct_gather_p_startpoll(uint16_t frequency)
+{
+	int rc = SLURM_SUCCESS;
+	
+#ifdef HAVE_AIX
+	pthread_attr_t attr;
+	pthread_t _watch_tasks_thread_id;
+
+	debug("%s loaded", plugin_name);
+	
+	debug("jobacct: frequency = %d", frequency);
+		
+	jobacct_shutdown = false;
+	
+	if (frequency == 0) {	/* don't want dynamic monitoring? */
+		debug2("jobacct AIX dynamic logging disabled");
+		return rc;
+	}
+
+	freq = frequency;
+	pagesize = getpagesize()/1024;
+	task_list = list_create(jobacct_common_free_jobacct);
+	
+	/* create polling thread */
+	slurm_attr_init(&attr);
+	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
+		error("pthread_attr_setdetachstate error %m");
+	
+	if  (pthread_create(&_watch_tasks_thread_id, &attr,
+			    &_watch_tasks, NULL)) {
+		debug("jobacct failed to create _watch_tasks "
+		      "thread: %m");
+		frequency = 0;
+	}
+	else 
+		debug3("jobacct AIX dynamic logging enabled");
+	slurm_attr_destroy(&attr);
+#else
+	error("jobacct AIX not loaded, not an aix system, check slurm.conf");
+#endif
+	return rc;
+}
+
+extern int jobacct_gather_p_endpoll()
+{
+	jobacct_shutdown = true;
+
+	return SLURM_SUCCESS;
+}
+
+extern void jobacct_gather_p_change_poll(uint16_t frequency)
+{
+#ifdef HAVE_AIX
+	freq = frequency;
+	if (freq == 0)
+		jobacct_shutdown = true;
+#endif
+	return;
+}
+
+extern void jobacct_gather_p_suspend_poll()
+{
+	jobacct_common_suspend_poll();
+}
+
+extern void jobacct_gather_p_resume_poll()
+{
+	jobacct_common_resume_poll();
+}
+
+extern int jobacct_gather_p_set_proctrack_container_id(uint32_t id)
+{
+	return jobacct_common_set_proctrack_container_id(id);
+}
+
+extern int jobacct_gather_p_add_task(pid_t pid, jobacct_id_t *jobacct_id)
+{
+	return jobacct_common_add_task(pid, jobacct_id);
+}
+
+extern struct jobacctinfo *jobacct_gather_p_stat_task(pid_t pid)
+{
+#ifdef HAVE_AIX
+	_get_process_data();
+#endif
+	return jobacct_common_stat_task(pid);
+}
+
+extern struct jobacctinfo *jobacct_gather_p_remove_task(pid_t pid)
+{
+	return jobacct_common_remove_task(pid);
+}
+
+extern void jobacct_gather_p_2_sacct(sacct_t *sacct, 
+				     struct jobacctinfo *jobacct)
+{
+	jobacct_common_2_sacct(sacct, jobacct);
+}
diff --git a/src/plugins/jobacct_gather/linux/Makefile.am b/src/plugins/jobacct_gather/linux/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..8a9451752beec52e946e5594492fca01d612a684
--- /dev/null
+++ b/src/plugins/jobacct_gather/linux/Makefile.am
@@ -0,0 +1,17 @@
+# Makefile for jobacct_gather/linux plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = jobacct_gather_linux.la
+
+# Null job completion logging plugin.
+jobacct_gather_linux_la_SOURCES = jobacct_gather_linux.c \
+	$(top_builddir)/src/slurmd/common/proctrack.c \
+	$(top_builddir)/src/slurmd/common/proctrack.h 
+
+jobacct_gather_linux_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+
diff --git a/src/plugins/jobacct/linux/Makefile.in b/src/plugins/jobacct_gather/linux/Makefile.in
similarity index 74%
rename from src/plugins/jobacct/linux/Makefile.in
rename to src/plugins/jobacct_gather/linux/Makefile.in
index e14899c36c205a4a4de94d307be05a10a41c35b9..bb7a009b997d00ed4c99179d83edabebe21b7bde 100644
--- a/src/plugins/jobacct/linux/Makefile.in
+++ b/src/plugins/jobacct_gather/linux/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# Makefile for jobacct/linux plugin
+# Makefile for jobacct_gather/linux plugin
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -35,7 +35,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-subdir = src/plugins/jobacct/linux
+subdir = src/plugins/jobacct_gather/linux
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,14 +75,15 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-jobacct_linux_la_LIBADD =
-am_jobacct_linux_la_OBJECTS = jobacct_linux.lo jobacct_common.lo \
-	common_slurmctld.lo common_slurmstepd.lo proctrack.lo
-jobacct_linux_la_OBJECTS = $(am_jobacct_linux_la_OBJECTS)
-jobacct_linux_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+jobacct_gather_linux_la_LIBADD =
+am_jobacct_gather_linux_la_OBJECTS = jobacct_gather_linux.lo \
+	proctrack.lo
+jobacct_gather_linux_la_OBJECTS =  \
+	$(am_jobacct_gather_linux_la_OBJECTS)
+jobacct_gather_linux_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(jobacct_linux_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+	$(jobacct_gather_linux_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -92,8 +95,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(jobacct_linux_la_SOURCES)
-DIST_SOURCES = $(jobacct_linux_la_SOURCES)
+SOURCES = $(jobacct_gather_linux_la_SOURCES)
+DIST_SOURCES = $(jobacct_gather_linux_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -120,6 +123,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +137,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +163,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +177,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +194,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +210,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -256,17 +270,14 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-pkglib_LTLIBRARIES = jobacct_linux.la
+pkglib_LTLIBRARIES = jobacct_gather_linux.la
 
 # Null job completion logging plugin.
-jobacct_linux_la_SOURCES = jobacct_linux.c \
-	$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c \
-	$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c \
+jobacct_gather_linux_la_SOURCES = jobacct_gather_linux.c \
 	$(top_builddir)/src/slurmd/common/proctrack.c \
 	$(top_builddir)/src/slurmd/common/proctrack.h 
 
-jobacct_linux_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobacct_gather_linux_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -280,9 +291,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobacct/linux/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobacct_gather/linux/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/plugins/jobacct/linux/Makefile
+	  $(AUTOMAKE) --foreign  src/plugins/jobacct_gather/linux/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -306,8 +317,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -315,8 +326,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -327,8 +338,8 @@ clean-pkglibLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-jobacct_linux.la: $(jobacct_linux_la_OBJECTS) $(jobacct_linux_la_DEPENDENCIES) 
-	$(jobacct_linux_la_LINK) -rpath $(pkglibdir) $(jobacct_linux_la_OBJECTS) $(jobacct_linux_la_LIBADD) $(LIBS)
+jobacct_gather_linux.la: $(jobacct_gather_linux_la_OBJECTS) $(jobacct_gather_linux_la_DEPENDENCIES) 
+	$(jobacct_gather_linux_la_LINK) -rpath $(pkglibdir) $(jobacct_gather_linux_la_OBJECTS) $(jobacct_gather_linux_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -336,10 +347,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_slurmctld.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_slurmstepd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_common.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_linux.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_gather_linux.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proctrack.Plo@am__quote@
 
 .c.o:
@@ -363,27 +371,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
-jobacct_common.lo: $(top_builddir)/src/plugins/jobacct/common/jobacct_common.c
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT jobacct_common.lo -MD -MP -MF $(DEPDIR)/jobacct_common.Tpo -c -o jobacct_common.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/jobacct_common.Tpo $(DEPDIR)/jobacct_common.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c' object='jobacct_common.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o jobacct_common.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/jobacct_common.c
-
-common_slurmctld.lo: $(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common_slurmctld.lo -MD -MP -MF $(DEPDIR)/common_slurmctld.Tpo -c -o common_slurmctld.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/common_slurmctld.Tpo $(DEPDIR)/common_slurmctld.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c' object='common_slurmctld.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common_slurmctld.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmctld.c
-
-common_slurmstepd.lo: $(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c
-@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common_slurmstepd.lo -MD -MP -MF $(DEPDIR)/common_slurmstepd.Tpo -c -o common_slurmstepd.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/common_slurmstepd.Tpo $(DEPDIR)/common_slurmstepd.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c' object='common_slurmstepd.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common_slurmstepd.lo `test -f '$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c' || echo '$(srcdir)/'`$(top_builddir)/src/plugins/jobacct/common/common_slurmstepd.c
-
 proctrack.lo: $(top_builddir)/src/slurmd/common/proctrack.c
 @am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT proctrack.lo -MD -MP -MF $(DEPDIR)/proctrack.Tpo -c -o proctrack.lo `test -f '$(top_builddir)/src/slurmd/common/proctrack.c' || echo '$(srcdir)/'`$(top_builddir)/src/slurmd/common/proctrack.c
 @am__fastdepCC_TRUE@	mv -f $(DEPDIR)/proctrack.Tpo $(DEPDIR)/proctrack.Plo
@@ -402,8 +389,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -415,8 +402,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -426,13 +413,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobacct/linux/jobacct_linux.c b/src/plugins/jobacct_gather/linux/jobacct_gather_linux.c
similarity index 66%
rename from src/plugins/jobacct/linux/jobacct_linux.c
rename to src/plugins/jobacct_gather/linux/jobacct_gather_linux.c
index 626ae5d6c7bfec3665308df693487e41a4f350f4..d8f19f1ff84f5f2509b717d58bf2875274c0defa 100644
--- a/src/plugins/jobacct/linux/jobacct_linux.c
+++ b/src/plugins/jobacct_gather/linux/jobacct_gather_linux.c
@@ -1,10 +1,10 @@
 /*****************************************************************************\
- *  jobacct_linux.c - slurm job accounting plugin.
+ *  jobacct_gather_linux.c - slurm job accounting gather plugin for linux.
  *****************************************************************************
  *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
  *  Written by Andy Riebs, <andy.riebs@hp.com>, who borrowed heavily
  *  from other parts of SLURM, and Danny Auble, <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -39,7 +39,13 @@
 \*****************************************************************************/
 
 #include <fcntl.h>
-#include "src/plugins/jobacct/common/jobacct_common.h"
+#include <signal.h>
+#include "src/common/jobacct_common.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_protocol_defs.h"
+#include "src/slurmd/common/proctrack.h"
+
+#define _DEBUG 0
 
 /*
  * These variables are required by the generic plugin interface.  If they
@@ -70,8 +76,8 @@
  * minimum versions for their plugins as the job accounting API 
  * matures.
  */
-const char plugin_name[] = "Job accounting LINUX plugin";
-const char plugin_type[] = "jobacct/linux";
+const char plugin_name[] = "Job accounting gather LINUX plugin";
+const char plugin_type[] = "jobacct_gather/linux";
 const uint32_t plugin_version = 100;
 
 /* Other useful declarations */
@@ -92,235 +98,13 @@ static pthread_mutex_t reading_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 /* Finally, pre-define all local routines. */
 
+static void _acct_kill_job(void);
 static void _get_offspring_data(List prec_list, prec_t *ancestor, pid_t pid);
 static void _get_process_data();
-static int _get_process_data_line(FILE *in, prec_t *prec);
+static int _get_process_data_line(int in, prec_t *prec);
 static void *_watch_tasks(void *arg);
 static void _destroy_prec(void *object);
 
-/*
- * init() is called when the plugin is loaded, before any other functions
- * are called.  Put global initialization here.
- */
-extern int init ( void )
-{
-	char *proctrack = slurm_get_proctrack_type();
-	if(!strcasecmp(proctrack, "proctrack/pgid")) {
-		info("WARNING: We will use a much slower algorithm with "
-		     "proctrack/pgid, use Proctracktype=proctrack/linuxproc "
-		     "or Proctracktype=proctrack/rms with %s",
-		     plugin_name);
-		pgid_plugin = true;
-	}
-	xfree(proctrack);
-
-	verbose("%s loaded", plugin_name);
-	return SLURM_SUCCESS;
-}
-
-extern int fini ( void )
-{
-	return SLURM_SUCCESS;
-}
-
-/*
- * The following routine is called by the slurmd mainline
- */
-
-int jobacct_p_init_struct(struct jobacctinfo *jobacct, 
-			  jobacct_id_t *jobacct_id)
-{
-	return common_init_struct(jobacct, jobacct_id);
-}
-
-struct jobacctinfo *jobacct_p_alloc(jobacct_id_t *jobacct_id)
-{
-	return common_alloc_jobacct(jobacct_id);
-}
-
-void jobacct_p_free(struct jobacctinfo *jobacct)
-{
-	common_free_jobacct(jobacct);
-}
-
-int jobacct_p_setinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
-{
-	return common_setinfo(jobacct, type, data);
-	
-}
-
-int jobacct_p_getinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
-{
-	return common_getinfo(jobacct, type, data);
-}
-
-void jobacct_p_aggregate(struct jobacctinfo *dest, struct jobacctinfo *from)
-{
-	common_aggregate(dest, from);
-}
-
-void jobacct_p_2_sacct(sacct_t *sacct, struct jobacctinfo *jobacct)
-{
-	common_2_sacct(sacct, jobacct);
-}
-
-void jobacct_p_pack(struct jobacctinfo *jobacct, Buf buffer)
-{
-	common_pack(jobacct, buffer);
-}
-
-int jobacct_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
-{
-	return common_unpack(jobacct, buffer);
-}
-
-
-int jobacct_p_init_slurmctld(char *job_acct_log)
-{
-	return common_init_slurmctld(job_acct_log);
-}
-
-int jobacct_p_fini_slurmctld()
-{
-	return common_fini_slurmctld();
-}
-
-int jobacct_p_job_start_slurmctld(struct job_record *job_ptr)
-{
-	return common_job_start_slurmctld(job_ptr);
-}
-
-int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
-{
-	return  common_job_complete_slurmctld(job_ptr);
-}
-
-int jobacct_p_step_start_slurmctld(struct step_record *step)
-{
-	return common_step_start_slurmctld(step);	
-}
-
-int jobacct_p_step_complete_slurmctld(struct step_record *step)
-{
-	return common_step_complete_slurmctld(step);	
-}
-
-int jobacct_p_suspend_slurmctld(struct job_record *job_ptr)
-{
-	return common_suspend_slurmctld(job_ptr);
-}
-
-/*
- * jobacct_startpoll() is called when the plugin is loaded by
- * slurmd, before any other functions are called.  Put global
- * initialization here.
- */
-
-int jobacct_p_startpoll(int frequency)
-{
-	int rc = SLURM_SUCCESS;
-	
-	pthread_attr_t attr;
-	pthread_t _watch_tasks_thread_id;
-	 
-	debug("jobacct LINUX plugin loaded");
-
-	/* Parse the JobAcctParameters */
-
-	
-	debug("jobacct: frequency = %d", frequency);
-		
-	jobacct_shutdown = false;
-	
-	if (frequency == 0) {	/* don't want dynamic monitoring? */
-		debug2("jobacct LINUX dynamic logging disabled");
-		return rc;
-	}
-
-	freq = frequency;
-	task_list = list_create(common_free_jobacct);
-	
-	/* create polling thread */
-	slurm_attr_init(&attr);
-	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
-		error("pthread_attr_setdetachstate error %m");
-	
-	if  (pthread_create(&_watch_tasks_thread_id, &attr,
-			    &_watch_tasks, NULL)) {
-		debug("jobacct failed to create _watch_tasks "
-		      "thread: %m");
-		frequency = 0;
-	}
-	else 
-		debug3("jobacct LINUX dynamic logging enabled");
-	slurm_attr_destroy(&attr);
-	
-	return rc;
-}
-
-int jobacct_p_endpoll()
-{
-	slurm_mutex_lock(&jobacct_lock);
-	if(task_list)
-		list_destroy(task_list);
-	task_list = NULL;
-	slurm_mutex_unlock(&jobacct_lock);
-	
-	if (slash_proc) {
-		slurm_mutex_lock(&reading_mutex);
-		(void) closedir(slash_proc);
-		slurm_mutex_unlock(&reading_mutex);
-	}
-	return common_endpoll();
-}
-
-int jobacct_p_set_proctrack_container_id(uint32_t id)
-{
-	return common_set_proctrack_container_id(id);
-}
-
-int jobacct_p_add_task(pid_t pid, jobacct_id_t *jobacct_id)
-{
-	return common_add_task(pid, jobacct_id);
-}
-
-struct jobacctinfo *jobacct_p_stat_task(pid_t pid)
-{
-	_get_process_data();
-	return common_stat_task(pid);
-}
-
-struct jobacctinfo *jobacct_p_remove_task(pid_t pid)
-{
-	return common_remove_task(pid);
-}
-
-void jobacct_p_suspend_poll()
-{
-	common_suspend_poll();
-}
-
-void jobacct_p_resume_poll()
-{
-	common_resume_poll();
-}
-
-extern int jobacct_p_node_down(struct node_record *node_ptr,
-			       time_t event_time, char *reason)
-{
-	return SLURM_SUCCESS;
-}
-extern int jobacct_p_node_up(struct node_record *node_ptr, time_t event_time)
-{
-	return SLURM_SUCCESS;
-}
-extern int jobacct_p_cluster_procs(uint32_t procs, time_t event_time)
-{
-	return SLURM_SUCCESS;
-}
-
 /* 
  * _get_offspring_data() -- collect memory usage data for the offspring
  *
@@ -351,6 +135,10 @@ _get_offspring_data(List prec_list, prec_t *ancestor, pid_t pid) {
 	itr = list_iterator_create(prec_list);
 	while((prec = list_next(itr))) {
 		if (prec->ppid == pid) {
+#if _DEBUG
+			info("pid:%u ppid:%u rss:%d KB", 
+			     prec->pid, prec->ppid, prec->rss);
+#endif
 			_get_offspring_data(prec_list, ancestor, prec->pid);
 			ancestor->usec += prec->usec;
 			ancestor->ssec += prec->ssec;
@@ -370,7 +158,7 @@ _get_offspring_data(List prec_list, prec_t *ancestor, pid_t pid) {
  *
  * OUT:	none
  *
-  * THREADSAFE! Only one thread ever gets here.
+ * THREADSAFE! Only one thread ever gets here.
  *
  * Assumption:
  *    Any file with a name of the form "/proc/[0-9]+/stat"
@@ -387,7 +175,7 @@ static void _get_process_data() {
 	List prec_list = NULL;
 	pid_t *pids = NULL;
 	int npids = 0;
-
+	uint32_t total_job_mem = 0;
 	int		i, fd;
 	ListIterator itr;
 	ListIterator itr2;
@@ -433,7 +221,7 @@ static void _get_process_data() {
 			fcntl(fd, F_SETFD, FD_CLOEXEC);
 			
 			prec = xmalloc(sizeof(prec_t));
-			if (_get_process_data_line(stat_fp, prec))
+			if (_get_process_data_line(fd, prec))
 				list_append(prec_list, prec);
 			else 
 				xfree(prec);
@@ -499,7 +287,7 @@ static void _get_process_data() {
 			fcntl(fd, F_SETFD, FD_CLOEXEC);
 
 			prec = xmalloc(sizeof(prec_t));
-			if (_get_process_data_line(stat_fp, prec))
+			if (_get_process_data_line(fd, prec))
 				list_append(prec_list, prec);
 			else 
 				xfree(prec);
@@ -524,12 +312,17 @@ static void _get_process_data() {
 		itr2 = list_iterator_create(prec_list);
 		while((prec = list_next(itr2))) {
 			if (prec->pid == jobacct->pid) {
+#if _DEBUG
+				info("pid:%u ppid:%u rss:%d KB", 
+				     prec->pid, prec->ppid, prec->rss);
+#endif
 				/* find all my descendents */
 				_get_offspring_data(prec_list, 
 						    prec, prec->pid);
 				/* tally their usage */
 				jobacct->max_rss = jobacct->tot_rss = 
 					MAX(jobacct->max_rss, prec->rss);
+				total_job_mem += prec->rss;
 				jobacct->max_vsize = jobacct->tot_vsize = 
 					MAX(jobacct->max_vsize, prec->vsize);
 				jobacct->max_pages = jobacct->tot_pages =
@@ -537,74 +330,108 @@ static void _get_process_data() {
 				jobacct->min_cpu = jobacct->tot_cpu = 
 					MAX(jobacct->min_cpu, 
 					    (prec->usec + prec->ssec));
-				debug2("%d size now %d %d time %d",
+				debug2("%d mem size %u %u time %u",
 				      jobacct->pid, jobacct->max_rss, 
 				      jobacct->max_vsize, jobacct->tot_cpu);
-				
 				break;
 			}
 		}
 		list_iterator_destroy(itr2);
 	}
-	list_iterator_destroy(itr);	
+	list_iterator_destroy(itr);
 	slurm_mutex_unlock(&jobacct_lock);
-	
+
+	if (job_mem_limit) {
+		debug("Job %u memory used:%u limit:%u KB", 
+		      acct_job_id, total_job_mem, job_mem_limit);
+	}
+	if (acct_job_id && job_mem_limit && 
+	    (total_job_mem > job_mem_limit)) {
+		error("Job %u exceeded %u KB memory limit, being killed",
+		       acct_job_id, job_mem_limit);
+		_acct_kill_job();
+	}
+
 finished:
 	list_destroy(prec_list);
 	processing = 0;	
 	return;
 }
 
+/* _acct_kill_job() issue RPC to kill a slurm job */
+static void _acct_kill_job(void)
+{
+	slurm_msg_t msg;
+	job_step_kill_msg_t req;
+
+	slurm_msg_t_init(&msg);
+	/* 
+	 * Request message:
+	 */
+	req.job_id      = acct_job_id;
+	req.job_step_id = NO_VAL;
+	req.signal      = SIGKILL;
+	req.batch_flag  = 0;
+	msg.msg_type    = REQUEST_CANCEL_JOB_STEP;
+	msg.data        = &req;
+
+	slurm_send_only_controller_msg(&msg);
+}
+
 /* _get_process_data_line() - get line of data from /proc/<pid>/stat
  *
- * IN:	in - input file channel
+ * IN:	in - input file descriptor
  * OUT:	prec - the destination for the data
  *
  * RETVAL:	==0 - no valid data
  * 		!=0 - data are valid
  *
- * Note: It seems a bit wasteful to do all those atoi() and
- *       atol() conversions that are implicit in the scanf(),
- *       but they help to ensure that we really are looking at the
- *       expected type of record.
+ * Based upon stat2proc() from the ps command. It can handle arbitrary executable 
+ * file basenames for `cmd', i.e. those with embedded whitespace or embedded ')'s.  
+ * Such names confuse %s (see scanf(3)), so the string is split and %39c is used 
+ * instead. (except for embedded ')' "(%[^)]c)" would work.
  */
-static int _get_process_data_line(FILE *in, prec_t *prec) {
-	/* discardable data */
-	int		d;
-	char		c;
-	char		*s;
-	uint32_t	tmpu32;
-	int max_path_len = pathconf("/", _PC_NAME_MAX);
-
-	/* useful datum */
-	int		nvals;
-
-	s = xmalloc(max_path_len + 1);
-	nvals=fscanf(in,
-		     "%d %s %c %d %d "
-		     "%d %d %d %d %d "
-		     "%d %d %d %d %d "
-		     "%d %d %d %d %d "
-		     "%d %d %d %d %d", 
-		     &prec->pid, s, &c, &prec->ppid, &d,
-		     &d, &d, &d, &tmpu32, &tmpu32,
-		     &tmpu32, &prec->pages, &tmpu32, &prec->usec, &prec->ssec,
-		     &tmpu32, &tmpu32, &tmpu32, &tmpu32, &tmpu32,
-		     &tmpu32, &tmpu32, &prec->vsize, &prec->rss, &tmpu32);
-	/* The fields in the record are
-	 *	pid, command, state, ppid, pgrp,
-	 *	session, tty_nr, tpgid, flags, minflt,
-	 *	cminflt, majflt, cmajflt, utime, stime,
-	 *	cutime, cstime, priority, nice, lit_0,
-	 *	itrealvalue, starttime, vsize, rss, rlim
-	 */
-	xfree(s);
-	if (nvals != 25)	/* Is it what we expected? */
-		return 0;	/* No! */
-	
-	prec->rss *= getpagesize();	/* convert rss from pages to bytes */
-	prec->rss /= 1024;      	/* convert rss to kibibytes */
-	prec->vsize /= 1024;		/* and convert vsize to kibibytes */
+static int _get_process_data_line(int in, prec_t *prec) {
+	char sbuf[256], *tmp;
+	int num_read, nvals;
+	char cmd[40], state[1];
+	int ppid, pgrp, session, tty_nr, tpgid;
+	long unsigned flags, minflt, cminflt, majflt, cmajflt;
+	long unsigned utime, stime, starttime, vsize;
+	long int cutime, cstime, priority, nice, timeout, itrealvalue, rss;
+
+	num_read = read(in, sbuf, (sizeof(sbuf) - 1));
+	if (num_read <= 0)
+		return 0;
+	sbuf[num_read] = '\0';
+
+	tmp = strrchr(sbuf, ')');	/* split into "PID (cmd" and "<rest>" */
+	*tmp = '\0';			/* replace trailing ')' with NUL */
+	/* parse these two strings separately, skipping the leading "(". */
+	nvals = sscanf(sbuf, "%d (%39c", &prec->pid, cmd);
+	if (nvals < 2)
+		return 0;
+
+	nvals = sscanf(tmp + 2,		/* skip space after ')' too */
+		"%c %d %d %d %d %d "
+		"%lu %lu %lu %lu %lu "
+		"%lu %lu %ld %ld %ld %ld "
+		"%ld %ld %lu %lu %ld",
+		state, &ppid, &pgrp, &session, &tty_nr, &tpgid,
+		&flags, &minflt, &cminflt, &majflt, &cmajflt,
+		&utime, &stime, &cutime, &cstime, &priority, &nice,
+		&timeout, &itrealvalue, &starttime, &vsize, &rss);
+	/* There are some additional fields, which we do not scan or use */
+	if ((nvals < 22) || (rss < 0))
+		return 0;
+
+	/* Copy the values that slurm records into our data structure */
+	prec->ppid  = ppid;
+	prec->pages = majflt;
+	prec->usec  = utime;
+	prec->ssec  = stime;
+	prec->vsize = vsize / 1024;		  /* convert from bytes to KB */
+	prec->rss   = rss * getpagesize() / 1024; /* convert from pages to KB */
 	return 1;
 }
 
@@ -629,7 +456,7 @@ static void *_watch_tasks(void *arg)
 	_task_sleep(1);
 
 	while(!jobacct_shutdown) {  /* Do this until shutdown is requested */
-		if(!suspended) {
+		if(!jobacct_suspended) {
 			_get_process_data();	/* Update the data */ 
 		}
 		_task_sleep(freq);
@@ -644,3 +471,186 @@ static void _destroy_prec(void *object)
 	xfree(prec);
 	return;
 }
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	char *temp = slurm_get_proctrack_type();
+	if(!strcasecmp(temp, "proctrack/pgid")) {
+		info("WARNING: We will use a much slower algorithm with "
+		     "proctrack/pgid, use Proctracktype=proctrack/linuxproc "
+		     "or Proctracktype=proctrack/rms with %s",
+		     plugin_name);
+		pgid_plugin = true;
+	}
+	xfree(temp);
+	temp = slurm_get_accounting_storage_type();
+	if(!strcasecmp(temp, ACCOUNTING_STORAGE_TYPE_NONE)) {
+		error("WARNING: Even though we are collecting accounting "
+		      "information you have asked for it not to be stored "
+		      "(%s) if this is not what you have in mind you will "
+		      "need to change it.", ACCOUNTING_STORAGE_TYPE_NONE);
+	}
+	xfree(temp);
+	verbose("%s loaded", plugin_name);
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+	return SLURM_SUCCESS;
+}
+
+extern struct jobacctinfo *jobacct_gather_p_create(jobacct_id_t *jobacct_id)
+{
+	return jobacct_common_alloc_jobacct(jobacct_id);
+}
+
+extern void jobacct_gather_p_destroy(struct jobacctinfo *jobacct)
+{
+	jobacct_common_free_jobacct(jobacct);
+}
+
+extern int jobacct_gather_p_setinfo(struct jobacctinfo *jobacct, 
+				    enum jobacct_data_type type, void *data)
+{
+	return jobacct_common_setinfo(jobacct, type, data);
+	
+}
+
+extern int jobacct_gather_p_getinfo(struct jobacctinfo *jobacct, 
+				    enum jobacct_data_type type, void *data)
+{
+	return jobacct_common_getinfo(jobacct, type, data);
+}
+
+extern void jobacct_gather_p_pack(struct jobacctinfo *jobacct, Buf buffer)
+{
+	jobacct_common_pack(jobacct, buffer);
+}
+
+extern int jobacct_gather_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
+{
+	return jobacct_common_unpack(jobacct, buffer);
+}
+
+extern void jobacct_gather_p_aggregate(struct jobacctinfo *dest,
+				       struct jobacctinfo *from)
+{
+	jobacct_common_aggregate(dest, from);
+}
+
+/*
+ * jobacct_startpoll() is called when the plugin is loaded by
+ * slurmd, before any other functions are called.  Put global
+ * initialization here.
+ */
+
+extern int jobacct_gather_p_startpoll(uint16_t frequency)
+{
+	int rc = SLURM_SUCCESS;
+	
+	pthread_attr_t attr;
+	pthread_t _watch_tasks_thread_id;
+	 
+	debug("%s loaded", plugin_name);
+
+	debug("jobacct-gather: frequency = %d", frequency);
+		
+	jobacct_shutdown = false;
+	
+	if (frequency == 0) {	/* don't want dynamic monitoring? */
+		debug2("jobacct-gather LINUX dynamic logging disabled");
+		return rc;
+	}
+
+	freq = frequency;
+	task_list = list_create(jobacct_common_free_jobacct);
+	
+	/* create polling thread */
+	slurm_attr_init(&attr);
+	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
+		error("pthread_attr_setdetachstate error %m");
+	
+	if  (pthread_create(&_watch_tasks_thread_id, &attr,
+			    &_watch_tasks, NULL)) {
+		debug("jobacct-gather failed to create _watch_tasks "
+		      "thread: %m");
+		frequency = 0;
+	}
+	else 
+		debug3("jobacct-gather LINUX dynamic logging enabled");
+	slurm_attr_destroy(&attr);
+	
+	return rc;
+}
+
+extern int jobacct_gather_p_endpoll()
+{
+	slurm_mutex_lock(&jobacct_lock);
+	if(task_list)
+		list_destroy(task_list);
+	task_list = NULL;
+	slurm_mutex_unlock(&jobacct_lock);
+	
+	if (slash_proc) {
+		slurm_mutex_lock(&reading_mutex);
+		(void) closedir(slash_proc);
+		slurm_mutex_unlock(&reading_mutex);
+	}
+
+	jobacct_shutdown = true;
+	
+	return SLURM_SUCCESS;
+}
+
+extern void jobacct_gather_p_change_poll(uint16_t frequency)
+{
+	freq = frequency;
+	if (freq == 0)
+		jobacct_shutdown = true;
+	return;
+}
+
+extern void jobacct_gather_p_suspend_poll()
+{
+	jobacct_common_suspend_poll();
+}
+
+extern void jobacct_gather_p_resume_poll()
+{
+	jobacct_common_resume_poll();
+}
+
+extern int jobacct_gather_p_set_proctrack_container_id(uint32_t id)
+{
+	return jobacct_common_set_proctrack_container_id(id);
+}
+
+extern int jobacct_gather_p_add_task(pid_t pid, jobacct_id_t *jobacct_id)
+{
+	return jobacct_common_add_task(pid, jobacct_id);
+}
+
+
+extern struct jobacctinfo *jobacct_gather_p_stat_task(pid_t pid)
+{
+	_get_process_data();
+	return jobacct_common_stat_task(pid);
+}
+
+extern struct jobacctinfo *jobacct_gather_p_remove_task(pid_t pid)
+{
+	return jobacct_common_remove_task(pid);
+}
+
+extern void jobacct_gather_p_2_sacct(sacct_t *sacct, 
+				     struct jobacctinfo *jobacct)
+{
+	jobacct_common_2_sacct(sacct, jobacct);
+}
+
+
diff --git a/src/plugins/jobacct_gather/none/Makefile.am b/src/plugins/jobacct_gather/none/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..08c8420b0a6245474a6920cc2ee4fbfaf8373044
--- /dev/null
+++ b/src/plugins/jobacct_gather/none/Makefile.am
@@ -0,0 +1,13 @@
+# Makefile for jobacct_gather/none plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = jobacct_gather_none.la
+
+# Null job completion logging plugin.
+jobacct_gather_none_la_SOURCES = jobacct_gather_none.c
+jobacct_gather_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/jobacct/gold/Makefile.in b/src/plugins/jobacct_gather/none/Makefile.in
similarity index 86%
rename from src/plugins/jobacct/gold/Makefile.in
rename to src/plugins/jobacct_gather/none/Makefile.in
index a7710977ad036d9aa0ca3259b9931677ef55ff78..00d16a3999d80b1da751252160dcc44687630f30 100644
--- a/src/plugins/jobacct/gold/Makefile.in
+++ b/src/plugins/jobacct_gather/none/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# Makefile for jobacct/none plugin
+# Makefile for jobacct_gather/none plugin
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -35,7 +35,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-subdir = src/plugins/jobacct/gold
+subdir = src/plugins/jobacct_gather/none
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,14 +75,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-jobacct_gold_la_LIBADD =
-am_jobacct_gold_la_OBJECTS = agent.lo base64.lo gold_interface.lo \
-	jobacct_gold.lo
-jobacct_gold_la_OBJECTS = $(am_jobacct_gold_la_OBJECTS)
-jobacct_gold_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+jobacct_gather_none_la_LIBADD =
+am_jobacct_gather_none_la_OBJECTS = jobacct_gather_none.lo
+jobacct_gather_none_la_OBJECTS = $(am_jobacct_gather_none_la_OBJECTS)
+jobacct_gather_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(jobacct_gold_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+	$(jobacct_gather_none_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -92,8 +93,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(jobacct_gold_la_SOURCES)
-DIST_SOURCES = $(jobacct_gold_la_SOURCES)
+SOURCES = $(jobacct_gather_none_la_SOURCES)
+DIST_SOURCES = $(jobacct_gather_none_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -120,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -255,17 +267,12 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
-
-# Gold job completion logging plugin.
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-pkglib_LTLIBRARIES = jobacct_gold.la
-jobacct_gold_la_SOURCES = \
-			agent.c agent.h \
-			base64.c base64.h \
-			gold_interface.c gold_interface.h \
-			jobacct_gold.c
-
-jobacct_gold_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+pkglib_LTLIBRARIES = jobacct_gather_none.la
+
+# Null job completion logging plugin.
+jobacct_gather_none_la_SOURCES = jobacct_gather_none.c
+jobacct_gather_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -279,9 +286,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobacct/gold/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobacct_gather/none/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/plugins/jobacct/gold/Makefile
+	  $(AUTOMAKE) --foreign  src/plugins/jobacct_gather/none/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -305,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -314,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -326,8 +333,8 @@ clean-pkglibLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-jobacct_gold.la: $(jobacct_gold_la_OBJECTS) $(jobacct_gold_la_DEPENDENCIES) 
-	$(jobacct_gold_la_LINK) -rpath $(pkglibdir) $(jobacct_gold_la_OBJECTS) $(jobacct_gold_la_LIBADD) $(LIBS)
+jobacct_gather_none.la: $(jobacct_gather_none_la_OBJECTS) $(jobacct_gather_none_la_DEPENDENCIES) 
+	$(jobacct_gather_none_la_LINK) -rpath $(pkglibdir) $(jobacct_gather_none_la_OBJECTS) $(jobacct_gather_none_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -335,10 +342,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gold_interface.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_gold.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_gather_none.Plo@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -372,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -385,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -396,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobacct/none/jobacct_none.c b/src/plugins/jobacct_gather/none/jobacct_gather_none.c
similarity index 61%
rename from src/plugins/jobacct/none/jobacct_none.c
rename to src/plugins/jobacct_gather/none/jobacct_gather_none.c
index 25d995622ccfde8c97cf72def9942009668fe533..48df0bf2d23481485837767a1684b18123f41453 100644
--- a/src/plugins/jobacct/none/jobacct_none.c
+++ b/src/plugins/jobacct_gather/none/jobacct_gather_none.c
@@ -1,11 +1,10 @@
-
 /*****************************************************************************\
  *  jobacct_none.c - NO-OP slurm job completion logging plugin.
  *****************************************************************************
  *
  *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
  *  Written by Andy Riebs, <andy.riebs@hp.com>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -39,23 +38,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
 \*****************************************************************************/
 
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <stdio.h>
-#include <slurm/slurm_errno.h>
-
-#include "src/slurmctld/slurmctld.h"
-#include "src/slurmd/slurmd/slurmd.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobacct_gather.h"
 
 /*
  * These variables are required by the generic plugin interface.  If they
@@ -86,8 +69,8 @@
  * minimum versions for their plugins as the job accounting API 
  * matures.
  */
-const char plugin_name[] = "Job accounting NOT_INVOKED plugin";
-const char plugin_type[] = "jobacct/none";
+const char plugin_name[] = "Job accounting gather NOT_INVOKED plugin";
+const char plugin_type[] = "jobacct_gather/none";
 const uint32_t plugin_version = 100;
 
 /*
@@ -105,153 +88,95 @@ extern int fini ( void )
 	return SLURM_SUCCESS;
 }
 
-/*
- * The following routines are called by slurmctld
- */
-
-/*
- * The following routines are called by slurmd
- */
-int jobacct_p_init_struct(struct jobacctinfo *jobacct, 
-			  jobacct_id_t *jobacct_id)
-{
-	return SLURM_SUCCESS;
-}
-
-struct jobacctinfo *jobacct_p_alloc(jobacct_id_t *jobacct_id)
+extern jobacctinfo_t *jobacct_gather_p_create(jobacct_id_t *jobacct_id)
 {
 	return NULL;
 }
 
-void jobacct_p_free(struct jobacctinfo *jobacct)
+extern void jobacct_gather_p_destroy(struct jobacctinfo *jobacct)
 {
 	return;
 }
 
-int jobacct_p_setinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
+extern int jobacct_gather_p_setinfo(struct jobacctinfo *jobacct, 
+				    enum jobacct_data_type type, void *data)
 {
 	return SLURM_SUCCESS;
 	
 }
 
-int jobacct_p_getinfo(struct jobacctinfo *jobacct, 
-		      enum jobacct_data_type type, void *data)
+extern int jobacct_gather_p_getinfo(struct jobacctinfo *jobacct, 
+				    enum jobacct_data_type type, void *data)
 {
 	return SLURM_SUCCESS;
 }
 
-void jobacct_p_aggregate(struct jobacctinfo *dest, struct jobacctinfo *from)
+extern void jobacct_gather_p_pack(struct jobacctinfo *jobacct, Buf buffer)
 {
 	return;
 }
 
-void jobacct_p_2_sacct(sacct_t *sacct, struct jobacctinfo *jobacct)
-{
-	return;
-}
-
-void jobacct_p_pack(struct jobacctinfo *jobacct, Buf buffer)
-{
-	return;
-}
-
-int jobacct_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
+extern int jobacct_gather_p_unpack(struct jobacctinfo **jobacct, Buf buffer)
 {
 	*jobacct = NULL;
 	return SLURM_SUCCESS;
 }
 
-
-int jobacct_p_init_slurmctld(char *job_acct_log)
+extern void jobacct_gather_p_aggregate(struct jobacctinfo *dest,
+				       struct jobacctinfo *from)
 {
-	return SLURM_SUCCESS;
+	return;
 }
 
-int jobacct_p_fini_slurmctld()
+extern int jobacct_gather_p_startpoll(uint16_t frequency)
 {
 	return SLURM_SUCCESS;
 }
 
-int jobacct_p_job_start_slurmctld(struct job_record *job_ptr)
+extern int jobacct_gather_p_endpoll()
 {
 	return SLURM_SUCCESS;
 }
 
-int jobacct_p_job_complete_slurmctld(struct job_record *job_ptr) 
-{
-	return  SLURM_SUCCESS;
-}
-
-int jobacct_p_step_start_slurmctld(struct step_record *step)
+extern void jobacct_gather_p_change_poll(uint16_t frequency)
 {
-	return SLURM_SUCCESS;	
-}
-
-int jobacct_p_step_complete_slurmctld(struct step_record *step)
-{
-	return SLURM_SUCCESS;	
+	return;
 }
 
-int jobacct_p_suspend_slurmctld(struct job_record *job_ptr)
+extern void jobacct_gather_p_suspend_poll()
 {
-	return SLURM_SUCCESS;
+	return;
 }
 
-int jobacct_p_startpoll(int frequency)
+extern void jobacct_gather_p_resume_poll()
 {
-	info("jobacct NONE plugin loaded");
-	debug3("slurmd_jobacct_init() called");
-	
-	return SLURM_SUCCESS;
+	return;
 }
 
-int jobacct_p_endpoll()
+extern int jobacct_gather_p_set_proctrack_container_id(uint32_t id)
 {
 	return SLURM_SUCCESS;
 }
 
-int jobacct_p_set_proctrack_container_id(uint32_t id)
+extern int jobacct_gather_p_add_task(pid_t pid, jobacct_id_t *jobacct_id)
 {
 	return SLURM_SUCCESS;
 }
 
-int jobacct_p_add_task(pid_t pid, jobacct_id_t *jobacct_id)
-{
-	return SLURM_SUCCESS;
-}
 
-struct jobacctinfo *jobacct_p_stat_task(pid_t pid)
+extern jobacctinfo_t *jobacct_gather_p_stat_task(pid_t pid)
 {
 	return NULL;
 }
 
-struct jobacctinfo *jobacct_p_remove_task(pid_t pid)
+extern jobacctinfo_t *jobacct_gather_p_remove_task(pid_t pid)
 {
 	return NULL;
 }
 
-void jobacct_p_suspend_poll()
-{
-	return;
-}
-
-void jobacct_p_resume_poll()
+extern void jobacct_gather_p_2_sacct(sacct_t *sacct, 
+				     struct jobacctinfo *jobacct)
 {
 	return;
 }
 
-extern int jobacct_p_node_down(struct node_record *node_ptr,
-			       time_t event_time, char *reason)
-{
-	return SLURM_SUCCESS;
-}
-extern int jobacct_p_node_up(struct node_record *node_ptr, time_t event_time)
-{
-	return SLURM_SUCCESS;
-}
-extern int jobacct_p_cluster_procs(uint32_t procs, time_t event_time)
-{
-	return SLURM_SUCCESS;
-}
-
diff --git a/src/plugins/jobcomp/Makefile.am b/src/plugins/jobcomp/Makefile.am
index 49d7c632bef5d37b5a62c36ebc2170c3e26768b3..0f2d169d4f9ad29d79ab9a1d54360f3540a7c26a 100644
--- a/src/plugins/jobcomp/Makefile.am
+++ b/src/plugins/jobcomp/Makefile.am
@@ -1,3 +1,3 @@
 # Makefile for jobcomp plugins
 
-SUBDIRS = filetxt none script
+SUBDIRS = filetxt none script mysql pgsql slurmdbd
diff --git a/src/plugins/jobcomp/Makefile.in b/src/plugins/jobcomp/Makefile.in
index 756a9dcb2c7e4156c19fa5bbf97bccda80d9bfac..c83e5dd7c7000e3db575ae62cc9470dea86f96a5 100644
--- a/src/plugins/jobcomp/Makefile.in
+++ b/src/plugins/jobcomp/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -234,7 +247,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = filetxt none script
+SUBDIRS = filetxt none script mysql pgsql slurmdbd
 all: all-recursive
 
 .SUFFIXES:
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobcomp/filetxt/Makefile.am b/src/plugins/jobcomp/filetxt/Makefile.am
index 0c48f13ec11aa6a0692325d297cc9a1c6a800bb4..0967681839473cbd24f497109ce519ecbe35dc11 100644
--- a/src/plugins/jobcomp/filetxt/Makefile.am
+++ b/src/plugins/jobcomp/filetxt/Makefile.am
@@ -9,5 +9,7 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
 pkglib_LTLIBRARIES = jobcomp_filetxt.la
 
 # Text file job completion logging plugin.
-jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c
+jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c \
+			filetxt_jobcomp_process.c filetxt_jobcomp_process.h
+
 jobcomp_filetxt_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/jobcomp/filetxt/Makefile.in b/src/plugins/jobcomp/filetxt/Makefile.in
index ce8f66b1c549ccb20603522f8b601fd055729bdb..860015aaaaffc892fefa842d5972b2774b97ad3a 100644
--- a/src/plugins/jobcomp/filetxt/Makefile.in
+++ b/src/plugins/jobcomp/filetxt/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -74,12 +76,13 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
 jobcomp_filetxt_la_LIBADD =
-am_jobcomp_filetxt_la_OBJECTS = jobcomp_filetxt.lo
+am_jobcomp_filetxt_la_OBJECTS = jobcomp_filetxt.lo \
+	filetxt_jobcomp_process.lo
 jobcomp_filetxt_la_OBJECTS = $(am_jobcomp_filetxt_la_OBJECTS)
 jobcomp_filetxt_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(jobcomp_filetxt_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +122,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +136,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +162,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +176,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +193,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +209,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -258,7 +272,9 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
 pkglib_LTLIBRARIES = jobcomp_filetxt.la
 
 # Text file job completion logging plugin.
-jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c
+jobcomp_filetxt_la_SOURCES = jobcomp_filetxt.c \
+			filetxt_jobcomp_process.c filetxt_jobcomp_process.h
+
 jobcomp_filetxt_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
 all: all-am
 
@@ -299,8 +315,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +324,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -329,6 +345,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filetxt_jobcomp_process.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_filetxt.Plo@am__quote@
 
 .c.o:
@@ -363,8 +380,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +393,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +404,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobcomp/filetxt/filetxt_jobcomp_process.c b/src/plugins/jobcomp/filetxt/filetxt_jobcomp_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..dd882778d57983d8707fe208c576795cf0d47a7b
--- /dev/null
+++ b/src/plugins/jobcomp/filetxt/filetxt_jobcomp_process.c
@@ -0,0 +1,300 @@
+/*****************************************************************************\
+ *  filetxt_jobcomp_process.c - functions the processing of
+ *                               information from the filetxt jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+#include "src/common/xstring.h"
+#include "src/common/xmalloc.h"
+#include "src/common/slurm_jobcomp.h"
+#include "filetxt_jobcomp_process.h"
+
+typedef struct {
+	char *name;
+	char *val;
+} filetxt_jobcomp_info_t;
+
+
+static void _destroy_filetxt_jobcomp_info(void *object)
+{
+	filetxt_jobcomp_info_t *jobcomp_info =
+		(filetxt_jobcomp_info_t *)object;
+	if(jobcomp_info) {
+		xfree(jobcomp_info);
+	}
+}
+
+
+/* _open_log_file() -- find the current or specified log file, and open it
+ *
+ * IN:		Nothing
+ * RETURNS:	Nothing
+ *
+ * Side effects:
+ * 	- Sets opt_filein to the current system accounting log unless
+ * 	  the user specified another file.
+ */
+
+static FILE *_open_log_file(char *logfile)
+{
+	FILE *fd = fopen(logfile, "r");
+	if (fd == NULL) {
+		perror(logfile);
+		exit(1);
+	}
+	return fd;
+}
+
+static void _do_fdump(List job_info_list, int lc)
+{
+	filetxt_jobcomp_info_t *jobcomp_info = NULL;
+	ListIterator itr = list_iterator_create(job_info_list);
+
+	printf("\n------- Line %d -------\n", lc);
+	while((jobcomp_info = list_next(itr))) {
+		printf("%12s: %s\n", jobcomp_info->name, jobcomp_info->val);
+	}
+}
+
+static jobcomp_job_rec_t *_parse_line(List job_info_list)
+{
+	ListIterator itr = NULL;
+	filetxt_jobcomp_info_t *jobcomp_info = NULL;
+	jobcomp_job_rec_t *job = xmalloc(sizeof(jobcomp_job_rec_t));
+	char *temp = NULL;
+	char *temp2 = NULL;
+
+	itr = list_iterator_create(job_info_list);
+	while((jobcomp_info = list_next(itr))) {
+		if(!strcasecmp("JobID", jobcomp_info->name)) {
+			job->jobid = atoi(jobcomp_info->val);
+		} else if(!strcasecmp("Partition", jobcomp_info->name)) {
+			job->partition = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("StartTime", jobcomp_info->name)) {
+			job->start_time = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("EndTime", jobcomp_info->name)) {
+			job->end_time = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("Userid", jobcomp_info->name)) {
+			temp = strstr(jobcomp_info->val, "(");
+			if(!temp) 
+				job->uid = atoi(jobcomp_info->val);
+			*temp++ = 0; 
+			temp2 = temp;
+			temp = strstr(temp, ")");
+			if(!temp) {
+				error("problem getting correct uid from %s",
+				      jobcomp_info->val);
+			} else {
+				*temp = 0;
+				job->uid = atoi(temp2);
+				job->uid_name = xstrdup(jobcomp_info->val);
+			}
+		} else if(!strcasecmp("GroupId", jobcomp_info->name)) {
+			temp = strstr(jobcomp_info->val, "(");
+			if(!temp) 
+				job->gid = atoi(jobcomp_info->val);
+			*temp++ = 0; 
+			temp2 = temp;
+			temp = strstr(temp, ")");
+			if(!temp) {
+				error("problem getting correct gid from %s",
+				      jobcomp_info->val);
+			} else {
+				*temp = 0;
+				job->gid = atoi(temp2);
+				job->gid_name = xstrdup(jobcomp_info->val);
+			}
+		} else if(!strcasecmp("Name", jobcomp_info->name)) {
+			job->jobname = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("NodeList", jobcomp_info->name)) {
+			job->nodelist = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("NodeCnt", jobcomp_info->name)) {
+			job->node_cnt = atoi(jobcomp_info->val);
+		} else if(!strcasecmp("JobState", jobcomp_info->name)) {
+			job->state = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("Timelimit", jobcomp_info->name)) {
+			job->timelimit = xstrdup(jobcomp_info->val);
+		}
+#ifdef HAVE_BG
+		else if(!strcasecmp("MaxProcs", jobcomp_info->name)) {
+			job->max_procs = atoi(jobcomp_info->val);
+		} else if(!strcasecmp("Block_Id", jobcomp_info->name)) {
+			job->blockid = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("Connection", jobcomp_info->name)) {
+			job->connection = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("reboot", jobcomp_info->name)) {
+			job->reboot = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("rotate", jobcomp_info->name)) {
+			job->rotate = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("geometry", jobcomp_info->name)) {
+			job->geo = xstrdup(jobcomp_info->val);
+		} else if(!strcasecmp("start", jobcomp_info->name)) {
+			job->bg_start_point = xstrdup(jobcomp_info->val);
+		}
+#endif
+		else {
+			error("Unknown type %s: %s", jobcomp_info->name,
+			      jobcomp_info->val);
+		}
+	}
+	list_iterator_destroy(itr);
+	
+	return job;
+}
+
+extern void filetxt_jobcomp_process_get_jobs(List job_list, 
+					      List selected_steps,
+					      List selected_parts,
+					      sacct_parameters_t *params)
+{
+	char line[BUFFER_SIZE];
+	char *fptr = NULL;
+	char *jobid = NULL;
+	char *partition = NULL;
+	FILE *fd = NULL;
+	int lc = 0;
+	jobcomp_job_rec_t *job = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	char *selected_part = NULL;
+	ListIterator itr = NULL;
+	List job_info_list = NULL;
+	filetxt_jobcomp_info_t *jobcomp_info = NULL;
+
+	fd = _open_log_file(params->opt_filein);
+	
+	while (fgets(line, BUFFER_SIZE, fd)) {
+		lc++;
+		fptr = line;	/* break the record into NULL-
+				   terminated strings */
+		if(job_info_list) 
+			list_destroy(job_info_list);
+		jobid = NULL;
+		partition = NULL;
+		job_info_list = list_create(_destroy_filetxt_jobcomp_info);
+		while(fptr) {
+			jobcomp_info =
+				xmalloc(sizeof(filetxt_jobcomp_info_t));
+			list_append(job_info_list, jobcomp_info);
+			jobcomp_info->name = fptr;
+			fptr = strstr(fptr, "=");
+			*fptr++ = 0;
+			jobcomp_info->val = fptr;
+			fptr = strstr(fptr, " ");
+			if(!strcasecmp("JobId", jobcomp_info->name)) 
+				jobid = jobcomp_info->val;
+			else if(!strcasecmp("Partition",
+					    jobcomp_info->name)) 
+				partition = jobcomp_info->val;
+			
+			
+			if(!fptr) {
+				fptr = strstr(jobcomp_info->val, "\n");
+				if (fptr)
+					*fptr = 0;
+				break; 
+			} else {
+				*fptr++ = 0;
+				if(*fptr == '\n') {
+					*fptr = 0;
+					break;
+				}
+			}
+		}
+				
+		if (list_count(selected_steps)) {
+			if(!jobid) 
+				continue;
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if (strcmp(selected_step->job, jobid))
+					continue;
+				/* job matches */
+				list_iterator_destroy(itr);
+				goto foundjob;
+			}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		}
+	foundjob:
+		
+		if (list_count(selected_parts)) {
+			if(!partition) 
+				continue;
+			itr = list_iterator_create(selected_parts);
+			while((selected_part = list_next(itr))) 
+				if (!strcasecmp(selected_part, partition)) {
+					list_iterator_destroy(itr);
+					goto foundp;
+				}
+			list_iterator_destroy(itr);
+			continue;	/* no match */
+		}
+	foundp:
+		
+		if (params->opt_fdump) {
+			_do_fdump(job_info_list, lc);
+			continue;
+		}
+		
+		
+		job = _parse_line(job_info_list);
+		
+		if(job)
+			list_append(job_list, job);
+	}
+	if(job_info_list) 
+		list_destroy(job_info_list);
+	
+	if (ferror(fd)) {
+		perror(params->opt_filein);
+		exit(1);
+	} 
+	fclose(fd);
+
+	return;
+}
+
+extern void filetxt_jobcomp_process_archive(List selected_parts,
+					     sacct_parameters_t *params)
+{
+	info("No code to archive jobcomp.");
+}
diff --git a/src/plugins/jobcomp/filetxt/filetxt_jobcomp_process.h b/src/plugins/jobcomp/filetxt/filetxt_jobcomp_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b2bb8776a97d45b16cbb5487cfd4586ebd4f922
--- /dev/null
+++ b/src/plugins/jobcomp/filetxt/filetxt_jobcomp_process.h
@@ -0,0 +1,55 @@
+/*****************************************************************************\
+ *  filetxt_jobcomp_process.h - functions the processing of
+ *                               information from the filetxt jobcomp
+ *                               database.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_FILETXT_JOBCOMP_PROCESS_H
+#define _HAVE_FILETXT_JOBCOMP_PROCESS_H
+
+#include "src/common/jobacct_common.h"
+
+extern void filetxt_jobcomp_process_get_jobs(List job_list, 
+					     List selected_steps,
+					     List selected_parts,
+					     sacct_parameters_t *params);
+extern void filetxt_jobcomp_process_archive(List selected_parts,
+					    sacct_parameters_t *params);
+
+#endif
diff --git a/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c b/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
index ebff6cafda052f266f1710dd85684cf1ad48672a..a4e67243babfa585bbb2747907873af586501f49 100644
--- a/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
+++ b/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -15,7 +15,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -47,37 +47,13 @@
 #endif
 
 #include <fcntl.h>
-#include <pthread.h>
 #include <pwd.h>
-#include <slurm/slurm.h>
-#include <slurm/slurm_errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <grp.h>
 #include <unistd.h>
-
-#include "src/common/macros.h"
-#include "src/common/node_select.h"
 #include "src/common/slurm_protocol_defs.h"
 #include "src/common/slurm_jobcomp.h"
-#include "src/common/uid.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/slurmctld/slurmctld.h"
-
-#define JOB_FORMAT "JobId=%lu UserId=%s(%lu) Name=%s JobState=%s Partition=%s "\
-		"TimeLimit=%s StartTime=%s EndTime=%s NodeList=%s NodeCnt=%u %s\n"
- 
-/* Type for error string table entries */
-typedef struct {
-	int xe_number;
-	char *xe_message;
-} slurm_errtab_t;
-
-static slurm_errtab_t slurm_errtab[] = {
-	{0, "No error"},
-	{-1, "Unspecified error"}
-};
+#include "src/common/parse_time.h"
+#include "filetxt_jobcomp_process.h"
 
 /*
  * These variables are required by the generic plugin interface.  If they
@@ -110,7 +86,21 @@ static slurm_errtab_t slurm_errtab[] = {
  */
 const char plugin_name[]       	= "Job completion text file logging plugin";
 const char plugin_type[]       	= "jobcomp/filetxt";
-const uint32_t plugin_version	= 90;
+const uint32_t plugin_version	= 100;
+
+#define JOB_FORMAT "JobId=%lu UserId=%s(%lu) GroupId=%s(%lu) Name=%s JobState=%s Partition=%s "\
+		"TimeLimit=%s StartTime=%s EndTime=%s NodeList=%s NodeCnt=%u ProcCnt=%u %s\n"
+ 
+/* Type for error string table entries */
+typedef struct {
+	int xe_number;
+	char *xe_message;
+} slurm_errtab_t;
+
+static slurm_errtab_t slurm_errtab[] = {
+	{0, "No error"},
+	{-1, "Unspecified error"}
+};
 
 /* A plugin-global errno. */
 static int plugin_errno = SLURM_SUCCESS;
@@ -119,6 +109,69 @@ static int plugin_errno = SLURM_SUCCESS;
 static pthread_mutex_t  file_lock = PTHREAD_MUTEX_INITIALIZER;
 static char *           log_name  = NULL;
 static int              job_comp_fd = -1;
+
+/* get the user name for the give user_id */
+static void
+_get_user_name(uint32_t user_id, char *user_name, int buf_size)
+{
+	static uint32_t cache_uid      = 0;
+	static char     cache_name[32] = "root";
+	struct passwd * user_info      = NULL;
+
+	if (user_id == cache_uid)
+		snprintf(user_name, buf_size, "%s", cache_name);
+	else {
+		user_info = getpwuid((uid_t) user_id);
+		if (user_info && user_info->pw_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				user_info->pw_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_uid = user_id;
+		snprintf(user_name, buf_size, "%s", cache_name);
+	}
+}
+
+/* get the group name for the give group_id */
+static void
+_get_group_name(uint32_t group_id, char *group_name, int buf_size)
+{
+	static uint32_t cache_gid      = 0;
+	static char     cache_name[32] = "root";
+	struct group  *group_info      = NULL;
+
+	if (group_id == cache_gid)
+		snprintf(group_name, buf_size, "%s", cache_name);
+	else {
+		group_info = getgrgid((gid_t) group_id);
+		if (group_info && group_info->gr_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				group_info->gr_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_gid = group_id;
+		snprintf(group_name, buf_size, "%s", cache_name);
+	}
+}
+
+/* 
+ * Linear search through table of errno values and strings,
+ * returns NULL on error, string on success.
+ */
+static char *_lookup_slurm_api_errtab(int errnum)
+{
+	char *res = NULL;
+	int i;
+
+	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
+		if (slurm_errtab[i].xe_number == errnum) {
+			res = slurm_errtab[i].xe_message;
+			break;
+		}
+	}
+	return res;
+}
+
 /*
  * init() is called when the plugin is loaded, before any other functions
  * are called.  Put global initialization here.
@@ -128,12 +181,20 @@ int init ( void )
 	return SLURM_SUCCESS;
 }
 
+int fini ( void )
+{
+	if (job_comp_fd >= 0)
+		close(job_comp_fd);
+	xfree(log_name);
+	return SLURM_SUCCESS;
+}
+
 /*
  * The remainder of this file implements the standard SLURM job completion
  * logging API.
  */
 
-int slurm_jobcomp_set_location ( char * location )
+extern int slurm_jobcomp_set_location ( char * location )
 {
 	int rc = SLURM_SUCCESS;
 
@@ -158,51 +219,11 @@ int slurm_jobcomp_set_location ( char * location )
 	return rc;
 }
 
-/* get the user name for the give user_id */
-static void
-_get_user_name(uint32_t user_id, char *user_name, int buf_size)
-{
-	static uint32_t cache_uid      = 0;
-	static char     cache_name[32] = "root";
-	struct passwd * user_info      = NULL;
-
-	if (user_id == cache_uid)
-		snprintf(user_name, buf_size, "%s", cache_name);
-	else {
-		user_info = getpwuid((uid_t) user_id);
-		if (user_info && user_info->pw_name[0])
-			snprintf(cache_name, sizeof(cache_name), "%s", 
-				user_info->pw_name);
-		else
-			snprintf(cache_name, sizeof(cache_name), "Unknown");
-		cache_uid = user_id;
-		snprintf(user_name, buf_size, "%s", cache_name);
-	}
-}
-
-/*
- * make_time_str - convert time_t to string with "YYYY-MM-DDTHH:MM:SS"
- *                 Note this is the ISO8601 standard format 
- * IN time     - a time stamp
- * IN str_size - size of string buffer
- * OUT string  - pointer user defined buffer
- */
-static void
-_make_time_str (time_t *time, char *string, int str_size)
-{
-	struct tm time_tm;
-
-	localtime_r (time, &time_tm);
-	snprintf ( string, str_size, "%4.4u-%2.2u-%2.2uT%2.2u:%2.2u:%2.2u",
-		(time_tm.tm_year + 1900), (time_tm.tm_mon+1), time_tm.tm_mday,
-		time_tm.tm_hour, time_tm.tm_min, time_tm.tm_sec);
-}
-
-int slurm_jobcomp_log_record ( struct job_record *job_ptr )
+extern int slurm_jobcomp_log_record ( struct job_record *job_ptr )
 {
 	int rc = SLURM_SUCCESS;
-	char job_rec[512+MAX_JOBNAME_LEN];
-	char usr_str[32], start_str[32], end_str[32], lim_str[32];
+	char job_rec[1024];
+	char usr_str[32], grp_str[32], start_str[32], end_str[32], lim_str[32];
 	char select_buf[128];
 	size_t offset = 0, tot_size, wrote;
 	enum job_states job_state;
@@ -214,6 +235,7 @@ int slurm_jobcomp_log_record ( struct job_record *job_ptr )
 
 	slurm_mutex_lock( &file_lock );
 	_get_user_name(job_ptr->user_id, usr_str, sizeof(usr_str));
+	_get_group_name(job_ptr->group_id, grp_str, sizeof(grp_str));
 	if (job_ptr->time_limit == INFINITE)
 		strcpy(lim_str, "UNLIMITED");
 	else
@@ -225,19 +247,22 @@ int slurm_jobcomp_log_record ( struct job_record *job_ptr )
 	 * JOB_FAILED, JOB_TIMEOUT, etc. */
 	job_state = job_ptr->job_state & (~JOB_COMPLETING);
 
-	_make_time_str(&(job_ptr->start_time), start_str, sizeof(start_str));
-	_make_time_str(&(job_ptr->end_time),   end_str,   sizeof(end_str));
+	slurm_make_time_str(&(job_ptr->start_time),
+			    start_str, sizeof(start_str));
+	slurm_make_time_str(&(job_ptr->end_time), end_str, sizeof(end_str));
 
 	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
 		select_buf, sizeof(select_buf), SELECT_PRINT_MIXED);
 
 	snprintf(job_rec, sizeof(job_rec), JOB_FORMAT,
-			(unsigned long) job_ptr->job_id, usr_str, 
-			(unsigned long) job_ptr->user_id, job_ptr->name, 
-			job_state_string(job_state), 
-			job_ptr->partition, lim_str, start_str, 
-			end_str, job_ptr->nodes, job_ptr->node_cnt,
-			select_buf);
+		 (unsigned long) job_ptr->job_id, usr_str, 
+		 (unsigned long) job_ptr->user_id, grp_str, 
+		 (unsigned long) job_ptr->group_id, job_ptr->name, 
+		 job_state_string(job_state), 
+		 job_ptr->partition, lim_str, start_str, 
+		 end_str, job_ptr->nodes, job_ptr->node_cnt,
+		 job_ptr->total_procs,
+		 select_buf);
 	tot_size = strlen(job_rec);
 
 	while ( offset < tot_size ) {
@@ -263,34 +288,33 @@ extern int slurm_jobcomp_get_errno( void )
 	return plugin_errno;
 }
 
-/* 
- * Linear search through table of errno values and strings,
- * returns NULL on error, string on success.
- */
-static char *_lookup_slurm_api_errtab(int errnum)
-{
-	char *res = NULL;
-	int i;
-
-	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
-		if (slurm_errtab[i].xe_number == errnum) {
-			res = slurm_errtab[i].xe_message;
-			break;
-		}
-	}
-	return res;
-}
-
 extern char *slurm_jobcomp_strerror( int errnum )
 {
 	char *res = _lookup_slurm_api_errtab(errnum);
 	return (res ? res : strerror(errnum));
 }
 
-int fini ( void )
+/* 
+ * get info from the database 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern void slurm_jobcomp_get_jobs(List job_list, 
+				      List selected_steps, List selected_parts,
+				      void *params)
 {
-	if (job_comp_fd >= 0)
-		close(job_comp_fd);
-	xfree(log_name);
-	return SLURM_SUCCESS;
+	filetxt_jobcomp_process_get_jobs(job_list, 
+					  selected_steps, selected_parts,
+					  params);	
+	return;
+}
+
+/* 
+ * expire old info from the database 
+ */
+extern void slurm_jobcomp_archive(List selected_parts,
+				     void *params)
+{
+	filetxt_jobcomp_process_archive(selected_parts, params);
+	return;
 }
diff --git a/src/plugins/jobcomp/mysql/Makefile.am b/src/plugins/jobcomp/mysql/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..44da93ece2005b4765cb8faf5fe158e404b3047a
--- /dev/null
+++ b/src/plugins/jobcomp/mysql/Makefile.am
@@ -0,0 +1,19 @@
+# Makefile for jobcomp/mysql plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = jobcomp_mysql.la
+
+# Mysql storage plugin.
+jobcomp_mysql_la_SOURCES = jobcomp_mysql.c \
+			mysql_jobcomp_process.c mysql_jobcomp_process.h
+jobcomp_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobcomp_mysql_la_CFLAGS = $(MYSQL_CFLAGS)
+jobcomp_mysql_la_LIBADD  = $(top_builddir)/src/database/libslurm_mysql.la \
+	$(MYSQL_LIBS)
+jobcomp_mysql_la_DEPENDENCIES = $(top_builddir)/src/database/libslurm_mysql.la
+
diff --git a/src/plugins/jobcomp/mysql/Makefile.in b/src/plugins/jobcomp/mysql/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..bddbb69dd55c47975df1b2693178915ee991fa9a
--- /dev/null
+++ b/src/plugins/jobcomp/mysql/Makefile.in
@@ -0,0 +1,578 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for jobcomp/mysql plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/jobcomp/mysql
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+am_jobcomp_mysql_la_OBJECTS = jobcomp_mysql_la-jobcomp_mysql.lo \
+	jobcomp_mysql_la-mysql_jobcomp_process.lo
+jobcomp_mysql_la_OBJECTS = $(am_jobcomp_mysql_la_OBJECTS)
+jobcomp_mysql_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(jobcomp_mysql_la_CFLAGS) \
+	$(CFLAGS) $(jobcomp_mysql_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(jobcomp_mysql_la_SOURCES)
+DIST_SOURCES = $(jobcomp_mysql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = jobcomp_mysql.la
+
+# Mysql storage plugin.
+jobcomp_mysql_la_SOURCES = jobcomp_mysql.c \
+			mysql_jobcomp_process.c mysql_jobcomp_process.h
+
+jobcomp_mysql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobcomp_mysql_la_CFLAGS = $(MYSQL_CFLAGS)
+jobcomp_mysql_la_LIBADD = $(top_builddir)/src/database/libslurm_mysql.la \
+	$(MYSQL_LIBS)
+
+jobcomp_mysql_la_DEPENDENCIES = $(top_builddir)/src/database/libslurm_mysql.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobcomp/mysql/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/jobcomp/mysql/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+jobcomp_mysql.la: $(jobcomp_mysql_la_OBJECTS) $(jobcomp_mysql_la_DEPENDENCIES) 
+	$(jobcomp_mysql_la_LINK) -rpath $(pkglibdir) $(jobcomp_mysql_la_OBJECTS) $(jobcomp_mysql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_mysql_la-jobcomp_mysql.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_mysql_la-mysql_jobcomp_process.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+jobcomp_mysql_la-jobcomp_mysql.lo: jobcomp_mysql.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_mysql_la_CFLAGS) $(CFLAGS) -MT jobcomp_mysql_la-jobcomp_mysql.lo -MD -MP -MF $(DEPDIR)/jobcomp_mysql_la-jobcomp_mysql.Tpo -c -o jobcomp_mysql_la-jobcomp_mysql.lo `test -f 'jobcomp_mysql.c' || echo '$(srcdir)/'`jobcomp_mysql.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/jobcomp_mysql_la-jobcomp_mysql.Tpo $(DEPDIR)/jobcomp_mysql_la-jobcomp_mysql.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='jobcomp_mysql.c' object='jobcomp_mysql_la-jobcomp_mysql.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_mysql_la_CFLAGS) $(CFLAGS) -c -o jobcomp_mysql_la-jobcomp_mysql.lo `test -f 'jobcomp_mysql.c' || echo '$(srcdir)/'`jobcomp_mysql.c
+
+jobcomp_mysql_la-mysql_jobcomp_process.lo: mysql_jobcomp_process.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_mysql_la_CFLAGS) $(CFLAGS) -MT jobcomp_mysql_la-mysql_jobcomp_process.lo -MD -MP -MF $(DEPDIR)/jobcomp_mysql_la-mysql_jobcomp_process.Tpo -c -o jobcomp_mysql_la-mysql_jobcomp_process.lo `test -f 'mysql_jobcomp_process.c' || echo '$(srcdir)/'`mysql_jobcomp_process.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/jobcomp_mysql_la-mysql_jobcomp_process.Tpo $(DEPDIR)/jobcomp_mysql_la-mysql_jobcomp_process.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mysql_jobcomp_process.c' object='jobcomp_mysql_la-mysql_jobcomp_process.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_mysql_la_CFLAGS) $(CFLAGS) -c -o jobcomp_mysql_la-mysql_jobcomp_process.lo `test -f 'mysql_jobcomp_process.c' || echo '$(srcdir)/'`mysql_jobcomp_process.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/jobcomp/mysql/jobcomp_mysql.c b/src/plugins/jobcomp/mysql/jobcomp_mysql.c
new file mode 100644
index 0000000000000000000000000000000000000000..46a139d9bc9a4e0c644c3c3fc3ff06cb08ea3736
--- /dev/null
+++ b/src/plugins/jobcomp/mysql/jobcomp_mysql.c
@@ -0,0 +1,459 @@
+/*****************************************************************************\
+ *  jobcomp_mysql.c - Store/Get all information in a mysql storage.
+ *
+ *  $Id: storage_mysql.c 10893 2007-01-29 21:53:48Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "mysql_jobcomp_process.h"
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
+#include "src/common/parse_time.h"
+#include "src/common/node_select.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Job completion MYSQL plugin";
+const char plugin_type[] = "jobcomp/mysql";
+const uint32_t plugin_version = 100;
+
+#ifdef HAVE_MYSQL
+
+#define DEFAULT_JOBCOMP_DB "slurm_jobcomp_db"
+
+MYSQL *jobcomp_mysql_db = NULL;
+
+char *jobcomp_table = "jobcomp_table";
+storage_field_t jobcomp_table_fields[] = {
+	{ "jobid", "int not null" },
+	{ "uid", "smallint unsigned not null" },
+	{ "user_name", "tinytext not null" },
+	{ "gid", "smallint unsigned not null" },
+	{ "group_name", "tinytext not null" },
+	{ "name", "tinytext not null" },
+	{ "state", "smallint not null" },
+	{ "partition", "tinytext not null" }, 
+	{ "timelimit", "tinytext not null" },
+	{ "starttime", "int unsigned default 0 not null" }, 
+	{ "endtime", "int unsigned default 0 not null" },
+	{ "nodelist", "text" }, 
+	{ "nodecnt", "mediumint unsigned not null" },
+	{ "proc_cnt", "mediumint unsigned not null" },
+#ifdef HAVE_BG
+	{ "connect_type", "tinytext" },
+	{ "reboot", "tinytext" },
+	{ "rotate", "tinytext" },
+	{ "maxprocs", "mediumint unsigned default 0 not null" },
+	{ "geometry", "tinytext" },
+	{ "start", "tinytext" },
+	{ "blockid", "tinytext" },
+#endif
+	{ NULL, NULL}
+};
+
+
+/* Type for error string table entries */
+typedef struct {
+	int xe_number;
+	char *xe_message;
+} slurm_errtab_t;
+
+static slurm_errtab_t slurm_errtab[] = {
+	{0, "No error"},
+	{-1, "Unspecified error"}
+};
+
+/* A plugin-global errno. */
+static int plugin_errno = SLURM_SUCCESS;
+
+/* File descriptor used for logging */
+static pthread_mutex_t  jobcomp_lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static mysql_db_info_t *_mysql_jobcomp_create_db_info()
+{
+	mysql_db_info_t *db_info = xmalloc(sizeof(mysql_db_info_t));
+	db_info->port = slurm_get_jobcomp_port();
+	if(!db_info->port) 
+		db_info->port = 3306;
+	db_info->host = slurm_get_jobcomp_host();	
+	db_info->user = slurm_get_jobcomp_user();	
+	db_info->pass = slurm_get_jobcomp_pass();	
+	return db_info;
+}
+
+static int _mysql_jobcomp_check_tables()
+{
+	if(mysql_db_create_table(jobcomp_mysql_db, jobcomp_table,
+				 jobcomp_table_fields, ")") == SLURM_ERROR)
+		return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+
+/* get the user name for the give user_id */
+static char *_get_user_name(uint32_t user_id)
+{
+	static uint32_t cache_uid      = 0;
+	static char     cache_name[32] = "root";
+	struct passwd * user_info      = NULL;
+	char *ret_name = NULL;
+
+	slurm_mutex_lock(&jobcomp_lock);
+	if (user_id != cache_uid) {
+		user_info = getpwuid((uid_t) user_id);
+		if (user_info && user_info->pw_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				user_info->pw_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_uid = user_id;
+	}
+	ret_name = xstrdup(cache_name);
+	slurm_mutex_unlock(&jobcomp_lock);
+
+	return ret_name;
+}
+
+/* get the group name for the give group_id */
+static char *_get_group_name(uint32_t group_id)
+{
+	static uint32_t cache_gid      = 0;
+	static char     cache_name[32] = "root";
+	struct group  *group_info      = NULL;
+	char *ret_name = NULL;
+
+	slurm_mutex_lock(&jobcomp_lock);
+	if (group_id != cache_gid) {
+		group_info = getgrgid((gid_t) group_id);
+		if (group_info && group_info->gr_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				 group_info->gr_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_gid = group_id;
+	}
+	ret_name = xstrdup(cache_name);
+	slurm_mutex_unlock(&jobcomp_lock);
+
+	return ret_name;
+}
+
+/* 
+ * Linear search through table of errno values and strings,
+ * returns NULL on error, string on success.
+ */
+static char *_lookup_slurm_api_errtab(int errnum)
+{
+	char *res = NULL;
+	int i;
+
+	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
+		if (slurm_errtab[i].xe_number == errnum) {
+			res = slurm_errtab[i].xe_message;
+			break;
+		}
+	}
+	return res;
+}
+#endif
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	static int first = 1;
+#ifndef HAVE_MYSQL
+	fatal("No MySQL storage was found on the machine. "
+	      "Please check the configure ran and run again.");
+#endif
+	if(first) {
+		/* since this can be loaded from many different places
+		   only tell us once. */
+		verbose("%s loaded", plugin_name);
+		first = 0;
+	} else {
+		debug4("%s loaded", plugin_name);
+	}
+	
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+#ifdef HAVE_MYSQL
+	if (jobcomp_mysql_db) {
+		mysql_close(jobcomp_mysql_db);
+		jobcomp_mysql_db = NULL;
+	}
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int slurm_jobcomp_set_location(char *location)
+{
+#ifdef HAVE_MYSQL
+	mysql_db_info_t *db_info = _mysql_jobcomp_create_db_info();
+	int rc = SLURM_SUCCESS;
+	char *db_name = NULL;
+	int i = 0;
+	
+	if(jobcomp_mysql_db && mysql_ping(jobcomp_mysql_db) == 0)
+		return SLURM_SUCCESS;
+	
+	if(!location)
+		db_name = DEFAULT_JOBCOMP_DB;
+	else {
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_JOBCOMP_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) 
+			db_name = DEFAULT_JOBCOMP_DB;
+		else
+			db_name = location;
+	}
+		
+	debug2("mysql_connect() called for db %s", db_name);
+	
+	mysql_get_db_connection(&jobcomp_mysql_db, db_name, db_info);
+	
+	rc = _mysql_jobcomp_check_tables();
+
+	destroy_mysql_db_info(db_info);
+
+	if(rc == SLURM_SUCCESS) 
+		debug("Jobcomp database init finished");
+	else
+		debug("Jobcomp database init failed");
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int slurm_jobcomp_log_record(struct job_record *job_ptr)
+{
+#ifdef HAVE_MYSQL
+	int rc = SLURM_SUCCESS;
+	char *usr_str = NULL, *grp_str = NULL, lim_str[32];
+#ifdef HAVE_BG
+	char connect_type[128];
+	char reboot[4];
+	char rotate[4];
+	char maxprocs[20];
+	char geometry[20];
+	char start[20];
+	char blockid[128];
+#endif
+	enum job_states job_state;
+	char query[1024];
+
+	if(!jobcomp_mysql_db || mysql_ping(jobcomp_mysql_db) != 0) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+	usr_str = _get_user_name(job_ptr->user_id);
+	grp_str = _get_group_name(job_ptr->group_id);
+	if (job_ptr->time_limit == INFINITE)
+		strcpy(lim_str, "UNLIMITED");
+	else
+		snprintf(lim_str, sizeof(lim_str), "%lu", 
+				(unsigned long) job_ptr->time_limit);
+
+	/* Job will typically be COMPLETING when this is called. 
+	 * We remove this flag to get the eventual completion state:
+	 * JOB_FAILED, JOB_TIMEOUT, etc. */
+	job_state = job_ptr->job_state & (~JOB_COMPLETING);
+
+#ifdef HAVE_BG
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		connect_type, sizeof(connect_type), SELECT_PRINT_CONNECTION);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		reboot, sizeof(reboot), SELECT_PRINT_REBOOT);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		rotate, sizeof(rotate), SELECT_PRINT_ROTATE);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		maxprocs, sizeof(maxprocs), SELECT_PRINT_MAX_PROCS);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		geometry, sizeof(geometry), SELECT_PRINT_GEOMETRY);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		start, sizeof(start), SELECT_PRINT_START);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		blockid, sizeof(blockid), SELECT_PRINT_BG_ID);
+#endif
+	snprintf(query, sizeof(query),
+		 "insert into %s (jobid, uid, user_name, gid, group_name, "
+		 "name, state, proc_cnt, "
+		 "partition, timelimit, starttime, endtime, nodelist, nodecnt"
+#ifdef HAVE_BG
+		 ", connect_type, reboot, rotate, maxprocs, geometry, "
+		 "start, blockid"
+#endif
+		 ") values (%u, %u, '%s', %u, '%s', '%s', %d, %u, "
+		 "'%s', '%s', %u, %u, '%s', %u"
+#ifdef HAVE_BG
+		 ", '%s', '%s', '%s', %s, '%s', '%s', '%s'"
+#endif
+		 ")",
+		 jobcomp_table, job_ptr->job_id, job_ptr->user_id, usr_str,
+		 job_ptr->group_id, grp_str, job_ptr->name,
+		 job_state, job_ptr->total_procs, job_ptr->partition, lim_str,
+		 (int)job_ptr->start_time, (int)job_ptr->end_time,
+		 job_ptr->nodes, job_ptr->node_cnt
+#ifdef HAVE_BG
+		 , connect_type, reboot, rotate, maxprocs, geometry,
+		 start, blockid
+#endif
+		);
+//	info("query = %s", query);
+	rc = mysql_db_query(jobcomp_mysql_db, query);
+	xfree(usr_str);
+	xfree(grp_str);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int slurm_jobcomp_get_errno(void)
+{
+#ifdef HAVE_MYSQL
+	return plugin_errno;
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern char *slurm_jobcomp_strerror(int errnum)
+{
+#ifdef HAVE_MYSQL
+	char *res = _lookup_slurm_api_errtab(errnum);
+	return (res ? res : strerror(errnum));
+#else
+	return NULL;
+#endif 
+}
+
+/* 
+ * get info from the storage 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List slurm_jobcomp_get_jobs(List selected_steps,
+				   List selected_parts,
+				   void *params)
+{
+	List job_list = NULL;
+				   
+#ifdef HAVE_MYSQL
+	if(!jobcomp_mysql_db || mysql_ping(jobcomp_mysql_db) != 0) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return job_list;
+		}
+		xfree(loc);
+	}
+
+	job_list = mysql_jobcomp_process_get_jobs(selected_steps,
+						  selected_parts,
+						  params);	
+#endif 
+	return job_list;
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void slurm_jobcomp_archive(List selected_parts, void *params)
+{
+#ifdef HAVE_MYSQL
+	if(!jobcomp_mysql_db || mysql_ping(jobcomp_mysql_db) != 0) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return;
+		}
+		xfree(loc);
+	}
+
+	mysql_jobcomp_process_archive(selected_parts, params);
+#endif 
+	return;
+}
diff --git a/src/plugins/jobcomp/mysql/mysql_jobcomp_process.c b/src/plugins/jobcomp/mysql/mysql_jobcomp_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..e6c51d81116a6f815ba63282ea9ed9e336cf1eea
--- /dev/null
+++ b/src/plugins/jobcomp/mysql/mysql_jobcomp_process.c
@@ -0,0 +1,207 @@
+/*****************************************************************************\
+ *  mysql_jobcomp_process.c - functions the processing of
+ *                               information from the mysql jobcomp
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "src/common/parse_time.h"
+#include "src/common/xstring.h"
+#include "mysql_jobcomp_process.h"
+
+#ifdef HAVE_MYSQL
+static void _do_fdump(MYSQL_ROW row, int lc)
+{	
+	int i = 0;
+	printf("\n------- Line %d -------\n", lc);	
+	while(jobcomp_table_fields[i].name) {
+		printf("%12s: %s\n",  jobcomp_table_fields[i].name, row[i]);
+		i++;
+	}
+
+	return;
+}
+
+extern List mysql_jobcomp_process_get_jobs(List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	MYSQL_RES *result = NULL;
+	MYSQL_ROW row;
+	int i;
+	int lc = 0;
+	jobcomp_job_rec_t *job = NULL;
+	char time_str[32];
+	time_t temp_time;
+	List job_list = list_create(jobcomp_destroy_job);
+		
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		xstrcat(extra, " where (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("jobid=%d",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		if(extra)
+			xstrcat(extra, " && (");
+		else
+			xstrcat(extra, " where (");
+		
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	i = 0;
+	while(jobcomp_table_fields[i].name) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, jobcomp_table_fields[i].name);
+		i++;
+	}
+	
+	query = xstrdup_printf("select %s from %s", tmp, jobcomp_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result =
+	     mysql_db_query_ret(jobcomp_mysql_db, query, 0))) {
+		xfree(query);
+		list_destroy(job_list);
+		return NULL;
+	}
+	xfree(query);
+
+	while((row = mysql_fetch_row(result))) {
+		lc++;
+
+		if (params->opt_fdump) {
+			_do_fdump(row, lc);
+			continue;
+		}
+		job = xmalloc(sizeof(jobcomp_job_rec_t));
+		if(row[JOBCOMP_REQ_JOBID])
+			job->jobid = atoi(row[JOBCOMP_REQ_JOBID]);
+		job->partition = xstrdup(row[JOBCOMP_REQ_PARTITION]);
+		temp_time = atoi(row[JOBCOMP_REQ_STARTTIME]);
+		slurm_make_time_str(&temp_time, 
+				    time_str, 
+				    sizeof(time_str));
+		
+		job->start_time = xstrdup(time_str);
+		temp_time = atoi(row[JOBCOMP_REQ_ENDTIME]);
+		slurm_make_time_str(&temp_time, 
+				    time_str, 
+				    sizeof(time_str));
+		
+		job->end_time = xstrdup(time_str);
+		if(row[JOBCOMP_REQ_UID])
+			job->uid = atoi(row[JOBCOMP_REQ_UID]);
+		job->uid_name = xstrdup(row[JOBCOMP_REQ_USER_NAME]);
+		if(row[JOBCOMP_REQ_GID])
+			job->gid = atoi(row[JOBCOMP_REQ_GID]);
+		job->gid_name = xstrdup(row[JOBCOMP_REQ_GROUP_NAME]);
+		job->jobname = xstrdup(row[JOBCOMP_REQ_NAME]);
+		job->nodelist = xstrdup(row[JOBCOMP_REQ_NODELIST]);
+		if(row[JOBCOMP_REQ_NODECNT])
+			job->node_cnt = atoi(row[JOBCOMP_REQ_NODECNT]);
+		if(row[JOBCOMP_REQ_STATE]) {
+			i = atoi(row[JOBCOMP_REQ_STATE]);
+			job->state = xstrdup(job_state_string(i));
+		}
+		job->timelimit = xstrdup(row[JOBCOMP_REQ_TIMELIMIT]);
+#ifdef HAVE_BG
+		if(row[JOBCOMP_REQ_MAXPROCS])
+			job->max_procs = atoi(row[JOBCOMP_REQ_MAXPROCS]);
+		job->connection = xstrdup(row[JOBCOMP_REQ_CONNECTION]);
+		job->reboot = xstrdup(row[JOBCOMP_REQ_REBOOT]);
+		job->rotate = xstrdup(row[JOBCOMP_REQ_ROTATE]);
+		job->geo = xstrdup(row[JOBCOMP_REQ_GEOMETRY]);
+		job->bg_start_point = xstrdup(row[JOBCOMP_REQ_START]);
+		job->blockid = xstrdup(row[JOBCOMP_REQ_BLOCKID]);
+#endif
+		list_append(job_list, job);
+	}
+		
+	mysql_free_result(result);
+	
+	return job_list;
+}
+
+extern void mysql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/jobcomp/mysql/mysql_jobcomp_process.h b/src/plugins/jobcomp/mysql/mysql_jobcomp_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..787b098c4aa9443524dfa9c03e2bfdf08d613bab
--- /dev/null
+++ b/src/plugins/jobcomp/mysql/mysql_jobcomp_process.h
@@ -0,0 +1,94 @@
+/*****************************************************************************\
+ *  mysql_jobcomp_process.h - functions the processing of
+ *                               information from the mysql jobcomp
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_MYSQL_JOBCOMP_PROCESS_H
+#define _HAVE_MYSQL_JOBCOMP_PROCESS_H
+
+#include "src/database/mysql_common.h"
+#include "src/common/slurm_jobacct_gather.h"
+#include "src/common/slurm_jobcomp.h"
+
+#ifdef HAVE_MYSQL
+extern MYSQL *jobcomp_mysql_db;
+extern int jobcomp_db_init;
+
+extern char *jobcomp_table;
+/* This variable and the following enum are related so if you change
+   the jobcomp_table_fields defined in mysql_jobcomp.c you must update
+   this enum accordingly.
+*/
+extern storage_field_t jobcomp_table_fields[];
+enum {
+	JOBCOMP_REQ_JOBID,
+	JOBCOMP_REQ_UID,
+	JOBCOMP_REQ_USER_NAME,
+	JOBCOMP_REQ_GID,
+	JOBCOMP_REQ_GROUP_NAME,
+	JOBCOMP_REQ_NAME,
+	JOBCOMP_REQ_STATE,
+	JOBCOMP_REQ_PARTITION,
+	JOBCOMP_REQ_TIMELIMIT,
+	JOBCOMP_REQ_STARTTIME,
+	JOBCOMP_REQ_ENDTIME,
+	JOBCOMP_REQ_NODELIST,
+	JOBCOMP_REQ_NODECNT,
+#ifdef HAVE_BG
+	JOBCOMP_REQ_CONNECTION,
+	JOBCOMP_REQ_REBOOT,
+	JOBCOMP_REQ_ROTATE,
+	JOBCOMP_REQ_MAXPROCS,
+	JOBCOMP_REQ_GEOMETRY,
+	JOBCOMP_REQ_START,
+	JOBCOMP_REQ_BLOCKID,
+#endif
+	JOBCOMP_REQ_COUNT		
+};
+
+extern List mysql_jobcomp_process_get_jobs(List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void mysql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/jobcomp/none/Makefile.in b/src/plugins/jobcomp/none/Makefile.in
index ef118a378557261b81910493376f79835e9e77f9..5d4d646c0b18b4628c0d5a119112160de46c7744 100644
--- a/src/plugins/jobcomp/none/Makefile.in
+++ b/src/plugins/jobcomp/none/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ jobcomp_none_la_OBJECTS = $(am_jobcomp_none_la_OBJECTS)
 jobcomp_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(jobcomp_none_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobcomp/none/jobcomp_none.c b/src/plugins/jobcomp/none/jobcomp_none.c
index 986a8a705a6da1a17845596afbaca46a7b4ebe75..767fac2a41916dba95d8b4b89866db087f19a6b8 100644
--- a/src/plugins/jobcomp/none/jobcomp_none.c
+++ b/src/plugins/jobcomp/none/jobcomp_none.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -83,7 +83,7 @@
  */
 const char plugin_name[]       	= "Job completion logging NONE plugin";
 const char plugin_type[]       	= "jobcomp/none";
-const uint32_t plugin_version	= 90;
+const uint32_t plugin_version	= 100;
 
 /*
  * init() is called when the plugin is loaded, before any other functions
@@ -119,7 +119,21 @@ char *slurm_jobcomp_strerror( int errnum )
 	        return NULL;
 }
 
+List slurm_jobcomp_get_jobs(List selected_steps, List selected_parts,
+			    void *params)
+{
+	return NULL;
+}
+
+void slurm_jobcomp_archive(List selected_parts,
+			   void *params)
+{
+	return;
+}
+
 int fini ( void )
 {
 	return SLURM_SUCCESS;
 }
+
+
diff --git a/src/plugins/jobcomp/pgsql/Makefile.am b/src/plugins/jobcomp/pgsql/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..ae90b1625a7588d03f02c1c399e8d48a32b04f3c
--- /dev/null
+++ b/src/plugins/jobcomp/pgsql/Makefile.am
@@ -0,0 +1,19 @@
+# Makefile for jobcomp/pgsql plugin
+
+CPPFLAGS = $(PGSQL_CFLAGS)
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = jobcomp_pgsql.la
+
+# Pgsql storage plugin.
+jobcomp_pgsql_la_SOURCES = jobcomp_pgsql.c \
+			pgsql_jobcomp_process.c pgsql_jobcomp_process.h
+jobcomp_pgsql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobcomp_pgsql_la_CFLAGS = $(PGSQL_CFLAGS)
+jobcomp_pgsql_la_LIBADD  = $(top_builddir)/src/database/libslurm_pgsql.la \
+	$(PGSQL_LIBS)
+jobcomp_pgsql_la_DEPENDENCIES = $(top_builddir)/src/database/libslurm_pgsql.la
diff --git a/src/plugins/jobcomp/pgsql/Makefile.in b/src/plugins/jobcomp/pgsql/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..71612054e9b04f6276ffd06ecfce0d08a0ddda0c
--- /dev/null
+++ b/src/plugins/jobcomp/pgsql/Makefile.in
@@ -0,0 +1,578 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for jobcomp/pgsql plugin
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/plugins/jobcomp/pgsql
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+am_jobcomp_pgsql_la_OBJECTS = jobcomp_pgsql_la-jobcomp_pgsql.lo \
+	jobcomp_pgsql_la-pgsql_jobcomp_process.lo
+jobcomp_pgsql_la_OBJECTS = $(am_jobcomp_pgsql_la_OBJECTS)
+jobcomp_pgsql_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(jobcomp_pgsql_la_CFLAGS) \
+	$(CFLAGS) $(jobcomp_pgsql_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(jobcomp_pgsql_la_SOURCES)
+DIST_SOURCES = $(jobcomp_pgsql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = $(PGSQL_CFLAGS)
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+pkglib_LTLIBRARIES = jobcomp_pgsql.la
+
+# Pgsql storage plugin.
+jobcomp_pgsql_la_SOURCES = jobcomp_pgsql.c \
+			pgsql_jobcomp_process.c pgsql_jobcomp_process.h
+
+jobcomp_pgsql_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobcomp_pgsql_la_CFLAGS = $(PGSQL_CFLAGS)
+jobcomp_pgsql_la_LIBADD = $(top_builddir)/src/database/libslurm_pgsql.la \
+	$(PGSQL_LIBS)
+
+jobcomp_pgsql_la_DEPENDENCIES = $(top_builddir)/src/database/libslurm_pgsql.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobcomp/pgsql/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/plugins/jobcomp/pgsql/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-pkglibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	done
+
+clean-pkglibLTLIBRARIES:
+	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+jobcomp_pgsql.la: $(jobcomp_pgsql_la_OBJECTS) $(jobcomp_pgsql_la_DEPENDENCIES) 
+	$(jobcomp_pgsql_la_LINK) -rpath $(pkglibdir) $(jobcomp_pgsql_la_OBJECTS) $(jobcomp_pgsql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_pgsql_la-jobcomp_pgsql.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_pgsql_la-pgsql_jobcomp_process.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+jobcomp_pgsql_la-jobcomp_pgsql.lo: jobcomp_pgsql.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_pgsql_la_CFLAGS) $(CFLAGS) -MT jobcomp_pgsql_la-jobcomp_pgsql.lo -MD -MP -MF $(DEPDIR)/jobcomp_pgsql_la-jobcomp_pgsql.Tpo -c -o jobcomp_pgsql_la-jobcomp_pgsql.lo `test -f 'jobcomp_pgsql.c' || echo '$(srcdir)/'`jobcomp_pgsql.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/jobcomp_pgsql_la-jobcomp_pgsql.Tpo $(DEPDIR)/jobcomp_pgsql_la-jobcomp_pgsql.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='jobcomp_pgsql.c' object='jobcomp_pgsql_la-jobcomp_pgsql.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_pgsql_la_CFLAGS) $(CFLAGS) -c -o jobcomp_pgsql_la-jobcomp_pgsql.lo `test -f 'jobcomp_pgsql.c' || echo '$(srcdir)/'`jobcomp_pgsql.c
+
+jobcomp_pgsql_la-pgsql_jobcomp_process.lo: pgsql_jobcomp_process.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_pgsql_la_CFLAGS) $(CFLAGS) -MT jobcomp_pgsql_la-pgsql_jobcomp_process.lo -MD -MP -MF $(DEPDIR)/jobcomp_pgsql_la-pgsql_jobcomp_process.Tpo -c -o jobcomp_pgsql_la-pgsql_jobcomp_process.lo `test -f 'pgsql_jobcomp_process.c' || echo '$(srcdir)/'`pgsql_jobcomp_process.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/jobcomp_pgsql_la-pgsql_jobcomp_process.Tpo $(DEPDIR)/jobcomp_pgsql_la-pgsql_jobcomp_process.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='pgsql_jobcomp_process.c' object='jobcomp_pgsql_la-pgsql_jobcomp_process.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jobcomp_pgsql_la_CFLAGS) $(CFLAGS) -c -o jobcomp_pgsql_la-pgsql_jobcomp_process.lo `test -f 'pgsql_jobcomp_process.c' || echo '$(srcdir)/'`pgsql_jobcomp_process.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(pkglibdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/plugins/jobcomp/pgsql/jobcomp_pgsql.c b/src/plugins/jobcomp/pgsql/jobcomp_pgsql.c
new file mode 100644
index 0000000000000000000000000000000000000000..a56157c07e56762991d7f2bf1cf75a5daced4289
--- /dev/null
+++ b/src/plugins/jobcomp/pgsql/jobcomp_pgsql.c
@@ -0,0 +1,482 @@
+/*****************************************************************************\
+ *  jobcomp_pgsql.c - Store/Get all information in a postgresql storage.
+ *
+ *  $Id: storage_pgsql.c 10893 2007-01-29 21:53:48Z da $
+ *****************************************************************************
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "pgsql_jobcomp_process.h"
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
+#include "src/common/parse_time.h"
+#include "src/common/node_select.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobacct" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobacct/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job accounting API 
+ * matures.
+ */
+const char plugin_name[] = "Job completion POSTGRESQL plugin";
+const char plugin_type[] = "jobcomp/pgsql";
+const uint32_t plugin_version = 100;
+
+#ifdef HAVE_PGSQL
+
+#define DEFAULT_JOBCOMP_DB "slurm_jobcomp_db"
+
+PGconn *jobcomp_pgsql_db = NULL;
+
+char *jobcomp_table = "jobcomp_table";
+storage_field_t jobcomp_table_fields[] = {
+	{ "jobid", "integer not null" },
+	{ "uid", "smallint not null" },
+	{ "user_name", "text not null" },
+	{ "gid", "smallint not null" },
+	{ "group_name", "text not null" },
+	{ "name", "text not null" },
+	{ "state", "smallint not null" },
+	{ "partition", "text not null" }, 
+	{ "timelimit", "text not null" },
+	{ "starttime", "bigint default 0 not null" }, 
+	{ "endtime", "bigint default 0 not null" },
+	{ "nodelist", "text" }, 
+	{ "nodecnt", "integer not null" },
+	{ "proc_cnt", "integer not null" },
+#ifdef HAVE_BG
+	{ "connect_type", "text" },
+	{ "reboot", "text" },
+	{ "rotate", "text" },
+	{ "maxprocs", "integer default 0 not null" },
+	{ "geometry", "text" },
+	{ "start", "text" },
+	{ "blockid", "text" },
+#endif
+	{ NULL, NULL}
+};
+
+/* Type for error string table entries */
+typedef struct {
+	int xe_number;
+	char *xe_message;
+} slurm_errtab_t;
+
+static slurm_errtab_t slurm_errtab[] = {
+	{0, "No error"},
+	{-1, "Unspecified error"}
+};
+
+/* A plugin-global errno. */
+static int plugin_errno = SLURM_SUCCESS;
+
+/* File descriptor used for logging */
+static pthread_mutex_t  jobcomp_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static pgsql_db_info_t *_pgsql_jobcomp_create_db_info()
+{
+	pgsql_db_info_t *db_info = xmalloc(sizeof(pgsql_db_info_t));
+	db_info->port = slurm_get_jobcomp_port();
+	/* it turns out it is better if using defaults to let postgres
+	   handle them on it's own terms */
+	if(!db_info->port)
+		db_info->port = 5432;
+	db_info->host = slurm_get_jobcomp_host();
+	db_info->user = slurm_get_jobcomp_user();	
+	db_info->pass = slurm_get_jobcomp_pass();	
+	return db_info;
+}
+
+static int _pgsql_jobcomp_check_tables(char *user)
+{
+
+	int i = 0, job_found = 0;
+	PGresult *result = NULL;
+	char *query = xstrdup_printf("select tablename from pg_tables "
+				     "where tableowner='%s' "
+				     "and tablename !~ '^pg_+'", user);
+
+	if(!(result =
+	     pgsql_db_query_ret(jobcomp_pgsql_db, query))) {
+		xfree(query);
+		return SLURM_ERROR;
+	}
+	xfree(query);
+
+	for (i = 0; i < PQntuples(result); i++) {
+		if(!job_found 
+		   && !strcmp(jobcomp_table, PQgetvalue(result, i, 0))) 
+			job_found = 1;
+	}
+	PQclear(result);
+
+	if(!job_found)
+		if(pgsql_db_create_table(jobcomp_pgsql_db, jobcomp_table,
+					 jobcomp_table_fields,
+					 ")") == SLURM_ERROR)
+			return SLURM_ERROR;
+
+	return SLURM_SUCCESS;
+}
+
+
+/* get the user name for the give user_id */
+static char *_get_user_name(uint32_t user_id)
+{
+	static uint32_t cache_uid      = 0;
+	static char     cache_name[32] = "root";
+	struct passwd * user_info      = NULL;
+	char *ret_name = NULL;
+
+	slurm_mutex_lock(&jobcomp_lock);
+	if (user_id != cache_uid) {
+		user_info = getpwuid((uid_t) user_id);
+		if (user_info && user_info->pw_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				user_info->pw_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_uid = user_id;
+	}
+	ret_name = xstrdup(cache_name);
+	slurm_mutex_unlock(&jobcomp_lock);
+
+	return ret_name;
+}
+
+/* get the group name for the give group_id */
+static char *_get_group_name(uint32_t group_id)
+{
+	static uint32_t cache_gid      = 0;
+	static char     cache_name[32] = "root";
+	struct group  *group_info      = NULL;
+	char *ret_name = NULL;
+
+	slurm_mutex_lock(&jobcomp_lock);
+	if (group_id != cache_gid) {
+		group_info = getgrgid((gid_t) group_id);
+		if (group_info && group_info->gr_name[0])
+			snprintf(cache_name, sizeof(cache_name), "%s", 
+				 group_info->gr_name);
+		else
+			snprintf(cache_name, sizeof(cache_name), "Unknown");
+		cache_gid = group_id;
+	}
+	ret_name = xstrdup(cache_name);
+	slurm_mutex_unlock(&jobcomp_lock);
+
+	return ret_name;
+}
+
+/* 
+ * Linear search through table of errno values and strings,
+ * returns NULL on error, string on success.
+ */
+static char *_lookup_slurm_api_errtab(int errnum)
+{
+	char *res = NULL;
+	int i;
+
+	for (i = 0; i < sizeof(slurm_errtab) / sizeof(slurm_errtab_t); i++) {
+		if (slurm_errtab[i].xe_number == errnum) {
+			res = slurm_errtab[i].xe_message;
+			break;
+		}
+	}
+	return res;
+}
+#endif
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+extern int init ( void )
+{
+	static int first = 1;
+#ifndef HAVE_PGSQL
+	fatal("No Postgresql storage was found on the machine. "
+	      "Please check the configure ran and run again.");
+#endif
+	if(first) {
+		/* since this can be loaded from many different places
+		   only tell us once. */
+		verbose("%s loaded", plugin_name);
+		first = 0;
+	} else {
+		debug4("%s loaded", plugin_name);
+	}
+
+	return SLURM_SUCCESS;
+}
+
+extern int fini ( void )
+{
+#ifdef HAVE_PGSQL
+	if (jobcomp_pgsql_db) {
+		PQfinish(jobcomp_pgsql_db);
+		jobcomp_pgsql_db = NULL;
+	}
+	return SLURM_SUCCESS;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int slurm_jobcomp_set_location(char *location)
+{
+#ifdef HAVE_PGSQL
+	pgsql_db_info_t *db_info = _pgsql_jobcomp_create_db_info();
+	int rc = SLURM_SUCCESS;
+	char *db_name = NULL;
+	int i = 0;
+	
+	if(jobcomp_pgsql_db && PQstatus(jobcomp_pgsql_db) == CONNECTION_OK) 
+		return SLURM_SUCCESS;
+	
+	if(!location)
+		db_name = DEFAULT_JOBCOMP_DB;
+	else {
+		while(location[i]) {
+			if(location[i] == '.' || location[i] == '/') {
+				debug("%s doesn't look like a database "
+				      "name using %s",
+				      location, DEFAULT_JOBCOMP_DB);
+				break;
+			}
+			i++;
+		}
+		if(location[i]) 
+			db_name = DEFAULT_JOBCOMP_DB;
+		else
+			db_name = location;
+	}
+		
+	debug2("pgsql_connect() called for db %s", db_name);
+	
+	pgsql_get_db_connection(&jobcomp_pgsql_db, db_name, db_info);
+	
+	rc = _pgsql_jobcomp_check_tables(db_info->user);
+
+	destroy_pgsql_db_info(db_info);
+
+	if(rc == SLURM_SUCCESS) 
+		debug("Jobcomp database init finished");
+	else
+		debug("Jobcomp database init failed");
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif
+}
+
+extern int slurm_jobcomp_log_record(struct job_record *job_ptr)
+{
+#ifdef HAVE_PGSQL
+	int rc = SLURM_SUCCESS;
+	char *usr_str = NULL, *grp_str = NULL, lim_str[32];
+#ifdef HAVE_BG
+	char connect_type[128];
+	char reboot[4];
+	char rotate[4];
+	char maxprocs[20];
+	char geometry[20];
+	char start[20];
+	char blockid[128];
+#endif
+	enum job_states job_state;
+	char query[1024];
+
+	if(!jobcomp_pgsql_db || PQstatus(jobcomp_pgsql_db) != CONNECTION_OK) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return SLURM_ERROR;
+		}
+		xfree(loc);
+	}
+
+	usr_str = _get_user_name(job_ptr->user_id);
+	grp_str = _get_group_name(job_ptr->group_id);
+	if (job_ptr->time_limit == INFINITE)
+		strcpy(lim_str, "UNLIMITED");
+	else
+		snprintf(lim_str, sizeof(lim_str), "%lu", 
+				(unsigned long) job_ptr->time_limit);
+
+	/* Job will typically be COMPLETING when this is called. 
+	 * We remove this flag to get the eventual completion state:
+	 * JOB_FAILED, JOB_TIMEOUT, etc. */
+	job_state = job_ptr->job_state & (~JOB_COMPLETING);
+
+#ifdef HAVE_BG
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		connect_type, sizeof(connect_type), SELECT_PRINT_CONNECTION);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		reboot, sizeof(reboot), SELECT_PRINT_REBOOT);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		rotate, sizeof(rotate), SELECT_PRINT_ROTATE);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		maxprocs, sizeof(maxprocs), SELECT_PRINT_MAX_PROCS);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		geometry, sizeof(geometry), SELECT_PRINT_GEOMETRY);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		start, sizeof(start), SELECT_PRINT_START);
+	select_g_sprint_jobinfo(job_ptr->select_jobinfo,
+		blockid, sizeof(blockid), SELECT_PRINT_BG_ID);
+#endif
+	snprintf(query, sizeof(query),
+		 "insert into %s (jobid, uid, user_name, gid, group_name, "
+		 "name, state, proc_cnt, "
+		 "partition, timelimit, starttime, endtime, nodelist, nodecnt"
+#ifdef HAVE_BG
+		 ", connect_type, reboot, rotate, maxprocs, geometry, "
+		 "start, blockid"
+#endif
+		 ") values (%u, %u, '%s', %u, '%s', '%s', %d, %u, "
+		 "'%s', '%s', %u, %u, '%s', %u"
+#ifdef HAVE_BG
+		 ", '%s', '%s', '%s', %s, '%s', '%s', '%s'"
+#endif
+		 ")",
+		 jobcomp_table, job_ptr->job_id, job_ptr->user_id, usr_str,
+		 job_ptr->group_id, grp_str, job_ptr->name, job_state,
+		 job_ptr->total_procs, job_ptr->partition, lim_str,
+		 (int)job_ptr->start_time, (int)job_ptr->end_time,
+		 job_ptr->nodes, job_ptr->node_cnt
+#ifdef HAVE_BG
+		 , connect_type, reboot, rotate, maxprocs, geometry,
+		 start, blockid
+#endif
+		 );
+	//info("here is the query %s", query);
+
+	rc = pgsql_db_query(jobcomp_pgsql_db, query);
+	xfree(usr_str);
+
+	return rc;
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern int slurm_jobcomp_get_errno()
+{
+#ifdef HAVE_PGSQL
+	return plugin_errno;
+#else
+	return SLURM_ERROR;
+#endif 
+}
+
+extern char *slurm_jobcomp_strerror(int errnum)
+{
+#ifdef HAVE_PGSQL
+	char *res = _lookup_slurm_api_errtab(errnum);
+	return (res ? res : strerror(errnum));
+#else
+	return NULL;
+#endif 
+}
+
+/* 
+ * get info from the storage 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List slurm_jobcomp_get_jobs(List selected_steps,
+				   List selected_parts,
+				   void *params)
+{
+	List job_list = NULL;
+
+#ifdef HAVE_PGSQL
+	if(!jobcomp_pgsql_db || PQstatus(jobcomp_pgsql_db) != CONNECTION_OK) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return NULL;
+		}
+		xfree(loc);
+	}
+
+	job_list = pgsql_jobcomp_process_get_jobs(selected_steps,
+						  selected_parts,
+						  params);	
+#endif 
+	return job_list;
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void slurm_jobcomp_archive(List selected_parts, void *params)
+{
+#ifdef HAVE_PGSQL
+	if(!jobcomp_pgsql_db || PQstatus(jobcomp_pgsql_db) != CONNECTION_OK) {
+		char *loc = slurm_get_jobcomp_loc();
+		if(slurm_jobcomp_set_location(loc) == SLURM_ERROR) {
+			xfree(loc);
+			return;
+		}
+		xfree(loc);
+	}
+
+	pgsql_jobcomp_process_archive(selected_parts, params);
+#endif 
+	return;
+}
diff --git a/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c b/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c
new file mode 100644
index 0000000000000000000000000000000000000000..38e47752741d66cc35c1f8d355a4133cd929afbb
--- /dev/null
+++ b/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.c
@@ -0,0 +1,223 @@
+/*****************************************************************************\
+ *  pgsql_jobcomp_process.c - functions the processing of
+ *                               information from the pgsql jobcomp
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#include <stdlib.h>
+#include "src/common/parse_time.h"
+#include "src/common/xstring.h"
+#include "pgsql_jobcomp_process.h"
+
+#ifdef HAVE_PGSQL
+static void _do_fdump(PGresult *result, int lc)
+{
+	int i = 0;
+	printf("\n------- Line %d -------\n", lc);	
+	while(jobcomp_table_fields[i].name) {
+		printf("%12s: %s\n",  jobcomp_table_fields[i].name, 
+		       PQgetvalue(result, lc, i));
+		i++;
+	}
+
+	return;
+}
+
+extern List pgsql_jobcomp_process_get_jobs(List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params)
+{
+
+	char *query = NULL;	
+	char *extra = NULL;	
+	char *tmp = NULL;	
+	char *selected_part = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	int set = 0;
+	PGresult *result = NULL;
+	int i;
+	jobcomp_job_rec_t *job = NULL;
+	char time_str[32];
+	time_t temp_time;
+	List job_list = NULL;
+
+	if(selected_steps && list_count(selected_steps)) {
+		set = 0;
+		xstrcat(extra, " where (");
+		itr = list_iterator_create(selected_steps);
+		while((selected_step = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("jobid=%d",
+					      selected_step->jobid);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	if(selected_parts && list_count(selected_parts)) {
+		set = 0;
+		if(extra)
+			xstrcat(extra, " && (");
+		else
+			xstrcat(extra, " where (");
+		
+		itr = list_iterator_create(selected_parts);
+		while((selected_part = list_next(itr))) {
+			if(set) 
+				xstrcat(extra, " || ");
+			tmp = xstrdup_printf("partition='%s'",
+					      selected_part);
+			xstrcat(extra, tmp);
+			set = 1;
+			xfree(tmp);
+		}
+		list_iterator_destroy(itr);
+		xstrcat(extra, ")");
+	}
+
+	i = 0;
+	while(jobcomp_table_fields[i].name) {
+		if(i) 
+			xstrcat(tmp, ", ");
+		xstrcat(tmp, jobcomp_table_fields[i].name);
+		i++;
+	}
+	
+	query = xstrdup_printf("select %s from %s", tmp, jobcomp_table);
+	xfree(tmp);
+
+	if(extra) {
+		xstrcat(query, extra);
+		xfree(extra);
+	}
+
+	//info("query = %s", query);
+	if(!(result =
+	     pgsql_db_query_ret(jobcomp_pgsql_db, query))) {
+		xfree(query);
+		return NULL;
+	}
+	xfree(query);
+	
+	job_list = list_create(jobcomp_destroy_job);
+	for (i = 0; i < PQntuples(result); i++) {
+		
+		if (params->opt_fdump) {
+			_do_fdump(result, i);
+			continue;
+		}
+		job = xmalloc(sizeof(jobcomp_job_rec_t));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_JOBID))
+			job->jobid = 
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_JOBID));
+		job->partition =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_PARTITION));
+		temp_time = atoi(PQgetvalue(result, i, JOBCOMP_REQ_STARTTIME));
+		slurm_make_time_str(&temp_time, 
+				    time_str, 
+				    sizeof(time_str));
+		job->start_time = xstrdup(time_str);
+		
+		temp_time = atoi(PQgetvalue(result, i, JOBCOMP_REQ_ENDTIME));
+		slurm_make_time_str(&temp_time, 
+				    time_str, 
+				    sizeof(time_str));
+		job->end_time = xstrdup(time_str);
+		
+		if(PQgetvalue(result, i, JOBCOMP_REQ_UID))
+			job->uid =
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_UID));
+		job->uid_name =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_USER_NAME));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_GID))
+			job->gid =
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_GID));
+		job->gid_name = 
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_GROUP_NAME));
+		job->jobname =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_NAME));
+		job->nodelist =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_NODELIST));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_NODECNT))
+			job->node_cnt =
+				atoi(PQgetvalue(result, i, JOBCOMP_REQ_NODECNT));
+		if(PQgetvalue(result, i, JOBCOMP_REQ_STATE)) {
+			int j = atoi(PQgetvalue(result, i, JOBCOMP_REQ_STATE));
+			job->state = xstrdup(job_state_string(j));
+		}
+		job->timelimit =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_TIMELIMIT));
+#ifdef HAVE_BG
+		if(PQgetvalue(result, i, JOBCOMP_REQ_MAXPROCS))
+			job->max_procs =
+				atoi(PQgetvalue(result, i, 
+						JOBCOMP_REQ_MAXPROCS));
+		job->blockid =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_BLOCKID));
+		job->connection =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_CONNECTION));
+		job->reboot =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_REBOOT));
+		job->rotate =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_ROTATE));
+		job->geo = 
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_GEOMETRY));
+		job->bg_start_point =
+			xstrdup(PQgetvalue(result, i, JOBCOMP_REQ_START));
+#endif
+		list_append(job_list, job);
+
+	}
+	
+	PQclear(result);
+	return job_list;
+}
+
+extern void pgsql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params)
+{
+	return;
+}
+
+#endif	
diff --git a/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.h b/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.h
new file mode 100644
index 0000000000000000000000000000000000000000..a3f0c8c351bbf82461eeb3246f6b1b4c60aa15b4
--- /dev/null
+++ b/src/plugins/jobcomp/pgsql/pgsql_jobcomp_process.h
@@ -0,0 +1,92 @@
+/*****************************************************************************\
+ *  pgsql_jobcomp_process.h - functions the processing of
+ *                               information from the pgsql jobcomp
+ *                               storage.
+ *****************************************************************************
+ *
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ *  This file is patterned after jobcomp_linux.c, written by Morris Jette and
+ *  Copyright (C) 2002 The Regents of the University of California.
+\*****************************************************************************/
+
+#ifndef _HAVE_PGSQL_JOBCOMP_PROCESS_H
+#define _HAVE_PGSQL_JOBCOMP_PROCESS_H
+
+#include "src/database/pgsql_common.h"
+#include "src/common/slurm_jobacct_gather.h"
+#include "src/common/slurm_jobcomp.h"
+
+#ifdef HAVE_PGSQL
+extern PGconn *jobcomp_pgsql_db;
+extern int jobcomp_db_init;
+
+extern char *jobcomp_table;
+/* This variable and the following enum are related so if you change
+   the jobcomp_table_fields defined in mysql_jobcomp.c you must update
+   this enum accordingly.
+*/
+extern storage_field_t jobcomp_table_fields[];
+enum {
+	JOBCOMP_REQ_JOBID,
+	JOBCOMP_REQ_UID,
+	JOBCOMP_REQ_USER_NAME,
+	JOBCOMP_REQ_GID,
+	JOBCOMP_REQ_GROUP_NAME,
+	JOBCOMP_REQ_NAME,
+	JOBCOMP_REQ_STATE,
+	JOBCOMP_REQ_PARTITION,
+	JOBCOMP_REQ_TIMELIMIT,
+	JOBCOMP_REQ_STARTTIME,
+	JOBCOMP_REQ_ENDTIME,
+	JOBCOMP_REQ_NODELIST,
+	JOBCOMP_REQ_NODECNT,
+	JOBCOMP_REQ_CONNECTION,
+	JOBCOMP_REQ_REBOOT,
+	JOBCOMP_REQ_ROTATE,
+	JOBCOMP_REQ_MAXPROCS,
+	JOBCOMP_REQ_GEOMETRY,
+	JOBCOMP_REQ_START,
+	JOBCOMP_REQ_BLOCKID,
+	JOBCOMP_REQ_COUNT		
+};
+
+extern List pgsql_jobcomp_process_get_jobs(List selected_steps,
+					   List selected_parts,
+					   sacct_parameters_t *params);
+
+extern void pgsql_jobcomp_process_archive(List selected_parts,
+					  sacct_parameters_t *params);
+#endif
+
+#endif
diff --git a/src/plugins/jobcomp/script/Makefile.in b/src/plugins/jobcomp/script/Makefile.in
index 5c262974d3f72ef60494977937b2f1b558f5fd74..2463aab8b29501aa30e411c0e6ed28051fda6f75 100644
--- a/src/plugins/jobcomp/script/Makefile.in
+++ b/src/plugins/jobcomp/script/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ jobcomp_script_la_OBJECTS = $(am_jobcomp_script_la_OBJECTS)
 jobcomp_script_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(jobcomp_script_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobcomp/script/jobcomp_script.c b/src/plugins/jobcomp/script/jobcomp_script.c
index 6e64a3100426c8487d1c267e31baee0c263501d7..660074beae09e809e7724aa6a2fb7bbfb9ff95ab 100644
--- a/src/plugins/jobcomp/script/jobcomp_script.c
+++ b/src/plugins/jobcomp/script/jobcomp_script.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  jobcomp_script.c - Script running slurm job completion logging plugin.
- *  $Id: jobcomp_script.c 11930 2007-08-03 05:40:18Z grondo $
+ *  $Id: jobcomp_script.c 14054 2008-05-14 17:06:31Z da $
  *****************************************************************************
  *  Produced at Center for High Performance Computing, North Dakota State
  *  University
  *  Written by Nathan Huff <nhuff@acm.org>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -98,7 +98,7 @@
  */
 const char plugin_name[]       	= "Job completion logging script plugin";
 const char plugin_type[]       	= "jobcomp/script";
-const uint32_t plugin_version	= 90;
+const uint32_t plugin_version	= 100;
 
 static char * script = NULL;
 static List comp_list = NULL;
@@ -145,8 +145,10 @@ static const char * _jobcomp_script_strerror (int errnum)
 struct jobcomp_info {
 	uint32_t jobid;
 	uint32_t uid;
+	uint32_t gid;
 	uint32_t limit;
 	uint32_t nprocs;
+	uint32_t nnodes;
 	uint16_t batch_flag;
 	time_t submit;
 	time_t start;
@@ -165,6 +167,7 @@ static struct jobcomp_info * _jobcomp_info_create (struct job_record *job)
 
 	j->jobid = job->job_id;
 	j->uid = job->user_id;
+	j->gid = job->group_id;
 	j->name = xstrdup (job->name);
 
 	/*
@@ -179,10 +182,11 @@ static struct jobcomp_info * _jobcomp_info_create (struct job_record *job)
 	j->limit = job->time_limit;
 	j->start = job->start_time;
 	j->end = job->end_time;
-	j->submit = job->details ? job->details->submit_time:job->start_time;;
+	j->submit = job->details ? job->details->submit_time:job->start_time;
 	j->batch_flag = job->batch_flag;
 	j->nodes = xstrdup (job->nodes);
-	j->nprocs = job->num_procs;
+	j->nprocs = job->total_procs;
+	j->nnodes = job->node_cnt;
 	j->account = job->account ? xstrdup (job->account) : NULL;
 
 	return (j);
@@ -287,10 +291,12 @@ static char ** _create_environment (struct jobcomp_info *job)
 
 	_env_append_fmt (&env, "JOBID", "%u",  job->jobid);
 	_env_append_fmt (&env, "UID",   "%u",  job->uid);
+	_env_append_fmt (&env, "GID",   "%u",  job->gid);
 	_env_append_fmt (&env, "START", "%lu", job->start);
 	_env_append_fmt (&env, "END",   "%lu", job->end);
 	_env_append_fmt (&env, "SUBMIT","%lu", job->submit);
 	_env_append_fmt (&env, "PROCS", "%u",  job->nprocs);
+	_env_append_fmt (&env, "NODECNT", "%u", job->nnodes);
 
 	_env_append (&env, "BATCH", (job->batch_flag ? "yes" : "no"));
 	_env_append (&env, "NODES",     job->nodes);
@@ -557,3 +563,26 @@ extern int fini ( void )
 
 	return rc;
 }
+
+/* 
+ * get info from the storage 
+ * in/out job_list List of job_rec_t *
+ * note List needs to be freed when called
+ */
+extern List slurm_jobcomp_get_jobs(List selected_steps,
+				   List selected_parts,
+				   void *params)
+{
+
+	info("This function is not implemented.");
+	return NULL;
+}
+
+/* 
+ * expire old info from the storage 
+ */
+extern void slurm_jobcomp_archive(List selected_parts, void *params)
+{
+	info("This function is not implemented.");
+	return;
+}
diff --git a/src/plugins/jobcomp/slurmdbd/Makefile.am b/src/plugins/jobcomp/slurmdbd/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..5ce733dbfc7ad5cd5ff6493e0efc762ccfb6a874
--- /dev/null
+++ b/src/plugins/jobcomp/slurmdbd/Makefile.am
@@ -0,0 +1,13 @@
+# Makefile for jobcomp/slurmdbd plugin
+
+AUTOMAKE_OPTIONS = foreign
+
+PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
+
+pkglib_LTLIBRARIES = jobcomp_slurmdbd.la
+
+# Null job completion logging plugin.
+jobcomp_slurmdbd_la_SOURCES = jobcomp_slurmdbd.c
+jobcomp_slurmdbd_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
diff --git a/src/plugins/jobacct/none/Makefile.in b/src/plugins/jobcomp/slurmdbd/Makefile.in
similarity index 86%
rename from src/plugins/jobacct/none/Makefile.in
rename to src/plugins/jobcomp/slurmdbd/Makefile.in
index ad57db32d6d2b6759f3fa225b2bab29621a0abb5..42f439efd5d53eb8ef59e4651ae6aa84c3e00f23 100644
--- a/src/plugins/jobacct/none/Makefile.in
+++ b/src/plugins/jobcomp/slurmdbd/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# Makefile for jobacct/none plugin
+# Makefile for jobcomp/slurmdbd plugin
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -35,7 +35,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-subdir = src/plugins/jobacct/none
+subdir = src/plugins/jobcomp/slurmdbd
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,13 +75,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-jobacct_none_la_LIBADD =
-am_jobacct_none_la_OBJECTS = jobacct_none.lo
-jobacct_none_la_OBJECTS = $(am_jobacct_none_la_OBJECTS)
-jobacct_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+jobcomp_slurmdbd_la_LIBADD =
+am_jobcomp_slurmdbd_la_OBJECTS = jobcomp_slurmdbd.lo
+jobcomp_slurmdbd_la_OBJECTS = $(am_jobcomp_slurmdbd_la_OBJECTS)
+jobcomp_slurmdbd_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(jobacct_none_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+	$(jobcomp_slurmdbd_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -91,8 +93,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(jobacct_none_la_SOURCES)
-DIST_SOURCES = $(jobacct_none_la_SOURCES)
+SOURCES = $(jobcomp_slurmdbd_la_SOURCES)
+DIST_SOURCES = $(jobcomp_slurmdbd_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -255,11 +268,11 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 PLUGIN_FLAGS = -module -avoid-version --export-dynamic 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
-pkglib_LTLIBRARIES = jobacct_none.la
+pkglib_LTLIBRARIES = jobcomp_slurmdbd.la
 
 # Null job completion logging plugin.
-jobacct_none_la_SOURCES = jobacct_none.c
-jobacct_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
+jobcomp_slurmdbd_la_SOURCES = jobcomp_slurmdbd.c
+jobcomp_slurmdbd_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -273,9 +286,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobacct/none/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/plugins/jobcomp/slurmdbd/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/plugins/jobacct/none/Makefile
+	  $(AUTOMAKE) --foreign  src/plugins/jobcomp/slurmdbd/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -320,8 +333,8 @@ clean-pkglibLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-jobacct_none.la: $(jobacct_none_la_OBJECTS) $(jobacct_none_la_DEPENDENCIES) 
-	$(jobacct_none_la_LINK) -rpath $(pkglibdir) $(jobacct_none_la_OBJECTS) $(jobacct_none_la_LIBADD) $(LIBS)
+jobcomp_slurmdbd.la: $(jobcomp_slurmdbd_la_OBJECTS) $(jobcomp_slurmdbd_la_DEPENDENCIES) 
+	$(jobcomp_slurmdbd_la_LINK) -rpath $(pkglibdir) $(jobcomp_slurmdbd_la_OBJECTS) $(jobcomp_slurmdbd_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -329,7 +342,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobacct_none.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jobcomp_slurmdbd.Plo@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/jobcomp/slurmdbd/jobcomp_slurmdbd.c b/src/plugins/jobcomp/slurmdbd/jobcomp_slurmdbd.c
new file mode 100644
index 0000000000000000000000000000000000000000..aceee6cc8a5f8045ba114714fb496cfa867d5dad
--- /dev/null
+++ b/src/plugins/jobcomp/slurmdbd/jobcomp_slurmdbd.c
@@ -0,0 +1,139 @@
+/*****************************************************************************\
+ *  jobcomp_slurmdbd.c - SlurmDBD slurm job completion plugin.
+ *****************************************************************************
+ *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Aubke <da@llnl.gov>.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_STDINT_H
+#  include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+
+#include <stdio.h>
+#include <slurm/slurm_errno.h>
+
+#include "src/common/slurm_jobcomp.h"
+#include "src/slurmctld/slurmctld.h"
+
+/*
+ * These variables are required by the generic plugin interface.  If they
+ * are not found in the plugin, the plugin loader will ignore it.
+ *
+ * plugin_name - a string giving a human-readable description of the
+ * plugin.  There is no maximum length, but the symbol must refer to
+ * a valid string.
+ *
+ * plugin_type - a string suggesting the type of the plugin or its
+ * applicability to a particular form of data or method of data handling.
+ * If the low-level plugin API is used, the contents of this string are
+ * unimportant and may be anything.  SLURM uses the higher-level plugin
+ * interface which requires this string to be of the form
+ *
+ *	<application>/<method>
+ *
+ * where <application> is a description of the intended application of
+ * the plugin (e.g., "jobcomp" for SLURM job completion logging) and <method>
+ * is a description of how this plugin satisfies that application.  SLURM will
+ * only load job completion logging plugins if the plugin_type string has a 
+ * prefix of "jobcomp/".
+ *
+ * plugin_version - an unsigned 32-bit integer giving the version number
+ * of the plugin.  If major and minor revisions are desired, the major
+ * version number may be multiplied by a suitable magnitude constant such
+ * as 100 or 1000.  Various SLURM versions will likely require a certain
+ * minimum versions for their plugins as the job completion logging API 
+ * matures.
+ */
+const char plugin_name[]       	= "Job completion logging SLURMDBD plugin";
+const char plugin_type[]       	= "jobcomp/slurmdbd";
+const uint32_t plugin_version	= 100;
+
+/*
+ * init() is called when the plugin is loaded, before any other functions
+ * are called.  Put global initialization here.
+ */
+int init ( void )
+{
+	return SLURM_SUCCESS;
+}
+
+/*
+ * The remainder of this file implements the standard SLURM job completion
+ * logging API.
+ */
+
+int slurm_jobcomp_set_location ( char * location )
+{
+	return SLURM_SUCCESS;
+}
+
+int slurm_jobcomp_log_record ( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
+int slurm_jobcomp_get_errno( void )
+{
+	return SLURM_SUCCESS;
+}
+
+char *slurm_jobcomp_strerror( int errnum )
+{
+	return NULL;
+}
+
+List slurm_jobcomp_get_jobs(List selected_steps, List selected_parts,
+			    void *params)
+{
+	return NULL;
+}
+
+void slurm_jobcomp_archive(List selected_parts,
+			   void *params)
+{
+	return;
+}
+
+int fini ( void )
+{
+	return SLURM_SUCCESS;
+}
+
+
diff --git a/src/plugins/mpi/Makefile.in b/src/plugins/mpi/Makefile.in
index 48bf6e365ddf80d68662c19727aa27828f5134aa..5bed871f5a12ae3f7c8cbc0dde723d1c409b6ccf 100644
--- a/src/plugins/mpi/Makefile.in
+++ b/src/plugins/mpi/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/lam/Makefile.in b/src/plugins/mpi/lam/Makefile.in
index 9fc4e0917fce1fe8971485a2bd4506afef6a06c7..554b35b32ad2176f7fd8e0fe4929c6f3193da05d 100644
--- a/src/plugins/mpi/lam/Makefile.in
+++ b/src/plugins/mpi/lam/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_lam_la_OBJECTS = $(am_mpi_lam_la_OBJECTS)
 mpi_lam_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_lam_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -297,8 +310,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -306,8 +319,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -361,8 +374,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -374,8 +387,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -385,13 +398,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/lam/lam.h b/src/plugins/mpi/lam/lam.h
index ab493a71e05f1b14964e665510f0a555bc697340..b09c0cbe8289c161971d602c6f0a92cfc8b28718 100644
--- a/src/plugins/mpi/lam/lam.h
+++ b/src/plugins/mpi/lam/lam.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/lam/mpi_lam.c b/src/plugins/mpi/lam/mpi_lam.c
index c366fb6aa5776d23765cd0b1638696b94a1f2fb1..c1d90bbcf5fb6b4d769aaede5219a5afebd63b53 100644
--- a/src/plugins/mpi/lam/mpi_lam.c
+++ b/src/plugins/mpi/lam/mpi_lam.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpich1_p4/Makefile.in b/src/plugins/mpi/mpich1_p4/Makefile.in
index f30e9f8d1cc0ca36ec017f9366caf01b1daff8f0..3d9ef1ecc8205ac63ea89673fb8d9ff1b53088d9 100644
--- a/src/plugins/mpi/mpich1_p4/Makefile.in
+++ b/src/plugins/mpi/mpich1_p4/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_mpich1_p4_la_OBJECTS = $(am_mpi_mpich1_p4_la_OBJECTS)
 mpi_mpich1_p4_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_mpich1_p4_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/mpich1_p4/mpich1_p4.c b/src/plugins/mpi/mpich1_p4/mpich1_p4.c
index e58f39a6a379748fe98a867aeae76831b8a7f010..66303a9a2ebbbe1d6321438c4bd82f12ec5469ee 100644
--- a/src/plugins/mpi/mpich1_p4/mpich1_p4.c
+++ b/src/plugins/mpi/mpich1_p4/mpich1_p4.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpich1_shmem/Makefile.in b/src/plugins/mpi/mpich1_shmem/Makefile.in
index cbdc0c145f8c81dc6dd06e5a63568141539a8995..8f832878ad0f63e34cb5c9617b4e790cfeee805a 100644
--- a/src/plugins/mpi/mpich1_shmem/Makefile.in
+++ b/src/plugins/mpi/mpich1_shmem/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_mpich1_shmem_la_OBJECTS = $(am_mpi_mpich1_shmem_la_OBJECTS)
 mpi_mpich1_shmem_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_mpich1_shmem_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -297,8 +310,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -306,8 +319,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -361,8 +374,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -374,8 +387,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -385,13 +398,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/mpich1_shmem/mpich1_shmem.c b/src/plugins/mpi/mpich1_shmem/mpich1_shmem.c
index 19bb60d01b4cfdfb74186594b7c1e82fbc16870a..2a848feacecef3e005b12fc7eb5c457972b77496 100644
--- a/src/plugins/mpi/mpich1_shmem/mpich1_shmem.c
+++ b/src/plugins/mpi/mpich1_shmem/mpich1_shmem.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpichgm/Makefile.in b/src/plugins/mpi/mpichgm/Makefile.in
index 4d723c0aaf6afcd580d1f0e0c6a4bfcf38c95325..23a04991e75f126664b8698395bcf42acff529ea 100644
--- a/src/plugins/mpi/mpichgm/Makefile.in
+++ b/src/plugins/mpi/mpichgm/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_mpichgm_la_OBJECTS = $(am_mpi_mpichgm_la_OBJECTS)
 mpi_mpichgm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_mpichgm_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -301,8 +314,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -310,8 +323,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -366,8 +379,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -379,8 +392,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -390,13 +403,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/mpichgm/mpi_mpichgm.c b/src/plugins/mpi/mpichgm/mpi_mpichgm.c
index 2d20c249e01cd8dbf65f9386896866be860e6d16..3524f351b9aa73465b6d9e9135a1ddeb8f8d9b5d 100644
--- a/src/plugins/mpi/mpichgm/mpi_mpichgm.c
+++ b/src/plugins/mpi/mpichgm/mpi_mpichgm.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpichgm/mpichgm.c b/src/plugins/mpi/mpichgm/mpichgm.c
index e5a1d6f8cde4ed6e8e199d651a28d0ac95c43ad5..c42295e7c95d5a43d18d0571a588e6fc803f7630 100644
--- a/src/plugins/mpi/mpichgm/mpichgm.c
+++ b/src/plugins/mpi/mpichgm/mpichgm.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Takao Hatazaki <takao.hatazaki@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpichgm/mpichgm.h b/src/plugins/mpi/mpichgm/mpichgm.h
index 8f092e832fcf49d6c80986adf76a003c2e38a042..f7180de8dc6bb2af2a45b4338f9cdaf54ffa2304 100644
--- a/src/plugins/mpi/mpichgm/mpichgm.h
+++ b/src/plugins/mpi/mpichgm/mpichgm.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpichmx/Makefile.in b/src/plugins/mpi/mpichmx/Makefile.in
index a59463b8bd86bd4cfb404a4039501621605aa6da..05febabcdcbcfa79c35b1228d2e3f8e1b8a37696 100644
--- a/src/plugins/mpi/mpichmx/Makefile.in
+++ b/src/plugins/mpi/mpichmx/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_mpichmx_la_OBJECTS = $(am_mpi_mpichmx_la_OBJECTS)
 mpi_mpichmx_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_mpichmx_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -301,8 +314,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -310,8 +323,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -366,8 +379,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -379,8 +392,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -390,13 +403,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/mpichmx/mpi_mpichmx.c b/src/plugins/mpi/mpichmx/mpi_mpichmx.c
index 3cdc842350ffebc9941b8557e04c13682c2b90e2..77b67a303e7783b90b724c97f1bc9f9cb3a71ce8 100644
--- a/src/plugins/mpi/mpichmx/mpi_mpichmx.c
+++ b/src/plugins/mpi/mpichmx/mpi_mpichmx.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpichmx/mpichmx.c b/src/plugins/mpi/mpichmx/mpichmx.c
index b1d48fffd8f00b48d055073fd5a624b50c3fe7e9..19998ab745e1647227f37596a32948b8d4d02c89 100644
--- a/src/plugins/mpi/mpichmx/mpichmx.c
+++ b/src/plugins/mpi/mpichmx/mpichmx.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Takao Hatazaki <takao.hatazaki@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mpichmx/mpichmx.h b/src/plugins/mpi/mpichmx/mpichmx.h
index cdcade47ccee58ed6ce0c68b6ecde9a83ee1db0b..6f71bb29b2181d3eec20f468b0b4d80d34e78738 100644
--- a/src/plugins/mpi/mpichmx/mpichmx.h
+++ b/src/plugins/mpi/mpichmx/mpichmx.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mvapich/Makefile.in b/src/plugins/mpi/mvapich/Makefile.in
index 7cf94d7fd3c052f420c605c84c761f8ec2ea2467..0bcd876e3d8e727dea0442849b765c4690285c84 100644
--- a/src/plugins/mpi/mvapich/Makefile.in
+++ b/src/plugins/mpi/mvapich/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_mvapich_la_OBJECTS = $(am_mpi_mvapich_la_OBJECTS)
 mpi_mvapich_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_mvapich_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -364,8 +377,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -377,8 +390,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -388,13 +401,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/mvapich/mpi_mvapich.c b/src/plugins/mpi/mvapich/mpi_mvapich.c
index c6e24729117fab915c0f286cde11b73992c4bdc0..01e51635440c8187bf3b0694d3293e9bd8ffc454 100644
--- a/src/plugins/mpi/mvapich/mpi_mvapich.c
+++ b/src/plugins/mpi/mvapich/mpi_mvapich.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mvapich/mvapich.c b/src/plugins/mpi/mvapich/mvapich.c
index 2a2b5541a262509cf9327a2ea703c004c465e30b..3182cb4a6cf32cb0d04e2a4e0134bed6105798e1 100644
--- a/src/plugins/mpi/mvapich/mvapich.c
+++ b/src/plugins/mpi/mvapich/mvapich.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).  
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/mvapich/mvapich.h b/src/plugins/mpi/mvapich/mvapich.h
index 257e4b0a6a5a15694c0a8a87756bf816abb3ea36..c4708a1762d44f044c682fd3a7153ba50e1c919c 100644
--- a/src/plugins/mpi/mvapich/mvapich.h
+++ b/src/plugins/mpi/mvapich/mvapich.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/none/Makefile.in b/src/plugins/mpi/none/Makefile.in
index 97d80b08fcf9452ba2f3504f11ce62f7258d236e..b4ef574dd266c07d7d534c0b1b92e2ed70a23b66 100644
--- a/src/plugins/mpi/none/Makefile.in
+++ b/src/plugins/mpi/none/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_none_la_OBJECTS = $(am_mpi_none_la_OBJECTS)
 mpi_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_none_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/none/mpi_none.c b/src/plugins/mpi/none/mpi_none.c
index f9288a252aa88f97595806bb23a72107e416cb57..b331e5f77a5334b446d35bd0fadd1a36d0fe42d3 100644
--- a/src/plugins/mpi/none/mpi_none.c
+++ b/src/plugins/mpi/none/mpi_none.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/mpi/openmpi/Makefile.in b/src/plugins/mpi/openmpi/Makefile.in
index 19e48800d8b9b9e167b0daa7e33f294ce8391179..e156ebc2fafee5b22e10c95da113d131fea74909 100644
--- a/src/plugins/mpi/openmpi/Makefile.in
+++ b/src/plugins/mpi/openmpi/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ mpi_openmpi_la_OBJECTS = $(am_mpi_openmpi_la_OBJECTS)
 mpi_openmpi_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(mpi_openmpi_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/mpi/openmpi/mpi_openmpi.c b/src/plugins/mpi/openmpi/mpi_openmpi.c
index 64fb70eddb08a66d96d563a293f2f9a672871f2a..543b39a1e6cb86684d0717782c854aa96c1bcb2a 100644
--- a/src/plugins/mpi/openmpi/mpi_openmpi.c
+++ b/src/plugins/mpi/openmpi/mpi_openmpi.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/proctrack/Makefile.in b/src/plugins/proctrack/Makefile.in
index 936995f07a8a53e46db8d7961f0ca22c5d25ba25..02e355b88b45f1afeb11e7d820894740ce94e48c 100644
--- a/src/plugins/proctrack/Makefile.in
+++ b/src/plugins/proctrack/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -351,8 +364,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -377,8 +390,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -388,13 +401,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/proctrack/aix/Makefile.in b/src/plugins/proctrack/aix/Makefile.in
index 28d16781343d06a2dad7f3a9974e8f46fdeb78bf..599c8f658dd166802f7293ea8cfd3033601c1973 100644
--- a/src/plugins/proctrack/aix/Makefile.in
+++ b/src/plugins/proctrack/aix/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ proctrack_aix_la_OBJECTS = $(am_proctrack_aix_la_OBJECTS)
 proctrack_aix_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(proctrack_aix_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -301,8 +314,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -310,8 +323,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -365,8 +378,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -378,8 +391,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -389,13 +402,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/proctrack/aix/proctrack_aix.c b/src/plugins/proctrack/aix/proctrack_aix.c
index df726aba630d3a31ef98b9b97a3d99d4adb5488e..d3b7fb63e35ce2be411141a1e488a4944b384c44 100644
--- a/src/plugins/proctrack/aix/proctrack_aix.c
+++ b/src/plugins/proctrack/aix/proctrack_aix.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/proctrack/linuxproc/Makefile.in b/src/plugins/proctrack/linuxproc/Makefile.in
index 1dadf4deb6b4ca384f590ba5f6df9eafe8701005..2034e44b79e0611d43dc177c9d8756fdf3379b76 100644
--- a/src/plugins/proctrack/linuxproc/Makefile.in
+++ b/src/plugins/proctrack/linuxproc/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -80,7 +82,7 @@ proctrack_linuxproc_la_OBJECTS = $(am_proctrack_linuxproc_la_OBJECTS)
 proctrack_linuxproc_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(proctrack_linuxproc_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -120,6 +122,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +136,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +162,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +176,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +193,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +209,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -304,8 +317,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -313,8 +326,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -369,8 +382,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -382,8 +395,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -393,13 +406,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/proctrack/linuxproc/kill_tree.c b/src/plugins/proctrack/linuxproc/kill_tree.c
index 871fcda5582f70c599f61e47d82089b17cf299da..b792cea0f4d71c71e76e39e8d364e9ba0db12e50 100644
--- a/src/plugins/proctrack/linuxproc/kill_tree.c
+++ b/src/plugins/proctrack/linuxproc/kill_tree.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Takao Hatazaki <takao.hatazaki@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/proctrack/linuxproc/kill_tree.h b/src/plugins/proctrack/linuxproc/kill_tree.h
index e27c333f7be982d52056c1b7ddd2512b9f29131e..8ae0d2c56404d3f01cec6a954ec898e5be99e0e8 100644
--- a/src/plugins/proctrack/linuxproc/kill_tree.h
+++ b/src/plugins/proctrack/linuxproc/kill_tree.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Takao Hatazaki <takao.hatazaki@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c b/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c
index 5b4b197129b7ac2778d8444804b067a6e5912c5c..95331c8d9f1ee3cd4444be27e77e7e9b30b9ba06 100644
--- a/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c
+++ b/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/proctrack/pgid/Makefile.in b/src/plugins/proctrack/pgid/Makefile.in
index fe1a1ba081562a9ba0a2d0e6b6c0ee29a4b48e01..f8a41c9111348795fc9e1cc88a72358cbc1c9672 100644
--- a/src/plugins/proctrack/pgid/Makefile.in
+++ b/src/plugins/proctrack/pgid/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ proctrack_pgid_la_OBJECTS = $(am_proctrack_pgid_la_OBJECTS)
 proctrack_pgid_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(proctrack_pgid_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -308,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/proctrack/pgid/proctrack_pgid.c b/src/plugins/proctrack/pgid/proctrack_pgid.c
index 04880e102bbbba6e302984e6762197c3b50aefa4..94f6f2b595a7de8948622cdafe7d35d478a9b406 100644
--- a/src/plugins/proctrack/pgid/proctrack_pgid.c
+++ b/src/plugins/proctrack/pgid/proctrack_pgid.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -46,7 +46,9 @@
 #  include <inttypes.h>
 #endif
 
-#define __USE_XOPEN_EXTENDED /* getpgid */
+#ifndef   __USE_XOPEN_EXTENDED
+#  define __USE_XOPEN_EXTENDED /* getpgid */
+#endif
 #include <unistd.h>
 
 #include <sys/types.h>
diff --git a/src/plugins/proctrack/rms/Makefile.in b/src/plugins/proctrack/rms/Makefile.in
index 3ac284288c06007846cdefa643753fb19ff8cd0c..4e2607fa93ea4c81141059f0a4ec5a6be94a9284 100644
--- a/src/plugins/proctrack/rms/Makefile.in
+++ b/src/plugins/proctrack/rms/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -80,7 +82,7 @@ proctrack_rms_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(proctrack_rms_la_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_ELAN_TRUE@am_proctrack_rms_la_rpath = -rpath $(pkglibdir)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -120,6 +122,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +136,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +162,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +176,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +193,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +209,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -300,8 +313,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -309,8 +322,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -364,8 +377,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -377,8 +390,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -388,13 +401,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/proctrack/rms/proctrack_rms.c b/src/plugins/proctrack/rms/proctrack_rms.c
index e85ce8a2bdba63a9c806cb0182f5a55ae742a1a7..d6f6bd747b48be66b40df8e8eeaf42eefbd53252 100644
--- a/src/plugins/proctrack/rms/proctrack_rms.c
+++ b/src/plugins/proctrack/rms/proctrack_rms.c
@@ -3,7 +3,7 @@
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/proctrack/sgi_job/Makefile.in b/src/plugins/proctrack/sgi_job/Makefile.in
index d74e95537f813dc9cd55351a9777b7c180304e8e..6ad660d31a3f4cb00acc2cc546d19f0466936cba 100644
--- a/src/plugins/proctrack/sgi_job/Makefile.in
+++ b/src/plugins/proctrack/sgi_job/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ proctrack_sgi_job_la_OBJECTS = $(am_proctrack_sgi_job_la_OBJECTS)
 proctrack_sgi_job_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(proctrack_sgi_job_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -297,8 +310,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -306,8 +319,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -361,8 +374,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -374,8 +387,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -385,13 +398,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c b/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c
index 4a0575080039afce3a6d3b7cfc8af810e67f24b1..53fa0d62c56b15c93bdf588e08a2a6dee5eb5e92 100644
--- a/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c
+++ b/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/Makefile.in b/src/plugins/sched/Makefile.in
index f06d022d6e80d45e945323d24fc5e6595e68fdc9..f91dedddec35b641b66a6f7a668459e9934cd1a4 100644
--- a/src/plugins/sched/Makefile.in
+++ b/src/plugins/sched/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/sched/backfill/Makefile.in b/src/plugins/sched/backfill/Makefile.in
index d6855810e0e4836405980f52b06181082dbb32fd..cd1bb54d8983caf9e68ad40b767c395c8af2bf43 100644
--- a/src/plugins/sched/backfill/Makefile.in
+++ b/src/plugins/sched/backfill/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ sched_backfill_la_OBJECTS = $(am_sched_backfill_la_OBJECTS)
 sched_backfill_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(sched_backfill_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = -fexceptions
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -300,8 +313,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -309,8 +322,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -365,8 +378,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -378,8 +391,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -389,13 +402,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/sched/backfill/backfill.c b/src/plugins/sched/backfill/backfill.c
index 804d289cdf7bcd0b57712ce24e5c05a826b9173e..008607474f7c7b53963d6b044ceaea5c8e858943 100644
--- a/src/plugins/sched/backfill/backfill.c
+++ b/src/plugins/sched/backfill/backfill.c
@@ -14,10 +14,11 @@
  *  "lx[06-08]", we can't start it without possibly delaying the higher 
  *  priority job.
  *****************************************************************************
- *  Copyright (C) 2003-2006 The Regents of the University of California.
+ *  Copyright (C) 2003-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -59,93 +60,82 @@
 #include "slurm/slurm_errno.h"
 #include "src/common/list.h"
 #include "src/common/macros.h"
+#include "src/common/node_select.h"
+#include "src/common/parse_time.h"
 #include "src/common/slurm_protocol_api.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
+#include "src/slurmctld/job_scheduler.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/locks.h"
+#include "src/slurmctld/node_scheduler.h"
 #include "src/slurmctld/slurmctld.h"
-
-typedef struct part_specs {
-	uint32_t idle_node_cnt;
-	uint32_t max_cpus;
-	uint32_t min_cpus;
-	uint32_t min_mem;
-	uint32_t min_disk;
-} part_specs_t;
+#include "src/slurmctld/srun_comm.h"
 
 typedef struct node_space_map {
-	uint32_t idle_node_cnt;
-	time_t time;
+	time_t begin_time;
+	time_t end_time;
+	bitstr_t *avail_bitmap;
+	int next;	/* next record, by time, zero termination */
 } node_space_map_t;
+int backfilled_jobs = 0;
 
 /*********************** local variables *********************/
-static bool altered_job   = false;
 static bool new_work      = false;
 static bool stop_backfill = false;
 static pthread_mutex_t thread_flag_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-static List pend_job_list = NULL;
-static List run_job_list  = NULL;
-
-#define MAX_JOB_CNT 100
-static int node_space_recs;
-static node_space_map_t node_space[MAX_JOB_CNT + 1];
+/* Backfill scheduling has considerable overhead, 
+ * so only attempt it every BACKFILL_INTERVAL seconds */
+#ifndef BACKFILL_INTERVAL
+#  define BACKFILL_INTERVAL	10
+#endif
 
 /* Set __DEBUG to get detailed logging for this thread without 
  * detailed logging for the entire slurmctld daemon */
-#define __DEBUG        0
-#define SLEEP_TIME     1
+#define __DEBUG			0
+
+/* Do not attempt to build job/resource/time record for
+ * more than MAX_BACKFILL_JOB_CNT records */
+#define MAX_BACKFILL_JOB_CNT	100
+
+/* Do not build job/resource/time record for more than this 
+ * far in the future, in seconds, currently one day */
+#define BACKFILL_WINDOW		(24 * 60 * 60)
 
 /*********************** local functions *********************/
-static int  _add_pending_job(struct job_record *job_ptr, 
-		struct part_record *part_ptr, part_specs_t *part_specs);
-static int  _add_running_job(struct job_record *job_ptr);
-static void _attempt_backfill(struct part_record *part_ptr);
-static void _backfill_part(part_specs_t *part_specs);
-static void _build_node_space_map(part_specs_t *part_specs);
-static void _change_prio(struct job_record *job_ptr, uint32_t prio);
+static void _add_reservation(uint32_t start_time, uint32_t end_reserve, 
+			     bitstr_t *res_bitmap, 
+			     node_space_map_t *node_space, 
+			     int *node_space_recs);
+static void _attempt_backfill(void);
 static void _diff_tv_str(struct timeval *tv1,struct timeval *tv2,
 		char *tv_str, int len_tv_str);
-static void _dump_node_space_map(uint32_t job_id, uint32_t node_cnt);
-static int  _get_avail_node_cnt(struct job_record *job_ptr); 
-static void _get_part_specs(struct part_record *part_ptr, 
-		part_specs_t *part_specs);
-static bool _has_state_changed(void);
-static bool _loc_restrict(struct job_record *job_ptr, part_specs_t *part_specs);
 static bool _more_work(void);
-static int  _sort_by_prio(void *x, void *y);
-static int  _sort_by_end(void *x, void *y);
-static int  _update_node_space_map(struct job_record *job_ptr);
+static int _start_job(struct job_record *job_ptr, bitstr_t *avail_bitmap);
 
-/* list processing function, sort jobs by _decreasing_ priority */
-static int _sort_by_prio(void *x, void *y)
-{
-	struct job_record *job_ptr1 = (struct job_record *) x;
-	struct job_record *job_ptr2 = (struct job_record *) y;
-	double diff = job_ptr2->priority - job_ptr1->priority;
-
-	if (diff > 0)
-		return 1;
-	else if (diff < 0)
-		return -1;
-	else
-		return 0;
-}
-
-/* list processing function, sort jobs by _increasing_ end time */
-static int _sort_by_end(void *x, void *y)
+#if __DEBUG
+/* Log resource allocate table */
+static void _dump_node_space_table(node_space_map_t *node_space_ptr)
 {
-	struct job_record *job_ptr1 = (struct job_record *) x;
-	struct job_record *job_ptr2 = (struct job_record *) y;
-	double diff = difftime(job_ptr1->end_time, job_ptr2->end_time);
-
-	if (diff > 0)
-		return 1;
-	else if (diff < 0)
-		return -1;
-	else
-		return 0;
+	int i = 0;
+	char begin_buf[32], end_buf[32], *node_list;
+
+	info("=========================================");
+	while (1) {
+		slurm_make_time_str(&node_space_ptr[i].begin_time,
+				    begin_buf, sizeof(begin_buf));
+		slurm_make_time_str(&node_space_ptr[i].end_time,
+				    end_buf, sizeof(end_buf));
+		node_list = bitmap2node_name(node_space_ptr[i].avail_bitmap);
+		info("Begin:%s End:%s Nodes:%s", begin_buf, end_buf, node_list);
+		xfree(node_list);
+		if ((i = node_space_ptr[i].next) == 0)
+			break;
+	}
+	info("=========================================");
 }
+#endif
 
 /*
  * _diff_tv_str - build a string showing the time difference between two times
@@ -171,512 +161,346 @@ extern void stop_backfill_agent(void)
 
 
 /* backfill_agent - detached thread periodically attempts to backfill jobs */
-extern void *
-backfill_agent(void *args)
+extern void *backfill_agent(void *args)
 {
 	struct timeval tv1, tv2;
 	char tv_str[20];
-	bool filter_root = false;
-	/* Read config, node, and partitions; Write jobs */
+	time_t now;
+	static time_t last_backfill_time = 0;
+	/* Read config, and partitions; Write jobs and nodes */
 	slurmctld_lock_t all_locks = {
-		READ_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK };
+		READ_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK };
 
-	if (slurm_get_root_filter())
-		filter_root = true;
 	while (!stop_backfill) {
-		sleep(SLEEP_TIME);      /* don't run continuously */
-		if ((!_more_work()) || stop_backfill)
+		sleep(2);		/* don't run continuously */
+
+		now = time(NULL);
+		/* Avoid resource fragmentation if important */
+		if (switch_no_frag() && job_is_completing())
+			continue;
+		if ((difftime(now, last_backfill_time) < BACKFILL_INTERVAL) ||
+		    stop_backfill || (!_more_work()))
 			continue;
+		last_backfill_time = now;
 
 		gettimeofday(&tv1, NULL);
 		lock_slurmctld(all_locks);
-		if ( _has_state_changed() ) {
-			ListIterator part_iterator;
-			struct part_record *part_ptr;
-
-			/* identify partitions eligible for backfill */
-			part_iterator = list_iterator_create(part_list);
-			while ((part_ptr = (struct part_record *) 
-						list_next(part_iterator))) {
-				if ( ((part_ptr->shared)       ||
-				      (part_ptr->state_up == 0)) )
-				 	continue; /* not under our control */
-				if ((part_ptr->root_only) && filter_root)
-					continue;
-				_attempt_backfill(part_ptr);
-			}
-			list_iterator_destroy(part_iterator);
-		}
+		_attempt_backfill();
 		unlock_slurmctld(all_locks);
 		gettimeofday(&tv2, NULL);
 		_diff_tv_str(&tv1, &tv2, tv_str, 20);
 #if __DEBUG
 		info("backfill: completed, %s", tv_str);
 #endif
-		if (altered_job) {
-			altered_job = false;
-			schedule();	/* has own locks */
-		}
 	}
 	return NULL;
 }
 
-/* trigger the attempt of a backfill */
-extern void
-run_backfill (void)
-{
-	pthread_mutex_lock( &thread_flag_mutex );
-	new_work = true;
-	pthread_mutex_unlock( &thread_flag_mutex );
-}
-
-static bool
-_more_work (void)
-{
-	static bool rc;
-	pthread_mutex_lock( &thread_flag_mutex );
-	rc = new_work;
-	new_work = false;
-	pthread_mutex_unlock( &thread_flag_mutex );
-	return rc;
-}
-
-/* Report if any changes occurred to job, node or partition information */
-static bool
-_has_state_changed(void)
+static void _attempt_backfill(void)
 {
-	static time_t backfill_job_time  = (time_t) 0;
-        static time_t backfill_node_time = (time_t) 0;
-	static time_t backfill_part_time = (time_t) 0;
+	bool filter_root = false;
+	struct job_queue *job_queue = NULL;
+	int i, j,job_queue_size, node_space_recs = 0;
+	struct job_record *job_ptr;
+	struct part_record *part_ptr;
+	uint32_t end_time, end_reserve, time_limit;
+	uint32_t min_nodes, max_nodes, req_nodes;
+	uint16_t orig_shared;
+	bitstr_t *avail_bitmap = NULL;
+	time_t now = time(NULL);
+	node_space_map_t node_space[MAX_BACKFILL_JOB_CNT + 2];
 
-	if ( (backfill_job_time  == last_job_update ) &&
-	     (backfill_node_time == last_node_update) &&
-	     (backfill_part_time == last_part_update) )
-		return false;
+	if (slurm_get_root_filter())
+		filter_root = true;
 
-	backfill_job_time  = last_job_update;
-	backfill_node_time = last_node_update;
-	backfill_part_time = last_part_update;
-	return true;
-}
+	job_queue_size = build_job_queue(&job_queue);
+	if (job_queue_size == 0)
+		return;
 
-/* Attempt to perform backfill scheduling on the specified partition */
-static void 
-_attempt_backfill(struct part_record *part_ptr)
-{
-	int i, cg_hung = 0, error_code = 0;
-	uint32_t max_pending_prio = 0;
-	uint32_t min_pend_job_size = INFINITE;
-	struct job_record *job_ptr;
-	ListIterator job_iterator;
-	part_specs_t part_specs;
-	time_t now = time(NULL);
+	sort_job_queue(job_queue, job_queue_size);
 
+	node_space[0].begin_time = now;
+	node_space[0].end_time = now + BACKFILL_WINDOW;
+	node_space[0].avail_bitmap = bit_alloc(node_record_count);
+	bit_or(node_space[0].avail_bitmap, avail_node_bitmap);
+	node_space[0].next = 0;
 #if __DEBUG
-	info("backfill: attempt on partition %s", part_ptr->name);
+	_dump_node_space_table(node_space);
 #endif
 
-	_get_part_specs(part_ptr, &part_specs);
-	if (part_specs.idle_node_cnt == 0)
-		return;		/* no idle nodes */
-
-	pend_job_list = list_create(NULL);
-	run_job_list  = list_create(NULL);
-		
-	/* build lists of pending and running jobs in this partition */
-	job_iterator = list_iterator_create(job_list);
-	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
-		if (job_ptr->part_ptr != part_ptr)
-			continue;	/* job in different partition */
-
-		if (job_ptr->job_state & JOB_COMPLETING) {
-			long wait_time = (long) difftime(now, job_ptr->end_time);
-			if (wait_time > 600) {
-				/* Job has been in completing state for 
-				 * >10 minutes, try to schedule around it */
-				cg_hung++;
-				continue;
-			}
-#if __DEBUG
-			info("backfill: Job %u completing, skip partition", 
-					job_ptr->job_id);
-#endif
-			error_code = 1;
-			break;
-		} else if (job_ptr->job_state == JOB_RUNNING) {
-			if (_add_running_job(job_ptr)) {
-				error_code = 2;
-				break;
-			}
-		} else if (job_ptr->job_state == JOB_PENDING) {
-			max_pending_prio = MAX(max_pending_prio, 
-					job_ptr->priority);
-			if (_add_pending_job(job_ptr, part_ptr, &part_specs)) {
-				error_code = 3;
-				break;
-			}
-			min_pend_job_size = MIN(min_pend_job_size, 
-					job_ptr->node_cnt);
+	for (i = 0; i < job_queue_size; i++) {
+		job_ptr = job_queue[i].job_ptr;
+		part_ptr = job_ptr->part_ptr;
+		if (part_ptr == NULL) {
+			part_ptr = find_part_record(job_ptr->partition);
+			xassert(part_ptr);
+			job_ptr->part_ptr = part_ptr;
+			error("partition pointer reset for job %u, part %s",
+			      job_ptr->job_id, job_ptr->partition);
 		}
-	}
-	list_iterator_destroy(job_iterator);
-	if (error_code) 
-		goto cleanup;
-
-	i = list_count(run_job_list) + cg_hung;
-	/* Do not try to backfill if
-	 * we already have many running jobs,
-	 * there are no pending jobs, OR
-	 * there are insufficient idle nodes to start any pending jobs */
-	if ((i > MAX_JOB_CNT)
-	|| list_is_empty(pend_job_list)
-	|| (min_pend_job_size > part_specs.idle_node_cnt))
-		goto cleanup;
-
-	list_sort(pend_job_list, _sort_by_prio);
-	list_sort(run_job_list, _sort_by_end);
-	_build_node_space_map(&part_specs);
-	_backfill_part(&part_specs);
-
-      cleanup:
-	list_destroy(pend_job_list);
-	list_destroy(run_job_list);
-}
-
-/* get the specs on nodes within a partition */
-static void 
-_get_part_specs(struct part_record *part_ptr, part_specs_t *part_specs)
-{
-	int i, j;
+		if ((part_ptr->state_up == 0) ||
+		    (part_ptr->node_bitmap == NULL))
+		 	continue;
+		if ((part_ptr->root_only) && filter_root)
+			continue;
 
-	part_specs->idle_node_cnt = 0;
-	part_specs->max_cpus      = 0;
-	part_specs->min_cpus      = INFINITE;
-	part_specs->min_mem       = INFINITE;
-	part_specs->min_disk      = INFINITE;
+		if (license_job_test(job_ptr) != SLURM_SUCCESS)
+			continue;
+		if (job_independent(job_ptr) != true)
+			continue;
 
-	for (i=0; i<node_record_count; i++) {
-		struct node_record *node_ptr = &node_record_table_ptr[i];
-		bool found_part = false;
+		/* Determine minimum and maximum node counts */
+		min_nodes = MAX(job_ptr->details->min_nodes,
+				part_ptr->min_nodes);
+		if (job_ptr->details->max_nodes == 0)
+			max_nodes = part_ptr->max_nodes;
+		else
+			max_nodes = MIN(job_ptr->details->max_nodes,
+					part_ptr->max_nodes);
+		max_nodes = MIN(max_nodes, 500000);     /* prevent overflows */
+		if (job_ptr->details->max_nodes)
+			req_nodes = max_nodes;
+		else
+			req_nodes = min_nodes;
+		if (min_nodes > max_nodes) {
+			/* job's min_nodes exceeds partition's max_nodes */
+			continue;
+		}
 
-		for (j=0; j<node_ptr->part_cnt; j++) {
-			if (node_ptr->part_pptr[j] != part_ptr)
-				continue;
-			found_part = true;
+		/* Determine job's expected completion time */
+		if (job_ptr->time_limit == NO_VAL)
+			time_limit = part_ptr->max_time;
+		else
+			time_limit = job_ptr->time_limit;
+		end_time = (time_limit * 60) + now;
+
+		/* Identify usable nodes for this job */
+		FREE_NULL_BITMAP(avail_bitmap);
+		avail_bitmap = bit_copy(part_ptr->node_bitmap);
+		for (j=0; ; ) {
+			if (node_space[j].end_time <= end_time) {
+				bit_and(avail_bitmap, 
+					node_space[j].avail_bitmap);
+			}
+			if ((j = node_space[j].next) == 0)
+				break;
+		}
+		if (job_req_node_filter(job_ptr, avail_bitmap))
+			continue;	/* problem with features */
+		if (job_ptr->details->exc_node_bitmap) {
+			bit_not(job_ptr->details->exc_node_bitmap);
+			bit_and(avail_bitmap, 
+				job_ptr->details->exc_node_bitmap);
+			bit_not(job_ptr->details->exc_node_bitmap);
+		}
+		if ((job_ptr->details->req_node_bitmap) &&
+		    (!bit_super_set(job_ptr->details->req_node_bitmap,
+				    avail_bitmap)))
+			continue;	/* required nodes missing */
+		if (bit_set_count(avail_bitmap) < min_nodes)
+			continue;	/* no nodes remain */
+
+		/* Try to schedule the job. First on dedicated nodes
+		 * then on shared nodes (if so configured). */
+		orig_shared = job_ptr->details->shared;
+		job_ptr->details->shared = 0;
+		j = select_g_job_test(job_ptr, avail_bitmap,
+				min_nodes, max_nodes, req_nodes, 
+				SELECT_MODE_WILL_RUN);
+		job_ptr->details->shared = orig_shared;
+		if ((j != SLURM_SUCCESS) && (orig_shared != 0)) {
+			j = select_g_job_test(job_ptr, avail_bitmap,
+					min_nodes, max_nodes, req_nodes, 
+					SELECT_MODE_WILL_RUN);
+		}
+		if (j != SLURM_SUCCESS)
+			continue;	/* not runable */
+		if (job_ptr->start_time <= now) {
+			/* Start the job now */
+			_start_job(job_ptr, avail_bitmap);
 			break;
 		}
-		if (found_part == false)
-			continue;	/* different partition */
-		if (node_ptr->node_state == NODE_STATE_IDLE)
-			part_specs->idle_node_cnt++;
-		if (slurmctld_conf.fast_schedule) {
-			part_specs->max_cpus = MAX(part_specs->max_cpus,
-					node_ptr->config_ptr->cpus);
-			part_specs->min_cpus = MIN(part_specs->min_cpus,
-					node_ptr->config_ptr->cpus);
-			part_specs->min_mem  = MIN(part_specs->min_mem,
-					node_ptr->config_ptr->real_memory);
-			part_specs->min_disk = MIN(part_specs->min_disk,
-					node_ptr->config_ptr->tmp_disk);
-		} else {
-			part_specs->max_cpus = MAX(part_specs->max_cpus,
-					node_ptr->cpus);
-			part_specs->min_cpus = MIN(part_specs->min_cpus,
-					node_ptr->cpus);
-			part_specs->min_mem  = MIN(part_specs->min_mem,
-					node_ptr->real_memory);
-			part_specs->min_disk = MIN(part_specs->min_disk,
-					 node_ptr->tmp_disk);
+		if (job_ptr->start_time > (now + BACKFILL_WINDOW)) {
+			/* Starts too far in the future to worry about */
+			continue;
 		}
-	}
-
-#if __DEBUG
-	info("backfill: partition %s cpus=%u:%u mem=%u+ disk=%u+",
-		part_ptr->name, part_specs->min_cpus, part_specs->max_cpus, 
-		part_specs->min_mem, part_specs->min_disk);
-#endif
-}
 
-/* Add specified pending job to our records */
-static int
-_add_pending_job(struct job_record *job_ptr, struct part_record *part_ptr, 
-		part_specs_t *part_specs)
-{
-	int min_node_cnt;
-	struct job_details *detail_ptr = job_ptr->details;
-
-	if (job_ptr->priority == 0) {
-#if __DEBUG
-		info("backfill: pending job %u is held", job_ptr->job_id);
-#endif
-		return 0;	/* Skip this job */
-	}
+		if (node_space_recs == MAX_BACKFILL_JOB_CNT) {
+			/* Already have too many jobs to deal with */
+			break;
+		}
 
-	if ((job_ptr->time_limit != NO_VAL) && 
-	    (job_ptr->time_limit > part_ptr->max_time)) {
+		/*
+		 * Add reservation to scheduling table
+		 */
+		end_reserve = job_ptr->start_time + (time_limit * 60);
+		bit_not(avail_bitmap);
+		_add_reservation(job_ptr->start_time, end_reserve, 
+				 avail_bitmap, node_space, &node_space_recs);
 #if __DEBUG
-		info("backfill: pending job %u exceeds partition time limit", 
-			job_ptr->job_id);
+		_dump_node_space_table(node_space);
 #endif
-		return 0;	/* Skip this job */
-	}
-
-	if (detail_ptr == NULL) {
-		error("backfill: pending job %u lacks details", 
-			job_ptr->job_id);
-		return 1;
 	}
+	FREE_NULL_BITMAP(avail_bitmap);
 
-	/* figure out how many nodes this job needs */
-	min_node_cnt = (job_ptr->num_procs + part_specs->max_cpus - 1) /
-			part_specs->max_cpus;	/* round up */
-	detail_ptr->min_nodes = MAX(min_node_cnt, detail_ptr->min_nodes);
-	if (detail_ptr->min_nodes > part_ptr->max_nodes) {
-#if __DEBUG
-		info("backfill: pending job %u exceeds partition node limit", 
-				job_ptr->job_id);
-#endif
-		return 0;	/* Skip this job */
+	for (i=0; ; ) {
+		bit_free(node_space[i].avail_bitmap);
+		if ((i = node_space[i].next) == 0)
+			break;
 	}
-
-#if __DEBUG
-	info("backfill: job %u pending on %d nodes", job_ptr->job_id, 
-		detail_ptr->min_nodes);
-#endif
-
-	list_append(pend_job_list, (void *) job_ptr);
-	return 0;
+	xfree(job_queue);
 }
 
-/* Add specified running job to our records */
-static int
-_add_running_job(struct job_record *job_ptr)
+static int _start_job(struct job_record *job_ptr, bitstr_t *avail_bitmap)
 {
+	int rc;
+	bitstr_t *orig_exc_nodes = NULL;
+	static uint32_t fail_jobid = 0;
+
+	if (job_ptr->details->exc_node_bitmap)
+		orig_exc_nodes = job_ptr->details->exc_node_bitmap;
+	job_ptr->details->exc_node_bitmap = bit_copy(avail_bitmap);
+	bit_not(job_ptr->details->exc_node_bitmap);
+
+	rc = select_nodes(job_ptr, false, NULL);
+	bit_free(job_ptr->details->exc_node_bitmap);
+	job_ptr->details->exc_node_bitmap = orig_exc_nodes;
+	if (rc == SLURM_SUCCESS) {	
+		/* job initiated */
+		last_job_update = time(NULL);
+		info("backfill: Started JobId=%u on %s",
+		     job_ptr->job_id, job_ptr->nodes);
+		if (job_ptr->batch_flag)
+			launch_job(job_ptr);
+		else
+			srun_allocate(job_ptr->job_id);
+		backfilled_jobs++;
 #if __DEBUG
-	info("backfill: job %u running on %d nodes: %s", job_ptr->job_id, 
-			job_ptr->node_cnt, job_ptr->nodes);
+		info("backfill: Jobs backfilled: %d", backfilled_jobs);
 #endif
+	} else if (job_ptr->job_id != fail_jobid) {
+		char *node_list = bitmap2node_name(avail_bitmap);
+		/* This happens when a job has sharing disabled and
+		 * a selected node is still completing some job, 
+		 * which should be a temporary situation. */
+		verbose("backfill: Failed to start JobId=%u on %s: %s",
+			job_ptr->job_id, node_list, slurm_strerror(rc));
+		xfree(node_list);
+		fail_jobid = job_ptr->job_id;
+	} else {
+		debug3("backfill: Failed to start JobId=%u", job_ptr->job_id);
+	}
 
-	list_append(run_job_list, (void *) job_ptr);
-	return 0;
+	return rc;
 }
 
-/* build a map of how many nodes are free at any point in time 
- * based upon currently running jobs. pending jobs are added to 
- * the map as we execute the backfill algorithm */
-static void 
-_build_node_space_map(part_specs_t *part_specs)
+/* trigger the attempt of a backfill */
+extern void run_backfill (void)
 {
-	ListIterator run_job_iterate;
-	struct job_record *run_job_ptr;
-	int base_size = 0;
-
-	node_space_recs = 0;
-
-	if (part_specs->idle_node_cnt) {
-		base_size = part_specs->idle_node_cnt;
-		node_space[node_space_recs].idle_node_cnt = base_size; 
-		node_space[node_space_recs++].time = time(NULL);
-	}
-
-	run_job_iterate = list_iterator_create(run_job_list);
-	while ( (run_job_ptr = list_next(run_job_iterate)) ) {
-		uint32_t nodes2free = _get_avail_node_cnt(run_job_ptr);
-		if (nodes2free == 0)
-			continue;	/* no nodes returning to service */
-		base_size += nodes2free;
-		node_space[node_space_recs].idle_node_cnt = base_size;
-		node_space[node_space_recs++].time = run_job_ptr->end_time;
-	}
-	list_iterator_destroy(run_job_iterate);
-
-	_dump_node_space_map(0, 0);
+	pthread_mutex_lock( &thread_flag_mutex );
+	new_work = true;
+	pthread_mutex_unlock( &thread_flag_mutex );
 }
 
-static void
-_dump_node_space_map(uint32_t job_id, uint32_t node_cnt)
+/* Report if any changes occurred to job, node or partition information */
+static bool _more_work (void)
 {
-#if __DEBUG
-	int i;
-	time_t now;
+	bool rc;
+	static time_t backfill_job_time  = (time_t) 0;
+	static time_t backfill_node_time = (time_t) 0;
+	static time_t backfill_part_time = (time_t) 0;
 
-	if (job_id == 0)
-		info("backfill: initial node_space_map");
-	else
-		info("backfill: node_space_map after job %u allocated %u nodes", 
-				job_id, node_cnt);
-
-	now = time(NULL);
-	for (i=0; i<node_space_recs; i++) {
-		info("backfill: %3d nodes at time %4d (seconds in future)",
-			node_space[i].idle_node_cnt,	
-			(int) difftime(node_space[i].time, now));
+	pthread_mutex_lock( &thread_flag_mutex );
+	if ( (backfill_job_time  == last_job_update ) &&
+	     (backfill_node_time == last_node_update) &&
+	     (backfill_part_time == last_part_update) &&
+	     (new_work == false) ) {
+		rc = false;
+	} else {
+		backfill_job_time  = last_job_update;
+		backfill_node_time = last_node_update;
+		backfill_part_time = last_part_update;
+		new_work = false;
+		rc = true;
 	}
-#endif
+	pthread_mutex_unlock( &thread_flag_mutex );
+	return rc;
 }
 
-/* return 1 if the job could be started now, 0 otherwise and add job into
- * node_space_map
- */
-static int
-_update_node_space_map(struct job_record *job_ptr)
+/* Create a reservation for a job in the future */
+static void _add_reservation(uint32_t start_time, uint32_t end_reserve, 
+			     bitstr_t *res_bitmap, 
+			     node_space_map_t *node_space, 
+			     int *node_space_recs)
 {
-	int i, j, min_nodes, nodes_needed;
-	time_t fini_time;
-
-	if (node_space_recs == 0)	/* no nodes now or in future */
-		return 0;
-	if (job_ptr->details == NULL)	/* pending job lacks details */
-		return 0;
-
-	if (job_ptr->time_limit == NO_VAL)
-		fini_time = time(NULL) + job_ptr->part_ptr->max_time;
-	else
-		fini_time = time(NULL) + job_ptr->time_limit;
-	min_nodes = node_space[0].idle_node_cnt;
-	for (i=1; i<node_space_recs; i++) {
-		if (node_space[i].time > fini_time)
+	int i, j;
+
+	for (j=0; ; ) {
+		if (node_space[j].end_time > start_time) {
+			/* insert start entry record */
+			i = *node_space_recs;
+			node_space[i].begin_time = start_time;
+			node_space[i].end_time = node_space[j].end_time;
+			node_space[j].end_time = start_time;
+			node_space[i].avail_bitmap = 
+				bit_copy(node_space[j].avail_bitmap);
+			node_space[i].next = node_space[j].next;
+			node_space[j].next = i;
+			(*node_space_recs)++;
 			break;
-		if (min_nodes > node_space[i].idle_node_cnt)
-			min_nodes = node_space[i].idle_node_cnt;
-	}
-	
-	nodes_needed = job_ptr->details->min_nodes;
-	if (nodes_needed <= min_nodes)
-		return 1;
-
-	for (i=0; i<node_space_recs; i++) {
-		int fits = 0;
-		if (node_space[i].idle_node_cnt < nodes_needed)
-			continue;	/* can't start yet... */
-		fits = 1;
-		for (j=i; j<node_space_recs; j++) {
-			if (node_space[j].idle_node_cnt < nodes_needed) {
-				fits = 0;
-				break;
-			}
 		}
-		if (fits == 0)
-			continue;
-		for (j=i; j<node_space_recs; j++) {
-			node_space[j].idle_node_cnt -= nodes_needed;
+		if (node_space[j].end_time == start_time) {
+			/* no need to insert start entry record */
+			break;
 		}
-		break;
-	}
-
-	_dump_node_space_map(job_ptr->job_id, nodes_needed);
-	return 0;
-}
-
-/* return the number of nodes to be returned to this partition when
- * the specified job terminates. Don't count DRAIN or DOWN nodes */
-static int
-_get_avail_node_cnt(struct job_record *job_ptr)
-{
-	int cnt = 0, i;
-	struct node_record *node_ptr;
-	uint16_t base_state;
-
-	for (i=0; i<node_record_count; i++) { 
-		if (bit_test(job_ptr->node_bitmap, i) == 0)
-			continue;
-		node_ptr = node_record_table_ptr + i;
-		if (node_ptr->node_state & NODE_STATE_DRAIN)
-			continue;
-		base_state = node_ptr->node_state & NODE_STATE_BASE;
-		if (base_state == NODE_STATE_DOWN)
-			continue;	
-		cnt++;
+		if ((j = node_space[j].next) == 0)
+			break;
 	}
 
-	return cnt;
-}
-
-
-/* scan pending job queue and change the priority of any that 
- * can run now without delaying the expected initiation time 
- * of any higher priority job */
-static void 
-_backfill_part(part_specs_t *part_specs)
-{
-	struct job_record *pend_job_ptr;
-	ListIterator pend_job_iterate;
-	struct job_record *first_job = NULL;	/* just used as flag */
-
-	/* find job to possibly backfill */
-	pend_job_iterate = list_iterator_create(pend_job_list);
-	while ( (pend_job_ptr = list_next(pend_job_iterate)) ) {
-		if (first_job == NULL)
-			first_job = pend_job_ptr;
-
-		if (_loc_restrict(pend_job_ptr, part_specs)) {
-#if __DEBUG
-			info("Job %u has locality restrictions",
-				pend_job_ptr->job_id);
-#endif
-			continue;
-		}
-
-		if (first_job == pend_job_ptr) {
-			if (pend_job_ptr->details == NULL)
-				break;
-			if (pend_job_ptr->details->min_nodes <= 
-					part_specs->idle_node_cnt) {
-#if __DEBUG
-				info("Job %u should start via FIFO",
-					pend_job_ptr->job_id);
-#endif
-				break;
-			}
+#if 0
+	/* This records end of reservation so we maintain a full map
+	 * of when jobs start and end. Since we only care about starting 
+	 * jobs right now, the end of reservation time is not very useful
+	 * unless we want to track expected job initiation time, which 
+	 * would necessitate additional logic. */
+	for (j=0; ; ) {
+		if ((node_space[j].begin_time < end_reserve) &&
+		    (node_space[j].end_time   > end_reserve)) {
+			/* insert end entry record */
+			i = *node_space_recs;
+			node_space[i].begin_time = node_space[j].begin_time;
+			node_space[j].begin_time = end_reserve;
+			node_space[i].end_time = end_reserve;
+			node_space[i].avail_bitmap = 
+				bit_copy(node_space[j].avail_bitmap);
+			node_space[i].next = j;
+			node_space[previous].next = i;
+			(*node_space_recs)++;
+			break;
 		}
-
-		if (_update_node_space_map(pend_job_ptr)) {
-			_change_prio(pend_job_ptr, 
-				(first_job->priority + 1));
+		if (node_space[j].end_time == end_reserve) {
+			/* no need to insert end entry record */
 			break;
 		}
+		previous = j;
+		if ((j = node_space[j].next) == 0)
+			break;
 	}
-	list_iterator_destroy(pend_job_iterate);
-}
 
-/* Return true if job has locality restrictions, false otherwise */
-static bool
-_loc_restrict(struct job_record *job_ptr, part_specs_t *part_specs)
-{
-	struct job_details *detail_ptr = job_ptr->details;
-	
-	if (detail_ptr == NULL)
-		return false;
-
-	if ( (detail_ptr->contiguous) || (detail_ptr->features)  ||
-	     (detail_ptr->req_nodes && detail_ptr->req_nodes[0]) ||
-	     (detail_ptr->exc_nodes && detail_ptr->exc_nodes[0]) )
-		return true;
-
-	if ( (detail_ptr->job_min_procs    > part_specs->min_cpus) ||
-	     (detail_ptr->job_min_memory   > part_specs->min_mem)  ||
-	     (detail_ptr->job_min_tmp_disk > part_specs->min_disk) )
-		return true;
-
-	if (part_specs->max_cpus != part_specs->min_cpus) {
-		int max_node_cnt;
-		max_node_cnt = (job_ptr->num_procs + part_specs->min_cpus 
-				- 1) / part_specs->min_cpus;
-		if (max_node_cnt > detail_ptr->min_nodes)
-			return true;
+	for (j=0; ; ) {
+		if ((node_space[j].begin_time >= start_time) &&
+		    (node_space[j].end_time   <= end_reserve)) {
+			bit_and(node_space[j].avail_bitmap, res_bitmap);
+		}
+		if ((j = node_space[j].next) == 0)
+			break;
 	}
-
-	return false;
-}
-
-/* Change the priority of a pending job to get it running now */
-static void
-_change_prio(struct job_record *job_ptr, uint32_t prio)
-{
-	info("backfill: set job %u to priority %u", job_ptr->job_id, prio);
-	job_ptr->priority = prio;
-	altered_job = true;
-	run_backfill();
-	last_job_update = time(NULL);
+#else
+	for (j=0; ; ) {
+		if (node_space[j].begin_time >= start_time)
+			bit_and(node_space[j].avail_bitmap, res_bitmap);
+		if ((j = node_space[j].next) == 0)
+			break;
+	}
+#endif
 }
-
diff --git a/src/plugins/sched/backfill/backfill.h b/src/plugins/sched/backfill/backfill.h
index de1ab0a09624aa31bd162bd6187dfa703f4c58b6..76ff6d13641dcf8d421275f8594f9604659fefdf 100644
--- a/src/plugins/sched/backfill/backfill.h
+++ b/src/plugins/sched/backfill/backfill.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/backfill/backfill_wrapper.c b/src/plugins/sched/backfill/backfill_wrapper.c
index 0a14d07994b44406b84ff774608a60efd92515b1..d2940cffea8dac76a0bda9bec95a963613e9cf6b 100644
--- a/src/plugins/sched/backfill/backfill_wrapper.c
+++ b/src/plugins/sched/backfill/backfill_wrapper.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -137,6 +137,24 @@ slurm_sched_plugin_schedule( void )
 	return SLURM_SUCCESS;
 }
 
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_newalloc                   ) */
+/***************************************************************************/
+int
+slurm_sched_plugin_newalloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_freealloc                  ) */
+/***************************************************************************/
+int
+slurm_sched_plugin_freealloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
 
 /**************************************************************************/
 /* TAG(                   slurm_sched_plugin_initial_priority           ) */
@@ -183,3 +201,18 @@ char *slurm_sched_strerror( int errnum )
 	return NULL;
 }
 
+/**************************************************************************/
+/* TAG(              slurm_sched_plugin_requeue                         ) */
+/**************************************************************************/
+void slurm_sched_plugin_requeue( struct job_record *job_ptr, char *reason )
+{
+	/* Empty. */
+}
+
+/**************************************************************************/
+/* TAG(              slurm_sched_get_conf                               ) */
+/**************************************************************************/
+char *slurm_sched_get_conf( void )
+{
+	return NULL;
+}
diff --git a/src/plugins/sched/builtin/Makefile.in b/src/plugins/sched/builtin/Makefile.in
index e5153c593c4915533ba6aca7c761587a1477a40e..f157306dc3ae253ac09c6ce220ec8d37d39346dc 100644
--- a/src/plugins/sched/builtin/Makefile.in
+++ b/src/plugins/sched/builtin/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ sched_builtin_la_OBJECTS = $(am_sched_builtin_la_OBJECTS)
 sched_builtin_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(sched_builtin_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = -fexceptions
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -297,8 +310,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -306,8 +319,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -361,8 +374,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -374,8 +387,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -385,13 +398,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/sched/builtin/builtin_wrapper.c b/src/plugins/sched/builtin/builtin_wrapper.c
index 72df0a5c77462281615acf1855b49046cf3190b4..9abed1f5e5c2321c744a97ae4141969e9d625956 100644
--- a/src/plugins/sched/builtin/builtin_wrapper.c
+++ b/src/plugins/sched/builtin/builtin_wrapper.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -83,6 +83,24 @@ slurm_sched_plugin_schedule( void )
 	return SLURM_SUCCESS;
 }
 
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_newalloc                   ) */
+/***************************************************************************/
+int
+slurm_sched_plugin_newalloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_freealloc                  ) */
+/***************************************************************************/
+int
+slurm_sched_plugin_freealloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
 
 /**************************************************************************/
 /* TAG(                   slurm_sched_plugin_initial_priority           ) */ 
@@ -129,3 +147,18 @@ char *slurm_sched_strerror( int errnum )
 	return NULL;
 }
 
+/**************************************************************************/
+/* TAG(              slurm_sched_plugin_requeue                         ) */
+/**************************************************************************/
+void slurm_sched_plugin_requeue( struct job_record *job_ptr, char *reason )
+{
+	/* Empty. */
+}
+
+/**************************************************************************/
+/* TAG(              slurm_sched_get_conf                               ) */
+/**************************************************************************/
+char *slurm_sched_get_conf( void )
+{
+	return NULL;
+}
diff --git a/src/plugins/sched/gang/Makefile.in b/src/plugins/sched/gang/Makefile.in
index c494168eadf5a7c3a19afabc4a032d750e4cc753..a71c67159ffbbdc9ed40651a0be44f94a6e83fb3 100644
--- a/src/plugins/sched/gang/Makefile.in
+++ b/src/plugins/sched/gang/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ sched_gang_la_OBJECTS = $(am_sched_gang_la_OBJECTS)
 sched_gang_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(sched_gang_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = -fexceptions
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -301,8 +314,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -310,8 +323,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -366,8 +379,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -379,8 +392,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -390,13 +403,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/sched/gang/gang.c b/src/plugins/sched/gang/gang.c
index f7fb884d24f2503594ff33128be3ab6e8fff0923..86ab638b195a7201ea5cfbe3c65c0b7fa9927395 100644
--- a/src/plugins/sched/gang/gang.c
+++ b/src/plugins/sched/gang/gang.c
@@ -1,10 +1,9 @@
 /*****************************************************************************
  *  gang.c - Gang scheduler functions.
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
+ *  Written by Chris Holmes
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -13,18 +12,18 @@
  *  the terms of the GNU General Public License as published by the Free
  *  Software Foundation; either version 2 of the License, or (at your option)
  *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
+ *  
+ *  In addition, as a special exception, the copyright holders give permission
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and
+ *  distribute linked combinations including the two. You must obey the GNU
+ *  General Public License in all respects for all of the code used other than
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this
+ *  exception to your version of the file(s), but you are not obligated to do
  *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
+ *  version.  If you delete this exception statement from all source files in
  *  the program, then also delete it here.
- *  
+ *
  *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
@@ -35,168 +34,1415 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
+/*
+ * gang scheduler plugin for SLURM
+ */
+
+#include <pthread.h>
+#include <unistd.h>
+
 #include "./gang.h"
+#include "slurm/slurm.h"
+#include "src/common/bitstring.h"
+#include "src/common/list.h"
+#include "src/common/node_select.h"
 #include "src/common/slurm_protocol_defs.h"
-#include "src/slurmctld/slurmctld.h"
+#include "src/common/xstring.h"
 #include "src/slurmctld/locks.h"
+#include "src/slurmctld/slurmctld.h"
 
+/* global timeslicer thread variables */
 static bool thread_running = false;
 static bool thread_shutdown = false;
 static pthread_mutex_t thread_flag_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_t gang_thread_id;
+static pthread_t timeslicer_thread_id;
+
+/* timeslicer flags and structures */
+enum entity_type {
+	GS_NODE,
+	GS_SOCKET,
+	GS_CORE,
+	GS_CPU
+};
+
+enum gs_flags {
+	GS_SUSPEND,
+	GS_RESUME,
+	GS_NO_PART,
+	GS_SUCCESS,
+	GS_ACTIVE,
+	GS_NO_ACTIVE,
+	GS_FILLER
+};
+
+struct gs_job {
+	uint32_t job_id;
+	uint16_t sig_state;
+	uint16_t row_state;
+	bitstr_t *resmap;
+	uint16_t *alloc_cpus;
+};
+
+struct gs_part {
+	char *part_name;
+	uint16_t priority;
+	uint32_t num_jobs;
+	struct gs_job **job_list;
+	uint32_t job_list_size;
+	uint32_t num_shadows;
+	struct gs_job **shadow;  /* see '"Shadow" Design' below */
+	uint32_t shadow_size;
+	uint32_t jobs_active;
+	bitstr_t *active_resmap;
+	uint16_t *active_cpus;
+	uint16_t array_size;
+	struct gs_part *next;
+};
+
+/******************************************
+ *
+ *       SUMMARY OF DATA MANAGEMENT
+ *
+ * For GS_NODE and GS_CPU:    bits in resmaps represent nodes
+ * For GS_SOCKET and GS_CORE: bits in resmaps represent sockets
+ * GS_NODE and GS_SOCKET ignore the CPU array
+ * GS_CPU and GS_CORE use the CPU array to help resolve conflict
+ *
+ *         EVALUATION ALGORITHM
+ *
+ * For GS_NODE and GS_SOCKET: bits CANNOT conflict
+ * For GS_CPUS and GS_CORE:  if bits conflict, make sure sum of CPUs per
+ *                           resource don't exceed physical resource count
+ *
+ *
+ * The j_ptr->alloc_cpus array is a collection of allocated values ONLY.
+ * For every bit set in j_ptr->resmap, there is a corresponding element
+ * (with an equal-to or less-than index value) in j_ptr->alloc_cpus. 
+ *
+ ******************************************
+ *
+ *        "Shadow" Design to support Preemption
+ *
+ * Jobs in higher priority partitions "cast shadows" on the active
+ * rows of lower priority partitions. The effect is that jobs that
+ * are "caught" in these shadows are preempted (suspended)
+ * indefinitely until the "shadow" disappears. When constructing
+ * the active row of a partition, any jobs in the 'shadow' array
+ * are applied first.
+ *
+ ******************************************
+ */
+
+
+/* global variables */
+static uint32_t timeslicer_seconds = 0;
+static uint16_t gr_type = GS_NODE;
+static uint16_t gs_fast_schedule = 0;
+static struct gs_part *gs_part_list = NULL;
+static uint32_t default_job_list_size = 64;
+static uint32_t gs_resmap_size = 0;
+static pthread_mutex_t data_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static uint32_t gs_num_groups = 0;
+static uint16_t *gs_cpus_per_res = NULL;
+static uint32_t *gs_cpu_count_reps = NULL;
+
+static struct gs_part **gs_part_sorted = NULL;
+static uint32_t num_sorted_part = 0;
+
+#define GS_CPU_ARRAY_INCREMENT 8
+
+/* function declarations */
+static void *_timeslicer_thread();
+
+
+char *_print_flag(int flag) {
+	switch (flag) {
+	case GS_SUSPEND:   return "GS_SUSPEND";
+	case GS_RESUME:    return "GS_RESUME";
+	case GS_NO_PART:   return "GS_NO_PART";
+	case GS_SUCCESS:   return "GS_SUCCESS";
+	case GS_ACTIVE:    return "GS_ACTIVE";
+	case GS_NO_ACTIVE: return "GS_NO_ACTIVE";
+	case GS_FILLER:    return "GS_FILLER";
+	default:           return "unknown";
+	}
+	return "unknown";
+}
+
+
+void _print_jobs(struct gs_part *p_ptr)
+{
+	int i;
+	debug3("sched/gang:  part %s has %u jobs, %u shadows:",
+		p_ptr->part_name, p_ptr->num_jobs, p_ptr->num_shadows);
+	for (i = 0; i < p_ptr->num_shadows; i++) {
+		debug3("sched/gang:   shadow job %u row_s %s, sig_s %s",
+			p_ptr->shadow[i]->job_id,
+			_print_flag(p_ptr->shadow[i]->row_state),
+			_print_flag(p_ptr->shadow[i]->sig_state));
+	}
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		debug3("sched/gang:   job %u row_s %s, sig_s %s",
+			p_ptr->job_list[i]->job_id,
+			_print_flag(p_ptr->job_list[i]->row_state),
+			_print_flag(p_ptr->job_list[i]->sig_state));
+	}
+	if (p_ptr->active_resmap) {
+		int s = bit_size(p_ptr->active_resmap);
+		i = bit_set_count(p_ptr->active_resmap);
+		debug3("sched/gang:  active resmap has %d of %d bits set", i, s);
+	}
+}
 
-/* Global configuration parameters */
-uint16_t multi_prog_level = 2;	/* maximum multi-programming level */
-uint16_t slice_time = 10;	/* seconds */
+static uint16_t
+_get_gr_type() {
 
-static bool	_context_switch(void);
-static void *	_gang_thread(void *no_data);
-static int	_gang_resume_job(uint32_t jobid);
-static int	_gang_suspend_job(uint32_t jobid);
-static void	_parse_gang_config(void);
+	switch (slurmctld_conf.select_type_param) {
+	case CR_CORE:
+	case CR_CORE_MEMORY:
+		return GS_CORE;
+	case CR_CPU:
+	case CR_CPU_MEMORY:
+		return GS_CPU;
+	case CR_SOCKET:
+	case CR_SOCKET_MEMORY:
+		return GS_SOCKET;
+	}
+	/* note that CR_MEMORY is node-level scheduling with
+	 * memory management */
+	return GS_NODE;
+}
 
+/* Return resource data for the given node */
+static uint16_t
+_compute_resources(int i, char socket_count)
+{
+	if (gr_type == GS_NODE)
+		return 1;
 
-/* _parse_gang_config - load gang scheduler configuration parameters.
- * To read gang.conf configuration file, see _parse_wiki_config
- * code in src/wiki/msg.c, or add parameters to main config file */
+	if (gr_type == GS_CPU) {
+		if (socket_count)
+			return 1;
+		if (gs_fast_schedule)
+			return node_record_table_ptr[i].config_ptr->cpus;
+		return node_record_table_ptr[i].cpus;
+	}
+	
+	if (socket_count || gr_type == GS_SOCKET) {
+		if (gs_fast_schedule)
+			return node_record_table_ptr[i].config_ptr->sockets;
+		return node_record_table_ptr[i].sockets;
+	}
+
+	/* gr_type == GS_CORE */
+	if (gs_fast_schedule)
+		return node_record_table_ptr[i].config_ptr->cores;
+	return node_record_table_ptr[i].cores;
+}
+
+/* For GS_CPU  the gs_phys_res_cnt is the total number of CPUs per node.
+ * For GS_CORE the gs_phys_res_cnt is the total number of cores per socket per
+ * node (currently no nodes are made with different core counts per socket) */
 static void
-_parse_gang_config(void)
+_load_phys_res_cnt()
 {
-	/* Reset multi_prog_level and slice_time as needed */
+	int i, array_size = GS_CPU_ARRAY_INCREMENT;
+	uint32_t adder;
+
+	xfree(gs_cpus_per_res);
+	xfree(gs_cpu_count_reps);
+	gs_num_groups = 0;
+	if (gr_type == GS_NODE || gr_type == GS_SOCKET)
+		return;
+
+	gs_cpus_per_res   = xmalloc(array_size * sizeof(uint16_t));
+	gs_cpu_count_reps = xmalloc(array_size * sizeof(uint32_t));
+	for (i = 0; i < node_record_count; i++) {
+		uint16_t res = _compute_resources(i, 0);
+		if (gs_cpus_per_res[gs_num_groups] == res) {
+			adder = 1;
+			if (gr_type == GS_CORE)
+				adder = _compute_resources(i, 1);
+			gs_cpu_count_reps[gs_num_groups] += adder;
+			continue;
+		}
+		if (gs_cpus_per_res[gs_num_groups] != 0) {
+			gs_num_groups++;
+			if (gs_num_groups >= array_size) {
+				array_size += GS_CPU_ARRAY_INCREMENT;
+				xrealloc(gs_cpus_per_res,
+					 array_size * sizeof(uint16_t));
+				xrealloc(gs_cpu_count_reps,
+					 array_size * sizeof(uint32_t));
+			}
+		}
+		gs_cpus_per_res[gs_num_groups] = res;
+		adder = 1;
+		if (gr_type == GS_CORE)
+			adder = _compute_resources(i, 1);
+		gs_cpu_count_reps[gs_num_groups] = adder;
+	}
+	gs_num_groups++;
+	for (i = 0; i < gs_num_groups; i++) {
+		debug3("sched/gang: _load_phys_res_cnt: grp %d cpus %u reps %u",
+			i, gs_cpus_per_res[i], gs_cpu_count_reps[i]);
+	}
+	return;
+}
+
+static uint16_t
+_get_phys_res_cnt(int res_index)
+{
+	int i = 0;
+	int pos = gs_cpu_count_reps[i++];
+	while (res_index >= pos) {
+		pos += gs_cpu_count_reps[i++];
+	}
+	return gs_cpus_per_res[i-1];
 }
 
+
+/* The gs_part_list is a single large array of gs_part entities.
+ * To destroy it, step down the array and destroy the pieces of
+ * each gs_part entity, and then delete the whole array.
+ * To destroy a gs_part entity, you need to delete the name, the
+ * list of jobs, the shadow list, and the active_resmap. Each
+ * job has a resmap that must be deleted also.
+ */
+static void
+_destroy_parts() {
+	int i;
+	struct gs_part *tmp, *ptr = gs_part_list;
+	struct gs_job *j_ptr;
+
+	while (ptr) {
+		tmp = ptr;
+		ptr = ptr->next;
+
+		xfree(tmp->part_name);
+		for (i = 0; i < tmp->num_jobs; i++) {
+			j_ptr = tmp->job_list[i];
+			if (j_ptr->resmap)
+				bit_free(j_ptr->resmap);
+			xfree(j_ptr->alloc_cpus);
+			xfree(j_ptr);
+		}
+		xfree(tmp->shadow);
+		if (tmp->active_resmap)
+			bit_free(tmp->active_resmap);
+		xfree(tmp->active_cpus);
+		xfree(tmp->job_list);
+	}
+	xfree(gs_part_list);
+}
+
+/* Build the gs_part_list. The job_list will be created later,
+ * once a job is added. */
+static void
+_build_parts() {
+	ListIterator part_iterator;
+	struct part_record *p_ptr;
+	int i, num_parts;
+
+	if (gs_part_list)
+		_destroy_parts();
+
+	/* reset the sorted list, since it's currently
+	 * pointing to partitions we just destroyed */
+	num_sorted_part = 0;
+
+	num_parts = list_count(part_list);
+	if (!num_parts)
+		return;
+
+	part_iterator = list_iterator_create(part_list);
+	if (part_iterator == NULL)
+		fatal ("memory allocation failure");
+
+	gs_part_list = xmalloc(num_parts * sizeof(struct gs_part));
+	i = 0;
+	while ((p_ptr = (struct part_record *) list_next(part_iterator))) {
+		gs_part_list[i].part_name = xstrdup(p_ptr->name);
+		gs_part_list[i].priority = p_ptr->priority;
+		/* everything else is already set to zero/NULL */
+		gs_part_list[i].next = &(gs_part_list[i+1]);
+		i++;
+	}
+	gs_part_list[--i].next = NULL;
+	list_iterator_destroy(part_iterator);
+}
+
+/* Find the gs_part entity with the given name */
+static struct gs_part *
+_find_gs_part(char *name)
+{
+	struct gs_part *p_ptr = gs_part_list;
+	for (; p_ptr; p_ptr = p_ptr->next) {
+		if (strcmp(name, p_ptr->part_name) == 0)
+			return p_ptr;
+	}
+	return NULL;
+}
+
+/* Find the job_list index of the given job_id in the given partition */
 static int
-_gang_resume_job(uint32_t jobid)
+_find_job_index(struct gs_part *p_ptr, uint32_t job_id) {
+	int i;
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		if (p_ptr->job_list[i]->job_id == job_id)
+			return i;
+	}
+	return -1;
+}
+
+/* Return 1 if job fits in this row, else return 0 */
+static int
+_can_cpus_fit(bitstr_t *setmap, struct gs_job *j_ptr, struct gs_part *p_ptr)
 {
-	int slurm_rc;
-	suspend_msg_t msg;
+	int i, size, a = 0;
+	uint16_t *p_cpus, *j_cpus;
+
+	size = bit_size(setmap);
+	p_cpus = p_ptr->active_cpus;
+	j_cpus = j_ptr->alloc_cpus;
 
-	msg.job_id = jobid;
-	msg.op = RESUME_JOB;
-	slurm_rc = job_suspend(&msg, 0, -1);
-	if (slurm_rc != SLURM_SUCCESS)
-		error("gang: Failed to resume job %u (%m)", jobid);
-	else
-		info("gang: Resumed job %u", jobid);
-	return slurm_rc;
+	if (!p_cpus || !j_cpus)
+		return 0;
+
+	for (i = 0; i < size; i++) {
+		if (bit_test(setmap, i)) {
+			if (p_cpus[i]+j_cpus[a] > _get_phys_res_cnt(i))
+				return 0;
+		}
+		if (bit_test(j_ptr->resmap, i))
+			a++;
+	}
+	return 1;
 }
 
+
+/* Return 1 if job fits in this row, else return 0 */
 static int
-_gang_suspend_job(uint32_t jobid)
+_job_fits_in_active_row(struct gs_job *j_ptr, struct gs_part *p_ptr)
 {
-	int slurm_rc;
+	int count;
+	bitstr_t *tmpmap;
+
+	if (p_ptr->active_resmap == NULL || p_ptr->jobs_active == 0)
+		return 1;
+
+	tmpmap = bit_copy(j_ptr->resmap);
+	if (!tmpmap)
+		fatal("sched/gang: memory allocation error");
+	
+	bit_and(tmpmap, p_ptr->active_resmap);
+	/* any set bits indicate contention for the same resource */
+	count = bit_set_count(tmpmap);
+	debug3("sched/gang: _job_fits_in_active_row: %d bits conflict", count);
+
+	if (count == 0) {
+		bit_free(tmpmap);
+		return 1;
+	}
+	if (gr_type == GS_NODE || gr_type == GS_SOCKET) {
+		bit_free(tmpmap);
+		return 0;
+	}
+
+	/* for GS_CPU and GS_CORE, we need to compare CPU arrays and
+	 * see if the sum of CPUs on any one resource exceed the total
+	 * of physical resources available */
+	count = _can_cpus_fit(tmpmap, j_ptr, p_ptr);
+	bit_free(tmpmap);
+	return count;
+}
+
+/* Add the given job to the "active" structures of
+ * the given partition and increment the run count */
+static void
+_add_job_to_active(struct gs_job *j_ptr, struct gs_part *p_ptr)
+{
+	int i, a, sz;
+
+	/* add job to active_resmap */
+	if (!p_ptr->active_resmap) {
+		/* allocate the active resmap */
+		debug3("sched/gang: _add_job_to_active: using job %u as active base",
+			j_ptr->job_id);
+		p_ptr->active_resmap = bit_copy(j_ptr->resmap);
+	} else if (p_ptr->jobs_active == 0) {
+		/* if the active_resmap exists but jobs_active is '0',
+		 * this means to overwrite the bitmap memory */
+		debug3("sched/gang: _add_job_to_active: copying job %u into active base",
+			j_ptr->job_id);
+		bit_copybits(p_ptr->active_resmap, j_ptr->resmap);
+	} else {
+		/* add job to existing jobs in the active resmap */
+		debug3("sched/gang: _add_job_to_active: merging job %u into active resmap",
+			j_ptr->job_id);
+		bit_or(p_ptr->active_resmap, j_ptr->resmap);
+	}
+	
+	/* add job to the active_cpus array */
+	if (gr_type == GS_CPU || gr_type == GS_CORE) {
+		sz = bit_size(p_ptr->active_resmap);
+		if (!p_ptr->active_cpus) {
+			/* create active_cpus array */
+			p_ptr->active_cpus = xmalloc(sz * sizeof(uint16_t));
+		}
+		if (p_ptr->jobs_active == 0) {
+			/* overwrite the existing values in active_cpus */
+			a = 0;
+			for (i = 0; i < sz; i++) {
+				if (bit_test(j_ptr->resmap, i)) {
+					p_ptr->active_cpus[i] =
+						j_ptr->alloc_cpus[a++];
+				} else {
+					p_ptr->active_cpus[i] = 0;
+				}
+			}
+		} else {
+			/* add job to existing jobs in the active cpus */
+			a = 0;
+			for (i = 0; i < sz; i++) {
+				if (bit_test(j_ptr->resmap, i)) {
+					uint16_t limit = _get_phys_res_cnt(i);
+					p_ptr->active_cpus[i] +=
+						j_ptr->alloc_cpus[a++];
+					/* when adding shadows, the resources
+					 * may get overcommitted */
+					if (p_ptr->active_cpus[i] > limit)
+						p_ptr->active_cpus[i] = limit;
+				}
+			}
+		}
+	}
+	p_ptr->jobs_active += 1;
+}
+
+static void
+_signal_job(uint32_t job_id, int sig)
+{
+	int rc;
 	suspend_msg_t msg;
+	
+	msg.job_id = job_id;
+	if (sig == GS_SUSPEND) {
+		debug3("sched/gang: suspending %u", job_id);
+		msg.op = SUSPEND_JOB;
+	} else {
+		debug3("sched/gang: resuming %u", job_id);
+		msg.op = RESUME_JOB;
+	}
+	rc = job_suspend(&msg, 0, -1);
+	if (rc)
+		error("sched/gang: error (%d) signaling(%d) job %u", rc, sig,
+		      job_id);
+}
 
-	msg.job_id = jobid;
-	msg.op = SUSPEND_JOB;
-	slurm_rc = job_suspend(&msg, 0, -1);
-	if (slurm_rc != SLURM_SUCCESS)
-		error("gang: Failed to suspend job %u (%m)", jobid);
-	else
-		info("gang: Suspended job %u", jobid);
-	return slurm_rc;
-}
-
-/* _context_switch - This is just a very simple proof of concept sample. 
- *	The production version needs to maintain an Ousterhout matrix and 
- *	make intelligent scheduling decisions. This version supports a 
- *	multi-programming level of 2 only. In practice we'll want a 
- *	time slice much larger than 10 seconds too, but that's fine for 
- *	testing. - Moe */
-static bool
-_context_switch(void)
-{
-	bool run_scheduler = false;
-	struct job_record *job_ptr;
-	ListIterator job_iterator;
+static uint32_t
+_get_resmap_size()
+{
+	int i;
+	uint32_t count = 0;
+	/* if GS_NODE or GS_CPU, then size is the number of nodes */
+	if (gr_type == GS_NODE || gr_type == GS_CPU)
+		return node_record_count;
+	/* else the size is the total number of sockets on all nodes */
+	for (i = 0; i < node_record_count; i++) {
+		count += _compute_resources(i, 1);
+	}
+	return count;
+}
 
-	if (!job_list)	/* Not yet initialized */
-		return false;
+/* Load the gs_job struct with the correct
+ * resmap and CPU array information
+ */
+static void
+_load_alloc_cpus(struct gs_job *j_ptr, bitstr_t *nodemap)
+{
+	int i, a, alloc_index, sz;
 
-	job_iterator = list_iterator_create(job_list);
-	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
-		if (job_ptr->job_state == JOB_RUNNING)
-			_gang_suspend_job(job_ptr->job_id);
-		else if (job_ptr->job_state == JOB_SUSPENDED) {
-			_gang_resume_job(job_ptr->job_id);
-			run_scheduler = true;
+	xfree(j_ptr->alloc_cpus);
+	sz = bit_set_count(j_ptr->resmap);
+	j_ptr->alloc_cpus = xmalloc(sz * sizeof(uint16_t));
+
+	a = 0;
+	alloc_index = 0;
+	for (i = 0; i < node_record_count; i++) {
+		uint16_t j, cores, sockets = _compute_resources(i, 1);
+		
+		if (bit_test(nodemap, i)) {
+			for (j = 0; j < sockets; j++) {
+				cores = select_g_get_job_cores(j_ptr->job_id,
+								alloc_index,
+								j);
+				if (cores > 0)
+					j_ptr->alloc_cpus[a++] = cores;
+			}
+			alloc_index++;
 		}
 	}
-	list_iterator_destroy(job_iterator);
-	return run_scheduler;
 }
 
-/* _gang_thread - A pthread to periodically perform gang scheduler context 
- *	switches. */
-static void *
-_gang_thread(void *no_data)
+/* return an appropriate resmap given the granularity (GS_NODE/GS_CORE/etc.) */
+/* This code fails if the bitmap size has changed. */
+static bitstr_t *
+_get_resmap(bitstr_t *origmap, uint32_t job_id)
+{
+	int i, alloc_index = 0, map_index = 0;
+	bitstr_t *newmap;
+	
+	if (bit_size(origmap) != node_record_count) {
+		error("sched/gang: bitmap size has changed from %d for %u",
+			node_record_count, job_id);
+		fatal("sched/gang: inconsistent bitmap size error");
+	}
+	if (gr_type == GS_NODE || gr_type == GS_CPU) {
+		newmap = bit_copy(origmap);
+		return newmap;
+	}
+	
+	/* for GS_SOCKET and GS_CORE the resmap represents sockets */
+	newmap = bit_alloc(gs_resmap_size);
+	if (!newmap) {
+		fatal("sched/gang: memory error creating newmap");
+	}
+	for (i = 0; i < node_record_count; i++) {
+		uint16_t j, cores, sockets = _compute_resources(i, 1);
+		
+		if (bit_test(origmap, i)) {
+			for (j = 0; j < sockets; j++) {
+				cores = select_g_get_job_cores(job_id,
+								alloc_index,
+								j);
+				if (cores > 0)
+					bit_set(newmap, map_index);
+				map_index++;
+			}
+			alloc_index++;
+		} else {
+			/* no cores allocated on this node */
+			map_index += sockets;
+		}
+	}
+	return newmap;
+}
+
+/* construct gs_part_sorted as a sorted list of the current partitions */
+static void
+_sort_partitions()
 {
-	bool run_scheduler;
+	struct gs_part *p_ptr;
+	int i, j, size = 0;
 
-	/* Locks: write job and node info */
-	slurmctld_lock_t job_write_lock = {
-		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
+	/* sort all partitions by priority */
+	for (p_ptr = gs_part_list; p_ptr; p_ptr = p_ptr->next, size++);
 
-	while (!thread_shutdown) {
-		lock_slurmctld(job_write_lock);
-		run_scheduler = _context_switch();
-		unlock_slurmctld(job_write_lock);
-		if (run_scheduler)
-			schedule();	/* has own locking */
-		sleep(slice_time);
+	/* sorted array is new, or number of partitions has changed */
+	if (size != num_sorted_part) {
+		xfree(gs_part_sorted);
+		gs_part_sorted = xmalloc(size * sizeof(struct gs_part *));
+		num_sorted_part = size;
+		/* load the array */
+		i = 0;
+		for (p_ptr = gs_part_list; p_ptr; p_ptr = p_ptr->next)
+			gs_part_sorted[i++] = p_ptr;
 	}
-	pthread_exit((void *) 0);
 
-	return NULL;
+	if (size <= 1) {
+		gs_part_sorted[0] = gs_part_list;
+		return;
+	}
+
+	/* sort array (new array or priorities may have changed) */
+	for (j = 0; j < size; j++) {
+		for (i = j+1; i < size; i++) {
+			if (gs_part_sorted[i]->priority >
+				gs_part_sorted[j]->priority) {
+				struct gs_part *tmp_ptr;
+				tmp_ptr = gs_part_sorted[j];
+				gs_part_sorted[j] = gs_part_sorted[i];
+				gs_part_sorted[i] = tmp_ptr;
+			}
+		}
+	}
 }
 
-/*
- * spawn_gang_thread - Create a pthread to perform gang scheduler actions
- *
- * NOTE: Create only one pthread in any plugin. Some systems leak memory on 
- * each pthread_create from within a plugin
+/* Scan the partition list. Add the given job as a "shadow" to every
+ * partition with a lower priority than the given partition */
+static void
+_cast_shadow(struct gs_job *j_ptr, uint16_t priority)
+{
+	struct gs_part *p_ptr;
+	int i;
+	
+	for (p_ptr = gs_part_list; p_ptr; p_ptr = p_ptr->next) {
+		if (p_ptr->priority >= priority)
+			continue;
+		
+		/* This partition has a lower priority, so add
+		 * the job as a "Shadow" */
+		if (!p_ptr->shadow) {
+			p_ptr->shadow_size = default_job_list_size;
+			p_ptr->shadow = xmalloc(p_ptr->shadow_size *
+						sizeof(struct gs_job *));
+			/* 'shadow' is initialized to be NULL filled */
+		} else {
+			/* does this shadow already exist? */
+			for (i = 0; i < p_ptr->num_shadows; i++) {
+				if (p_ptr->shadow[i] == j_ptr)
+					break;
+			}
+			if (i < p_ptr->num_shadows)
+				continue;
+		}
+		
+		if (p_ptr->num_shadows+1 >= p_ptr->shadow_size) {
+			p_ptr->shadow_size *= 2;
+			xrealloc(p_ptr->shadow, p_ptr->shadow_size *
+						sizeof(struct gs_job *));
+		}
+		p_ptr->shadow[p_ptr->num_shadows++] = j_ptr;
+	}
+}
+
+/* Remove the given job as a "shadow" from all partitions */
+static void
+_clear_shadow(struct gs_job *j_ptr)
+{
+	struct gs_part *p_ptr;
+	int i;
+	
+	for (p_ptr = gs_part_list; p_ptr; p_ptr = p_ptr->next) {
+
+		if (!p_ptr->shadow)
+			continue;
+
+		for (i = 0; i < p_ptr->num_shadows; i++) {
+			if (p_ptr->shadow[i] == j_ptr)
+				break;
+		}
+		if (i >= p_ptr->num_shadows)
+			/* job not found */
+			continue;
+
+		p_ptr->num_shadows--;
+
+		/* shift all other jobs down */
+		for (; i < p_ptr->num_shadows; i++)
+			p_ptr->shadow[i] = p_ptr->shadow[i+1];
+		p_ptr->shadow[p_ptr->num_shadows] = NULL;
+	}
+}
+
+/* Rebuild the active row BUT preserve the order of existing jobs.
+ * This is called after one or more jobs have been removed from
+ * the partition or if a higher priority "shadow" has been added
+ * which could preempt running jobs.
  */
-extern int
-spawn_gang_thread(void)
+static void
+_update_active_row(struct gs_part *p_ptr, int add_new_jobs)
+{
+	int i;
+	struct gs_job *j_ptr;
+
+	/* rebuild the active row, starting with any shadows */
+	p_ptr->jobs_active = 0;
+	for (i = 0; p_ptr->shadow && p_ptr->shadow[i]; i++) {
+		_add_job_to_active(p_ptr->shadow[i], p_ptr);
+	}
+	
+	/* attempt to add the existing 'active' jobs */
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		j_ptr = p_ptr->job_list[i];
+		if (j_ptr->row_state != GS_ACTIVE)
+			continue;
+		if (_job_fits_in_active_row(j_ptr, p_ptr)) {
+			_add_job_to_active(j_ptr, p_ptr);
+			_cast_shadow(j_ptr, p_ptr->priority);
+			
+		} else {
+			/* this job has been preempted by a shadow job.
+			 * suspend it and preserve it's job_list order */
+			if (j_ptr->sig_state != GS_SUSPEND) {
+				_signal_job(j_ptr->job_id, GS_SUSPEND);
+				j_ptr->sig_state = GS_SUSPEND;
+				_clear_shadow(j_ptr);
+			}
+			j_ptr->row_state = GS_NO_ACTIVE;
+		}
+	}
+	/* attempt to add the existing 'filler' jobs */
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		j_ptr = p_ptr->job_list[i];
+		if (j_ptr->row_state != GS_FILLER)
+			continue;
+		if (_job_fits_in_active_row(j_ptr, p_ptr)) {
+			_add_job_to_active(j_ptr, p_ptr);
+			_cast_shadow(j_ptr, p_ptr->priority);
+		} else {
+			/* this job has been preempted by a shadow job.
+			 * suspend it and preserve it's job_list order */
+			if (j_ptr->sig_state != GS_SUSPEND) {
+				_signal_job(j_ptr->job_id, GS_SUSPEND);
+				j_ptr->sig_state = GS_SUSPEND;
+				_clear_shadow(j_ptr);
+			}
+			j_ptr->row_state = GS_NO_ACTIVE;
+		}
+	}
+
+	if (!add_new_jobs)
+		return;
+
+	/* attempt to add any new jobs */
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		j_ptr = p_ptr->job_list[i];
+		if (j_ptr->row_state != GS_NO_ACTIVE)
+			continue;
+		if (_job_fits_in_active_row(j_ptr, p_ptr)) {
+			_add_job_to_active(j_ptr, p_ptr);
+			_cast_shadow(j_ptr, p_ptr->priority);
+			/* note that this job is a "filler" for this row */
+			j_ptr->row_state = GS_FILLER;
+			/* resume the job */
+			if (j_ptr->sig_state == GS_SUSPEND) {
+				_signal_job(j_ptr->job_id, GS_RESUME);
+				j_ptr->sig_state = GS_RESUME;
+			}
+		}
+	}
+}
+
+/* rebuild all active rows without reordering jobs:
+ * - attempt to preserve running jobs
+ * - suspend any jobs that have been "shadowed" (preempted)
+ * - resume any "filler" jobs that can be found
+ */
+static void
+_update_all_active_rows()
+{
+	int i;
+	
+	/* Sort the partitions. This way the shadows of any high-priority
+	 * jobs are appropriately adjusted before the lower priority
+	 * partitions are updated */
+	_sort_partitions();
+	
+	for (i = 0; i < num_sorted_part; i++) {
+		_update_active_row(gs_part_sorted[i], 1);
+	}
+}
+
+/* remove the given job from the given partition */
+static void
+_remove_job_from_part(uint32_t job_id, struct gs_part *p_ptr)
+{
+	int i;
+	struct gs_job *j_ptr;
+
+	if (!job_id || !p_ptr)
+		return;
+
+	debug3("sched/gang: _remove_job_from_part: removing job %u", job_id);
+	/* find the job in the job_list */
+	i = _find_job_index(p_ptr, job_id);
+	if (i < 0)
+		/* job not found */
+		return;
+
+	j_ptr = p_ptr->job_list[i];
+	
+	/* remove any shadow first */
+	_clear_shadow(j_ptr);
+	
+	/* remove the job from the job_list by shifting everyone else down */
+	p_ptr->num_jobs -= 1;
+	for (; i < p_ptr->num_jobs; i++) {
+		p_ptr->job_list[i] = p_ptr->job_list[i+1];
+	}
+	p_ptr->job_list[i] = NULL;
+	
+	/* make sure the job is not suspended, and then delete it */
+	if (j_ptr->sig_state == GS_SUSPEND) {
+		debug3("sched/gang: _remove_job_from_part: resuming suspended job %u",
+			j_ptr->job_id);
+		_signal_job(j_ptr->job_id, GS_RESUME);
+	}
+	bit_free(j_ptr->resmap);
+	j_ptr->resmap = NULL;
+	if (j_ptr->alloc_cpus)
+		xfree(j_ptr->alloc_cpus);
+	j_ptr->alloc_cpus = NULL;
+	xfree(j_ptr);
+	
+	return;
+}
+
+/* Add the given job to the given partition, and if it remains running
+ * then "cast it's shadow" over the active row of any partition with a
+ * lower priority than the given partition. Return the sig state of the
+ * job (GS_SUSPEND or GS_RESUME) */
+static uint16_t
+_add_job_to_part(struct gs_part *p_ptr, uint32_t job_id, bitstr_t *job_bitmap)
+{
+	int i;
+	struct gs_job *j_ptr;
+
+	xassert(p_ptr);
+	xassert(job_id > 0);
+	xassert(job_bitmap);
+
+	debug3("sched/gang: _add_job_to_part: adding job %u", job_id);
+	_print_jobs(p_ptr);
+	
+	/* take care of any memory needs */
+	if (!p_ptr->job_list) {
+		p_ptr->job_list_size = default_job_list_size;
+		p_ptr->job_list = xmalloc(p_ptr->job_list_size *
+						sizeof(struct gs_job *));
+		/* job_list is initialized to be NULL filled */
+	}
+	
+	/* protect against duplicates */
+	i = _find_job_index(p_ptr, job_id);
+	if (i >= 0) {
+		/* This job already exists, but the resource allocation
+		 * may have changed. In any case, remove the existing
+		 * job before adding this new one.
+		 */
+		debug3("sched/gang: _add_job_to_part: duplicate job %u detected",
+			job_id);
+		_remove_job_from_part(job_id, p_ptr);
+		_update_active_row(p_ptr, 0);
+	}
+	
+	/* more memory management */
+	if (p_ptr->num_jobs+1 == p_ptr->job_list_size) {
+		p_ptr->job_list_size *= 2;
+		xrealloc(p_ptr->job_list, p_ptr->job_list_size *
+						sizeof(struct gs_job *));
+		for (i = p_ptr->num_jobs+1; i < p_ptr->job_list_size; i++)
+			p_ptr->job_list[i] = NULL;
+	}
+	j_ptr = xmalloc(sizeof(struct gs_job));
+	
+	/* gather job info */
+	j_ptr->job_id    = job_id;
+	j_ptr->sig_state = GS_RESUME;  /* all jobs are running initially */
+	j_ptr->row_state = GS_NO_ACTIVE; /* job is not in the active row */
+	j_ptr->resmap    = _get_resmap(job_bitmap, job_id);
+	j_ptr->alloc_cpus = NULL;
+	if (gr_type == GS_CORE || gr_type == GS_CPU) {
+		_load_alloc_cpus(j_ptr, job_bitmap);
+	}
+
+	/* append this job to the job_list */
+	p_ptr->job_list[p_ptr->num_jobs++] = j_ptr;
+	
+	/* determine the immediate fate of this job (run or suspend) */
+	if (_job_fits_in_active_row(j_ptr, p_ptr)) {
+		debug3("sched/gang: _add_job_to_part: adding job %u to active row", 
+			job_id);
+		_add_job_to_active(j_ptr, p_ptr);
+		/* note that this job is a "filler" for this row */
+		j_ptr->row_state = GS_FILLER;
+		/* all jobs begin in the run state, so
+		 * there's no need to signal this job */
+
+		/* since this job is running we need to "cast it's shadow"
+		 * over lower priority partitions */
+		_cast_shadow(j_ptr, p_ptr->priority);
+
+	} else {
+		debug3("sched/gang: _add_job_to_part: suspending job %u",
+			job_id);
+		_signal_job(j_ptr->job_id, GS_SUSPEND);
+		j_ptr->sig_state = GS_SUSPEND;
+	}
+	
+	_print_jobs(p_ptr);
+	
+	return j_ptr->sig_state;
+}
+
+/* ensure that all jobs running in SLURM are accounted for.
+ * this procedure assumes that the gs data has already been
+ * locked by the caller! 
+ */
+static void
+_scan_slurm_job_list()
+{
+	struct job_record *job_ptr;
+	struct gs_part *p_ptr;
+	int i;
+	ListIterator job_iterator;
+
+	if (!job_list) {	/* no jobs */
+		return;
+	}
+	debug3("sched/gang: _scan_slurm_job_list: job_list exists...");
+	job_iterator = list_iterator_create(job_list);
+	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
+		debug3("sched/gang: _scan_slurm_job_list: checking job %u",
+			job_ptr->job_id);		
+		if (job_ptr->job_state == JOB_PENDING)
+			continue;
+		if (job_ptr->job_state == JOB_SUSPENDED ||
+		    job_ptr->job_state == JOB_RUNNING) {
+			/* are we tracking this job already? */
+			p_ptr = _find_gs_part(job_ptr->partition);
+			if (!p_ptr) /* no partition */
+				continue;
+			i = _find_job_index(p_ptr, job_ptr->job_id);
+			if (i >= 0)
+				/* we're tracking it, so continue */
+				continue;
+			
+			/* We're not tracking this job. Resume it if it's
+			 * suspended, and then add it to the job list. */
+			
+			if (job_ptr->job_state == JOB_SUSPENDED)
+			/* The likely scenario here is that the slurmctld has
+			 * failed over, and this is a job that the sched/gang
+			 * plugin had previously suspended.
+			 * It's not possible to determine the previous order
+			 * of jobs without preserving sched/gang state, which
+			 * is not worth the extra infrastructure. Just resume
+			 * the job and then add it to the job list.
+			 */
+				_signal_job(job_ptr->job_id, GS_RESUME);
+			
+			_add_job_to_part(p_ptr, job_ptr->job_id,
+					 job_ptr->node_bitmap);
+			continue;
+		}
+		
+		/* if the job is not pending, suspended, or running, then
+		   it's completing or completed. Make sure we've released
+		   this job */		
+		p_ptr = _find_gs_part(job_ptr->partition);
+		if (!p_ptr) /* no partition */
+			continue;
+		_remove_job_from_part(job_ptr->job_id, p_ptr);
+	}
+	list_iterator_destroy(job_iterator);
+
+	/* now that all of the old jobs have been flushed out,
+	 * update the active row of all partitions */
+	_update_all_active_rows();
+
+	return;
+}
+
+
+/****************************
+ * SLURM Timeslicer Hooks
+ *
+ * Here is a summary of the primary activities that occur
+ * within this plugin:
+ *
+ * gs_init: initialize plugin
+ *
+ * gs_job_start: a new allocation has been created
+ * gs_job_scan: synchronize with master job list
+ * gs_job_fini: an existing allocation has been cleared
+ * gs_reconfig: refresh partition and job data
+ * _cycle_job_list: timeslicer thread is rotating jobs
+ *
+ * gs_fini: terminate plugin
+ *
+ ***************************/
+
+static void
+_spawn_timeslicer_thread()
 {
 	pthread_attr_t thread_attr_msg;
 
 	pthread_mutex_lock( &thread_flag_mutex );
 	if (thread_running) {
-		error("gang thread already running, not starting another");
+		error("timeslicer thread already running, not starting another");
 		pthread_mutex_unlock(&thread_flag_mutex);
-		return SLURM_ERROR;
+		return;
 	}
 
-	_parse_gang_config();
 	slurm_attr_init(&thread_attr_msg);
-	if (pthread_create(&gang_thread_id, &thread_attr_msg, 
-			_gang_thread, NULL))
+	if (pthread_create(&timeslicer_thread_id, &thread_attr_msg, 
+			_timeslicer_thread, NULL))
 		fatal("pthread_create %m");
 
 	slurm_attr_destroy(&thread_attr_msg);
 	thread_running = true;
 	pthread_mutex_unlock(&thread_flag_mutex);
+}
+
+extern int
+gs_init()
+{
+	/* initialize global variables */
+	debug3("sched/gang: entering gs_init");
+	timeslicer_seconds = slurmctld_conf.sched_time_slice;
+	gs_fast_schedule = slurm_get_fast_schedule();
+	gr_type = _get_gr_type();
+	gs_resmap_size = _get_resmap_size();
+
+	/* load the physical resource count data */
+	_load_phys_res_cnt();
+
+	pthread_mutex_lock(&data_mutex);
+	_build_parts();
+	/* load any currently running jobs */
+	_scan_slurm_job_list();
+	pthread_mutex_unlock(&data_mutex);
+
+	/* spawn the timeslicer thread */
+	_spawn_timeslicer_thread();
+	debug3("sched/gang: leaving gs_init");
 	return SLURM_SUCCESS;
 }
 
-extern void
-term_gang_thread(void)
+extern int
+gs_fini()
 {
+	/* terminate the timeslicer thread */
+	debug3("sched/gang: entering gs_fini");
 	pthread_mutex_lock(&thread_flag_mutex);
 	if (thread_running) {
 		int i;
 		thread_shutdown = true;
 		for (i=0; i<4; i++) {
-			if (pthread_cancel(gang_thread_id)) {
-				gang_thread_id = 0;
+			if (pthread_cancel(timeslicer_thread_id)) {
+				timeslicer_thread_id = 0;
 				break;
 			}
 			usleep(1000);
 		}
-		if (gang_thread_id)
-			error("Cound not kill gang pthread");
+		if (timeslicer_thread_id)
+			error("sched/gang: Cound not kill timeslicer pthread");
 	}
 	pthread_mutex_unlock(&thread_flag_mutex);
+	
+	pthread_mutex_lock(&data_mutex);
+	_destroy_parts();
+	xfree(gs_part_sorted);
+	gs_part_sorted = NULL;
+	xfree(gs_cpus_per_res);
+	xfree(gs_cpu_count_reps);
+	gs_num_groups = 0;
+	pthread_mutex_unlock(&data_mutex);
+	debug3("sched/gang: leaving gs_fini");
+
+	return SLURM_SUCCESS;
 }
 
+extern int
+gs_job_start(struct job_record *job_ptr)
+{
+	struct gs_part *p_ptr;
+	uint16_t job_state;
+
+	debug3("sched/gang: entering gs_job_start");
+	/* add job to partition */
+	pthread_mutex_lock(&data_mutex);
+	p_ptr = _find_gs_part(job_ptr->partition);
+	if (p_ptr) {
+		job_state = _add_job_to_part(p_ptr, job_ptr->job_id,
+						job_ptr->node_bitmap);
+		/* if this job is running then check for preemption */
+		if (job_state == GS_RESUME)
+			_update_all_active_rows();
+	}
+	pthread_mutex_unlock(&data_mutex);
+
+	if (!p_ptr) {
+		/* No partition was found for this job, so let it run
+		 * uninterupted (what else can we do?)
+		 */
+		error("sched_gang: could not find partition %s for job %u",
+		      job_ptr->partition, job_ptr->job_id);
+	}
+	debug3("sched/gang: leaving gs_job_start");
+	return SLURM_SUCCESS;
+}
+
+extern int
+gs_job_scan(void)
+{
+	/* scan the master SLURM job list for any new
+	 * jobs to add, or for any old jobs to remove
+	 */
+	debug3("sched/gang: entering gs_job_scan");
+	pthread_mutex_lock(&data_mutex);
+	_scan_slurm_job_list();
+	pthread_mutex_unlock(&data_mutex);
+	debug3("sched/gang: leaving gs_job_scan");
+
+	return SLURM_SUCCESS;
+}
+
+extern int
+gs_job_fini(struct job_record *job_ptr)
+{
+	struct gs_part *p_ptr;
+	
+	debug3("sched/gang: entering gs_job_fini");
+	pthread_mutex_lock(&data_mutex);
+	p_ptr = _find_gs_part(job_ptr->partition);
+	if (!p_ptr) {
+		pthread_mutex_unlock(&data_mutex);
+		debug3("sched/gang: leaving gs_job_fini");
+		return SLURM_SUCCESS;
+	}
+
+	/* remove job from the partition */
+	_remove_job_from_part(job_ptr->job_id, p_ptr);
+	/* this job may have preempted other jobs, so
+	 * check by updating all active rows */
+	_update_all_active_rows();
+	pthread_mutex_unlock(&data_mutex);
+	debug3("sched/gang: leaving gs_job_fini");
+	
+	return SLURM_SUCCESS;
+}
+
+/* rebuild from scratch */
+/* A reconfigure can affect this plugin in these ways:
+ * - partitions can be added or removed
+ *   - this affects the gs_part_list
+ * - nodes can be removed from a partition, or added to a partition
+ *   - this affects the size of the active resmap
+ *
+ * If nodes have been added or removed, then the node_record_count
+ * will be different from gs_resmap_size. In this case, we need
+ * to resize the existing resmaps to prevent errors when comparing
+ * them.
+ *
+ * Here's the plan:
+ * 1. save a copy of the global structures, and then construct
+ *    new ones.
+ * 2. load the new partition structures with existing jobs, 
+ *    confirming the job exists and resizing their resmaps
+ *    (if necessary).
+ * 3. make sure all partitions are accounted for. If a partition
+ *    was removed, make sure any jobs that were in the queue and
+ *    that were suspended are resumed. Conversely, if a partition
+ *    was added, check for existing jobs that may be contending
+ *    for resources that we could begin timeslicing.
+ * 4. delete the old global structures and return.
+ */
+extern int
+gs_reconfig()
+{
+	int i;
+	struct gs_part *p_ptr, *old_part_list, *newp_ptr;
+	struct job_record *job_ptr;
+
+	debug3("sched/gang: entering gs_reconfig");
+	pthread_mutex_lock(&data_mutex);
+
+	old_part_list = gs_part_list;
+	gs_part_list = NULL;
+	_build_parts();
+	
+	/* scan the old part list and add existing jobs to the new list */
+	for (p_ptr = old_part_list; p_ptr; p_ptr = p_ptr->next) {
+		newp_ptr = _find_gs_part(p_ptr->part_name);
+		if (!newp_ptr) {
+			/* this partition was removed, so resume
+			 * any suspended jobs and continue */
+			for (i = 0; i < p_ptr->num_jobs; i++) {
+				if (p_ptr->job_list[i]->sig_state == GS_SUSPEND) {
+					_signal_job(p_ptr->job_list[i]->job_id,
+						   GS_RESUME);
+					p_ptr->job_list[i]->sig_state = GS_RESUME;
+				}	
+			}
+			continue;
+		}
+		if (p_ptr->num_jobs == 0)
+			/* no jobs to transfer */
+			continue;
+		/* we need to transfer the jobs from p_ptr to new_ptr and
+		 * adjust their resmaps (if necessary). then we need to create
+		 * the active resmap and adjust the state of each job (if
+		 * necessary). NOTE: there could be jobs that only overlap
+		 * on nodes that are no longer in the partition, but we're
+		 * not going to worry about those cases.
+		 */
+		/* add the jobs from p_ptr into new_ptr in their current order
+		 * to preserve the state of timeslicing.
+		 */
+		for (i = 0; i < p_ptr->num_jobs; i++) {
+			job_ptr = find_job_record(p_ptr->job_list[i]->job_id);
+			if (job_ptr == NULL) {
+				/* job no longer exists in SLURM, so drop it */
+				continue;
+			}
+			/* resume any job that is suspended */
+			if (job_ptr->job_state == JOB_SUSPENDED)
+				_signal_job(job_ptr->job_id, GS_RESUME);
+
+			/* transfer the job as long as it is still active */
+			if (job_ptr->job_state == JOB_SUSPENDED ||
+			    job_ptr->job_state == JOB_RUNNING) {				
+				_add_job_to_part(newp_ptr, job_ptr->job_id,
+						 job_ptr->node_bitmap);
+			}
+		}
+	}
+
+	/* confirm all jobs. Scan the master job_list and confirm that we
+	 * are tracking all jobs */
+	_scan_slurm_job_list();
+
+	/* Finally, destroy the old data */
+	p_ptr = gs_part_list;
+	gs_part_list = old_part_list;
+	_destroy_parts();
+	gs_part_list = p_ptr;
+
+	pthread_mutex_unlock(&data_mutex);
+	debug3("sched/gang: leaving gs_reconfig");
+	return SLURM_SUCCESS;
+}
+
+/************************************
+ * Timeslicer Functions
+ ***********************************/
+
+/* Build the active row from the job_list.
+ * The job_list is assumed to be sorted */
+static void
+_build_active_row(struct gs_part *p_ptr)
+{
+	int i;
+	
+	debug3("sched/gang: entering _build_active_row");
+	p_ptr->jobs_active = 0;
+	if (p_ptr->num_jobs == 0)
+		return;
+	
+	/* apply all shadow jobs first */
+	for (i = 0; i < p_ptr->num_shadows; i++) {
+		_add_job_to_active(p_ptr->shadow[i], p_ptr);
+	}
+	
+	/* attempt to add jobs from the job_list in the current order */
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		if (_job_fits_in_active_row(p_ptr->job_list[i], p_ptr)) {
+			_add_job_to_active(p_ptr->job_list[i], p_ptr);
+			p_ptr->job_list[i]->row_state = GS_ACTIVE;
+		}
+	}
+	debug3("sched/gang: leaving _build_active_row");
+}
+
+/* _cycle_job_list
+ *
+ * This is the heart of the timeslicer. The algorithm works as follows:
+ *
+ * 1. Each new job is added to the end of the job list, so the earliest job
+ *    is at the front of the list.
+ * 2. Any "shadow" jobs are first applied to the active_resmap. Then the
+ *    active_resmap is filled out by starting with the first job in the list,
+ *    and adding to it any job that doesn't conflict with the resources.
+ * 3. When the timeslice has passed, all jobs that were added to the active
+ *    resmap are moved to the back of the list (preserving their order among
+ *    each other).
+ * 4. Loop back to step 2, starting with the new "first job in the list".
+ */
+static void
+_cycle_job_list(struct gs_part *p_ptr)
+{
+	int i, j;
+	struct gs_job *j_ptr;
+	
+	debug3("sched/gang: entering _cycle_job_list");
+	_print_jobs(p_ptr);
+	/* re-prioritize the job_list and set all row_states to GS_NO_ACTIVE */
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		while (p_ptr->job_list[i]->row_state == GS_ACTIVE) {
+			/* move this job to the back row and "de-activate" it */
+			j_ptr = p_ptr->job_list[i];
+			j_ptr->row_state = GS_NO_ACTIVE;
+			for (j = i; j+1 < p_ptr->num_jobs; j++) {
+				p_ptr->job_list[j] = p_ptr->job_list[j+1];
+			}
+			p_ptr->job_list[j] = j_ptr;
+		}
+		if (p_ptr->job_list[i]->row_state == GS_FILLER)
+			p_ptr->job_list[i]->row_state = GS_NO_ACTIVE;
+			
+	}
+	debug3("sched/gang: _cycle_job_list reordered job list:");
+	_print_jobs(p_ptr);
+	/* Rebuild the active row. */
+	_build_active_row(p_ptr);
+	debug3("sched/gang: _cycle_job_list new active job list:");
+	_print_jobs(p_ptr);
+
+	/* Suspend running jobs that are GS_NO_ACTIVE */
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		j_ptr = p_ptr->job_list[i];
+		if (j_ptr->row_state == GS_NO_ACTIVE &&
+		    j_ptr->sig_state == GS_RESUME) {
+		    	debug3("sched/gang: _cycle_job_list: suspending job %u",
+				j_ptr->job_id);
+			_signal_job(j_ptr->job_id, GS_SUSPEND);
+			j_ptr->sig_state = GS_SUSPEND;
+			_clear_shadow(j_ptr);
+		}
+	}
+	
+	/* Resume suspended jobs that are GS_ACTIVE */
+	for (i = 0; i < p_ptr->num_jobs; i++) {
+		j_ptr = p_ptr->job_list[i];
+		if (j_ptr->row_state == GS_ACTIVE &&
+		    j_ptr->sig_state == GS_SUSPEND) {
+		    	debug3("sched/gang: _cycle_job_list: resuming job %u",
+				j_ptr->job_id);
+			_signal_job(j_ptr->job_id, GS_RESUME);
+			j_ptr->sig_state = GS_RESUME;
+			_cast_shadow(j_ptr, p_ptr->priority);
+		}
+	}
+	debug3("sched/gang: leaving _cycle_job_list");
+}
+
+/* The timeslicer thread */
+static void *
+_timeslicer_thread() {
+	struct gs_part *p_ptr;
+	int i;
+	
+	debug3("sched/gang: starting timeslicer loop");
+	while (!thread_shutdown) {
+		pthread_mutex_lock(&data_mutex);
+
+		_sort_partitions();
+		
+		/* scan each partition... */
+		debug3("sched/gang: _timeslicer_thread: scanning partitions");
+		for (i = 0; i < num_sorted_part; i++) {
+			p_ptr = gs_part_sorted[i];
+			debug3("sched/gang: _timeslicer_thread: part %s: run %u total %u",
+				p_ptr->part_name, p_ptr->jobs_active,
+				p_ptr->num_jobs);
+			if (p_ptr->jobs_active <
+					p_ptr->num_jobs + p_ptr->num_shadows)
+				_cycle_job_list(p_ptr);
+		}
+		pthread_mutex_unlock(&data_mutex);
+		
+		/* sleep AND check for thread termination requests */
+		pthread_testcancel();
+		debug3("sched/gang: _timeslicer_thread: preparing to sleep");
+		sleep(timeslicer_seconds);
+		debug3("sched/gang: _timeslicer_thread: waking up");
+		pthread_testcancel();
+	}
+	pthread_exit((void *) 0);
+	return NULL;
+}
diff --git a/src/plugins/sched/gang/gang.h b/src/plugins/sched/gang/gang.h
index a08d7b23408a896b795559d2cfda00e740d63d50..520ea513ae3dd50dd34746c1194d39e6e0773339 100644
--- a/src/plugins/sched/gang/gang.h
+++ b/src/plugins/sched/gang/gang.h
@@ -1,10 +1,9 @@
 /*****************************************************************************\
  *  gang.h - Gang scheduler definitions
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
+ *  Written by Chris Holmes
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -13,18 +12,18 @@
  *  the terms of the GNU General Public License as published by the Free
  *  Software Foundation; either version 2 of the License, or (at your option)
  *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
+ *  
+ *  In addition, as a special exception, the copyright holders give permission
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and
+ *  distribute linked combinations including the two. You must obey the GNU
+ *  General Public License in all respects for all of the code used other than
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this
+ *  exception to your version of the file(s), but you are not obligated to do
  *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
+ *  version.  If you delete this exception statement from all source files in
  *  the program, then also delete it here.
- *  
+ *
  *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
@@ -43,9 +42,14 @@
 
 #include "src/common/plugin.h"
 #include "src/common/log.h"
+#include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/slurmctld.h"
 
-extern int	spawn_gang_thread(void);
-extern void	term_gang_thread(void);
+extern int 	gs_init(void);
+extern int 	gs_fini(void);
+extern int	gs_job_start(struct job_record *job_ptr);
+extern int	gs_job_scan(void);
+extern int	gs_job_fini(struct job_record *job_ptr);
+extern int	gs_reconfig(void);
 
 #endif
diff --git a/src/plugins/sched/gang/sched_gang.c b/src/plugins/sched/gang/sched_gang.c
index 5f29755f3342243d0d3e6d5d980e93a8b79ccf78..52095c6a85805be73d64c63fbfcc3beff6ed57c0 100644
--- a/src/plugins/sched/gang/sched_gang.c
+++ b/src/plugins/sched/gang/sched_gang.c
@@ -1,10 +1,9 @@
 /*****************************************************************************\
  *  sched_gang.c - Gang scheduler plugin functions.
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
+ *  Written by Chris Holmes
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -13,18 +12,18 @@
  *  the terms of the GNU General Public License as published by the Free
  *  Software Foundation; either version 2 of the License, or (at your option)
  *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
+ *  
+ *  In addition, as a special exception, the copyright holders give permission
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and
+ *  distribute linked combinations including the two. You must obey the GNU
+ *  General Public License in all respects for all of the code used other than
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this
+ *  exception to your version of the file(s), but you are not obligated to do
  *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
+ *  version.  If you delete this exception statement from all source files in
  *  the program, then also delete it here.
- *  
+ *
  *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
@@ -39,7 +38,7 @@
 
 const char		plugin_name[]	= "Gang Scheduler plugin";
 const char		plugin_type[]	= "sched/gang";
-const uint32_t		plugin_version	= 100;
+const uint32_t		plugin_version	= 101;
 
 /* A plugin-global errno. */
 static int plugin_errno = SLURM_SUCCESS;
@@ -50,7 +49,7 @@ static int plugin_errno = SLURM_SUCCESS;
 extern int init( void )
 {
 	verbose( "gang scheduler plugin loaded" );
-	return spawn_gang_thread();
+	return gs_init();
 }
 
 /**************************************************************************/
@@ -58,7 +57,7 @@ extern int init( void )
 /**************************************************************************/
 extern void fini( void )
 {
-	term_gang_thread();
+	gs_fini();
 }
 
 /**************************************************************************/
@@ -66,7 +65,7 @@ extern void fini( void )
 /**************************************************************************/
 int slurm_sched_plugin_reconfig( void )
 {
-	return SLURM_SUCCESS;
+	return gs_reconfig();
 }
 
 /***************************************************************************/
@@ -74,9 +73,34 @@ int slurm_sched_plugin_reconfig( void )
 /***************************************************************************/
 extern int slurm_sched_plugin_schedule( void )
 {
+	/* synchronize job listings */
+	debug3("sched/gang: slurm_sched_schedule called");
+	/* return gs_job_scan();*/
 	return SLURM_SUCCESS;
 }
 
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_newalloc                   ) */
+/***************************************************************************/
+extern int slurm_sched_plugin_newalloc( struct job_record *job_ptr )
+{
+	if (!job_ptr)
+		return SLURM_ERROR;
+	debug3("sched/gang: slurm_sched_newalloc called");
+	return gs_job_start(job_ptr);
+}
+
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_freealloc                  ) */
+/***************************************************************************/
+extern int slurm_sched_plugin_freealloc( struct job_record *job_ptr )
+{
+	if (!job_ptr)
+		return SLURM_ERROR;
+	debug3("sched/gang: slurm_sched_freealloc called");
+	return gs_job_fini(job_ptr);
+}
+
 
 /**************************************************************************/
 /* TAG(                   slurm_sched_plugin_initial_priority           ) */ 
@@ -85,6 +109,8 @@ extern uint32_t
 slurm_sched_plugin_initial_priority( uint32_t last_prio,
 				     struct job_record *job_ptr )
 {
+	/* ignored for timeslicing, but will be used to support priority */
+
 	if (last_prio >= 2)
 		return (last_prio - 1);
 	else
@@ -96,7 +122,8 @@ slurm_sched_plugin_initial_priority( uint32_t last_prio,
 /**************************************************************************/
 void slurm_sched_plugin_job_is_pending( void )
 {
-	/* No action required */
+	/* synchronize job listings? Here? */
+	/*return gs_job_scan();*/
 }
 
 /**************************************************************************/
@@ -104,7 +131,7 @@ void slurm_sched_plugin_job_is_pending( void )
 /**************************************************************************/
 void slurm_sched_plugin_partition_change( void )
 {
-        /* No action required */
+        gs_reconfig();
 }
 
 /**************************************************************************/
@@ -123,3 +150,18 @@ char *slurm_sched_strerror( int errnum )
 	return NULL;
 }
 
+/**************************************************************************/
+/* TAG(              slurm_sched_plugin_requeue                         ) */
+/**************************************************************************/
+void slurm_sched_plugin_requeue( struct job_record *job_ptr, char *reason )
+{
+	/* Empty. */
+}
+
+/**************************************************************************/
+/* TAG(              slurm_sched_get_conf                               ) */
+/**************************************************************************/
+char *slurm_sched_get_conf( void )
+{
+	return NULL;
+}
diff --git a/src/plugins/sched/hold/Makefile.in b/src/plugins/sched/hold/Makefile.in
index 3100ebc068c8eec38dcc63a714b7746c5dd1f4f3..4f1130aa282a07707918e995d70333593a5dfad2 100644
--- a/src/plugins/sched/hold/Makefile.in
+++ b/src/plugins/sched/hold/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -79,7 +81,7 @@ sched_hold_la_OBJECTS = $(am_sched_hold_la_OBJECTS)
 sched_hold_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(sched_hold_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = -fexceptions
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -297,8 +310,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -306,8 +319,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -361,8 +374,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -374,8 +387,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -385,13 +398,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/sched/hold/hold_wrapper.c b/src/plugins/sched/hold/hold_wrapper.c
index c488374c8eeb96812d2a13d017e7c43c05149db4..7e6dc6405a717a3bc7acff891ecbd1b1da1bbe35 100644
--- a/src/plugins/sched/hold/hold_wrapper.c
+++ b/src/plugins/sched/hold/hold_wrapper.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -88,6 +88,24 @@ slurm_sched_plugin_schedule( void )
 	return SLURM_SUCCESS;
 }
 
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_newalloc                   ) */
+/***************************************************************************/
+int
+slurm_sched_plugin_newalloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_freealloc                  ) */
+/***************************************************************************/
+int
+slurm_sched_plugin_freealloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
 
 /**************************************************************************/
 /* TAG(                   slurm_sched_plugin_initial_priority           ) */ 
@@ -139,3 +157,18 @@ char *slurm_sched_strerror( int errnum )
 	return NULL;
 }
 
+/**************************************************************************/
+/* TAG(              slurm_sched_plugin_requeue                         ) */
+/**************************************************************************/
+void slurm_sched_plugin_requeue( struct job_record *job_ptr, char *reason )
+{
+	/* Empty. */
+}
+
+/**************************************************************************/
+/* TAG(              slurm_sched_get_conf                               ) */
+/**************************************************************************/
+char *slurm_sched_get_conf( void )
+{
+	return NULL;
+}
diff --git a/src/plugins/sched/wiki/Makefile.in b/src/plugins/sched/wiki/Makefile.in
index 17ec4ae8413bfebc5baf1db7ba7e934685ea2c7f..7efbdab57657b8e4302d73c3ac83713d5b4793e9 100644
--- a/src/plugins/sched/wiki/Makefile.in
+++ b/src/plugins/sched/wiki/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -81,7 +83,7 @@ sched_wiki_la_OBJECTS = $(am_sched_wiki_la_OBJECTS)
 sched_wiki_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(sched_wiki_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -121,6 +123,7 @@ CXXFLAGS = -fexceptions
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -134,10 +137,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -157,7 +163,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -168,6 +177,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -183,6 +194,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -198,6 +210,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -313,8 +326,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -322,8 +335,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -387,8 +400,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -400,8 +413,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -411,13 +424,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/sched/wiki/cancel_job.c b/src/plugins/sched/wiki/cancel_job.c
index ec392bbdd9036bdb6636a30ef399576c04c386c4..a74921f06b4a65ec860fb3d4b574d2fddf63dfa2 100644
--- a/src/plugins/sched/wiki/cancel_job.c
+++ b/src/plugins/sched/wiki/cancel_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki/get_jobs.c b/src/plugins/sched/wiki/get_jobs.c
index 687bd65cd48cb6ea11297814eaae35c94cc088f2..e638098a1f130f3f149411b8197b138eadb86134 100644
--- a/src/plugins/sched/wiki/get_jobs.c
+++ b/src/plugins/sched/wiki/get_jobs.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -42,6 +42,7 @@
 #include "src/common/hostlist.h"
 #include "src/common/list.h"
 #include "src/common/uid.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 
@@ -125,8 +126,8 @@ extern int	get_jobs(char *cmd_ptr, int *err_code, char **err_msg)
 		/* report all jobs */
 		buf = _dump_all_jobs(&job_rec_cnt, update_time);
 	} else {
-		struct job_record *job_ptr;
-		char *job_name, *tmp2_char;
+		struct job_record *job_ptr = NULL;
+		char *job_name = NULL, *tmp2_char = NULL;
 		uint32_t job_id;
 
 		job_name = strtok_r(tmp_char, ":", &tmp2_char);
@@ -148,7 +149,10 @@ extern int	get_jobs(char *cmd_ptr, int *err_code, char **err_msg)
 	if (buf)
 		buf_size = strlen(buf);
 	tmp_buf = xmalloc(buf_size + 32);
-	sprintf(tmp_buf, "SC=0 ARG=%d#%s", job_rec_cnt, buf);
+	if (job_rec_cnt)
+		sprintf(tmp_buf, "SC=0 ARG=%d#%s", job_rec_cnt, buf);
+	else
+		sprintf(tmp_buf, "SC=0 ARG=0#");
 	xfree(buf);
 	*err_code = 0;
 	*err_msg = tmp_buf;
@@ -241,18 +245,18 @@ static char *	_dump_job(struct job_record *job_ptr, time_t update_time)
 	}
 
 	snprintf(tmp, sizeof(tmp), 
-		"UPDATETIME=%u;WCLIMIT=%u;",
+		"UPDATETIME=%u;WCLIMIT=%u;TASKS=%u;",
 		(uint32_t) job_ptr->time_last_active,
-		(uint32_t) _get_job_time_limit(job_ptr));
+		(uint32_t) _get_job_time_limit(job_ptr),
+		_get_job_tasks(job_ptr));
 	xstrcat(buf, tmp);
 
-	/* Don't report actual tasks or nodes allocated since
-	 * this can impact requeue on heterogenous clusters */
-	snprintf(tmp, sizeof(tmp),
-		"TASKS=%u;NODES=%u;",
-		_get_job_tasks(job_ptr),
-		_get_job_min_nodes(job_ptr));
-	xstrcat(buf, tmp);
+	if (!IS_JOB_FINISHED(job_ptr)) {
+		snprintf(tmp, sizeof(tmp),
+			"NODES=%u;",
+			_get_job_min_nodes(job_ptr));
+		xstrcat(buf, tmp);
+	}
 
 	snprintf(tmp, sizeof(tmp),
 		"DPROCS=%u;",
@@ -344,7 +348,8 @@ static uint32_t _get_job_min_disk(struct job_record *job_ptr)
 static uint32_t	_get_job_min_nodes(struct job_record *job_ptr)
 {
 	if (job_ptr->job_state > JOB_PENDING) {
-		/* return actual count of allocated nodes */
+		/* return actual count of currently allocated nodes.
+		 * NOTE: gets decremented to zero while job is completing */
 		return job_ptr->node_cnt;
 	}
 
@@ -372,15 +377,21 @@ static uint32_t _get_job_submit_time(struct job_record *job_ptr)
 
 static uint32_t _get_job_tasks(struct job_record *job_ptr)
 {
-	uint32_t task_cnt = 1;
-
-	if (job_ptr->num_procs)
-		task_cnt = job_ptr->num_procs;
+	uint32_t task_cnt;
 
-	if (job_ptr->details) {
-		task_cnt = MAX(task_cnt,
-			       (_get_job_min_nodes(job_ptr) * 
-			        job_ptr->details->ntasks_per_node));
+	if (job_ptr->job_state > JOB_PENDING) {
+		task_cnt = job_ptr->total_procs;
+	} else {
+		if (job_ptr->num_procs)
+			task_cnt = job_ptr->num_procs;
+		else
+			task_cnt = 1;
+		if (job_ptr->details) {
+			task_cnt = MAX(task_cnt,
+				       (_get_job_min_nodes(job_ptr) * 
+				        job_ptr->details->
+					ntasks_per_node));
+		}
 	}
 
 	return task_cnt / _get_job_cpus_per_task(job_ptr);
@@ -414,12 +425,12 @@ static char *	_get_job_state(struct job_record *job_ptr)
 			return "Running";
 	}
 
-	if (base_state == JOB_PENDING)
-		return "Idle";
 	if (base_state == JOB_RUNNING)
 		return "Running";
 	if (base_state == JOB_SUSPENDED)
 		return "Suspended";
+	if (base_state == JOB_PENDING)
+		return "Idle";
 
 	if (base_state == JOB_COMPLETE)
 		return "Completed";
diff --git a/src/plugins/sched/wiki/get_nodes.c b/src/plugins/sched/wiki/get_nodes.c
index 8569e9580ad97087373c7eba099d019fb99c8505..7c51c106db97c2f4cf43f17b4cbed4073e65aa3e 100644
--- a/src/plugins/sched/wiki/get_nodes.c
+++ b/src/plugins/sched/wiki/get_nodes.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -50,10 +50,16 @@ static char *	_get_node_state(struct node_record *node_ptr);
  * RET 0 on success, -1 on failure
  *
  * Response format
- * ARG=<cnt>#<NODEID>:STATE=<state>;
- *                    FEATURE=<feature:feature>;
- *                    CMEMORY=<mb>;CDISK=<mb>;CPROC=<cpus>;
- *         [#<NODEID>:...];
+ * Response format
+ * ARG=<cnt>#<NODEID>:
+ *	STATE=<state>;		 Moab equivalent node state
+ *	[ARCH=<architecture>;]	 Computer architecture
+ *	[OS=<operating_system>;] Operating system
+ *	CMEMORY=<MB>;		 MB of memory on node
+ *	CDISK=<MB>;		 MB of disk space on node
+ *	CPROCS=<cpus>;		 CPU count on node
+ *	[FEATURE=<feature>;]	 Features associated with node, if any
+ *  [#<NODEID>:...];
  */
 extern int	get_nodes(char *cmd_ptr, int *err_code, char **err_msg)
 {
@@ -84,12 +90,17 @@ extern int	get_nodes(char *cmd_ptr, int *err_code, char **err_msg)
 		/* report all nodes */
 		buf = _dump_all_nodes(&node_rec_cnt, update_time);
 	} else {
-		struct node_record *node_ptr;
-		char *node_name, *tmp2_char;
+		struct node_record *node_ptr = NULL;
+		char *node_name = NULL, *tmp2_char = NULL;
 
 		node_name = strtok_r(tmp_char, ":", &tmp2_char);
 		while (node_name) {
 			node_ptr = find_node_record(node_name);
+			if (node_ptr == NULL) {
+				error("sched/wiki2: bad hostname %s",
+				      node_name);
+				continue;
+			}
 			tmp_buf = _dump_node(node_ptr, update_time);
 			if (node_rec_cnt > 0)
 				xstrcat(buf, "#");
@@ -105,7 +116,10 @@ extern int	get_nodes(char *cmd_ptr, int *err_code, char **err_msg)
 	if (buf)
 		buf_size = strlen(buf);
 	tmp_buf = xmalloc(buf_size + 32);
-	sprintf(tmp_buf, "SC=0 ARG=%d#%s", node_rec_cnt, buf);
+	if (node_rec_cnt)
+		sprintf(tmp_buf, "SC=0 ARG=%d#%s", node_rec_cnt, buf);
+	else
+		sprintf(tmp_buf, "SC=0 ARG=0#");
 	xfree(buf);
 	*err_code = 0;
 	*err_msg = tmp_buf;
@@ -144,7 +158,30 @@ static char *	_dump_node(struct node_record *node_ptr, time_t update_time)
 		node_ptr->name, 
 		_get_node_state(node_ptr));
 	xstrcat(buf, tmp);
-	
+
+	if (node_ptr->arch) {
+		snprintf(tmp, sizeof(tmp), "ARCH=%s;", node_ptr->arch);
+		xstrcat(buf, tmp);
+	}
+
+	if (node_ptr->os) {
+		snprintf(tmp, sizeof(tmp), "OS=%s;", node_ptr->os);
+		xstrcat(buf, tmp);
+	}
+
+	if (node_ptr->config_ptr
+	&&  node_ptr->config_ptr->feature) {
+		snprintf(tmp, sizeof(tmp), "FEATURES=%s;",
+			node_ptr->config_ptr->feature);
+		/* comma separated to colon */
+		for (i=0; (tmp[i] != '\0'); i++) {
+			if ((tmp[i] == ',')
+			||  (tmp[i] == '|'))
+				tmp[i] = ':';
+		}
+		xstrcat(buf, tmp);
+	}
+
 	if (update_time > 0)
 		return buf;
 
@@ -165,19 +202,6 @@ static char *	_dump_node(struct node_record *node_ptr, time_t update_time)
 	}
 	xstrcat(buf, tmp);
 
-	if (node_ptr->config_ptr
-	&&  node_ptr->config_ptr->feature) {
-		snprintf(tmp, sizeof(tmp), "FEATURES=%s;",
-			node_ptr->config_ptr->feature);
-		/* comma separated to colon */
-		for (i=0; (tmp[i] != '\0'); i++) {
-			if ((tmp[i] == ',')
-			||  (tmp[i] == '|'))
-				tmp[i] = ':';
-		}
-		xstrcat(buf, tmp);
-	}
-
 	return buf;
 }
 
@@ -186,7 +210,8 @@ static char *	_get_node_state(struct node_record *node_ptr)
 	uint16_t state = node_ptr->node_state;
 	uint16_t base_state = state & NODE_STATE_BASE;
 
-	if (state & NODE_STATE_DRAIN)
+	if ((state & NODE_STATE_DRAIN)
+	||  (state & NODE_STATE_FAIL))
 		return "Draining";
 	if (state & NODE_STATE_COMPLETING)
 		return "Busy";
diff --git a/src/plugins/sched/wiki/hostlist.c b/src/plugins/sched/wiki/hostlist.c
index c31dc6bf89207b154d55f354e6f062353055becc..1c3214891a3b94e82f51c210c66a315dec2e5db7 100644
--- a/src/plugins/sched/wiki/hostlist.c
+++ b/src/plugins/sched/wiki/hostlist.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -74,7 +74,8 @@ static char * _task_list_exp(struct job_record *job_ptr);
  */
 extern char * moab2slurm_task_list(char *moab_tasklist, int *task_cnt)
 {
-	char *slurm_tasklist, *host, *tmp1, *tmp2, *tok, *tok_p;
+	char *slurm_tasklist = NULL, *host = NULL, *tmp1 = NULL, 
+		*tmp2 = NULL, *tok = NULL, *tok_p = NULL;
 	int i, reps;
 	hostlist_t hl;
 	static uint32_t cr_test = 0, cr_enabled = 0;
diff --git a/src/plugins/sched/wiki/job_modify.c b/src/plugins/sched/wiki/job_modify.c
index e3a62654951e8e3241d248157ca37ac629aa2c60..4ac123c9ca7c52b6c137e17389a290154a04f7cd 100644
--- a/src/plugins/sched/wiki/job_modify.c
+++ b/src/plugins/sched/wiki/job_modify.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -37,10 +37,11 @@
 
 #include "./msg.h"
 #include <strings.h>
+#include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 
-static void	_null_term(char *str)
+extern void	null_term(char *str)
 {
 	char *tmp_ptr;
 	for (tmp_ptr=str; ; tmp_ptr++) {
@@ -53,24 +54,8 @@ static void	_null_term(char *str)
 	}
 }
 
-/* return -1 on error */
-static int32_t _get_depend_id(char *str)
-{
-	/* stand-alone job_id */
-	if (isdigit(str[0]))
-		return (int32_t) atol(str);
-
-	if (strncasecmp(str, "afterany:", 9) != 0)	/* invalid spec */
-		return (int32_t) -1;
-
-	str += 9;
-	if (!isdigit(str[0]))
-		return (int32_t) -1;
-	return (int32_t) atol(str);
-}
-
 static int	_job_modify(uint32_t jobid, char *bank_ptr, 
-			int32_t depend_id, char *new_hostlist,
+			char *depend_ptr, char *new_hostlist,
 			uint32_t new_node_cnt, char *part_name_ptr, 
 			uint32_t new_time_limit)
 {
@@ -86,9 +71,16 @@ static int	_job_modify(uint32_t jobid, char *bank_ptr,
 		return ESLURM_DISABLED;
 	}
 
-	if (depend_id != -1) {
-		info("wiki: changing job dependency to %d", depend_id);
-		job_ptr->dependency = depend_id;
+	if (depend_ptr) {
+		int rc = update_job_dependency(job_ptr, depend_ptr);
+		if (rc == SLURM_SUCCESS) {
+			info("wiki: changed job %u dependency to %s", 
+				jobid, depend_ptr);
+		} else {
+			error("wiki: changing job %u dependency to %s", 
+				jobid, depend_ptr);
+			return EINVAL;
+		}
 	}
 
 	if (new_time_limit) {
@@ -174,11 +166,11 @@ host_fini:	if (rc) {
 		}
 		info("wiki: change job %u partition %s",
 			jobid, part_name_ptr);
-		strncpy(job_ptr->partition, part_name_ptr, MAX_SLURM_NAME);
+		xfree(job_ptr->partition);
+		job_ptr->partition = xstrdup(part_name_ptr);
 		job_ptr->part_ptr = part_ptr;
 		last_job_update = time(NULL);
 	}
-
 	if (new_node_cnt) {
 		if (IS_JOB_PENDING(job_ptr) && job_ptr->details) {
 			job_ptr->details->min_nodes = new_node_cnt;
@@ -207,7 +199,6 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 	char *arg_ptr, *bank_ptr, *depend_ptr, *nodes_ptr;
 	char *host_ptr, *part_ptr, *time_ptr, *tmp_char;
 	int slurm_rc;
-	int depend_id = -1;
 	uint32_t jobid, new_node_cnt = 0, new_time_limit = 0;
 	static char reply_msg[128];
 	/* Locks: write job, read node and partition info */
@@ -241,24 +232,17 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 	if (bank_ptr) {
 		bank_ptr[4] = ':';
 		bank_ptr += 5;
-		_null_term(bank_ptr);
+		null_term(bank_ptr);
 	}
 	if (depend_ptr) {
 		depend_ptr[6] = ':';
 		depend_ptr += 7;
-		depend_id = _get_depend_id(depend_ptr);
-		if (depend_id == -1) {
-			*err_code = -300;
-			*err_msg = "MODIFYJOB has invalid DEPEND specificiation";
-			error("wiki: MODIFYJOB has invalid DEPEND spec: %s",
-				depend_ptr);
-			return -1;
-		}
+		null_term(depend_ptr);
 	}
 	if (host_ptr) {
 		host_ptr[8] = ':';
 		host_ptr += 9;
-		_null_term(bank_ptr);
+		null_term(bank_ptr);
 	}
 	if (nodes_ptr) {
 		nodes_ptr[5] = ':';
@@ -268,7 +252,7 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 	if (part_ptr) {
 		part_ptr[9] = ':';
 		part_ptr += 10;
-		_null_term(part_ptr);
+		null_term(part_ptr);
 	}
 	if (time_ptr) {
 		time_ptr[9] = ':';
@@ -286,7 +270,7 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 	}
 
 	lock_slurmctld(job_write_lock);
-	slurm_rc = _job_modify(jobid, bank_ptr, depend_id, host_ptr,
+	slurm_rc = _job_modify(jobid, bank_ptr, depend_ptr, host_ptr,
 			new_node_cnt, part_ptr, new_time_limit);
 	unlock_slurmctld(job_write_lock);
 	if (slurm_rc != SLURM_SUCCESS) {
diff --git a/src/plugins/sched/wiki/msg.c b/src/plugins/sched/wiki/msg.c
index 60df0858f47a5a82c5f544616b6904e1d90c5575..8f3ec8252927accb5114a611cbdc157975f04875 100644
--- a/src/plugins/sched/wiki/msg.c
+++ b/src/plugins/sched/wiki/msg.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -38,6 +38,7 @@
 #include "./crypto.h"
 #include "./msg.h"
 #include "src/common/uid.h"
+#include "src/slurmctld/locks.h"
 
 #define _DEBUG 0
 
@@ -139,12 +140,20 @@ static void *_msg_thread(void *no_data)
 	slurm_fd sock_fd = -1, new_fd;
 	slurm_addr cli_addr;
 	char *msg;
-	slurm_ctl_conf_t *conf = slurm_conf_lock();
+	slurm_ctl_conf_t *conf;
 	int i;
+	/* Locks: Write configuration, job, node, and partition */
+	slurmctld_lock_t config_write_lock = {
+		WRITE_LOCK, WRITE_LOCK, WRITE_LOCK, WRITE_LOCK };
 
+	conf = slurm_conf_lock();
 	sched_port = conf->schedport;
 	slurm_conf_unlock();
 
+	/* Wait until configuration is completely loaded */
+	lock_slurmctld(config_write_lock);
+	unlock_slurmctld(config_write_lock);
+
 	/* If SchedulerPort is already taken, keep trying to open it
 	 * once per minute. Slurmctld will continue to function
 	 * during this interval even if nothing can be scheduled. */
@@ -178,8 +187,10 @@ static void *_msg_thread(void *no_data)
 		err_code = 0;
 		err_msg = "";
 		msg = _recv_msg(new_fd);
-		_proc_msg(new_fd, msg);
-		xfree(msg);
+		if (msg) {
+			_proc_msg(new_fd, msg);
+			xfree(msg);
+		}
 		slurm_close_accepted_conn(new_fd);
 	}
 	if (sock_fd > 0)
@@ -202,7 +213,7 @@ static char * _get_wiki_conf_path(void)
 		val = default_slurm_config_file;
 
 	/* Replace file name on end of path */
-	i = strlen(val) + 1;
+	i = strlen(val) + 10;
 	path = xmalloc(i);
 	strcpy(path, val);
 	val = strrchr(path, (int)'/');
@@ -287,7 +298,7 @@ extern int parse_wiki_config(void)
 	s_p_get_uint16(&job_aggregation_time, "JobAggregationTime", tbl); 
 
 	if (s_p_get_string(&exclude_partitions, "ExcludePartitions", tbl)) {
-		char *tok, *tok_p;
+		char *tok = NULL, *tok_p = NULL;
 		tok = strtok_r(exclude_partitions, ",", &tok_p);
 		i = 0;
 		while (tok) {
@@ -344,10 +355,55 @@ extern int parse_wiki_config(void)
 	info("JobAggregationTime = %u sec", job_aggregation_time);
 	info("JobPriority        = %s", init_prio_mode ? "run" : "hold");
 	info("KillWait           = %u sec", kill_wait);      
+	for (i=0; i<EXC_PART_CNT; i++) {
+		if (!exclude_part_ptr[i])
+			continue;
+		info("ExcludePartitions  = %s", exclude_part_ptr[i]->name);
+	}
+	for (i=0; i<HIDE_PART_CNT; i++) {
+		if (!hide_part_ptr[i])
+			continue;
+		info("HidePartitionJobs  = %s", hide_ptr_ptr[i]->name);
+	}
 #endif
 	return SLURM_SUCCESS;
 }
 
+extern char *	get_wiki_conf(void)
+{
+	int i, first;
+	char buf[20], *conf = NULL;
+
+	snprintf(buf, sizeof(buf), "HostFormat=%u", use_host_exp);
+	xstrcat(conf, buf);
+
+	first = 1;
+	for (i=0; i<EXC_PART_CNT; i++) {
+		if (!exclude_part_ptr[i])
+			continue;
+		if (first) {
+			xstrcat(conf, ";ExcludePartitions=");
+			first = 0;
+		} else
+			xstrcat(conf, ",");
+		xstrcat(conf, exclude_part_ptr[i]->name);
+	}
+
+	first = 1;
+	for (i=0; i<HIDE_PART_CNT; i++) {
+		if (!hide_part_ptr[i])
+			continue;
+		if (first) {
+			xstrcat(conf, ";HidePartitionJobs=");
+			first = 0;
+		} else
+			xstrcat(conf, ",");
+		xstrcat(conf, hide_part_ptr[i]->name);
+	}
+
+	return conf;
+}
+
 static size_t	_read_bytes(int fd, char *buf, const size_t size)
 {
 	size_t bytes_remaining, bytes_read;
diff --git a/src/plugins/sched/wiki/msg.h b/src/plugins/sched/wiki/msg.h
index 5015e26cb162d5db939105399b4715007d9b8b44..7964a09a7b34fe36f98e0a15c62a51e040cc94a9 100644
--- a/src/plugins/sched/wiki/msg.h
+++ b/src/plugins/sched/wiki/msg.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -99,10 +99,16 @@ extern uint16_t	job_aggregation_time;
 extern uint16_t kill_wait;
 extern uint16_t use_host_exp;
 
+extern char *   bitmap2wiki_node_name(bitstr_t *bitmap);
 extern int	event_notify(char *msg);
 extern int	spawn_msg_thread(void);
 extern void	term_msg_thread(void);
-extern char *   bitmap2wiki_node_name(bitstr_t *bitmap);
+extern char *   get_wiki_conf(void);
+
+/*
+ * Given a string, replace the first space found with '\0'
+ */
+extern void	null_term(char *str);
 
 /* Functions called from within msg.c (rather than creating a bunch 
  * more header files with one function definition each */
diff --git a/src/plugins/sched/wiki/resume_job.c b/src/plugins/sched/wiki/resume_job.c
index 319219244b55f6128c64c10797901e298a3b2f0a..b172e04d25cc5f8aefc2fe9a42b67a0b0c6d22eb 100644
--- a/src/plugins/sched/wiki/resume_job.c
+++ b/src/plugins/sched/wiki/resume_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki/sched_wiki.c b/src/plugins/sched/wiki/sched_wiki.c
index 64606a366d998632fb2c9ef1e3945a77ae943151..4fdb4dd7dc52df20f5dce6710c58691b1fdfe022 100644
--- a/src/plugins/sched/wiki/sched_wiki.c
+++ b/src/plugins/sched/wiki/sched_wiki.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -76,6 +76,22 @@ extern int slurm_sched_plugin_schedule( void )
 	return SLURM_SUCCESS;
 }
 
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_newalloc                   ) */
+/***************************************************************************/
+extern int slurm_sched_plugin_newalloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_freealloc                  ) */
+/***************************************************************************/
+extern int slurm_sched_plugin_freealloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
 
 /**************************************************************************/
 /* TAG(                   slurm_sched_plugin_initial_priority           ) */ 
@@ -150,3 +166,18 @@ char *slurm_sched_strerror( int errnum )
 	return NULL;
 }
 
+/**************************************************************************/
+/* TAG(              slurm_sched_plugin_requeue                         ) */
+/**************************************************************************/
+void slurm_sched_plugin_requeue( struct job_record *job_ptr, char *reason )
+{
+	/* Empty. */
+}
+
+/**************************************************************************/
+/* TAG(              slurm_sched_get_conf                               ) */
+/**************************************************************************/
+char *slurm_sched_get_conf( void )
+{
+	return get_wiki_conf();
+}
diff --git a/src/plugins/sched/wiki/start_job.c b/src/plugins/sched/wiki/start_job.c
index 180e79742dd7a46e2e30c8830cfc217023da8274..22007c62819de54f4265549482d9f56e40478145 100644
--- a/src/plugins/sched/wiki/start_job.c
+++ b/src/plugins/sched/wiki/start_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -39,6 +39,7 @@
 #include "src/common/node_select.h"
 #include "src/common/slurm_protocol_defs.h"
 #include "src/common/xstring.h"
+#include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 #include "src/slurmctld/state_save.h"
@@ -46,7 +47,9 @@
 static int	_start_job(uint32_t jobid, int task_cnt, char *hostlist, 
 			char *tasklist, int *err_code, char **err_msg);
 
-/* RET 0 on success, -1 on failure */
+/* Start a job:
+ *	CMD=STARTJOB ARG=<jobid> TASKLIST=<node_list>
+ * RET 0 on success, -1 on failure */
 extern int	start_job(char *cmd_ptr, int *err_code, char **err_msg)
 {
 	char *arg_ptr, *task_ptr, *tasklist, *tmp_char;
@@ -79,6 +82,7 @@ extern int	start_job(char *cmd_ptr, int *err_code, char **err_msg)
 		return -1;
 	}
 	task_ptr += 9;	/* skip over "TASKLIST=" */
+	null_term(task_ptr);
 	tasklist = moab2slurm_task_list(task_ptr, &task_cnt);
 	if (tasklist)
 		hl = hostlist_create(tasklist);
diff --git a/src/plugins/sched/wiki/suspend_job.c b/src/plugins/sched/wiki/suspend_job.c
index 058d2dce3f271bb4f7775a8a3aa5701c80b39bfe..383b9539b3ee64cf94e4e9afbf9eb0694df16b03 100644
--- a/src/plugins/sched/wiki/suspend_job.c
+++ b/src/plugins/sched/wiki/suspend_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/Makefile.in b/src/plugins/sched/wiki2/Makefile.in
index 62fccc35004db363eab48fd032a8aa79cc5e9fab..fdd07feb3960c5927607b7df85b757cf3d04252e 100644
--- a/src/plugins/sched/wiki2/Makefile.in
+++ b/src/plugins/sched/wiki2/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -84,7 +86,7 @@ sched_wiki2_la_OBJECTS = $(am_sched_wiki2_la_OBJECTS)
 sched_wiki2_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(sched_wiki2_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -124,6 +126,7 @@ CXXFLAGS = -fexceptions
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -137,10 +140,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -160,7 +166,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -171,6 +180,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -186,6 +197,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -201,6 +213,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -324,8 +337,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -333,8 +346,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -406,8 +419,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -419,8 +432,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -430,13 +443,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/sched/wiki2/cancel_job.c b/src/plugins/sched/wiki2/cancel_job.c
index 294a67c128f18523d0c961bdf80d4308c4775194..8a91bf0a01aa37cf6cc1a74d8366aecbad34cc23 100644
--- a/src/plugins/sched/wiki2/cancel_job.c
+++ b/src/plugins/sched/wiki2/cancel_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/event.c b/src/plugins/sched/wiki2/event.c
index f3795d2d5e3fc1d86c01c5672031429ddce4afa8..5c840507126aed3be2f06747820d196cbd6ebd47 100644
--- a/src/plugins/sched/wiki2/event.c
+++ b/src/plugins/sched/wiki2/event.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/get_jobs.c b/src/plugins/sched/wiki2/get_jobs.c
index 59b3720bd09488349428344388eaaf659e425c7e..b95a9fcc9d68948c2097d2c96ab3dd3af6140991 100644
--- a/src/plugins/sched/wiki2/get_jobs.c
+++ b/src/plugins/sched/wiki2/get_jobs.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -43,6 +43,7 @@
 #include "src/common/list.h"
 #include "src/common/node_select.h"
 #include "src/common/uid.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/locks.h"
 
 static char *	_dump_all_jobs(int *job_cnt, time_t update_time);
@@ -65,10 +66,23 @@ static int	_hidden_job(struct job_record *job_ptr);
 
 static uint32_t cr_enabled = 0, cr_test = 0;
 
+/* We only keep a few reject message to limit the overhead */
+#define REJECT_MSG_MAX        16
+#define REJECT_MSG_LEN       128
+static int reject_msg_cnt = 0;
+typedef struct reject_msg {
+	uint32_t job_id;
+	char     reason[REJECT_MSG_LEN];
+} reject_msg_t;
+reject_msg_t reject_msgs[REJECT_MSG_MAX];
+
 /*
  * get_jobs - get information on specific job(s) changed since some time
- * cmd_ptr IN - CMD=GETJOBS ARG=[<UPDATETIME>:<JOBID>[:<JOBID>]...]
+ * cmd_ptr IN   - CMD=GETJOBS ARG=[<UPDATETIME>:<JOBID>[:<JOBID>]...]
  *                              [<UPDATETIME>:ALL]
+ * err_code OUT - 0 or an error code
+ * err_msg OUT  - response message
+ * NOTE: xfree() err_msg if err_code is zero
  * RET 0 on success, -1 on failure
  *
  * Response format
@@ -100,7 +114,6 @@ static uint32_t cr_enabled = 0, cr_test = 0;
  * [#<JOBID>;...];			additional jobs, if any
  *
  */
-/* RET 0 on success, -1 on failure */
 extern int	get_jobs(char *cmd_ptr, int *err_code, char **err_msg)
 {
 	char *arg_ptr = NULL, *tmp_char = NULL, *tmp_buf = NULL, *buf = NULL;
@@ -165,7 +178,10 @@ extern int	get_jobs(char *cmd_ptr, int *err_code, char **err_msg)
 	if (buf)
 		buf_size = strlen(buf);
 	tmp_buf = xmalloc(buf_size + 32);
-	sprintf(tmp_buf, "SC=0 ARG=%d#%s", job_rec_cnt, buf);
+	if (job_rec_cnt)
+		sprintf(tmp_buf, "SC=0 ARG=%d#%s", job_rec_cnt, buf);
+	else
+		sprintf(tmp_buf, "SC=0 ARG=0#");
 	xfree(buf);
 	*err_code = 0;
 	*err_msg = tmp_buf;
@@ -216,6 +232,7 @@ static char *	_dump_job(struct job_record *job_ptr, time_t update_time)
 {
 	char tmp[16384], *buf = NULL;
 	uint32_t end_time, suspend_time;
+	int i, rej_sent = 0;
 
 	if (!job_ptr)
 		return NULL;
@@ -261,7 +278,22 @@ static char *	_dump_job(struct job_record *job_ptr, time_t update_time)
 		xfree(hosts);
 	}
 
-	if (job_ptr->job_state == JOB_FAILED) {
+	if (reject_msg_cnt) {
+		/* Possible job requeue/reject message */
+		for (i=0; i<REJECT_MSG_MAX; i++) {
+			if (reject_msgs[i].job_id != job_ptr->job_id)
+				continue;
+			snprintf(tmp, sizeof(tmp),
+				"REJMESSAGE=\"%s\";",
+				reject_msgs[i].reason);
+			xstrcat(buf, tmp);
+			reject_msgs[i].job_id = 0;
+			reject_msg_cnt--;
+			rej_sent = 1;
+			break;
+		}
+	}
+	if ((rej_sent == 0) && (job_ptr->job_state == JOB_FAILED)) {
 		snprintf(tmp, sizeof(tmp),
 			"REJMESSAGE=\"%s\";",
 			job_reason_string(job_ptr->state_reason));
@@ -272,16 +304,18 @@ static char *	_dump_job(struct job_record *job_ptr, time_t update_time)
 		xstrcat(buf, "FLAGS=INTERACTIVE;");
 
 	snprintf(tmp, sizeof(tmp), 
-		"UPDATETIME=%u;WCLIMIT=%u;",
+		"UPDATETIME=%u;WCLIMIT=%u;TASKS=%u;",
 		(uint32_t) job_ptr->time_last_active,
-		(uint32_t) _get_job_time_limit(job_ptr));
+		(uint32_t) _get_job_time_limit(job_ptr),
+		_get_job_tasks(job_ptr));
 	xstrcat(buf, tmp);
 
-	snprintf(tmp, sizeof(tmp),
-		"TASKS=%u;NODES=%u;",
-		_get_job_tasks(job_ptr),
-		_get_job_min_nodes(job_ptr));
-	xstrcat(buf, tmp);
+	if (!IS_JOB_FINISHED(job_ptr)) {
+		snprintf(tmp, sizeof(tmp),
+			"NODES=%u;",
+			_get_job_min_nodes(job_ptr));
+		xstrcat(buf, tmp);
+	}
 
 	snprintf(tmp, sizeof(tmp),
 		"DPROCS=%u;",
@@ -351,26 +385,25 @@ static void	_get_job_comment(struct job_record *job_ptr,
 	size = snprintf(buffer, buf_size, "COMMENT=\"");
 
 	/* JOB DEPENDENCY */
-	if (job_ptr->dependency) {
+	if (job_ptr->details && job_ptr->details->dependency) {
 		/* Kludge for job dependency set via srun */
 		size += snprintf((buffer + size), (buf_size - size),
-			"DEPEND=afterany:%u", job_ptr->dependency);
+			"DEPEND=%s", job_ptr->details->dependency);
 		field_sep = "?";
 	}
 
 	/* SHARED NODES */
 	if (cr_enabled)	{			/* consumable resources */
 		if (job_ptr->part_ptr &&
-		    (job_ptr->part_ptr->shared == SHARED_EXCLUSIVE))
+		    (job_ptr->part_ptr->max_share == 0))	/* Exclusive use */
 			sharing = 0;
-		else if (job_ptr->details && (job_ptr->details->shared != 0))
-			sharing = 1;
-	} else if (job_ptr->part_ptr) {			/* partition with */
-		if (job_ptr->part_ptr->shared == SHARED_FORCE)
+		else if (job_ptr->details && job_ptr->details->shared)
 			sharing = 1;
-		else if ((job_ptr->part_ptr->shared == SHARED_YES)
-		&&  (job_ptr->details)			/* optional for partition */
-		&&  (job_ptr->details->shared))		/* with job to share */
+	} else if (job_ptr->part_ptr) {		/* partition level control */
+		if (job_ptr->part_ptr->max_share & SHARED_FORCE)
+			sharing = 1;		/* Sharing forced */
+		else if ((job_ptr->part_ptr->max_share > 1) &&
+		         (job_ptr->details) && (job_ptr->details->shared))
 			sharing = 1;
 	}
 	if (sharing) {
@@ -425,7 +458,8 @@ static uint32_t _get_job_min_disk(struct job_record *job_ptr)
 static uint32_t	_get_job_min_nodes(struct job_record *job_ptr)
 {
 	if (job_ptr->job_state > JOB_PENDING) {
-		/* return actual count of allocated nodes */
+		/* return actual count of currently allocated nodes.
+		 * NOTE: gets decremented to zero while job is completing */
 		return job_ptr->node_cnt;
 	}
 
@@ -453,15 +487,21 @@ static uint32_t _get_job_submit_time(struct job_record *job_ptr)
 
 static uint32_t _get_job_tasks(struct job_record *job_ptr)
 {
-	uint32_t task_cnt = 1;
-
-	if (job_ptr->num_procs)
-		task_cnt = job_ptr->num_procs;
+	uint32_t task_cnt;
 
-	if (job_ptr->details) {
-		task_cnt = MAX(task_cnt,
-			       (_get_job_min_nodes(job_ptr) * 
-			        job_ptr->details->ntasks_per_node));
+	if (job_ptr->job_state > JOB_PENDING) {
+		task_cnt = job_ptr->total_procs;
+	} else {
+		if (job_ptr->num_procs)
+			task_cnt = job_ptr->num_procs;
+		else
+			task_cnt = 1;
+		if (job_ptr->details) {
+			task_cnt = MAX(task_cnt,
+				       (_get_job_min_nodes(job_ptr) * 
+				        job_ptr->details->
+					ntasks_per_node));
+		}
 	}
 
 	return task_cnt / _get_job_cpus_per_task(job_ptr);
@@ -504,12 +544,12 @@ static char *	_get_job_state(struct job_record *job_ptr)
 			return "Running";
 	}
 
-	if (base_state == JOB_PENDING)
-		return "Idle";
 	if (base_state == JOB_RUNNING)
 		return "Running";
 	if (base_state == JOB_SUSPENDED)
 		return "Suspended";
+	if (base_state == JOB_PENDING)
+		return "Idle";
 
 	if ((base_state == JOB_COMPLETE) || (base_state == JOB_FAILED))
 		state_str = "Completed";
@@ -567,4 +607,30 @@ static uint32_t	_get_job_suspend_time(struct job_record *job_ptr)
 	return (uint32_t) 0;
 }
 
+extern void wiki_job_requeue(struct job_record *job_ptr, char *reason)
+{
+	int empty = -1, i;
+
+	for (i=0; i<REJECT_MSG_MAX; i++) {
+		if ((reject_msgs[i].job_id == 0) && (empty == -1)) {
+			empty = i;
+			if (reject_msg_cnt == 0)
+				break;
+		} else if (reject_msgs[i].job_id != job_ptr->job_id)
+			continue;
+
+		/* over-write previous message for this job */
+		strncpy(reject_msgs[i].reason, reason, REJECT_MSG_LEN);
+		reject_msgs[i].reason[REJECT_MSG_LEN - 1] = '\0';
+		return;
+	}
+
+	if (empty == -1)	/* no free space */
+		return;
+
+	reject_msgs[empty].job_id = job_ptr->job_id;
+	strncpy(reject_msgs[i].reason, reason, REJECT_MSG_LEN);
+	reject_msgs[i].reason[REJECT_MSG_LEN - 1] = '\0';
+	reject_msg_cnt++;
+}
 
diff --git a/src/plugins/sched/wiki2/get_nodes.c b/src/plugins/sched/wiki2/get_nodes.c
index ddf66db692fc3830b85312adb67d70d71c8cad70..34450f6746a4a318927ad19497c9d41c2e84be0e 100644
--- a/src/plugins/sched/wiki2/get_nodes.c
+++ b/src/plugins/sched/wiki2/get_nodes.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -36,30 +36,40 @@
 \*****************************************************************************/
 
 #include "./msg.h"
+#include "src/common/hostlist.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 
 static char *	_dump_all_nodes(int *node_cnt, time_t update_time);
-static char *	_dump_node(struct node_record *node_ptr, time_t update_time);
+static char *	_dump_node(struct node_record *node_ptr, hostlist_t hl, 
+			   time_t update_time);
 static char *	_get_node_state(struct node_record *node_ptr);
+static int	_same_info(struct node_record *node1_ptr, 
+			   struct node_record *node2_ptr, time_t update_time);
+static int	_str_cmp(char *s1, char *s2);
 
 /*
  * get_nodes - get information on specific node(s) changed since some time
- * cmd_ptr IN - CMD=GETNODES ARG=[<UPDATETIME>:<NODEID>[:<NODEID>]...]
+ * cmd_ptr IN   - CMD=GETNODES ARG=[<UPDATETIME>:<NODEID>[:<NODEID>]...]
  *                               [<UPDATETIME>:ALL]
+ * err_code OUT - 0 or an error code
+ * err_msg OUT  - response message
+ * NOTE: xfree() err_msg if err_code is zero
  * RET 0 on success, -1 on failure
  *
  * Response format
  * ARG=<cnt>#<NODEID>:
- *	STATE=<state>;		Moab equivalent node state
- *	CCLASS=<[part:cpus]>;	SLURM partition with CPU count of node,
- *				make have more than one partition
- *	CMEMORY=<MB>;		MB of memory on node
- *	CDISK=<MB>;		MB of disk space on node
- *	CPROCS=<cpus>;		CPU count on node
- *	[FEATURE=<feature>;]	features associated with node, if any,
- *	[CAT=<reason>];		Reason for a node being down or drained
- *				colon separator
+ *	STATE=<state>;		 Moab equivalent node state
+ *	[CAT=<reason>];		 Reason for a node being down or drained
+ *				 colon separator
+ *	CCLASS=<[part:cpus]>;	 SLURM partition with CPU count of node,
+ *				 make have more than one partition
+ *	[ARCH=<architecture>;]	 Computer architecture
+ *	[OS=<operating_system>;] Operating system
+ *	CMEMORY=<MB>;		 MB of memory on node
+ *	CDISK=<MB>;		 MB of disk space on node
+ *	CPROCS=<cpus>;		 CPU count on node
+ *	[FEATURE=<feature>;]	 Features associated with node, if any
  *  [#<NODEID>:...];
  */
 extern int	get_nodes(char *cmd_ptr, int *err_code, char **err_msg)
@@ -92,19 +102,31 @@ extern int	get_nodes(char *cmd_ptr, int *err_code, char **err_msg)
 		buf = _dump_all_nodes(&node_rec_cnt, update_time);
 	} else {
 		struct node_record *node_ptr = NULL;
-		char *node_name = NULL, *tmp2_char = NULL;
-
-		node_name = strtok_r(tmp_char, ":", &tmp2_char);
-		while (node_name) {
-			node_ptr = find_node_record(node_name);
-			tmp_buf = _dump_node(node_ptr, update_time);
-			if (node_rec_cnt > 0)
-				xstrcat(buf, "#");
-			xstrcat(buf, tmp_buf);
-			xfree(tmp_buf);
-			node_rec_cnt++;
-			node_name = strtok_r(NULL, ":", &tmp2_char);
+		char *node_name, *slurm_hosts;
+		int node_cnt;
+		hostset_t slurm_hostset;
+
+		slurm_hosts = moab2slurm_task_list(tmp_char, &node_cnt);
+		if ((slurm_hostset = hostset_create(slurm_hosts))) {
+			while ((node_name = hostset_shift(slurm_hostset))) {
+				node_ptr = find_node_record(node_name);
+				if (node_ptr == NULL) {
+					error("sched/wiki2: bad hostname %s", 
+					      node_name);
+					continue;
+				}
+				tmp_buf = _dump_node(node_ptr, NULL, update_time);
+				if (node_rec_cnt > 0)
+					xstrcat(buf, "#");
+				xstrcat(buf, tmp_buf);
+				xfree(tmp_buf);
+				node_rec_cnt++;
+			}
+			hostset_destroy(slurm_hostset);
+		} else {
+			error("hostset_create(%s): %m", slurm_hosts);
 		}
+		xfree(slurm_hosts);
 	}
 	unlock_slurmctld(node_read_lock);
 
@@ -112,7 +134,10 @@ extern int	get_nodes(char *cmd_ptr, int *err_code, char **err_msg)
 	if (buf)
 		buf_size = strlen(buf);
 	tmp_buf = xmalloc(buf_size + 32);
-	sprintf(tmp_buf, "SC=0 ARG=%d#%s", node_rec_cnt, buf);
+	if (node_rec_cnt)
+		sprintf(tmp_buf, "SC=0 ARG=%d#%s", node_rec_cnt, buf);
+	else
+		sprintf(tmp_buf, "SC=0 ARG=0#");
 	xfree(buf);
 	*err_code = 0;
 	*err_msg = tmp_buf;
@@ -121,36 +146,143 @@ extern int	get_nodes(char *cmd_ptr, int *err_code, char **err_msg)
 
 static char *	_dump_all_nodes(int *node_cnt, time_t update_time)
 {
-	int i, cnt = 0;
+	int i, cnt = 0, rc;
 	struct node_record *node_ptr = node_record_table_ptr;
 	char *tmp_buf = NULL, *buf = NULL;
-
+	struct node_record *uniq_node_ptr = NULL;
+	hostlist_t hl = NULL;
+	
 	for (i=0; i<node_record_count; i++, node_ptr++) {
 		if (node_ptr->name == NULL)
 			continue;
-		tmp_buf = _dump_node(node_ptr, update_time);
+		if (use_host_exp == 2) {
+			rc = _same_info(uniq_node_ptr, node_ptr, update_time);
+			if (rc == 0) {
+				uniq_node_ptr = node_ptr;
+				if (hl) {
+					hostlist_push(hl, node_ptr->name);
+				} else {
+					hl = hostlist_create(node_ptr->name);
+					if (hl == NULL)
+						fatal("malloc failure");
+				}
+				continue;
+			} else {
+				tmp_buf = _dump_node(uniq_node_ptr, hl, 
+						     update_time);
+				hostlist_destroy(hl);
+				hl = hostlist_create(node_ptr->name);
+				if (hl == NULL)
+					fatal("malloc failure");
+				uniq_node_ptr = node_ptr;
+			}
+		} else {
+			tmp_buf = _dump_node(node_ptr, hl, update_time);
+		}
 		if (cnt > 0)
 			xstrcat(buf, "#");
 		xstrcat(buf, tmp_buf);
 		xfree(tmp_buf);
 		cnt++;
 	}
+
+	if (hl) {
+		tmp_buf = _dump_node(uniq_node_ptr, hl, update_time);
+		hostlist_destroy(hl);
+		if (cnt > 0)
+			xstrcat(buf, "#");
+		xstrcat(buf, tmp_buf);
+		xfree(tmp_buf);
+		cnt++;
+	}
+
 	*node_cnt = cnt;
 	return buf;
 }
 
-static char *	_dump_node(struct node_record *node_ptr, time_t update_time)
+/* Determine if node1 and node2 have the same parameters that we report to Moab
+ * RET 0 of node1 is NULL or their parameters are the same
+ *     >0 otherwise
+ */
+static int	_same_info(struct node_record *node1_ptr, 
+			   struct node_record *node2_ptr, time_t update_time)
 {
-	char tmp[512], *buf = NULL;
+	int i;
+
+	if (node1_ptr == NULL)	/* first record, treat as a match */
+		return 0;
+
+	if (node1_ptr->node_state != node2_ptr->node_state)
+		return 1;
+	if (_str_cmp(node1_ptr->reason, node2_ptr->reason))
+		return 2;
+	if (update_time > last_node_update)
+		return 0;
+
+	if (slurmctld_conf.fast_schedule) {
+		/* config from slurm.conf */
+		if (node1_ptr->config_ptr->cpus != node2_ptr->config_ptr->cpus)
+			return 3;
+	} else {
+		/* config as reported by slurmd */
+		if (node1_ptr->cpus != node2_ptr->cpus)
+			return 4;
+	}
+	if (node1_ptr->part_cnt != node2_ptr->part_cnt)
+		return 5;
+	for (i=0; i<node1_ptr->part_cnt; i++) {
+		if (node1_ptr->part_pptr[i] !=  node2_ptr->part_pptr[i])
+			return 6;
+	}
+	if (_str_cmp(node1_ptr->arch, node2_ptr->arch))
+		return 7;
+	if (_str_cmp(node1_ptr->os, node2_ptr->os))
+		return 8;
+	if (update_time > 0)
+		return 0;
+
+	if (slurmctld_conf.fast_schedule) {
+		/* config from slurm.conf */
+		if ((node1_ptr->config_ptr->real_memory != 
+		     node2_ptr->config_ptr->real_memory) ||
+		    (node1_ptr->config_ptr->tmp_disk != 
+		     node2_ptr->config_ptr->tmp_disk) ||
+		    (node1_ptr->config_ptr->cpus != 
+		     node2_ptr->config_ptr->cpus))
+			return 9;
+	} else {
+		if ((node1_ptr->real_memory != node2_ptr->real_memory) ||
+		    (node1_ptr->tmp_disk    != node2_ptr->tmp_disk) ||
+		    (node1_ptr->cpus        != node2_ptr->cpus))
+			return 10;
+	}
+	if (_str_cmp(node1_ptr->config_ptr->feature, 
+		     node2_ptr->config_ptr->feature))
+		return 11;
+	return 0;
+}
+
+static char *	_dump_node(struct node_record *node_ptr, hostlist_t hl, 
+			   time_t update_time)
+{
+	char tmp[16*1024], *buf = NULL;
 	int i;
 	uint32_t cpu_cnt;
 
 	if (!node_ptr)
 		return NULL;
 
-	snprintf(tmp, sizeof(tmp), "%s:STATE=%s;",
-		node_ptr->name, 
-		_get_node_state(node_ptr));
+	if (hl) {
+		hostlist_sort(hl);
+		hostlist_uniq(hl);
+		hostlist_ranged_string(hl, sizeof(tmp), tmp);
+		 xstrcat(buf, tmp);
+	} else {
+		snprintf(tmp, sizeof(tmp), "%s", node_ptr->name);
+		xstrcat(buf, tmp);
+	}
+
+	snprintf(tmp, sizeof(tmp), ":STATE=%s;", _get_node_state(node_ptr));
 	xstrcat(buf, tmp);
 	if (node_ptr->reason) {
 		snprintf(tmp, sizeof(tmp), "CAT=\"%s\";", node_ptr->reason);
@@ -178,6 +310,28 @@ static char *	_dump_node(struct node_record *node_ptr, time_t update_time)
 	if (i > 0)
 		xstrcat(buf, ";");
 
+	if (node_ptr->arch) {
+		snprintf(tmp, sizeof(tmp), "ARCH=%s;", node_ptr->arch);
+		xstrcat(buf, tmp);
+	}
+
+	if (node_ptr->os) {
+		snprintf(tmp, sizeof(tmp), "OS=%s;", node_ptr->os);
+		xstrcat(buf, tmp);
+	}
+
+	if (node_ptr->config_ptr
+	&&  node_ptr->config_ptr->feature) {
+		snprintf(tmp, sizeof(tmp), "FEATURE=%s;",
+			node_ptr->config_ptr->feature);
+		/* comma separator to colon */
+		for (i=0; (tmp[i] != '\0'); i++) {
+			if (tmp[i] == ',')
+				tmp[i] = ':';
+		}
+		xstrcat(buf, tmp);
+	}
+
 	if (update_time > 0)
 		return buf;
 
@@ -198,18 +352,6 @@ static char *	_dump_node(struct node_record *node_ptr, time_t update_time)
 	}
 	xstrcat(buf, tmp);
 
-	if (node_ptr->config_ptr
-	&&  node_ptr->config_ptr->feature) {
-		snprintf(tmp, sizeof(tmp), "FEATURE=%s;",
-			node_ptr->config_ptr->feature);
-		/* comma separator to colon */
-		for (i=0; (tmp[i] != '\0'); i++) {
-			if (tmp[i] == ',')
-				tmp[i] = ':';
-		}
-		xstrcat(buf, tmp);
-	}
-
 	return buf;
 }
 
@@ -218,7 +360,8 @@ static char *	_get_node_state(struct node_record *node_ptr)
 	uint16_t state = node_ptr->node_state;
 	uint16_t base_state = state & NODE_STATE_BASE;
 
-	if (state & NODE_STATE_DRAIN)
+	if ((state & NODE_STATE_DRAIN)
+	||  (state & NODE_STATE_FAIL))
 		return "Draining";
 	if (state & NODE_STATE_COMPLETING)
 		return "Busy";
@@ -232,3 +375,16 @@ static char *	_get_node_state(struct node_record *node_ptr)
 	
 	return "Unknown";
 }
+
+/* Like strcmp(), but can handle NULL pointers */
+static int	_str_cmp(char *s1, char *s2)
+{
+	if (s1 && s2)
+		return strcmp(s1, s2);
+
+	if ((s1 == NULL) && (s2 == NULL))
+		return 0;
+
+	/* One pointer is valid and the other is NULL */
+	return 1;
+}
diff --git a/src/plugins/sched/wiki2/hostlist.c b/src/plugins/sched/wiki2/hostlist.c
index 7a96bd30cc5956bd22ab0b1c1826373e33ec285a..c9f83f4a249376b423c1a01e188f44e86797841c 100644
--- a/src/plugins/sched/wiki2/hostlist.c
+++ b/src/plugins/sched/wiki2/hostlist.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -74,7 +74,8 @@ static char * _task_list_exp(struct job_record *job_ptr);
  */
 extern char * moab2slurm_task_list(char *moab_tasklist, int *task_cnt)
 {
-	char *slurm_tasklist, *host, *tmp1, *tmp2, *tok, *tok_p;
+	char *slurm_tasklist = NULL, *host = NULL, *tmp1 = NULL,
+		*tmp2 = NULL, *tok = NULL, *tok_p = NULL;
 	int i, reps;
 	hostlist_t hl;
 	static uint32_t cr_test = 0, cr_enabled = 0;
diff --git a/src/plugins/sched/wiki2/initialize.c b/src/plugins/sched/wiki2/initialize.c
index 9d143c1c92911a36e7831664893a4a682c620316..f94576ab1f1f7f72591675fcc5a6934ffb2ac49a 100644
--- a/src/plugins/sched/wiki2/initialize.c
+++ b/src/plugins/sched/wiki2/initialize.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -40,7 +40,16 @@
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 
-/* RET 0 on success, -1 on failure */
+/*
+ * initialize_wiki - used by Moab to communication desired format information
+ * cmd_ptr IN   - CMD=INITIALIZE EPORT=<port> USEHOSTEXP=[N|T|F]
+ *                USEHOSTEXP=N : use hostlist expression for GETNODES messages
+ *                USEHOSTEXP=T : use hostlist expression for GETJOBS messages
+ *                USEHOSTEXP=F : use no hostlist expressions
+ * err_code OUT - 0 or an error code
+ * err_msg OUT  - response message
+ * RET 0 on success, -1 on failure
+ */
 extern int	initialize_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 {
 	char *arg_ptr, *eport_ptr, *exp_ptr, *use_ptr;
@@ -65,6 +74,8 @@ extern int	initialize_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 			use_host_exp = 1;
 		else if (exp_ptr[0] == 'F')
 			use_host_exp = 0;
+		else if (exp_ptr[0] == 'N')
+			use_host_exp = 2;
 		else {
 			*err_code = -300;
 			*err_msg = "INITIALIZE has invalid USEHOSTEXP";
@@ -73,7 +84,9 @@ extern int	initialize_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 		}
 	}
 
-	if (use_host_exp)
+	if      (use_host_exp == 2)
+		use_ptr = "N";
+	else if (use_host_exp == 1)
 		use_ptr = "T";
 	else
 		use_ptr = "F";
diff --git a/src/plugins/sched/wiki2/job_add_task.c b/src/plugins/sched/wiki2/job_add_task.c
index c639f1ed4a0f310b70619ce7769182115acb13d2..97d6604ac4a54f0ec5ef4c8728a2e4989188717a 100644
--- a/src/plugins/sched/wiki2/job_add_task.c
+++ b/src/plugins/sched/wiki2/job_add_task.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/job_modify.c b/src/plugins/sched/wiki2/job_modify.c
index f726304fab48edce864bd2ff09e5ac713f665bb4..9e5f7aec1787c71bb4dfdbacf56eadbd0d4e2b47 100644
--- a/src/plugins/sched/wiki2/job_modify.c
+++ b/src/plugins/sched/wiki2/job_modify.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -37,6 +37,7 @@
 
 #include "./msg.h"
 #include <strings.h>
+#include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 
@@ -54,27 +55,11 @@ extern void	null_term(char *str)
 	}
 }
 
-/* return -1 on error */
-static int32_t _get_depend_id(char *str)
-{
-	/* stand-alone job_id */
-	if (isdigit(str[0]))
-		return (int32_t) atol(str);
-
-	if (strncasecmp(str, "afterany:", 9) != 0)	/* invalid spec */
-		return (int32_t) -1;
-
-	str += 9;
-	if (!isdigit(str[0]))
-		return (int32_t) -1;
-	return (int32_t) atol(str);
-}
-
 static int	_job_modify(uint32_t jobid, char *bank_ptr, 
-			int32_t depend_id, char *new_hostlist,
+			char *depend_ptr, char *new_hostlist,
 			uint32_t new_node_cnt, char *part_name_ptr, 
 			uint32_t new_time_limit, char *name_ptr,
-			char *start_ptr)
+			char *start_ptr, char *feature_ptr)
 {
 	struct job_record *job_ptr;
 	time_t now = time(NULL);
@@ -89,9 +74,16 @@ static int	_job_modify(uint32_t jobid, char *bank_ptr,
 		return ESLURM_DISABLED;
 	}
 
-	if (depend_id != -1) {
-		info("wiki: changing job dependency to %d", depend_id);
-		job_ptr->dependency = depend_id;
+	if (depend_ptr) {
+		int rc = update_job_dependency(job_ptr, depend_ptr);
+		if (rc == SLURM_SUCCESS) {
+			info("wiki: changed job %u dependency to %s", 
+				jobid, depend_ptr);
+		} else {
+			error("wiki: changing job %u dependency to %s", 
+				jobid, depend_ptr);
+			return EINVAL;
+		}
 	}
 
 	if (new_time_limit) {
@@ -114,6 +106,20 @@ static int	_job_modify(uint32_t jobid, char *bank_ptr,
 		last_job_update = now;
 	}
 
+	if (feature_ptr) {
+		if ((job_ptr->job_state == JOB_PENDING) &&
+		    (job_ptr->details)) {
+			info("wiki: change job %u features to %s", 
+				jobid, feature_ptr);
+			job_ptr->details->features = xstrdup(feature_ptr);
+			last_job_update = now;
+		} else {
+			error("wiki: MODIFYJOB features of non-pending "
+				"job %u", jobid);
+			return ESLURM_DISABLED;
+		}
+	}
+
 	if (start_ptr) {
 		char *end_ptr;
 		uint32_t begin_time = strtol(start_ptr, &end_ptr, 10);
@@ -122,6 +128,7 @@ static int	_job_modify(uint32_t jobid, char *bank_ptr,
 			info("wiki: change job %u begin time to %u", 
 				jobid, begin_time);
 			job_ptr->details->begin_time = begin_time;
+			last_job_update = now;
 		} else {
 			error("wiki: MODIFYJOB begin_time of non-pending "
 				"job %u", jobid);
@@ -131,7 +138,8 @@ static int	_job_modify(uint32_t jobid, char *bank_ptr,
 
 	if (name_ptr) {
 		info("wiki: change job %u name %s", jobid, name_ptr);
-		strncpy(job_ptr->name, name_ptr, sizeof(job_ptr->name));
+		xfree(job_ptr->name);
+		job_ptr->name = xstrdup(name_ptr);
 		last_job_update = now;
 	}
 
@@ -201,7 +209,8 @@ host_fini:	if (rc) {
 		}
 		info("wiki: change job %u partition %s",
 			jobid, part_name_ptr);
-		strncpy(job_ptr->partition, part_name_ptr, MAX_SLURM_NAME);
+		xfree(job_ptr->partition);
+		job_ptr->partition = xstrdup(part_name_ptr);
 		job_ptr->part_ptr = part_ptr;
 		last_job_update = now;
 	}
@@ -228,14 +237,14 @@ host_fini:	if (rc) {
 /* Modify a job:
  *	CMD=MODIFYJOB ARG=<jobid> PARTITION=<name> NODES=<number>
  *		DEPEND=afterany:<jobid> TIMELIMT=<seconds> BANK=<name>
- *		MINSTARTTIME=<uts>
+ *		MINSTARTTIME=<uts> RFEATURES=<features>
  * RET 0 on success, -1 on failure */
 extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 {
 	char *arg_ptr, *bank_ptr, *depend_ptr, *nodes_ptr, *start_ptr;
 	char *host_ptr, *name_ptr, *part_ptr, *time_ptr, *tmp_char;
+	char *feature_ptr;
 	int i, slurm_rc;
-	int depend_id = -1;
 	uint32_t jobid, new_node_cnt = 0, new_time_limit = 0;
 	static char reply_msg[128];
 	/* Locks: write job, read node and partition info */
@@ -260,14 +269,15 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 		error("wiki: MODIFYJOB has invalid jobid");
 		return -1;
 	}
-	bank_ptr   = strstr(cmd_ptr, "BANK=");
-	depend_ptr = strstr(cmd_ptr, "DEPEND=");
-	name_ptr   = strstr(cmd_ptr, "JOBNAME=");
-	host_ptr   = strstr(cmd_ptr, "HOSTLIST=");
-	start_ptr  = strstr(cmd_ptr, "MINSTARTTIME=");
-	nodes_ptr  = strstr(cmd_ptr, "NODES=");
-	part_ptr   = strstr(cmd_ptr, "PARTITION=");
-	time_ptr   = strstr(cmd_ptr, "TIMELIMIT=");
+	bank_ptr    = strstr(cmd_ptr, "BANK=");
+	depend_ptr  = strstr(cmd_ptr, "DEPEND=");
+	host_ptr    = strstr(cmd_ptr, "HOSTLIST=");
+	name_ptr    = strstr(cmd_ptr, "JOBNAME=");
+	start_ptr   = strstr(cmd_ptr, "MINSTARTTIME=");
+	nodes_ptr   = strstr(cmd_ptr, "NODES=");
+	part_ptr    = strstr(cmd_ptr, "PARTITION=");
+	feature_ptr = strstr(cmd_ptr, "RFEATURES=");
+	time_ptr    = strstr(cmd_ptr, "TIMELIMIT=");
 	if (bank_ptr) {
 		bank_ptr[4] = ':';
 		bank_ptr += 5;
@@ -276,14 +286,12 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 	if (depend_ptr) {
 		depend_ptr[6] = ':';
 		depend_ptr += 7;
-		depend_id = _get_depend_id(depend_ptr);
-		if (depend_id == -1) {
-			*err_code = -300;
-			*err_msg = "MODIFYJOB has invalid DEPEND specificiation";
-			error("wiki: MODIFYJOB has invalid DEPEND spec: %s",
-				depend_ptr);
-			return -1;
-		}
+		null_term(depend_ptr);
+	}
+	if (feature_ptr) {
+		feature_ptr[9] = ':';
+		feature_ptr += 10;
+		null_term(feature_ptr);
 	}
 	if (host_ptr) {
 		host_ptr[8] = ':';
@@ -295,7 +303,7 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 		name_ptr += 8;
 		if (name_ptr[0] == '\"') {
 			name_ptr++;
-			for (i=0; i<MAX_JOBNAME_LEN; i++) {
+			for (i=0; ; i++) {
 				if (name_ptr[i] == '\0')
 					break;
 				if (name_ptr[i] == '\"') {
@@ -303,11 +311,9 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 					break;
 				}
 			}
-			if (i == MAX_JOBNAME_LEN)
-				name_ptr[i-1] = '\0';
 		} else if (name_ptr[0] == '\'') {
 			name_ptr++;
-			for (i=0; i<MAX_JOBNAME_LEN; i++) {
+			for (i=0; ; i++) {
 				if (name_ptr[i] == '\0')
 					break;
 				if (name_ptr[i] == '\'') {
@@ -315,8 +321,6 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 					break;
 				}
 			}
-			if (i == MAX_JOBNAME_LEN)
-				name_ptr[i-1] = '\0';
 		} else
 			null_term(name_ptr);
 	}
@@ -351,9 +355,9 @@ extern int	job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg)
 	}
 
 	lock_slurmctld(job_write_lock);
-	slurm_rc = _job_modify(jobid, bank_ptr, depend_id, host_ptr,
+	slurm_rc = _job_modify(jobid, bank_ptr, depend_ptr, host_ptr,
 			new_node_cnt, part_ptr, new_time_limit, name_ptr,
-			start_ptr);
+			start_ptr, feature_ptr);
 	unlock_slurmctld(job_write_lock);
 	if (slurm_rc != SLURM_SUCCESS) {
 		*err_code = -700;
diff --git a/src/plugins/sched/wiki2/job_notify.c b/src/plugins/sched/wiki2/job_notify.c
index ac7ed5217faf57e78248676b8440e6e881eeb713..ddb3a65dd3bbd2eae6aa4f9b02a838d6611a6082 100644
--- a/src/plugins/sched/wiki2/job_notify.c
+++ b/src/plugins/sched/wiki2/job_notify.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/job_release_task.c b/src/plugins/sched/wiki2/job_release_task.c
index 896a7504df68afd4b4e7651a8455556f0f1f1875..1a02f40e122eb2a40243f026dd8724b27a8f315f 100644
--- a/src/plugins/sched/wiki2/job_release_task.c
+++ b/src/plugins/sched/wiki2/job_release_task.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/job_requeue.c b/src/plugins/sched/wiki2/job_requeue.c
index ce0bd142a7a08deaf04b42a85c4ae7a8fd7ec323..444b810ee8d8bb62ca9747364ed861fad0b8afd1 100644
--- a/src/plugins/sched/wiki2/job_requeue.c
+++ b/src/plugins/sched/wiki2/job_requeue.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/job_signal.c b/src/plugins/sched/wiki2/job_signal.c
index 02f1e99c6878519488d584101ddde351efe453ad..d1a24fa068f4d5eed9b13d65127ca1717ec3036a 100644
--- a/src/plugins/sched/wiki2/job_signal.c
+++ b/src/plugins/sched/wiki2/job_signal.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/job_will_run.c b/src/plugins/sched/wiki2/job_will_run.c
index 637a112b09dec2ee9e6a4c94a0d41a187225924b..3ecca4dfd0677249731a973414edea4bddec3c65 100644
--- a/src/plugins/sched/wiki2/job_will_run.c
+++ b/src/plugins/sched/wiki2/job_will_run.c
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  job_will_run.c - Process Wiki job will_run test
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
+ *  Copyright (C) 2006-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -36,22 +37,45 @@
 \*****************************************************************************/
 
 #include "./msg.h"
+#include "src/common/node_select.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 #include "src/slurmctld/node_scheduler.h"
 #include "src/slurmctld/state_save.h"
 
-static char *	_copy_nodelist_no_dup(char *node_list);
-static int	_will_run_test(uint32_t jobid, char *hostlist, 
-			int *err_code, char **err_msg);
+#define MAX_JOB_QUEUE 20
 
-/* RET 0 on success, -1 on failure */
+static void     _select_list_del(void *x);
+static char *	_will_run_test(uint32_t *jobid, time_t *start_time, 
+			       char **node_list, int job_cnt, 
+			       int *err_code, char **err_msg);
+
+/*
+ * job_will_run - Determine if, when and where a priority ordered list of jobs
+ *		  can be initiated with the currently running jobs as a 
+ *		  backgorund
+ * cmd_ptr IN   - CMD=JOBWILLRUN ARG=JOBID=<JOBID>[@<TIME>],<AVAIL_NODES>
+ *		   [JOBID=<JOBID>[@<TIME>],<AVAIL_NODES>]...
+ * err_code OUT - 0 on success or some error code
+ * err_msg OUT  - error message if any of the specified jobs can not be started
+ *		  at the specified time (if given) on the available nodes. 
+ *		  Otherwise information on when and where the pending jobs
+ *		  will be initiated
+ *                ARG=<JOBID>:<PROCS>@<TIME>,<USED_NODES>
+ *		     [<JOBID>:<PROCS>@<TIME>,<USED_NODES>]
+ * NOTE: xfree() err_msg if err_code is zero
+ * RET 0 on success, -1 on failure
+ */
 extern int	job_will_run(char *cmd_ptr, int *err_code, char **err_msg)
 {
-	char *arg_ptr, *task_ptr, *node_ptr, *tmp_char;
-	int i;
-	uint32_t jobid;
-	char host_string[MAXHOSTRANGELEN];
+	char *arg_ptr, *buf, *tmp_buf, *tmp_char;
+	int job_cnt;
+	uint32_t jobid[MAX_JOB_QUEUE];
+	time_t start_time[MAX_JOB_QUEUE];
+	char *avail_nodes[MAX_JOB_QUEUE];
+	/* Locks: write job, read node and partition info */
+	slurmctld_lock_t job_write_lock = {
+		NO_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK };
 
 	arg_ptr = strstr(cmd_ptr, "ARG=");
 	if (arg_ptr == NULL) {
@@ -60,176 +84,279 @@ extern int	job_will_run(char *cmd_ptr, int *err_code, char **err_msg)
 		error("wiki: JOBWILLRUN lacks ARG");
 		return -1;
 	}
-	jobid = strtoul(arg_ptr+4, &tmp_char, 10);
-	if ((tmp_char[0] != '\0') && (!isspace(tmp_char[0]))) {
-		*err_code = -300;
-		*err_msg = "Invalid ARG value";
-		error("wiki: JOBWILLRUN has invalid jobid");
-		return -1;
-	}
+	arg_ptr += 4;
 
-	task_ptr = strstr(cmd_ptr, "TASKLIST=");
-	if (task_ptr) {
-		hostlist_t hl;
-		node_ptr = task_ptr + 9;
-		for (i=0; node_ptr[i]!='\0'; i++) {
-			if (node_ptr[i] == ':')
-				node_ptr[i] = ',';
+	for (job_cnt=0; job_cnt<MAX_JOB_QUEUE; ) {
+		if (strncmp(arg_ptr, "JOBID=", 6)) {
+			*err_code = -300;
+			*err_msg = "Invalid ARG value";
+			error("wiki: JOBWILLRUN has invalid ARG value");
+			return -1;
 		}
-		hl = hostlist_create(node_ptr);
-		i = hostlist_ranged_string(hl, sizeof(host_string), host_string);
-		hostlist_destroy(hl);
-		if (i < 0) {
+		arg_ptr += 6;
+		jobid[job_cnt] = strtoul(arg_ptr, &tmp_char, 10);
+		if (tmp_char[0] == '@')
+			start_time[job_cnt] = strtoul(tmp_char+1, &tmp_char, 10);
+		else
+			start_time[job_cnt] = 0;
+		if (tmp_char[0] != ',') {
 			*err_code = -300;
-			*err_msg = "JOBWILLRUN has invalid TASKLIST";
-			error("wiki: JOBWILLRUN has invalid TASKLIST");
+			*err_msg = "Invalid ARG value";
+			error("wiki: JOBWILLRUN has invalid ARG value");
 			return -1;
 		}
-	} else {
-		/* no restrictions on nodes available for use */
-		strcpy(host_string, "");
+		avail_nodes[job_cnt] = tmp_char + 1;
+		job_cnt++;
+
+		while (tmp_char[0] && (!isspace(tmp_char[0])))
+			tmp_char++;
+		if (tmp_char[0] == '\0')
+			break;
+		tmp_char[0] = '\0';	/* was space */
+		tmp_char++;
+		while (isspace(tmp_char[0]))
+			tmp_char++;
+		if (tmp_char[0] == '\0')
+			break;
+		arg_ptr = tmp_char;
 	}
 
-	if (_will_run_test(jobid, host_string, err_code, err_msg) != 0)
+	lock_slurmctld(job_write_lock);
+	buf = _will_run_test(jobid, start_time, avail_nodes, job_cnt, 
+			     err_code, err_msg);
+	unlock_slurmctld(job_write_lock);
+
+	if (!buf)
 		return -1;
 
+	tmp_buf = xmalloc(strlen(buf) + 32);
+	sprintf(tmp_buf, "SC=0 ARG=%s", buf);
+	xfree(buf);
+	*err_code = 0;
+	*err_msg = tmp_buf;
 	return 0;
 }
 
-static int	_will_run_test(uint32_t jobid, char *hostlist,
-			int *err_code, char **err_msg)
+static void _select_list_del (void *x)
+{
+	select_will_run_t *select_will_run = (select_will_run_t *) x;
+	FREE_NULL_BITMAP(select_will_run->avail_nodes);
+	xfree(select_will_run);
+}
+
+static char *	_will_run_test(uint32_t *jobid, time_t *start_time, 
+			       char **node_list, int job_cnt, 
+			       int *err_code, char **err_msg)
 {
-	int rc = 0, i;
 	struct job_record *job_ptr;
-	/* Write lock on job info, read lock on node info */
-	slurmctld_lock_t job_write_lock = {
-		NO_LOCK, WRITE_LOCK, READ_LOCK, NO_LOCK };
-	char *new_node_list, *picked_node_list = NULL;
-	bitstr_t *new_bitmap, *save_exc_bitmap, *save_req_bitmap;
-	uint32_t save_prio;
-	bitstr_t *picked_node_bitmap = NULL;
-	/* Just create a big static message buffer to avoid dealing with
-	 * xmalloc/xfree. We'll switch to compressed node naming soon
-	 * and this buffer can be set smaller then. */
-	static char reply_msg[16384];
+	struct part_record *part_ptr;
+	bitstr_t *avail_bitmap = NULL;
+	char *hostlist, *reply_msg = NULL;
+	uint32_t min_nodes, max_nodes, req_nodes;
+	int i, rc;
+	select_will_run_t *select_will_run = NULL;
+	List select_list;
+	ListIterator iter;
 
-	lock_slurmctld(job_write_lock);
-	job_ptr = find_job_record(jobid);
-	if (job_ptr == NULL) {
-		*err_code = -700;
-		*err_msg = "No such job";
-		error("wiki: Failed to find job %u", jobid);
-		rc = -1;
-		unlock_slurmctld(job_write_lock);
-		return rc;
-	}
+	select_list = list_create(_select_list_del);
+	if (select_list == NULL)
+		fatal("list_create: malloc failure");
 
-	if ((job_ptr->details == NULL)
-	||  (job_ptr->job_state != JOB_PENDING)) {
-		*err_code = -700;
-		*err_msg = "Job not pending, can't test  will_run";
-		error("wiki: Attempt to test will_run of non-pending job %u",
-			jobid);
-		rc = -1;
-		unlock_slurmctld(job_write_lock);
-		return rc;
-	}
+	for (i=0; i<job_cnt; i++) {
+		debug2("wiki2: will_run job_id=%u start_time=%u node_list=%s",
+			jobid[i], start_time[i], node_list[i]);
+		job_ptr = find_job_record(jobid[i]);
+		if (job_ptr == NULL) {
+			*err_code = -700;
+			*err_msg = "No such job";
+			error("wiki: Failed to find job %u", jobid[i]);
+			break;
+		}
+		if (job_ptr->job_state != JOB_PENDING) {
+			*err_code = -700;
+			*err_msg = "WillRun not applicable to non-pending job";
+			error("wiki: WillRun on non-pending job %u", jobid[i]);
+			break;
+		}
 
-	new_node_list = _copy_nodelist_no_dup(hostlist);
-	if (hostlist && (new_node_list == NULL)) {
-		*err_code = -700;
-		*err_msg = "Invalid TASKLIST";
-		error("wiki: Attempt to set invalid node list for job %u, %s",
-			jobid, hostlist);
-		rc = -1;
-		unlock_slurmctld(job_write_lock);
-		return rc;
-	}
+		part_ptr = job_ptr->part_ptr;
+		if (part_ptr == NULL) {
+			*err_code = -700;
+			*err_msg = "Job lacks a partition";
+			error("wiki: Job %u lacks a partition", jobid[i]);
+			break;
+		}
 
-	if (node_name2bitmap(new_node_list, false, &new_bitmap) != 0) {
-		*err_code = -700;
-		*err_msg = "Invalid TASKLIST";
-		error("wiki: Attempt to set invalid node list for job %u, %s",
-			jobid, hostlist);
-		rc = -1;
-		xfree(new_node_list);
-		unlock_slurmctld(job_write_lock);
-		return rc;
-	}
+		if ((job_ptr->details == NULL) ||
+		    (job_ptr->job_state != JOB_PENDING)) {
+			*err_code = -700;
+			*err_msg = "Job not pending, can't test  will_run";
+			error("wiki: Attempt to test will_run of non-pending "
+			      "job %u", jobid[i]);
+			break;
+		}
 
-	/* Put the inverse of this on the excluded node list, 
-	 * Remove any required nodes, and test */
-	save_exc_bitmap = job_ptr->details->exc_node_bitmap;
-	if (hostlist[0]) {	/* empty hostlist, all nodes usable */
-		bit_not(new_bitmap);
-		job_ptr->details->exc_node_bitmap = new_bitmap;
-	}
-	save_req_bitmap = job_ptr->details->req_node_bitmap;
-	job_ptr->details->req_node_bitmap = bit_alloc(node_record_count);
-	save_prio = job_ptr->priority;
-	job_ptr->priority = 1;
+		if ((node_list[i] == NULL) || (node_list[i][0] == '\0')) {
+			/* assume all nodes available to job for testing */
+			avail_bitmap = bit_copy(avail_node_bitmap);
+		} else if (node_name2bitmap(node_list[i], false, 
+					    &avail_bitmap) != 0) {
+			*err_code = -700;
+			*err_msg = "Invalid available nodes value";
+			error("wiki: Attempt to set invalid available node "
+			      "list for job %u, %s", jobid[i], node_list[i]);
+			break;
+		}
+
+		/* Only consider nodes that are not DOWN or DRAINED */
+		bit_and(avail_bitmap, avail_node_bitmap);
+
+		/* Consider only nodes in this job's partition */
+		if (part_ptr->node_bitmap)
+			bit_and(avail_bitmap, part_ptr->node_bitmap);
+		else {
+			*err_code = -730;
+			*err_msg = "Job's partition has no nodes";
+			error("wiki: no nodes in partition %s for job %u", 
+				part_ptr->name, jobid[i]);
+			break;
+		}
 
-	rc = select_nodes(job_ptr, true, &picked_node_bitmap);
-	if (picked_node_bitmap) {
-		picked_node_list = bitmap2wiki_node_name(picked_node_bitmap);
-		i = strlen(picked_node_list);
-		if ((i + 64) > sizeof(reply_msg))
-			error("wiki: will_run buffer overflow");
+		if (job_req_node_filter(job_ptr, avail_bitmap) != 
+		    SLURM_SUCCESS) {
+			/* Job probably has invalid feature list */
+			*err_code = -730;
+			*err_msg = "Job's required features not available "
+				   "on selected nodes";
+			error("wiki: job %u not runnable on hosts=%s", 
+				jobid[i], node_list[i]);
+			break;
+		}
+		if (job_ptr->details->exc_node_bitmap) {
+			bit_not(job_ptr->details->exc_node_bitmap);
+			bit_and(avail_bitmap, job_ptr->details->exc_node_bitmap);
+			bit_not(job_ptr->details->exc_node_bitmap);
+		}
+		if ((job_ptr->details->req_node_bitmap) &&
+		    (!bit_super_set(job_ptr->details->req_node_bitmap, 
+				    avail_bitmap))) {
+			*err_code = -730;
+			*err_msg = "Job's required nodes not available";
+			error("wiki: job %u not runnable on hosts=%s", 
+				jobid[i], node_list[i]);
+			break;
+		}
+
+		min_nodes = MAX(job_ptr->details->min_nodes, 
+				part_ptr->min_nodes);
+		if (job_ptr->details->max_nodes == 0)
+			max_nodes = part_ptr->max_nodes;
+		else
+			max_nodes = MIN(job_ptr->details->max_nodes, 
+					part_ptr->max_nodes);
+		max_nodes = MIN(max_nodes, 500000); /* prevent overflows */
+		if (job_ptr->details->max_nodes)
+			req_nodes = max_nodes;
+		else
+			req_nodes = min_nodes;
+		if (min_nodes > max_nodes) {
+			/* job's min_nodes exceeds partitions max_nodes */
+			*err_code = -730;
+			*err_msg = "Job's min_nodes > max_nodes";
+			error("wiki: job %u not runnable on hosts=%s", 
+				jobid[i], node_list[i]);
+			break;
+		}
+		select_will_run = xmalloc(sizeof(select_will_run_t));
+		select_will_run->avail_nodes = avail_bitmap;
+		avail_bitmap = NULL;
+		select_will_run->job_ptr     = job_ptr;
+		job_ptr->start_time          = start_time[i];
+		select_will_run->max_nodes   = max_nodes;
+		select_will_run->min_nodes   = min_nodes;
+		select_will_run->req_nodes   = req_nodes;
+		list_push(select_list, select_will_run); 
+	}
+	FREE_NULL_BITMAP(avail_bitmap);
+	if (i < job_cnt) {	/* error logged above */
+		/* Restore pending job start time */
+		iter = list_iterator_create(select_list);
+		if (iter == NULL)
+			fatal("list_iterator_create: malloc failure");
+		while ((select_will_run = list_next(iter)))
+			select_will_run->job_ptr->start_time = 0;
+		list_iterator_destroy(iter);
+		list_destroy(select_list);
+		return NULL;
 	}
 
-	if (rc == SLURM_SUCCESS) {
-		*err_code = 0;
-		snprintf(reply_msg, sizeof(reply_msg),
-			"SC=0 Job %d runnable now TASKLIST:%s",
-			jobid, picked_node_list);
-		*err_msg = reply_msg;
-	} else if (rc == ESLURM_NODES_BUSY) {
-		*err_code = 1;
-		snprintf(reply_msg, sizeof(reply_msg),
-			"SC=1 Job %d runnable later TASKLIST:%s",
-			jobid, picked_node_list);
-		*err_msg = reply_msg;
+	if (job_cnt == 1) {
+		rc = select_g_job_test(
+				select_will_run->job_ptr, 
+				select_will_run->avail_nodes,
+				select_will_run->min_nodes, 
+				select_will_run->max_nodes, 
+				select_will_run->req_nodes, 
+				SELECT_MODE_WILL_RUN);
 	} else {
-		char *err_str = slurm_strerror(rc);
-		error("wiki: job %d never runnable on hosts=%s %s", 
-			jobid, new_node_list, err_str);
-		*err_code = -740;
-		snprintf(reply_msg, sizeof(reply_msg), 
-			"SC=-740 Job %d not runable: %s", 
-			jobid, err_str);
-		*err_msg = reply_msg;
+		rc = select_g_job_list_test(select_list);
 	}
 
-	/* Restore job's state, release memory */
-	xfree(picked_node_list);
-	FREE_NULL_BITMAP(picked_node_bitmap);
-	xfree(new_node_list);
-	bit_free(new_bitmap);
-	FREE_NULL_BITMAP(job_ptr->details->req_node_bitmap);
-	job_ptr->details->exc_node_bitmap = save_exc_bitmap;
-	job_ptr->details->req_node_bitmap = save_req_bitmap;
-	job_ptr->priority = save_prio;
-	unlock_slurmctld(job_write_lock);
- 	return rc;
-}
-
-static char *	_copy_nodelist_no_dup(char *node_list)
-{
-	int   new_size = 128;
-	char *new_str;
-	hostlist_t hl = hostlist_create(node_list);
+	if (rc == SLURM_SUCCESS) {
+		char tmp_str[128];
+		*err_code = 0;
+		uint32_t proc_cnt = 0;
 
-	if (hl == NULL)
-		return NULL;
+		iter = list_iterator_create(select_list);
+		if (iter == NULL)
+			fatal("list_iterator_create: malloc failure");
+		for (i=0; i<job_cnt; i++) {
+			select_will_run = list_next(iter);
+			if (select_will_run == NULL) {
+				error("wiki2: select_list size is bad");
+				break;
+			}
+			if (i)
+				xstrcat(reply_msg, " ");
+			else
+				xstrcat(reply_msg, "STARTINFO=");
+#ifdef HAVE_BG
+			select_g_get_jobinfo(select_will_run->job_ptr->
+					     select_jobinfo,
+                             		     SELECT_DATA_NODE_CNT, 
+					     &proc_cnt);
 
-	hostlist_uniq(hl);
-	new_str = xmalloc(new_size);
-	while (hostlist_ranged_string(hl, new_size, new_str) == -1) {
-		new_size *= 2;
-		xrealloc(new_str, new_size);
+#else
+			proc_cnt = select_will_run->job_ptr->total_procs;
+#endif
+			snprintf(tmp_str, sizeof(tmp_str), "%u:%u@%u,",
+				 select_will_run->job_ptr->job_id,
+				 proc_cnt,
+				 (uint32_t) select_will_run->
+					    job_ptr->start_time);
+			/* Restore pending job start time */
+			select_will_run->job_ptr->start_time = 0;
+			xstrcat(reply_msg, tmp_str);
+			hostlist = bitmap2node_name(select_will_run->
+						    avail_nodes);
+			xstrcat(reply_msg, hostlist);
+			xfree(hostlist);
+		}
+		list_iterator_destroy(iter);
+	} else {
+		/* Restore pending job start times */
+		iter = list_iterator_create(select_list);
+		if (iter == NULL)
+			fatal("list_iterator_create: malloc failure");
+		while ((select_will_run = list_next(iter)))
+			select_will_run->job_ptr->start_time = 0;
+		list_iterator_destroy(iter);
+		xstrcat(reply_msg, "Jobs not runable on selected nodes");
+		error("wiki: jobs not runnable on nodes");
 	}
-	hostlist_destroy(hl);
-	return new_str;
+
+	list_destroy(select_list);
+	return reply_msg;
 }
 
 /*
@@ -240,7 +367,7 @@ static char *	_copy_nodelist_no_dup(char *node_list)
  * IN bitmap - bitmap pointer
  * RET pointer to node list or NULL on error 
  * globals: node_record_table_ptr - pointer to node table
- * NOTE: the caller must xfree the memory at node_list when no longer required
+ * NOTE: the caller must xfree the returned pointer when no longer required
  */
 extern char *	bitmap2wiki_node_name(bitstr_t *bitmap)
 {
diff --git a/src/plugins/sched/wiki2/msg.c b/src/plugins/sched/wiki2/msg.c
index ab710c9768ab9eadcaeebce707502578783a49dd..50790b3c90929ecbb8a1d7c7efd970fd12662e8d 100644
--- a/src/plugins/sched/wiki2/msg.c
+++ b/src/plugins/sched/wiki2/msg.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -38,6 +38,7 @@
 #include "./crypto.h"
 #include "./msg.h"
 #include "src/common/uid.h"
+#include "src/slurmctld/locks.h"
 #include <sys/poll.h>
 
 #define _DEBUG 0
@@ -142,12 +143,20 @@ static void *_msg_thread(void *no_data)
 	slurm_fd sock_fd = -1, new_fd;
 	slurm_addr cli_addr;
 	char *msg;
-	slurm_ctl_conf_t *conf = slurm_conf_lock();
+	slurm_ctl_conf_t *conf;
 	int i;
+	/* Locks: Write configuration, job, node, and partition */
+	slurmctld_lock_t config_write_lock = {
+		WRITE_LOCK, WRITE_LOCK, WRITE_LOCK, WRITE_LOCK };
 
+	conf = slurm_conf_lock();
 	sched_port = conf->schedport;
 	slurm_conf_unlock();
 
+	/* Wait until configuration is completely loaded */
+	lock_slurmctld(config_write_lock);
+	unlock_slurmctld(config_write_lock);
+
 	/* If SchedulerPort is already taken, keep trying to open it
 	 * once per minute. Slurmctld will continue to function
 	 * during this interval even if nothing can be scheduled. */
@@ -181,8 +190,10 @@ static void *_msg_thread(void *no_data)
 		err_code = 0;
 		err_msg = "";
 		msg = _recv_msg(new_fd);
-		_proc_msg(new_fd, msg);
-		xfree(msg);
+		if (msg) {
+			_proc_msg(new_fd, msg);
+			xfree(msg);
+		}
 		slurm_close_accepted_conn(new_fd);
 	}
 	verbose("wiki: message engine shutdown");
@@ -206,7 +217,7 @@ static char * _get_wiki_conf_path(void)
 		val = default_slurm_config_file;
 
 	/* Replace file name on end of path */
-	i = strlen(val) + 1;
+	i = strlen(val) + 10;
 	path = xmalloc(i);
 	strcpy(path, val);
 	val = strrchr(path, (int)'/');
@@ -351,11 +362,61 @@ extern int parse_wiki_config(void)
 	info("HostFormat         = %u", use_host_exp);
 	info("JobAggregationTime = %u sec", job_aggregation_time);
 	info("JobPriority        = %s", init_prio_mode ? "run" : "hold");
-	info("KillWait           = %u sec", kill_wait);      
+	info("KillWait           = %u sec", kill_wait);
+	for (i=0; i<EXC_PART_CNT; i++) {
+		if (!exclude_part_ptr[i])
+			continue;
+		info("ExcludePartitions  = %s", exclude_part_ptr[i]->name);
+	}
+	for (i=0; i<HIDE_PART_CNT; i++) {
+		if (!hide_part_ptr[i])
+			continue;
+		info("HidePartitionJobs  = %s", hide_ptr_ptr[i]->name);
+	}
 #endif
 	return SLURM_SUCCESS;
 }
 
+/*
+ * Return a string containing any scheduling plugin configuration information 
+ * that we want to expose via "scontrol show configuration".
+ * NOTE: the caller must xfree the returned pointer
+ */
+extern char *	get_wiki_conf(void)
+{
+	int i, first;
+	char buf[20], *conf = NULL;
+
+	snprintf(buf, sizeof(buf), "HostFormat=%u", use_host_exp);
+	xstrcat(conf, buf);
+
+	first = 1;
+	for (i=0; i<EXC_PART_CNT; i++) {
+		if (!exclude_part_ptr[i])
+			continue;
+		if (first) {
+			xstrcat(conf, ";ExcludePartitions=");
+			first = 0;
+		} else
+			xstrcat(conf, ",");
+		xstrcat(conf, exclude_part_ptr[i]->name);
+	}
+
+	first = 1;
+	for (i=0; i<HIDE_PART_CNT; i++) {
+		if (!hide_part_ptr[i])
+			continue;
+		if (first) {
+			xstrcat(conf, ";HidePartitionJobs=");
+			first = 0;
+		} else
+			xstrcat(conf, ",");
+		xstrcat(conf, hide_part_ptr[i]->name);
+	}
+
+	return conf;
+}
+
 static size_t	_read_bytes(int fd, char *buf, size_t size)
 {
 	size_t bytes_remaining, bytes_read;
@@ -620,7 +681,8 @@ static void	_proc_msg(slurm_fd new_fd, char *msg)
 		job_release_task(cmd_ptr, &err_code, &err_msg);
 	} else if (strncmp(cmd_ptr, "JOBWILLRUN", 10) == 0) {
 		msg_type = "wiki:JOBWILLRUN";
-		job_will_run(cmd_ptr, &err_code, &err_msg);
+		if (!job_will_run(cmd_ptr, &err_code, &err_msg))
+			goto free_resp_msg;
 	} else if (strncmp(cmd_ptr, "MODIFYJOB", 9) == 0) {
 		msg_type = "wiki:MODIFYJOB";
 		job_modify_wiki(cmd_ptr, &err_code, &err_msg);
diff --git a/src/plugins/sched/wiki2/msg.h b/src/plugins/sched/wiki2/msg.h
index 53cbb8c9ff18bebae1f1add54b6dfff693f2bd26..6b58dcf2307133c1be3bbf1d9608338772556e5b 100644
--- a/src/plugins/sched/wiki2/msg.h
+++ b/src/plugins/sched/wiki2/msg.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -101,18 +101,55 @@ extern uint16_t	job_aggregation_time;
 extern uint16_t kill_wait;
 extern uint16_t use_host_exp;
 
+/*
+ * bitmap2wiki_node_name  - given a bitmap, build a list of colon separated 
+ *	node names (if we can't use node range expressions), or the 
+ *	normal slurm node name expression
+ *
+ * IN bitmap - bitmap pointer
+ * RET pointer to node list or NULL on error 
+ * globals: node_record_table_ptr - pointer to node table
+ * NOTE: the caller must xfree the returned pointer when no longer required
+ */
+extern char *   bitmap2wiki_node_name(bitstr_t *bitmap);
+
+/*
+ * event_notify - Notify Moab of some event
+ * event_code IN - message code to send Moab
+ *          1234 - job state change
+ *          1235  - partition state change
+ * desc IN - event description
+ * RET 0 on success, -1 on failure
+ */
 extern int	event_notify(int event_code, char *desc);
-extern int	spawn_msg_thread(void);
+
+/*
+ * Spawn message hander thread
+ */
+extern int spawn_msg_thread(void);
+
+/*
+ * Terminate message hander thread
+ */
 extern void	term_msg_thread(void);
-extern char *   bitmap2wiki_node_name(bitstr_t *bitmap);
+
+/*
+ * Return a string containing any scheduling plugin configuration information 
+ * that we want to expose via "scontrol show configuration".
+ * NOTE: the caller must xfree the returned pointer
+ */
+extern char *	get_wiki_conf(void);
 
 /*
  * Given a string, replace the first space found with '\0'
  */
 extern void	null_term(char *str);
 
-/* Functions called from within msg.c (rather than creating a bunch 
- * more header files with one function definition each */
+
+/*
+ * Functions called from within msg.c (rather than creating a bunch 
+ * more header files with one function definition each)
+ */
 extern int	cancel_job(char *cmd_ptr, int *err_code, char **err_msg);
 extern int	get_jobs(char *cmd_ptr, int *err_code, char **err_msg);
 extern int 	get_nodes(char *cmd_ptr, int *err_code, char **err_msg);
@@ -130,3 +167,4 @@ extern char *	slurm_job2moab_task_list(struct job_record *job_ptr);
 extern int	start_job(char *cmd_ptr, int *err_code, char **err_msg);
 extern int	suspend_job(char *cmd_ptr, int *err_code, char **err_msg);
 extern int	resume_job(char *cmd_ptr, int *err_code, char **err_msg);
+extern void     wiki_job_requeue(struct job_record *job_ptr, char *reason);
diff --git a/src/plugins/sched/wiki2/resume_job.c b/src/plugins/sched/wiki2/resume_job.c
index 319219244b55f6128c64c10797901e298a3b2f0a..b172e04d25cc5f8aefc2fe9a42b67a0b0c6d22eb 100644
--- a/src/plugins/sched/wiki2/resume_job.c
+++ b/src/plugins/sched/wiki2/resume_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/sched/wiki2/sched_wiki.c b/src/plugins/sched/wiki2/sched_wiki.c
index fd7710640424a0eba2da18a74794398f492886e7..db4168acf23d4ee072134e45de54a5f1809db980 100644
--- a/src/plugins/sched/wiki2/sched_wiki.c
+++ b/src/plugins/sched/wiki2/sched_wiki.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -75,6 +75,22 @@ extern int slurm_sched_plugin_schedule( void )
 	return SLURM_SUCCESS;
 }
 
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_newalloc                   ) */
+/***************************************************************************/
+extern int slurm_sched_plugin_newalloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
+/***************************************************************************/
+/*  TAG(                   slurm_sched_plugin_freealloc                  ) */
+/***************************************************************************/
+extern int slurm_sched_plugin_freealloc( struct job_record *job_ptr )
+{
+	return SLURM_SUCCESS;
+}
+
 
 /**************************************************************************/
 /* TAG(                   slurm_sched_plugin_initial_priority           ) */ 
@@ -151,3 +167,18 @@ char *slurm_sched_strerror( int errnum )
 	return NULL;
 }
 
+/**************************************************************************/
+/* TAG(              slurm_sched_plugin_requeue                         ) */
+/**************************************************************************/
+void slurm_sched_plugin_requeue( struct job_record *job_ptr, char *reason )
+{
+        wiki_job_requeue(job_ptr, reason);
+}
+
+/**************************************************************************/
+/* TAG(              slurm_sched_get_conf                               ) */
+/**************************************************************************/
+char *slurm_sched_get_conf( void )
+{
+	return get_wiki_conf();
+}
diff --git a/src/plugins/sched/wiki2/start_job.c b/src/plugins/sched/wiki2/start_job.c
index 564919f93ad682e69be342566ead6493d7cfc754..bc9f296c6ef945d251bdff8a5a5cf1813ba12b73 100644
--- a/src/plugins/sched/wiki2/start_job.c
+++ b/src/plugins/sched/wiki2/start_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -39,6 +39,7 @@
 #include "src/common/node_select.h"
 #include "src/common/slurm_protocol_defs.h"
 #include "src/common/xstring.h"
+#include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 #include "src/slurmctld/state_save.h"
@@ -115,28 +116,36 @@ extern int	start_job(char *cmd_ptr, int *err_code, char **err_msg)
 		return -1;
 	}
 	task_ptr += 9;	/* skip over "TASKLIST=" */
-	tasklist = moab2slurm_task_list(task_ptr, &task_cnt);
-	if (tasklist)
-		hl = hostlist_create(tasklist);
-	if ((tasklist == NULL) || (hl == NULL)) {
-		*err_code = -300;
-		*err_msg = "STARTJOB TASKLIST is invalid";
-		error("wiki: STARTJOB TASKLIST is invalid: %s",
-			task_ptr);
-		xfree(tasklist);
-		return -1;
-	}
-	hostlist_uniq(hl);
-	hostlist_sort(hl);
-	i = hostlist_ranged_string(hl, sizeof(host_string), host_string);
-	hostlist_destroy(hl);
-	if (i < 0) {
-		*err_code = -300;
-		*err_msg = "STARTJOB has invalid TASKLIST";
-		error("wiki: STARTJOB has invalid TASKLIST: %s",
-			host_string);
-		xfree(tasklist);
-		return -1;
+	if ((task_ptr[0] == '\0') || isspace(task_ptr[0])) {
+		/* No TASKLIST specification, useful for testing */
+		host_string[0] = '0';
+		task_cnt = 0;
+		tasklist = NULL;
+	} else {
+		null_term(task_ptr);
+		tasklist = moab2slurm_task_list(task_ptr, &task_cnt);
+		if (tasklist)
+			hl = hostlist_create(tasklist);
+		if ((tasklist == NULL) || (hl == NULL)) {
+			*err_code = -300;
+			*err_msg = "STARTJOB TASKLIST is invalid";
+			error("wiki: STARTJOB TASKLIST is invalid: %s",
+			      task_ptr);
+			xfree(tasklist);
+			return -1;
+		}
+		hostlist_uniq(hl);
+		hostlist_sort(hl);
+		i = hostlist_ranged_string(hl, sizeof(host_string), host_string);
+		hostlist_destroy(hl);
+		if (i < 0) {
+			*err_code = -300;
+			*err_msg = "STARTJOB has invalid TASKLIST";
+			error("wiki: STARTJOB has invalid TASKLIST: %s",
+			      host_string);
+			xfree(tasklist);
+			return -1;
+		}
 	}
 
 	rc = _start_job(jobid, task_cnt, host_string, tasklist, comment_ptr,
@@ -172,7 +181,8 @@ static int	_start_job(uint32_t jobid, int task_cnt, char *hostlist,
 		NO_LOCK, WRITE_LOCK, READ_LOCK, NO_LOCK };
 	char *new_node_list = NULL;
 	static char tmp_msg[128];
-	bitstr_t *new_bitmap, *save_req_bitmap = (bitstr_t *) NULL;
+	bitstr_t *new_bitmap = (bitstr_t *) NULL;
+	bitstr_t *save_req_bitmap = (bitstr_t *) NULL;
 	bitoff_t i, bsize;
 	int ll; /* layout info index */
 	char *node_name, *node_idx, *node_cur, *save_req_nodes = NULL;
@@ -216,29 +226,21 @@ static int	_start_job(uint32_t jobid, int task_cnt, char *hostlist,
 		job_ptr->comment = xstrdup(comment_ptr);
 	}
 
-	new_node_list = xstrdup(hostlist);
-	if (hostlist && (new_node_list == NULL)) {
-		*err_code = -700;
-		*err_msg = "Invalid TASKLIST";
-		error("wiki: Attempt to set invalid node list for job %u, %s",
-			jobid, hostlist);
-		rc = -1;
-		goto fini;
-	}
-
-	if (node_name2bitmap(new_node_list, false, &new_bitmap) != 0) {
-		*err_code = -700;
-		*err_msg = "Invalid TASKLIST";
-		error("wiki: Attempt to set invalid node list for job %u, %s",
-			jobid, hostlist);
-		xfree(new_node_list);
-		rc = -1;
-		goto fini;
-	}
-
-	/* User excluded node list incompatable with Wiki
-	 * Exclude all nodes not explicitly requested */
 	if (task_cnt) {
+		new_node_list = xstrdup(hostlist);
+		if (node_name2bitmap(new_node_list, false, &new_bitmap) != 0) {
+			*err_code = -700;
+			*err_msg = "Invalid TASKLIST";
+			error("wiki: Attempt to set invalid node list for "
+				"job %u, %s",
+				jobid, hostlist);
+			xfree(new_node_list);
+			rc = -1;
+			goto fini;
+		}
+
+		/* User excluded node list incompatable with Wiki
+		 * Exclude all nodes not explicitly requested */
 		FREE_NULL_BITMAP(job_ptr->details->exc_node_bitmap);
 		job_ptr->details->exc_node_bitmap = bit_copy(new_bitmap);
 		bit_not(job_ptr->details->exc_node_bitmap);
@@ -281,7 +283,7 @@ static int	_start_job(uint32_t jobid, int task_cnt, char *hostlist,
 		}
 	}
 
-	/* get job ready to start now */
+	/* save and update job state to start now */
 	save_req_nodes = job_ptr->details->req_nodes;
 	job_ptr->details->req_nodes = new_node_list;
 	save_req_bitmap = job_ptr->details->req_node_bitmap;
diff --git a/src/plugins/sched/wiki2/suspend_job.c b/src/plugins/sched/wiki2/suspend_job.c
index 058d2dce3f271bb4f7775a8a3aa5701c80b39bfe..383b9539b3ee64cf94e4e9afbf9eb0694df16b03 100644
--- a/src/plugins/sched/wiki2/suspend_job.c
+++ b/src/plugins/sched/wiki2/suspend_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/select/Makefile.in b/src/plugins/select/Makefile.in
index 0d92f90a175ef658016570cb21c67d9a5f81bc5e..0a7883657356c922f40877bb679302617056a3bc 100644
--- a/src/plugins/select/Makefile.in
+++ b/src/plugins/select/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/select/bluegene/Makefile.in b/src/plugins/select/bluegene/Makefile.in
index 2c595da0045da59e9e71cb0c415e113cc95a0eae..03cd7fcc5d0800bffa163bb7bbfe966b6b71a3e0 100644
--- a/src/plugins/select/bluegene/Makefile.in
+++ b/src/plugins/select/bluegene/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/select/bluegene/block_allocator/Makefile.am b/src/plugins/select/bluegene/block_allocator/Makefile.am
index 1d003724a923e0cc3dff68449ffd13524d8e3f2f..5061e0daa4aef45b99d182478cdccac67a2afaa4 100644
--- a/src/plugins/select/bluegene/block_allocator/Makefile.am
+++ b/src/plugins/select/bluegene/block_allocator/Makefile.am
@@ -12,7 +12,6 @@ INCLUDES = -I$(top_srcdir) $(BG_INCLUDES)
 # 	block_allocator.h bridge_linker.h
 
 # block_allocator_LDADD = \
-# 	$(top_builddir)/src/common/libcommon.la \
 # 	$(top_builddir)/src/api/libslurm.la
 
 
@@ -26,12 +25,6 @@ noinst_LTLIBRARIES = libbluegene_block_allocator.la
 libbluegene_block_allocator_la_SOURCES =    \
 	block_allocator.c bridge_linker.c block_allocator.h bridge_linker.h
 
-libbluegene_block_allocator_la_LIBADD  =  \
-	$(top_builddir)/src/common/libcommon.la -lpthread \
-	$(top_builddir)/src/api/libslurm.la
-
 libbluegene_block_allocator_la_LDFLAGS        = \
 	$(LIB_LDFLAGS) -lm    
 
-libbluegene_block_allocator_la_DEPENDENCIES  = \
-	$(top_builddir)/src/common/libcommon.la 
diff --git a/src/plugins/select/bluegene/block_allocator/Makefile.in b/src/plugins/select/bluegene/block_allocator/Makefile.in
index e606f162100f5a71a6e2267e51ca0205f349b489..65d67a3ef89735670d7629bee182011531d7d508 100644
--- a/src/plugins/select/bluegene/block_allocator/Makefile.in
+++ b/src/plugins/select/bluegene/block_allocator/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -65,6 +67,7 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
 CONFIG_CLEAN_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
+libbluegene_block_allocator_la_LIBADD =
 am_libbluegene_block_allocator_la_OBJECTS = block_allocator.lo \
 	bridge_linker.lo
 libbluegene_block_allocator_la_OBJECTS =  \
@@ -73,7 +76,7 @@ libbluegene_block_allocator_la_LINK = $(LIBTOOL) --tag=CC \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
 	$(AM_CFLAGS) $(CFLAGS) \
 	$(libbluegene_block_allocator_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -113,6 +116,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -126,10 +130,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -149,7 +156,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -160,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -175,6 +187,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -190,6 +203,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -257,7 +271,6 @@ INCLUDES = -I$(top_srcdir) $(BG_INCLUDES)
 # 	block_allocator.h bridge_linker.h
 
 # block_allocator_LDADD = \
-# 	$(top_builddir)/src/common/libcommon.la \
 # 	$(top_builddir)/src/api/libslurm.la
 
 # block_allocator_LDFLAGS = -export-dynamic -lm $(CMD_LDFLAGS)
@@ -269,16 +282,9 @@ noinst_LTLIBRARIES = libbluegene_block_allocator.la
 libbluegene_block_allocator_la_SOURCES = \
 	block_allocator.c bridge_linker.c block_allocator.h bridge_linker.h
 
-libbluegene_block_allocator_la_LIBADD = \
-	$(top_builddir)/src/common/libcommon.la -lpthread \
-	$(top_builddir)/src/api/libslurm.la
-
 libbluegene_block_allocator_la_LDFLAGS = \
 	$(LIB_LDFLAGS) -lm    
 
-libbluegene_block_allocator_la_DEPENDENCIES = \
-	$(top_builddir)/src/common/libcommon.la 
-
 all: all-am
 
 .SUFFIXES:
@@ -365,8 +371,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -378,8 +384,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -389,13 +395,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/select/bluegene/block_allocator/block_allocator.c b/src/plugins/select/bluegene/block_allocator/block_allocator.c
index 9c0467374b800c4b20621eacd58353a18f3bd019..b9bf065eccb4289d93d0c6654272c9ee70a47d86 100644
--- a/src/plugins/select/bluegene/block_allocator/block_allocator.c
+++ b/src/plugins/select/bluegene/block_allocator/block_allocator.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  block_allocator.c - Assorted functions for layout of bglblocks, 
  *	 wiring, mapping for smap, etc.
- *  $Id: block_allocator.c 13150 2008-01-31 22:59:13Z da $
+ *  $Id: block_allocator.c 13934 2008-04-23 23:00:29Z da $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -404,8 +404,9 @@ extern int new_ba_request(ba_request_t* ba_request)
 			if ((geo[i] < 1) 
 			    ||  (geo[i] > DIM_SIZE[i])){
 				error("new_ba_request Error, "
-				      "request geometry is invalid %d "
-				      "DIMS are %c%c%c", 
+				      "request geometry is invalid %d can't be "
+				      "%d, DIMS are %c%c%c", 
+				      i,
 				      geo[i],
 				      alpha_num[DIM_SIZE[X]],
 				      alpha_num[DIM_SIZE[Y]],
@@ -980,7 +981,7 @@ extern void init_wires()
 #else
 				source = &ba_system_ptr->grid[x];
 #endif
-				for(i=0; i<6; i++) {
+				for(i=0; i<NUM_PORTS_PER_NODE; i++) {
 					_switch_config(source, source, 
 						       X, i, i);
 					_switch_config(source, source, 
@@ -1051,11 +1052,11 @@ extern void ba_update_node_state(ba_node_t *ba_node, uint16_t state)
 	}
 
 #ifdef HAVE_BG
-	debug2("ba_update_node_state: new state of node[%c%c%c] is %s", 
+	debug2("ba_update_node_state: new state of [%c%c%c] is %s", 
 	       alpha_num[ba_node->coord[X]], alpha_num[ba_node->coord[Y]],
 	       alpha_num[ba_node->coord[Z]], node_state_string(state)); 
 #else
-	debug2("ba_update_node_state: new state of node[%d] is %s", 
+	debug2("ba_update_node_state: new state of [%d] is %s", 
 	       ba_node->coord[X],
 	       node_state_string(state)); 
 #endif
@@ -1093,7 +1094,6 @@ extern ba_node_t *ba_copy_node(ba_node_t *ba_node)
  */
 extern int allocate_block(ba_request_t* ba_request, List results)
 {
-
 	if (!_initialized){
 		error("Error, configuration not initialized, "
 		      "calling ba_init(NULL)");
@@ -1252,9 +1252,12 @@ extern int copy_node_path(List nodes, List dest_nodes)
 			curr_switch = &ba_node->axis_switch[dim];
 			new_switch = &new_ba_node->axis_switch[dim];
 			if(curr_switch->int_wire[0].used) {
-				_copy_the_path(dest_nodes, 
-					       curr_switch, new_switch,
-					       0, dim);
+				if(!_copy_the_path(dest_nodes, 
+						   curr_switch, new_switch,
+						   0, dim)) {
+					rc = SLURM_ERROR;
+					break;
+				}
 			}
 		}
 		
@@ -1306,23 +1309,35 @@ extern int check_and_set_node_list(List nodes)
 			curr_ba_switch = &curr_ba_node->axis_switch[i];
 			//info("checking dim %d", i);
 		
-			for(j=0; j<BA_SYSTEM_DIMENSIONS; j++) {
+			for(j=0; j<NUM_PORTS_PER_NODE; j++) {
 				//info("checking port %d", j);
 		
 				if(ba_switch->int_wire[j].used 
-				   && curr_ba_switch->int_wire[j].used) {
+				   && curr_ba_switch->int_wire[j].used
+					&& j != curr_ba_switch->
+				   int_wire[j].port_tar) {
 					debug3("%c%c%c dim %d port %d "
-					       "is already in use",
+					       "is already in use to %d",
 					       alpha_num[ba_node->coord[X]], 
 					       alpha_num[ba_node->coord[Y]],
 					       alpha_num[ba_node->coord[Z]], 
 					       i,
-					       j);
+					       j,
+					       curr_ba_switch->
+					       int_wire[j].port_tar);
 					rc = SLURM_ERROR;
 					goto end_it;
 				}
 				if(!ba_switch->int_wire[j].used)
 					continue;
+
+				/* info("setting %c%c%c dim %d port %d -> %d", */
+/* 				     alpha_num[ba_node->coord[X]],  */
+/* 				     alpha_num[ba_node->coord[Y]], */
+/* 				     alpha_num[ba_node->coord[Z]],  */
+/* 				     i, */
+/* 				     j, */
+/* 				     ba_switch->int_wire[j].port_tar); */
 				curr_ba_switch->int_wire[j].used = 1;
 				curr_ba_switch->int_wire[j].port_tar 
 					= ba_switch->int_wire[j].port_tar;
@@ -2479,9 +2494,8 @@ static int _copy_the_path(List nodes, ba_switch_t *curr_switch,
 		next_mark_switch = &ba_node->axis_switch[dim];
 			
 	}
-	_copy_the_path(nodes, next_switch, next_mark_switch,
+	return _copy_the_path(nodes, next_switch, next_mark_switch,
 		       port_tar, dim);
-	return 1;
 }
 
 static int _find_yz_path(ba_node_t *ba_node, int *first, 
@@ -2777,8 +2791,8 @@ static int _reset_the_path(ba_switch_t *curr_switch, int source,
 #endif
 		.axis_switch[dim];
 
-	_reset_the_path(next_switch, port_tar, target, dim);
-	return 1;
+	return _reset_the_path(next_switch, port_tar, target, dim);
+//	return 1;
 }
 
 /*
@@ -3161,7 +3175,7 @@ start_again:
 #endif
 	}							
 requested_end:
-	debug("can't allocate");
+	debug2("1 can't allocate");
 	
 	return 0;
 }
@@ -3554,7 +3568,7 @@ static int _set_external_wires(int dim, int count, ba_node_t* source,
 			break;
 		}
 	} else {
-		fatal("Do don't have a config to do a BG system with %d "
+		fatal("We don't have a config to do a BG system with %d "
 		      "in the X-dim.", DIM_SIZE[X]);
 	}
 #else
@@ -4897,56 +4911,56 @@ int main(int argc, char** argv)
 	ba_init(new_node_ptr);
 	init_wires(NULL);
 						
-	/* results = list_create(NULL); */
-/* 	request->geometry[0] = 1; */
-/* 	request->geometry[1] = 4; */
-/* 	request->geometry[2] = 4; */
-/* 	request->start[0] = 5; */
-/* 	request->start[1] = 0; */
-/* 	request->start[2] = 0; */
-/* 	request->start_req = 1; */
-/* 	request->size = 32; */
-/* 	request->rotate = 0; */
-/* 	request->elongate = 0; */
-/* 	request->conn_type = SELECT_TORUS; */
-/* 	new_ba_request(request); */
-/* 	print_ba_request(request); */
-/* 	if(!allocate_block(request, results)) { */
-/*        		debug("couldn't allocate %c%c%c", */
-/* 		       request->geometry[0], */
-/* 		       request->geometry[1], */
-/* 		       request->geometry[2]);	 */
-/* 	} */
-/* 	list_destroy(results); */
-
-/* 	results = list_create(NULL); */
-/* 	request->geometry[0] = 1; */
-/* 	request->geometry[1] = 1; */
-/* 	request->geometry[2] = 1; */
-/* 	request->start[0] = 0; */
-/* 	request->start[1] = 0; */
-/* 	request->start[2] = 0; */
-/* 	request->start_req = 1; */
-/* 	request->size = 1; */
-/* 	request->rotate = 0; */
-/* 	request->elongate = 0; */
-/* 	request->conn_type = SELECT_TORUS; */
-/* 	new_ba_request(request); */
-/* 	print_ba_request(request); */
-/* 	if(!allocate_block(request, results)) { */
-/*        		debug("couldn't allocate %c%c%c", */
-/* 		       alpha_num[request->geometry[0]], */
-/* 		       alpha_num[request->geometry[1]], */
-/* 		       alpha_num[request->geometry[2]]);	 */
-/* 	} */
-/* 	list_destroy(results); */
-
 	results = list_create(NULL);
-	request->geometry[0] = 12;
+	request->geometry[0] = 1;
 	request->geometry[1] = 1;
 	request->geometry[2] = 1;
-	request->start[0] = 0;
+	request->start[0] = 6;
+	request->start[1] = 3;
+	request->start[2] = 2;
+	request->start_req = 1;
+//	request->size = 1;
+	request->rotate = 0;
+	request->elongate = 0;
+	request->conn_type = SELECT_TORUS;
+	new_ba_request(request);
+	print_ba_request(request);
+	if(!allocate_block(request, results)) {
+       		debug("couldn't allocate %c%c%c",
+		       request->geometry[0],
+		       request->geometry[1],
+		       request->geometry[2]);
+	}
+	list_destroy(results);
+
+	results = list_create(NULL);
+	request->geometry[0] = 2;
+	request->geometry[1] = 4;
+	request->geometry[2] = 1;
+	request->start[0] = 3;
 	request->start[1] = 0;
+	request->start[2] = 2;
+	request->start_req = 1;
+//	request->size = 16;
+	request->rotate = 0;
+	request->elongate = 0;
+	request->conn_type = SELECT_TORUS;
+	new_ba_request(request);
+	print_ba_request(request);
+	if(!allocate_block(request, results)) {
+       		debug("couldn't allocate %c%c%c",
+		       alpha_num[request->geometry[0]],
+		       alpha_num[request->geometry[1]],
+		       alpha_num[request->geometry[2]]);
+	}
+	list_destroy(results);
+
+	results = list_create(NULL);
+	request->geometry[0] = 2;
+	request->geometry[1] = 1;
+	request->geometry[2] = 4;
+	request->start[0] = 5;
+	request->start[1] = 2;
 	request->start[2] = 0;
 	request->start_req = 1;
 	request->rotate = 0;
@@ -5004,16 +5018,17 @@ int main(int argc, char** argv)
 	for(x=startx;x<endx;x++) {
 		for(y=starty;y<endy;y++) {
 			for(z=startz;z<endz;z++) {
+				ba_node_t *curr_node = 
+					&(ba_system_ptr->grid[x][y][z]);
 				info("Node %c%c%c Used = %d Letter = %c",
 				     alpha_num[x],alpha_num[y],alpha_num[z],
-				     ba_system_ptr->grid[x][y][z].used,
-				     ba_system_ptr->grid[x][y][z].letter);
+				     curr_node->used,
+				     curr_node->letter);
 				for(dim=0;dim<1;dim++) {
 					info("Dim %d",dim);
 					ba_switch_t *wire =
-						&ba_system_ptr->
-						grid[x][y][z].axis_switch[dim];
-					for(j=0;j<6;j++)
+						&curr_node->axis_switch[dim];
+					for(j=0;j<NUM_PORTS_PER_NODE;j++)
 						info("\t%d -> %d -> %c%c%c %d "
 						     "Used = %d",
 						     j, wire->int_wire[j].
diff --git a/src/plugins/select/bluegene/block_allocator/block_allocator.h b/src/plugins/select/bluegene/block_allocator/block_allocator.h
index 91fe587478f55e963a80a597abcc149801ce8259..b9b1c5a15f50cf00277d71ace11aceb01ff5788e 100644
--- a/src/plugins/select/bluegene/block_allocator/block_allocator.h
+++ b/src/plugins/select/bluegene/block_allocator/block_allocator.h
@@ -227,7 +227,7 @@ extern void destroy_image_group_list(void *ptr);
 extern void destroy_image(void *ptr);
 extern void destroy_ba_node(void *ptr);
 
-/**
+/*
  * create a block request.  Note that if the geometry is given,
  * then size is ignored.  If elongate is true, the algorithm will try
  * to fit that a block of cubic shape and then it will try other
@@ -247,23 +247,23 @@ extern void destroy_ba_node(void *ptr);
  */
 extern int new_ba_request(ba_request_t* ba_request);
 
-/**
+/*
  * delete a block request 
  */
 extern void delete_ba_request(void *arg);
 
-/**
+/*
  * empty a list that we don't want to destroy the memory of the
  * elements always returns 1
 */
 extern int empty_null_destroy_list(void *arg, void *key);
 
-/**
+/*
  * print a block request 
  */
 extern void print_ba_request(ba_request_t* ba_request);
 
-/**
+/*
  * Initialize internal structures by either reading previous block
  * configurations from a file or by running the graph solver.
  * 
@@ -272,7 +272,7 @@ extern void print_ba_request(ba_request_t* ba_request);
  * return: success or error of the intialization.
  */
 extern void ba_init();
-/**
+/*
  */
 extern void init_wires();
 /** 
diff --git a/src/plugins/select/bluegene/plugin/Makefile.am b/src/plugins/select/bluegene/plugin/Makefile.am
index 5ba952deda516ee44adfa2e33b3a13fdb36880de..817ccd600c50122c42b8dd7a83dd9a1bae840cd2 100644
--- a/src/plugins/select/bluegene/plugin/Makefile.am
+++ b/src/plugins/select/bluegene/plugin/Makefile.am
@@ -14,10 +14,13 @@ select_bluegene_la_SOURCES = select_bluegene.c \
 				bg_job_place.c bg_job_place.h \
 				bg_job_run.c bg_job_run.h \
 				bg_block_info.c bg_block_info.h \
+				bg_record_functions.c bg_record_functions.h \
 				bluegene.c bluegene.h \
 				state_test.c state_test.h \
 				bg_switch_connections.c \
 				block_sys.c \
+				dynamic_block.c dynamic_block.h \
+				defined_block.c defined_block.h \
 				../wrap_rm_api.h
 
 select_bluegene_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
@@ -32,12 +35,9 @@ libsched_if64_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
 
 sbin_PROGRAMS = slurm_prolog slurm_epilog sfree
 
-sfree_LDADD = $(top_builddir)/src/common/libcommon.la \
-		$(top_builddir)/src/api/libslurm.la
-slurm_prolog_LDADD = $(top_builddir)/src/common/libcommon.la \
-		$(top_builddir)/src/api/libslurm.la
-slurm_epilog_LDADD =  $(top_builddir)/src/common/libcommon.la \
-		$(top_builddir)/src/api/libslurm.la
+sfree_LDADD = $(top_builddir)/src/api/libslurmhelper.la
+slurm_prolog_LDADD = $(top_builddir)/src/api/libslurmhelper.la
+slurm_epilog_LDADD = $(top_builddir)/src/api/libslurmhelper.la
 sfree_SOURCES = sfree.c sfree.h opts.c \
 		../block_allocator/bridge_linker.c \
 		../block_allocator/bridge_linker.h 
diff --git a/src/plugins/select/bluegene/plugin/Makefile.in b/src/plugins/select/bluegene/plugin/Makefile.in
index 2f204dce4a1dd039cfd21e930dd8698ad28a49c1..6f705c3df54b92a9e9918151f7f0448f4c79858d 100644
--- a/src/plugins/select/bluegene/plugin/Makefile.in
+++ b/src/plugins/select/bluegene/plugin/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -47,6 +47,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -85,8 +87,9 @@ libsched_if64_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 select_bluegene_la_DEPENDENCIES =  \
 	../block_allocator/libbluegene_block_allocator.la
 am_select_bluegene_la_OBJECTS = select_bluegene.lo bg_job_place.lo \
-	bg_job_run.lo bg_block_info.lo bluegene.lo state_test.lo \
-	bg_switch_connections.lo block_sys.lo
+	bg_job_run.lo bg_block_info.lo bg_record_functions.lo \
+	bluegene.lo state_test.lo bg_switch_connections.lo \
+	block_sys.lo dynamic_block.lo defined_block.lo
 select_bluegene_la_OBJECTS = $(am_select_bluegene_la_OBJECTS)
 select_bluegene_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@@ -96,26 +99,23 @@ PROGRAMS = $(sbin_PROGRAMS)
 am_sfree_OBJECTS = sfree.$(OBJEXT) opts.$(OBJEXT) \
 	bridge_linker.$(OBJEXT)
 sfree_OBJECTS = $(am_sfree_OBJECTS)
-sfree_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
-	$(top_builddir)/src/api/libslurm.la
+sfree_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 sfree_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sfree_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_slurm_epilog_OBJECTS = slurm_epilog.$(OBJEXT)
 slurm_epilog_OBJECTS = $(am_slurm_epilog_OBJECTS)
-slurm_epilog_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
-	$(top_builddir)/src/api/libslurm.la
+slurm_epilog_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 slurm_epilog_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(slurm_epilog_LDFLAGS) $(LDFLAGS) -o $@
 am_slurm_prolog_OBJECTS = slurm_prolog.$(OBJEXT)
 slurm_prolog_OBJECTS = $(am_slurm_prolog_OBJECTS)
-slurm_prolog_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
-	$(top_builddir)/src/api/libslurm.la
+slurm_prolog_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 slurm_prolog_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(slurm_prolog_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -159,6 +159,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -172,10 +173,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -195,7 +199,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -206,6 +213,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -221,6 +230,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -236,6 +246,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -302,10 +313,13 @@ select_bluegene_la_SOURCES = select_bluegene.c \
 				bg_job_place.c bg_job_place.h \
 				bg_job_run.c bg_job_run.h \
 				bg_block_info.c bg_block_info.h \
+				bg_record_functions.c bg_record_functions.h \
 				bluegene.c bluegene.h \
 				state_test.c state_test.h \
 				bg_switch_connections.c \
 				block_sys.c \
+				dynamic_block.c dynamic_block.h \
+				defined_block.c defined_block.h \
 				../wrap_rm_api.h
 
 select_bluegene_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
@@ -314,15 +328,9 @@ select_bluegene_la_LIBADD = ../block_allocator/libbluegene_block_allocator.la
 # MPIRUN dynamic lib.
 libsched_if64_la_SOURCES = libsched_if64.c 
 libsched_if64_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-sfree_LDADD = $(top_builddir)/src/common/libcommon.la \
-		$(top_builddir)/src/api/libslurm.la
-
-slurm_prolog_LDADD = $(top_builddir)/src/common/libcommon.la \
-		$(top_builddir)/src/api/libslurm.la
-
-slurm_epilog_LDADD = $(top_builddir)/src/common/libcommon.la \
-		$(top_builddir)/src/api/libslurm.la
-
+sfree_LDADD = $(top_builddir)/src/api/libslurmhelper.la
+slurm_prolog_LDADD = $(top_builddir)/src/api/libslurmhelper.la
+slurm_epilog_LDADD = $(top_builddir)/src/api/libslurmhelper.la
 sfree_SOURCES = sfree.c sfree.h opts.c \
 		../block_allocator/bridge_linker.c \
 		../block_allocator/bridge_linker.h 
@@ -371,8 +379,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -380,8 +388,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -405,8 +413,8 @@ install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -443,10 +451,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_block_info.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_job_place.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_job_run.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_record_functions.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bg_switch_connections.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/block_sys.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bluegene.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bridge_linker.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/defined_block.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic_block.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsched_if64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opts.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/select_bluegene.Plo@am__quote@
@@ -501,8 +512,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -514,8 +525,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -525,13 +536,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/select/bluegene/plugin/bg_job_place.c b/src/plugins/select/bluegene/plugin/bg_job_place.c
index 30d60327b72102027de95209dd15428506f0c44f..3cb46be9e85fe66e0a736daca9d1c0ce697076c0 100644
--- a/src/plugins/select/bluegene/plugin/bg_job_place.c
+++ b/src/plugins/select/bluegene/plugin/bg_job_place.c
@@ -2,7 +2,7 @@
  *  bg_job_place.c - blue gene job placement (e.g. base block selection)
  *  functions.
  *
- *  $Id: bg_job_place.c 13271 2008-02-14 20:02:00Z da $ 
+ *  $Id: bg_job_place.c 13999 2008-05-07 22:08:58Z da $ 
  *****************************************************************************
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -43,6 +43,9 @@
 #include "src/common/node_select.h"
 #include "src/slurmctld/trigger_mgr.h"
 #include "bluegene.h"
+#include "dynamic_block.h"
+
+#ifdef HAVE_BG 
 
 #define _DEBUG 0
 #define MAX_GROUPS 128
@@ -54,16 +57,51 @@ _STMT_START {		\
 	(b) = (t);	\
 } _STMT_END
 
-static int  _find_best_block_match(struct job_record* job_ptr,
-				   bitstr_t* slurm_block_bitmap, uint32_t min_nodes, 
-				   uint32_t max_nodes, uint32_t req_nodes,
-				   int spec, bg_record_t** found_bg_record,
-				   bool test_only);
-static int  _get_user_groups(uint32_t user_id, uint32_t group_id, 
-			     gid_t *groups, int max_groups, int *ngroups);
+
+pthread_mutex_t create_dynamic_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t job_list_test_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* This list is for the test_job_list function because we will be
+ * adding and removing blocks off the bg_job_block_list and don't want
+ * to ruin that list in submit_job it should = bg_job_block_list
+ * otherwise it should be a copy of that list.
+ */
+List job_block_test_list = NULL;
+
 static void _rotate_geo(uint16_t *req_geometry, int rot_cnt);
-static int  _test_image_perms(char *image_name, List image_list, 
+static int _bg_record_sort_aval_inc(bg_record_t* rec_a, bg_record_t* rec_b); 
+static int _get_user_groups(uint32_t user_id, uint32_t group_id, 
+			     gid_t *groups, int max_groups, int *ngroups);
+static int _test_image_perms(char *image_name, List image_list, 
 			      struct job_record* job_ptr);
+static int _check_images(struct job_record* job_ptr,
+			 char **blrtsimage, char **linuximage,
+			 char **mloaderimage, char **ramdiskimage);
+static bg_record_t *_find_matching_block(List block_list, 
+					 struct job_record* job_ptr, 
+					 bitstr_t* slurm_block_bitmap,
+					 ba_request_t *request,
+					 uint32_t max_procs,
+					 int allow, int check_image,
+					 int overlap_check,
+					 List overlapped_list,
+					 bool test_only);
+static int _check_for_booted_overlapping_blocks(
+	List block_list, ListIterator bg_record_itr,
+	bg_record_t *bg_record, int overlap_check, List overlapped_list,
+	bool test_only);
+static int _dynamically_request(List block_list, int *blocks_added,
+				ba_request_t *request,
+				bitstr_t* slurm_block_bitmap,
+				char *user_req_nodes);
+static int _find_best_block_match(List block_list, int *blocks_added,
+				  struct job_record* job_ptr,
+				  bitstr_t* slurm_block_bitmap,
+				  uint32_t min_nodes, 
+				  uint32_t max_nodes, uint32_t req_nodes,
+				  bg_record_t** found_bg_record,
+				  bool test_only);
+static int _sync_block_lists(List full_list, List incomp_list);
 
 /* Rotate a 3-D geometry array through its six permutations */
 static void _rotate_geo(uint16_t *req_geometry, int rot_cnt)
@@ -84,7 +122,97 @@ static void _rotate_geo(uint16_t *req_geometry, int rot_cnt)
 	}
 }
 
-pthread_mutex_t create_dynamic_mutex = PTHREAD_MUTEX_INITIALIZER;
+/* 
+ * Comparator used for sorting blocks smallest to largest
+ * 
+ * returns: -1: rec_a < rec_b   0: rec_a == rec_b   1: rec_a > rec_b
+ * 
+ */
+static int _bg_record_sort_aval_inc(bg_record_t* rec_a, bg_record_t* rec_b)
+{
+	int size_a = rec_a->node_cnt;
+	int size_b = rec_b->node_cnt;
+
+	if(rec_a->job_ptr && !rec_b->job_ptr)
+		return -1;
+	else if(!rec_a->job_ptr && rec_b->job_ptr)
+		return 1;
+	else if(rec_a->job_ptr && rec_b->job_ptr) {
+		if(rec_a->job_ptr->start_time > rec_b->job_ptr->start_time)
+			return 1;
+		else if(rec_a->job_ptr->start_time < rec_b->job_ptr->start_time)
+			return -1;
+	}
+
+	if (size_a < size_b)
+		return -1;
+	else if (size_a > size_b)
+		return 1;
+	if(rec_a->nodes && rec_b->nodes) {
+		size_a = strcmp(rec_a->nodes, rec_b->nodes);
+		if (size_a < 0)
+			return -1;
+		else if (size_a > 0)
+			return 1;
+	}
+	if (rec_a->quarter < rec_b->quarter)
+		return -1;
+	else if (rec_a->quarter > rec_b->quarter)
+		return 1;
+
+	if(rec_a->nodecard < rec_b->nodecard)
+		return -1;
+	else if(rec_a->nodecard > rec_b->nodecard)
+		return 1;
+
+	return 0;
+}
+
+/* 
+ * Comparator used for sorting blocks smallest to largest
+ * 
+ * returns: -1: rec_a >rec_b   0: rec_a == rec_b   1: rec_a < rec_b
+ * 
+ */
+static int _bg_record_sort_aval_dec(bg_record_t* rec_a, bg_record_t* rec_b)
+{
+	int size_a = rec_a->node_cnt;
+	int size_b = rec_b->node_cnt;
+
+	if(rec_a->job_ptr && !rec_b->job_ptr)
+		return 1;
+	else if(!rec_a->job_ptr && rec_b->job_ptr)
+		return -1;
+	else if(rec_a->job_ptr && rec_b->job_ptr) {
+		if(rec_a->job_ptr->start_time > rec_b->job_ptr->start_time)
+			return -1;
+		else if(rec_a->job_ptr->start_time < rec_b->job_ptr->start_time)
+			return 1;
+	}
+
+	if (size_a < size_b)
+		return -1;
+	else if (size_a > size_b)
+		return 1;
+	if(rec_a->nodes && rec_b->nodes) {
+		size_a = strcmp(rec_a->nodes, rec_b->nodes);
+		if (size_a < 0)
+			return -1;
+		else if (size_a > 0)
+			return 1;
+	}
+	if (rec_a->quarter < rec_b->quarter)
+		return -1;
+	else if (rec_a->quarter > rec_b->quarter)
+		return 1;
+
+	if(rec_a->nodecard < rec_b->nodecard)
+		return -1;
+	else if(rec_a->nodecard > rec_b->nodecard)
+		return 1;
+
+	return 0;
+}
 
 /*
  * Get a list of groups associated with a specific user_id
@@ -110,7 +238,7 @@ static int _get_user_groups(uint32_t user_id, uint32_t group_id,
 		return -1;
 	}
 	*ngroups = max_groups;
-	rc = getgrouplist(pwd.pw_name, (gid_t) group_id, groups, ngroups);
+ 	rc = getgrouplist(pwd.pw_name, (gid_t) group_id, groups, ngroups);
 	xfree(buffer);
 	if (rc < 0) {
 		error("getgrouplist(%s): %m", pwd.pw_name);
@@ -140,14 +268,13 @@ static int _test_image_perms(char *image_name, List image_list,
 
 	itr = list_iterator_create(image_list);
 	while ((image = list_next(itr))) {
-		if (!strcasecmp(image->name, image_name) ||
-		    !strcasecmp(image->name, "*")) {
+		if (!strcasecmp(image->name, image_name)
+		    || !strcasecmp(image->name, "*")) {
 			if (image->def) {
 				allow = 1;
 				break;
 			}
-			if (!image->groups ||
-			    !list_count(image->groups)) {
+			if (!image->groups || !list_count(image->groups)) {
 				allow = 1;
 				break;
 			}
@@ -161,8 +288,7 @@ static int _test_image_perms(char *image_name, List image_list,
 				cache_user = job_ptr->user_id;
 			}
 			itr2 = list_iterator_create(image->groups);
-			while ((allow == 0) &&
-			       (image_group = list_next(itr2))) {
+			while (!allow && (image_group = list_next(itr2))) {
 				for (i=0; i<ngroups; i++) {
 					if (image_group->gid
 					    == groups[i]) {
@@ -181,251 +307,117 @@ static int _test_image_perms(char *image_name, List image_list,
 	return allow;
 }
 
-/*
- * finds the best match for a given job request 
- * 
- * IN - int spec right now holds the place for some type of
- * specification as to the importance of certain job params, for
- * instance, geometry, type, size, etc.
- * 
- * OUT - block_id of matched block, NULL otherwise
- * returns 1 for error (no match)
- * 
- */
-static int _find_best_block_match(struct job_record* job_ptr, 
-				  bitstr_t* slurm_block_bitmap,
-				  uint32_t min_nodes, uint32_t max_nodes,
-				  uint32_t req_nodes, int spec,
-				  bg_record_t** found_bg_record, 
-				  bool test_only)
+static int _check_images(struct job_record* job_ptr,
+			 char **blrtsimage, char **linuximage,
+			 char **mloaderimage, char **ramdiskimage)
 {
-	ListIterator itr;
-	ListIterator itr2;
-	bg_record_t *record = NULL;
-	bg_record_t *found_record = NULL;
-	uint16_t req_geometry[BA_SYSTEM_DIMENSIONS];
-	uint16_t start[BA_SYSTEM_DIMENSIONS];
-	uint16_t conn_type, rotate, target_size = 0;
-	uint32_t req_procs = job_ptr->num_procs;
-	uint32_t proc_cnt;
-	ba_request_t request; 
-	int i;
-	int rot_cnt = 0;
-	int created = 0;
 	int allow = 0;
-	int check_image = 1;
-	uint32_t max_procs = NO_VAL;
-	List lists_of_lists = NULL;
-	List temp_list = NULL;
-	char tmp_char[256];
-	bitstr_t* tmp_bitmap = NULL;
-	int start_req = 0;
-	static int total_cpus = 0;
-	char *blrtsimage = NULL;        /* BlrtsImage for this request */
-	char *linuximage = NULL;        /* LinuxImage for this request */
-	char *mloaderimage = NULL;      /* mloaderImage for this request */
-	char *ramdiskimage = NULL;      /* RamDiskImage for this request */
-	int rc = SLURM_SUCCESS;
-
-	if(!total_cpus)
-		total_cpus = DIM_SIZE[X] * DIM_SIZE[Y] * DIM_SIZE[Z] 
-			* procs_per_node;
-
-	if(req_nodes > max_nodes) {
-		error("can't run this job max bps is %u asking for %u",
-		      max_nodes, req_nodes);
-		return SLURM_ERROR;
-	}
-
-	slurm_mutex_lock(&block_state_mutex);
-	if(!test_only && req_procs > num_unused_cpus) {
-		debug2("asking for %u I only got %d", 
-		       req_procs, num_unused_cpus);
-		slurm_mutex_unlock(&block_state_mutex);
-		return SLURM_ERROR;
-	}
-	slurm_mutex_unlock(&block_state_mutex);
-	if(!bg_list) {
-		error("_find_best_block_match: There is no bg_list");
-		return SLURM_ERROR;
-	}
-	
-	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_START, &start);
-		
-	if(start[X] != (uint16_t)NO_VAL)
-		start_req = 1;
-
-	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_CONN_TYPE, &conn_type);
-	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_GEOMETRY, &req_geometry);
-	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_ROTATE, &rotate);
-	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_MAX_PROCS, &max_procs);
 
 	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_BLRTS_IMAGE, &blrtsimage);
-	if (blrtsimage) {
-		allow = _test_image_perms(blrtsimage, bg_blrtsimage_list, 
+			     SELECT_DATA_BLRTS_IMAGE, blrtsimage);
+	
+	if (*blrtsimage) {
+		allow = _test_image_perms(*blrtsimage, bg_blrtsimage_list, 
 					  job_ptr);
 		if (!allow) {
 			error("User %u:%u is not allowed to use BlrtsImage %s",
-			      job_ptr->user_id, job_ptr->group_id, blrtsimage);
-			rc = SLURM_ERROR;
-			goto end_it;
+			      job_ptr->user_id, job_ptr->group_id, *blrtsimage);
+			return SLURM_ERROR;
+		       
 		}
 	}
 
 	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_LINUX_IMAGE, &linuximage);
-	if (linuximage) {
-		allow = _test_image_perms(linuximage, bg_linuximage_list, 
+			     SELECT_DATA_LINUX_IMAGE, linuximage);
+	if (*linuximage) {
+		allow = _test_image_perms(*linuximage, bg_linuximage_list, 
 					  job_ptr);
 		if (!allow) {
 			error("User %u:%u is not allowed to use LinuxImage %s",
-			      job_ptr->user_id, job_ptr->group_id, linuximage);
-			rc = SLURM_ERROR;
-			goto end_it;
+			      job_ptr->user_id, job_ptr->group_id, *linuximage);
+			return SLURM_ERROR;
 		}
 	}
 
 	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_MLOADER_IMAGE, &mloaderimage);
-	if (mloaderimage) {
-		allow = _test_image_perms(mloaderimage, bg_mloaderimage_list, 
+			     SELECT_DATA_MLOADER_IMAGE, mloaderimage);
+	if (*mloaderimage) {
+		allow = _test_image_perms(*mloaderimage, bg_mloaderimage_list, 
 					  job_ptr);
 		if(!allow) {
 			error("User %u:%u is not allowed "
 			      "to use MloaderImage %s",
 			      job_ptr->user_id, job_ptr->group_id, 
-			      mloaderimage);
-			rc = SLURM_ERROR;
-			goto end_it;
+			      *mloaderimage);
+			return SLURM_ERROR;
 		}
 	}
 
 	select_g_get_jobinfo(job_ptr->select_jobinfo,
-			     SELECT_DATA_RAMDISK_IMAGE, &ramdiskimage);
-	if (ramdiskimage) {
-		allow = _test_image_perms(ramdiskimage, bg_ramdiskimage_list, 
+			     SELECT_DATA_RAMDISK_IMAGE, ramdiskimage);
+	if (*ramdiskimage) {
+		allow = _test_image_perms(*ramdiskimage, bg_ramdiskimage_list, 
 					  job_ptr);
 		if(!allow) {
 			error("User %u:%u is not allowed "
 			      "to use RamDiskImage %s",
 			      job_ptr->user_id, job_ptr->group_id, 
-			      ramdiskimage);
-			rc = SLURM_ERROR;
-			goto end_it;
-		}
-	}
-	
-	if(req_geometry[X] != 0 && req_geometry[X] != (uint16_t)NO_VAL) {
-		target_size = 1;
-		for (i=0; i<BA_SYSTEM_DIMENSIONS; i++)
-			target_size *= (uint16_t)req_geometry[i];
-		if(target_size != min_nodes) {
-			debug2("min_nodes not set correctly %u should be %u "
-			      "from %u%u%u",
-			      min_nodes, target_size, 
-			      req_geometry[X],
-			      req_geometry[Y],
-			      req_geometry[Z]);
-			min_nodes = target_size;
-		}
-		if(!req_nodes)
-			req_nodes = req_nodes;
-	}
-	if (target_size == 0) {	/* no geometry specified */
-		if(job_ptr->details->req_nodes 
-		   && !start_req) {
-			bg_record_t *tmp_record = NULL;
-			char *tmp_nodes= job_ptr->details->req_nodes;
-			int len = strlen(tmp_nodes);
-			
-			i = 0;
-			while(i<len 
-			      && tmp_nodes[i] != '[' 
-			      && (tmp_nodes[i] < '0' || tmp_nodes[i] > 'Z'
-				  || (tmp_nodes[i] > '9'
-				      && tmp_nodes[i] < 'A')))
-				i++;
-			
-			if(i<len) {
-				len -= i;
-				tmp_record = xmalloc(sizeof(bg_record_t));
-				tmp_record->bg_block_list =
-					list_create(destroy_ba_node);
-				slurm_conf_lock();
-				len += strlen(slurmctld_conf.node_prefix)+1;
-				tmp_record->nodes = xmalloc(len);
-				
-				snprintf(tmp_record->nodes,
-					 len,
-					 "%s%s", 
-					 slurmctld_conf.node_prefix, 
-					 tmp_nodes+i);
-				slurm_conf_unlock();
-			
-				process_nodes(tmp_record);
-				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) {
-					req_geometry[i] = tmp_record->geo[i];
-					start[i] = tmp_record->start[i];
-				}
-				destroy_bg_record(tmp_record);
-				select_g_set_jobinfo(job_ptr->select_jobinfo,
-						     SELECT_DATA_GEOMETRY, 
-						     &req_geometry);
-				select_g_set_jobinfo(job_ptr->select_jobinfo,
-						     SELECT_DATA_START, 
-						     &start);
-				start_req = 1;
-			}  else 
-				error("BPs=%s is in a weird format", 
-				      tmp_nodes); 
-		} else {
-			req_geometry[X] = (uint16_t)NO_VAL;
+			      *ramdiskimage);
+			return SLURM_ERROR;
 		}
-		target_size = min_nodes;
 	}
+
+	return SLURM_SUCCESS;
+}
+
+static bg_record_t *_find_matching_block(List block_list, 
+					 struct job_record* job_ptr, 
+					 bitstr_t* slurm_block_bitmap,
+					 ba_request_t *request,
+					 uint32_t max_procs,
+					 int allow, int check_image,
+					 int overlap_check,
+					 List overlapped_list,
+					 bool test_only)
+{
+	bg_record_t *bg_record = NULL;
+	ListIterator itr = NULL;
+	uint32_t proc_cnt = 0;
+	char tmp_char[256];
 	
-	/* this is where we should have the control flow depending on
-	 * the spec arguement */
-		
-	*found_bg_record = NULL;
-	allow = 0;
-try_again:	
-	slurm_mutex_lock(&block_state_mutex);
 	debug("number of blocks to check: %d state %d", 
-	      list_count(bg_list),
+	      list_count(block_list),
 	      test_only);
-	itr = list_iterator_create(bg_list);
-	while ((record = (bg_record_t*) list_next(itr))) {		
+		
+	itr = list_iterator_create(block_list);
+	while ((bg_record = (bg_record_t*) list_next(itr))) {		
 		/* If test_only we want to fall through to tell the 
 		   scheduler that it is runnable just not right now. 
 		*/
 		debug3("%s job_running = %d", 
-		       record->bg_block_id, record->job_running);
+		       bg_record->bg_block_id, bg_record->job_running);
 		/*block is messed up some how (BLOCK_ERROR_STATE) ignore it*/
-		if(record->job_running == BLOCK_ERROR_STATE) {
+		if(bg_record->job_running == BLOCK_ERROR_STATE) {
 			debug("block %s is in an error state (can't use)", 
-			      record->bg_block_id);			
+			      bg_record->bg_block_id);			
 			continue;
-		} else if((record->job_running != NO_JOB_RUNNING) 
-			  && !test_only) {
+		} else if((bg_record->job_running != NO_JOB_RUNNING) 
+			  && (bg_record->job_running != job_ptr->job_id)
+			  && (bluegene_layout_mode == LAYOUT_DYNAMIC 
+			      || (!test_only 
+				  && bluegene_layout_mode != LAYOUT_DYNAMIC))) {
 			debug("block %s in use by %s job %d", 
-			      record->bg_block_id,
-			      record->user_name,
-			      record->job_running);
+			      bg_record->bg_block_id,
+			      bg_record->user_name,
+			      bg_record->job_running);
 			continue;
 		}
-		
+
 		/* Check processor count */
-		proc_cnt = record->bp_count * record->cpus_per_bp;
+		proc_cnt = bg_record->bp_count * bg_record->cpus_per_bp;
 		debug3("asking for %u-%u looking at %d", 
-		      req_procs, max_procs, proc_cnt);
-		if ((proc_cnt < req_procs)
+		       request->procs, max_procs, proc_cnt);
+		if ((proc_cnt < request->procs)
 		    || ((max_procs != NO_VAL) && (proc_cnt > max_procs))) {
 			/* We use the proccessor count per block here
 			   mostly to see if we can run on a smaller block. 
@@ -433,27 +425,11 @@ try_again:
 			convert_num_unit((float)proc_cnt, tmp_char, 
 					 sizeof(tmp_char), UNIT_NONE);
 			debug("block %s CPU count (%s) not suitable",
-			      record->bg_block_id, 
+			      bg_record->bg_block_id, 
 			      tmp_char);
 			continue;
 		}
 
-		/*
-		 * check that the number of nodes is suitable
-		 */
- 		debug3("asking for %u-%u bps looking at %d", 
-		      min_nodes, req_nodes, record->bp_count);
-		if ((record->bp_count < min_nodes)
-		    ||  (req_nodes != 0 && record->bp_count > req_nodes)
-		    ||  (record->bp_count < target_size)) {
-			convert_num_unit((float)record->node_cnt, tmp_char,
-					 sizeof(tmp_char), UNIT_NONE);
-			debug("block %s node count (%s) not suitable",
-			      record->bg_block_id,
-			      tmp_char);
-			continue;
-		}
-		
 		/*
 		 * Next we check that this block's bitmap is within 
 		 * the set of nodes which the job can use. 
@@ -461,9 +437,9 @@ try_again:
 		 * drained, allocated to some other job, or in some 
 		 * SLURM block not available to this job.
 		 */
-		if (!bit_super_set(record->bitmap, slurm_block_bitmap)) {
+		if (!bit_super_set(bg_record->bitmap, slurm_block_bitmap)) {
 			debug("bg block %s has nodes not usable by this job",
-			      record->bg_block_id);
+			      bg_record->bg_block_id);
 			continue;
 		}
 
@@ -472,92 +448,37 @@ try_again:
 		 */
 		if (job_ptr->details->req_node_bitmap
 		    && (!bit_super_set(job_ptr->details->req_node_bitmap,
-				       record->bitmap))) {
+				       bg_record->bitmap))) {
 			debug("bg block %s lacks required nodes",
-				record->bg_block_id);
+				bg_record->bg_block_id);
 			continue;
 		}
-				
-		/* Make sure no other blocks are under this block 
-		   are booted and running jobs
-		*/
-		itr2 = list_iterator_create(bg_list);
-		while ((found_record = (bg_record_t*)
-			list_next(itr2)) != NULL) {
-			if ((!found_record->bg_block_id)
-			    || (!strcmp(record->bg_block_id, 
-					found_record->bg_block_id)))
-				continue;
-			if(blocks_overlap(record, found_record)) {
-				if(!test_only
-				   && bluegene_layout_mode == LAYOUT_OVERLAP) {
-					if(!created && record->state 
-						!= RM_PARTITION_READY)
-						break;
-					else if(created == 1 
-						&& found_record->state 
-						!= RM_PARTITION_FREE) {
-						break;
-					} 
-				}
-				if(!test_only && found_record->job_running
-				   != NO_JOB_RUNNING) {
-					if(found_record->job_running
-					   == BLOCK_ERROR_STATE)
-						error("can't use %s, "
-						      "overlapping block %s "
-						      "is in an error state.",
-						      record->bg_block_id,
-						      found_record->
-						      bg_block_id);
-					else
-						debug("can't use %s, there is "
-						      "a job (%d) running on "
-						      "an overlapping "
-						      "block %s", 
-						      record->bg_block_id,
-						      found_record->
-						      job_running,
-						      found_record->
-						      bg_block_id);
-				
-					if(bluegene_layout_mode == 
-					   LAYOUT_DYNAMIC) {
-						list_remove(itr);
-						temp_list = list_create(NULL);
-						list_push(temp_list, record);
-						num_block_to_free++;
-						free_block_list(temp_list);
-						list_destroy(temp_list);
-					} 
-					break;
-				} 
-			} 
-		}
-		list_iterator_destroy(itr2);
-
-		if(found_record) {
+		
+		
+		if(_check_for_booted_overlapping_blocks(
+			   block_list, itr, bg_record,
+			   overlap_check, overlapped_list, test_only))
 			continue;
-		} 
-
+		
 		if(check_image) {
-			if(blrtsimage &&
-			   strcasecmp(blrtsimage, record->blrtsimage)) {
+			if(request->blrtsimage &&
+			   strcasecmp(request->blrtsimage,
+				      bg_record->blrtsimage)) {
 				allow = 1;
 				continue;
-			}
-			if(linuximage &&
-			   strcasecmp(linuximage, record->linuximage)) {
+			} else if(request->linuximage &&
+			   strcasecmp(request->linuximage,
+				      bg_record->linuximage)) {
 				allow = 1;
 				continue;
-			}
-			if(mloaderimage &&
-			   strcasecmp(mloaderimage, record->mloaderimage)) {
+			} else if(request->mloaderimage &&
+			   strcasecmp(request->mloaderimage, 
+				      bg_record->mloaderimage)) {
 				allow = 1;
 				continue;
-			}
-			if(ramdiskimage &&
-			   strcasecmp(ramdiskimage, record->ramdiskimage)) {
+			} else if(request->ramdiskimage &&
+			   strcasecmp(request->ramdiskimage,
+				      bg_record->ramdiskimage)) {
 				allow = 1;
 				continue;
 			}			
@@ -566,221 +487,667 @@ try_again:
 		/***********************************************/
 		/* check the connection type specified matches */
 		/***********************************************/
-		if ((conn_type != record->conn_type)
-		    && (conn_type != SELECT_NAV)) {
+		if ((request->conn_type != bg_record->conn_type)
+		    && (request->conn_type != SELECT_NAV)) {
 			debug("bg block %s conn-type not usable asking for %s "
-			      "record is %s", 
-			      record->bg_block_id,
-			      convert_conn_type(conn_type),
-			      convert_conn_type(record->conn_type));
+			      "bg_record is %s", 
+			      bg_record->bg_block_id,
+			      convert_conn_type(request->conn_type),
+			      convert_conn_type(bg_record->conn_type));
 			continue;
 		} 
 
 		/*****************************************/
 		/* match up geometry as "best" possible  */
 		/*****************************************/
-		if (req_geometry[X] == (uint16_t)NO_VAL)
+		if (request->geometry[X] == (uint16_t)NO_VAL)
 			;	/* Geometry not specified */
 		else {	/* match requested geometry */
 			bool match = false;
-			rot_cnt = 0;	/* attempt six rotations  */
+			int rot_cnt = 0;	/* attempt six rotations  */
 			
 			for (rot_cnt=0; rot_cnt<6; rot_cnt++) {		
-				if ((record->geo[X] >= req_geometry[X])
-				&&  (record->geo[Y] >= req_geometry[Y])
-				&&  (record->geo[Z] >= req_geometry[Z])) {
+				if ((bg_record->geo[X] >= request->geometry[X])
+				    && (bg_record->geo[Y]
+					>= request->geometry[Y])
+				    && (bg_record->geo[Z]
+					>= request->geometry[Z])) {
 					match = true;
 					break;
 				}
-				if (!rotate) {
+				if (!request->rotate) 
 					break;
-				}
-				_rotate_geo(req_geometry, rot_cnt);
+				
+				_rotate_geo((uint16_t *)request->geometry,
+					    rot_cnt);
 			}
-
+			
 			if (!match) 
 				continue;	/* Not usable */
 		}
-		*found_bg_record = record;
-		debug2("we found one! %s", (*found_bg_record)->bg_block_id);
+		debug2("we found one! %s", bg_record->bg_block_id);
 		break;
 	}
 	list_iterator_destroy(itr);
-
-	/* set the bitmap and do other allocation activities */
-	if (*found_bg_record) {
-		if(!test_only) {
-			if(check_block_bp_states(
-				   (*found_bg_record)->bg_block_id) 
-			   == SLURM_ERROR) {
-				error("_find_best_block_match: Marking "
-				      "block %s in an error state "
-				      "because of bad bps.",
-				      (*found_bg_record)->bg_block_id);
-				(*found_bg_record)->job_running =
-					BLOCK_ERROR_STATE;
-				(*found_bg_record)->state = RM_PARTITION_ERROR;
-				slurm_mutex_unlock(&block_state_mutex);
-				trigger_block_error();
-				goto try_again;
-			}
-		}
-		format_node_name(*found_bg_record, tmp_char, sizeof(tmp_char));
 	
-		debug("_find_best_block_match %s <%s>", 
-			(*found_bg_record)->bg_block_id, 
-			tmp_char);
-		bit_and(slurm_block_bitmap, (*found_bg_record)->bitmap);
-		slurm_mutex_unlock(&block_state_mutex);
-		rc = SLURM_SUCCESS;
-		goto end_it;
-	}
+	return bg_record;
+}
 
-	/* see if we can just reset the image and reboot the block */
-	if(allow) {
-		check_image = 0;
-		allow = 0;
-		slurm_mutex_unlock(&block_state_mutex);
-		goto try_again;
-	}
+static int _check_for_booted_overlapping_blocks(
+	List block_list, ListIterator bg_record_itr,
+	bg_record_t *bg_record, int overlap_check, List overlapped_list,
+	bool test_only)
+{
+	bg_record_t *found_record = NULL;
+	ListIterator itr = NULL;
+	int rc = 0;
 
-	check_image = 1;
-	/* all these assume that the *found_bg_record is NULL */
-	if(bluegene_layout_mode == LAYOUT_OVERLAP && !test_only && created<2) {
-		created++;
-		slurm_mutex_unlock(&block_state_mutex);
-		goto try_again;
-	}
+	 /* this test only is for actually picking a block not testing */
+	if(test_only && bluegene_layout_mode == LAYOUT_DYNAMIC)
+		return rc;
+
+	/* Make sure no other blocks are under this block 
+	   are booted and running jobs
+	*/
+	itr = list_iterator_create(block_list);
+	while ((found_record = (bg_record_t*)list_next(itr)) != NULL) {
+		if ((!found_record->bg_block_id)
+		    || (bg_record == found_record)) {
+			debug4("Don't need to look at myself %s %s",
+			       bg_record->bg_block_id,
+			       found_record->bg_block_id);
+			continue;
+		}
 		
-	slurm_mutex_unlock(&block_state_mutex);
-	if(bluegene_layout_mode != LAYOUT_DYNAMIC)
-		goto not_dynamic;
-	
-	if(test_only) {
-		for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-			request.start[i] = start[i];
-			
-		for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-			request.geometry[i] = req_geometry[i];
-			
-		request.save_name = NULL;
-		request.elongate_geos = NULL;
-		request.size = target_size;
-		request.procs = req_procs;
-		request.conn_type = conn_type;
-		request.rotate = rotate;
-		request.elongate = true;
-		request.start_req = start_req;
-		request.blrtsimage = blrtsimage;
-		request.linuximage = linuximage;
-		request.mloaderimage = mloaderimage;
-		request.ramdiskimage = ramdiskimage;
-		if(job_ptr->details->req_node_bitmap) 
-			request.avail_node_bitmap = 
-				job_ptr->details->req_node_bitmap;
-		else
-			request.avail_node_bitmap = slurm_block_bitmap;
-
-		debug("trying with all free blocks");
-		if(create_dynamic_block(&request, NULL) == SLURM_ERROR) {
-			error("this job will never run on "
-			      "this system");
-			xfree(request.save_name);
-			rc = SLURM_ERROR;
-			goto end_it;
-		} else {
-			if(!request.save_name) {
-				error("no name returned from "
-				      "create_dynamic_block");
-				rc = SLURM_ERROR;
-				goto end_it;
+		if(blocks_overlap(bg_record, found_record)) {
+			/* make the available time on this block
+			 * (bg_record) the max of this found_record's job
+			 * or the one already set if in overlapped_block_list
+			 * since we aren't setting job_running we
+			 * don't have to remove them since the
+			 * block_list should always be destroyed afterwards.
+			 */
+			if(test_only && overlapped_list
+			   && found_record->job_ptr 
+			   && bg_record->job_running == NO_JOB_RUNNING) {
+				debug2("found over lapping block %s "
+				       "overlapped %s with job %u",
+				       found_record->bg_block_id,
+				       bg_record->bg_block_id,
+				       found_record->job_ptr->job_id);
+				ListIterator itr = list_iterator_create(
+					overlapped_list);
+				bg_record_t *tmp_rec = NULL;
+				while((tmp_rec = list_next(itr))) {
+					if(tmp_rec == bg_record)
+						break;
+				}
+				list_iterator_destroy(itr);
+				if(tmp_rec && tmp_rec->job_ptr->end_time 
+				   < found_record->job_ptr->end_time)
+					tmp_rec->job_ptr =
+						found_record->job_ptr;
+				else if(!tmp_rec) {
+					bg_record->job_ptr =
+						found_record->job_ptr;
+					list_append(overlapped_list,
+						    bg_record);
+				}
+			}
+			/* We already know this block doesn't work
+			 * right now so we will if there is another
+			 * overlapping block that ends later
+			 */
+			if(rc)
+				continue;
+			/* This test is here to check if the block we
+			 * chose is not booted or if there is a block
+			 * overlapping that we could avoid freeing if
+			 * we choose something else
+			 */
+			if(bluegene_layout_mode == LAYOUT_OVERLAP
+			   && ((overlap_check == 0 && bg_record->state 
+				!= RM_PARTITION_READY)
+			       || (overlap_check == 1 && found_record->state 
+				   != RM_PARTITION_FREE))) {
+
+				if(!test_only) {
+					rc = 1;
+					break;
+				}
+			}
+
+			if(found_record->job_running != NO_JOB_RUNNING) {
+				if(found_record->job_running
+				   == BLOCK_ERROR_STATE)
+					error("can't use %s, "
+					      "overlapping block %s "
+					      "is in an error state.",
+					      bg_record->bg_block_id,
+					      found_record->bg_block_id);
+				else
+					debug("can't use %s, there is "
+					      "a job (%d) running on "
+					      "an overlapping "
+					      "block %s", 
+					      bg_record->bg_block_id,
+					      found_record->job_running,
+					      found_record->bg_block_id);
+				
+				if(bluegene_layout_mode == LAYOUT_DYNAMIC) {
+					/* this will remove and
+					 * destroy the memory for
+					 * bg_record
+					*/
+					list_remove(bg_record_itr);
+					if(bg_record->original) {
+						debug3("This was a copy");
+						found_record =
+							bg_record->original;
+						remove_from_bg_list(
+							bg_list, found_record);
+					} else {
+						debug("looking for original");
+						found_record =
+							find_and_remove_org_from_bg_list(
+								bg_list,
+								bg_record);
+					}
+					destroy_bg_record(bg_record);
+					if(!found_record) {
+						error("1 this record wasn't "
+						      "found in the list!");
+						//rc = SLURM_ERROR;
+					} else {
+						List temp_list =
+							list_create(NULL);
+						list_push(temp_list, 
+							  found_record);
+						num_block_to_free++;
+						free_block_list(temp_list);
+						list_destroy(temp_list);
+					}
+				} 
+				rc = 1;
+					
+				if(!test_only) 
+					break;
 			} 
+		} 
+	}
+	list_iterator_destroy(itr);
+
+	return rc;
+}
+
+/*
+ *
+ * Return SLURM_SUCCESS on successful create, SLURM_ERROR for no create 
+ */
 
-			slurm_conf_lock();
-			snprintf(tmp_char, sizeof(tmp_char), "%s%s", 
-				 slurmctld_conf.node_prefix,
-				 request.save_name);
-			slurm_conf_unlock();
-			if (node_name2bitmap(tmp_char, 
-					     false, 
-					     &tmp_bitmap)) {
-				fatal("Unable to convert nodes %s to bitmap", 
-				      tmp_char);
+static int _dynamically_request(List block_list, int *blocks_added,
+				ba_request_t *request,
+				bitstr_t* slurm_block_bitmap,
+				char *user_req_nodes)
+{
+	List list_of_lists = NULL;
+	List temp_list = NULL;
+	List new_blocks = NULL;
+	ListIterator itr = NULL;
+	int rc = SLURM_ERROR;
+	int create_try = 0;
+	int start_geo[BA_SYSTEM_DIMENSIONS];
+	
+	memcpy(start_geo, request->geometry, sizeof(int)*BA_SYSTEM_DIMENSIONS);
+	debug2("going to create %d", request->size);
+	list_of_lists = list_create(NULL);
+	
+	if(user_req_nodes) 
+		list_append(list_of_lists, job_block_test_list);
+	else {
+		list_append(list_of_lists, block_list);
+		if(job_block_test_list == bg_job_block_list &&
+		   list_count(block_list) != list_count(bg_booted_block_list)) {
+			list_append(list_of_lists, bg_booted_block_list);
+			if(list_count(bg_booted_block_list) 
+			   != list_count(job_block_test_list)) 
+				list_append(list_of_lists, job_block_test_list);
+		} else if(list_count(block_list) 
+			  != list_count(job_block_test_list)) {
+			list_append(list_of_lists, job_block_test_list);
+		}
+	}
+	itr = list_iterator_create(list_of_lists);
+	while ((temp_list = (List)list_next(itr))) {
+		create_try++;
+		
+		/* 1- try empty space
+		   2- we see if we can create one in the 
+		   unused bps
+		   3- see if we can create one in the non 
+		   job running bps
+		*/
+		debug("trying with %d", create_try);
+		if((new_blocks = create_dynamic_block(block_list,
+						      request, temp_list))) {
+			bg_record_t *bg_record = NULL;
+			while((bg_record = list_pop(new_blocks))) {
+				if(block_exist_in_list(block_list, bg_record))
+					destroy_bg_record(bg_record);
+				else {
+					if(job_block_test_list 
+					   == bg_job_block_list) {
+						if(configure_block(bg_record)
+						   == SLURM_ERROR) {
+							destroy_bg_record(
+								bg_record);
+							error("_dynamically_"
+							      "request: "
+							      "unable to "
+							      "configure "
+							      "block");
+							rc = SLURM_ERROR;
+							break;
+						}
+					}
+					list_append(block_list, bg_record);
+					print_bg_record(bg_record);
+					(*blocks_added) = 1;
+				}
 			}
-			
-			bit_and(slurm_block_bitmap, tmp_bitmap);
-			FREE_NULL_BITMAP(tmp_bitmap);
-			xfree(request.save_name);
+			list_destroy(new_blocks);
+			if(!*blocks_added) {
+				memcpy(request->geometry, start_geo,      
+				       sizeof(int)*BA_SYSTEM_DIMENSIONS); 
+				rc = SLURM_ERROR;
+				continue;
+			}
+			list_sort(block_list,
+				  (ListCmpF)_bg_record_sort_aval_dec);
+	
 			rc = SLURM_SUCCESS;
-			goto end_it;
+			break;
+		} else if (errno == ESLURM_INTERCONNECT_FAILURE) {
+			rc = SLURM_ERROR;
+			break;
+		} 
+
+		memcpy(request->geometry, start_geo,
+		       sizeof(int)*BA_SYSTEM_DIMENSIONS);
+	
+	}
+	list_iterator_destroy(itr);
+
+	if(list_of_lists)
+		list_destroy(list_of_lists);
+
+	return rc;
+}
+/*
+ * finds the best match for a given job request 
+ * 
+ * 
+ * OUT - block_id of matched block, NULL otherwise
+ * returns 1 for error (no match)
+ * 
+ */
+static int _find_best_block_match(List block_list, 
+				  int *blocks_added,
+				  struct job_record* job_ptr, 
+				  bitstr_t* slurm_block_bitmap,
+				  uint32_t min_nodes, uint32_t max_nodes,
+				  uint32_t req_nodes,
+				  bg_record_t** found_bg_record, 
+				  bool test_only)
+{
+	bg_record_t *bg_record = NULL;
+	uint16_t req_geometry[BA_SYSTEM_DIMENSIONS];
+	uint16_t start[BA_SYSTEM_DIMENSIONS];
+	uint16_t conn_type, rotate, target_size = 0;
+	uint32_t req_procs = job_ptr->num_procs;
+	ba_request_t request; 
+	int i;
+	int overlap_check = 0;
+	int allow = 0;
+	int check_image = 1;
+	uint32_t max_procs = (uint32_t)NO_VAL;
+	char tmp_char[256];
+	int start_req = 0;
+	static int total_cpus = 0;
+	char *blrtsimage = NULL;        /* BlrtsImage for this request */
+	char *linuximage = NULL;        /* LinuxImage for this request */
+	char *mloaderimage = NULL;      /* mloaderImage for this request */
+	char *ramdiskimage = NULL;      /* RamDiskImage for this request */
+	int rc = SLURM_SUCCESS;
+	int create_try = 0;
+	List overlapped_list = NULL;
+
+	if(!total_cpus)
+		total_cpus = DIM_SIZE[X] * DIM_SIZE[Y] * DIM_SIZE[Z] 
+			* procs_per_node;
+
+	if(req_nodes > max_nodes) {
+		error("can't run this job max bps is %u asking for %u",
+		      max_nodes, req_nodes);
+		return SLURM_ERROR;
+	}
+
+	if(!test_only && req_procs > num_unused_cpus) {
+		debug2("asking for %u I only got %d", 
+		       req_procs, num_unused_cpus);
+		return SLURM_ERROR;
+	}
+
+	if(!block_list) {
+		error("_find_best_block_match: There is no block_list");
+		return SLURM_ERROR;
+	}
+	
+	select_g_get_jobinfo(job_ptr->select_jobinfo,
+			     SELECT_DATA_START, &start);
+		
+	if(start[X] != (uint16_t)NO_VAL)
+		start_req = 1;
+
+	select_g_get_jobinfo(job_ptr->select_jobinfo,
+			     SELECT_DATA_CONN_TYPE, &conn_type);
+	select_g_get_jobinfo(job_ptr->select_jobinfo,
+			     SELECT_DATA_GEOMETRY, &req_geometry);
+	select_g_get_jobinfo(job_ptr->select_jobinfo,
+			     SELECT_DATA_ROTATE, &rotate);
+	select_g_get_jobinfo(job_ptr->select_jobinfo,
+			     SELECT_DATA_MAX_PROCS, &max_procs);
+
+	
+	if((rc = _check_images(job_ptr, &blrtsimage, &linuximage,
+			       &mloaderimage, &ramdiskimage)) == SLURM_ERROR)
+		goto end_it;
+	
+	if(req_geometry[X] != 0 && req_geometry[X] != (uint16_t)NO_VAL) {
+		target_size = 1;
+		for (i=0; i<BA_SYSTEM_DIMENSIONS; i++)
+			target_size *= (uint16_t)req_geometry[i];
+		if(target_size != min_nodes) {
+			debug2("min_nodes not set correctly %u should be %u "
+			      "from %u%u%u",
+			      min_nodes, target_size, 
+			      req_geometry[X],
+			      req_geometry[Y],
+			      req_geometry[Z]);
+			min_nodes = target_size;
 		}
-	} else if(!created) {
-		debug2("going to create %d", target_size);
-		lists_of_lists = list_create(NULL);
-		if(job_ptr->details->req_nodes) {
-			list_append(lists_of_lists, bg_job_block_list);
+		if(!req_nodes)
+			req_nodes = min_nodes;
+	}
+	if (target_size == 0) {	/* no geometry specified */
+		if(job_ptr->details->req_nodes 
+		   && !start_req) {
+			bg_record_t *tmp_record = NULL;
+			char *tmp_nodes= job_ptr->details->req_nodes;
+			int len = strlen(tmp_nodes);
+			
+			i = 0;
+			while(i<len 
+			      && tmp_nodes[i] != '[' 
+			      && (tmp_nodes[i] < '0' || tmp_nodes[i] > 'Z'
+				  || (tmp_nodes[i] > '9'
+				      && tmp_nodes[i] < 'A')))
+				i++;
+			
+			if(i<len) {
+				len -= i;
+				tmp_record = xmalloc(sizeof(bg_record_t));
+				tmp_record->bg_block_list =
+					list_create(destroy_ba_node);
+				slurm_conf_lock();
+				len += strlen(slurmctld_conf.node_prefix)+1;
+				tmp_record->nodes = xmalloc(len);
+				
+				snprintf(tmp_record->nodes,
+					 len,
+					 "%s%s", 
+					 slurmctld_conf.node_prefix, 
+					 tmp_nodes+i);
+				slurm_conf_unlock();
+			
+				process_nodes(tmp_record, false);
+				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) {
+					req_geometry[i] = tmp_record->geo[i];
+					start[i] = tmp_record->start[i];
+				}
+				destroy_bg_record(tmp_record);
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
+						     SELECT_DATA_GEOMETRY, 
+						     &req_geometry);
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
+						     SELECT_DATA_START, 
+						     &start);
+				start_req = 1;
+			}  else 
+				error("BPs=%s is in a weird format", 
+				      tmp_nodes); 
 		} else {
-			list_append(lists_of_lists, bg_list);
-			if(list_count(bg_list)
-			   != list_count(bg_booted_block_list)) {
-				list_append(lists_of_lists, 
-					    bg_booted_block_list);
-				if(list_count(bg_booted_block_list) 
-				   != list_count(bg_job_block_list)) 
-					list_append(lists_of_lists, 
-						    bg_job_block_list);
-			} else if(list_count(bg_list) 
-				  != list_count(bg_job_block_list)) 
-				list_append(lists_of_lists, bg_job_block_list);
+			req_geometry[X] = (uint16_t)NO_VAL;
 		}
-		itr = list_iterator_create(lists_of_lists);
-		while ((temp_list = (List)list_next(itr))) {
-			created++;
+		target_size = min_nodes;
+	}
+	
+	*found_bg_record = NULL;
+	allow = 0;
 
-			for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-				request.start[i] = start[i];
+	for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+		request.start[i] = start[i];
+	
+	for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+		request.geometry[i] = req_geometry[i];
+	
+	request.save_name = NULL;
+	request.elongate_geos = NULL;
+	request.size = target_size;
+	request.procs = req_procs;
+	request.conn_type = conn_type;
+	request.rotate = rotate;
+	request.elongate = true;
+	request.start_req = start_req;
+	request.blrtsimage = blrtsimage;
+	request.linuximage = linuximage;
+	request.mloaderimage = mloaderimage;
+	request.ramdiskimage = ramdiskimage;
+	if(job_ptr->details->req_node_bitmap) 
+		request.avail_node_bitmap = 
+			job_ptr->details->req_node_bitmap;
+	else
+		request.avail_node_bitmap = slurm_block_bitmap;
+
+	select_g_get_jobinfo(job_ptr->select_jobinfo,
+			     SELECT_DATA_MAX_PROCS, &max_procs);
+	/* since we only look at procs after this and not nodes we
+	 *  need to set a max_procs if given
+	 */
+	if(max_procs == (uint32_t)NO_VAL) 
+		max_procs = max_nodes * procs_per_node;
+	
+	while(1) {
+		/* Here we are creating a list of all the blocks that
+		 * have overlapped jobs so if we don't find one that
+		 * works we will have can look and see the earliest
+		 * the job can start.  This doesn't apply to Dynamic mode.
+		 */ 
+		if(test_only && bluegene_layout_mode != LAYOUT_DYNAMIC) 
+			overlapped_list = list_create(NULL);
+		
+		bg_record = _find_matching_block(block_list, 
+						 job_ptr,
+						 slurm_block_bitmap,
+						 &request,
+						 max_procs,
+						 allow, check_image,
+						 overlap_check, 
+						 overlapped_list,
+						 test_only);
+		if(!bg_record && test_only
+		   && bluegene_layout_mode != LAYOUT_DYNAMIC
+		   && list_count(overlapped_list)) {
+			ListIterator itr =
+				list_iterator_create(overlapped_list);
+			bg_record_t *tmp_rec = NULL;
+			while((tmp_rec = list_next(itr))) {
+				if(!bg_record || 
+				   (tmp_rec->job_ptr->end_time <
+				    bg_record->job_ptr->end_time))
+					bg_record = tmp_rec;
+			}
+			list_iterator_destroy(itr);
+		}
+		
+		if(test_only && bluegene_layout_mode != LAYOUT_DYNAMIC)
+			list_destroy(overlapped_list);
+
+		/* set the bitmap and do other allocation activities */
+		if (bg_record) {
+			if(!test_only) {
+				if(check_block_bp_states(
+					   bg_record->bg_block_id) 
+				   == SLURM_ERROR) {
+					error("_find_best_block_match: Marking "
+					      "block %s in an error state "
+					      "because of bad bps.",
+					      bg_record->bg_block_id);
+					bg_record->job_running =
+						BLOCK_ERROR_STATE;
+					bg_record->state = RM_PARTITION_ERROR;
+					trigger_block_error();
+					continue;
+				}
+			}
+			format_node_name(bg_record, tmp_char, sizeof(tmp_char));
 			
+			debug("_find_best_block_match %s <%s>", 
+			      bg_record->bg_block_id, 
+			      tmp_char);
+			bit_and(slurm_block_bitmap, bg_record->bitmap);
+			rc = SLURM_SUCCESS;
+			*found_bg_record = bg_record;
+			goto end_it;
+		} else {
+			/* this gets altered in _find_matching_block so we
+			   reset it */
 			for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
 				request.geometry[i] = req_geometry[i];
+		}
+		
+		/* see if we can just reset the image and reboot the block */
+		if(allow) {
+			check_image = 0;
+			allow = 0;
+			continue;
+		}
+		
+		check_image = 1;
+
+		/* all these assume that the *bg_record is NULL */
+
+		if(bluegene_layout_mode == LAYOUT_OVERLAP
+		   && !test_only && overlap_check < 2) {
+			overlap_check++;
+			continue;
+		}
+		
+		if(create_try || bluegene_layout_mode != LAYOUT_DYNAMIC)
+			goto no_match;
+		
+		if((rc = _dynamically_request(block_list, blocks_added,
+					      &request, 
+					      slurm_block_bitmap, 
+					      job_ptr->details->req_nodes))
+		   == SLURM_SUCCESS) {
+			create_try = 1;
+			continue;
+		}
 			
-			request.save_name = NULL;
-			request.elongate_geos = NULL;
-			request.size = target_size;
-			request.procs = req_procs;
-			request.conn_type = conn_type;
-			request.rotate = rotate;
-			request.elongate = true;
-			request.start_req = start_req;
-			request.blrtsimage = blrtsimage;
-			request.linuximage = linuximage;
-			request.mloaderimage = mloaderimage;
-			request.ramdiskimage = ramdiskimage;
-			if(job_ptr->details->req_node_bitmap) 
-				request.avail_node_bitmap = 
-					job_ptr->details->req_node_bitmap;
+
+		if(test_only) {
+			List new_blocks = NULL;
+			List job_list = NULL;
+			debug("trying with empty machine");
+			slurm_mutex_lock(&block_state_mutex);
+			if(job_block_test_list == bg_job_block_list) 
+				job_list = copy_bg_list(job_block_test_list);
 			else
-				request.avail_node_bitmap = slurm_block_bitmap;
-			
-			/* 1- try empty space
-			   2- we see if we can create one in the 
-			   unused bps
-			   3- see if we can create one in the non 
-			   job running bps
-			*/
-			debug("trying with %d", created);
-			if(create_dynamic_block(&request, temp_list) 
-			   == SLURM_SUCCESS) {
-				list_iterator_destroy(itr);
-				list_destroy(lists_of_lists);
-				lists_of_lists = NULL;
-				goto try_again;
+				job_list = job_block_test_list;
+			slurm_mutex_unlock(&block_state_mutex);
+			list_sort(job_list, (ListCmpF)_bg_record_sort_aval_inc);
+			while(1) {
+				/* this gets altered in
+				 * create_dynamic_block so we reset it */
+				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+					request.geometry[i] = req_geometry[i];
+
+				bg_record = list_pop(job_list);
+				if(bg_record)
+					debug2("taking off %d(%s) started at %d ends at %d",
+					       bg_record->job_running,
+					       bg_record->bg_block_id,
+					       bg_record->job_ptr->start_time,
+					       bg_record->job_ptr->end_time);
+				if(!(new_blocks = create_dynamic_block(
+					     block_list, &request, job_list))) {
+					destroy_bg_record(bg_record);
+					if(errno == ESLURM_INTERCONNECT_FAILURE
+					   || !list_count(job_list)) {
+						error("this job will never "
+						      "run on this system");
+						break;
+					}
+					continue;
+				}
+				rc = SLURM_SUCCESS;
+				/* outside of the job_test_list this
+				 * gets destroyed later, so don't worry
+				 * about it now 
+				 */
+				(*found_bg_record) = list_pop(new_blocks);
+				bit_and(slurm_block_bitmap,
+					(*found_bg_record)->bitmap);
+
+				if(bg_record) {
+					(*found_bg_record)->job_ptr 
+						= bg_record->job_ptr; 
+					destroy_bg_record(bg_record);
+				}
+					
+				if(job_block_test_list != bg_job_block_list) {
+					list_append(block_list,
+						    (*found_bg_record));
+					while((bg_record = 
+					       list_pop(new_blocks))) {
+						if(block_exist_in_list(
+							   block_list,
+							   bg_record))
+							destroy_bg_record(
+								bg_record);
+						else {
+							list_append(block_list,
+								    bg_record);
+//					print_bg_record(bg_record);
+						}
+					}
+				} 
+					
+				list_destroy(new_blocks);
+				break;
 			}
+
+			if(job_block_test_list == bg_job_block_list) 
+				list_destroy(job_list);
+
+			goto end_it;
+		} else {
+			break;
 		}
-		list_iterator_destroy(itr);
-		if(lists_of_lists)
-			list_destroy(lists_of_lists);
 	}
-not_dynamic:
+
+no_match:
 	debug("_find_best_block_match none found");
 	rc = SLURM_ERROR;
 
@@ -793,6 +1160,43 @@ end_it:
 	return rc;
 }
 
+
+static int _sync_block_lists(List full_list, List incomp_list)
+{
+	ListIterator itr;
+	ListIterator itr2;
+	bg_record_t *bg_record = NULL;
+	bg_record_t *new_record = NULL;
+	int count = 0;
+
+	itr = list_iterator_create(full_list);
+	itr2 = list_iterator_create(incomp_list);
+	while((new_record = list_next(itr))) {
+		while((bg_record = list_next(itr2))) {
+			if(bit_equal(bg_record->bitmap, new_record->bitmap)
+			   && bit_equal(bg_record->ionode_bitmap,
+					new_record->ionode_bitmap))
+				break;
+		} 
+
+		if(!bg_record) {
+			bg_record = xmalloc(sizeof(bg_record_t));
+			copy_bg_record(new_record, bg_record);
+			debug4("adding %s", bg_record->bg_block_id);
+			list_append(incomp_list, bg_record);
+			count++;
+		} 
+		list_iterator_reset(itr2);
+	}
+	list_iterator_destroy(itr);
+	list_iterator_destroy(itr2);
+	sort_bg_record_inc_size(incomp_list);
+
+	return count;
+}
+
+#endif // HAVE_BG
+
 /*
  * Try to find resources for a given job request
  * IN job_ptr - pointer to job record in slurmctld
@@ -800,20 +1204,37 @@ end_it:
  *	be used
  * IN min_nodes, max_nodes  - minimum and maximum number of nodes to allocate
  *	to this job (considers slurm block limits)
- * IN test_only - if true, only test if ever could run, not necessarily now
+ * IN mode - SELECT_MODE_RUN_NOW: try to schedule job now
+ *           SELECT_MODE_TEST_ONLY: test if job can ever run
+ *           SELECT_MODE_WILL_RUN: determine when and where job can run
  * RET - SLURM_SUCCESS if job runnable now, error code otherwise
  */
 extern int submit_job(struct job_record *job_ptr, bitstr_t *slurm_block_bitmap,
-		      uint32_t min_nodes, uint32_t max_nodes, uint32_t req_nodes, 
-		      bool test_only)
+		      uint32_t min_nodes, uint32_t max_nodes,
+		      uint32_t req_nodes, int mode)
 {
-	int spec = 1; /* this will be like, keep TYPE a priority, etc,  */
-	bg_record_t* record = NULL;
+	int rc = SLURM_SUCCESS;
+#ifdef HAVE_BG
+	int i=0;
+	bg_record_t* bg_record = NULL;
 	char buf[100];
-	int i, rc = SLURM_SUCCESS;
-	uint16_t geo[BA_SYSTEM_DIMENSIONS];
 	uint16_t tmp16 = (uint16_t)NO_VAL;
-	
+	List block_list = NULL;
+	int blocks_added = 0;
+	int starttime = time(NULL);
+	bool test_only;
+
+	if (mode == SELECT_MODE_TEST_ONLY || mode == SELECT_MODE_WILL_RUN)
+		test_only = true;
+	else if (mode == SELECT_MODE_RUN_NOW)
+		test_only = false;
+	else	
+		return EINVAL;	/* something not yet supported */
+
+	if(bluegene_layout_mode == LAYOUT_DYNAMIC)
+		slurm_mutex_lock(&create_dynamic_mutex);
+
+	job_block_test_list = bg_job_block_list;
 	
 	select_g_sprint_jobinfo(job_ptr->select_jobinfo, buf, sizeof(buf), 
 				SELECT_PRINT_MIXED);
@@ -832,71 +1253,323 @@ extern int submit_job(struct job_record *job_ptr, bitstr_t *slurm_block_bitmap,
 				SELECT_PRINT_RAMDISK_IMAGE);
 	debug2("RamDiskImage=%s", buf);
 	
-	if(bluegene_layout_mode == LAYOUT_DYNAMIC)
-		slurm_mutex_lock(&create_dynamic_mutex);
+	slurm_mutex_lock(&block_state_mutex);
+	block_list = copy_bg_list(bg_list);
+	slurm_mutex_unlock(&block_state_mutex);
 	
-	rc = _find_best_block_match(job_ptr, slurm_block_bitmap, min_nodes, 
-				    max_nodes, req_nodes, spec, 
-				    &record, test_only);
+	list_sort(block_list, (ListCmpF)_bg_record_sort_aval_dec);
+
+	rc = _find_best_block_match(block_list, &blocks_added,
+				    job_ptr, slurm_block_bitmap, min_nodes, 
+				    max_nodes, req_nodes,  
+				    &bg_record, test_only);
 	
 	if(rc == SLURM_SUCCESS) {
-		if(!record) {
-			debug2("can run, but block not made");
+		if(bg_record) {
+			/* Here we see if there is a job running since
+			 * some jobs take awhile to finish we need to
+			 * make sure the time of the end is in the
+			 * future.  If it isn't (meaning it is in the
+			 * past or current time) we add 5 seconds to
+			 * it so we don't use the block immediately.
+			 */
+			if(bg_record->job_ptr 
+			   && bg_record->job_ptr->end_time) { 
+				if(bg_record->job_ptr->end_time <= starttime)
+					starttime += 5;
+				else
+					starttime =
+						bg_record->job_ptr->end_time;
+			}
+						
+			job_ptr->start_time = starttime;
+			
+			select_g_set_jobinfo(job_ptr->select_jobinfo,
+					     SELECT_DATA_NODES, 
+					     bg_record->nodes);
 			select_g_set_jobinfo(job_ptr->select_jobinfo,
+					     SELECT_DATA_IONODES, 
+					     bg_record->ionodes);
+			
+			if(!bg_record->bg_block_id) {
+				uint16_t geo[BA_SYSTEM_DIMENSIONS];
+				
+				debug2("%d can start job at "
+				       "%u on %s on unmade block",
+				       test_only, starttime,
+				       bg_record->nodes);
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
 					     SELECT_DATA_BLOCK_ID,
 					     "unassigned");
-			if(job_ptr->num_procs < bluegene_bp_node_cnt 
-				&& job_ptr->num_procs > 0) {
-				i = procs_per_node/job_ptr->num_procs;
-				debug2("divide by %d", i);
-			} else 
-				i = 1;
-			min_nodes *= bluegene_bp_node_cnt/i;
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
+				if(job_ptr->num_procs < bluegene_bp_node_cnt 
+				   && job_ptr->num_procs > 0) {
+					i = procs_per_node/job_ptr->num_procs;
+					debug2("divide by %d", i);
+				} else 
+					i = 1;
+				min_nodes *= bluegene_bp_node_cnt/i;
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
 					     SELECT_DATA_NODE_CNT,
 					     &min_nodes);
-			
-			for(i=0; i<BA_SYSTEM_DIMENSIONS; i++)
-				geo[i] = 0;
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
-					     SELECT_DATA_GEOMETRY, 
-					     &geo);
-			
-		} else {
-			slurm_mutex_lock(&block_state_mutex);
+				memset(geo, 0, 
+				       sizeof(uint16_t) * BA_SYSTEM_DIMENSIONS);
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
+						     SELECT_DATA_GEOMETRY, 
+						     &geo);
+				/* This is a fake record so we need to
+				 * destroy it after we get the info from
+				 * it */
+				destroy_bg_record(bg_record);
+			} else {
+				if((bg_record->ionodes)
+				   && (job_ptr->part_ptr->max_share <= 1))
+					error("Small block used in "
+					      "non-shared partition");
+				
+				debug2("%d can start job at %u on %s",
+				       test_only, starttime,
+				       bg_record->nodes);
 
-			if((record->ionodes)
-			   && (job_ptr->part_ptr->shared == 0))
-				error("Small block used in "
-				      "non-shared partition");
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
+						     SELECT_DATA_BLOCK_ID,
+						     bg_record->bg_block_id);
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
+						     SELECT_DATA_NODE_CNT, 
+						     &bg_record->node_cnt);
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
+						     SELECT_DATA_GEOMETRY, 
+						     &bg_record->geo);
 
-			/* set the block id and info about block */
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
-					     SELECT_DATA_BLOCK_ID, 
-					     record->bg_block_id);
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
-					     SELECT_DATA_IONODES, 
-					     record->ionodes);
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
-					     SELECT_DATA_NODE_CNT, 
-					     &record->node_cnt);
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
-					     SELECT_DATA_GEOMETRY, 
-					     &record->geo);
-			tmp16 = record->conn_type;
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
-					     SELECT_DATA_CONN_TYPE, 
-					     &tmp16);
-			slurm_mutex_unlock(&block_state_mutex);
+				tmp16 = bg_record->conn_type;
+				select_g_set_jobinfo(job_ptr->select_jobinfo,
+						     SELECT_DATA_CONN_TYPE, 
+						     &tmp16);
+			}
+		} else {
+			error("we got a success, but no block back");
 		}
-		if(test_only) {
-			select_g_set_jobinfo(job_ptr->select_jobinfo,
-					     SELECT_DATA_BLOCK_ID,
-					     "unassigned");
-		} 
 	}
+
+	if(bluegene_layout_mode == LAYOUT_DYNAMIC) {		
+		slurm_mutex_lock(&block_state_mutex);
+		if(blocks_added) 
+			_sync_block_lists(block_list, bg_list);		
+		slurm_mutex_unlock(&block_state_mutex);
+		slurm_mutex_unlock(&create_dynamic_mutex);
+	}
+
+	list_destroy(block_list);
+#endif
+	return rc;
+}
+
+extern int test_job_list(List req_list)
+{
+	int rc = SLURM_SUCCESS;
+#ifdef HAVE_BG
+	bg_record_t* bg_record = NULL;
+	bg_record_t* new_record = NULL;
+	char buf[100];
+//	uint16_t tmp16 = (uint16_t)NO_VAL;
+	List block_list = NULL;
+	int blocks_added = 0;
+	int starttime = time(NULL);
+	ListIterator itr = NULL;
+	select_will_run_t *will_run = NULL;
+
+	slurm_mutex_lock(&job_list_test_mutex);
+	
 	if(bluegene_layout_mode == LAYOUT_DYNAMIC)
+		slurm_mutex_lock(&create_dynamic_mutex);
+
+	job_block_test_list = copy_bg_list(bg_job_block_list);
+
+	slurm_mutex_lock(&block_state_mutex);
+	block_list = copy_bg_list(bg_list);
+	slurm_mutex_unlock(&block_state_mutex);
+
+	itr = list_iterator_create(req_list);
+	while((will_run = list_next(itr))) {
+		if(!will_run->job_ptr) {
+			error("test_job_list: you need to give me a job_ptr");
+			rc = SLURM_ERROR;
+			break;
+		}
+		
+		select_g_sprint_jobinfo(will_run->job_ptr->select_jobinfo,
+					buf, sizeof(buf), 
+					SELECT_PRINT_MIXED);
+		debug("bluegene:submit_job_list: %s nodes=%u-%u-%u", 
+		      buf, will_run->min_nodes,
+		      will_run->req_nodes, will_run->max_nodes);
+		list_sort(block_list, (ListCmpF)_bg_record_sort_aval_dec);
+		rc = _find_best_block_match(block_list, &blocks_added,
+					    will_run->job_ptr,
+					    will_run->avail_nodes,
+					    will_run->min_nodes, 
+					    will_run->max_nodes,
+					    will_run->req_nodes, 
+					    &bg_record, true);
+		
+		if(rc == SLURM_SUCCESS) {
+			if(bg_record) {
+				if(bg_record->job_ptr
+				   && bg_record->job_ptr->end_time) {
+					starttime =
+						bg_record->job_ptr->end_time;
+				}
+				bg_record->job_running =
+					will_run->job_ptr->job_id;
+				bg_record->job_ptr = will_run->job_ptr;
+				debug2("test_job_list: "
+				       "can run job %u on found block at %d"
+				       "nodes = %s",
+				       bg_record->job_ptr->job_id,
+				       starttime,
+				       bg_record->nodes);
+				
+				if(!block_exist_in_list(job_block_test_list,
+							bg_record)) {
+					new_record =
+						xmalloc(sizeof(bg_record_t));
+					copy_bg_record(bg_record, new_record);
+					list_append(job_block_test_list,
+						    new_record);
+				}
+
+				if(will_run->job_ptr->start_time) {
+					if(will_run->job_ptr->start_time
+					   < starttime) {
+						debug2("test_job_list: "
+						       "Time is later "
+						       "than one supplied.");
+						rc = SLURM_ERROR;
+						break;
+					}
+					
+					//continue;
+				} else
+					will_run->job_ptr->start_time 
+						= starttime;
+
+				if(will_run->job_ptr->time_limit != INFINITE
+				   && will_run->job_ptr->time_limit != NO_VAL) 
+					will_run->job_ptr->end_time =
+						will_run->job_ptr->start_time +
+						will_run->job_ptr->time_limit *
+						60;
+				else if(will_run->job_ptr->part_ptr->max_time
+					!= INFINITE
+					&& will_run->job_ptr->
+					part_ptr->max_time != NO_VAL) 
+					will_run->job_ptr->end_time =
+						will_run->job_ptr->start_time +
+						will_run->job_ptr->
+						part_ptr->max_time * 60;
+				else
+					will_run->job_ptr->end_time = 
+						will_run->job_ptr->start_time +
+						31536000; // + year
+						
+				select_g_set_jobinfo(
+					will_run->job_ptr->select_jobinfo,
+					SELECT_DATA_NODES, 
+					bg_record->nodes);
+				select_g_set_jobinfo(
+					will_run->job_ptr->select_jobinfo,
+					SELECT_DATA_IONODES, 
+					bg_record->ionodes);
+				
+/* 				if(!bg_record->bg_block_id) { */
+/* 					uint16_t geo[BA_SYSTEM_DIMENSIONS]; */
+					
+/* 					debug2("test_job_list: " */
+/* 					       "can start job at " */
+/* 					       "%u on %s on unmade block", */
+/* 					       starttime, */
+/* 					       bg_record->nodes); */
+/* 					select_g_set_jobinfo( */
+/* 						will_run->job_ptr-> */
+/* 						select_jobinfo, */
+/* 						SELECT_DATA_BLOCK_ID, */
+/* 						"unassigned"); */
+/* 					if(will_run->job_ptr->num_procs */
+/* 					   < bluegene_bp_node_cnt  */
+/* 					   && will_run->job_ptr->num_procs */
+/* 					   > 0) { */
+/* 						i = procs_per_node/ */
+/* 							will_run->job_ptr-> */
+/* 							num_procs; */
+/* 						debug2("divide by %d", i); */
+/* 					} else  */
+/* 						i = 1; */
+/* 					will_run->min_nodes *=  */
+/* 						bluegene_bp_node_cnt/i; */
+/* 					select_g_set_jobinfo( */
+/* 						will_run->job_ptr-> */
+/* 						select_jobinfo, */
+/* 						SELECT_DATA_NODE_CNT, */
+/* 						&will_run->min_nodes); */
+/* 					memset(geo, 0,  */
+/* 					       sizeof(uint16_t)  */
+/* 					       * BA_SYSTEM_DIMENSIONS); */
+/* 					select_g_set_jobinfo( */
+/* 						will_run->job_ptr-> */
+/* 						select_jobinfo, */
+/* 						SELECT_DATA_GEOMETRY,  */
+/* 						&geo); */
+/* 				} else { */
+/* 					if((bg_record->ionodes) */
+/* 					   && (will_run->job_ptr->part_ptr-> */
+/* 					       max_share */
+/* 					       <= 1)) */
+/* 						error("Small block used in " */
+/* 						      "non-shared partition"); */
+					
+/* 					debug2("test_job_list: " */
+/* 					       "can start job at %u on %s", */
+/* 					       starttime, */
+/* 					       bg_record->nodes); */
+					
+/* 					select_g_set_jobinfo( */
+/* 						will_run->job_ptr-> */
+/* 						select_jobinfo, */
+/* 						SELECT_DATA_BLOCK_ID, */
+/* 						bg_record->bg_block_id); */
+/* 					select_g_set_jobinfo( */
+/* 						will_run->job_ptr-> */
+/* 						select_jobinfo, */
+/* 						SELECT_DATA_NODE_CNT,  */
+/* 						&bg_record->node_cnt); */
+/* 					select_g_set_jobinfo( */
+/* 						will_run->job_ptr-> */
+/* 						select_jobinfo, */
+/* 						SELECT_DATA_GEOMETRY,  */
+/* 						&bg_record->geo); */
+					
+/* 					tmp16 = bg_record->conn_type; */
+/* 					select_g_set_jobinfo( */
+/* 						will_run->job_ptr-> */
+/* 						select_jobinfo, */
+/* 						SELECT_DATA_CONN_TYPE,  */
+/* 						&tmp16); */
+/* 				} */
+			} else {
+				error("we got a success, but no block back");
+				rc = SLURM_ERROR;
+			}
+		}
+	}
+	list_iterator_destroy(itr);
+
+	if(bluegene_layout_mode == LAYOUT_DYNAMIC) 		
 		slurm_mutex_unlock(&create_dynamic_mutex);
 	
+
+	list_destroy(block_list);
+	list_destroy(job_block_test_list);
+	
+	slurm_mutex_unlock(&job_list_test_mutex);
+#endif
 	return rc;
 }
diff --git a/src/plugins/select/bluegene/plugin/bg_job_place.h b/src/plugins/select/bluegene/plugin/bg_job_place.h
index f523b52b19c88554c64b590d56dda68b11c4f590..448698e58323df3c24389482c684e7363b88d383 100644
--- a/src/plugins/select/bluegene/plugin/bg_job_place.h
+++ b/src/plugins/select/bluegene/plugin/bg_job_place.h
@@ -49,12 +49,15 @@
  *	                      to this job (considers slurm partition limits)
  * IN test_only - test to see if job is ever runnable, 
  *                or (false) runable right now
- * IN test_only - if true, only test if ever could run, not necessarily now
- * IN test_only - if true, only test if ever could run, not necessarily now
+ * IN mode - SELECT_MODE_RUN_NOW: try to schedule job now
+ *           SELECT_MODE_TEST_ONLY: test if job can ever run
+ *           SELECT_MODE_WILL_RUN: determine when and where job can run
  * RET - SLURM_SUCCESS if job runnable now, error code otherwise 
  */
 extern int submit_job(struct job_record *job_ptr, bitstr_t *bitmap,
-		uint32_t min_nodes, uint32_t max_nodes, uint32_t req_nodes, 
-		bool test_only);
+		      uint32_t min_nodes, uint32_t max_nodes,
+		      uint32_t req_nodes, int mode);
+
+extern int test_job_list(List req_list);
 
 #endif /* _BG_JOB_PLACE_H_ */
diff --git a/src/plugins/select/bluegene/plugin/bg_job_run.c b/src/plugins/select/bluegene/plugin/bg_job_run.c
index 5153de5689352b5fa20f5fac44a27691416fe642..4f0e7383fc163539cda56ae712d9a36341e0f815 100644
--- a/src/plugins/select/bluegene/plugin/bg_job_run.c
+++ b/src/plugins/select/bluegene/plugin/bg_job_run.c
@@ -2,7 +2,7 @@
  *  bg_job_run.c - blue gene job execution (e.g. initiation and termination) 
  *  functions.
  *
- *  $Id: bg_job_run.c 13271 2008-02-14 20:02:00Z da $ 
+ *  $Id: bg_job_run.c 13947 2008-04-29 19:35:34Z jette $ 
  *****************************************************************************
  *  Copyright (C) 2004-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -70,8 +70,8 @@ enum update_op {START_OP, TERM_OP, SYNC_OP};
 
 typedef struct bg_update {
 	enum update_op op;	/* start | terminate | sync */
-	uid_t uid;		/* new user */
-	uint32_t job_id;	/* SLURM job id */	
+	struct job_record *job_ptr;	/* pointer to job running on
+					 * block or NULL if no job */
 	uint16_t reboot;	/* reboot block before starting job */
 	pm_partition_id_t bg_block_id;
 	char *blrtsimage;       /* BlrtsImage for this block */
@@ -205,32 +205,36 @@ static void _sync_agent(bg_update_t *bg_update_ptr)
 {
 	bg_record_t * bg_record = NULL;
 	
-	bg_record = 
-		find_bg_record_in_list(bg_list, bg_update_ptr->bg_block_id);
+	bg_record = find_bg_record_in_list(bg_list, bg_update_ptr->bg_block_id);
 	if(!bg_record) {
 		error("No block %s", bg_update_ptr->bg_block_id);
 		return;
 	}
 	slurm_mutex_lock(&block_state_mutex);
-	bg_record->job_running = bg_update_ptr->job_id;
+
+	bg_record->job_running = bg_update_ptr->job_ptr->job_id;
+	bg_record->job_ptr = bg_update_ptr->job_ptr;
+
 	if(!block_exist_in_list(bg_job_block_list, bg_record)) {
 		list_push(bg_job_block_list, bg_record);
 		num_unused_cpus -= bg_record->bp_count*bg_record->cpus_per_bp;
 	}
+	if(!block_exist_in_list(bg_booted_block_list, bg_record)) 
+		list_push(bg_booted_block_list, bg_record);
 	slurm_mutex_unlock(&block_state_mutex);
 
 	if(bg_record->state == RM_PARTITION_READY) {
-		if(bg_record->user_uid != bg_update_ptr->uid) {
+		if(bg_record->user_uid != bg_update_ptr->job_ptr->user_id) {
 			int set_user_rc = SLURM_SUCCESS;
 
 			slurm_mutex_lock(&block_state_mutex);
 			debug("User isn't correct for job %d on %s, "
 			      "fixing...", 
-			      bg_update_ptr->job_id,
+			      bg_update_ptr->job_ptr->job_id,
 			      bg_update_ptr->bg_block_id);
 			xfree(bg_record->target_name);
-			bg_record->target_name = 
-				xstrdup(uid_to_string(bg_update_ptr->uid));
+			bg_record->target_name = xstrdup(
+				uid_to_string(bg_update_ptr->job_ptr->user_id));
 			set_user_rc = set_block_user(bg_record);
 			slurm_mutex_unlock(&block_state_mutex);
 		
@@ -267,7 +271,7 @@ static void _start_agent(bg_update_t *bg_update_ptr)
 	if(!bg_record) {
 		error("block %s not found in bg_list",
 		      bg_update_ptr->bg_block_id);
-		(void) slurm_fail_job(bg_update_ptr->job_id);
+		(void) slurm_fail_job(bg_update_ptr->job_ptr->job_id);
 		slurm_mutex_unlock(&job_start_mutex);
 		return;
 	}
@@ -275,9 +279,9 @@ static void _start_agent(bg_update_t *bg_update_ptr)
 	if(bg_record->job_running <= NO_JOB_RUNNING) {
 		slurm_mutex_unlock(&block_state_mutex);
 		slurm_mutex_unlock(&job_start_mutex);
-		debug("job %d finished during the queueing job "
+		debug("job %u finished during the queueing job "
 		      "(everything is ok)",
-		      bg_update_ptr->job_id);
+		      bg_update_ptr->job_ptr->job_id);
 		return;
 	}
 	if(bg_record->state == RM_PARTITION_DEALLOCATING) {
@@ -333,8 +337,8 @@ static void _start_agent(bg_update_t *bg_update_ptr)
 	if(bg_record->job_running <= NO_JOB_RUNNING) {
 		slurm_mutex_unlock(&block_state_mutex);
 		slurm_mutex_unlock(&job_start_mutex);
-		debug("job %d already finished before boot",
-		      bg_update_ptr->job_id);
+		debug("job %u already finished before boot",
+		      bg_update_ptr->job_ptr->job_id);
 		return;
 	}
 
@@ -424,7 +428,7 @@ static void _start_agent(bg_update_t *bg_update_ptr)
 			   is a no-op if issued prior 
 			   to the script initiation do clean up just
 			   incase the fail job isn't ran */
-			(void) slurm_fail_job(bg_update_ptr->job_id);
+			(void) slurm_fail_job(bg_update_ptr->job_ptr->job_id);
 			slurm_mutex_lock(&block_state_mutex);
 			if (remove_from_bg_list(bg_job_block_list, bg_record)
 			    == SLURM_SUCCESS) {
@@ -441,16 +445,17 @@ static void _start_agent(bg_update_t *bg_update_ptr)
 	
 	if(bg_record->job_running <= NO_JOB_RUNNING) {
 		slurm_mutex_unlock(&job_start_mutex);
-		debug("job %d finished during the start of the boot "
+		debug("job %u finished during the start of the boot "
 		      "(everything is ok)",
-		      bg_update_ptr->job_id);
+		      bg_update_ptr->job_ptr->job_id);
 		return;
 	}
 	slurm_mutex_lock(&block_state_mutex);
 		
 	bg_record->boot_count = 0;
 	xfree(bg_record->target_name);
-	bg_record->target_name = xstrdup(uid_to_string(bg_update_ptr->uid));
+	bg_record->target_name = xstrdup(
+		uid_to_string(bg_update_ptr->job_ptr->user_id));
 	debug("setting the target_name for Block %s to %s",
 	      bg_record->bg_block_id,
 	      bg_record->target_name);
@@ -604,9 +609,10 @@ static void _term_agent(bg_update_t *bg_update_ptr)
 		}
 			
 		slurm_mutex_lock(&block_state_mutex);
-		if(bg_record->job_running > NO_JOB_RUNNING)
+		if(bg_record->job_running > NO_JOB_RUNNING) {
 			bg_record->job_running = NO_JOB_RUNNING;
-		
+			bg_record->job_ptr = NULL;
+		}
 		/* remove user from list */
 		
 		slurm_conf_lock();
@@ -647,7 +653,7 @@ static void _term_agent(bg_update_t *bg_update_ptr)
 #endif
 	
 }
-	
+
 /* Process requests off the bg_update_list queue and exit when done */
 static void *_block_agent(void *args)
 {
@@ -662,6 +668,8 @@ static void *_block_agent(void *args)
 	while (!agent_fini) {
 		slurm_mutex_lock(&agent_cnt_mutex);
 		bg_update_ptr = list_dequeue(bg_update_list);
+/* 		info("running %d %d %d", TERM_OP, bg_update_ptr->op, */
+/* 		     list_count(bg_update_list)); */
 		slurm_mutex_unlock(&agent_cnt_mutex);
 		if (!bg_update_ptr) {
 			usleep(100000);
@@ -698,9 +706,16 @@ static void _block_op(bg_update_t *bg_update_ptr)
 	    &&  ((bg_update_list = list_create(_bg_list_del)) == NULL))
 		fatal("malloc failure in start_job/list_create");
 
-	/* push job onto queue in a FIFO */
-	if (list_push(bg_update_list, bg_update_ptr) == NULL)
-		fatal("malloc failure in _block_op/list_push");
+	/* push TERM_OP on the head of the queue
+	 * append START_OP and SYNC_OP to the tail of the queue */
+	if (bg_update_ptr->op == TERM_OP) {
+		if (list_push(bg_update_list, bg_update_ptr) == NULL)
+			fatal("malloc failure in _block_op/list_push");
+	} else {
+		if (list_enqueue(bg_update_list, bg_update_ptr) == NULL)
+			fatal("malloc failure in _block_op/list_enqueue");
+	}
+		
 	/* already running MAX_AGENTS we don't really need more 
 	   since they never end */
 	if (agent_cnt > MAX_AGENT_COUNT) {
@@ -785,7 +800,7 @@ static int _excise_block(List block_list, pm_partition_id_t bg_block_id,
 			
 			/* exact match of name and node list */
 			debug("synced Block %s", bg_block_id);
-			list_delete(iter);
+			list_delete_item(iter);
 			rc = SLURM_SUCCESS;
 			break;
 		}		
@@ -840,8 +855,8 @@ extern int start_job(struct job_record *job_ptr)
 
 	bg_update_ptr = xmalloc(sizeof(bg_update_t));
 	bg_update_ptr->op = START_OP;
-	bg_update_ptr->uid = job_ptr->user_id;
-	bg_update_ptr->job_id = job_ptr->job_id;
+	bg_update_ptr->job_ptr = job_ptr;
+
 	select_g_get_jobinfo(job_ptr->select_jobinfo,
 			     SELECT_DATA_BLOCK_ID, 
 			     &(bg_update_ptr->bg_block_id));
@@ -890,7 +905,8 @@ extern int start_job(struct job_record *job_ptr)
 		slurm_mutex_lock(&block_state_mutex);
 		job_ptr->num_procs = (bg_record->cpus_per_bp *
 				      bg_record->bp_count);
-		bg_record->job_running = bg_update_ptr->job_id;
+		bg_record->job_running = bg_update_ptr->job_ptr->job_id;
+		bg_record->job_ptr = bg_update_ptr->job_ptr;
 		if(!block_exist_in_list(bg_job_block_list, bg_record)) {
 			list_push(bg_job_block_list, bg_record);
 			num_unused_cpus -= 
@@ -900,7 +916,7 @@ extern int start_job(struct job_record *job_ptr)
 			list_push(bg_booted_block_list, bg_record);
 		slurm_mutex_unlock(&block_state_mutex);
 	} else {
-		error("bg_record %s does exist, requested for job (%d)", 
+		error("bg_record %s doesn't exist, requested for job (%d)", 
 		      bg_update_ptr->bg_block_id, job_ptr->job_id);
 		_bg_list_del(bg_update_ptr);
 		return SLURM_ERROR;
@@ -929,8 +945,7 @@ int term_job(struct job_record *job_ptr)
 	
 	bg_update_ptr = xmalloc(sizeof(bg_update_t));
 	bg_update_ptr->op = TERM_OP;
-	bg_update_ptr->uid = job_ptr->user_id;
-	bg_update_ptr->job_id = job_ptr->job_id;
+	bg_update_ptr->job_ptr = job_ptr;
 	select_g_get_jobinfo(job_ptr->select_jobinfo,
 			     SELECT_DATA_BLOCK_ID, 
 			     &(bg_update_ptr->bg_block_id));
@@ -1014,12 +1029,13 @@ extern int sync_jobs(List job_list)
 				continue;
 			}
 
-			debug3("Queue sync of job %u in BG block %s",
+			debug3("Queue sync of job %u in BG block %s "
+			       "ending at %d",
 			       job_ptr->job_id, 
-			       bg_update_ptr->bg_block_id);
+			       bg_update_ptr->bg_block_id,
+			       job_ptr->end_time);
 			bg_update_ptr->op = SYNC_OP;
-			bg_update_ptr->uid = job_ptr->user_id;
-			bg_update_ptr->job_id = job_ptr->job_id;
+			bg_update_ptr->job_ptr = job_ptr;
 			_block_op(bg_update_ptr);
 		}
 		list_iterator_destroy(job_iterator);
diff --git a/src/plugins/select/bluegene/plugin/bg_job_run.h b/src/plugins/select/bluegene/plugin/bg_job_run.h
index 92db1d14d30e1c903d0b0d005928277fecf1d388..9ea7ea949d1f7ae05b25d68cd4779a694662b1df 100644
--- a/src/plugins/select/bluegene/plugin/bg_job_run.h
+++ b/src/plugins/select/bluegene/plugin/bg_job_run.h
@@ -40,6 +40,13 @@
 
 #include "src/slurmctld/slurmctld.h"
 
+/*
+ * Boot a block. Partition state expected to be FREE upon entry. 
+ * NOTE: This function does not wait for the boot to complete.
+ * the slurm prolog script needs to perform the waiting.
+ */
+extern int boot_block(bg_record_t *bg_record);
+
 /*
  * Perform any setup required to initiate a job
  * job_ptr IN - pointer to the job being initiated
@@ -51,6 +58,13 @@
  */
 extern int start_job(struct job_record *job_ptr);
 
+/*
+ * Synchronize BG block state to that of currently active jobs.
+ * This can recover from slurmctld crashes when block ownership 
+ * changes were queued
+ */
+extern int sync_jobs(List job_list);
+
 /* 
  * Perform any work required to terminate a job
  * job_ptr IN - pointer to the job being terminated
@@ -72,17 +86,4 @@ extern int term_job(struct job_record *job_ptr);
  */
 extern int term_jobs_on_block(pm_partition_id_t bg_block_id);
 
-/*
- * Synchronize BG block state to that of currently active jobs.
- * This can recover from slurmctld crashes when block ownership 
- * changes were queued
- */
-extern int sync_jobs(List job_list);
-
-/*
- * Boot a block. Partition state expected to be FREE upon entry. 
- * NOTE: This function does not wait for the boot to complete.
- * the slurm prolog script needs to perform the waiting.
- */
-extern int boot_block(bg_record_t *bg_record);
 #endif /* _BG_JOB_RUN_H_ */
diff --git a/src/plugins/select/bluegene/plugin/bg_record_functions.c b/src/plugins/select/bluegene/plugin/bg_record_functions.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0f78ecf5fe9d2f71800c27b16c624bf78378ac4
--- /dev/null
+++ b/src/plugins/select/bluegene/plugin/bg_record_functions.c
@@ -0,0 +1,867 @@
+/*****************************************************************************\
+ *  bg_record_functions.c - header for creating blocks in a static environment.
+ *
+ *  $Id: bg_record_functions.c 12954 2008-01-04 20:37:49Z da $
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "bluegene.h"
+#include "dynamic_block.h"
+
+#include "src/slurmctld/trigger_mgr.h"
+
+/* some local functions */
+#ifdef HAVE_BG
+static int  _addto_node_list(bg_record_t *bg_record, int *start, int *end);
+static int  _ba_node_cmpf_inc(ba_node_t *node_a, ba_node_t *node_b);
+#endif
+
+extern void print_bg_record(bg_record_t* bg_record)
+{
+	if (!bg_record) {
+		error("print_bg_record, record given is null");
+		return;
+	}
+#if _DEBUG
+	info(" bg_record: ");
+	if (bg_record->bg_block_id)
+		info("\tbg_block_id: %s", bg_record->bg_block_id);
+	info("\tnodes: %s", bg_record->nodes);
+	info("\tsize: %d BPs %u Nodes %d cpus", 
+	     bg_record->bp_count,
+	     bg_record->node_cnt,
+	     bg_record->cpus_per_bp * bg_record->bp_count);
+	info("\tgeo: %ux%ux%u", bg_record->geo[X], bg_record->geo[Y], 
+	     bg_record->geo[Z]);
+	info("\tconn_type: %s", convert_conn_type(bg_record->conn_type));
+	info("\tnode_use: %s", convert_node_use(bg_record->node_use));
+	if (bg_record->bitmap) {
+		char bitstring[BITSIZE];
+		bit_fmt(bitstring, BITSIZE, bg_record->bitmap);
+		info("\tbitmap: %s", bitstring);
+	}
+#else
+{
+	char tmp_char[256];
+	format_node_name(bg_record, tmp_char, sizeof(tmp_char));
+	info("Record: BlockID:%s Nodes:%s Conn:%s",
+	     bg_record->bg_block_id, tmp_char,
+	     convert_conn_type(bg_record->conn_type));
+}
+#endif
+}
+
+extern void destroy_bg_record(void *object)
+{
+	bg_record_t* bg_record = (bg_record_t*) object;
+
+	if (bg_record) {
+		xfree(bg_record->bg_block_id);
+		xfree(bg_record->nodes);
+		xfree(bg_record->ionodes);
+		xfree(bg_record->user_name);
+		xfree(bg_record->target_name);
+		if(bg_record->bg_block_list) {
+			list_destroy(bg_record->bg_block_list);
+			bg_record->bg_block_list = NULL;
+		}
+		FREE_NULL_BITMAP(bg_record->bitmap);
+		FREE_NULL_BITMAP(bg_record->ionode_bitmap);
+
+		xfree(bg_record->blrtsimage);
+		xfree(bg_record->linuximage);
+		xfree(bg_record->mloaderimage);
+		xfree(bg_record->ramdiskimage);
+
+		xfree(bg_record);
+	}
+}
+
+extern int block_exist_in_list(List my_list, bg_record_t *bg_record)
+{
+	ListIterator itr = list_iterator_create(my_list);
+	bg_record_t *found_record = NULL;
+	int rc = 0;
+
+	while ((found_record = (bg_record_t *) list_next(itr)) != NULL) {
+		/* check for full node bitmap compare */
+		if(bit_equal(bg_record->bitmap, found_record->bitmap)
+		   && bit_equal(bg_record->ionode_bitmap,
+				found_record->ionode_bitmap)) {
+			if(bg_record->ionodes)
+				debug3("This block %s[%s] "
+				       "is already in the list %s",
+				       bg_record->nodes,
+				       bg_record->ionodes,
+				       found_record->bg_block_id);
+			else
+				debug3("This block %s "
+				       "is already in the list %s",
+				       bg_record->nodes,
+				       found_record->bg_block_id);
+				
+			rc = 1;
+			break;
+		}
+	}
+	list_iterator_destroy(itr);
+	return rc;
+}
+
+extern void process_nodes(bg_record_t *bg_record, bool startup)
+{
+#ifdef HAVE_BG
+	int j=0, number;
+	int start[BA_SYSTEM_DIMENSIONS];
+	int end[BA_SYSTEM_DIMENSIONS];
+	ListIterator itr;
+	ba_node_t* ba_node = NULL;
+	
+	if(!bg_record->bg_block_list 
+	   || !list_count(bg_record->bg_block_list)) {
+		if(!bg_record->bg_block_list) {
+			bg_record->bg_block_list =
+				list_create(destroy_ba_node);
+		}
+		bg_record->bp_count = 0;
+		if((bg_record->conn_type == SELECT_SMALL) && (!startup))
+			error("We shouldn't be here there could be some "
+			      "badness if we use this logic %s",
+			      bg_record->nodes);
+		while (bg_record->nodes[j] != '\0') {
+			if ((bg_record->nodes[j] == '['
+			     || bg_record->nodes[j] == ',')
+			    && (bg_record->nodes[j+8] == ']' 
+				|| bg_record->nodes[j+8] == ',')
+			    && (bg_record->nodes[j+4] == 'x'
+				|| bg_record->nodes[j+4] == '-')) {
+				j++;
+				number = xstrntol(bg_record->nodes + j,
+						  NULL, BA_SYSTEM_DIMENSIONS,
+						  HOSTLIST_BASE);
+				start[X] = number / 
+					(HOSTLIST_BASE * HOSTLIST_BASE);
+				start[Y] = (number % 
+					    (HOSTLIST_BASE * HOSTLIST_BASE))
+					/ HOSTLIST_BASE;
+				start[Z] = (number % HOSTLIST_BASE);
+				j += 4;
+				number = xstrntol(bg_record->nodes + j,
+						NULL, 3, HOSTLIST_BASE);
+				end[X] = number /
+					(HOSTLIST_BASE * HOSTLIST_BASE);
+				end[Y] = (number 
+					  % (HOSTLIST_BASE * HOSTLIST_BASE))
+					/ HOSTLIST_BASE;
+				end[Z] = (number % HOSTLIST_BASE);
+				j += 3;
+				if(!bg_record->bp_count) {
+					bg_record->start[X] = start[X];
+					bg_record->start[Y] = start[Y];
+					bg_record->start[Z] = start[Z];
+					debug2("start is %dx%dx%d",
+					       bg_record->start[X],
+					       bg_record->start[Y],
+					       bg_record->start[Z]);
+				}
+				bg_record->bp_count += _addto_node_list(
+					bg_record, 
+					start, 
+					end);
+				if(bg_record->nodes[j] != ',')
+					break;
+				j--;
+			} else if((bg_record->nodes[j] >= '0'
+				   && bg_record->nodes[j] <= '9')
+				  || (bg_record->nodes[j] >= 'A'
+				      && bg_record->nodes[j] <= 'Z')) {
+				
+				number = xstrntol(bg_record->nodes + j,
+						  NULL, BA_SYSTEM_DIMENSIONS,
+						  HOSTLIST_BASE);
+				start[X] = number / 
+					(HOSTLIST_BASE * HOSTLIST_BASE);
+				start[Y] = (number % 
+					    (HOSTLIST_BASE * HOSTLIST_BASE))
+					/ HOSTLIST_BASE;
+				start[Z] = (number % HOSTLIST_BASE);
+				j+=3;
+				if(!bg_record->bp_count) {
+					bg_record->start[X] = start[X];
+					bg_record->start[Y] = start[Y];
+					bg_record->start[Z] = start[Z];
+					debug2("start is %dx%dx%d",
+					       bg_record->start[X],
+					       bg_record->start[Y],
+					       bg_record->start[Z]);
+				}
+				bg_record->bp_count += _addto_node_list(
+					bg_record, 
+					start, 
+					start);
+				if(bg_record->nodes[j] != ',')
+					break;
+				j--;
+			}
+			j++;
+		}
+	}
+	
+	bg_record->geo[X] = 0;
+	bg_record->geo[Y] = 0;
+	bg_record->geo[Z] = 0;
+	end[X] = -1;
+	end[Y] = -1;
+	end[Z] = -1;
+
+	list_sort(bg_record->bg_block_list, (ListCmpF) _ba_node_cmpf_inc);
+
+	itr = list_iterator_create(bg_record->bg_block_list);
+	while ((ba_node = list_next(itr)) != NULL) {
+		if(!ba_node->used)
+			continue;
+		debug4("%c%c%c is included in this block",
+		       alpha_num[ba_node->coord[X]],
+		       alpha_num[ba_node->coord[Y]],
+		       alpha_num[ba_node->coord[Z]]);
+		       
+		if(ba_node->coord[X]>end[X]) {
+			bg_record->geo[X]++;
+			end[X] = ba_node->coord[X];
+		}
+		if(ba_node->coord[Y]>end[Y]) {
+			bg_record->geo[Y]++;
+			end[Y] = ba_node->coord[Y];
+		}
+		if(ba_node->coord[Z]>end[Z]) {
+			bg_record->geo[Z]++;
+			end[Z] = ba_node->coord[Z];
+		}
+	}
+	list_iterator_destroy(itr);
+	debug3("geo = %c%c%c bp count is %d\n",
+	       alpha_num[bg_record->geo[X]],
+	       alpha_num[bg_record->geo[Y]],
+	       alpha_num[bg_record->geo[Z]],
+	       bg_record->bp_count);
+
+	if ((bg_record->geo[X] == DIM_SIZE[X])
+	    && (bg_record->geo[Y] == DIM_SIZE[Y])
+	    && (bg_record->geo[Z] == DIM_SIZE[Z])) {
+		bg_record->full_block = 1;	
+	}	
+	
+/* #ifndef HAVE_BG_FILES */
+/* 	max_dim[X] = MAX(max_dim[X], end[X]); */
+/* 	max_dim[Y] = MAX(max_dim[Y], end[Y]); */
+/* 	max_dim[Z] = MAX(max_dim[Z], end[Z]); */
+/* #endif */
+   
+	if (node_name2bitmap(bg_record->nodes, 
+			     false, 
+			     &bg_record->bitmap)) {
+		fatal("1 Unable to convert nodes %s to bitmap", 
+		      bg_record->nodes);
+	}
+#endif
+	return;
+}
+
+/* 
+ * NOTE: This function does not do a mutex lock so if you are copying the
+ * main bg_list you need to lock 'block_state_mutex' before calling
+ */
+extern List copy_bg_list(List in_list) 
+{
+	bg_record_t *bg_record = NULL;
+	bg_record_t *new_record = NULL;
+	List out_list = list_create(destroy_bg_record);
+	ListIterator itr = list_iterator_create(in_list);
+
+	while ((bg_record = (bg_record_t *) list_next(itr))) { 
+		new_record = xmalloc(sizeof(bg_record_t));
+		new_record->original = bg_record;
+		copy_bg_record(bg_record, new_record);
+		list_append(out_list, new_record);
+	}
+
+	list_iterator_destroy(itr);
+	
+	return out_list;	
+}
+
+extern void copy_bg_record(bg_record_t *fir_record, bg_record_t *sec_record)
+{
+	int i;
+	ListIterator itr = NULL;
+	ba_node_t *ba_node = NULL, *new_ba_node = NULL;
+	
+	if(!fir_record || !sec_record) {
+		error("copy_bg_record: "
+		      "given a null for either first record or second record");
+		return;
+	}
+
+	xfree(sec_record->bg_block_id);
+	sec_record->bg_block_id = xstrdup(fir_record->bg_block_id);
+	xfree(sec_record->nodes);
+	sec_record->nodes = xstrdup(fir_record->nodes);
+	xfree(sec_record->ionodes);
+	sec_record->ionodes = xstrdup(fir_record->ionodes);
+	xfree(sec_record->user_name);
+	sec_record->user_name = xstrdup(fir_record->user_name);
+	xfree(sec_record->target_name);
+	sec_record->target_name = xstrdup(fir_record->target_name);
+
+	xfree(sec_record->blrtsimage);
+	sec_record->blrtsimage = xstrdup(fir_record->blrtsimage);
+	xfree(sec_record->linuximage);
+	sec_record->linuximage = xstrdup(fir_record->linuximage);
+	xfree(sec_record->mloaderimage);
+	sec_record->mloaderimage = xstrdup(fir_record->mloaderimage);
+	xfree(sec_record->ramdiskimage);
+	sec_record->ramdiskimage = xstrdup(fir_record->ramdiskimage);
+
+	sec_record->user_uid = fir_record->user_uid;
+	sec_record->state = fir_record->state;
+	sec_record->conn_type = fir_record->conn_type;
+	sec_record->node_use = fir_record->node_use;
+	sec_record->bp_count = fir_record->bp_count;
+	sec_record->switch_count = fir_record->switch_count;
+	sec_record->boot_state = fir_record->boot_state;
+	sec_record->boot_count = fir_record->boot_count;
+	sec_record->full_block = fir_record->full_block;
+
+	for(i=0;i<BA_SYSTEM_DIMENSIONS;i++) {
+		sec_record->geo[i] = fir_record->geo[i];
+		sec_record->start[i] = fir_record->start[i];
+	}
+
+	FREE_NULL_BITMAP(sec_record->bitmap);
+	if(fir_record->bitmap 
+	   && (sec_record->bitmap = bit_copy(fir_record->bitmap)) == NULL) {
+		error("Unable to copy bitmap for %s", fir_record->nodes);
+		sec_record->bitmap = NULL;
+	}
+	FREE_NULL_BITMAP(sec_record->ionode_bitmap);
+	if(fir_record->ionode_bitmap 
+	   && (sec_record->ionode_bitmap
+	       = bit_copy(fir_record->ionode_bitmap)) == NULL) {
+		error("Unable to copy ionode_bitmap for %s",
+		      fir_record->nodes);
+		sec_record->ionode_bitmap = NULL;
+	}
+	if(sec_record->bg_block_list)
+		list_destroy(sec_record->bg_block_list);
+	sec_record->bg_block_list = list_create(destroy_ba_node);
+	if(fir_record->bg_block_list) {
+		itr = list_iterator_create(fir_record->bg_block_list);
+		while((ba_node = list_next(itr))) {
+			new_ba_node = ba_copy_node(ba_node);
+			list_push(sec_record->bg_block_list, new_ba_node);
+		}
+		list_iterator_destroy(itr);
+	}
+	sec_record->job_running = fir_record->job_running;
+	sec_record->job_ptr = fir_record->job_ptr;
+	sec_record->cpus_per_bp = fir_record->cpus_per_bp;
+	sec_record->node_cnt = fir_record->node_cnt;
+	sec_record->quarter = fir_record->quarter;
+	sec_record->nodecard = fir_record->nodecard;
+}
+
+extern bg_record_t *find_bg_record_in_list(List my_list, char *bg_block_id)
+{
+	ListIterator itr;
+	bg_record_t *bg_record = NULL;
+		
+	if(!bg_block_id)
+		return NULL;
+			
+	if(my_list) {
+		slurm_mutex_lock(&block_state_mutex);
+		itr = list_iterator_create(my_list);
+		while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
+			if(bg_record->bg_block_id)
+				if (!strcmp(bg_record->bg_block_id, 
+					    bg_block_id))
+					break;
+		}
+		list_iterator_destroy(itr);
+		slurm_mutex_unlock(&block_state_mutex);
+		if(bg_record)
+			return bg_record;
+		else
+			return NULL;
+	} else {
+		error("find_bg_record_in_list: no list");
+		return NULL;
+	}
+	
+}
+
+/* All changes to the bg_list target_name must 
+   be done before this function is called. 
+   also slurm_conf_lock() must be called before calling this
+   function along with slurm_conf_unlock() afterwards.		
+*/
+extern int update_block_user(bg_record_t *bg_record, int set) 
+{
+	struct passwd *pw_ent = NULL;
+
+	if(!bg_record->target_name) {
+		error("Must set target_name to run update_block_user.");
+		return -1;
+	}
+	if(!bg_record->user_name) {
+		error("No user_name");
+		bg_record->user_name = xstrdup(slurmctld_conf.slurm_user_name);
+	}
+#ifdef HAVE_BG_FILES
+	int rc=0;	
+	if(set) {
+		if((rc = remove_all_users(bg_record->bg_block_id, 
+					  bg_record->target_name))
+		   == REMOVE_USER_ERR) {
+			error("1 Something happened removing "
+			      "users from block %s", 
+			      bg_record->bg_block_id);
+			return -1;
+		} else if (rc == REMOVE_USER_NONE) {
+			if (strcmp(bg_record->target_name, 
+				   slurmctld_conf.slurm_user_name)) {
+				info("Adding user %s to Block %s",
+				     bg_record->target_name, 
+				     bg_record->bg_block_id);
+				
+				if ((rc = bridge_add_block_user(
+					     bg_record->bg_block_id, 
+					     bg_record->target_name)) 
+				    != STATUS_OK) {
+					error("bridge_add_block_user"
+					      "(%s,%s): %s", 
+					      bg_record->bg_block_id, 
+					      bg_record->target_name,
+					      bg_err_str(rc));
+					return -1;
+				} 
+			}
+		}
+	}
+#endif
+	
+	if(strcmp(bg_record->target_name, bg_record->user_name)) {
+		xfree(bg_record->user_name);
+		bg_record->user_name = xstrdup(bg_record->target_name);
+		if((pw_ent = getpwnam(bg_record->user_name)) == NULL) {
+			error("getpwnam(%s): %m", bg_record->user_name);
+			return -1;
+		} else {
+			bg_record->user_uid = pw_ent->pw_uid; 
+		}		
+		return 1;
+	}
+	
+	return 0;
+}
+
+/* If any nodes in node_list are drained, draining, or down, 
+ *   then just return
+ *   else drain all of the nodes
+ * This function lets us drain an entire bgblock only if 
+ * we have not already identified a specific node as bad. */
+extern void drain_as_needed(bg_record_t *bg_record, char *reason)
+{
+	bool needed = true;
+	hostlist_t hl;
+	char *host = NULL;
+	char bg_down_node[128];
+
+	if(bg_record->job_running > NO_JOB_RUNNING)
+		slurm_fail_job(bg_record->job_running);			
+
+	/* small blocks */
+	if(bg_record->cpus_per_bp != procs_per_node) {
+		debug2("small block");
+		goto end_it;
+	}
+	
+	/* at least one base partition */
+	hl = hostlist_create(bg_record->nodes);
+	if (!hl) {
+		slurm_drain_nodes(bg_record->nodes, reason);
+		return;
+	}
+	while ((host = hostlist_shift(hl))) {
+		if (node_already_down(bg_down_node)) {
+			needed = false;
+			free(host);
+			break;
+		}
+		free(host);
+	}
+	hostlist_destroy(hl);
+	
+	if (needed) {
+		slurm_drain_nodes(bg_record->nodes, reason);
+	}
+end_it:
+	while(bg_record->job_running > NO_JOB_RUNNING) {
+		debug2("block %s is still running job %d",
+		       bg_record->bg_block_id, bg_record->job_running);
+		sleep(1);
+	}
+	
+	slurm_mutex_lock(&block_state_mutex);
+	error("Setting Block %s to ERROR state.", bg_record->bg_block_id);
+	bg_record->job_running = BLOCK_ERROR_STATE;
+	bg_record->state = RM_PARTITION_ERROR;
+	slurm_mutex_unlock(&block_state_mutex);
+	trigger_block_error();
+	return;
+}
+
+extern int set_ionodes(bg_record_t *bg_record)
+{
+	int i = 0;
+	int start_bit = 0;
+	int size = 0;
+	char bitstring[BITSIZE];
+	
+	if(!bg_record)
+		return SLURM_ERROR;
+	/* set the bitmap blank here if it is a full node we don't
+	   want anything set we also don't want the bg_record->ionodes set.
+	*/
+	bg_record->ionode_bitmap = bit_alloc(bluegene_numpsets);
+	if(bg_record->quarter == (uint16_t)NO_VAL) {
+		return SLURM_SUCCESS;
+	}
+
+	start_bit = bluegene_quarter_ionode_cnt*bg_record->quarter;
+	
+	if(bg_record->nodecard != (uint16_t)NO_VAL
+	   && bluegene_nodecard_ionode_cnt) {
+		start_bit += bluegene_nodecard_ionode_cnt*bg_record->nodecard;
+		size = bluegene_nodecard_ionode_cnt;
+	} else
+		size = bluegene_quarter_ionode_cnt;
+	size += start_bit;
+
+	if(size == start_bit) {
+		error("start bit is the same as the end bit %d", size);
+		return SLURM_ERROR;
+	}
+	for(i=start_bit; i<size; i++)
+		bit_set(bg_record->ionode_bitmap, i);
+	
+	bit_fmt(bitstring, BITSIZE, bg_record->ionode_bitmap);
+	bg_record->ionodes = xstrdup(bitstring);
+
+	return SLURM_SUCCESS;
+}
+
+extern int add_bg_record(List records, List used_nodes, blockreq_t *blockreq)
+{
+	bg_record_t *bg_record = NULL;
+	bg_record_t *found_record = NULL;
+	ba_node_t *ba_node = NULL;
+	ListIterator itr;
+	struct passwd *pw_ent = NULL;
+	int i, len;
+	int small_size = 0;
+	int small_count = 0;
+	uint16_t quarter = 0;
+	uint16_t nodecard = 0;
+	int node_cnt = 0;
+	
+	if(!records) {
+		fatal("add_bg_record: no records list given");
+	}
+	bg_record = (bg_record_t*) xmalloc(sizeof(bg_record_t));
+	
+	slurm_conf_lock();
+	bg_record->user_name = 
+		xstrdup(slurmctld_conf.slurm_user_name);
+	bg_record->target_name = 
+		xstrdup(slurmctld_conf.slurm_user_name);
+	slurm_conf_unlock();
+	if((pw_ent = getpwnam(bg_record->user_name)) == NULL) {
+		error("getpwnam(%s): %m", bg_record->user_name);
+	} else {
+		bg_record->user_uid = pw_ent->pw_uid;
+	}
+
+	bg_record->bg_block_list = list_create(destroy_ba_node);
+	if(used_nodes) {
+		if(copy_node_path(used_nodes, bg_record->bg_block_list)
+		   == SLURM_ERROR)
+			error("couldn't copy the path for the allocation");
+		bg_record->bp_count = list_count(used_nodes);
+	}
+	bg_record->quarter = (uint16_t)NO_VAL;
+	bg_record->nodecard = (uint16_t)NO_VAL;
+	if(set_ionodes(bg_record) == SLURM_ERROR) {
+		fatal("add_bg_record: problem creating ionodes");
+	}
+	/* bg_record->boot_state = 0; 	Implicit */
+	/* bg_record->state = 0;	Implicit */
+	debug2("asking for %s %d %d %s", 
+	       blockreq->block, blockreq->quarters, blockreq->nodecards,
+	       convert_conn_type(blockreq->conn_type));
+	len = strlen(blockreq->block);
+	i=0;
+	while(i<len 
+	      && blockreq->block[i] != '[' 
+	      && (blockreq->block[i] < '0' || blockreq->block[i] > 'Z'
+		  || (blockreq->block[i] > '9' && blockreq->block[i] < 'A')))
+		i++;
+	
+	if(i<len) {
+		len -= i;
+		slurm_conf_lock();
+		len += strlen(slurmctld_conf.node_prefix)+1;
+		bg_record->nodes = xmalloc(len);
+		snprintf(bg_record->nodes, len, "%s%s", 
+			slurmctld_conf.node_prefix, blockreq->block+i);
+		slurm_conf_unlock();
+			
+	} else 
+		fatal("BPs=%s is in a weird format", blockreq->block); 
+	
+	process_nodes(bg_record, false);
+	
+	bg_record->node_use = SELECT_COPROCESSOR_MODE;
+	bg_record->conn_type = blockreq->conn_type;
+	bg_record->cpus_per_bp = procs_per_node;
+	bg_record->node_cnt = bluegene_bp_node_cnt * bg_record->bp_count;
+	bg_record->job_running = NO_JOB_RUNNING;
+
+	if(blockreq->blrtsimage)
+		bg_record->blrtsimage = xstrdup(blockreq->blrtsimage);
+	else
+		bg_record->blrtsimage = xstrdup(default_blrtsimage);
+
+	if(blockreq->linuximage)
+		bg_record->linuximage = xstrdup(blockreq->linuximage);
+	else
+		bg_record->linuximage = xstrdup(default_linuximage);
+
+	if(blockreq->mloaderimage)
+		bg_record->mloaderimage = xstrdup(blockreq->mloaderimage);
+	else
+		bg_record->mloaderimage = xstrdup(default_mloaderimage);
+
+	if(blockreq->ramdiskimage)
+		bg_record->ramdiskimage = xstrdup(blockreq->ramdiskimage);
+	else
+		bg_record->ramdiskimage = xstrdup(default_ramdiskimage);
+		
+	if(bg_record->conn_type != SELECT_SMALL) {
+		/* this needs to be an append so we keep things in the
+		   order we got them, they will be sorted later */
+		list_append(records, bg_record);
+		/* this isn't a correct list so we need to set it later for
+		   now we just used it to be the bp number */
+		if(!used_nodes) {
+			debug4("we didn't get a request list so we are "
+			       "destroying this bp list");
+			list_destroy(bg_record->bg_block_list);
+			bg_record->bg_block_list = NULL;
+		}
+	} else {
+		debug("adding a small block");
+		/* if the ionode cnt for nodecards is 0 then don't
+		   allow a nodecard allocation 
+		*/
+		if(!bluegene_nodecard_ionode_cnt) {
+			if(blockreq->nodecards) 
+				fatal("There is an error in your "
+				      "bluegene.conf file.\n"
+				      "Can't create a 32 node block with "
+				      "Numpsets=%u. (Try setting it to 64)",
+				      bluegene_numpsets);
+		}
+
+		if(blockreq->nodecards==0 && blockreq->quarters==0) {
+			info("No specs given for this small block, "
+			     "I am spliting this block into 4 quarters");
+			blockreq->quarters=4;
+		}		
+
+		i = (blockreq->nodecards*bluegene_nodecard_node_cnt) + 
+			(blockreq->quarters*bluegene_quarter_node_cnt);
+		if(i != bluegene_bp_node_cnt)
+			fatal("There is an error in your bluegene.conf file.\n"
+			      "I am unable to request %d nodes consisting of "
+			      "%u nodecards and\n%u quarters in one "
+			      "base partition with %u nodes.", 
+			      i, bluegene_bp_node_cnt, 
+			      blockreq->nodecards, blockreq->quarters);
+		small_count = blockreq->nodecards+blockreq->quarters; 
+		
+		/* Automatically create 4-way split if 
+		 * conn_type == SELECT_SMALL in bluegene.conf
+		 * Here we go through each node listed and do the same thing
+		 * for each node.
+		 */
+		itr = list_iterator_create(bg_record->bg_block_list);
+		while ((ba_node = list_next(itr)) != NULL) {
+			/* break base partition up into 16 parts */
+			small_size = 16;
+			node_cnt = 0;
+			quarter = 0;
+			nodecard = 0;
+			for(i=0; i<small_count; i++) {
+				if(i == blockreq->nodecards) {
+					/* break base partition 
+					   up into 4 parts */
+					small_size = 4;
+				}
+									
+				if(small_size == 4)
+					nodecard = (uint16_t)NO_VAL;
+				else
+					nodecard = i%4; 
+				found_record = create_small_record(bg_record,
+								   quarter,
+								   nodecard);
+								 
+				/* this needs to be an append so we
+				   keep things in the order we got
+				   them, they will be sorted later */
+				list_append(records, found_record);
+				node_cnt += bluegene_bp_node_cnt/small_size;
+				if(node_cnt == 128) {
+					node_cnt = 0;
+					quarter++;
+				}
+			}
+		}
+		list_iterator_destroy(itr);
+		destroy_bg_record(bg_record);
+	} 
+	return SLURM_SUCCESS;
+}
+
+extern int format_node_name(bg_record_t *bg_record, char *buf, int buf_size)
+{
+	if(bg_record->ionodes) {
+		snprintf(buf, buf_size, "%s[%s]",
+			bg_record->nodes,
+			bg_record->ionodes);
+	} else {
+		snprintf(buf, buf_size, "%s", bg_record->nodes);
+	}
+	return SLURM_SUCCESS;
+}
+
+/************************* local functions ***************************/
+
+#ifdef HAVE_BG
+static int _addto_node_list(bg_record_t *bg_record, int *start, int *end)
+{
+	int node_count=0;
+	int x,y,z;
+	char node_name_tmp[255];
+	ba_node_t *ba_node = NULL;
+
+	if ((start[X] < 0) || (start[Y] < 0) || (start[Z] < 0)) {
+		fatal("bluegene.conf starting coordinate is invalid: %d%d%d",
+		      start[X], start[Y], start[Z]);
+	}
+	if ((end[X] >= DIM_SIZE[X]) || (end[Y] >= DIM_SIZE[Y])
+	||  (end[Z] >= DIM_SIZE[Z])) {
+		fatal("bluegene.conf matrix size exceeds space defined in " 
+		      "slurm.conf %c%c%cx%d%d%d => %c%c%c",
+		      alpha_num[start[X]], alpha_num[start[Y]],
+		      alpha_num[start[Z]], 
+		      end[X], end[Y], end[Z], 
+		      alpha_num[DIM_SIZE[X]], alpha_num[DIM_SIZE[Y]], 
+		      alpha_num[DIM_SIZE[Z]]);
+	}
+	debug3("adding bps: %c%c%cx%c%c%c",
+	       alpha_num[start[X]], alpha_num[start[Y]], alpha_num[start[Z]],
+	       alpha_num[end[X]], alpha_num[end[Y]], alpha_num[end[Z]]);
+	debug3("slurm.conf:    %c%c%c",
+	       alpha_num[DIM_SIZE[X]], alpha_num[DIM_SIZE[Y]],
+	       alpha_num[DIM_SIZE[Z]]); 
+	
+	for (x = start[X]; x <= end[X]; x++) {
+		for (y = start[Y]; y <= end[Y]; y++) {
+			for (z = start[Z]; z <= end[Z]; z++) {
+				slurm_conf_lock();
+				snprintf(node_name_tmp, sizeof(node_name_tmp),
+					 "%s%c%c%c", 
+					 slurmctld_conf.node_prefix,
+					 alpha_num[x], alpha_num[y],
+					 alpha_num[z]);		
+				slurm_conf_unlock();
+				ba_node = ba_copy_node(
+					&ba_system_ptr->grid[x][y][z]);
+				ba_node->used = 1;
+				list_append(bg_record->bg_block_list, ba_node);
+				node_count++;
+			}
+		}
+	}
+	return node_count;
+}
+
+static int _ba_node_cmpf_inc(ba_node_t *node_a, ba_node_t *node_b)
+{
+	if (node_a->coord[X] < node_b->coord[X])
+		return -1;
+	else if (node_a->coord[X] > node_b->coord[X])
+		return 1;
+	
+	if (node_a->coord[Y] < node_b->coord[Y])
+		return -1;
+	else if (node_a->coord[Y] > node_b->coord[Y])
+		return 1;
+
+	if (node_a->coord[Z] < node_b->coord[Z])
+		return -1;
+	else if (node_a->coord[Z] > node_b->coord[Z])
+		return 1;
+
+	error("You have the node %c%c%c in the list twice",
+	      alpha_num[node_a->coord[X]],
+	      alpha_num[node_a->coord[Y]],
+	      alpha_num[node_a->coord[Z]]); 
+	return 0;
+}
+#endif //HAVE_BG
+
+
diff --git a/src/plugins/select/bluegene/plugin/bg_record_functions.h b/src/plugins/select/bluegene/plugin/bg_record_functions.h
new file mode 100644
index 0000000000000000000000000000000000000000..0c54869312caa5b21223ec953d93dee380fd5594
--- /dev/null
+++ b/src/plugins/select/bluegene/plugin/bg_record_functions.h
@@ -0,0 +1,136 @@
+/*****************************************************************************\
+ *  bg_record_functions.h - header for creating blocks in a static environment.
+ *
+ *  $Id: bg_record_functions.h 12954 2008-01-04 20:37:49Z da $
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _BLUEGENE_BG_RECORD_FUNCTIONS_H_
+#define _BLUEGENE_BG_RECORD_FUNCTIONS_H_
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <pwd.h>
+
+#include "src/common/bitstring.h"
+#include "src/common/hostlist.h"
+#include "src/common/list.h"
+#include "src/common/macros.h"
+#include "src/common/node_select.h"
+#include "src/common/parse_time.h"
+#include "src/slurmctld/slurmctld.h"
+
+#include "../block_allocator/block_allocator.h"
+
+typedef struct bg_record {
+	pm_partition_id_t bg_block_id;	/* ID returned from MMCS	*/
+	char *nodes;			/* String of nodes in block */
+	char *ionodes; 		        /* String of ionodes in block
+					 * NULL if not a small block*/
+	char *user_name;		/* user using the block */
+	char *target_name;		/* when a block is freed this 
+					   is the name of the user we 
+					   want on the block */
+	int full_block;                 /* whether or not block is the full
+					   block */
+	int modifying;                  /* flag to say the block is
+					   being modified or not at
+					   job launch usually */
+	uid_t user_uid;   		/* Owner of block uid	*/
+	rm_partition_state_t state;   	/* the allocated block   */
+	int start[BA_SYSTEM_DIMENSIONS];/* start node */
+	uint16_t geo[BA_SYSTEM_DIMENSIONS];  /* geometry */
+	rm_connection_type_t conn_type;	/* Mesh or Torus or NAV */
+	rm_partition_mode_t node_use;	/* either COPROCESSOR or VIRTUAL */
+	rm_partition_t *bg_block;       /* structure to hold info from db2 */
+	List bg_block_list;             /* node list of blocks in block */
+	int bp_count;                   /* size */
+	int switch_count;               /* number of switches used. */
+	int boot_state;                 /* check to see if boot failed. 
+					   -1 = fail, 
+					   0 = not booting, 
+					   1 = booting */
+	int boot_count;                 /* number of attemts boot attempts */
+	bitstr_t *bitmap;               /* bitmap to check the name 
+					   of block */
+	bitstr_t *ionode_bitmap;        /* for small blocks bitmap to
+					   keep track which ionodes we
+					   are on.  NULL if not a small block*/
+	struct job_record *job_ptr;	/* pointer to job running on
+					 * block or NULL if no job */
+	int job_running;                /* job id of job running of if
+					 * block is in an error state
+					 * BLOCK_ERROR_STATE */
+	int cpus_per_bp;                /* count of cpus per base part */
+	uint32_t node_cnt;              /* count of nodes per block */
+	uint16_t quarter;               /* used for small blocks 
+					   determine quarter of BP */
+	uint16_t nodecard;              /* used for small blocks 
+					   determine nodecard of quarter */
+	char *blrtsimage;              /* BlrtsImage for this block */
+	char *linuximage;              /* LinuxImage for this block */
+	char *mloaderimage;            /* mloaderImage for this block */
+	char *ramdiskimage;            /* RamDiskImage for this block */
+	struct bg_record *original;    /* if this is a copy this is a
+					  pointer to the original */
+} bg_record_t;
+
+/* Log a bg_record's contents */
+extern void print_bg_record(bg_record_t *record);
+extern void destroy_bg_record(void *object);
+extern int block_exist_in_list(List my_list, bg_record_t *bg_record);
+extern void process_nodes(bg_record_t *bg_reord, bool startup);
+extern List copy_bg_list(List in_list);
+extern void copy_bg_record(bg_record_t *fir_record, bg_record_t *sec_record);
+
+/* return bg_record from a bg_list */
+extern bg_record_t *find_bg_record_in_list(List my_list, char *bg_block_id);
+
+/* change username of a block bg_record_t target_name needs to be 
+   updated before call of function. 
+*/
+extern int update_block_user(bg_record_t *bg_block_id, int set); 
+extern void drain_as_needed(bg_record_t *bg_record, char *reason);
+
+extern int set_ionodes(bg_record_t *bg_record);
+
+extern int add_bg_record(List records, List used_nodes, blockreq_t *blockreq);
+
+extern int format_node_name(bg_record_t *bg_record, char *buf, int buf_size);
+
+#endif /* _BLUEGENE_BG_RECORD_FUNCTIONS_H_ */
diff --git a/src/plugins/select/bluegene/plugin/block_sys.c b/src/plugins/select/bluegene/plugin/block_sys.c
index 20f7288aaf0a6e0d13bbb002e41138bd8ea6e082..eb67ba679010dec460cec85342a33acd101e4495 100755
--- a/src/plugins/select/bluegene/plugin/block_sys.c
+++ b/src/plugins/select/bluegene/plugin/block_sys.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  block_sys.c - component used for wiring up the blocks
  *
- *  $Id: block_sys.c 11400 2007-04-24 18:50:38Z da $
+ *  $Id: block_sys.c 13960 2008-04-30 21:45:26Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -654,7 +654,7 @@ int read_bg_blocks()
 		       bg_record->bg_block_id, 
 		       bg_record->state);
 		
-		process_nodes(bg_record);
+		process_nodes(bg_record, false);
 	
 		if(bluegene_layout_mode == LAYOUT_DYNAMIC) {
 			bg_record_t *tmp_record = xmalloc(sizeof(bg_record_t));
diff --git a/src/plugins/select/bluegene/plugin/bluegene.c b/src/plugins/select/bluegene/plugin/bluegene.c
index 30684bf23bbe289a75e13cf728871205fd3dbff2..e6cf2017f6ca9211e35b4042881f6819b59f65cf 100644
--- a/src/plugins/select/bluegene/plugin/bluegene.c
+++ b/src/plugins/select/bluegene/plugin/bluegene.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  bluegene.c - blue gene node configuration processing module. 
  *
- *  $Id: bluegene.c 13271 2008-02-14 20:02:00Z da $
+ *  $Id: bluegene.c 13924 2008-04-23 06:24:55Z da $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -37,11 +37,9 @@
 \*****************************************************************************/
 
 #include "bluegene.h"
-#include "src/slurmctld/trigger_mgr.h"
+#include "defined_block.h"
 #include <stdio.h>
 
-#define BUFSIZE 4096
-#define BITSIZE 128
 #define MMCS_POLL_TIME 120	/* poll MMCS for down switches and nodes 
 				 * every 120 secs */
 #define BG_POLL_TIME 0	        /* poll bg blocks every 3 secs */
@@ -55,7 +53,6 @@ rm_BGL_t *bg = NULL;
 
 List bg_list = NULL;			/* total list of bg_record entries */
 List bg_curr_block_list = NULL;  	/* current bg blocks in bluegene.conf*/
-List bg_found_block_list = NULL;  	/* found bg blocks already on system */
 List bg_job_block_list = NULL;  	/* jobs running in these blocks */
 List bg_booted_block_list = NULL;  	/* blocks that are booted */
 List bg_freeing_list = NULL;  	        /* blocks that being freed */
@@ -97,21 +94,12 @@ int max_dim[BA_SYSTEM_DIMENSIONS] = { 0 };
 # endif
 #endif
 
-/* some local functions */
-#ifdef HAVE_BG
-static int  _addto_node_list(bg_record_t *bg_record, int *start, int *end);
-static int  _ba_node_cmpf_inc(ba_node_t *node_a, ba_node_t *node_b);
-#endif
 
 static void _set_bg_lists();
-static int  _validate_config_nodes(void);
+static int  _validate_config_nodes(List *bg_found_block_list);
 static int  _bg_record_cmpf_inc(bg_record_t *rec_a, bg_record_t *rec_b);
-static int _delete_old_blocks(void);
+static int _delete_old_blocks(List bg_found_block_list);
 static char *_get_bg_conf(void);
-static int _split_block(bg_record_t *bg_record, int procs);
-static int _breakup_blocks(ba_request_t *request, List my_block_list);
-static bg_record_t *_create_small_record(bg_record_t *bg_record, 
-					 uint16_t quarter, uint16_t nodecard);
 static int  _reopen_bridge_log(void);
 
 /* Initialize all plugin variables */
@@ -159,10 +147,6 @@ extern void fini_bg(void)
 		list_destroy(bg_curr_block_list);
 		bg_curr_block_list = NULL;
 	}	
-	if (bg_found_block_list) {
-		list_destroy(bg_found_block_list);
-		bg_found_block_list = NULL;
-	}
 	if (bg_job_block_list) {
 		list_destroy(bg_job_block_list);
 		bg_job_block_list = NULL;
@@ -217,487 +201,6 @@ extern void fini_bg(void)
 	ba_fini();
 }
 
-extern void print_bg_record(bg_record_t* bg_record)
-{
-	if (!bg_record) {
-		error("print_bg_record, record given is null");
-		return;
-	}
-#if _DEBUG
-	info(" bg_record: ");
-	if (bg_record->bg_block_id)
-		info("\tbg_block_id: %s", bg_record->bg_block_id);
-	info("\tnodes: %s", bg_record->nodes);
-	info("\tsize: %d BPs %u Nodes %d cpus", 
-	     bg_record->bp_count,
-	     bg_record->node_cnt,
-	     bg_record->cpus_per_bp * bg_record->bp_count);
-	info("\tgeo: %ux%ux%u", bg_record->geo[X], bg_record->geo[Y], 
-	     bg_record->geo[Z]);
-	info("\tconn_type: %s", convert_conn_type(bg_record->conn_type));
-	info("\tnode_use: %s", convert_node_use(bg_record->node_use));
-	if (bg_record->bitmap) {
-		char bitstring[BITSIZE];
-		bit_fmt(bitstring, BITSIZE, bg_record->bitmap);
-		info("\tbitmap: %s", bitstring);
-	}
-#else
-{
-	char tmp_char[256];
-	format_node_name(bg_record, tmp_char, sizeof(tmp_char));
-	info("Record: BlockID:%s Nodes:%s Conn:%s",
-	     bg_record->bg_block_id, tmp_char,
-	     convert_conn_type(bg_record->conn_type));
-}
-#endif
-}
-
-extern void destroy_bg_record(void *object)
-{
-	bg_record_t* bg_record = (bg_record_t*) object;
-
-	if (bg_record) {
-		xfree(bg_record->bg_block_id);
-		xfree(bg_record->nodes);
-		xfree(bg_record->ionodes);
-		xfree(bg_record->user_name);
-		xfree(bg_record->target_name);
-		if(bg_record->bg_block_list)
-			list_destroy(bg_record->bg_block_list);
-		FREE_NULL_BITMAP(bg_record->bitmap);
-		FREE_NULL_BITMAP(bg_record->ionode_bitmap);
-
-		xfree(bg_record->blrtsimage);
-		xfree(bg_record->linuximage);
-		xfree(bg_record->mloaderimage);
-		xfree(bg_record->ramdiskimage);
-
-		xfree(bg_record);
-	}
-}
-
-extern int block_exist_in_list(List my_list, bg_record_t *bg_record)
-{
-	ListIterator itr = list_iterator_create(my_list);
-	bg_record_t *found_record = NULL;
-	int rc = 0;
-
-	while ((found_record = (bg_record_t *) list_next(itr)) != NULL) {
-		/* check for full node bitmap compare */
-		if(bit_equal(bg_record->bitmap, found_record->bitmap)
-		   && bit_equal(bg_record->ionode_bitmap,
-				found_record->ionode_bitmap)) {
-			if(bg_record->ionodes)
-				debug3("This block %s[%s] "
-				       "is already in the list %s",
-				       bg_record->nodes,
-				       bg_record->ionodes,
-				       found_record->bg_block_id);
-			else
-				debug3("This block %s "
-				       "is already in the list %s",
-				       bg_record->nodes,
-				       found_record->bg_block_id);
-				
-			rc = 1;
-			break;
-		}
-	}
-	list_iterator_destroy(itr);
-	return rc;
-}
-
-extern void process_nodes(bg_record_t *bg_record)
-{
-#ifdef HAVE_BG
-	int j=0, number;
-	int start[BA_SYSTEM_DIMENSIONS];
-	int end[BA_SYSTEM_DIMENSIONS];
-	ListIterator itr;
-	ba_node_t* ba_node = NULL;
-	
-	if(!bg_record->bg_block_list 
-	   || !list_count(bg_record->bg_block_list)) {
-		if(!bg_record->bg_block_list) {
-			bg_record->bg_block_list =
-				list_create(destroy_ba_node);
-		}
-		bg_record->bp_count = 0;
-		
-		while (bg_record->nodes[j] != '\0') {
-			if ((bg_record->nodes[j] == '['
-			     || bg_record->nodes[j] == ',')
-			    && (bg_record->nodes[j+8] == ']' 
-				|| bg_record->nodes[j+8] == ',')
-			    && (bg_record->nodes[j+4] == 'x'
-				|| bg_record->nodes[j+4] == '-')) {
-				j++;
-				number = xstrntol(bg_record->nodes + j,
-						  NULL, BA_SYSTEM_DIMENSIONS,
-						  HOSTLIST_BASE);
-				start[X] = number / 
-					(HOSTLIST_BASE * HOSTLIST_BASE);
-				start[Y] = (number % 
-					    (HOSTLIST_BASE * HOSTLIST_BASE))
-					/ HOSTLIST_BASE;
-				start[Z] = (number % HOSTLIST_BASE);
-				j += 4;
-				number = xstrntol(bg_record->nodes + j,
-						NULL, 3, HOSTLIST_BASE);
-				end[X] = number /
-					(HOSTLIST_BASE * HOSTLIST_BASE);
-				end[Y] = (number 
-					  % (HOSTLIST_BASE * HOSTLIST_BASE))
-					/ HOSTLIST_BASE;
-				end[Z] = (number % HOSTLIST_BASE);
-				j += 3;
-				if(!bg_record->bp_count) {
-					bg_record->start[X] = start[X];
-					bg_record->start[Y] = start[Y];
-					bg_record->start[Z] = start[Z];
-					debug2("start is %dx%dx%d",
-					       bg_record->start[X],
-					       bg_record->start[Y],
-					       bg_record->start[Z]);
-				}
-				bg_record->bp_count += _addto_node_list(
-					bg_record, 
-					start, 
-					end);
-				if(bg_record->nodes[j] != ',')
-					break;
-				j--;
-			} else if((bg_record->nodes[j] >= '0'
-				   && bg_record->nodes[j] <= '9')
-				  || (bg_record->nodes[j] >= 'A'
-				      && bg_record->nodes[j] <= 'Z')) {
-				
-				number = xstrntol(bg_record->nodes + j,
-						  NULL, BA_SYSTEM_DIMENSIONS,
-						  HOSTLIST_BASE);
-				start[X] = number / 
-					(HOSTLIST_BASE * HOSTLIST_BASE);
-				start[Y] = (number % 
-					    (HOSTLIST_BASE * HOSTLIST_BASE))
-					/ HOSTLIST_BASE;
-				start[Z] = (number % HOSTLIST_BASE);
-				j+=3;
-				if(!bg_record->bp_count) {
-					bg_record->start[X] = start[X];
-					bg_record->start[Y] = start[Y];
-					bg_record->start[Z] = start[Z];
-					debug2("start is %dx%dx%d",
-					       bg_record->start[X],
-					       bg_record->start[Y],
-					       bg_record->start[Z]);
-				}
-				bg_record->bp_count += _addto_node_list(
-					bg_record, 
-					start, 
-					start);
-				if(bg_record->nodes[j] != ',')
-					break;
-				j--;
-			}
-			j++;
-		}
-	}
-	
-	bg_record->geo[X] = 0;
-	bg_record->geo[Y] = 0;
-	bg_record->geo[Z] = 0;
-	end[X] = -1;
-	end[Y] = -1;
-	end[Z] = -1;
-
-	list_sort(bg_record->bg_block_list, (ListCmpF) _ba_node_cmpf_inc);
-
-	itr = list_iterator_create(bg_record->bg_block_list);
-	while ((ba_node = list_next(itr)) != NULL) {
-		if(!ba_node->used)
-			continue;
-		debug4("%c%c%c is included in this block",
-		       alpha_num[ba_node->coord[X]],
-		       alpha_num[ba_node->coord[Y]],
-		       alpha_num[ba_node->coord[Z]]);
-		       
-		if(ba_node->coord[X]>end[X]) {
-			bg_record->geo[X]++;
-			end[X] = ba_node->coord[X];
-		}
-		if(ba_node->coord[Y]>end[Y]) {
-			bg_record->geo[Y]++;
-			end[Y] = ba_node->coord[Y];
-		}
-		if(ba_node->coord[Z]>end[Z]) {
-			bg_record->geo[Z]++;
-			end[Z] = ba_node->coord[Z];
-		}
-	}
-	list_iterator_destroy(itr);
-	debug3("geo = %c%c%c bp count is %d\n",
-	       alpha_num[bg_record->geo[X]],
-	       alpha_num[bg_record->geo[Y]],
-	       alpha_num[bg_record->geo[Z]],
-	       bg_record->bp_count);
-
-	if ((bg_record->geo[X] == DIM_SIZE[X])
-	    && (bg_record->geo[Y] == DIM_SIZE[Y])
-	    && (bg_record->geo[Z] == DIM_SIZE[Z])) {
-		bg_record->full_block = 1;	
-	}	
-	
-#ifndef HAVE_BG_FILES
-	max_dim[X] = MAX(max_dim[X], end[X]);
-	max_dim[Y] = MAX(max_dim[Y], end[Y]);
-	max_dim[Z] = MAX(max_dim[Z], end[Z]);
-#endif
-   
-	if (node_name2bitmap(bg_record->nodes, 
-			     false, 
-			     &bg_record->bitmap)) {
-		fatal("1 Unable to convert nodes %s to bitmap", 
-		      bg_record->nodes);
-	}
-#endif
-	return;
-}
-
-extern void copy_bg_record(bg_record_t *fir_record, bg_record_t *sec_record)
-{
-	int i;
-	ListIterator itr = NULL;
-	ba_node_t *ba_node = NULL, *new_ba_node = NULL;
-
-	xfree(sec_record->bg_block_id);
-	sec_record->bg_block_id = xstrdup(fir_record->bg_block_id);
-	xfree(sec_record->nodes);
-	sec_record->nodes = xstrdup(fir_record->nodes);
-	xfree(sec_record->ionodes);
-	sec_record->ionodes = xstrdup(fir_record->ionodes);
-	xfree(sec_record->user_name);
-	sec_record->user_name = xstrdup(fir_record->user_name);
-	xfree(sec_record->target_name);
-	sec_record->target_name = xstrdup(fir_record->target_name);
-
-	xfree(sec_record->blrtsimage);
-	sec_record->blrtsimage = xstrdup(fir_record->blrtsimage);
-	xfree(sec_record->linuximage);
-	sec_record->linuximage = xstrdup(fir_record->linuximage);
-	xfree(sec_record->mloaderimage);
-	sec_record->mloaderimage = xstrdup(fir_record->mloaderimage);
-	xfree(sec_record->ramdiskimage);
-	sec_record->ramdiskimage = xstrdup(fir_record->ramdiskimage);
-
-	sec_record->user_uid = fir_record->user_uid;
-	sec_record->state = fir_record->state;
-	sec_record->conn_type = fir_record->conn_type;
-	sec_record->node_use = fir_record->node_use;
-	sec_record->bp_count = fir_record->bp_count;
-	sec_record->switch_count = fir_record->switch_count;
-	sec_record->boot_state = fir_record->boot_state;
-	sec_record->boot_count = fir_record->boot_count;
-	sec_record->full_block = fir_record->full_block;
-
-	for(i=0;i<BA_SYSTEM_DIMENSIONS;i++) {
-		sec_record->geo[i] = fir_record->geo[i];
-		sec_record->start[i] = fir_record->start[i];
-	}
-
-	FREE_NULL_BITMAP(sec_record->bitmap);
-	if(fir_record->bitmap 
-	   && (sec_record->bitmap = bit_copy(fir_record->bitmap)) == NULL) {
-		error("Unable to copy bitmap for %s", fir_record->nodes);
-		sec_record->bitmap = NULL;
-	}
-	FREE_NULL_BITMAP(sec_record->ionode_bitmap);
-	if(fir_record->ionode_bitmap 
-	   && (sec_record->ionode_bitmap
-	       = bit_copy(fir_record->ionode_bitmap)) == NULL) {
-		error("Unable to copy ionode_bitmap for %s",
-		      fir_record->nodes);
-		sec_record->ionode_bitmap = NULL;
-	}
-	if(sec_record->bg_block_list)
-		list_destroy(sec_record->bg_block_list);
-	sec_record->bg_block_list = list_create(destroy_ba_node);
-	if(fir_record->bg_block_list) {
-		itr = list_iterator_create(fir_record->bg_block_list);
-		while((ba_node = list_next(itr))) {
-			new_ba_node = ba_copy_node(ba_node);
-			list_push(sec_record->bg_block_list, new_ba_node);
-		}
-		list_iterator_destroy(itr);
-	}
-	sec_record->job_running = fir_record->job_running;
-	sec_record->cpus_per_bp = fir_record->cpus_per_bp;
-	sec_record->node_cnt = fir_record->node_cnt;
-	sec_record->quarter = fir_record->quarter;
-	sec_record->nodecard = fir_record->nodecard;
-}
-
-extern bg_record_t *find_bg_record_in_list(List my_list, char *bg_block_id)
-{
-	ListIterator itr;
-	bg_record_t *bg_record = NULL;
-		
-	if(!bg_block_id)
-		return NULL;
-			
-	if(my_list) {
-		slurm_mutex_lock(&block_state_mutex);
-		itr = list_iterator_create(my_list);
-		while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
-			if(bg_record->bg_block_id)
-				if (!strcmp(bg_record->bg_block_id, 
-					    bg_block_id))
-					break;
-		}
-		list_iterator_destroy(itr);
-		slurm_mutex_unlock(&block_state_mutex);
-		if(bg_record)
-			return bg_record;
-		else
-			return NULL;
-	} else {
-		error("find_bg_record_in_list: no list");
-		return NULL;
-	}
-	
-}
-/* All changes to the bg_list target_name must 
-   be done before this function is called. 
-   also slurm_conf_lock() must be called before calling this
-   function along with slurm_conf_unlock() afterwards.		
-*/
-extern int update_block_user(bg_record_t *bg_record, int set) 
-{
-	struct passwd *pw_ent = NULL;
-
-	if(!bg_record->target_name) {
-		error("Must set target_name to run update_block_user.");
-		return -1;
-	}
-	if(!bg_record->user_name) {
-		error("No user_name");
-		bg_record->user_name = xstrdup(slurmctld_conf.slurm_user_name);
-	}
-#ifdef HAVE_BG_FILES
-	int rc=0;	
-	if(set) {
-		if((rc = remove_all_users(bg_record->bg_block_id, 
-					  bg_record->target_name))
-		   == REMOVE_USER_ERR) {
-			error("1 Something happened removing "
-			      "users from block %s", 
-			      bg_record->bg_block_id);
-			return -1;
-		} else if (rc == REMOVE_USER_NONE) {
-			if (strcmp(bg_record->target_name, 
-				   slurmctld_conf.slurm_user_name)) {
-				info("Adding user %s to Block %s",
-				     bg_record->target_name, 
-				     bg_record->bg_block_id);
-				
-				if ((rc = bridge_add_block_user(
-					     bg_record->bg_block_id, 
-					     bg_record->target_name)) 
-				    != STATUS_OK) {
-					error("bridge_add_block_user"
-					      "(%s,%s): %s", 
-					      bg_record->bg_block_id, 
-					      bg_record->target_name,
-					      bg_err_str(rc));
-					return -1;
-				} 
-			}
-		}
-	}
-#endif
-	
-	if(strcmp(bg_record->target_name, bg_record->user_name)) {
-		xfree(bg_record->user_name);
-		bg_record->user_name = xstrdup(bg_record->target_name);
-		if((pw_ent = getpwnam(bg_record->user_name)) == NULL) {
-			error("getpwnam(%s): %m", bg_record->user_name);
-			return -1;
-		} else {
-			bg_record->user_uid = pw_ent->pw_uid; 
-		}		
-		return 1;
-	}
-	
-	return 0;
-}
-
-/* If any nodes in node_list are drained, draining, or down, 
- *   then just return
- *   else drain all of the nodes
- * This function lets us drain an entire bgblock only if 
- * we have not already identified a specific node as bad. */
-extern void drain_as_needed(bg_record_t *bg_record, char *reason)
-{
-	bool needed = true;
-	hostlist_t hl;
-	char *host = NULL;
-	char bg_down_node[128];
-
-	if(bg_record->job_running > NO_JOB_RUNNING)
-		slurm_fail_job(bg_record->job_running);			
-
-	/* small blocks */
-	if(bg_record->cpus_per_bp != procs_per_node) {
-		debug2("small block");
-		goto end_it;
-	}
-	
-	/* at least one base partition */
-	hl = hostlist_create(bg_record->nodes);
-	if (!hl) {
-		slurm_drain_nodes(bg_record->nodes, reason);
-		return;
-	}
-	while ((host = hostlist_shift(hl))) {
-		if (node_already_down(bg_down_node)) {
-			needed = false;
-			free(host);
-			break;
-		}
-		free(host);
-	}
-	hostlist_destroy(hl);
-	
-	if (needed) {
-		slurm_drain_nodes(bg_record->nodes, reason);
-	}
-end_it:
-	while(bg_record->job_running > NO_JOB_RUNNING) {
-		debug2("block %s is still running job %d",
-		       bg_record->bg_block_id, bg_record->job_running);
-		sleep(1);
-	}
-	
-	slurm_mutex_lock(&block_state_mutex);
-	error("Setting Block %s to ERROR state.", bg_record->bg_block_id);
-	bg_record->job_running = BLOCK_ERROR_STATE;
-	bg_record->state = RM_PARTITION_ERROR;
-	slurm_mutex_unlock(&block_state_mutex);
-	trigger_block_error();
-	return;
-}
-
-extern int format_node_name(bg_record_t *bg_record, char *buf, int buf_size)
-{
-	if(bg_record->ionodes) {
-		snprintf(buf, buf_size, "%s[%s]",
-			bg_record->nodes,
-			bg_record->ionodes);
-	} else {
-		snprintf(buf, buf_size, "%s", bg_record->nodes);
-	}
-	return SLURM_SUCCESS;
-}
-
 extern bool blocks_overlap(bg_record_t *rec_a, bg_record_t *rec_b)
 {
 	bitstr_t *my_bitmap = NULL;
@@ -886,10 +389,8 @@ extern char* convert_node_use(rm_partition_mode_t pt)
 extern void sort_bg_record_inc_size(List records){
 	if (records == NULL)
 		return;
-	slurm_mutex_lock(&block_state_mutex);
 	list_sort(records, (ListCmpF) _bg_record_cmpf_inc);
 	last_bg_update = time(NULL);
-	slurm_mutex_unlock(&block_state_mutex);
 }
 
 /*
@@ -925,659 +426,21 @@ extern void *bluegene_agent(void *args)
 					if((rc = update_freeing_block_list())
 					   == -1)
 						error("Error with "
-						      "update_block_list 2");
-				}
-			}
-		}
-
-		if (difftime(now, last_mmcs_test) >= MMCS_POLL_TIME) {
-			if (agent_fini)		/* don't bother */
-				return NULL;	/* quit now */
-			last_mmcs_test = now;
-			test_mmcs_failures();	/* can run for a while */
-		}	
-				
-		sleep(1);
-	}
-	return NULL;
-}
-
-/*
- * create_defined_blocks - create the static blocks that will be used
- * for scheduling, all partitions must be able to be created and booted
- * at once.  
- * IN - int overlapped, 1 if partitions are to be overlapped, 0 if they are
- * static.
- * RET - success of fitting all configurations
- */
-extern int create_defined_blocks(bg_layout_t overlapped)
-{
-	int rc = SLURM_SUCCESS;
-
-	ListIterator itr;
-	bg_record_t *bg_record = NULL;
-	ListIterator itr_found;
-	int i;
-	bg_record_t *found_record = NULL;
-	int geo[BA_SYSTEM_DIMENSIONS];
-	char temp[256];
-	List results = NULL;
-	
-#ifdef HAVE_BG_FILES
-	init_wires();
-#endif
-	slurm_mutex_lock(&block_state_mutex);
-	reset_ba_system(false);
-	if(bg_list) {
-		itr = list_iterator_create(bg_list);
-		while((bg_record = list_next(itr))) {
-			if(bg_found_block_list) {
-				itr_found = list_iterator_create(
-					bg_found_block_list);
-				while ((found_record = (bg_record_t*) 
-					list_next(itr_found)) != NULL) {
-/* 					info("%s.%d.%d ?= %s.%d.%d\n", */
-/* 					     bg_record->nodes, */
-/* 					     bg_record->quarter, */
-/* 					     bg_record->nodecard, */
-/* 					     found_record->nodes, */
-/* 					     found_record->quarter, */
-/* 					     found_record->nodecard); */
-					
-					if ((bit_equal(bg_record->bitmap, 
-						       found_record->bitmap))
-					    && (bg_record->quarter ==
-						found_record->quarter)
-					    && (bg_record->nodecard ==
-						found_record->nodecard)) {
-						/* don't reboot this one */
-						break;	
-					}
-				}
-				list_iterator_destroy(itr_found);
-			} else {
-				error("create_defined_blocks: "
-				      "no bg_found_block_list 1");
-			}
-			if(bg_record->bp_count>0 
-			   && !bg_record->full_block
-			   && bg_record->cpus_per_bp == procs_per_node) {
-				char *name = NULL;
-				if(overlapped == LAYOUT_OVERLAP) {
-					reset_ba_system(false);
-					set_all_bps_except(bg_record->nodes);
-				}
-				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-					geo[i] = bg_record->geo[i];
-				debug2("adding %s %c%c%c %c%c%c",
-				       bg_record->nodes,
-				       alpha_num[bg_record->start[X]],
-				       alpha_num[bg_record->start[Y]],
-				       alpha_num[bg_record->start[Z]],
-				       alpha_num[geo[X]],
-				       alpha_num[geo[Y]],
-				       alpha_num[geo[Z]]);
-				if(bg_record->bg_block_list
-				   && list_count(bg_record->bg_block_list)) {
-					if(check_and_set_node_list(
-						   bg_record->bg_block_list)
-					   == SLURM_ERROR) {
-						debug2("something happened in "
-						       "the load of %s"
-						       "Did you use smap to "
-						       "make the "
-						       "bluegene.conf file?",
-						       bg_record->bg_block_id);
-						list_iterator_destroy(itr);
-						slurm_mutex_unlock(
-							&block_state_mutex);
-						return SLURM_ERROR;
-					}
-				} else {
-					results = list_create(NULL);
-					name = set_bg_block(
-						results,
-						bg_record->start, 
-						geo, 
-						bg_record->conn_type);
-					if(!name) {
-						error("I was unable to "
-						      "make the "
-						      "requested block.");
-						list_destroy(results);
-						list_iterator_destroy(itr);
-						slurm_mutex_unlock(
-							&block_state_mutex);
-						return SLURM_ERROR;
-					}
-					slurm_conf_lock();
-					snprintf(temp, sizeof(temp), "%s%s",
-						 slurmctld_conf.node_prefix,
-						 name);
-					slurm_conf_unlock();
-					xfree(name);
-					if(strcmp(temp, bg_record->nodes)) {
-						fatal("given list of %s "
-						      "but allocated %s, "
-						      "your order might be "
-						      "wrong in the "
-						      "bluegene.conf",
-						      bg_record->nodes,
-						      temp);
-					}
-					if(bg_record->bg_block_list)
-						list_destroy(bg_record->
-							     bg_block_list);
-					bg_record->bg_block_list =
-						list_create(destroy_ba_node);
-					copy_node_path(
-						results, 
-						bg_record->bg_block_list);
-					list_destroy(results);
-				}
-			}
-			if(found_record == NULL) {
-				if(bg_record->full_block) {
-					/* if this is defined we need
-					   to remove it since we are
-					   going to try to create it
-					   later on overlap systems
-					   this doesn't matter, but
-					   since we don't clear the
-					   table on static mode we
-					   can't do it here or it just
-					   won't work since other
-					   wires will be or are
-					   already set
-					*/ 
-					list_remove(itr);
-					continue;
-				}
-				if((rc = configure_block(bg_record)) 
-				   == SLURM_ERROR) {
-					list_iterator_destroy(itr);
-					slurm_mutex_unlock(&block_state_mutex);
-					return rc;
-				}
-				print_bg_record(bg_record);
-			}
-		}
-		list_iterator_destroy(itr);
-	} else {
-		error("create_defined_blocks: no bg_list 2");
-		slurm_mutex_unlock(&block_state_mutex);
-		return SLURM_ERROR;
-	}
-	slurm_mutex_unlock(&block_state_mutex);
-	create_full_system_block();
-	sort_bg_record_inc_size(bg_list);
-	
-#ifdef _PRINT_BLOCKS_AND_EXIT
-	if(bg_list) {
-		itr = list_iterator_create(bg_list);
-		debug("\n\n");
-		while ((found_record = (bg_record_t *) list_next(itr)) 
-		       != NULL) {
-			print_bg_record(found_record);
-		}
-		list_iterator_destroy(itr);
-	} else {
-		error("create_defined_blocks: no bg_list 5");
-	}
- 	exit(0);
-#endif	/* _PRINT_BLOCKS_AND_EXIT */
-	rc = SLURM_SUCCESS;
-	//exit(0);
-	return rc;
-}
-
-
-
-/*
- * create_dynamic_block - create a new block to be used for a new
- * job allocation.  This will be added to the booted and job bg_lists.
- * RET - success of fitting configuration in the running system.
- */
-extern int create_dynamic_block(ba_request_t *request, List my_block_list)
-{
-	int rc = SLURM_SUCCESS;
-	
-	ListIterator itr;
-	bg_record_t *bg_record = NULL;
-	List results = NULL;
-	List requests = NULL;
-	uint16_t num_quarter=0, num_nodecard=0;
-	bitstr_t *my_bitmap = NULL;
-	int geo[BA_SYSTEM_DIMENSIONS];
-	int i;
-	blockreq_t blockreq;
-
-	slurm_mutex_lock(&block_state_mutex);
-		
-	if(my_block_list) {
-		reset_ba_system(true);
-		itr = list_iterator_create(my_block_list);
-		while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
-			if(!my_bitmap) {
-				my_bitmap = 
-					bit_alloc(bit_size(bg_record->bitmap));
-			}
-				
-			if(!bit_super_set(bg_record->bitmap, my_bitmap)) {
-				bit_or(my_bitmap, bg_record->bitmap);
-				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-					geo[i] = bg_record->geo[i];
-				debug2("adding %s %c%c%c %c%c%c",
-				       bg_record->nodes,
-				       alpha_num[bg_record->start[X]],
-				       alpha_num[bg_record->start[Y]],
-				       alpha_num[bg_record->start[Z]],
-				       alpha_num[geo[X]],
-				       alpha_num[geo[Y]],
-				       alpha_num[geo[Z]]);
-
-				if(check_and_set_node_list(
-					   bg_record->bg_block_list)
-				   == SLURM_ERROR) {
-					debug2("something happened in "
-					      "the load of %s",
-					      bg_record->bg_block_id);
-					list_iterator_destroy(itr);
-					slurm_mutex_unlock(&block_state_mutex);
-					FREE_NULL_BITMAP(my_bitmap);
-					return SLURM_ERROR;
-				}
-				//set_node_list(bg_record->bg_block_list);
-/* #endif	 */
-			}
-		}
-		list_iterator_destroy(itr);
-		FREE_NULL_BITMAP(my_bitmap);
-	} else {
-		reset_ba_system(false);
-		debug("No list was given");
-	}
-
-	if(request->avail_node_bitmap) {
-		int j=0, number;
-		int x,y,z;
-		char *nodes = NULL;
-		bitstr_t *bitmap = bit_alloc(node_record_count);
-		int start[BA_SYSTEM_DIMENSIONS];
-		int end[BA_SYSTEM_DIMENSIONS];
-
-		/* we want the bps that aren't in this partition to
-		 * mark them as used
-		 */
-		bit_or(bitmap, request->avail_node_bitmap);
-		bit_not(bitmap);
-		nodes = bitmap2node_name(bitmap);
-		//info("not using %s", nodes);
-		while(nodes[j] != '\0') {
-			if ((nodes[j] == '[' || nodes[j] == ',')
-			    && (nodes[j+8] == ']' || nodes[j+8] == ',')
-			    && (nodes[j+4] == 'x' || nodes[j+4] == '-')) {
-				j++;
-				number = xstrntol(nodes + j,
-						  NULL, BA_SYSTEM_DIMENSIONS,
-						  HOSTLIST_BASE);
-				start[X] = number / 
-					(HOSTLIST_BASE * HOSTLIST_BASE);
-				start[Y] = (number % 
-					    (HOSTLIST_BASE * HOSTLIST_BASE))
-					/ HOSTLIST_BASE;
-				start[Z] = (number % HOSTLIST_BASE);
-				j += 4;
-				number = xstrntol(nodes + j,
-						NULL, 3, HOSTLIST_BASE);
-				end[X] = number /
-					(HOSTLIST_BASE * HOSTLIST_BASE);
-				end[Y] = (number 
-					  % (HOSTLIST_BASE * HOSTLIST_BASE))
-					/ HOSTLIST_BASE;
-				end[Z] = (number % HOSTLIST_BASE);
-				j += 3;
-				for (x = start[X]; x <= end[X]; x++) {
-					for (y = start[Y]; y <= end[Y]; y++) {
-						for (z = start[Z]; 
-						     z <= end[Z]; z++) {
-							ba_system_ptr->
-								grid[x]
-#ifdef HAVE_BG
-								[y][z]
-#endif
-								.used = 1;
-						}
-					}
-				}
-				
-				if(nodes[j] != ',')
-					break;
-				j--;
-			} else if((nodes[j] >= '0' && nodes[j] <= '9')
-				  || (nodes[j] >= 'A' && nodes[j] <= 'Z')) {
-				
-				number = xstrntol(nodes + j,
-						  NULL, BA_SYSTEM_DIMENSIONS,
-						  HOSTLIST_BASE);
-				x = number / (HOSTLIST_BASE * HOSTLIST_BASE);
-				y = (number % (HOSTLIST_BASE * HOSTLIST_BASE))
-					/ HOSTLIST_BASE;
-				z = (number % HOSTLIST_BASE);
-				j+=3;
-				ba_system_ptr->grid[x]
-#ifdef HAVE_BG
-					[y][z]
-#endif
-					.used = 1;
-
-				if(nodes[j] != ',') 
-					break;
-				j--;
-			}
-			j++;
-		}
-		xfree(nodes);
-		FREE_NULL_BITMAP(bitmap);
-	}
-
-	if(request->size==1 && request->procs < bluegene_bp_node_cnt) {
-		request->conn_type = SELECT_SMALL;
-		if(request->procs == (procs_per_node/16)) {
-			if(!bluegene_nodecard_ionode_cnt) {
-				error("can't create this size %d "
-				      "on this system numpsets is %d",
-				      request->procs,
-				      bluegene_numpsets);
-				goto finished;
-			}
-
-			num_nodecard=4;
-			num_quarter=3;
-		} else {
-			if(!bluegene_quarter_ionode_cnt) {
-				error("can't create this size %d "
-				      "on this system numpsets is %d",
-				      request->procs,
-				      bluegene_numpsets);
-				goto finished;
-			}
-			num_quarter=4;
-		}
-
-		if(_breakup_blocks(request, my_block_list) != SLURM_SUCCESS) {
-			debug2("small block not able to be placed");
-			//rc = SLURM_ERROR;
-		} else 
-			goto finished;
-	}
-		
-	if(request->conn_type == SELECT_NAV)
-		request->conn_type = SELECT_TORUS;
-	
-	if(!new_ba_request(request)) {
-		error("Problems with request for size %d geo %dx%dx%d", 
-		      request->size,
-		      request->geometry[X], 
-		      request->geometry[Y], 
-		      request->geometry[Z]);
-		rc = SLURM_ERROR;
-		goto finished;
-	} 
-	
-	if(!list_count(bg_list) || !my_block_list) {
-		bg_record = NULL;
-		goto no_list;
-	}
-
-	/*Try to put block starting in the smallest of the exisiting blocks*/
-	if(!request->start_req) {
-		itr = list_iterator_create(bg_list);
-		while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
-			request->rotate_count = 0;
-			request->elongate_count = 1;
-		
-			if(bg_record->job_running == NO_JOB_RUNNING 
-			   && (bg_record->quarter == (uint16_t) NO_VAL
-			       || (bg_record->quarter == 0 
-				   && (bg_record->nodecard == (uint16_t) NO_VAL
-				       || bg_record->nodecard == 0)))) {
-				
-				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-					request->start[i] = 
-						bg_record->start[i];
-				debug2("allocating %s %c%c%c %d",
-				       bg_record->nodes,
-				       alpha_num[request->start[X]],
-				       alpha_num[request->start[Y]],
-				       alpha_num[request->start[Z]],
-				       request->size);
-				request->start_req = 1;
-				rc = SLURM_SUCCESS;
-				if(results)
-					list_delete_all(
-						results,
-						&empty_null_destroy_list, "");
-				else
-					results = list_create(NULL);
-				if (!allocate_block(request, results)){
-					debug2("allocate failure for size %d "
-					       "base partitions", 
-					       request->size);
-					rc = SLURM_ERROR;
-				} else 
-					break;
-			}
-		}
-		list_iterator_destroy(itr);
-		
-		request->start_req = 0;
-		for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-			request->start[i] = (uint16_t) NO_VAL;
-	}
-no_list:
-	if(!bg_record) {		
-		rc = SLURM_SUCCESS;
-		if(results)
-			list_delete_all(results, 
-					&empty_null_destroy_list, "");
-		else
-			results = list_create(NULL);
-		if (!allocate_block(request, results)) {
-			debug("allocate failure for size %d base partitions", 
-			      request->size);
-			rc = SLURM_ERROR;
-		}
-	}
-
-	if(rc == SLURM_ERROR || !my_block_list) {
-		goto finished;
-	}
-	/*set up bg_record(s) here */
-	requests = list_create(destroy_bg_record);
-	
-	blockreq.block = request->save_name;
-	blockreq.blrtsimage = request->blrtsimage;
-	blockreq.linuximage = request->linuximage;
-	blockreq.mloaderimage = request->mloaderimage;
-	blockreq.ramdiskimage = request->ramdiskimage;
-	blockreq.conn_type = request->conn_type;
-	blockreq.nodecards = num_nodecard;
-	blockreq.quarters = num_quarter;
-
-	add_bg_record(requests, results, &blockreq);
-
-	while((bg_record = (bg_record_t *) list_pop(requests)) != NULL) {
-		if(block_exist_in_list(bg_list, bg_record))
-			destroy_bg_record(bg_record);
-		else {
-			if(configure_block(bg_record) == SLURM_ERROR) {
-				destroy_bg_record(bg_record);
-				error("create_dynamic_block: "
-				      "unable to configure block in api");
-				goto finished;
-			}
-			
-			list_append(bg_list, bg_record);
-			print_bg_record(bg_record);
-		}
-	}
-
-finished:
-	if(my_block_list)
-		xfree(request->save_name);
-	if(request->elongate_geos)
-		list_destroy(request->elongate_geos);
-	if(results)
-		list_destroy(results);
-	if(requests)
-		list_destroy(requests);
-	
-	slurm_mutex_unlock(&block_state_mutex);
-	sort_bg_record_inc_size(bg_list);
-	
-	return rc;
-}
-
-extern int create_full_system_block()
-{
-	int rc = SLURM_SUCCESS;
-	ListIterator itr;
-	bg_record_t *bg_record = NULL;
-	char *name = NULL;
-	List records = NULL;
-	int geo[BA_SYSTEM_DIMENSIONS];
-	int i;
-	blockreq_t blockreq;
-	List results = NULL;
-	
-	/* Here we are adding a block that in for the entire machine 
-	   just in case it isn't in the bluegene.conf file.
-	*/
-	slurm_mutex_lock(&block_state_mutex);
-	
-#ifdef HAVE_BG_FILES
-	geo[X] = DIM_SIZE[X] - 1;
-	geo[Y] = DIM_SIZE[Y] - 1;
-	geo[Z] = DIM_SIZE[Z] - 1;
-#else
-	geo[X] = max_dim[X];
-	geo[Y] = max_dim[Y];
-	geo[Z] = max_dim[Z];
-#endif
-	slurm_conf_lock();
-	i = (10+strlen(slurmctld_conf.node_prefix));
-	name = xmalloc(i);
-	if((geo[X] == 0) && (geo[Y] == 0) && (geo[Z] == 0))
-		snprintf(name, i, "%s000",
-			 slurmctld_conf.node_prefix);
-	else
-		snprintf(name, i, "%s[000x%c%c%c]",
-			 slurmctld_conf.node_prefix,
-			 alpha_num[geo[X]], alpha_num[geo[Y]],
-			 alpha_num[geo[Z]]);
-	slurm_conf_unlock();
-			
-	if(bg_found_block_list) {
-		itr = list_iterator_create(bg_found_block_list);
-		while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
-			if (!strcmp(name, bg_record->nodes)) {
-				xfree(name);
-				list_iterator_destroy(itr);
-				/* don't create total already there */
-				goto no_total;	
-			}
-		}
-		list_iterator_destroy(itr);
-	} else {
-		error("create_full_system_block: no bg_found_block_list 2");
-	}
-	
-	if(bg_list) {
-		itr = list_iterator_create(bg_list);
-		while ((bg_record = (bg_record_t *) list_next(itr)) 
-		       != NULL) {
-			if (!strcmp(name, bg_record->nodes)) {
-				xfree(name);
-				list_iterator_destroy(itr);
-				/* don't create total already there */
-				goto no_total;	
+						      "update_block_list 2");
+				}
 			}
 		}
-		list_iterator_destroy(itr);
-	} else {
-		xfree(name);
-		error("create_overlapped_blocks: no bg_list 3");
-		rc = SLURM_ERROR;
-		goto no_total;
-	}
 
-	records = list_create(destroy_bg_record);
-	blockreq.block = name;
-	blockreq.blrtsimage = NULL;
-	blockreq.linuximage = NULL;
-	blockreq.mloaderimage = NULL;
-	blockreq.ramdiskimage = NULL;
-	blockreq.conn_type = SELECT_TORUS;
-	blockreq.nodecards = 0;
-	blockreq.quarters = 0;
-	add_bg_record(records, NULL, &blockreq);
-	xfree(name);
-	
-	bg_record = (bg_record_t *) list_pop(records);
-	if(!bg_record) {
-		error("Nothing was returned from full system create");
-		rc = SLURM_ERROR;
-		goto no_total;
-	}
-	reset_ba_system(false);
-	for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
-		geo[i] = bg_record->geo[i];
-	debug2("adding %s %c%c%c %c%c%c",
-	       bg_record->nodes,
-	       alpha_num[bg_record->start[X]],
-	       alpha_num[bg_record->start[Y]],
-	       alpha_num[bg_record->start[Z]],
-	       alpha_num[geo[X]],
-	       alpha_num[geo[Y]],
-	       alpha_num[geo[Z]]);
-	results = list_create(NULL);
-	name = set_bg_block(results,
-			    bg_record->start, 
-			    geo, 
-			    bg_record->conn_type);
-	if(!name) {
-		error("I was unable to make the "
-		      "requested block.");
-		list_destroy(results);
-		list_iterator_destroy(itr);
-		slurm_mutex_unlock(&block_state_mutex);
-		return SLURM_ERROR;
-	}
-	xfree(name);
-	if(bg_record->bg_block_list)
-		list_destroy(bg_record->bg_block_list);
-	bg_record->bg_block_list =
-		list_create(destroy_ba_node);
-	copy_node_path(results, 
-		       bg_record->bg_block_list);
-	list_destroy(results);
+		if (difftime(now, last_mmcs_test) >= MMCS_POLL_TIME) {
+			if (agent_fini)		/* don't bother */
+				return NULL;	/* quit now */
+			last_mmcs_test = now;
+			test_mmcs_failures();	/* can run for a while */
+		}	
 				
-	if((rc = configure_block(bg_record)) == SLURM_ERROR) {
-		error("create_full_system_block: "
-		      "unable to configure block in api");
-		destroy_bg_record(bg_record);
-		goto no_total;
+		sleep(1);
 	}
-
-	print_bg_record(bg_record);
-	list_append(bg_list, bg_record);
-
-no_total:
-	if(records)
-		list_destroy(records);
-	slurm_mutex_unlock(&block_state_mutex);
-	return rc;
+	return NULL;
 }
 
 /* must set the protecting mutex if any before this function is called */
@@ -1607,6 +470,57 @@ extern int remove_from_bg_list(List my_bg_list, bg_record_t *bg_record)
 	return rc;
 }
 
+/* This is here to remove from the orignal list when dealing with
+ * copies like above all locks need to be set.  This function does not
+ * free anything you must free it when you are done */
+extern bg_record_t *find_and_remove_org_from_bg_list(List my_list, 
+						     bg_record_t *bg_record)
+{
+	ListIterator itr = list_iterator_create(my_list);
+	bg_record_t *found_record = NULL;
+
+	while ((found_record = (bg_record_t *) list_next(itr)) != NULL) {
+		/* check for full node bitmap compare */
+		if(bit_equal(bg_record->bitmap, found_record->bitmap)
+		   && bit_equal(bg_record->ionode_bitmap,
+				found_record->ionode_bitmap)) {
+			
+			if(!strcmp(bg_record->bg_block_id,
+				   found_record->bg_block_id)) {
+				list_remove(itr);
+				debug2("got the block");
+				break;
+			}
+		}
+	}
+	list_iterator_destroy(itr);
+	return found_record;
+}
+
+/* This is here to remove from the orignal list when dealing with
+ * copies like above all locks need to be set */
+extern bg_record_t *find_org_in_bg_list(List my_list, bg_record_t *bg_record)
+{
+	ListIterator itr = list_iterator_create(my_list);
+	bg_record_t *found_record = NULL;
+
+	while ((found_record = (bg_record_t *) list_next(itr)) != NULL) {
+		/* check for full node bitmap compare */
+		if(bit_equal(bg_record->bitmap, found_record->bitmap)
+		   && bit_equal(bg_record->ionode_bitmap,
+				found_record->ionode_bitmap)) {
+			
+			if(!strcmp(bg_record->bg_block_id,
+				   found_record->bg_block_id)) {
+				debug2("got the block");
+				break;
+			}
+		}
+	}
+	list_iterator_destroy(itr);
+	return found_record;
+}
+
 extern int bg_free_block(bg_record_t *bg_record)
 {
 #ifdef HAVE_BG_FILES
@@ -1744,19 +658,13 @@ extern void *mult_destroy_block(void *args)
 		}
 		slurm_mutex_lock(&block_state_mutex);
 		remove_from_bg_list(bg_list, bg_record);
-		slurm_mutex_unlock(&block_state_mutex);
-			
-		slurm_mutex_lock(&block_state_mutex);
 		list_push(bg_freeing_list, bg_record);
-		slurm_mutex_unlock(&block_state_mutex);
 		
 		/* 
 		 * we only are sorting this so when we send it to a
 		 * tool such as smap it will be in a nice order
 		 */
 		sort_bg_record_inc_size(bg_freeing_list);
-		
-		slurm_mutex_lock(&block_state_mutex);
 		if(remove_from_bg_list(bg_job_block_list, bg_record) 
 		   == SLURM_SUCCESS) {
 			num_unused_cpus += 
@@ -1914,7 +822,9 @@ extern int read_bg_conf(void)
 	static time_t last_config_update = (time_t) 0;
 	struct stat config_stat;
 	ListIterator itr = NULL;
-
+	/* found bg blocks already on system */
+	List bg_found_block_list = list_create(NULL);
+	
 	debug("Reading the bluegene.conf file");
 
 	/* check if config file has changed */
@@ -2128,8 +1038,7 @@ extern int read_bg_conf(void)
 				   &count, "BPs", tbl)) {
 			info("WARNING: no blocks defined in bluegene.conf, "
 			     "only making full system block");
-			i = 0;
-			create_full_system_block(&i);
+			create_full_system_block(NULL);
 		}
 		
 		for (i = 0; i < count; i++) {
@@ -2138,8 +1047,8 @@ extern int read_bg_conf(void)
 	}
 //#if 0	
 	/* Check to see if the configs we have are correct */
-	if (_validate_config_nodes() == SLURM_ERROR) { 
-		_delete_old_blocks();
+	if (_validate_config_nodes(&bg_found_block_list) == SLURM_ERROR) { 
+		_delete_old_blocks(bg_found_block_list);
 	}
 //#endif
 	/* looking for blocks only I created */
@@ -2147,7 +1056,8 @@ extern int read_bg_conf(void)
 		init_wires();
 		info("No blocks created until jobs are submitted");
 	} else {
-		if (create_defined_blocks(bluegene_layout_mode) 
+		if (create_defined_blocks(bluegene_layout_mode,
+					  bg_found_block_list) 
 		    == SLURM_ERROR) {
 			/* error in creating the static blocks, so
 			 * blocks referenced by submitted jobs won't
@@ -2161,314 +1071,24 @@ extern int read_bg_conf(void)
 	slurm_mutex_lock(&block_state_mutex);
 	list_destroy(bg_curr_block_list);
 	bg_curr_block_list = NULL;
-	list_destroy(bg_found_block_list);
-	bg_found_block_list = NULL;
+	if(bg_found_block_list) {
+		list_destroy(bg_found_block_list);
+		bg_found_block_list = NULL;
+	}
 	last_bg_update = time(NULL);
 	blocks_are_created = 1;
-	slurm_mutex_unlock(&block_state_mutex);
 	sort_bg_record_inc_size(bg_list);
+	slurm_mutex_unlock(&block_state_mutex);
 	debug("Blocks have finished being created.");
 	s_p_hashtbl_destroy(tbl);
 
 	return SLURM_SUCCESS;
 }
 
-extern int set_ionodes(bg_record_t *bg_record)
-{
-	int i = 0;
-	int start_bit = 0;
-	int size = 0;
-	char bitstring[BITSIZE];
-	
-	if(!bg_record)
-		return SLURM_ERROR;
-	/* set the bitmap blank here if it is a full node we don't
-	   want anything set we also don't want the bg_record->ionodes set.
-	*/
-	bg_record->ionode_bitmap = bit_alloc(bluegene_numpsets);
-	if(bg_record->quarter == (uint16_t)NO_VAL) {
-		return SLURM_SUCCESS;
-	}
-
-	start_bit = bluegene_quarter_ionode_cnt*bg_record->quarter;
-	
-	if(bg_record->nodecard != (uint16_t)NO_VAL
-	   && bluegene_nodecard_ionode_cnt) {
-		start_bit += bluegene_nodecard_ionode_cnt*bg_record->nodecard;
-		size = bluegene_nodecard_ionode_cnt;
-	} else
-		size = bluegene_quarter_ionode_cnt;
-	size += start_bit;
-
-	if(size == start_bit) {
-		error("start bit is the same as the end bit %d", size);
-		return SLURM_ERROR;
-	}
-	for(i=start_bit; i<size; i++)
-		bit_set(bg_record->ionode_bitmap, i);
-	
-	bit_fmt(bitstring, BITSIZE, bg_record->ionode_bitmap);
-	bg_record->ionodes = xstrdup(bitstring);
-
-	return SLURM_SUCCESS;
-}
-
-extern int add_bg_record(List records, List used_nodes, blockreq_t *blockreq)
-{
-	bg_record_t *bg_record = NULL;
-	bg_record_t *found_record = NULL;
-	ba_node_t *ba_node = NULL;
-	ListIterator itr;
-	struct passwd *pw_ent = NULL;
-	int i, len;
-	int small_size = 0;
-	int small_count = 0;
-	uint16_t quarter = 0;
-	uint16_t nodecard = 0;
-	int node_cnt = 0;
-	
-	if(!records) {
-		fatal("add_bg_record: no records list given");
-	}
-	bg_record = (bg_record_t*) xmalloc(sizeof(bg_record_t));
-	
-	slurm_conf_lock();
-	bg_record->user_name = 
-		xstrdup(slurmctld_conf.slurm_user_name);
-	bg_record->target_name = 
-		xstrdup(slurmctld_conf.slurm_user_name);
-	slurm_conf_unlock();
-	if((pw_ent = getpwnam(bg_record->user_name)) == NULL) {
-		error("getpwnam(%s): %m", bg_record->user_name);
-	} else {
-		bg_record->user_uid = pw_ent->pw_uid;
-	}
-
-	bg_record->bg_block_list = list_create(destroy_ba_node);
-	if(used_nodes) {
-		if(copy_node_path(used_nodes, bg_record->bg_block_list)
-		   == SLURM_ERROR)
-			error("couldn't copy the path for the allocation");
-		bg_record->bp_count = list_count(used_nodes);
-	}
-	bg_record->quarter = (uint16_t)NO_VAL;
-	bg_record->nodecard = (uint16_t)NO_VAL;
-	if(set_ionodes(bg_record) == SLURM_ERROR) {
-		fatal("add_bg_record: problem creating ionodes");
-	}
-	/* bg_record->boot_state = 0; 	Implicit */
-	/* bg_record->state = 0;	Implicit */
-	debug2("asking for %s %d %d %s", 
-	       blockreq->block, blockreq->quarters, blockreq->nodecards,
-	       convert_conn_type(blockreq->conn_type));
-	len = strlen(blockreq->block);
-	i=0;
-	while(i<len 
-	      && blockreq->block[i] != '[' 
-	      && (blockreq->block[i] < '0' || blockreq->block[i] > 'Z'
-		  || (blockreq->block[i] > '9' && blockreq->block[i] < 'A')))
-		i++;
-	
-	if(i<len) {
-		len -= i;
-		slurm_conf_lock();
-		len += strlen(slurmctld_conf.node_prefix)+1;
-		bg_record->nodes = xmalloc(len);
-		snprintf(bg_record->nodes, len, "%s%s", 
-			slurmctld_conf.node_prefix, blockreq->block+i);
-		slurm_conf_unlock();
-			
-	} else 
-		fatal("BPs=%s is in a weird format", blockreq->block); 
-	
-	process_nodes(bg_record);
-	
-	bg_record->node_use = SELECT_COPROCESSOR_MODE;
-	bg_record->conn_type = blockreq->conn_type;
-	bg_record->cpus_per_bp = procs_per_node;
-	bg_record->node_cnt = bluegene_bp_node_cnt * bg_record->bp_count;
-	bg_record->job_running = NO_JOB_RUNNING;
-
-	if(blockreq->blrtsimage)
-		bg_record->blrtsimage = xstrdup(blockreq->blrtsimage);
-	else
-		bg_record->blrtsimage = xstrdup(default_blrtsimage);
-
-	if(blockreq->linuximage)
-		bg_record->linuximage = xstrdup(blockreq->linuximage);
-	else
-		bg_record->linuximage = xstrdup(default_linuximage);
-
-	if(blockreq->mloaderimage)
-		bg_record->mloaderimage = xstrdup(blockreq->mloaderimage);
-	else
-		bg_record->mloaderimage = xstrdup(default_mloaderimage);
-
-	if(blockreq->ramdiskimage)
-		bg_record->ramdiskimage = xstrdup(blockreq->ramdiskimage);
-	else
-		bg_record->ramdiskimage = xstrdup(default_ramdiskimage);
-		
-	if(bg_record->conn_type != SELECT_SMALL) {
-		/* this needs to be an append so we keep things in the
-		   order we got them, they will be sorted later */
-		list_append(records, bg_record);
-		/* this isn't a correct list so we need to set it later for
-		   now we just used it to be the bp number */
-		if(!used_nodes) {
-			debug4("we didn't get a request list so we are "
-			       "destroying this bp list");
-			list_destroy(bg_record->bg_block_list);
-			bg_record->bg_block_list = NULL;
-		}
-	} else {
-		debug("adding a small block");
-		/* if the ionode cnt for nodecards is 0 then don't
-		   allow a nodecard allocation 
-		*/
-		if(!bluegene_nodecard_ionode_cnt)
-			blockreq->nodecards = 0;
-
-		if(blockreq->nodecards==0 && blockreq->quarters==0) {
-			info("No specs given for this small block, "
-			     "I am spliting this block into 4 quarters");
-			blockreq->quarters=4;
-		}		
-
-		i = (blockreq->nodecards*bluegene_nodecard_node_cnt) + 
-			(blockreq->quarters*bluegene_quarter_node_cnt);
-		if(i != bluegene_bp_node_cnt)
-			fatal("There is an error in your bluegene.conf file.\n"
-			      "I am unable to request %d nodes in one "
-			      "base partition with %d nodes.", 
-			      i, bluegene_bp_node_cnt);
-		small_count = blockreq->nodecards+blockreq->quarters; 
-		
-		/* Automatically create 4-way split if 
-		 * conn_type == SELECT_SMALL in bluegene.conf
-		 * Here we go through each node listed and do the same thing
-		 * for each node.
-		 */
-		itr = list_iterator_create(bg_record->bg_block_list);
-		while ((ba_node = list_next(itr)) != NULL) {
-			/* break base partition up into 16 parts */
-			small_size = 16;
-			node_cnt = 0;
-			quarter = 0;
-			nodecard = 0;
-			for(i=0; i<small_count; i++) {
-				if(i == blockreq->nodecards) {
-					/* break base partition 
-					   up into 4 parts */
-					small_size = 4;
-				}
-									
-				if(small_size == 4)
-					nodecard = (uint16_t)NO_VAL;
-				else
-					nodecard = i%4; 
-				found_record = _create_small_record(bg_record,
-								    quarter,
-								    nodecard);
-								 
-				/* this needs to be an append so we
-				   keep things in the order we got
-				   them, they will be sorted later */
-				list_append(records, found_record);
-				node_cnt += bluegene_bp_node_cnt/small_size;
-				if(node_cnt == 128) {
-					node_cnt = 0;
-					quarter++;
-				}
-			}
-		}
-		list_iterator_destroy(itr);
-		destroy_bg_record(bg_record);
-	} 
-	return SLURM_SUCCESS;
-}
-
-#ifdef HAVE_BG
-static int _addto_node_list(bg_record_t *bg_record, int *start, int *end)
-{
-	int node_count=0;
-	int x,y,z;
-	char node_name_tmp[255];
-	ba_node_t *ba_node = NULL;
-
-	if ((start[X] < 0) || (start[Y] < 0) || (start[Z] < 0)) {
-		fatal("bluegene.conf starting coordinate is invalid: %d%d%d",
-		      start[X], start[Y], start[Z]);
-	}
-	if ((end[X] >= DIM_SIZE[X]) || (end[Y] >= DIM_SIZE[Y])
-	||  (end[Z] >= DIM_SIZE[Z])) {
-		fatal("bluegene.conf matrix size exceeds space defined in " 
-		      "slurm.conf %c%c%cx%d%d%d => %c%c%c",
-		      alpha_num[start[X]], alpha_num[start[Y]],
-		      alpha_num[start[Z]], 
-		      end[X], end[Y], end[Z], 
-		      alpha_num[DIM_SIZE[X]], alpha_num[DIM_SIZE[Y]], 
-		      alpha_num[DIM_SIZE[Z]]);
-	}
-	debug3("adding bps: %c%c%cx%c%c%c",
-	       alpha_num[start[X]], alpha_num[start[Y]], alpha_num[start[Z]],
-	       alpha_num[end[X]], alpha_num[end[Y]], alpha_num[end[Z]]);
-	debug3("slurm.conf:    %c%c%c",
-	       alpha_num[DIM_SIZE[X]], alpha_num[DIM_SIZE[Y]],
-	       alpha_num[DIM_SIZE[Z]]); 
-	
-	for (x = start[X]; x <= end[X]; x++) {
-		for (y = start[Y]; y <= end[Y]; y++) {
-			for (z = start[Z]; z <= end[Z]; z++) {
-				slurm_conf_lock();
-				snprintf(node_name_tmp, sizeof(node_name_tmp),
-					 "%s%c%c%c", 
-					 slurmctld_conf.node_prefix,
-					 alpha_num[x], alpha_num[y],
-					 alpha_num[z]);		
-				slurm_conf_unlock();
-				ba_node = ba_copy_node(
-					&ba_system_ptr->grid[x][y][z]);
-				ba_node->used = 1;
-				list_append(bg_record->bg_block_list, ba_node);
-				node_count++;
-			}
-		}
-	}
-	return node_count;
-}
-
-static int _ba_node_cmpf_inc(ba_node_t *node_a, ba_node_t *node_b)
-{
-	if (node_a->coord[X] < node_b->coord[X])
-		return -1;
-	else if (node_a->coord[X] > node_b->coord[X])
-		return 1;
-	
-	if (node_a->coord[Y] < node_b->coord[Y])
-		return -1;
-	else if (node_a->coord[Y] > node_b->coord[Y])
-		return 1;
-
-	if (node_a->coord[Z] < node_b->coord[Z])
-		return -1;
-	else if (node_a->coord[Z] > node_b->coord[Z])
-		return 1;
-
-	error("You have the node %c%c%c in the list twice",
-	      alpha_num[node_a->coord[X]],
-	      alpha_num[node_a->coord[Y]],
-	      alpha_num[node_a->coord[Z]]); 
-	return 0;
-}
-#endif //HAVE_BG
 
 static void _set_bg_lists()
 {
 	slurm_mutex_lock(&block_state_mutex);
-	if(bg_found_block_list)
-		list_destroy(bg_found_block_list);
-	bg_found_block_list = list_create(NULL);
 	if(bg_booted_block_list) 
 		list_destroy(bg_booted_block_list);
 	bg_booted_block_list = list_create(NULL);
@@ -2504,12 +1124,15 @@ static void _set_bg_lists()
 }
 
 /*
- * Match slurm configuration information with current BG block 
- * configuration. Return SLURM_SUCCESS if they match, else an error 
+ * _validate_config_nodes - Match slurm configuration information with
+ *                          current BG block configuration.
+ * IN/OUT bg_found_block_list - if NULL is created and then any blocks
+ *                              found on the system are then pushed on.
+ * RET - SLURM_SUCCESS if they match, else an error 
  * code. Writes bg_block_id into bg_list records.
  */
 
-static int _validate_config_nodes(void)
+static int _validate_config_nodes(List *bg_found_block_list)
 {
 	int rc = SLURM_ERROR;
 #ifdef HAVE_BG_FILES
@@ -2521,6 +1144,7 @@ static int _validate_config_nodes(void)
 	ListIterator itr_curr;
 	rm_partition_mode_t node_use;
 	char tmp_char[256];
+
 	/* read current bg block info into bg_curr_block_list */
 	if (read_bg_blocks() == SLURM_ERROR)
 		return SLURM_ERROR;
@@ -2535,7 +1159,11 @@ static int _validate_config_nodes(void)
 	while ((init_bg_record = list_next(itr_curr))) 
 		if(init_bg_record->full_block) 
 			full_system_bg_record = init_bg_record;	
-		
+	
+	if(!*bg_found_block_list)
+		(*bg_found_block_list) = list_create(NULL);
+
+	
 	itr_conf = list_iterator_create(bg_list);
 	while ((bg_record = (bg_record_t*) list_next(itr_conf))) {
 		/* translate hostlist to ranged 
@@ -2590,7 +1218,7 @@ static int _validate_config_nodes(void)
 			if(bg_record->full_block)
 				full_created = 1;
 
-			list_push(bg_found_block_list, bg_record);
+			list_push(*bg_found_block_list, bg_record);
 			format_node_name(bg_record, tmp_char,
 					 sizeof(tmp_char));
 			info("Existing: BlockID:%s Nodes:%s Conn:%s",
@@ -2613,7 +1241,7 @@ static int _validate_config_nodes(void)
 		bg_record = xmalloc(sizeof(bg_record_t));
 		copy_bg_record(full_system_bg_record, bg_record);
 		list_append(bg_list, bg_record);
-		list_push(bg_found_block_list, bg_record);
+		list_push(*bg_found_block_list, bg_record);
 		format_node_name(bg_record, tmp_char, sizeof(tmp_char));
 		info("Existing: BlockID:%s Nodes:%s Conn:%s",
 		     bg_record->bg_block_id, 
@@ -2669,7 +1297,7 @@ static int _bg_record_cmpf_inc(bg_record_t* rec_a, bg_record_t* rec_b)
 	return 0;
 }
 
-static int _delete_old_blocks(void)
+static int _delete_old_blocks(List bg_found_block_list)
 {
 #ifdef HAVE_BG_FILES
 	ListIterator itr_curr, itr_found;
@@ -2698,13 +1326,12 @@ static int _delete_old_blocks(void)
 	} else {
 		if(bg_curr_block_list) {
 			itr_curr = list_iterator_create(bg_curr_block_list);
-			while ((init_record = (bg_record_t*) 
-				list_next(itr_curr))) {
+			while ((init_record = list_next(itr_curr))) {
 				if(bg_found_block_list) {
 					itr_found = list_iterator_create(
 						bg_found_block_list);
-					while ((found_record = (bg_record_t*) 
-						list_next(itr_found)) 
+					while ((found_record 
+						= list_next(itr_found)) 
 					       != NULL) {
 						if (!strcmp(init_record->
 							    bg_block_id, 
@@ -2818,360 +1445,6 @@ static char *_get_bg_conf(void)
 	return rc;
 }
 
-static int _split_block(bg_record_t *bg_record, int procs) 
-{
-	bg_record_t *found_record = NULL;
-	bool full_bp = false; 
-	int small_count = 0;
-	int small_size = 0;
-	uint16_t num_nodecard = 0, num_quarter = 0;
-	int i;
-	int node_cnt = 0;
-	uint16_t quarter = 0;
-	uint16_t nodecard = 0;
-
-	if(bg_record->quarter == (uint16_t) NO_VAL)
-		full_bp = true;
-	
-	if(procs == (procs_per_node/16) && bluegene_nodecard_ionode_cnt) {
-		num_nodecard=4;
-		if(full_bp)
-			num_quarter=3;
-	} else if(full_bp) {
-		num_quarter = 4;
-	} else {
-		error("you asked for something that was already this size");
-		return SLURM_ERROR;
-	}
-	debug2("asking for %d 32s from a %d block",
-	       num_nodecard, bg_record->node_cnt);
-	small_count = num_nodecard+num_quarter; 
-
-	/* break base partition up into 16 parts */
-	small_size = bluegene_bp_node_cnt/bluegene_nodecard_node_cnt;
-	node_cnt = 0;
-	if(!full_bp)
-		quarter = bg_record->quarter;
-	else
-		quarter = 0;
-	nodecard = 0;
-	for(i=0; i<small_count; i++) {
-		if(i == num_nodecard) {
-			/* break base partition up into 4 parts */
-			small_size = 4;
-		}
-		
-		if(small_size == 4)
-			nodecard = (uint16_t)NO_VAL;
-		else
-			nodecard = i%4; 
-		found_record = _create_small_record(bg_record,
-						    quarter,
-						    nodecard);
-		if(block_exist_in_list(bg_list, found_record)) {
-			destroy_bg_record(found_record);
-		} else {
-			if(configure_block(found_record) == SLURM_ERROR) {
-				destroy_bg_record(found_record);
-				error("_split_block: "
-				      "unable to configure block in api");
-				return SLURM_ERROR;
-			}
-			list_append(bg_list, found_record);
-			print_bg_record(found_record);
-		}
-		node_cnt += bluegene_bp_node_cnt/small_size;
-		if(node_cnt == 128) {
-			node_cnt = 0;
-			quarter++;
-		}
-	}
-		
-	return SLURM_SUCCESS;
-}
-
-static int _breakup_blocks(ba_request_t *request, List my_block_list)
-{
-	int rc = SLURM_ERROR;
-	bg_record_t *bg_record = NULL;
-	ListIterator itr;
-	int proc_cnt=0;
-	int total_proc_cnt=0;
-	uint16_t last_quarter = (uint16_t) NO_VAL;
-	char tmp_char[256];
-	
-	debug2("proc count = %d size = %d",
-	       request->procs, request->size);
-	
-	itr = list_iterator_create(bg_list);			
-	while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
-		if(bg_record->job_running != NO_JOB_RUNNING)
-			continue;
-		if(bg_record->state != RM_PARTITION_FREE)
-			continue;
-		if (request->avail_node_bitmap &&
-		    !bit_super_set(bg_record->bitmap,
-				   request->avail_node_bitmap)) {
-			debug2("bg block %s has nodes not usable by this job",
-			       bg_record->bg_block_id);
-			continue;
-		}
-			
-		if(request->start_req) {
-			if ((request->start[X] != bg_record->start[X])
-			    || (request->start[Y] != bg_record->start[Y])
-			    || (request->start[Z] != bg_record->start[Z])) {
-				debug4("small got %c%c%c looking for %c%c%c",
-				       alpha_num[bg_record->start[X]],
-				       alpha_num[bg_record->start[Y]],
-				       alpha_num[bg_record->start[Z]],
-				       alpha_num[request->start[X]],
-				       alpha_num[request->start[Y]],
-				       alpha_num[request->start[Z]]);
-				continue;
-			}
-			debug3("small found %c%c%c looking for %c%c%c",
-			       alpha_num[bg_record->start[X]],
-			       alpha_num[bg_record->start[Y]],
-			       alpha_num[bg_record->start[Z]],
-			       alpha_num[request->start[X]],
-			       alpha_num[request->start[Y]],
-			       alpha_num[request->start[Z]]);
-		}
-		proc_cnt = bg_record->bp_count * 
-			bg_record->cpus_per_bp;
-		if(proc_cnt == request->procs) {
-			debug("found it here %s, %s",
-			       bg_record->bg_block_id,
-			       bg_record->nodes);
-			request->save_name = xmalloc(4);
-			snprintf(request->save_name,
-				 4,
-				 "%c%c%c",
-				 alpha_num[bg_record->start[X]],
-				 alpha_num[bg_record->start[Y]],
-				 alpha_num[bg_record->start[Z]]);
-			rc = SLURM_SUCCESS;
-			goto finished;
-		}
-		if(bg_record->node_cnt > bluegene_bp_node_cnt)
-			continue;
-		if(proc_cnt < request->procs) {
-			if(last_quarter != bg_record->quarter){
-				last_quarter = bg_record->quarter;
-				total_proc_cnt = proc_cnt;
-			} else {
-				total_proc_cnt += proc_cnt;
-			}
-			debug2("1 got %d on quarter %d",
-			       total_proc_cnt, last_quarter);
-			if(total_proc_cnt == request->procs) {
-				request->save_name = xmalloc(4);
-				snprintf(request->save_name, 
-					 4,
-					 "%c%c%c",
-					 alpha_num[bg_record->start[X]],
-					 alpha_num[bg_record->start[Y]],
-					 alpha_num[bg_record->start[Z]]);
-				if(!my_block_list) {
-					rc = SLURM_SUCCESS;
-					goto finished;	
-				}
-						
-				bg_record = _create_small_record(
-					bg_record,
-					last_quarter,
-					(uint16_t) NO_VAL);
-				if(block_exist_in_list(bg_list, bg_record))
-					destroy_bg_record(bg_record);
-				else {
-					if(configure_block(bg_record)
-					   == SLURM_ERROR) {
-						destroy_bg_record(bg_record);
-						error("_breakup_blocks: "
-						      "unable to configure "
-						      "block in api");
-						return SLURM_ERROR;
-					}
-					list_append(bg_list, bg_record);
-					print_bg_record(bg_record);
-				}
-				rc = SLURM_SUCCESS;
-				goto finished;	
-			}
-			continue;
-		}
-		break;
-	}
-	if(bg_record) {
-		debug2("got one on the first pass");
-		goto found_one;
-	}
-	list_iterator_reset(itr);
-	last_quarter = (uint16_t) NO_VAL;
-	while ((bg_record = (bg_record_t *) list_next(itr)) 
-	       != NULL) {
-		if(bg_record->job_running != NO_JOB_RUNNING)
-			continue;
-		if (request->avail_node_bitmap &&
-		    !bit_super_set(bg_record->bitmap,
-				   request->avail_node_bitmap)) {
-			debug2("bg block %s has nodes not usable by this job",
-			       bg_record->bg_block_id);
-			continue;
-		}
-
-		if(request->start_req) {
-			if ((request->start[X] != bg_record->start[X])
-			    || (request->start[Y] != bg_record->start[Y])
-			    || (request->start[Z] != bg_record->start[Z])) {
-				debug4("small 2 got %c%c%c looking for %c%c%c",
-				       alpha_num[bg_record->start[X]],
-				       alpha_num[bg_record->start[Y]],
-				       alpha_num[bg_record->start[Z]],
-				       alpha_num[request->start[X]],
-				       alpha_num[request->start[Y]],
-				       alpha_num[request->start[Z]]);
-				continue;
-			}
-			debug3("small 2 found %c%c%c looking for %c%c%c",
-			       alpha_num[bg_record->start[X]],
-			       alpha_num[bg_record->start[Y]],
-			       alpha_num[bg_record->start[Z]],
-			       alpha_num[request->start[X]],
-			       alpha_num[request->start[Y]],
-			       alpha_num[request->start[Z]]);
-		}
-				
-		proc_cnt = bg_record->bp_count * bg_record->cpus_per_bp;
-		if(proc_cnt == request->procs) {
-			debug2("found it here %s, %s",
-			       bg_record->bg_block_id,
-			       bg_record->nodes);
-			request->save_name = xmalloc(4);
-			snprintf(request->save_name,
-				 4,
-				 "%c%c%c",
-				 alpha_num[bg_record->start[X]],
-				 alpha_num[bg_record->start[Y]],
-				 alpha_num[bg_record->start[Z]]);
-			rc = SLURM_SUCCESS;
-			goto finished;
-		} 
-
-		if(bg_record->node_cnt > bluegene_bp_node_cnt)
-			continue;
-		if(proc_cnt < request->procs) {
-			if(last_quarter != bg_record->quarter){
-				last_quarter = bg_record->quarter;
-				total_proc_cnt = proc_cnt;
-			} else {
-				total_proc_cnt += proc_cnt;
-			}
-			debug2("got %d on quarter %d",
-			       total_proc_cnt, last_quarter);
-			if(total_proc_cnt == request->procs) {
-				request->save_name = xmalloc(4);
-				snprintf(request->save_name,
-					 4,
-					 "%c%c%c",
-					 alpha_num[bg_record->start[X]],
-					 alpha_num[bg_record->start[Y]],
-					 alpha_num[bg_record->start[Z]]);
-				if(!my_block_list) {
-					rc = SLURM_SUCCESS;
-					goto finished;	
-				}
-				bg_record = _create_small_record(
-					bg_record,
-					last_quarter,
-					(uint16_t) NO_VAL);
-				if(block_exist_in_list(bg_list, bg_record))
-					destroy_bg_record(bg_record);
-				else {
-					if(configure_block(bg_record)
-					   == SLURM_ERROR) {
-						destroy_bg_record(bg_record);
-						error("_breakup_blocks: "
-						      "unable to configure "
-						      "block in api 2");
-						return SLURM_ERROR;
-					}
-					list_append(bg_list, bg_record);
-					print_bg_record(bg_record);
-				}
-				rc = SLURM_SUCCESS;
-				goto finished;	
-			}
-			continue;
-		}				
-		break;
-	}
-found_one:
-	if(bg_record) {
-		format_node_name(bg_record, tmp_char, sizeof(tmp_char));
-			
-		debug2("going to split %s, %s",
-		       bg_record->bg_block_id,
-		       tmp_char);
-		request->save_name = xmalloc(4);
-		snprintf(request->save_name, 
-			 4,
-			 "%c%c%c",
-			 alpha_num[bg_record->start[X]],
-			 alpha_num[bg_record->start[Y]],
-			 alpha_num[bg_record->start[Z]]);
-		if(!my_block_list) {
-			rc = SLURM_SUCCESS;
-			goto finished;	
-		}
-		_split_block(bg_record, request->procs);
-		rc = SLURM_SUCCESS;
-		goto finished;
-	}
-	
-finished:
-	list_iterator_destroy(itr);
-		
-	return rc;
-}
-
-static bg_record_t *_create_small_record(bg_record_t *bg_record, 
-					 uint16_t quarter, uint16_t nodecard)
-{
-	bg_record_t *found_record = NULL;
-	int small_size = 4;
-	
-	found_record = (bg_record_t*) xmalloc(sizeof(bg_record_t));
-				
-	found_record->job_running = NO_JOB_RUNNING;
-	found_record->user_name = xstrdup(bg_record->user_name);
-	found_record->user_uid = bg_record->user_uid;
-	found_record->bg_block_list = list_create(destroy_ba_node);
-	found_record->nodes = xstrdup(bg_record->nodes);
-	found_record->blrtsimage = xstrdup(bg_record->blrtsimage);
-	found_record->linuximage = xstrdup(bg_record->linuximage);
-	found_record->mloaderimage = xstrdup(bg_record->mloaderimage);
-	found_record->ramdiskimage = xstrdup(bg_record->ramdiskimage);
-
-	process_nodes(found_record);
-				
-	found_record->conn_type = SELECT_SMALL;
-				
-	found_record->node_use = SELECT_COPROCESSOR_MODE;
-	if(nodecard != (uint16_t) NO_VAL)
-		small_size = 16;
-	found_record->cpus_per_bp = procs_per_node/small_size;
-	found_record->node_cnt = bluegene_bp_node_cnt/small_size;
-	found_record->quarter = quarter; 
-	found_record->nodecard = nodecard;
-	
-	if(set_ionodes(found_record) == SLURM_ERROR) 
-		error("couldn't create ionode_bitmap for %d.%d",
-		      found_record->quarter, found_record->nodecard);
-	return found_record;
-}
-
 static int _reopen_bridge_log(void)
 {
 	int rc = SLURM_SUCCESS;
diff --git a/src/plugins/select/bluegene/plugin/bluegene.h b/src/plugins/select/bluegene/plugin/bluegene.h
index b19e4d1ecc147072de6804c0758a2c8afb007351..e5afba4c0b73e7166c2977b941c2832300570391 100644
--- a/src/plugins/select/bluegene/plugin/bluegene.h
+++ b/src/plugins/select/bluegene/plugin/bluegene.h
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  bluegene.h - header for blue gene configuration processing module. 
  *
- *  $Id: bluegene.h 10449 2006-12-12 16:34:51Z da $
+ *  $Id: bluegene.h 13924 2008-04-23 06:24:55Z da $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -39,22 +39,7 @@
 #ifndef _BLUEGENE_H_
 #define _BLUEGENE_H_
 
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <pwd.h>
-
-#include "src/common/bitstring.h"
-#include "src/common/hostlist.h"
-#include "src/common/list.h"
-#include "src/common/macros.h"
-#include "src/common/node_select.h"
-#include "src/common/parse_time.h"
-#include "src/slurmctld/slurmctld.h"
-#include "../block_allocator/block_allocator.h"
+#include "bg_record_functions.h"
 
 typedef enum bg_layout_type {
 	LAYOUT_STATIC,  /* no overlaps, except for full system block
@@ -64,53 +49,6 @@ typedef enum bg_layout_type {
 	LAYOUT_DYNAMIC	/* slurm will make all blocks */
 } bg_layout_t;
 
-typedef struct bg_record {
-	pm_partition_id_t bg_block_id;	/* ID returned from MMCS	*/
-	char *nodes;			/* String of nodes in block */
-	char *ionodes; 		        /* String of ionodes in block
-					 * NULL if not a small block*/
-	char *user_name;		/* user using the block */
-	char *target_name;		/* when a block is freed this 
-					   is the name of the user we 
-					   want on the block */
-	int full_block;                 /* whether or not block is the full
-					   block */
-	int modifying;                  /* flag to say the block is
-					   being modified or not at
-					   job launch usually */
-	uid_t user_uid;   		/* Owner of block uid	*/
-	rm_partition_state_t state;   	/* the allocated block   */
-	int start[BA_SYSTEM_DIMENSIONS];/* start node */
-	uint16_t geo[BA_SYSTEM_DIMENSIONS];  /* geometry */
-	rm_connection_type_t conn_type;	/* Mesh or Torus or NAV */
-	rm_partition_mode_t node_use;	/* either COPROCESSOR or VIRTUAL */
-	rm_partition_t *bg_block;       /* structure to hold info from db2 */
-	List bg_block_list;             /* node list of blocks in block */
-	int bp_count;                   /* size */
-	int switch_count;               /* number of switches used. */
-	int boot_state;                 /* check to see if boot failed. 
-					   -1 = fail, 
-					   0 = not booting, 
-					   1 = booting */
-	int boot_count;                 /* number of attemts boot attempts */
-	bitstr_t *bitmap;               /* bitmap to check the name 
-					   of block */
-	bitstr_t *ionode_bitmap;        /* for small blocks bitmap to
-					   keep track which ionodes we
-					   are on.  NULL if not a small block*/
-	int job_running;                /* job id if there is a job running 
-					   on the block */
-	int cpus_per_bp;                /* count of cpus per base part */
-	uint32_t node_cnt;              /* count of nodes per block */
-	uint16_t quarter;               /* used for small blocks 
-					   determine quarter of BP */
-	uint16_t nodecard;              /* used for small blocks 
-					   determine nodecard of quarter */
-	char *blrtsimage;              /* BlrtsImage for this block */
-	char *linuximage;              /* LinuxImage for this block */
-	char *mloaderimage;            /* mloaderImage for this block */
-	char *ramdiskimage;            /* RamDiskImage for this block */
-} bg_record_t;
 
 /* Global variables */
 extern rm_BGL_t *bg;
@@ -134,8 +72,6 @@ extern List bg_list;			/* List of configured BG blocks */
 extern List bg_job_block_list;  	/* jobs running in these blocks */
 extern List bg_booted_block_list;  	/* blocks that are booted */
 extern List bg_freeing_list;  	        /* blocks that being freed */
-extern List bg_request_list;  	        /* list of request that can't 
-					   be made just yet */
 extern List bg_blrtsimage_list;
 extern List bg_linuximage_list;
 extern List bg_mloaderimage_list;
@@ -154,6 +90,8 @@ extern int num_unused_cpus;
 #define BLOCK_ERROR_STATE    -3
 #define NO_JOB_RUNNING       -1
 #define MAX_AGENT_COUNT      30
+#define BUFSIZE 4096
+#define BITSIZE 128
 
 #include "bg_block_info.h"
 #include "bg_job_place.h"
@@ -169,22 +107,6 @@ extern int init_bg(void);
 /* Purge all plugin variables */
 extern void fini_bg(void);
 
-/* Log a bg_record's contents */
-extern void print_bg_record(bg_record_t *record);
-extern void destroy_bg_record(void *object);
-extern int block_exist_in_list(List my_list, bg_record_t *bg_record);
-extern void process_nodes(bg_record_t *bg_reord);
-extern void copy_bg_record(bg_record_t *fir_record, bg_record_t *sec_record);
-
-/* return bg_record from a bg_list */
-extern bg_record_t *find_bg_record_in_list(List my_list, char *bg_block_id);
-
-/* change username of a block bg_record_t target_name needs to be 
-   updated before call of function. 
-*/
-extern int update_block_user(bg_record_t *bg_block_id, int set); 
-extern void drain_as_needed(bg_record_t *bg_record, char *reason);
-extern int format_node_name(bg_record_t *bg_record, char *buf, int buf_size);
 extern bool blocks_overlap(bg_record_t *rec_a, bg_record_t *rec_b);
 
 
@@ -207,24 +129,15 @@ extern void sort_bg_record_inc_size(List records);
  * nodes and switches */
 extern void *bluegene_agent(void *args);
 
-/*
- * create_*_block(s) - functions for creating blocks that will be used
- *   for scheduling.
- * RET - success of fitting all configurations
- */
-extern int create_defined_blocks(bg_layout_t overlapped);
-extern int create_dynamic_block(ba_request_t *request, List my_block_list);
-extern int create_full_system_block();
-
 extern int bg_free_block(bg_record_t *bg_record);
 extern int remove_from_bg_list(List my_bg_list, bg_record_t *bg_record);
-extern int remove_from_request_list();
+extern bg_record_t *find_and_remove_org_from_bg_list(List my_list, 
+						     bg_record_t *bg_record);
+extern bg_record_t *find_org_in_bg_list(List my_list, bg_record_t *bg_record);
 extern void *mult_free_block(void *args);
 extern void *mult_destroy_block(void *args);
 extern int free_block_list(List delete_list);
 extern int read_bg_conf(void);
-extern int set_ionodes(bg_record_t *bg_record);
-extern int add_bg_record(List records, List used_nodes, blockreq_t *blockreq);
 
 /* block_sys.c */
 /*****************************************************/
diff --git a/src/plugins/select/bluegene/plugin/defined_block.c b/src/plugins/select/bluegene/plugin/defined_block.c
new file mode 100644
index 0000000000000000000000000000000000000000..4407f7019b147e63c6f2a2995b1551b33aee8fb5
--- /dev/null
+++ b/src/plugins/select/bluegene/plugin/defined_block.c
@@ -0,0 +1,370 @@
+/*****************************************************************************\
+ *  defined_block.c - functions for creating blocks in a static environment.
+ *
+ *  $Id: defined_block.c 12954 2008-01-04 20:37:49Z da $
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "defined_block.h"
+
+/*
+ * create_defined_blocks - create the static blocks that will be used
+ * for scheduling, all partitions must be able to be created and booted
+ * at once.  
+ * IN - int overlapped, 1 if partitions are to be overlapped, 0 if they are
+ * static.
+ * RET - success of fitting all configurations
+ */
+extern int create_defined_blocks(bg_layout_t overlapped,
+				 List bg_found_block_list)
+{
+	int rc = SLURM_SUCCESS;
+
+	ListIterator itr;
+	bg_record_t *bg_record = NULL;
+	ListIterator itr_found;
+	int i;
+	bg_record_t *found_record = NULL;
+	int geo[BA_SYSTEM_DIMENSIONS];
+	char temp[256];
+	List results = NULL;
+	
+#ifdef HAVE_BG_FILES
+	init_wires();
+#endif
+	slurm_mutex_lock(&block_state_mutex);
+	reset_ba_system(false);
+	if(bg_list) {
+		itr = list_iterator_create(bg_list);
+		while((bg_record = list_next(itr))) {
+			if(bg_found_block_list) {
+				itr_found = list_iterator_create(
+					bg_found_block_list);
+				while ((found_record = (bg_record_t*) 
+					list_next(itr_found)) != NULL) {
+/* 					info("%s.%d.%d ?= %s.%d.%d\n", */
+/* 					     bg_record->nodes, */
+/* 					     bg_record->quarter, */
+/* 					     bg_record->nodecard, */
+/* 					     found_record->nodes, */
+/* 					     found_record->quarter, */
+/* 					     found_record->nodecard); */
+					
+					if ((bit_equal(bg_record->bitmap, 
+						       found_record->bitmap))
+					    && (bg_record->quarter ==
+						found_record->quarter)
+					    && (bg_record->nodecard ==
+						found_record->nodecard)) {
+						/* don't reboot this one */
+						break;	
+					}
+				}
+				list_iterator_destroy(itr_found);
+			} else {
+				error("create_defined_blocks: "
+				      "no bg_found_block_list 1");
+			}
+			if(bg_record->bp_count>0 
+			   && !bg_record->full_block
+			   && bg_record->cpus_per_bp == procs_per_node) {
+				char *name = NULL;
+				if(overlapped == LAYOUT_OVERLAP) {
+					reset_ba_system(false);
+					set_all_bps_except(bg_record->nodes);
+				}
+				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+					geo[i] = bg_record->geo[i];
+				debug2("adding %s %c%c%c %c%c%c",
+				       bg_record->nodes,
+				       alpha_num[bg_record->start[X]],
+				       alpha_num[bg_record->start[Y]],
+				       alpha_num[bg_record->start[Z]],
+				       alpha_num[geo[X]],
+				       alpha_num[geo[Y]],
+				       alpha_num[geo[Z]]);
+				if(bg_record->bg_block_list
+				   && list_count(bg_record->bg_block_list)) {
+					if(check_and_set_node_list(
+						   bg_record->bg_block_list)
+					   == SLURM_ERROR) {
+						debug2("something happened in "
+						       "the load of %s"
+						       "Did you use smap to "
+						       "make the "
+						       "bluegene.conf file?",
+						       bg_record->bg_block_id);
+						list_iterator_destroy(itr);
+						slurm_mutex_unlock(
+							&block_state_mutex);
+						return SLURM_ERROR;
+					}
+				} else {
+					results = list_create(NULL);
+					name = set_bg_block(
+						results,
+						bg_record->start, 
+						geo, 
+						bg_record->conn_type);
+					if(!name) {
+						error("I was unable to "
+						      "make the "
+						      "requested block.");
+						list_destroy(results);
+						list_iterator_destroy(itr);
+						slurm_mutex_unlock(
+							&block_state_mutex);
+						return SLURM_ERROR;
+					}
+					slurm_conf_lock();
+					snprintf(temp, sizeof(temp), "%s%s",
+						 slurmctld_conf.node_prefix,
+						 name);
+					slurm_conf_unlock();
+					xfree(name);
+					if(strcmp(temp, bg_record->nodes)) {
+						fatal("given list of %s "
+						      "but allocated %s, "
+						      "your order might be "
+						      "wrong in bluegene.conf",
+						      bg_record->nodes,
+						      temp);
+					}
+					if(bg_record->bg_block_list)
+						list_destroy(bg_record->
+							     bg_block_list);
+					bg_record->bg_block_list =
+						list_create(destroy_ba_node);
+					copy_node_path(
+						results, 
+						bg_record->bg_block_list);
+					list_destroy(results);
+				}
+			}
+			if(found_record == NULL) {
+				if(bg_record->full_block) {
+					/* if this is defined we need
+					   to remove it since we are
+					   going to try to create it
+					   later on overlap systems
+					   this doesn't matter, but
+					   since we don't clear the
+					   table on static mode we
+					   can't do it here or it just
+					   won't work since other
+					   wires will be or are
+					   already set
+					*/ 
+					list_remove(itr);
+					continue;
+				}
+				if((rc = configure_block(bg_record)) 
+				   == SLURM_ERROR) {
+					list_iterator_destroy(itr);
+					slurm_mutex_unlock(&block_state_mutex);
+					return rc;
+				}
+				print_bg_record(bg_record);
+			}
+		}
+		list_iterator_destroy(itr);
+	} else {
+		error("create_defined_blocks: no bg_list 2");
+		slurm_mutex_unlock(&block_state_mutex);
+		return SLURM_ERROR;
+	}
+	slurm_mutex_unlock(&block_state_mutex);
+	create_full_system_block(bg_found_block_list);
+
+	slurm_mutex_lock(&block_state_mutex);
+	sort_bg_record_inc_size(bg_list);
+	slurm_mutex_unlock(&block_state_mutex);
+	
+#ifdef _PRINT_BLOCKS_AND_EXIT
+	if(bg_list) {
+		itr = list_iterator_create(bg_list);
+		debug("\n\n");
+		while ((found_record = (bg_record_t *) list_next(itr)) 
+		       != NULL) {
+			print_bg_record(found_record);
+		}
+		list_iterator_destroy(itr);
+	} else {
+		error("create_defined_blocks: no bg_list 5");
+	}
+ 	exit(0);
+#endif	/* _PRINT_BLOCKS_AND_EXIT */
+	rc = SLURM_SUCCESS;
+	//exit(0);
+	return rc;
+}
+
+extern int create_full_system_block(List bg_found_block_list)
+{
+	int rc = SLURM_SUCCESS;
+	ListIterator itr;
+	bg_record_t *bg_record = NULL;
+	char *name = NULL;
+	List records = NULL;
+	int geo[BA_SYSTEM_DIMENSIONS];
+	int i;
+	blockreq_t blockreq;
+	List results = NULL;
+	
+	/* Here we are adding a block that in for the entire machine 
+	   just in case it isn't in the bluegene.conf file.
+	*/
+	slurm_mutex_lock(&block_state_mutex);
+	
+//#ifdef HAVE_BG_FILES
+	geo[X] = DIM_SIZE[X] - 1;
+	geo[Y] = DIM_SIZE[Y] - 1;
+	geo[Z] = DIM_SIZE[Z] - 1;
+/* #else */
+/* 	geo[X] = max_dim[X]; */
+/* 	geo[Y] = max_dim[Y]; */
+/* 	geo[Z] = max_dim[Z]; */
+/* #endif */
+	slurm_conf_lock();
+	i = (10+strlen(slurmctld_conf.node_prefix));
+	name = xmalloc(i);
+	if((geo[X] == 0) && (geo[Y] == 0) && (geo[Z] == 0))
+		snprintf(name, i, "%s000",
+			 slurmctld_conf.node_prefix);
+	else
+		snprintf(name, i, "%s[000x%c%c%c]",
+			 slurmctld_conf.node_prefix,
+			 alpha_num[geo[X]], alpha_num[geo[Y]],
+			 alpha_num[geo[Z]]);
+	slurm_conf_unlock();
+			
+	if(bg_found_block_list) {
+		itr = list_iterator_create(bg_found_block_list);
+		while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
+			if (!strcmp(name, bg_record->nodes)) {
+				xfree(name);
+				list_iterator_destroy(itr);
+				/* don't create total already there */
+				goto no_total;	
+			}
+		}
+		list_iterator_destroy(itr);
+	} else {
+		error("create_full_system_block: no bg_found_block_list 2");
+	}
+	
+	if(bg_list) {
+		itr = list_iterator_create(bg_list);
+		while ((bg_record = (bg_record_t *) list_next(itr)) 
+		       != NULL) {
+			if (!strcmp(name, bg_record->nodes)) {
+				xfree(name);
+				list_iterator_destroy(itr);
+				/* don't create total already there */
+				goto no_total;	
+			}
+		}
+		list_iterator_destroy(itr);
+	} else {
+		xfree(name);
+		error("create_overlapped_blocks: no bg_list 3");
+		rc = SLURM_ERROR;
+		goto no_total;
+	}
+
+	records = list_create(destroy_bg_record);
+	blockreq.block = name;
+	blockreq.blrtsimage = NULL;
+	blockreq.linuximage = NULL;
+	blockreq.mloaderimage = NULL;
+	blockreq.ramdiskimage = NULL;
+	blockreq.conn_type = SELECT_TORUS;
+	blockreq.nodecards = 0;
+	blockreq.quarters = 0;
+	add_bg_record(records, NULL, &blockreq);
+	xfree(name);
+	
+	bg_record = (bg_record_t *) list_pop(records);
+	if(!bg_record) {
+		error("Nothing was returned from full system create");
+		rc = SLURM_ERROR;
+		goto no_total;
+	}
+	reset_ba_system(false);
+	for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+		geo[i] = bg_record->geo[i];
+	debug2("adding %s %c%c%c %c%c%c",
+	       bg_record->nodes,
+	       alpha_num[bg_record->start[X]],
+	       alpha_num[bg_record->start[Y]],
+	       alpha_num[bg_record->start[Z]],
+	       alpha_num[geo[X]],
+	       alpha_num[geo[Y]],
+	       alpha_num[geo[Z]]);
+	results = list_create(NULL);
+	name = set_bg_block(results,
+			    bg_record->start, 
+			    geo, 
+			    bg_record->conn_type);
+	if(!name) {
+		error("I was unable to make the "
+		      "requested block.");
+		list_destroy(results);
+		list_iterator_destroy(itr);
+		slurm_mutex_unlock(&block_state_mutex);
+		return SLURM_ERROR;
+	}
+	xfree(name);
+	if(bg_record->bg_block_list)
+		list_destroy(bg_record->bg_block_list);
+	bg_record->bg_block_list = list_create(destroy_ba_node);
+	copy_node_path(results, bg_record->bg_block_list);
+	list_destroy(results);
+				
+	if((rc = configure_block(bg_record)) == SLURM_ERROR) {
+		error("create_full_system_block: "
+		      "unable to configure block in api");
+		destroy_bg_record(bg_record);
+		goto no_total;
+	}
+
+	print_bg_record(bg_record);
+	list_append(bg_list, bg_record);
+
+no_total:
+	if(records)
+		list_destroy(records);
+	slurm_mutex_unlock(&block_state_mutex);
+	return rc;
+}
diff --git a/src/plugins/select/bluegene/plugin/defined_block.h b/src/plugins/select/bluegene/plugin/defined_block.h
new file mode 100644
index 0000000000000000000000000000000000000000..4255135f3c2508117150a0a75fcb76c155fda112
--- /dev/null
+++ b/src/plugins/select/bluegene/plugin/defined_block.h
@@ -0,0 +1,48 @@
+/*****************************************************************************\
+ *  defined_block.h - header for creating blocks in a static environment.
+ *
+ *  $Id: defined_block.h 12954 2008-01-04 20:37:49Z da $
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _BLUEGENE_DEFINED_BLOCK_H_
+#define _BLUEGENE_DEFINED_BLOCK_H_
+
+#include "bluegene.h"
+
+extern int create_defined_blocks(bg_layout_t overlapped,
+				 List bg_found_block_list);
+extern int create_full_system_block(List bg_found_block_list);
+
+#endif /* _BLUEGENE_DEFINED_BLOCK_H_ */
diff --git a/src/plugins/select/bluegene/plugin/dynamic_block.c b/src/plugins/select/bluegene/plugin/dynamic_block.c
new file mode 100644
index 0000000000000000000000000000000000000000..941f4fc7913036b1f3de9d681822bb0c3381ef38
--- /dev/null
+++ b/src/plugins/select/bluegene/plugin/dynamic_block.c
@@ -0,0 +1,715 @@
+/*****************************************************************************\
+ *  dynamic_block.c - functions for creating blocks in a dynamic environment.
+ *
+ *  $Id: dynamic_block.c 12954 2008-01-04 20:37:49Z da $
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "dynamic_block.h"
+
+static int _split_block(List block_list, List new_blocks,
+			bg_record_t *bg_record, int procs);
+static int _breakup_blocks(List block_list, List new_blocks,
+			   ba_request_t *request, List my_block_list);
+
+/*
+ * create_dynamic_block - create new block(s) to be used for a new
+ * job allocation.
+ * RET - a list of created block(s) or NULL on failure errno is set.
+ */
+extern List create_dynamic_block(List block_list, 
+				 ba_request_t *request, List my_block_list)
+{
+	int rc = SLURM_SUCCESS;
+	
+	ListIterator itr;
+	bg_record_t *bg_record = NULL;
+	List results = NULL;
+	List new_blocks = NULL;
+	uint16_t num_quarter=0, num_nodecard=0;
+	bitstr_t *my_bitmap = NULL;
+	int geo[BA_SYSTEM_DIMENSIONS];
+	int i;
+	blockreq_t blockreq;
+
+	slurm_mutex_lock(&block_state_mutex);
+	if(my_block_list) {
+		reset_ba_system(true);
+		itr = list_iterator_create(my_block_list);
+		while ((bg_record = list_next(itr))) {
+			if(!my_bitmap) {
+				my_bitmap = 
+					bit_alloc(bit_size(bg_record->bitmap));
+			}
+				
+			if(!bit_super_set(bg_record->bitmap, my_bitmap)) {
+				bit_or(my_bitmap, bg_record->bitmap);
+				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+					geo[i] = bg_record->geo[i];
+				debug2("adding %s %c%c%c %c%c%c",
+				       bg_record->nodes,
+				       alpha_num[bg_record->start[X]],
+				       alpha_num[bg_record->start[Y]],
+				       alpha_num[bg_record->start[Z]],
+				       alpha_num[geo[X]],
+				       alpha_num[geo[Y]],
+				       alpha_num[geo[Z]]);
+
+				if(check_and_set_node_list(
+					   bg_record->bg_block_list)
+				   == SLURM_ERROR) {
+					debug2("something happened in "
+					       "the load of %s",
+					       bg_record->bg_block_id);
+					list_iterator_destroy(itr);
+					FREE_NULL_BITMAP(my_bitmap);
+					rc = SLURM_ERROR;
+					goto finished;
+				}
+			}
+		}
+		list_iterator_destroy(itr);
+		FREE_NULL_BITMAP(my_bitmap);
+	} else {
+		reset_ba_system(false);
+		debug("No list was given");
+	}
+
+	if(request->avail_node_bitmap) {
+		int j=0, number;
+		int x,y,z;
+		char *nodes = NULL;
+		bitstr_t *bitmap = bit_alloc(node_record_count);
+		int start[BA_SYSTEM_DIMENSIONS];
+		int end[BA_SYSTEM_DIMENSIONS];
+		
+		/* we want the bps that aren't in this partition to
+		 * mark them as used
+		 */
+		bit_or(bitmap, request->avail_node_bitmap);
+		bit_not(bitmap);
+		nodes = bitmap2node_name(bitmap);
+		
+		//info("not using %s", nodes);
+		while(nodes[j] != '\0') {
+			if ((nodes[j] == '[' || nodes[j] == ',')
+			    && (nodes[j+8] == ']' || nodes[j+8] == ',')
+			    && (nodes[j+4] == 'x' || nodes[j+4] == '-')) {
+
+				j++;
+				number = xstrntol(nodes + j,
+						  NULL, BA_SYSTEM_DIMENSIONS,
+						  HOSTLIST_BASE);
+				start[X] = number / 
+					(HOSTLIST_BASE * HOSTLIST_BASE);
+				start[Y] = (number % 
+					    (HOSTLIST_BASE * HOSTLIST_BASE))
+					/ HOSTLIST_BASE;
+				start[Z] = (number % HOSTLIST_BASE);
+				j += 4;
+				number = xstrntol(nodes + j,
+						NULL, 3, HOSTLIST_BASE);
+				end[X] = number /
+					(HOSTLIST_BASE * HOSTLIST_BASE);
+				end[Y] = (number 
+					  % (HOSTLIST_BASE * HOSTLIST_BASE))
+					/ HOSTLIST_BASE;
+				end[Z] = (number % HOSTLIST_BASE);
+				j += 3;
+				for (x = start[X]; x <= end[X]; x++) {
+					for (y = start[Y]; y <= end[Y]; y++) {
+						for (z = start[Z]; 
+						     z <= end[Z]; z++) {
+							ba_system_ptr->
+								grid[x]
+#ifdef HAVE_BG
+								[y][z]
+#endif
+								.used = 1;
+						}
+					}
+				}
+				
+				if(nodes[j] != ',')
+					break;
+				j--;
+			} else if((nodes[j] >= '0' && nodes[j] <= '9')
+				  || (nodes[j] >= 'A' && nodes[j] <= 'Z')) {
+				
+				number = xstrntol(nodes + j,
+						  NULL, BA_SYSTEM_DIMENSIONS,
+						  HOSTLIST_BASE);
+				x = number / (HOSTLIST_BASE * HOSTLIST_BASE);
+				y = (number % (HOSTLIST_BASE * HOSTLIST_BASE))
+					/ HOSTLIST_BASE;
+				z = (number % HOSTLIST_BASE);
+				j+=3;
+
+				ba_system_ptr->grid[x]
+#ifdef HAVE_BG
+					[y][z]
+#endif
+					.used = 1;
+
+				if(nodes[j] != ',')
+					break;
+				j--;
+			}
+			j++;
+		}
+		xfree(nodes);
+		FREE_NULL_BITMAP(bitmap);
+	}
+
+	if(request->size==1 && request->procs < bluegene_bp_node_cnt) {
+		request->conn_type = SELECT_SMALL;
+		if(request->procs == (procs_per_node/16)) {
+			if(!bluegene_nodecard_ionode_cnt) {
+				error("can't create this size %d "
+				      "on this system numpsets is %d",
+				      request->procs,
+				      bluegene_numpsets);
+				goto finished;
+			}
+
+			num_nodecard=4;
+			num_quarter=3;
+		} else {
+			if(!bluegene_quarter_ionode_cnt) {
+				error("can't create this size %d "
+				      "on this system numpsets is %d",
+				      request->procs,
+				      bluegene_numpsets);
+				goto finished;
+			}
+			num_quarter=4;
+		}
+		new_blocks = list_create(destroy_bg_record);
+		if(_breakup_blocks(block_list, new_blocks, 
+				   request, my_block_list)
+		   != SLURM_SUCCESS) {
+			list_destroy(new_blocks);
+			new_blocks = NULL;
+			debug2("small block not able to be placed");
+			//rc = SLURM_ERROR;
+		} else 
+			goto finished;
+	}
+	
+	if(request->conn_type == SELECT_NAV)
+		request->conn_type = SELECT_TORUS;
+	
+	if(!new_ba_request(request)) {
+		error("Problems with request for size %d geo %dx%dx%d", 
+		      request->size,
+		      request->geometry[X], 
+		      request->geometry[Y], 
+		      request->geometry[Z]);
+		rc = ESLURM_INTERCONNECT_FAILURE;
+		goto finished;
+	} 
+	
+	if(!list_count(block_list) || !my_block_list) {
+		bg_record = NULL;
+		goto no_list;
+	}
+
+	/*Try to put block starting in the smallest of the exisiting blocks*/
+	if(!request->start_req) {
+		itr = list_iterator_create(block_list);
+		while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
+			request->rotate_count = 0;
+			request->elongate_count = 1;
+		
+			if(bg_record->job_running == NO_JOB_RUNNING 
+			   && (bg_record->quarter == (uint16_t) NO_VAL
+			       || (bg_record->quarter == 0 
+				   && (bg_record->nodecard == (uint16_t) NO_VAL
+				       || bg_record->nodecard == 0)))) {
+				
+				for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+					request->start[i] = 
+						bg_record->start[i];
+				debug2("allocating %s %c%c%c %d",
+				       bg_record->nodes,
+				       alpha_num[request->start[X]],
+				       alpha_num[request->start[Y]],
+				       alpha_num[request->start[Z]],
+				       request->size);
+				request->start_req = 1;
+				rc = SLURM_SUCCESS;
+				if(results)
+					list_delete_all(
+						results,
+						&empty_null_destroy_list, "");
+				else
+					results = list_create(NULL);
+				if (!allocate_block(request, results)){
+					debug2("1 allocate failure for size %d "
+					       "base partitions", 
+					       request->size);
+					rc = SLURM_ERROR;
+				} else 
+					break;
+			}
+		}
+		list_iterator_destroy(itr);
+		
+		request->start_req = 0;
+		for(i=0; i<BA_SYSTEM_DIMENSIONS; i++) 
+			request->start[i] = (uint16_t) NO_VAL;
+	}
+
+no_list:
+	if(!bg_record) {		
+		rc = SLURM_SUCCESS;
+		if(results)
+			list_delete_all(results, 
+					&empty_null_destroy_list, "");
+		else
+			results = list_create(NULL);
+		if (!allocate_block(request, results)) {
+			debug("allocate failure for size %d base partitions", 
+			       request->size);
+			rc = SLURM_ERROR;
+		}
+	}
+
+	if(rc != SLURM_SUCCESS) 
+		goto finished;
+	
+	/*set up bg_record(s) here */
+	new_blocks = list_create(destroy_bg_record);
+	
+	blockreq.block = request->save_name;
+	blockreq.blrtsimage = request->blrtsimage;
+	blockreq.linuximage = request->linuximage;
+	blockreq.mloaderimage = request->mloaderimage;
+	blockreq.ramdiskimage = request->ramdiskimage;
+	blockreq.conn_type = request->conn_type;
+	blockreq.nodecards = num_nodecard;
+	blockreq.quarters = num_quarter;
+
+	add_bg_record(new_blocks, results, &blockreq);
+
+finished:
+	xfree(request->save_name);
+	
+	if(request->elongate_geos) {
+		list_destroy(request->elongate_geos);
+		request->elongate_geos = NULL;
+	}
+	if(results)
+		list_destroy(results);
+	errno = rc;
+	slurm_mutex_unlock(&block_state_mutex);
+
+	return new_blocks;
+}
+
+extern bg_record_t *create_small_record(bg_record_t *bg_record, 
+					uint16_t quarter, uint16_t nodecard)
+{
+	bg_record_t *found_record = NULL;
+	int small_size = 4;
+	ListIterator itr = NULL;
+	ba_node_t *new_ba_node = NULL;
+	ba_node_t *ba_node = NULL;
+	found_record = (bg_record_t*) xmalloc(sizeof(bg_record_t));
+				
+	found_record->job_running = NO_JOB_RUNNING;
+	found_record->user_name = xstrdup(bg_record->user_name);
+	found_record->user_uid = bg_record->user_uid;
+	found_record->bg_block_list = list_create(destroy_ba_node);
+	itr = list_iterator_create(bg_record->bg_block_list);
+	ba_node = list_next(itr);
+	list_iterator_destroy(itr);
+	if(!ba_node)
+		error("you gave me a list with no ba_nodes");
+	else {
+		int i=0,j=0;
+		new_ba_node = ba_copy_node(ba_node);
+		for (i=0; i<BA_SYSTEM_DIMENSIONS; i++){
+			for(j=0;j<NUM_PORTS_PER_NODE;j++) {
+				ba_node->axis_switch[i].int_wire[j].used = 0;	
+				if(i!=X) {
+					if(j==3 || j==4) 
+						ba_node->axis_switch[i].
+							int_wire[j].
+							used = 1;	
+				}
+				ba_node->axis_switch[i].int_wire[j].
+					port_tar = j;
+			}
+		}
+		list_append(found_record->bg_block_list, new_ba_node);
+		found_record->bp_count = 1;
+	}
+	found_record->nodes = xstrdup(bg_record->nodes);
+	found_record->blrtsimage = xstrdup(bg_record->blrtsimage);
+	found_record->linuximage = xstrdup(bg_record->linuximage);
+	found_record->mloaderimage = xstrdup(bg_record->mloaderimage);
+	found_record->ramdiskimage = xstrdup(bg_record->ramdiskimage);
+
+	process_nodes(found_record, false);
+				
+	found_record->conn_type = SELECT_SMALL;
+				
+	found_record->node_use = SELECT_COPROCESSOR_MODE;
+	if(nodecard != (uint16_t) NO_VAL)
+		small_size = 16;
+	found_record->cpus_per_bp = procs_per_node/small_size;
+	found_record->node_cnt = bluegene_bp_node_cnt/small_size;
+	found_record->quarter = quarter; 
+	found_record->nodecard = nodecard;
+	
+	if(set_ionodes(found_record) == SLURM_ERROR) 
+		error("couldn't create ionode_bitmap for %d.%d",
+		      found_record->quarter, found_record->nodecard);
+	return found_record;
+}
+
+/*********************** Local Functions *************************/
+
+static int _split_block(List block_list, List new_blocks,
+			bg_record_t *bg_record, int procs) 
+{
+	bg_record_t *found_record = NULL;
+	bool full_bp = false; 
+	int small_count = 0;
+	int small_size = 0;
+	uint16_t num_nodecard = 0, num_quarter = 0;
+	int i;
+	int node_cnt = 0;
+	uint16_t quarter = 0;
+	uint16_t nodecard = 0;
+
+	if(bg_record->quarter == (uint16_t) NO_VAL)
+		full_bp = true;
+	
+	if(procs == (procs_per_node/16) && bluegene_nodecard_ionode_cnt) {
+		num_nodecard=4;
+		if(full_bp)
+			num_quarter=3;
+	} else if(full_bp) {
+		num_quarter = 4;
+	} else {
+		error("you asked for something that was already this size");
+		return SLURM_ERROR;
+	}
+	debug2("asking for %d 32s from a %d block",
+	       num_nodecard, bg_record->node_cnt);
+	small_count = num_nodecard+num_quarter; 
+
+	/* break base partition up into 16 parts */
+	small_size = bluegene_bp_node_cnt/bluegene_nodecard_node_cnt;
+	node_cnt = 0;
+	if(!full_bp)
+		quarter = bg_record->quarter;
+	else
+		quarter = 0;
+	nodecard = 0;
+	for(i=0; i<small_count; i++) {
+		if(i == num_nodecard) {
+			/* break base partition up into 4 parts */
+			small_size = 4;
+		}
+		
+		if(small_size == 4)
+			nodecard = (uint16_t)NO_VAL;
+		else
+			nodecard = i%4; 
+		found_record = create_small_record(bg_record,
+						   quarter,
+						   nodecard);
+		list_append(new_blocks, found_record);
+				
+		node_cnt += bluegene_bp_node_cnt/small_size;
+		if(node_cnt == 128) {
+			node_cnt = 0;
+			quarter++;
+		}
+	}
+		
+	return SLURM_SUCCESS;
+}
+
+static int _breakup_blocks(List block_list, List new_blocks,
+			   ba_request_t *request, List my_block_list)
+{
+	int rc = SLURM_ERROR;
+	bg_record_t *bg_record = NULL;
+	ListIterator itr;
+	int proc_cnt=0;
+	int total_proc_cnt=0;
+	uint16_t last_quarter = (uint16_t) NO_VAL;
+	char tmp_char[256];
+	
+	debug2("proc count = %d size = %d",
+	       request->procs, request->size);
+	
+	itr = list_iterator_create(block_list);			
+	while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
+		if(bg_record->job_running != NO_JOB_RUNNING)
+			continue;
+		if(bg_record->state != RM_PARTITION_FREE)
+			continue;
+		if (request->avail_node_bitmap &&
+		    !bit_super_set(bg_record->bitmap,
+				   request->avail_node_bitmap)) {
+			debug2("bg block %s has nodes not usable by this job",
+			       bg_record->bg_block_id);
+			continue;
+		}
+
+		if(request->start_req) {
+			if ((request->start[X] != bg_record->start[X])
+			    || (request->start[Y] != bg_record->start[Y])
+			    || (request->start[Z] != bg_record->start[Z])) {
+				debug4("small got %c%c%c looking for %c%c%c",
+				       alpha_num[bg_record->start[X]],
+				       alpha_num[bg_record->start[Y]],
+				       alpha_num[bg_record->start[Z]],
+				       alpha_num[request->start[X]],
+				       alpha_num[request->start[Y]],
+				       alpha_num[request->start[Z]]);
+				continue;
+			}
+			debug3("small found %c%c%c looking for %c%c%c",
+			       alpha_num[bg_record->start[X]],
+			       alpha_num[bg_record->start[Y]],
+			       alpha_num[bg_record->start[Z]],
+			       alpha_num[request->start[X]],
+			       alpha_num[request->start[Y]],
+			       alpha_num[request->start[Z]]);
+		}
+		proc_cnt = bg_record->bp_count * 
+			bg_record->cpus_per_bp;
+		if(proc_cnt == request->procs) {
+			debug2("found it here %s, %s",
+			       bg_record->bg_block_id,
+			       bg_record->nodes);
+			request->save_name = xmalloc(4);
+			snprintf(request->save_name,
+				 4,
+				 "%c%c%c",
+				 alpha_num[bg_record->start[X]],
+				 alpha_num[bg_record->start[Y]],
+				 alpha_num[bg_record->start[Z]]);
+			rc = SLURM_SUCCESS;
+			goto finished;
+		}
+		if(bg_record->node_cnt > bluegene_bp_node_cnt)
+			continue;
+		if(proc_cnt < request->procs) {
+			if(last_quarter != bg_record->quarter){
+				last_quarter = bg_record->quarter;
+				total_proc_cnt = proc_cnt;
+			} else {
+				total_proc_cnt += proc_cnt;
+			}
+			debug2("1 got %d on quarter %d",
+			       total_proc_cnt, last_quarter);
+			if(total_proc_cnt == request->procs) {
+				request->save_name = xmalloc(4);
+				snprintf(request->save_name, 
+					 4,
+					 "%c%c%c",
+					 alpha_num[bg_record->start[X]],
+					 alpha_num[bg_record->start[Y]],
+					 alpha_num[bg_record->start[Z]]);
+				if(!my_block_list) {
+					rc = SLURM_SUCCESS;
+					goto finished;	
+				}
+						
+				bg_record = create_small_record(
+					bg_record,
+					last_quarter,
+					(uint16_t) NO_VAL);
+				list_append(new_blocks, bg_record);
+							
+				rc = SLURM_SUCCESS;
+				goto finished;	
+			}
+			continue;
+		}
+		break;
+	}
+	if(bg_record) {
+		debug2("got one on the first pass");
+		goto found_one;
+	}
+	list_iterator_reset(itr);
+	last_quarter = (uint16_t) NO_VAL;
+	while ((bg_record = (bg_record_t *) list_next(itr)) 
+	       != NULL) {
+		if(bg_record->job_running != NO_JOB_RUNNING)
+			continue;
+		if (request->avail_node_bitmap &&
+		    !bit_super_set(bg_record->bitmap,
+				   request->avail_node_bitmap)) {
+			debug2("bg block %s has nodes not usable by this job",
+			       bg_record->bg_block_id);
+			continue;
+		}
+
+		if(request->start_req) {
+			if ((request->start[X] != bg_record->start[X])
+			    || (request->start[Y] != bg_record->start[Y])
+			    || (request->start[Z] != bg_record->start[Z])) {
+				debug4("small 2 got %c%c%c looking for %c%c%c",
+				       alpha_num[bg_record->start[X]],
+				       alpha_num[bg_record->start[Y]],
+				       alpha_num[bg_record->start[Z]],
+				       alpha_num[request->start[X]],
+				       alpha_num[request->start[Y]],
+				       alpha_num[request->start[Z]]);
+				continue;
+			}
+			debug3("small 2 found %c%c%c looking for %c%c%c",
+			       alpha_num[bg_record->start[X]],
+			       alpha_num[bg_record->start[Y]],
+			       alpha_num[bg_record->start[Z]],
+			       alpha_num[request->start[X]],
+			       alpha_num[request->start[Y]],
+			       alpha_num[request->start[Z]]);
+		}
+				
+		proc_cnt = bg_record->bp_count * bg_record->cpus_per_bp;
+		if(proc_cnt == request->procs) {
+			debug2("found it here %s, %s",
+			       bg_record->bg_block_id,
+			       bg_record->nodes);
+			request->save_name = xmalloc(4);
+			snprintf(request->save_name,
+				 4,
+				 "%c%c%c",
+				 alpha_num[bg_record->start[X]],
+				 alpha_num[bg_record->start[Y]],
+				 alpha_num[bg_record->start[Z]]);
+			rc = SLURM_SUCCESS;
+			goto finished;
+		} 
+
+		if(bg_record->node_cnt > bluegene_bp_node_cnt)
+			continue;
+		if(proc_cnt < request->procs) {
+			if(last_quarter != bg_record->quarter){
+				last_quarter = bg_record->quarter;
+				total_proc_cnt = proc_cnt;
+			} else {
+				total_proc_cnt += proc_cnt;
+			}
+			debug2("got %d on quarter %d",
+			       total_proc_cnt, last_quarter);
+			if(total_proc_cnt == request->procs) {
+				request->save_name = xmalloc(4);
+				snprintf(request->save_name,
+					 4,
+					 "%c%c%c",
+					 alpha_num[bg_record->start[X]],
+					 alpha_num[bg_record->start[Y]],
+					 alpha_num[bg_record->start[Z]]);
+				if(!my_block_list) {
+					rc = SLURM_SUCCESS;
+					goto finished;	
+				}
+				bg_record = create_small_record(
+					bg_record,
+					last_quarter,
+					(uint16_t) NO_VAL);
+				list_append(new_blocks, bg_record);
+								
+				rc = SLURM_SUCCESS;
+				goto finished;	
+			}
+			continue;
+		}				
+		break;
+	}
+found_one:
+	if(bg_record) {
+		List temp_list = NULL;
+		bg_record_t *found_record = NULL;
+
+		if(bg_record->original) {
+			debug3("This was a copy");
+			found_record = bg_record->original;
+		} else {
+			debug3("looking for original");
+			found_record = find_org_in_bg_list(
+				bg_list, bg_record);
+		}
+		if(!found_record) {
+			error("this record wasn't found in the list!");
+			rc = SLURM_ERROR;
+			goto finished;
+		}
+		
+		format_node_name(found_record, tmp_char, sizeof(tmp_char));
+			
+		debug2("going to split %s, %s",
+		       found_record->bg_block_id,
+		       tmp_char);
+		request->save_name = xmalloc(4);
+		snprintf(request->save_name, 
+			 4,
+			 "%c%c%c",
+			 alpha_num[found_record->start[X]],
+			 alpha_num[found_record->start[Y]],
+			 alpha_num[found_record->start[Z]]);
+		if(!my_block_list) {
+			rc = SLURM_SUCCESS;
+			goto finished;	
+		}
+		_split_block(block_list, new_blocks,
+			     found_record, request->procs);
+		remove_from_bg_list(block_list, bg_record);
+		destroy_bg_record(bg_record);
+		remove_from_bg_list(bg_list, found_record);
+		temp_list = list_create(NULL);
+		list_push(temp_list, found_record);
+		num_block_to_free++;
+		free_block_list(temp_list);
+		list_destroy(temp_list);
+		rc = SLURM_SUCCESS;
+		goto finished;
+	}
+	
+finished:
+	list_iterator_destroy(itr);
+		
+	return rc;
+}
diff --git a/src/plugins/select/bluegene/plugin/dynamic_block.h b/src/plugins/select/bluegene/plugin/dynamic_block.h
new file mode 100644
index 0000000000000000000000000000000000000000..c98aadf1a32b492088d8a0a8584ab01242f41efe
--- /dev/null
+++ b/src/plugins/select/bluegene/plugin/dynamic_block.h
@@ -0,0 +1,49 @@
+/*****************************************************************************\
+ *  dynamic_block.h - header for creating blocks in a dynamic environment.
+ *
+ *  $Id: dynamic_block.h 12954 2008-01-04 20:37:49Z da $
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _BLUEGENE_DYNAMIC_BLOCK_H_
+#define _BLUEGENE_DYNAMIC_BLOCK_H_
+
+#include "bluegene.h"
+
+extern List create_dynamic_block(List block_list,
+				 ba_request_t *request, List my_block_list);
+
+extern bg_record_t *create_small_record(bg_record_t *bg_record, 
+					uint16_t quarter, uint16_t nodecard);
+#endif /* _BLUEGENE_DYNAMIC_BLOCK_H_ */
diff --git a/src/plugins/select/bluegene/plugin/opts.c b/src/plugins/select/bluegene/plugin/opts.c
index e196a982e6979addc39ffaea863f94df77594818..4fa9392294bf00598190cf8d00de5f260e23a540 100644
--- a/src/plugins/select/bluegene/plugin/opts.c
+++ b/src/plugins/select/bluegene/plugin/opts.c
@@ -1,11 +1,11 @@
 /****************************************************************************\
  *  opts.c - sfree command line option processing functions
- *  $Id: opts.c 12403 2007-09-25 18:36:42Z da $
+ *  $Id: opts.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/select/bluegene/plugin/select_bluegene.c b/src/plugins/select/bluegene/plugin/select_bluegene.c
index e23eca54c2d91890b85d02679ee7ea8aaaf9853f..1d17316b75c648a25ea48dfe5468db862d6f3c35 100644
--- a/src/plugins/select/bluegene/plugin/select_bluegene.c
+++ b/src/plugins/select/bluegene/plugin/select_bluegene.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  select_bluegene.c - node selection plugin for Blue Gene system.
  * 
- *  $Id: select_bluegene.c 13423 2008-02-29 17:30:38Z da $
+ *  $Id: select_bluegene.c 14091 2008-05-20 21:34:02Z da $
  *****************************************************************************
  *  Copyright (C) 2004-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Dan Phung <phung4@llnl.gov> Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -38,6 +38,11 @@
 \*****************************************************************************/
 
 #include "bluegene.h"
+
+#ifndef HAVE_BG
+#include "defined_block.h"
+#endif
+
 #include "src/slurmctld/trigger_mgr.h"
 #include <fcntl.h>
  
@@ -45,7 +50,7 @@
 
 /* Change BLOCK_STATE_VERSION value when changing the state save
  * format i.e. pack_block() */
-#define BLOCK_STATE_VERSION      "VER000"
+#define BLOCK_STATE_VERSION      "VER001"
 
 /* global */
 int procs_per_node = 512;
@@ -80,7 +85,7 @@ int procs_per_node = 512;
  */
 const char plugin_name[]       	= "Blue Gene node selection plugin";
 const char plugin_type[]       	= "select/bluegene";
-const uint32_t plugin_version	= 90;
+const uint32_t plugin_version	= 100;
 
 /* pthread stuff for updating BG node status */
 static pthread_t bluegene_thread = 0;
@@ -91,6 +96,8 @@ static int _init_status_pthread(void);
 static int _wait_for_thread (pthread_t thread_id);
 static char *_block_state_str(int state);
 
+extern int select_p_alter_node_cnt(enum select_node_cnt type, void *data);
+
 /*
  * init() is called when the plugin is loaded, before any other functions
  * are called.  Put global initialization here.
@@ -117,6 +124,7 @@ extern int init ( void )
 	if ((SELECT_COPROCESSOR_MODE  != RM_PARTITION_COPROCESSOR_MODE)
 	||  (SELECT_VIRTUAL_NODE_MODE != RM_PARTITION_VIRTUAL_NODE_MODE))
 		fatal("enum node_use_type out of sync with rm_api.h");
+	
 #endif
 
 	verbose("%s loading...", plugin_name);
@@ -213,9 +221,22 @@ extern int fini ( void )
 		fatal("Error, could not read the file");
 		return SLURM_ERROR;
 	}
+	if(part_list) {
+		struct part_record *part_ptr = NULL;
+		ListIterator itr = list_iterator_create(part_list);
+		while((part_ptr = list_next(itr))) {
+			part_ptr->max_nodes = part_ptr->max_nodes_orig;
+			part_ptr->min_nodes = part_ptr->min_nodes_orig;
+			select_p_alter_node_cnt(SELECT_SET_BP_CNT, 
+						&part_ptr->max_nodes);
+			select_p_alter_node_cnt(SELECT_SET_BP_CNT,
+						&part_ptr->min_nodes);
+		}
+		list_iterator_destroy(itr);
+	}
 #else
 	/*looking for blocks only I created */
-	if (create_defined_blocks(bluegene_layout_mode) 
+	if (create_defined_blocks(bluegene_layout_mode, NULL) 
 			== SLURM_ERROR) {
 		/* error in creating the static blocks, so
 		 * blocks referenced by submitted jobs won't
@@ -225,7 +246,7 @@ extern int fini ( void )
 		return SLURM_ERROR;
 	}
 #endif
-	
+
 	return SLURM_SUCCESS; 
 }
 
@@ -337,7 +358,7 @@ extern int select_p_state_restore(char *dir_name)
 	List results = NULL;
 	int data_allocated, data_read = 0;
 	char *ver_str = NULL;
-	uint16_t ver_str_len;
+	uint32_t ver_str_len;
 	struct passwd *pw_ent = NULL;
 	int blocks = 0;
 
@@ -385,10 +406,9 @@ extern int select_p_state_restore(char *dir_name)
 	 * we don't try to unpack data using the wrong format routines
 	 */
 	if(size_buf(buffer)
-	   >= sizeof(uint16_t) + strlen(BLOCK_STATE_VERSION)) {
+	   >= sizeof(uint32_t) + strlen(BLOCK_STATE_VERSION)) {
 	        char *ptr = get_buf_data(buffer);
-		
-	        if (!memcmp(&ptr[sizeof(uint16_t)], BLOCK_STATE_VERSION, 3)) {
+		if (!memcmp(&ptr[sizeof(uint32_t)], BLOCK_STATE_VERSION, 3)) {
 		        safe_unpackstr_xmalloc(&ver_str, &ver_str_len, buffer);
 		        debug3("Version string in block_state header is %s",
 			       ver_str);
@@ -402,9 +422,10 @@ extern int select_p_state_restore(char *dir_name)
 		return EFAULT;
 	}
 	xfree(ver_str);
-	if(select_g_unpack_node_info(&node_select_ptr, buffer) == SLURM_ERROR) 
+	if(select_g_unpack_node_info(&node_select_ptr, buffer) == SLURM_ERROR) { 
+		error("select_p_state_restore: problem unpacking node_info");
 		goto unpack_error;
-	
+	}
 	reset_ba_system(false);
 
 	node_bitmap = bit_alloc(node_record_count);	
@@ -416,6 +437,21 @@ extern int select_p_state_restore(char *dir_name)
 		bit_nclear(node_bitmap, 0, bit_size(node_bitmap) - 1);
 		bit_nclear(ionode_bitmap, 0, bit_size(ionode_bitmap) - 1);
 		
+		j = 0;
+		while(bg_info_record->bp_inx[j] >= 0) {
+			if (bg_info_record->bp_inx[j+1]
+			    >= node_record_count) {
+				fatal("Job state recovered incompatable with "
+					"bluegene.conf. bp=%u state=%d",
+					node_record_count,
+					bg_info_record->bp_inx[j+1]);
+			}
+			bit_nset(node_bitmap,
+				 bg_info_record->bp_inx[j],
+				 bg_info_record->bp_inx[j+1]);
+			j += 2;
+		}		
+
 		j = 0;
 		while(bg_info_record->ionode_inx[j] >= 0) {
 			if (bg_info_record->ionode_inx[j+1]
@@ -434,9 +470,10 @@ extern int select_p_state_restore(char *dir_name)
 		while((bg_record = list_next(itr))) {
 			if(bit_equal(bg_record->bitmap, node_bitmap)
 			   && bit_equal(bg_record->ionode_bitmap,
-					ionode_bitmap)) 
+					ionode_bitmap))
 				break;			
 		}
+
 		list_iterator_reset(itr);
 		if(bg_record) {
 			slurm_mutex_lock(&block_state_mutex);
@@ -456,9 +493,10 @@ extern int select_p_state_restore(char *dir_name)
 			continue;
 #endif
 			if(bluegene_layout_mode != LAYOUT_DYNAMIC) {
-				error("Only adding state save blocks in "
-				      "Dynamic block creation Mode not "
-				      "adding %s",
+				error("Evidently we found a block (%s) which "
+				      "we had before but no longer care about. "
+				      "We are not adding it since we aren't "
+				      "using Dynamic mode",
 				      bg_info_record->bg_block_id);
 				continue;
 			}
@@ -492,7 +530,7 @@ extern int select_p_state_restore(char *dir_name)
 			bg_record->conn_type = bg_info_record->conn_type;
 			bg_record->boot_state = 0;
 
-			process_nodes(bg_record);
+			process_nodes(bg_record, true);
 
 			slurm_conf_lock();
 			bg_record->target_name = 
@@ -542,13 +580,18 @@ extern int select_p_state_restore(char *dir_name)
 
 			xfree(name);
 			if(strcmp(temp, bg_record->nodes)) {
+#ifdef HAVE_BG_FILES
 				fatal("given list of %s "
 				      "but allocated %s, "
 				      "your order might be "
-				      "wrong in the "
-				      "bluegene.conf",
-				      bg_record->nodes,
-				      temp);
+				      "wrong in bluegene.conf",
+				      bg_record->nodes, temp);
+#else
+				fatal("bad wiring in preserved state "
+				      "(found %s, but allocated %s) "
+				      "YOU MUST COLDSTART",
+				      bg_record->nodes, temp);
+#endif
 			}
 			if(bg_record->bg_block_list)
 				list_destroy(bg_record->bg_block_list);
@@ -566,7 +609,9 @@ extern int select_p_state_restore(char *dir_name)
 	FREE_NULL_BITMAP(node_bitmap);
 	list_iterator_destroy(itr);
 
+	slurm_mutex_lock(&block_state_mutex);
 	sort_bg_record_inc_size(bg_list);
+	slurm_mutex_unlock(&block_state_mutex);
 		
 	info("Recovered %d blocks", blocks);
 	select_g_free_node_info(&node_select_ptr);
@@ -599,33 +644,52 @@ extern int select_p_node_init(struct node_record *node_ptr, int node_cnt)
  *	identify the nodes which "best" satify the request. The specified 
  *	nodes may be DOWN or BUSY at the time of this test as may be used 
  *	to deterime if a job could ever run.
- * IN job_ptr - pointer to job being scheduled
+ * IN/OUT job_ptr - pointer to job being scheduled start_time is set
+ *	when we can possibly start job.
  * IN/OUT bitmap - usable nodes are set on input, nodes not required to 
  *	satisfy the request are cleared, other left set
  * IN min_nodes - minimum count of nodes
  * IN max_nodes - maximum count of nodes (0==don't care)
  * IN req_nodes - requested (or desired) count of nodes
- * IN test_only - if true, only test if ever could run, not necessarily now
+ * IN mode - SELECT_MODE_RUN_NOW: try to schedule job now
+ *           SELECT_MODE_TEST_ONLY: test if job can ever run
+ *           SELECT_MODE_WILL_RUN: determine when and where job can run
  * RET zero on success, EINVAL otherwise
  * NOTE: bitmap must be a superset of req_nodes at the time that 
  *	select_p_job_test is called
  */
 extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
-			uint32_t min_nodes, uint32_t max_nodes, 
-			uint32_t req_nodes, bool test_only)
+			     uint32_t min_nodes, uint32_t max_nodes, 
+			     uint32_t req_nodes, int mode)
 {
-	/* bg block test - is there a block where we have:
+	/* submit_job - is there a block where we have:
 	 * 1) geometry requested
 	 * 2) min/max nodes (BPs) requested
 	 * 3) type: TORUS or MESH or NAV (torus else mesh)
-	 * 4) use: VIRTUAL or COPROCESSOR
 	 * 
 	 * note: we don't have to worry about security at this level
 	 * as the SLURM block logic will handle access rights.
 	 */
 
 	return submit_job(job_ptr, bitmap, min_nodes, max_nodes, 
-			  req_nodes, test_only);
+			  req_nodes, mode);
+}
+
+/*
+ * select_p_job_list_test - Given a list of select_will_run_t's in
+ *	accending priority order we will see if we can start and
+ *	finish all the jobs without increasing the start times of the
+ *	jobs specified and fill in the est_start of requests with no
+ *	est_start.  If you are looking to see if one job will ever run
+ *	then use select_p_job_test instead.
+ * IN/OUT req_list - list of select_will_run_t's in asscending
+ *	             priority order on success of placement fill in
+ *	             est_start of request with time.
+ * RET zero on success, EINVAL otherwise
+ */
+extern int select_p_job_list_test(List req_list)
+{
+	return test_job_list(req_list);
 }
 
 extern int select_p_job_begin(struct job_record *job_ptr)
@@ -648,6 +712,11 @@ extern int select_p_job_resume(struct job_record *job_ptr)
 	return ESLURM_NOT_SUPPORTED;
 }
 
+extern int select_p_get_job_cores(uint32_t job_id, int alloc_index, int s)
+{
+	return ESLURM_NOT_SUPPORTED;
+}
+
 extern int select_p_job_ready(struct job_record *job_ptr)
 {
 #ifdef HAVE_BG_FILES
@@ -1049,7 +1118,14 @@ extern int select_p_get_extra_jobinfo (struct node_record *node_ptr,
                                        enum select_data_info info,
                                        void *data)
 {
-       return SLURM_SUCCESS;
+	if (info == SELECT_AVAIL_CPUS) {
+		/* Needed to track CPUs allocated to jobs on whole nodes
+		 * for sched/wiki2 (Moab scheduler). Small block allocations
+		 * handled through use of job_ptr->num_procs in slurmctld */
+		uint16_t *cpus_per_bp = (uint16_t *) data;
+		*cpus_per_bp = procs_per_node;
+	}
+	return SLURM_SUCCESS;
 }
 
 extern int select_p_get_info_from_plugin (enum select_data_info info, 
@@ -1091,15 +1167,32 @@ extern int select_p_update_node_state (int index, uint16_t state)
 extern int select_p_alter_node_cnt(enum select_node_cnt type, void *data)
 {
 	job_desc_msg_t *job_desc = (job_desc_msg_t *)data;
-	uint32_t *nodes = (uint32_t *)data;
-	int tmp, i;
+	uint32_t *nodes = (uint32_t *)data, tmp;
+	int i;
 	uint16_t req_geometry[BA_SYSTEM_DIMENSIONS];
 	
+	if(!bluegene_bp_node_cnt) {
+		fatal("select_g_alter_node_cnt: This can't be called "
+		      "before select_g_block_init");
+	}
+
 	switch (type) {
 	case SELECT_GET_NODE_SCALING:
 		if((*nodes) != INFINITE)
 			(*nodes) = bluegene_bp_node_cnt;
 		break;
+	case SELECT_SET_BP_CNT:
+		if(((*nodes) == INFINITE) || ((*nodes) == NO_VAL))
+			tmp = (*nodes);
+		else if((*nodes) > bluegene_bp_node_cnt) {
+			tmp = (*nodes);
+			tmp /= bluegene_bp_node_cnt;
+			if(tmp < 1) 
+				tmp = 1;
+		} else 
+			tmp = 1;
+		(*nodes) = tmp;
+		break;
 	case SELECT_APPLY_NODE_MIN_OFFSET:
 		if((*nodes) == 1) {
 			/* Job will actually get more than one c-node, 
@@ -1151,15 +1244,15 @@ extern int select_p_alter_node_cnt(enum select_node_cnt type, void *data)
 		/* See if min_nodes is greater than one base partition */
 		if(job_desc->min_nodes > bluegene_bp_node_cnt) {
 			/*
-			  if it is make sure it is a factor of 
-			  bluegene_bp_node_cnt, if it isn't make it 
-			  that way 
-			*/
+			 * if it is make sure it is a factor of 
+			 * bluegene_bp_node_cnt, if it isn't make it 
+			 * that way 
+			 */
 			tmp = job_desc->min_nodes % bluegene_bp_node_cnt;
 			if(tmp > 0)
 				job_desc->min_nodes += 
 					(bluegene_bp_node_cnt-tmp);
-		}
+		}				
 		tmp = job_desc->min_nodes / bluegene_bp_node_cnt;
 		
 		/* this means it is greater or equal to one bp */
@@ -1235,3 +1328,18 @@ extern int select_p_alter_node_cnt(enum select_node_cnt type, void *data)
 	
 	return SLURM_SUCCESS;
 }
+
+extern int select_p_reconfigure(void)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int select_p_step_begin(struct step_record *step_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int select_p_step_fini(struct step_record *step_ptr)
+{
+	return SLURM_SUCCESS;
+}
diff --git a/src/plugins/select/bluegene/plugin/sfree.c b/src/plugins/select/bluegene/plugin/sfree.c
index 98c41d2b06275116982c80b4a434377bdba9b464..0e49f57f109ac7bf19e2db68180ee851a4c8357e 100644
--- a/src/plugins/select/bluegene/plugin/sfree.c
+++ b/src/plugins/select/bluegene/plugin/sfree.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  sfree.c - free specified block or all blocks.
- *  $Id: sfree.c 12858 2007-12-19 20:15:32Z da $
+ *  $Id: sfree.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/select/bluegene/plugin/sfree.h b/src/plugins/select/bluegene/plugin/sfree.h
index 58dbfef0c8a9f131e8c3549e437d6363199d7659..f8bad5a1c81e46a27c938bb4ade9c1f4ca42a89e 100644
--- a/src/plugins/select/bluegene/plugin/sfree.h
+++ b/src/plugins/select/bluegene/plugin/sfree.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/select/bluegene/plugin/slurm_epilog.c b/src/plugins/select/bluegene/plugin/slurm_epilog.c
index 4e6115600b181fc6556152bfc5682b592aed55b7..a281e5e73c6bf0ce44dbad09f261fe7b4aa58e2b 100644
--- a/src/plugins/select/bluegene/plugin/slurm_epilog.c
+++ b/src/plugins/select/bluegene/plugin/slurm_epilog.c
@@ -3,12 +3,12 @@
  *      owned by this user. This is executed via SLURM to synchronize the 
  *      user's job execution with slurmctld configuration of partitions.
  *
- * $Id: slurm_epilog.c 10574 2006-12-15 23:38:29Z jette $
+ * $Id: slurm_epilog.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/select/bluegene/plugin/slurm_prolog.c b/src/plugins/select/bluegene/plugin/slurm_prolog.c
index 992bd885278c7be9b36d320c640ea8bc7c390b85..dbe8a93328074e7aa174110588617de0587e4e20 100644
--- a/src/plugins/select/bluegene/plugin/slurm_prolog.c
+++ b/src/plugins/select/bluegene/plugin/slurm_prolog.c
@@ -2,13 +2,11 @@
  *  slurm_ prolog.c - Wait until the specified partition is ready and owned by 
  *	this user. This is executed via SLURM to synchronize the user's job 
  *	execution with slurmctld configuration of partitions.
- *
- *  $Id: slurm_prolog.c 10574 2006-12-15 23:38:29Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -61,15 +59,15 @@
 
 /*
  * Check the bgblock's status every POLL_SLEEP seconds. 
- * Retry for a period of MIN_FREE_PERVIOUS_BLOCK_DELAY + MIN_DELAY + 
- * (INCR_DELAY * POLL_SLEEP * base partition count).
- * For example if MIN_DELAY=300 and INCR_DELAY=20 and POLL_SLEEP=3, 
- * wait up to 1260 seconds.
- * For a 16 base partition bgblock to be ready (300 + (20 * 3 * 16).
+ * Retry for a period of 
+ * MIN_FREE_PERVIOUS_BLOCK_DELAY + MIN_DELAY + (INCR_DELAY * base partition count)
+ * For example if MIN_FREE_PERVIOUS_BLOCK_DELAY=300 and MIN_DELAY=600 and 
+ * INCR_DELAY=20 and job_size=4 base partitions then wait up to 980 seconds
+ * 300 + 600 + (20 * 4)
  */ 
 #define POLL_SLEEP 3			/* retry interval in seconds  */
 #define MIN_FREE_PERVIOUS_BLOCK_DELAY 300 /* time in seconds */
-#define MIN_DELAY  300			/* time in seconds */
+#define MIN_DELAY  600			/* time in seconds */
 #define INCR_DELAY 20			/* time in seconds per BP */
 
 int max_delay = MIN_DELAY + MIN_FREE_PERVIOUS_BLOCK_DELAY;
@@ -115,7 +113,7 @@ static int _wait_part_ready(uint32_t job_id)
 {
 	int is_ready = 0, i, rc;
 	
-	max_delay = MIN_DELAY + MIN_FREE_PERVIOUS_BLOCK_DELAY +
+	max_delay = MIN_FREE_PERVIOUS_BLOCK_DELAY + MIN_DELAY +
 		(INCR_DELAY * _get_job_size(job_id));
 
 #if _DEBUG
diff --git a/src/plugins/select/bluegene/plugin/state_test.c b/src/plugins/select/bluegene/plugin/state_test.c
index bb8a497af1be4601b384565d58dd6d2e38b180ba..ac651efa07c30ff503b3be7aea30964b3d78f2c8 100644
--- a/src/plugins/select/bluegene/plugin/state_test.c
+++ b/src/plugins/select/bluegene/plugin/state_test.c
@@ -2,7 +2,7 @@
  *  state_test.c - Test state of Bluegene base partitions and switches. 
  *  DRAIN nodes in SLURM that are not usable. 
  *
- *  $Id: state_test.c 11400 2007-04-24 18:50:38Z da $
+ *  $Id: state_test.c 12928 2007-12-28 21:59:29Z da $
  *****************************************************************************
  *  Copyright (C) 2004-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -309,6 +309,7 @@ extern bool node_already_down(char *node_name)
 {
 	uint16_t base_state;
 	struct node_record *node_ptr = find_node_record(node_name);
+	
 	if (node_ptr) {
 		base_state = node_ptr->node_state & 
 			(~NODE_STATE_NO_RESPOND);
diff --git a/src/plugins/select/cons_res/Makefile.am b/src/plugins/select/cons_res/Makefile.am
index cb6bd89e26c849ebf21d1b9c1c095aa8a9dc3b45..fc88fa6fe049d43ca91df6b57d25739de492f960 100644
--- a/src/plugins/select/cons_res/Makefile.am
+++ b/src/plugins/select/cons_res/Makefile.am
@@ -12,4 +12,3 @@ pkglib_LTLIBRARIES = select_cons_res.la
 select_cons_res_la_SOURCES =  select_cons_res.c select_cons_res.h \
                               dist_tasks.c dist_tasks.h
 select_cons_res_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-select_cons_res_la_LIBADD  = $(top_builddir)/src/common/libcommon.la
diff --git a/src/plugins/select/cons_res/Makefile.in b/src/plugins/select/cons_res/Makefile.in
index 29b88930103e17d65a63834a42d1c66c0b3643d3..4e1ec9662899827be32acff3cafc50ee22725a85 100644
--- a/src/plugins/select/cons_res/Makefile.in
+++ b/src/plugins/select/cons_res/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,14 +75,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-select_cons_res_la_DEPENDENCIES =  \
-	$(top_builddir)/src/common/libcommon.la
+select_cons_res_la_LIBADD =
 am_select_cons_res_la_OBJECTS = select_cons_res.lo dist_tasks.lo
 select_cons_res_la_OBJECTS = $(am_select_cons_res_la_OBJECTS)
 select_cons_res_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(select_cons_res_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -120,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -263,7 +275,6 @@ select_cons_res_la_SOURCES = select_cons_res.c select_cons_res.h \
                               dist_tasks.c dist_tasks.h
 
 select_cons_res_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-select_cons_res_la_LIBADD = $(top_builddir)/src/common/libcommon.la
 all: all-am
 
 .SUFFIXES:
@@ -303,8 +314,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -312,8 +323,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -368,8 +379,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -381,8 +392,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -392,13 +403,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/select/cons_res/dist_tasks.c b/src/plugins/select/cons_res/dist_tasks.c
index 1f6e1f4036d4c6a3c1682d64bfa0c3425a37a884..1a9dc8492dfc0d72a423832795501a8c1c4d3086 100644
--- a/src/plugins/select/cons_res/dist_tasks.c
+++ b/src/plugins/select/cons_res/dist_tasks.c
@@ -6,7 +6,7 @@
  ***************************************************************************** 
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,121 +56,24 @@
  * CPUs/Logical processors resources we keep the initial set of
  * resources.
  *
- * IN job_ptr - pointer to job being scheduled
+ * IN/OUT job_ptr - pointer to job being scheduled. The per-node
+ *                  job->alloc_cpus array is computed here.
+ *
  */
-int compute_c_b_task_dist(struct select_cr_job *job, 	    
-			  const select_type_plugin_info_t cr_type,
-			  const uint16_t fast_schedule)
+int compute_c_b_task_dist(struct select_cr_job *job)
 {
 	int i, j, rc = SLURM_SUCCESS;
-	uint16_t avail_cpus = 0, cpus, sockets, cores, threads;
 	bool over_subscribe = false;
 	uint32_t taskid = 0, last_taskid, maxtasks = job->nprocs;
 
 	for (j = 0; (taskid < maxtasks); j++) {	/* cycle counter */
 		bool space_remaining = false;
 		last_taskid = taskid;
-		for (i = 0; 
-		     ((i < job->nhosts) && (taskid < maxtasks)); i++) {
-			struct node_cr_record *this_node;
-			this_node = find_cr_node_record (job->host[i]);
-			if (this_node == NULL) {
-				error(" cons_res: could not find node %s",
-				      job->host[i]);
-				return SLURM_ERROR;
-			}
-
-			switch(cr_type) {
-			case CR_MEMORY:
-				if (fast_schedule) {
-					avail_cpus = this_node->node_ptr->config_ptr->cpus;
-				} else {
-					avail_cpus = this_node->node_ptr->cpus;
-				}
-			case CR_CPU:
-			case CR_CPU_MEMORY:
-				if (fast_schedule) {
-					avail_cpus = this_node->node_ptr->config_ptr->cpus;
-				} else {
-					avail_cpus = this_node->node_ptr->cpus;
-				}
-				avail_cpus -= this_node->alloc_lps;
-				avail_cpus = MIN(job->cpus[i], avail_cpus);
-				break;
-			case CR_SOCKET:
-			case CR_SOCKET_MEMORY:
-			{
-				uint16_t alloc_sockets = 0;
-				uint16_t alloc_lps     = 0;
-				get_resources_this_node(&cpus, &sockets, 
-							&cores, &threads, 
-							this_node, &alloc_sockets, 
-							&alloc_lps, &job->job_id);
-				
-				avail_cpus = slurm_get_avail_procs(job->max_sockets, 
-								   job->max_cores, 
-								   job->max_threads,
-								   job->min_sockets,
-								   job->min_cores, 
-								   job->cpus_per_task, 
-								   job->ntasks_per_node, 
-								   job->ntasks_per_socket, 
-								   job->ntasks_per_core, 
-								   &cpus,
-								   &sockets,
-								   &cores,
-								   &threads,
-								   alloc_sockets,
-								   this_node->alloc_cores,
-								   alloc_lps,
-								   cr_type,
-								   job->job_id,
-								   this_node->node_ptr->name);
-				break;
-			}
-			case CR_CORE:
-			case CR_CORE_MEMORY:
-			{
-				uint16_t alloc_sockets = 0;
-				uint16_t alloc_lps     = 0;
-				get_resources_this_node(&cpus, &sockets, 
-							&cores, &threads, 
-							this_node, &alloc_sockets,
-							&alloc_lps, &job->job_id);
-				
-				avail_cpus = slurm_get_avail_procs(job->max_sockets, 
-								   job->max_cores, 
-								   job->max_threads, 
-								   job->min_sockets,
-								   job->min_cores,
-								   job->cpus_per_task,
-								   job->ntasks_per_node,
-								   job->ntasks_per_socket,
-								   job->ntasks_per_core, 
-								   &cpus,
-								   &sockets,
-								   &cores,
-								   &threads,
-								   alloc_sockets,
-								   this_node->alloc_cores,
-								   alloc_lps,
-								   cr_type,
-								   job->job_id,
-								   this_node->node_ptr->name);
-				break;
-			}
-			default:
-				/* We should never get in here. If we
-                                   do it is a bug */
-				error (" cr_type not recognized ");
-				return SLURM_ERROR;
-				break;
-			}
-			avail_cpus = MIN(avail_cpus, job->cpus[i]);
-			if ((j < avail_cpus) || over_subscribe) {
+		for (i = 0; ((i < job->nhosts) && (taskid < maxtasks)); i++) {
+			if ((j < job->cpus[i]) || over_subscribe) {
 				taskid++;
-				job->alloc_lps[i]++;
-				if ((j + 1) < avail_cpus)
+				job->alloc_cpus[i]++;
+				if ((j + 1) < job->cpus[i])
 					space_remaining = true;
 			}
 		}
@@ -178,250 +81,282 @@ int compute_c_b_task_dist(struct select_cr_job *job,
 			over_subscribe = true;
 		if (last_taskid == taskid) {
 			/* avoid infinite loop */
-			fatal("compute_c_b_task_dist failure");
+			error("compute_c_b_task_dist failure");
+			rc = SLURM_ERROR;
+			break;
 		}
 	}
 
 #if (CR_DEBUG)	
 	for (i = 0; i < job->nhosts; i++) {
-		info("cons_res _c_b_task_dist %u host %s nprocs %u maxtasks %u cpus %u alloc_lps %u", 
-		     job->job_id, job->host[i], job->nprocs, 
-		     maxtasks, job->cpus[i], job->alloc_lps[i]);
+		info("cons_res _c_b_task_dist %u host_index %d nprocs %u "
+		     "maxtasks %u cpus %u alloc_cpus %u", 
+		     job->job_id, i, job->nprocs, 
+		     maxtasks, job->cpus[i], job->alloc_cpus[i]);
 	}
 #endif	
 
 	return rc;
 }
 
+/* scan all rows looking for the best fit, and return the offset */
+static int _find_offset(struct select_cr_job *job, const int job_index,
+			uint16_t cores, uint16_t sockets, uint32_t maxcores,
+			const select_type_plugin_info_t cr_type,
+			struct node_cr_record *this_cr_node)
+{
+	struct part_cr_record *p_ptr;
+	int i, j, index, offset, skip;
+	uint16_t acores, asockets, freecpus, last_freecpus = 0;
+	struct multi_core_data *mc_ptr;
+
+	p_ptr = get_cr_part_ptr(this_cr_node, job->job_ptr->part_ptr);
+	if (p_ptr == NULL)
+		abort();
+	mc_ptr = job->job_ptr->details->mc_ptr;
+
+	index = -1;
+	for (i = 0; i < p_ptr->num_rows; i++) {
+		acores = 0;
+		asockets = 0;
+		skip = 0;
+		offset = i * this_cr_node->sockets;
+		for (j = 0; j < this_cr_node->sockets; j++) {
+			if ((cores - p_ptr->alloc_cores[offset+j]) <
+							mc_ptr->min_cores) {
+				/* count the number of unusable sockets */
+				skip++;
+				acores += cores;
+			} else { 
+				acores += p_ptr->alloc_cores[offset+j];
+			}
+			if (p_ptr->alloc_cores[offset+j])
+				asockets++;
+		}
+		/* make sure we have the required number of usable sockets */
+		if (skip && ((sockets - skip) < mc_ptr->min_sockets))
+			continue;
+		/* CR_SOCKET needs UNALLOCATED sockets */
+		if ((cr_type == CR_SOCKET) || (cr_type == CR_SOCKET_MEMORY)) {
+			if (sockets - asockets < mc_ptr->min_sockets)
+				continue;
+		}
+
+		freecpus = (cores * sockets) - acores;
+		if (freecpus < maxcores)
+			continue;
+
+		if (index < 0) {
+			index = i;
+			last_freecpus = freecpus;
+		}
+		if (freecpus < last_freecpus) {
+			index = i;
+			last_freecpus = freecpus;
+		}
+	}
+	if (index < 0) {
+		/* This may happen if a node has fewer nodes than
+		 * configured and FastSchedule=2 */
+		error("job_assign_task: failure in computing offset");
+		index = 0;
+	}
+
+	return index * this_cr_node->sockets;
+}
+
 /*  _job_assign_tasks: Assign tasks to hardware for block and cyclic
  *  distributions */
-void _job_assign_tasks(struct select_cr_job *job, 
-		       struct node_cr_record *this_cr_node,
-		       const uint16_t usable_threads, 
-		       const uint16_t usable_cores, 
-		       const uint16_t usable_sockets,
-		       const int job_index, 
-		       const uint32_t maxtasks,
-		       const select_type_plugin_info_t cr_type) 
+static int _job_assign_tasks(struct select_cr_job *job, 
+			struct node_cr_record *this_cr_node,
+			const int job_index, 
+			const select_type_plugin_info_t cr_type,
+			const int cyclic) 
 {
-	int i, j;
-	uint16_t nsockets = this_cr_node->node_ptr->sockets;
-	uint16_t acores, avail_cores[nsockets];
-	uint16_t asockets, avail_sockets[nsockets];
-	uint32_t taskcount = 0, last_taskcount;
-	uint16_t ncores = 0, total = 0;
-
-	debug3("job_assign_task %u s_ m %u u %u c_ u %u min %u"
-	       " t_ u %u min %u task %u ", 
-	       job->job_id, job->min_sockets, usable_sockets, 
-	       job->min_cores, usable_cores, job->min_threads, 
-	       usable_threads, maxtasks);
+	int i, j, rc = SLURM_SUCCESS;
+	uint16_t cores, cpus, sockets, threads;
+	uint16_t usable_cores, usable_sockets, usable_threads;
+	uint16_t *avail_cores = NULL;
+	uint32_t corecount, last_corecount;
+	uint16_t asockets, offset, total;
+	uint32_t maxcores, reqcores, maxtasks = job->alloc_cpus[job_index];
+	struct part_cr_record *p_ptr;
+	struct multi_core_data *mc_ptr;
+	
+	p_ptr = get_cr_part_ptr(this_cr_node, job->job_ptr->part_ptr);
+	if (p_ptr == NULL)
+		return SLURM_ERROR;
 
-	for (i=0; i < nsockets; i++) {
-		avail_cores[i]   = 0;
-		avail_sockets[i] = 0;
+	if ((job->job_ptr == NULL) || (job->job_ptr->details == NULL)) {
+		/* This should never happen */
+		error("cons_res: job %u has no details", job->job_id);
+		return SLURM_ERROR;
+	}
+	if (!job->job_ptr->details->mc_ptr)
+		job->job_ptr->details->mc_ptr = create_default_mc();
+	mc_ptr = job->job_ptr->details->mc_ptr;
+
+	/* get hardware info for this node */	
+	get_resources_this_node(&cpus,  &sockets, &cores, &threads, 
+				this_cr_node, job->job_id);
+
+	/* compute any job limits */	
+	usable_sockets = MIN(mc_ptr->max_sockets, sockets);
+	usable_cores   = MIN(mc_ptr->max_cores,   cores);
+	usable_threads = MIN(mc_ptr->max_threads, threads);
+
+	/* determine the number of required cores. When multiple threads
+	 * are available, the maxtasks value may not reflect the requested
+	 * core count, which is what we are seeking here. */
+	if (job->job_ptr->details->overcommit) {
+		maxcores = 1;
+		reqcores = 1;
+	} else {
+		maxcores = maxtasks / usable_threads;
+		while ((maxcores * usable_threads) < maxtasks)
+			maxcores++;
+		reqcores = mc_ptr->min_cores * mc_ptr->min_sockets;
+		if (maxcores < reqcores)
+			maxcores = reqcores;
 	}
 
+	offset = _find_offset(job, job_index, cores, sockets, maxcores, cr_type,
+			      this_cr_node);
+	job->node_offset[job_index] = offset;
+
+	debug3("job_assign_task %u s_ min %u u %u c_ min %u u %u"
+	       " t_ min %u u %u task %u core %u offset %u", 
+	       job->job_id, mc_ptr->min_sockets, usable_sockets, 
+	       mc_ptr->min_cores, usable_cores, mc_ptr->min_threads, 
+	       usable_threads, maxtasks, maxcores, offset);
+
+	avail_cores = xmalloc(sizeof(uint16_t) * sockets);
+	/* initialized to zero by xmalloc */
+
 	total = 0;
 	asockets = 0;
-	for (i=0; i<nsockets; i++) {
-		if ((total >= maxtasks) && (asockets >= job->min_sockets)) {
+	for (i = 0; i < sockets; i++) {
+		if ((total >= maxcores) && (asockets >= mc_ptr->min_sockets)) {
 			break;
 		}
-		if (this_cr_node->node_ptr->cores <=
-		    this_cr_node->alloc_cores[i]) {
+		if (this_cr_node->cores <= p_ptr->alloc_cores[offset+i]) {
 			continue;
 		}
-		acores = this_cr_node->node_ptr->cores - 
-			this_cr_node->alloc_cores[i];
-		if (usable_cores <= acores) {
-			ncores = usable_cores;
-		} else if (job->min_cores <= acores) {
-			ncores = job->min_cores;
-		} else {
-			ncores = 0;
+		/* for CR_SOCKET, we only want to allocate empty sockets */
+		if ((cr_type == CR_SOCKET || cr_type == CR_SOCKET_MEMORY) &&
+		    (p_ptr->alloc_cores[offset+i] > 0))
+			continue;
+		avail_cores[i] = this_cr_node->cores - 
+				 p_ptr->alloc_cores[offset+i];
+		if (usable_cores <= avail_cores[i]) {
+			avail_cores[i] = usable_cores;
+		} else if (mc_ptr->min_cores > avail_cores[i]) {
+			avail_cores[i] = 0;
 		}
-		if (ncores > 0) {
-			avail_cores[i]   = ncores;
-			avail_sockets[i] = 1;
-			total += ncores*usable_threads;
+		if (avail_cores[i] > 0) {
+			total += avail_cores[i];
 			asockets++;
 		}
 	}
 	
+#if(CR_DEBUG)
+    	for (i = 0; i < sockets; i+=2) {
+		info("cons_res: assign_task: avail_cores[%d]=%u, [%d]=%u", i,
+		     avail_cores[i], i+1, avail_cores[i+1]);
+	}
+#endif
 	if (asockets == 0) {
 		/* Should never get here but just in case */
 		error("cons_res: %u Zero sockets satisfy"
 		      " request -B %u:%u: Using alternative strategy",
-		      job->job_id, job->min_sockets, job->min_cores);
-		for (i=0; i < nsockets; i++) {
-			if (this_cr_node->node_ptr->cores <=
-			    this_cr_node->alloc_cores[i])
+		      job->job_id, mc_ptr->min_sockets, mc_ptr->min_cores);
+		for (i = 0; i < sockets; i++) {
+			if (this_cr_node->cores <= p_ptr->alloc_cores[offset+i])
 				continue;
-			acores = this_cr_node->node_ptr->cores - 
-				this_cr_node->alloc_cores[i];
-			avail_cores[i]   = acores;
-			avail_sockets[i] = 1;
+			avail_cores[i] = this_cr_node->cores - 
+				p_ptr->alloc_cores[offset+i];
 		}
 	}
 	
-	if (asockets < job->min_sockets) {
-		error("cons_res: %u maxtasks %u Cannot satisfy"
+	if (asockets < mc_ptr->min_sockets) {
+		error("cons_res: %u maxcores %u Cannot satisfy"
 		      " request -B %u:%u: Using -B %u:%u",
-		      job->job_id, maxtasks, job->min_sockets, 
-		      job->min_cores, asockets, job->min_cores);
+		      job->job_id, maxcores, mc_ptr->min_sockets, 
+		      mc_ptr->min_cores, asockets, mc_ptr->min_cores);
 	}
 
-	for (i=0; taskcount<maxtasks; i++) {
-		last_taskcount = taskcount;
-		for (j=0; ((j<nsockets) && (taskcount<maxtasks)); j++) {
-			asockets = avail_sockets[j];
-			if (asockets == 0)
-				continue;
+	corecount = 0;
+	if (cyclic) {
+		/* distribute tasks cyclically across the sockets */
+		for (i=1; corecount<maxcores; i++) {
+			last_corecount = corecount;
+			for (j=0; ((j<sockets) && (corecount<maxcores)); j++) {
+				if (avail_cores[j] == 0)
+					continue;
+				if (i<=avail_cores[j]) {
+					job->alloc_cores[job_index][j]++;
+					corecount++;
+				}
+			}
+			if (last_corecount == corecount) {
+				/* Avoid possible infinite loop on error */
+				error("_job_assign_tasks failure");
+				rc = SLURM_ERROR;
+				goto fini;
+			}
+		}
+	} else {
+		/* distribute tasks in blocks across the sockets */
+		for (j=0; ((j<sockets) && (corecount<maxcores)); j++) {
+			last_corecount = corecount;
 			if (avail_cores[j] == 0)
 				continue;
-			if (i == 0)
-				job->alloc_sockets[job_index]++;
-			if (i<avail_cores[j])
+			for (i = 0; (i < avail_cores[j]) && 
+				    (corecount<maxcores); i++) {
 				job->alloc_cores[job_index][j]++;
-			taskcount++;
-		}
-		if (last_taskcount == taskcount) {
-			/* Avoid possible infinite loop on error */
-			fatal("_job_assign_tasks failure");
+				corecount++;
+			}
+			if (last_corecount == corecount) {
+				/* Avoid possible infinite loop on error */
+				error("_job_assign_tasks failure");
+				rc = SLURM_ERROR;
+				goto fini;
+			}
 		}
 	}
+ fini:	xfree(avail_cores);
+	return rc;
 }
 
-/*  _job_assign_tasks: Assign tasks to hardware for block and cyclic
- *  distributions */
-void _job_assign_tasks_plane(struct select_cr_job *job, 
-			     struct node_cr_record *this_cr_node,
-			     const uint16_t usable_threads, 
-			     const uint16_t usable_cores, 
-			     const uint16_t usable_sockets,
-			     const int job_index, 
-			     const uint32_t maxtasks,
-			     const uint16_t plane_size,
-			     const select_type_plugin_info_t cr_type) 
+static uint16_t _get_cpu_offset(struct select_cr_job *job, int index,
+				struct node_cr_record *this_node)
 {
-	int s, l, m, i, j;
-	uint16_t nsockets = this_cr_node->node_ptr->sockets;
-	uint16_t avail_cores[nsockets];
-	uint16_t avail_sockets[nsockets];
-	uint32_t taskcount, last_taskcount;
-	uint16_t total, ncores, acores, isocket;
-	uint16_t core_index, thread_index, ucores;
-	uint16_t max_plane_size = 0;
-	int last_socket_index = -1;
-
-	debug3("job_assign_task %u _plane_ s_ m %u u %u c_ u %u"
-	       " min %u t_ u %u min %u task %u", 
-	       job->job_id, job->min_sockets, usable_sockets, 
-	       job->min_cores, usable_cores, job->min_threads, 
-	       usable_threads, maxtasks);
-	
-	for (i=0; i < nsockets; i++) {
-		avail_cores[i]   = 0;
-		avail_sockets[i] = 0;
-	}
-	
-	total = 0;
-	isocket = 0;
-	for (i=0; i<nsockets; i++) {
-		if ((total >= maxtasks) && (isocket >= job->min_sockets)) {
-			break;
-		}
-		/* sockets with the required available core count */
-		if (this_cr_node->node_ptr->cores <=
-		    this_cr_node->alloc_cores[i]) {
-			continue;
-		}
-		acores = this_cr_node->node_ptr->cores - 
-			this_cr_node->alloc_cores[i];
-		if (plane_size <= acores) {
-			ncores = plane_size;
-		} else if (usable_cores <= acores) {
-			ncores = usable_cores;
-		} else if (job->min_cores <= acores) {
-			ncores = job->min_cores;
-		} else {
-			ncores = 0;
-		}
-		if (ncores > 0) {
-			avail_cores[i]   = ncores;
-			avail_sockets[i] = 1;
-			total += ncores*usable_threads;
-			isocket++;
-		}
-	}
-	
-	if (isocket == 0) {
-		/* Should never get here but just in case */
-		error("cons_res: %u Zero sockets satisfy request"
-		      " -B %u:%u: Using alternative strategy",
-		      job->job_id, job->min_sockets, job->min_cores);
-		for (i=0; i < nsockets; i++) {
-			if (this_cr_node->node_ptr->cores <=
-			    this_cr_node->alloc_cores[i])
-				continue;
-			acores = this_cr_node->node_ptr->cores - 
-				this_cr_node->alloc_cores[i];
-			avail_cores[i]   = acores;
-			avail_sockets[i] = 1;
-		}
-	}
-	
-	if (isocket < job->min_sockets)
-		error("cons_res: %u maxtasks %d Cannot satisfy"
-		      " request -B %u:%u: Using -B %u:%u",
-		      job->job_id, maxtasks, job->min_sockets, 
-		      job->min_cores, isocket, job->min_cores);
-	
-	last_socket_index = -1;
-	taskcount = 0;
-	for (j=0; taskcount<maxtasks; j++) {
-		last_taskcount = taskcount;
-		for (s=0; ((s<nsockets) && (taskcount<maxtasks)); 
-		     s++) {
-			if (avail_sockets[s] == 0)
-				continue;
-			ucores = avail_cores[s];
-			max_plane_size = 
-				(plane_size > ucores) 
-				? plane_size : ucores;
-			for (m=0; ((m<max_plane_size) 
-				   && (taskcount<maxtasks)); 
-			     m++) {
-				core_index = m%ucores;
-				if(m > ucores) 
-					continue;
-				for(l=0; ((l<usable_threads) 
-					  && (taskcount<maxtasks)); 
-				    l++) {
-					thread_index =
-						l%usable_threads;
-					if(thread_index > usable_threads)
-						continue;
-					if (last_socket_index != s) {
-						job->alloc_sockets [job_index]++;
-						last_socket_index = s;
-					}
-					if ((l == 0) && (m < ucores)) {
-						if (job->alloc_cores[job_index][s] 
-						    < this_cr_node->node_ptr->cores) {
-							job->alloc_cores[job_index][s]++;
-						}
-					}
-					taskcount++;
-				}
+	int i, set = 0;
+	uint16_t cpus, sockets, cores, threads, besto = 0, offset = 0;
+	struct part_cr_record *p_ptr;
+
+	p_ptr = get_cr_part_ptr(this_node, job->job_ptr->part_ptr);
+	if ((p_ptr == NULL) || (p_ptr->num_rows < 2))
+		return offset;
+
+	get_resources_this_node(&cpus, &sockets, &cores, &threads,
+	        		this_node, job->job_id);
+	/* scan all rows looking for the best row for job->alloc_cpus[index] */
+	for (i = 0; i < p_ptr->num_rows; i++) {
+		if ((cpus - p_ptr->alloc_cores[offset]) >=
+						job->alloc_cpus[index]) {
+			if (!set) {
+				set = 1;
+				besto = offset;
+			}
+			if (p_ptr->alloc_cores[offset] >
+						p_ptr->alloc_cores[besto]) {
+				besto = offset;
 			}
 		}
-		if (last_taskcount == taskcount) {
-			/* avoid possible infinite loop on error */
-			fatal("job_assign_task failure");
-		}
+		offset += this_node->sockets;
 	}
+	return besto;
 }
 
 /* To effectively deal with heterogeneous nodes, we fake a cyclic
@@ -445,178 +380,69 @@ void _job_assign_tasks_plane(struct select_cr_job *job,
  * In the consumable resources environment we need to determine the
  * layout schema within slurmctld.
 */
-int cr_dist(struct select_cr_job *job, int cyclic,
-	    const select_type_plugin_info_t cr_type,
-	    const uint16_t fast_schedule)
+extern int cr_dist(struct select_cr_job *job, int cyclic,
+		   const select_type_plugin_info_t cr_type)
 {
-#if(CR_DEBUG)
-    	int i;
-#endif
-	int j, rc = SLURM_SUCCESS; 
+	int i, cr_cpu = 0, rc = SLURM_SUCCESS; 
 	uint32_t taskcount = 0;
-	uint32_t maxtasks  = job->nprocs;
 	int host_index;
-	uint16_t usable_cpus = 0;
-	uint16_t usable_sockets = 0, usable_cores = 0, usable_threads = 0;
-	int last_socket_index = -1;
-	int last_core_index = -1;
 	int job_index = -1;
 
-	int error_code = compute_c_b_task_dist(job, cr_type, fast_schedule);
+	int error_code = compute_c_b_task_dist(job);
 	if (error_code != SLURM_SUCCESS) {
 		error(" Error in compute_c_b_task_dist");
 		return error_code;
 	}
 
-	if ((cr_type == CR_CPU) 
-	    || (cr_type == CR_MEMORY) 
-	    || (cr_type == CR_CPU_MEMORY)) 
-		return SLURM_SUCCESS;
+	if ((cr_type == CR_CPU) || (cr_type == CR_MEMORY) ||
+	    (cr_type == CR_CPU_MEMORY)) 
+		cr_cpu = 1;
 
 	for (host_index = 0; 
 	     ((host_index < node_record_count) && (taskcount < job->nprocs));
 	     host_index++) {
 		struct node_cr_record *this_cr_node;
-		uint16_t alloc_sockets = 0;
-		uint16_t alloc_lps     = 0;
-		uint16_t avail_cpus    = 0;
+
 		if (bit_test(job->node_bitmap, host_index) == 0)
 			continue;
 		job_index++;
 		
-		this_cr_node = find_cr_node_record(
-			node_record_table_ptr[host_index].name);
-		if (this_cr_node == NULL) {
-			error(" cons_res: could not find node %s", 
-			      node_record_table_ptr[host_index].name);
+		if (select_node_ptr == NULL) {
+			error("cons_res: select_node_ptr is NULL");
 			return SLURM_ERROR;
 		}
-
-		get_resources_this_node(&usable_cpus,  &usable_sockets, 
-					&usable_cores, &usable_threads, 
-					this_cr_node,  &alloc_sockets, 
-					&alloc_lps, &job->job_id);
+		this_cr_node = &select_node_ptr[host_index];
 		
-		avail_cpus = slurm_get_avail_procs(job->max_sockets,
-						   job->max_cores,
-						   job->max_threads,
-						   job->min_sockets,
-						   job->min_cores,
-						   job->cpus_per_task,
-						   job->ntasks_per_node,
-						   job->ntasks_per_socket,
-						   job->ntasks_per_core,
-						   &usable_cpus,
-						   &usable_sockets,
-						   &usable_cores,
-						   &usable_threads,
-						   alloc_sockets,
-						   this_cr_node->alloc_cores,
-						   alloc_lps,
-						   cr_type,
-						   job->job_id,
-						   this_cr_node->node_ptr->name);
-		avail_cpus = MIN(avail_cpus, job->cpus[job_index]);
-
-#if(CR_DEBUG)
-		info("cons_res: _cr_dist %u avail_s %u _c %u _t %u"
-		     " alloc_s %d lps %u",
-		     job->job_id, usable_sockets, usable_cores, 
-		     usable_threads,
-		     alloc_sockets, alloc_lps);
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY))
-			for(i=0; i<usable_sockets;i++)
-				info("cons_res: _cr_dist alloc_cores %d = %u", 
-				     i, this_cr_node->alloc_cores[i]);
-#endif		
-		
-		if (avail_cpus == 0) {
-			error(" cons_res: %d no available cpus on node %s "
-			      " s %u c %u t %u", 
-			      job->job_id, node_record_table_ptr[host_index].name,
-			      usable_sockets, usable_cores, usable_threads);
+		if (job->cpus[job_index] == 0) {
+			error("cons_res: %d no available cpus on node %s ",
+			      job->job_id,
+			      node_record_table_ptr[host_index].name);
+			continue;
 		}
-		
-		maxtasks = job->alloc_lps[job_index];
-		job->alloc_sockets[job_index] = 0;
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			for (j = 0; 
-			     j < job->num_sockets[job_index]; 
-			     j++)
-				job->alloc_cores[job_index][j] = 0;
-		}		
-		
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			_job_assign_tasks(job, this_cr_node, 
-					  usable_threads, usable_cores, 
-					  usable_sockets, job_index, 
-					  maxtasks, cr_type);
-		} else if (cyclic == 0) { /* block lllp distribution */
-			/* CR _SOCKET or CR_SOCKET_MEMORY */
-			int s, c, t;
-			last_socket_index = -1;	
-			taskcount = 0;
-			for (s=0; 
-			     s < usable_sockets; 
-			     s++) {
-				last_core_index = -1;	
-				if (maxtasks <= taskcount)
-					continue;
-				for (c=0; 
-				     c < usable_cores; 
-				     c++) {
-					if (maxtasks <= taskcount)
-						continue;
-					for (t=0; 
-					     t < usable_threads; t++) {
-						if (maxtasks <= taskcount) 
-							continue;
-						if (last_socket_index != s) {
-							job->alloc_sockets[job_index]++;
-							last_socket_index = s;
-						}
-						taskcount++;
-					}
-				}
-			}
-		} else if (cyclic == 1) { /* cyclic lllp distribution */
-			/* CR_SOCKET or CR_SOCKET_MEMORY */
-			int s, c, t;
-			int last_socket_index = 0;
-			taskcount = 0;
-			for (t=0; 
-			     t < usable_threads; t++) {
-				if (maxtasks <= taskcount)
-					continue;
-				for (c=0; 
-				     c < usable_cores; c++) {
-					if (maxtasks <= taskcount)
-						continue;
-					for (s=0;
-					     s < usable_sockets; s++) {
-						if (maxtasks <= taskcount)
-							continue;
-						if (last_socket_index == 0) {
-							job->alloc_sockets[job_index]++;
-							if(s == (usable_sockets-1))
-								last_socket_index = 1;
-						}
-						taskcount++;
-					}
-				}
-			}
+
+		if (cr_cpu) {
+			/* compute the offset */
+			job->node_offset[job_index] =
+				_get_cpu_offset(job, job_index, this_cr_node);
+		} else {
+			for (i = 0; i < job->num_sockets[job_index]; i++)
+				job->alloc_cores[job_index][i] = 0;
+
+			if (_job_assign_tasks(job, this_cr_node, job_index, 
+					      cr_type, cyclic) != SLURM_SUCCESS)
+				return SLURM_ERROR;
 		}
-		
 #if(CR_DEBUG)
-		info("cons_res _cr_dist %u host %d %s alloc_ "
-		     "sockets %u lps %u", 
-		     job->job_id, host_index,  this_cr_node->node_ptr->name, 
-		     job->alloc_sockets[job_index], job->alloc_lps[job_index]);
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY))
-			for(i=0; i<usable_sockets;i++)
-				info("cons_res: _cr_dist: %u alloc_cores[%d][%d] = %u", 
-				     job->job_id, i, job_index, 
-				     job->alloc_cores[job_index][i]);
+		info("cons_res _cr_dist %u host %d %s alloc_cpus %u", 
+		     job->job_id, host_index, this_cr_node->node_ptr->name, 
+		     job->alloc_cpus[job_index]);
+		for(i=0; !cr_cpu && i<job->num_sockets[job_index];i+=2) {
+			info("cons_res: _cr_dist: %u " 
+			     "alloc_cores[%d][%d]=%u, [%d][%d]=%u", 
+			     job->job_id, 
+			     job_index, i, job->alloc_cores[job_index][i], 
+			     job_index, i+1, job->alloc_cores[job_index][i+1]);
+		}
 #endif
 	}
 	return rc;
@@ -627,38 +453,59 @@ int cr_dist(struct select_cr_job *job, int cyclic,
  * case we do not need to compute the number of tasks on each nodes
  * since it should be set to the number of cpus.
  */
-int cr_exclusive_dist(struct select_cr_job *job,
-		      const select_type_plugin_info_t cr_type)
+extern int cr_exclusive_dist(struct select_cr_job *job,
+		 	     const select_type_plugin_info_t cr_type)
 {
 	int i, j;
-	int host_index = 0;
+	int host_index = 0, get_cores = 0;
 
-	for (i = 0; i < node_record_count; i++) {
-		if (bit_test(job->node_bitmap, i) == 0)
-			continue;
-		job->alloc_lps[host_index] = node_record_table_ptr[i].cpus;
-		job->alloc_sockets[host_index] = 
-			node_record_table_ptr[i].sockets; 
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			for (j = 0; j < node_record_table_ptr[i].sockets; j++)
-				job->alloc_cores[host_index][j] = 
-					node_record_table_ptr[i].cores; 
+	if ((cr_type == CR_CORE)   || (cr_type == CR_CORE_MEMORY) ||
+	    (cr_type == CR_SOCKET) || (cr_type == CR_SOCKET_MEMORY))
+		get_cores = 1;
+
+	if (select_fast_schedule) {
+		struct config_record *config_ptr;
+		for (i = 0; i < node_record_count; i++) {
+			if (bit_test(job->node_bitmap, i) == 0)
+				continue;
+			config_ptr = node_record_table_ptr[i].config_ptr;
+			job->alloc_cpus[host_index] = config_ptr->cpus;
+			if (get_cores) {
+				for (j=0; j<config_ptr->sockets; 
+				     j++) {
+					job->alloc_cores[host_index][j] = 
+						config_ptr->cores;
+				}
+			}
+			host_index++;
+		}
+	} else {
+		for (i = 0; i < node_record_count; i++) {
+			if (bit_test(job->node_bitmap, i) == 0)
+				continue;
+			job->alloc_cpus[host_index] = node_record_table_ptr[i].
+						      cpus;
+			if (get_cores) {
+				for (j=0; j<node_record_table_ptr[i].sockets; 
+				     j++) {
+					job->alloc_cores[host_index][j] = 
+						node_record_table_ptr[i].cores;
+				}
+			}
+			host_index++;
 		}
-		host_index++;
 	}
 	return SLURM_SUCCESS;
 }
 
-int cr_plane_dist(struct select_cr_job *job, 
-		  const uint16_t plane_size,
-		  const select_type_plugin_info_t cr_type)
+extern int cr_plane_dist(struct select_cr_job *job, 
+			 const uint16_t plane_size,
+			 const select_type_plugin_info_t cr_type)
 {
-	uint32_t maxtasks    = job->nprocs;
-	uint16_t num_hosts   = job->nhosts;
-	int i, j, k, s, m, l, host_index;
-	uint16_t usable_cpus, usable_sockets, usable_cores, usable_threads;
+	uint32_t maxtasks  = job->nprocs;
+	uint32_t num_hosts = job->nhosts;
+	int i, j, k, host_index, cr_cpu = 0;
 	uint32_t taskcount = 0, last_taskcount;
-	int last_socket_index = -1;
 	int job_index = -1;
 	bool count_done = false;
 
@@ -683,149 +530,71 @@ int cr_plane_dist(struct select_cr_job *job,
 					break;
 				}
 				taskcount++;
-				job->alloc_lps[i]++;
+				job->alloc_cpus[i]++;
 			}
 		}
 		if (last_taskcount == taskcount) {
 			/* avoid possible infinite loop on error */
-			fatal("cr_plane_dist failure");
+			error("cr_plane_dist failure");
+			return SLURM_ERROR;
 		}
 	}
 
 #if(CR_DEBUG)	
 	for (i = 0; i < job->nhosts; i++) {
-		info("cons_res _cr_plane_dist %u host %s alloc_lps %u ", 
-		     job->job_id, job->host[i],  job->alloc_lps[i]);
+		info("cons_res _cr_plane_dist %u host_index %d alloc_cpus %u ", 
+		     job->job_id, i, job->alloc_cpus[i]);
 	}
 #endif
 
+	if ((cr_type == CR_CPU) || (cr_type == CR_MEMORY) ||
+	    (cr_type == CR_CPU_MEMORY))
+		cr_cpu = 1;
+
 	taskcount = 0;
 	for (host_index = 0; 
 	     ((host_index < node_record_count) && (taskcount < job->nprocs));
 	     host_index++) {
 		struct node_cr_record *this_cr_node = NULL;
-		uint16_t alloc_sockets = 0;
-		uint16_t alloc_lps     = 0;
-		uint16_t avail_cpus    = 0;
+
 		if (bit_test(job->node_bitmap, host_index) == 0)
 			continue;
 		job_index++;
-		
-		this_cr_node = find_cr_node_record(
-			node_record_table_ptr[host_index].name);
-		if (this_cr_node == NULL) {
-			error("cons_res: could not find node %s", 
-			      node_record_table_ptr[host_index].name);
+
+		if (select_node_ptr == NULL) {
+			error("cons_res: select_node_ptr is NULL");
 			return SLURM_ERROR;
 		}
+		this_cr_node = &select_node_ptr[host_index];
 		
-		get_resources_this_node(&usable_cpus, &usable_sockets, 
-					&usable_cores, &usable_threads, 
-					this_cr_node,  &alloc_sockets, 
-					&alloc_lps, &job->job_id);
-		
-		avail_cpus = slurm_get_avail_procs(job->max_sockets,
-						   job->max_cores,
-						   job->max_threads,
-						   job->min_sockets,
-						   job->min_cores,
-						   job->cpus_per_task,
-						   job->ntasks_per_node,
-						   job->ntasks_per_socket,
-						   job->ntasks_per_core,
-						   &usable_cpus,
-						   &usable_sockets,
-						   &usable_cores,
-						   &usable_threads,
-						   alloc_sockets,
-						   this_cr_node->alloc_cores,
-						   alloc_lps,
-						   cr_type,
-						   job->job_id,
-						   this_cr_node->node_ptr->name);
-		avail_cpus = MIN(avail_cpus, job->cpus[job_index]);
-		if (avail_cpus == 0) {
-			error(" cons_res: no available cpus on node %s", 
+		if (job->cpus[job_index] == 0) {
+			error("cons_res: no available cpus on node %s", 
 			      node_record_table_ptr[host_index].name);
+			continue;
 		}
 
-		job->alloc_sockets[job_index] = 0;
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			for (j = 0; 
-			     j < job->num_sockets[job_index]; 
-			     j++)
-				job->alloc_cores[job_index][j] = 0;
-		}	
-		maxtasks = job->alloc_lps[job_index];
-
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			_job_assign_tasks_plane(job, this_cr_node, 
-						usable_threads, 
-						usable_cores, usable_sockets, 
-						job_index, maxtasks,
-						plane_size, cr_type);
+		if (cr_cpu) {
+			/* compute the offset */
+			job->node_offset[job_index] =
+				_get_cpu_offset(job, job_index, this_cr_node);
 		} else {
-			/* CR _SOCKET or CR_SOCKET_MEMORY */
-			int core_index;
-			int thread_index;
-			int max_plane_size;
-			last_socket_index = -1;
-			taskcount = 0;
-			for (j=0; taskcount<maxtasks; j++) {
-				last_taskcount = taskcount;
-				for (s=0; ((s<usable_sockets) && (taskcount<maxtasks)); 
-				     s++) {
-					max_plane_size = 
-						(plane_size > usable_cores) 
-						? plane_size : usable_cores;
-					for (m=0; ((m<max_plane_size) && 
-					     (taskcount<maxtasks)); m++) {
-						core_index = m % usable_cores;
-						if(m > usable_cores) 
-							continue;
-						for(l=0; ((l<usable_threads) && 
-						    (taskcount<maxtasks)); l++) {
-							thread_index =
-								l % usable_threads;
-							if(thread_index > usable_threads)
-								continue;
-							if (last_socket_index != s) {
-								job->alloc_sockets[job_index]++;
-								last_socket_index = s;
-							}
-						}
-					}
-					taskcount++;
-				}
-				if (last_taskcount == taskcount) {
-					/* avoid possible infinite loop on error */
-					fatal("cr_plane_dist failure");
-				}
-			}
-		}
+			for (j = 0; j < job->num_sockets[job_index]; j++)
+				job->alloc_cores[job_index][j] = 0;
 
-#if(0)
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			job->alloc_lps[job_index] = 0;
-			for (i = 0; i < job->alloc_sockets[job_index]; i++)
-				job->alloc_lps[job_index] += 
-					job->alloc_cores[job_index][i];
+			if (_job_assign_tasks(job, this_cr_node, job_index, 
+					      cr_type, 0) != SLURM_SUCCESS)
+				return SLURM_ERROR;
 		}
-#endif
-
 #if(CR_DEBUG)
-		info("cons_res _cr_plane_dist %u host %d %s alloc_ "
-		     "s %u lps %u", 
-		     job->job_id, host_index,  this_cr_node->node_ptr->name, 
-		     job->alloc_sockets[job_index], job->alloc_lps[job_index]);
-		int i = 0;
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			for (i = 0; i < this_cr_node->node_ptr->sockets; i++)
-				info("cons_res _cr_plane_dist %u host %d "
-				     "%s alloc_cores %u",
-				     job->job_id, host_index, 
-				     this_cr_node->node_ptr->name, 
-				     job->alloc_cores[job_index][i]);
+		info("cons_res _cr_plane_dist %u host %d %s alloc_cpus %u", 
+		     job->job_id, host_index, this_cr_node->node_ptr->name, 
+		     job->alloc_cpus[job_index]);
+
+		for (i = 0; !cr_cpu && i < this_cr_node->sockets; i++) {
+			info("cons_res _cr_plane_dist %u host %d %s alloc_cores %u",
+			     job->job_id, host_index,
+			     this_cr_node->node_ptr->name,
+			     job->alloc_cores[job_index][i]);
 		}
 #endif
 		
diff --git a/src/plugins/select/cons_res/dist_tasks.h b/src/plugins/select/cons_res/dist_tasks.h
index f500441b74d025eb3627a92766062e09a97d6cce..aea7e3f19472a37c5f10442ffacfee1a72a9f615 100644
--- a/src/plugins/select/cons_res/dist_tasks.h
+++ b/src/plugins/select/cons_res/dist_tasks.h
@@ -5,7 +5,7 @@
  *****************************************************************************
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -53,15 +53,12 @@ int cr_exclusive_dist(struct select_cr_job *job,
 		      const select_type_plugin_info_t cr_type);
 
 int cr_dist(struct select_cr_job *job, int cyclic,
-	    const select_type_plugin_info_t cr_type,
-	    const uint16_t fast_schedule);
+	    const select_type_plugin_info_t cr_type);
 
 int cr_plane_dist(struct select_cr_job *job, 
 		  const uint16_t plane_size,
 		  const select_type_plugin_info_t cr_type);
 
-int compute_c_b_task_dist(struct select_cr_job *job, 	    
-			  const select_type_plugin_info_t cr_type,
-			  const uint16_t fast_schedule);
+int compute_c_b_task_dist(struct select_cr_job *job);
 
 #endif /* !_CONS_RES_DIST_TASKS_H */
diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index a246aefac90e441676eb12a77676b3a8792a620e..acca6dc9ee4f137b7e32b3ab6d97072428b35de1 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -2,7 +2,7 @@
  *  select_cons_res.c - node selection plugin supporting consumable 
  *  resources policies.
  *
- *  $Id: select_cons_res.c 13373 2008-02-27 16:47:13Z jette $
+ *  $Id: select_cons_res.c 13814 2008-04-07 15:46:55Z jette $
  *****************************************************************************\
  *
  *  The following example below illustrates how four jobs are allocated
@@ -32,27 +32,27 @@
  * 
  *  [<snip>]# squeue
  *  JOBID PARTITION     NAME     USER  ST       TIME  NODES NODELIST(REASON)
- *     5       lsf    sleep     root  PD       0:00      1 (Resources)
- *     2       lsf    sleep     root   R       0:13      4 linux[01-04]
- *     3       lsf    sleep     root   R       0:09      3 linux[01-03]
- *     4       lsf    sleep     root   R       0:05      1 linux04
+ *     5        lsf    sleep     root  PD       0:00      1 (Resources)
+ *     2        lsf    sleep     root   R       0:13      4 linux[01-04]
+ *     3        lsf    sleep     root   R       0:09      3 linux[01-03]
+ *     4        lsf    sleep     root   R       0:05      1 linux04
  *  [<snip>]#
  * 
  *  Once Job 2 finishes, Job 5, which was pending, is allocated
  *  available resources and is then running as illustrated below:
  * 
  *  [<snip>]# squeue4
- *   JOBID PARTITION     NAME     USER  ST       TIME  NODES NODELIST(REASON)
- *     3       lsf    sleep     root   R       1:58      3 linux[01-03]
- *     4       lsf    sleep     root   R       1:54      1 linux04
- *     5       lsf    sleep     root   R       0:02      3 linux[01-03]
+ *   JOBID PARTITION    NAME     USER  ST       TIME  NODES NODELIST(REASON)
+ *     3        lsf    sleep     root   R       1:58      3 linux[01-03]
+ *     4        lsf    sleep     root   R       1:54      1 linux04
+ *     5        lsf    sleep     root   R       0:02      3 linux[01-03]
  *  [<snip>]#
  * 
  *  Job 3, Job 4, and Job 5 are now running concurrently on the cluster.
  * 
  *  [<snip>]#  squeue4
  *  JOBID PARTITION     NAME     USER  ST       TIME  NODES NODELIST(REASON)
- *     5       lsf    sleep     root   R       1:52      3 xc14n[13-15]
+ *     5        lsf    sleep     root   R       1:52      3 xc14n[13-15]
  *  [<snip>]#
  *
  * The advantage of the consumable resource scheduling policy is that
@@ -137,333 +137,487 @@
  * as 100 or 1000.  Various SLURM versions will likely require a certain
  * minimum versions for their plugins as the node selection API matures.
  */
-const char plugin_name[] =
-    "Consumable Resources (CR) Node Selection plugin";
+const char plugin_name[] = "Consumable Resources (CR) Node Selection plugin";
 const char plugin_type[] = "select/cons_res";
 const uint32_t plugin_version = 90;
-const uint32_t pstate_version = 3;	/* version control on saved state */
+const uint32_t pstate_version = 6;	/* version control on saved state */
 
-#define CR_JOB_STATE_SUSPENDED 1
+#define CR_JOB_ALLOCATED_CPUS  0x1
+#define CR_JOB_ALLOCATED_MEM   0x2
 
 select_type_plugin_info_t cr_type = CR_CPU; /* cr_type is overwritten in init() */
 
 /* Array of node_cr_record. One entry for each node in the cluster */
-static struct node_cr_record *select_node_ptr = NULL;
+struct node_cr_record *select_node_ptr = NULL;
+uint16_t select_fast_schedule;
 static int select_node_cnt = 0;
-static struct node_cr_record **cr_node_hash_table = NULL;
 static time_t last_cr_update_time;
 static pthread_mutex_t cr_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-/* Restored node_cr_records - used by select_p_state_restore/node_init */
-static struct node_cr_record *prev_select_node_ptr = NULL;
-static int prev_select_node_cnt = 0;
+List select_cr_job_list = NULL; /* List of select_cr_job(s) that are still active */
+static uint32_t last_verified_job_id = 0;
+/* verify the job list after every CR_VERIFY_JOB_CYCLE jobs have finished */
+#define CR_VERIFY_JOB_CYCLE 2000
+
+static void	_cr_job_list_del(void *x);
+static int	_cr_job_list_sort(void *x, void *y);
+static struct node_cr_record *_dup_node_cr(struct node_cr_record *node_cr_ptr);
+static int	_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
+			uint32_t min_nodes, uint32_t max_nodes, 
+			uint32_t req_nodes, int mode, 
+			enum node_cr_state job_node_req,
+			struct node_cr_record *select_node_ptr);
+static int 	_will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
+			uint32_t min_nodes, uint32_t max_nodes, 
+			uint32_t req_nodes, enum node_cr_state job_node_req);
+
+#ifdef CR_DEBUG
+static void _dump_state(struct node_cr_record *select_node_ptr)
+{
+	int i, j, cores;
+	struct part_cr_record *parts;
+	ListIterator job_iterator;
+	struct select_cr_job *job;
 
-static uint16_t select_fast_schedule;
+	for (i=0; i<select_node_cnt; i++) {
+		info("node:%s sockets:%u alloc_memory:%u state:%d",
+			select_node_ptr[i].node_ptr->name,
+			select_node_ptr[i].sockets,
+			select_node_ptr[i].alloc_memory,
+			select_node_ptr[i].node_state);
+		parts = select_node_ptr[i].parts;
+		while (parts) {
+			info("  part:%s rows:%u",
+				parts->part_ptr->name,
+				parts->num_rows);
+			cores = select_node_ptr[i].sockets * 
+				parts->num_rows;
+			for (j=0; j<cores; j++) {
+				info("    alloc_cores[%d]:%u",
+					j, parts->alloc_cores[j]);
+			}
+			parts = parts->next;
+		}
+	}
 
-List select_cr_job_list = NULL; /* List of select_cr_job(s) that are still active */
+	if (select_cr_job_list == NULL)
+	    	return;
+	job_iterator = list_iterator_create(select_cr_job_list);
+	while ((job = (struct select_cr_job *) list_next(job_iterator))) {
+		info("job:%u nprocs:%u nhosts:%u",
+			job->job_id, job->nprocs, job->nhosts);
+		if (job->job_ptr == NULL)
+			error("  job_ptr is NULL");
+		else if (job->job_ptr->job_id != job->job_id)
+			error("  job_ptr is bad");
+		for (i=0; ((i<job->nhosts)&&(i<2)); i++) {
+			info("  cpus:%u alloc_cpus:%u ",
+				job->cpus[i], job->alloc_cpus[i]);
+			info("  node_offset:%u",
+				job->node_offset[i]);
+		}
+	}
+	list_iterator_destroy(job_iterator);
+	return;
+}
+#endif
 
-#if(0)
-/* 
- * _cr_dump_hash - print the cr_node_hash_table contents, used for debugging
- *	or analysis of hash technique. See _hash_table in slurmctld/node_mgr.c 
- * global: select_node_ptr    - table of node_cr_record
- *         cr_node_hash_table - table of hash indices
- * Inspired from _dump_hash() in slurmctld/node_mgr.c
- */
-static void _cr_dump_hash (void) 
+/* Create a duplicate node_cr_records structure */
+static struct node_cr_record *_dup_node_cr(struct node_cr_record *node_cr_ptr)
 {
-	int i, inx;
-	struct node_cr_record *this_node_ptr;
+	int i, j;
+	struct node_cr_record *new_node_cr_ptr;
+	struct part_cr_record *part_cr_ptr, *new_part_cr_ptr;
 
-	if (cr_node_hash_table == NULL)
-		return;
-	for (i = 0; i < select_node_cnt; i++) {
-		this_node_ptr = cr_node_hash_table[i];
-		while (this_node_ptr) {
-		        inx = this_node_ptr - select_node_ptr;
-			verbose("node_hash[%d]:%d", i, inx);
-			this_node_ptr = this_node_ptr->node_next;
+	if (node_cr_ptr == NULL)
+		return NULL;
+
+	new_node_cr_ptr = xmalloc(select_node_cnt *
+				  sizeof(struct node_cr_record));
+
+	for (i=0; i<select_node_cnt; i++) {
+		new_node_cr_ptr[i].node_ptr     = select_node_ptr[i].node_ptr;
+		new_node_cr_ptr[i].cpus         = select_node_ptr[i].cpus;
+		new_node_cr_ptr[i].sockets      = select_node_ptr[i].sockets;
+		new_node_cr_ptr[i].cores        = select_node_ptr[i].cores;
+		new_node_cr_ptr[i].threads      = select_node_ptr[i].threads;
+		new_node_cr_ptr[i].real_memory  = select_node_ptr[i].real_memory;
+		new_node_cr_ptr[i].alloc_memory = select_node_ptr[i].alloc_memory;
+		new_node_cr_ptr[i].node_state   = select_node_ptr[i].node_state;
+
+		part_cr_ptr = select_node_ptr[i].parts;
+		while (part_cr_ptr) {
+			new_part_cr_ptr = xmalloc(sizeof(struct part_cr_record));
+			new_part_cr_ptr->part_ptr   = part_cr_ptr->part_ptr;
+			new_part_cr_ptr->num_rows   = part_cr_ptr->num_rows;
+			j = sizeof(uint16_t) * part_cr_ptr->num_rows * 
+			    select_node_ptr[i].sockets;
+			new_part_cr_ptr->alloc_cores = xmalloc(j);
+			memcpy(new_part_cr_ptr->alloc_cores, 
+			       part_cr_ptr->alloc_cores, j);
+			new_part_cr_ptr->next        = new_node_cr_ptr[i].parts;
+			new_node_cr_ptr[i].parts     = new_part_cr_ptr;
+			part_cr_ptr = part_cr_ptr->next;
 		}
 	}
+	return new_node_cr_ptr;
 }
 
-#endif
-
-/* 
- * _cr_hash_index - return a hash table index for the given node name 
- * IN name = the node's name
- * RET the hash table index
- * Inspired from _hash_index(char *name) in slurmctld/node_mgr.c 
- */
-static int _cr_hash_index (const char *name) 
+static void _destroy_node_part_array(struct node_cr_record *this_cr_node)
 {
-	int index = 0;
-	int j;
+	struct part_cr_record *p_ptr;
 
-	if ((select_node_cnt == 0)
-	||  (name == NULL))
-		return 0;	/* degenerate case */
+	if (!this_cr_node)
+		return;
+	for (p_ptr = this_cr_node->parts; p_ptr; p_ptr = p_ptr->next)
+		xfree(p_ptr->alloc_cores);
+	xfree(this_cr_node->parts);
+}
 
-	/* Multiply each character by its numerical position in the
-	 * name string to add a bit of entropy, because host names such
-	 * as cluster[0001-1000] can cause excessive index collisions.
-	 */
-	for (j = 1; *name; name++, j++)
-		index += (int)*name * j;
-	index %= select_node_cnt;
-	
-	return index;
+static void _cr_job_list_del(void *x)
+{
+	xfree(x);
+}
+static int  _cr_job_list_sort(void *x, void *y)
+{
+	struct job_record **job1_pptr = (struct job_record **) x;
+	struct job_record **job2_pptr = (struct job_record **) y;
+	return (int) difftime(job1_pptr[0]->end_time, job2_pptr[0]->end_time);
 }
 
-/*
- * _build_cr_node_hash_table - build a hash table of the node_cr_record entries. 
- * global: select_node_ptr    - table of node_cr_record 
- *         cr_node_hash_table - table of hash indices
- * NOTE: manages memory for cr_node_hash_table
- * Inspired from rehash_nodes() in slurmctld/node_mgr.c
- */
-void _build_cr_node_hash_table (void)
+static void _create_node_part_array(struct node_cr_record *this_cr_node)
 {
-	int i, inx;
+	struct node_record *node_ptr;
+	struct part_cr_record *p_ptr;
+	int i;
 
-	xfree (cr_node_hash_table);
-	cr_node_hash_table = xmalloc (sizeof (struct node_cr_record *) * 
-				select_node_cnt);
+	if (!this_cr_node)
+		return;
+	node_ptr = this_cr_node->node_ptr;
 
-	for (i = 0; i < select_node_cnt; i++) {
-		if (strlen (select_node_ptr[i].node_ptr->name) == 0)
-			continue;	/* vestigial record */
-		inx = _cr_hash_index (select_node_ptr[i].node_ptr->name);
-		select_node_ptr[i].node_next = cr_node_hash_table[inx];
-		cr_node_hash_table[inx] = &select_node_ptr[i];
-	}
+	if (this_cr_node->parts)
+		_destroy_node_part_array(this_cr_node);
 
-#if(0)
-	_cr_dump_hash();
+	if (node_ptr->part_cnt < 1)
+		return;
+	this_cr_node->parts = xmalloc(sizeof(struct part_cr_record) *
+	        		      node_ptr->part_cnt);
+	for (i = 0; i < node_ptr->part_cnt; i++) {
+		p_ptr		 = &(this_cr_node->parts[i]);
+		p_ptr->part_ptr  = node_ptr->part_pptr[i];
+		p_ptr->num_rows  = node_ptr->part_pptr[i]->max_share;
+		if (p_ptr->num_rows & SHARED_FORCE)
+			p_ptr->num_rows &= (~SHARED_FORCE);
+		/* SHARED=EXCLUSIVE sets max_share = 0 */
+		if (p_ptr->num_rows < 1)
+			p_ptr->num_rows = 1;
+#if (CR_DEBUG)
+		info("cons_res: _create_node_part_array: part %s  num_rows %d",
+		     p_ptr->part_ptr->name, p_ptr->num_rows);
 #endif
-	return;
+		p_ptr->alloc_cores = xmalloc(sizeof(uint16_t) *
+		        		     this_cr_node->sockets *
+					     p_ptr->num_rows);
+		if (i+1 < node_ptr->part_cnt)
+			p_ptr->next = &(this_cr_node->parts[i+1]);
+		else
+			p_ptr->next = NULL;
+	}
+
 }
 
-/* 
- * find_cr_node_record - find a record for node with specified name
- * input: name - name of the desired node 
- * output: return pointer to node record or NULL if not found
- * global: select_node_ptr - pointer to global select_node_ptr
- *         cr_node_hash_table - table of hash indecies
- * Inspired from find_node_record (char *name) in slurmctld/node_mgr.c 
- */
-struct node_cr_record * find_cr_node_record (const char *name) 
+static int _find_job_by_id(void *x, void *key)
 {
-	int i;
+	struct select_cr_job *cr_job_ptr = (struct select_cr_job *) x;
+	uint32_t *job_id = (uint32_t *) key;
 
-	if ((name == NULL)
-	||  (name[0] == '\0')) {
-		info("find_cr_node_record passed NULL name");
-		return NULL;
-	}
+	if (cr_job_ptr->job_id == *job_id)
+		return 1;
+	return 0;
+}
 
-	/* try to find via hash table, if it exists */
-	if (cr_node_hash_table) {
-		struct node_cr_record *this_node;
+/* Find a partition record based upon pointer to slurmctld record */
+extern struct part_cr_record *get_cr_part_ptr(struct node_cr_record *this_node,
+					      struct part_record *part_ptr)
+{
+	struct part_cr_record *p_ptr;
 
-		i = _cr_hash_index (name);
-		this_node = cr_node_hash_table[i];
-		while (this_node) {
-			xassert(this_node->node_ptr->magic == NODE_MAGIC);
-			if (strncmp(this_node->node_ptr->name, name, MAX_SLURM_NAME) == 0) {
-				return this_node;
-			}
-			this_node = this_node->node_next;
-		}
-		error ("find_cr_node_record: lookup failure using hashtable for %s", 
-                        name);
-	} 
+	if (part_ptr == NULL)
+		return NULL;
 
-	/* revert to sequential search */
-	else {
-		for (i = 0; i < select_node_cnt; i++) {
-		        if (strcmp (name, select_node_ptr[i].node_ptr->name) == 0) {
-			        debug3("cons_res find_cr_node_record: linear %s",  name);
-				return (&select_node_ptr[i]);
-			}
-		}
-		error ("find_cr_node_record: lookup failure with linear search for %s", 
-                        name);
+	if (!this_node->parts)
+		_create_node_part_array(this_node);
+
+	for (p_ptr = this_node->parts; p_ptr; p_ptr = p_ptr->next) {
+		if (p_ptr->part_ptr == part_ptr)
+			return p_ptr;
 	}
-	error ("find_cr_node_record: lookup failure with both method %s", name);
-	return (struct node_cr_record *) NULL;
+	error("cons_res: could not find partition %s", part_ptr->name);
+
+	return NULL;
 }
 
-void chk_resize_node(struct node_cr_record *node, uint16_t sockets)
+/* This just resizes alloc_cores based on a potential change to
+ * the number of sockets on this node (if fast_schedule = 0 and the
+ * node checks in with a different node count after initialization).
+ * Any changes to the number of partition rows will be caught
+ * and adjusted in select_p_reconfigure() */
+static void _chk_resize_node(struct node_cr_record *node)
 {
-	if ((node->alloc_cores == NULL) ||
-			(sockets > node->num_sockets)) {
-		debug3("cons_res: increasing node %s num_sockets from %u to %u",
-			node->node_ptr->name, node->num_sockets, sockets);
-	    	xrealloc(node->alloc_cores, sockets * sizeof(uint16_t));
+	struct part_cr_record *p_ptr;
+
+	if ((select_fast_schedule > 0) ||
+	    (node->cpus >= node->node_ptr->cpus))
+		return;
+
+	verbose("cons_res: increasing node %s cpus from %u to %u",
+		node->node_ptr->name, node->cpus, node->node_ptr->cpus);
+	node->cpus        = node->node_ptr->cpus;
+	node->sockets     = node->node_ptr->sockets;
+	node->cores       = node->node_ptr->cores;
+	node->threads     = node->node_ptr->threads;
+	node->real_memory = node->node_ptr->real_memory;
+	for (p_ptr = node->parts; p_ptr; p_ptr = p_ptr->next) {
+		xrealloc(p_ptr->alloc_cores, (sizeof(uint16_t) *
+			 node->sockets * p_ptr->num_rows));
 		/* NOTE: xrealloc zero fills added memory */
-		node->num_sockets = sockets;
 	}
 }
 
-void chk_resize_job(struct select_cr_job *job, uint16_t node_id, uint16_t sockets)
+static void _chk_resize_job(struct select_cr_job *job, uint16_t node_id, 
+			    uint16_t sockets)
 {
 	if ((job->alloc_cores[node_id] == NULL) ||
 	    		(sockets > job->num_sockets[node_id])) {
-		debug3("cons_res: increasing job %u node %u num_sockets from %u to %u",
-			job->job_id, node_id, job->num_sockets[node_id], sockets);
+		debug3("cons_res: increasing job %u node %u "
+			"num_sockets from %u to %u",
+			job->job_id, node_id, 
+			job->num_sockets[node_id], sockets);
 	    	xrealloc(job->alloc_cores[node_id], sockets * sizeof(uint16_t));
 		/* NOTE: xrealloc zero fills added memory */
 		job->num_sockets[node_id] = sockets;
 	}
 }
 
-void get_resources_this_node(uint16_t *cpus, 
-			     uint16_t *sockets, 
-			     uint16_t *cores,
-			     uint16_t *threads, 
-			     struct node_cr_record *this_cr_node,
-			     uint16_t *alloc_sockets, 
-			     uint16_t *alloc_lps,
-			     uint32_t *jobid)
+extern void get_resources_this_node(uint16_t *cpus, uint16_t *sockets, 
+				    uint16_t *cores, uint16_t *threads, 
+				    struct node_cr_record *this_cr_node,
+				    uint32_t jobid)
 {
-	if (select_fast_schedule) {
-		*cpus    = this_cr_node->node_ptr->config_ptr->cpus;
-		*sockets = this_cr_node->node_ptr->config_ptr->sockets;
-		*cores   = this_cr_node->node_ptr->config_ptr->cores;
-		*threads = this_cr_node->node_ptr->config_ptr->threads;
-	} else {
-		*cpus    = this_cr_node->node_ptr->cpus;
-		*sockets = this_cr_node->node_ptr->sockets;
-		*cores   = this_cr_node->node_ptr->cores;
-		*threads = this_cr_node->node_ptr->threads;
-	}
-	*alloc_sockets  = this_cr_node->alloc_sockets;
-	*alloc_lps      = this_cr_node->alloc_lps;
+	_chk_resize_node(this_cr_node);
+
+	*cpus    = this_cr_node->cpus;
+	*sockets = this_cr_node->sockets;
+	*cores   = this_cr_node->cores;
+	*threads = this_cr_node->threads;
 
 	debug3("cons_res %u _get_resources host %s HW_ "
 	       "cpus %u sockets %u cores %u threads %u ", 
-	       *jobid, this_cr_node->node_ptr->name,
+	       jobid, this_cr_node->node_ptr->name,
 	       *cpus, *sockets, *cores, *threads);
-	debug3("cons_res %u _get_resources host %s Alloc_ sockets %u lps %u", 
-	       *jobid, this_cr_node->node_ptr->name, 
-	       *alloc_sockets, *alloc_lps);
 }
 
-/*
- * _get_avail_memory returns the amount of available real memory in MB
- * for this node.
+/* _get_cpu_data
+ * determine the number of available free cores/cpus/sockets
+ * IN - p_ptr:       pointer to a node's part_cr_record for a specific partition
+ * IN - num_sockets: number of sockets on this node
+ * IN - max_cpus:    the total number of cores/cpus/sockets on this node
+ * OUT- row_index:   the row index from which the returned value was obtained
+ *                   (if -1 then nothing is allocated in this partition)
+ * OUT- free_row:    the row index of an unallocated row (if -1 then all rows
+ *                   contain allocated cores)
+ * RETURN - the maximum number of free cores/cpus/sockets found in the given
+ *          row_index (if 0 then node is full; if 'max_cpus' then node is free)
  */
-static uint32_t _get_avail_memory(int index, int all_available) 
+static uint16_t _get_cpu_data (struct part_cr_record *p_ptr, int num_sockets,
+			       uint16_t max_cpus, int *row_index, int *free_row)
 {
-	uint32_t avail_memory = 0;
-	struct node_cr_record *this_cr_node;
-	
-	if (select_fast_schedule) {
-		avail_memory = select_node_ptr[index].node_ptr->config_ptr->real_memory;
-	} else {
-		avail_memory = select_node_ptr[index].node_ptr->real_memory;
+	int i, j, index;
+	uint16_t alloc_count = 0;
+	bool counting_sockets = 0;
+	if ((cr_type == CR_SOCKET) || (cr_type == CR_SOCKET_MEMORY))
+		counting_sockets = 1;
+ 
+ 	*free_row = -1;
+	*row_index = -1;
+
+	for (i = 0, index = 0; i < p_ptr->num_rows; i++) {
+		uint16_t cpu_count = 0;
+		uint16_t socket_count = 0;
+		for (j = 0; j < num_sockets; j++, index++) {
+			if (p_ptr->alloc_cores[index]) {
+				socket_count++;
+				cpu_count += p_ptr->alloc_cores[index];
+			}
+		}
+		if (socket_count > 0) {
+			if (counting_sockets) {
+				if ((alloc_count == 0) ||
+				    (socket_count < alloc_count)) {
+					alloc_count = socket_count;
+					*row_index = i;
+				}
+			} else {
+				if ((alloc_count == 0) ||
+				    (cpu_count < alloc_count)) {
+					alloc_count = cpu_count;
+					*row_index = i;
+				}
+			}
+		} 
+		else if (*free_row < 0) {
+			*free_row = i;
+		}
 	}
-	
-	if (all_available) 
-		return avail_memory;
-	
-	this_cr_node = find_cr_node_record (select_node_ptr[index].node_ptr->name);
-	if (this_cr_node == NULL) {
-		error(" cons_res: could not find node %s", 
-		      select_node_ptr[index].node_ptr->name);
-		avail_memory = 0;
-		return avail_memory;
-	}
-	avail_memory -= this_cr_node->alloc_memory;
-	
-	return(avail_memory);
+	return max_cpus - alloc_count;
 }
 
 /*
- * _get_avail_lps - Get the number of "available" cpus on a node
- *	given the number of cpus_per_task and
- *	maximum sockets, cores, threads.  Note that the value of
- *	cpus is the lowest-level logical processor (LLLP).
+ * _get_task_count - Given the job requirements, compute the number of tasks
+ *                   this node can run
+ *
  * IN job_ptr - pointer to job being scheduled
  * IN index - index of node's configuration information in select_node_ptr
  */
-static uint16_t _get_avail_lps(struct job_record *job_ptr, 
-			  const int index, 
-			  const bool all_available)
+static uint16_t _get_task_count(struct node_cr_record *select_node_ptr,
+				struct job_record *job_ptr, const int index, 
+				const bool all_available, bool try_partial_idle,
+				enum node_cr_state job_node_req)
 {
-	uint16_t avail_cpus, cpus_per_task = 0;
+	uint16_t numtasks, cpus_per_task = 0;
 	uint16_t max_sockets = 0, max_cores = 0, max_threads = 0;
 	uint16_t min_sockets = 0, min_cores = 0, min_threads = 0;
 	uint16_t ntasks_per_node = 0, ntasks_per_socket = 0, ntasks_per_core = 0;
-	uint16_t cpus, sockets, cores, threads;
-	uint16_t alloc_sockets = 0, alloc_lps = 0;
-	struct node_cr_record *this_cr_node;
+	uint16_t i, cpus, sockets, cores, threads, *alloc_cores = NULL;
+	struct node_cr_record *this_node;
+	struct part_cr_record *p_ptr;
 	struct multi_core_data *mc_ptr = NULL;
 
-	if (job_ptr->details) {
-		cpus_per_task   = job_ptr->details->cpus_per_task;
-		ntasks_per_node = job_ptr->details->ntasks_per_node;
-		mc_ptr = job_ptr->details->mc_ptr;
-	}
-	if (mc_ptr) {
-		min_sockets = mc_ptr->min_sockets;
-		max_sockets = mc_ptr->max_sockets;
-		min_cores   = mc_ptr->min_cores;
-		max_cores   = mc_ptr->max_cores;
-		min_threads = mc_ptr->min_threads;
-		max_threads = mc_ptr->max_threads;
-		ntasks_per_socket = mc_ptr->ntasks_per_socket;
-		ntasks_per_core   = mc_ptr->ntasks_per_core;
-	}
-
-	this_cr_node = find_cr_node_record (select_node_ptr[index].node_ptr->name);
-	if (this_cr_node == NULL) {
-		error(" cons_res: could not find node %s", 
-		      select_node_ptr[index].node_ptr->name);
-		avail_cpus = 0;
-		return avail_cpus;
-	}
+	cpus_per_task   = job_ptr->details->cpus_per_task;
+	ntasks_per_node = job_ptr->details->ntasks_per_node;
+
+	mc_ptr      = job_ptr->details->mc_ptr;
+	min_sockets = mc_ptr->min_sockets;
+	max_sockets = mc_ptr->max_sockets;
+	min_cores   = mc_ptr->min_cores;
+	max_cores   = mc_ptr->max_cores;
+	min_threads = mc_ptr->min_threads;
+	max_threads = mc_ptr->max_threads;
+	ntasks_per_socket = mc_ptr->ntasks_per_socket;
+	ntasks_per_core   = mc_ptr->ntasks_per_core;
+
+	this_node = &(select_node_ptr[index]);
 	get_resources_this_node(&cpus, &sockets, &cores, &threads, 
-				this_cr_node, &alloc_sockets,
-				&alloc_lps, &job_ptr->job_id);
-	if (all_available) {
-		alloc_sockets = 0;
-		alloc_lps     = 0;
-	}
-
-	chk_resize_node(this_cr_node, sockets);
-	avail_cpus = slurm_get_avail_procs(max_sockets,
-					   max_cores,
-					   max_threads,
-					   min_sockets,
-					   min_cores,
-					   cpus_per_task,
-					   ntasks_per_node,
-					   ntasks_per_socket,
-					   ntasks_per_core,
-					   &cpus, &sockets, &cores,
-					   &threads, alloc_sockets,
-					   this_cr_node->alloc_cores, 
-					   alloc_lps, cr_type, 
-					   job_ptr->job_id,
-					   this_cr_node->node_ptr->name);
-	return(avail_cpus);
+				this_node, job_ptr->job_id);
+
+	alloc_cores = xmalloc(sockets * sizeof(uint16_t));
+	/* array is zero filled by xmalloc() */
+
+	if (!all_available) {
+		p_ptr = get_cr_part_ptr(this_node, job_ptr->part_ptr);
+		if (!p_ptr) {
+			error("cons_res: _get_task_count: could not find part %s",
+			      job_ptr->part_ptr->name);
+		} else {
+			if (job_node_req == NODE_CR_ONE_ROW) {
+				/* need to scan over all partitions with
+				 * num_rows = 1 */
+				for (p_ptr = this_node->parts; p_ptr;
+				     p_ptr = p_ptr->next) {
+					if (p_ptr->num_rows > 1)
+						continue;
+					for (i = 0; i < sockets; i++) {
+					    if ((cr_type == CR_SOCKET) ||
+						(cr_type == CR_SOCKET_MEMORY)) {
+						if (p_ptr->alloc_cores[i])
+							alloc_cores[i] = cores;
+					    } else {
+						alloc_cores[i] =
+							p_ptr->alloc_cores[i];
+					    }
+					}
+				}
+			} else {
+				/* job_node_req == EXCLUSIVE | AVAILABLE
+				 * if EXCLUSIVE, then node *should* be free and
+				 * this code should fall through with
+				 * alloc_cores all set to zero.
+				 * if AVAILABLE then scan partition rows based
+				 * on 'try_partial_idle' setting. Note that
+				 * if 'try_partial_idle' is FALSE then this
+				 * code should use a 'free' row and this is
+				 * where a new row will first be evaluated.
+				 */
+				uint16_t count, max_cpus;
+				int alloc_row, free_row;
+
+				max_cpus = cpus;
+				if ((cr_type == CR_SOCKET) ||
+				    (cr_type == CR_SOCKET_MEMORY))
+					max_cpus = sockets;
+				if ((cr_type == CR_CORE) ||
+				    (cr_type == CR_CORE_MEMORY))
+					max_cpus = cores * sockets;
+
+				count = _get_cpu_data(p_ptr, sockets, max_cpus,
+						      &alloc_row, &free_row);
+				if ((count == 0) && (free_row == -1)) {
+					/* node is completely allocated */
+					xfree(alloc_cores);
+					return 0;
+				}
+				if ((free_row == -1) && (!try_partial_idle)) {
+					/* no free rows, so partial idle is
+					 * all that is left! */
+					try_partial_idle = 1;
+				}
+				if (try_partial_idle && (alloc_row > -1)) {
+					alloc_row *= sockets;
+					for (i = 0; i < sockets; i++)
+						alloc_cores[i] =
+						p_ptr->alloc_cores[alloc_row+i];
+				}
+			}
+		}
+	}
+#if (CR_DEBUG)
+	for (i = 0; i < sockets; i+=2) {
+		info("cons_res: _get_task_count: %s alloc_cores[%d]=%d, [%d]=%d",
+		     this_node->node_ptr->name, i, alloc_cores[i],
+		     i+1, alloc_cores[i+1]);
+	}
+#endif
+
+	numtasks = slurm_get_avail_procs(max_sockets, max_cores, max_threads,
+					 min_sockets, min_cores,
+					 cpus_per_task,
+					 ntasks_per_node,
+					 ntasks_per_socket,
+					 ntasks_per_core,
+					 &cpus, &sockets, &cores,
+					 &threads, alloc_cores, 
+					 cr_type, job_ptr->job_id,
+					 this_node->node_ptr->name);
+#if (CR_DEBUG)
+	info("cons_res: _get_task_count computed a_tasks %d s %d c %d "
+		"t %d on %s for job %d",
+		numtasks, sockets, cores, 
+		threads, this_node->node_ptr->name, job_ptr->job_id);
+#endif
+	xfree(alloc_cores);
+	return(numtasks);
 }		
 
 /* xfree an array of node_cr_record */
-static void _xfree_select_nodes(struct node_cr_record *ptr, int select_node_cnt)
+static void _xfree_select_nodes(struct node_cr_record *ptr, int count)
 {
 	int i;
 	
 	if (ptr == NULL)
 		return;
 
-	for (i = 0; i < select_node_cnt; i++) {
-		xfree(ptr[i].alloc_cores);
-		xfree(ptr[i].name);
-		ptr[i].num_sockets = 0;
-	}
+	for (i = 0; i < count; i++)
+		_destroy_node_part_array(&(ptr[i]));
 	xfree(ptr);
 }
 
@@ -475,16 +629,12 @@ static void _xfree_select_cr_job(struct select_cr_job *job)
 	if (job == NULL)
 		return;
 
-	if (job->host) {
-		for (i=0; i<job->nhosts; i++)
-			xfree(job->host[i]);
-		xfree(job->host);
-	}
 	xfree(job->cpus);
-	xfree(job->alloc_lps);	
-	xfree(job->alloc_sockets);
+	xfree(job->alloc_cpus);	
+	xfree(job->node_offset);	
 	xfree(job->alloc_memory);
-	if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
+	if ((cr_type == CR_CORE)   || (cr_type == CR_CORE_MEMORY) ||
+	    (cr_type == CR_SOCKET) || (cr_type == CR_SOCKET_MEMORY)) {
 		for (i = 0; i < job->nhosts; i++)
 			xfree(job->alloc_cores[i]);
 		xfree(job->alloc_cores);
@@ -502,9 +652,8 @@ static void _clear_job_list(void)
 	ListIterator job_iterator;
 	struct select_cr_job *job;
 
-	if (select_cr_job_list == NULL) {
+	if (select_cr_job_list == NULL)
 	    	return;
-	}
 
 	slurm_mutex_lock(&cr_mutex);
 	job_iterator = list_iterator_create(select_cr_job_list);
@@ -516,6 +665,36 @@ static void _clear_job_list(void)
 	slurm_mutex_unlock(&cr_mutex);
 }
 
+static void _verify_select_job_list(uint32_t job_id)
+{
+	ListIterator job_iterator;
+	struct select_cr_job *job;
+
+	if (list_count(select_cr_job_list) < 1) {
+		last_verified_job_id = job_id;
+		return;
+	}
+	if ((job_id > last_verified_job_id) &&
+	    (job_id < (last_verified_job_id + CR_VERIFY_JOB_CYCLE))) {
+		return;
+	}
+
+	last_verified_job_id = job_id;
+	slurm_mutex_lock(&cr_mutex);
+	job_iterator = list_iterator_create(select_cr_job_list);
+	while ((job = (struct select_cr_job *) list_next(job_iterator))) {
+		if (find_job_record(job->job_id) == NULL) {
+			list_remove(job_iterator);
+			debug2("cons_res: _verify_job_list: removing "
+				"nonexistent job %u", job->job_id);
+			_xfree_select_cr_job(job);
+		}
+	}
+	list_iterator_destroy(job_iterator);
+	slurm_mutex_unlock(&cr_mutex);	
+	last_cr_update_time = time(NULL);
+}
+
 /* Append a specific select_cr_job to select_cr_job_list. If the
  * select_job already exists then it is deleted and re-added otherwise
  * it is just added to the list.
@@ -524,8 +703,8 @@ static void _append_to_job_list(struct select_cr_job *new_job)
 {
 	int job_id = new_job->job_id;
 	struct select_cr_job *old_job = NULL;
-
 	ListIterator iterator = list_iterator_create(select_cr_job_list);
+
 	slurm_mutex_lock(&cr_mutex);
 	while ((old_job = (struct select_cr_job *) list_next(iterator))) {
 		if (old_job->job_id != job_id)
@@ -534,103 +713,93 @@ static void _append_to_job_list(struct select_cr_job *new_job)
 		_xfree_select_cr_job(old_job);	/* xfree job structure */
 		break;
 	}
-
 	list_iterator_destroy(iterator);
 	list_append(select_cr_job_list, new_job);
 	slurm_mutex_unlock(&cr_mutex);
-	debug3 (" cons_res: _append_to_job_list job_id %u to list. "
+	debug3 ("cons_res: _append_to_job_list job_id %u to list. "
 		"list_count %d ", job_id, list_count(select_cr_job_list));
 }
 
-/*
- * _count_cpus - report how many cpus are available with the identified nodes 
- */
-static void _count_cpus(bitstr_t *bitmap, uint16_t *sum)
+/* find the maximum number of idle cpus from all partitions */
+static uint16_t _count_idle_cpus(struct node_cr_record *this_node)
 {
-	int i, allocated_lps;
-	*sum = 0;
+	struct part_cr_record *p_ptr;
+	int i, j, index, idlecpus;
+	uint16_t cpus, sockets, cores, threads;
 
-	for (i = 0; i < node_record_count; i++) {
-		struct node_cr_record *this_node;
-		allocated_lps = 0;
-		if (bit_test(bitmap, i) != 1)
-			continue;
+	if (this_node->node_state == NODE_CR_RESERVED)
+		return (uint16_t) 0;
 
-		this_node = find_cr_node_record(node_record_table_ptr[i].name);
-		if (this_node == NULL) {
-			error(" cons_res: Invalid Node reference %s ",
-			      node_record_table_ptr[i].name);
-			*sum = 0;
-			return;
-		}
+	get_resources_this_node(&cpus, &sockets, &cores, &threads, 
+				this_node, 0);
 
-		switch(cr_type) {
-		case CR_SOCKET:
-		case CR_SOCKET_MEMORY:
-			if (slurmctld_conf.fast_schedule) {
-				(*sum) += (node_record_table_ptr[i].config_ptr->sockets -
-					this_node->alloc_sockets) * 
-					node_record_table_ptr[i].config_ptr->cores *
-					node_record_table_ptr[i].config_ptr->threads;
-			} else {
-				(*sum) += (node_record_table_ptr[i].sockets - 
-					this_node->alloc_sockets) 
-					* node_record_table_ptr[i].cores
-					* node_record_table_ptr[i].threads;
-			}
-			break;
-		case CR_CORE:
-		case CR_CORE_MEMORY:
-		{
-			int core_cnt = 0;
-			chk_resize_node(this_node, this_node->node_ptr->sockets);
-			for (i = 0; i < this_node->node_ptr->sockets; i++)
-				core_cnt += this_node->alloc_cores[i];
-			if (slurmctld_conf.fast_schedule) {
-				(*sum) += ((node_record_table_ptr[i].config_ptr->sockets
-					 * node_record_table_ptr[i].config_ptr->cores)
-					- core_cnt)
-					* node_record_table_ptr[i].config_ptr->threads;
-			} else {
-				(*sum) += ((node_record_table_ptr[i].sockets 
-					 * node_record_table_ptr[i].cores) 
-					- core_cnt)
-					* node_record_table_ptr[i].threads;
+	if (!this_node->parts)
+		return cpus;
+
+	idlecpus = cpus;
+	if (this_node->node_state == NODE_CR_ONE_ROW) {
+		/* check single-row partitions for idle CPUs */
+		for (p_ptr = this_node->parts; p_ptr; p_ptr = p_ptr->next) {
+			if (p_ptr->num_rows > 1)
+				continue;
+			for (i = 0; i < this_node->sockets; i++) {
+				if ((cr_type == CR_SOCKET) ||
+				    (cr_type == CR_SOCKET_MEMORY)) {
+				 	if (p_ptr->alloc_cores[i])
+						idlecpus -= cores;
+				} else {
+					idlecpus -= p_ptr->alloc_cores[i];
+				}
 			}
-			break;
+			if (idlecpus < 1)
+				return (uint16_t) 0;
 		}
-		case CR_MEMORY:
-			if (slurmctld_conf.fast_schedule) {
-				(*sum) += node_record_table_ptr[i].config_ptr->cpus;
-			} else {
-				(*sum) += node_record_table_ptr[i].cpus;
-			}
-			break;
-		case CR_CPU:
-		case CR_CPU_MEMORY:
-		default:
-			if (slurmctld_conf.fast_schedule) {
-				(*sum) += node_record_table_ptr[i].config_ptr->cpus -
-					this_node->alloc_lps; 
-			} else {
-				(*sum) += node_record_table_ptr[i].cpus -
-					this_node->alloc_lps; 
+		return (uint16_t) idlecpus;
+	}
+
+	if (this_node->node_state == NODE_CR_AVAILABLE) {
+		/* check all partitions for idle CPUs */
+		int tmpcpus, max_idle = 0;
+		for (p_ptr = this_node->parts; p_ptr; p_ptr = p_ptr->next) {
+			for (i = 0, index = 0; i < p_ptr->num_rows; i++) {
+				tmpcpus = idlecpus;
+				for (j = 0; j < this_node->sockets;
+				     j++, index++) {
+				 	if ((cr_type == CR_SOCKET) ||
+				 	    (cr_type == CR_SOCKET_MEMORY)) {
+						if (p_ptr->alloc_cores[index])
+							tmpcpus -= cores;
+					} else {
+						tmpcpus -= p_ptr->
+							   alloc_cores[index];
+					}
+				}
+				if (tmpcpus > max_idle) {
+					max_idle = tmpcpus;
+					if (max_idle == idlecpus)
+						break;
+				}
 			}
-			break;
+			if (max_idle == idlecpus)
+				break;
 		}
+		if (this_node->parts)
+			idlecpus = max_idle;
 	}
+	return (uint16_t) idlecpus;
 }
 
 static int _synchronize_bitmaps(bitstr_t ** partially_idle_bitmap)
 {
-	int rc = SLURM_SUCCESS, i;
-	bitstr_t *bitmap = bit_alloc(bit_size(avail_node_bitmap));
+	int rc = SLURM_SUCCESS;
+	int size, i, idlecpus = bit_set_count(avail_node_bitmap);
+	size = bit_size(avail_node_bitmap);
+	bitstr_t *bitmap = bit_alloc(size);
 
-	debug3(" cons_res:  Synch size avail %d size idle %d ",
-	       bit_size(avail_node_bitmap), bit_size(idle_node_bitmap));
+	debug3("cons_res: synch_bm: size avail %d (%d set) size idle %d ",
+	       size, idlecpus, bit_size(idle_node_bitmap));
 
-	for (i = 0; i < node_record_count; i++) {
-		uint16_t allocated_cpus;
+	for (i = 0; i < select_node_cnt; i++) {
 		if (bit_test(avail_node_bitmap, i) != 1)
 			continue;
 
@@ -638,205 +807,291 @@ static int _synchronize_bitmaps(bitstr_t ** partially_idle_bitmap)
 			bit_set(bitmap, i);
 			continue;
 		}
-
-		allocated_cpus = 0;
-		rc = select_g_get_select_nodeinfo(&node_record_table_ptr
-						  [i], SELECT_ALLOC_CPUS,
-						  &allocated_cpus);
-		if (rc != SLURM_SUCCESS) {
-			error(" cons_res: Invalid Node reference %s",
-			      node_record_table_ptr[i].name);
-			goto cleanup;
-		}
-
-		if (allocated_cpus < node_record_table_ptr[i].cpus)
+		
+		idlecpus = _count_idle_cpus(&(select_node_ptr[i]));
+		if (idlecpus)
 			bit_set(bitmap, i);
-		else
-			bit_clear(bitmap, i);
 	}
+	idlecpus = bit_set_count(bitmap);
+	debug3("cons_res: synch found %d partially idle nodes", idlecpus);
 
 	*partially_idle_bitmap = bitmap;
-	if (rc == SLURM_SUCCESS)
+	if (rc != SLURM_SUCCESS)
+		FREE_NULL_BITMAP(bitmap);
+	return rc;
+}
+
+/* allocate resources to the given job
+ *
+ * if suspend = 0 then fully add job
+ * if suspend = 1 then only add memory
+ */
+static int _add_job_to_nodes(struct select_cr_job *job, char *pre_err,
+			     int suspend)
+{
+	int host_index, i, j, rc = SLURM_SUCCESS;
+	uint16_t add_memory = 0;
+	uint16_t memset = job->state & CR_JOB_ALLOCATED_MEM;
+	uint16_t cpuset = job->state & CR_JOB_ALLOCATED_CPUS;
+
+	if (memset && cpuset)
+		return rc;
+	if (job->node_bitmap == NULL) {	/* likely still starting up */
+		error("job %u has no node_bitmap", job->job_id);
 		return rc;
+	}
+	if (!memset &&
+	    ((cr_type == CR_CORE_MEMORY) || (cr_type == CR_CPU_MEMORY) ||
+	     (cr_type == CR_MEMORY) || (cr_type == CR_SOCKET_MEMORY))) {
+		job->state |= CR_JOB_ALLOCATED_MEM;
+		add_memory = 1;
+	}
+	if (!cpuset && !suspend)
+		job->state |= CR_JOB_ALLOCATED_CPUS;
+
+	i = -1;
+	for (host_index = 0; host_index < select_node_cnt; host_index++) {
+		struct node_cr_record *this_node;
+		struct part_cr_record *p_ptr;
+		uint16_t offset = 0;
+
+		if (bit_test(job->node_bitmap, host_index) == 0)
+			continue;
+	
+		this_node = &select_node_ptr[host_index];
+		i++;
+
+		/* Update this node's allocated resources, starting with
+		 * memory (if applicable) */
+		
+		if (add_memory)
+			this_node->alloc_memory += job->alloc_memory[i];
+
+		if (cpuset || suspend)
+			continue;
+
+		this_node->node_state = job->node_req;
+		
+		p_ptr = get_cr_part_ptr(this_node, job->job_ptr->part_ptr);
+		if (p_ptr == NULL) {
+			error("%s: could not find part %s", pre_err,
+			      job->job_ptr->partition);
+			continue;
+		}
+
+		/* The offset could be invalid if the sysadmin reduced the
+		 * number of shared rows after this job was allocated. In
+		 * this case, we *should* attempt to place this job in
+		 * other rows. However, this may be futile if they are all
+		 * currently full.
+		 * For now, we're going to be lazy and simply NOT "allocate"
+		 * this job on the node(s) (hey - you get what you pay for). ;-)
+		 * This just means that we will not be accounting for this
+		 * job when determining available space for future jobs,
+		 * which is relatively harmless (hey, there was space when
+		 * this job was first scheduled - if the sysadmin doesn't
+		 * like it, then (s)he can terminate the job). ;-)
+		 * Note that we are still "allocating" memory for this job
+		 * (if requested). 
+		 */
+		offset = job->node_offset[i];
+		if (offset > (this_node->sockets * (p_ptr->num_rows - 1))) {
+			rc = SLURM_ERROR;
+			continue;
+		}
+
+		switch (cr_type) {
+		case CR_SOCKET_MEMORY:
+		case CR_SOCKET:
+		case CR_CORE_MEMORY:
+		case CR_CORE:
+			_chk_resize_job(job, i, this_node->sockets);
+			for (j = 0; j < this_node->sockets; j++) {
+				p_ptr->alloc_cores[offset+j] +=
+							job->alloc_cores[i][j];
+				if (p_ptr->alloc_cores[offset+j] >
+						this_node->cores)
+					error("%s: Job %u Host %s offset %u "
+					      "too many allocated "
+					      "cores %u for socket %d",
+					      pre_err, job->job_id,
+					      this_node->node_ptr->name, offset,
+					      p_ptr->alloc_cores[offset+j], j);
+			}
+			break;
+		case CR_CPU_MEMORY:
+		case CR_CPU:
+			/* "CPU" count is stored in the first "core" */
+			p_ptr->alloc_cores[offset] += job->alloc_cpus[i];
+			break;
+		default:
+			break;
+		}
 
-      cleanup:
-	FREE_NULL_BITMAP(bitmap);
+		/* Remove debug only */
+		debug3("cons_res: %s: Job %u (+) node %s alloc_mem %u state %d",
+			pre_err, job->job_id, 
+			node_record_table_ptr[host_index].name,
+			this_node->alloc_memory, this_node->node_state);
+		debug3("cons_res: %s: Job %u (+) alloc_ cpus %u offset %u mem %u",
+			pre_err, job->job_id, job->alloc_cpus[i],
+			job->node_offset[i], job->alloc_memory[i]);
+		for (j = 0; j < this_node->sockets; j++)
+			debug3("cons_res: %s: Job %u (+) node %s alloc_cores[%d] %u",
+				pre_err, job->job_id, 
+				node_record_table_ptr[host_index].name, 
+				j, p_ptr->alloc_cores[offset+j]);
+	}
+	last_cr_update_time = time(NULL);
 	return rc;
 }
 
-static int _clear_select_jobinfo(struct job_record *job_ptr)
+/* deallocate resources that were assigned to this job 
+ *
+ * if remove_all = 1: deallocate all resources
+ * if remove_all = 0: the job has been suspended, so just deallocate CPUs
+ */
+static int _rm_job_from_nodes(struct node_cr_record *select_node_ptr,
+			      struct select_cr_job *job, char *pre_err,
+			      int remove_all)
 {
-	int rc = SLURM_SUCCESS, i, j, nodes, job_id;
-	struct select_cr_job *job = NULL;
-	ListIterator iterator;
+	int host_index, i, j, k, rc = SLURM_SUCCESS;
 
-	xassert(job_ptr);
-	xassert(job_ptr->magic == JOB_MAGIC);
+	uint16_t memset = job->state & CR_JOB_ALLOCATED_MEM;
+	uint16_t cpuset = job->state & CR_JOB_ALLOCATED_CPUS;
+	uint16_t remove_memory = 0;
 
-	if (list_count(select_cr_job_list) == 0)
+	if (!memset && !cpuset)
 		return rc;
+	if (!cpuset && !remove_all)
+		return rc;
+	if (memset && remove_all &&
+	    ((cr_type == CR_CORE_MEMORY) || (cr_type == CR_CPU_MEMORY) ||
+	     (cr_type == CR_MEMORY) || (cr_type == CR_SOCKET_MEMORY))) {
+	 	remove_memory = 1;
+		job->state &= ~CR_JOB_ALLOCATED_MEM;
+	}
+	if (cpuset)
+	 	job->state &= ~CR_JOB_ALLOCATED_CPUS;
 
-	job_id = job_ptr->job_id;
-	iterator = list_iterator_create(select_cr_job_list);
-	while ((job = (struct select_cr_job *) list_next(iterator))) {
-		if (job->job_id != job_id)
+	i = -1;
+	for (host_index = 0; host_index < select_node_cnt; host_index++) {
+		struct node_cr_record *this_node;
+		struct part_cr_record *p_ptr;
+		uint16_t offset;
+		
+		if (bit_test(job->node_bitmap, host_index) == 0)
 			continue;
-		if (job->state & CR_JOB_STATE_SUSPENDED)
-			nodes = 0;
-		else
-			nodes = job->nhosts;
-		for (i = 0; i < nodes; i++) {
-			struct node_cr_record *this_node;
-			this_node = find_cr_node_record(job->host[i]);
-			if (this_node == NULL) {
-				error("cons_res: could not find node %s",
-				      job->host[i]);
-				rc = SLURM_ERROR; 
-				goto out;
+
+		this_node = &select_node_ptr[host_index];
+		i++;
+
+		/* Update this nodes allocated resources, beginning with
+		 * memory (if applicable) */
+		if (remove_memory) {
+			if (this_node->alloc_memory >= job->alloc_memory[i])
+				this_node->alloc_memory -= job->alloc_memory[i];
+			else {
+				error("%s: alloc_memory underflow on %s",
+				      pre_err, this_node->node_ptr->name);
+				this_node->alloc_memory = 0;
+				rc = SLURM_ERROR;  
 			}
-			
-			/* Updating this node allocated resources */
-			switch(cr_type) {
-			case CR_SOCKET:
-			case CR_SOCKET_MEMORY:
-				if (this_node->alloc_lps >= job->alloc_lps[i])
-					this_node->alloc_lps -= job->alloc_lps[i];
-				else {
-					error("cons_res: alloc_lps underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;
-				}
-				if (this_node->alloc_sockets >= job->alloc_sockets[i])
-					this_node->alloc_sockets -= job->alloc_sockets[i];
+		}
+		
+		if (!cpuset)
+			continue;
+		
+		p_ptr = get_cr_part_ptr(this_node, job->job_ptr->part_ptr);
+		if (p_ptr == NULL) {
+			error("%s: could not find part %s", pre_err,
+			      job->job_ptr->partition);
+			continue;
+		}
+
+		/* If the offset is no longer valid, then the job was never
+		 * "allocated" on these cores (see add_job_to_nodes).
+		 * Therefore just continue. */
+		offset = job->node_offset[i];
+		if (offset > (this_node->sockets * (p_ptr->num_rows - 1))) {
+			rc = SLURM_ERROR;
+			continue;
+		}
+		
+		switch(cr_type) {
+		case CR_SOCKET_MEMORY:
+		case CR_SOCKET:
+		case CR_CORE_MEMORY:
+		case CR_CORE:
+			_chk_resize_job(job, i, this_node->sockets);
+			for (j = 0; j < this_node->sockets; j++) {
+				if (p_ptr->alloc_cores[offset+j] >= 
+						job->alloc_cores[i][j])
+					p_ptr->alloc_cores[offset+j] -= 
+							job->alloc_cores[i][j];
 				else {
-					error("cons_res: alloc_sockets underflow on %s",
-					      this_node->node_ptr->name);
+					error("%s: alloc_cores underflow on %s",
+					      pre_err, 
+					      node_record_table_ptr[host_index].name);
+					p_ptr->alloc_cores[offset+j] = 0;
 					rc = SLURM_ERROR;
 				}
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;  
-				}
-				if (rc == SLURM_ERROR) {
-					this_node->alloc_lps = 0;
-					this_node->alloc_sockets = 0;
-					this_node->alloc_memory = 0;
-					goto out;
-				}
-				break;
-			case CR_CORE:
-			case CR_CORE_MEMORY:
-				if (this_node->alloc_lps >= job->alloc_lps[i])
-					this_node->alloc_lps -= job->alloc_lps[i];
-				else {
-					error("cons_res: alloc_lps underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;
-				}
-				chk_resize_node(this_node, 
-						this_node->node_ptr->sockets);
-				chk_resize_job(job, i, this_node->num_sockets);
-				for (j =0; j < this_node->num_sockets; j++) {
-					if (this_node->alloc_cores[j] >= 
-							job->alloc_cores[i][j])
-						this_node->alloc_cores[j] -= 
-								job->alloc_cores[i][j];
-					else {
-						error("cons_res: alloc_cores underflow on %s",
-						      this_node->node_ptr->name);
-						rc = SLURM_ERROR;
-					}
-				}
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;  
-				}
-				if (rc == SLURM_ERROR) {
-					this_node->alloc_lps = 0;
-					for (j =0; j < this_node->num_sockets; j++) {
-						this_node->alloc_cores[j] = 0;
-					}
-					this_node->alloc_memory = 0;
-					goto out;
-				}
-				break;
-			case CR_MEMORY:
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					this_node->alloc_memory = 0;
-					rc = SLURM_ERROR;  
-					goto out;
-				}
-				break;
-			case CR_CPU:
-			case CR_CPU_MEMORY:
-				if (this_node->alloc_lps >= job->alloc_lps[i])
-					this_node->alloc_lps -= job->alloc_lps[i];
-				else {
-					error("cons_res: alloc_lps underflow on %s",
-					      this_node->node_ptr->name);
-					this_node->alloc_lps = 0;
-					rc = SLURM_ERROR;  
-					goto out;
-				}
-				if (cr_type == CR_CPU)
-					break;
+			}
+			break;
+		case CR_CPU_MEMORY:
+		case CR_CPU:
+			/* CPU count is stored in the first "core" */
+			if (p_ptr->alloc_cores[offset] >= job->alloc_cpus[i])
+				p_ptr->alloc_cores[offset] -=
+							job->alloc_cpus[i];
+			else {
+				error("%s: CPU underflow (%u - %u) on %s",
+				      pre_err, p_ptr->alloc_cores[offset],
+				      job->alloc_cpus[i], 
+				      node_record_table_ptr[host_index].name);
+				p_ptr->alloc_cores[offset] = 0;
+				rc = SLURM_ERROR;  
+			}
+			break;
+		default:
+			break;
+		}
 
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					this_node->alloc_memory = 0;
-					rc = SLURM_ERROR;  
-					goto out;
+		/* if all cores are available, set NODE_CR_AVAILABLE */
+		if (this_node->node_state != NODE_CR_AVAILABLE) {
+			/* need to scan all partitions */
+			struct part_cr_record *pptr;
+			int count = 0;
+			for (pptr = this_node->parts; pptr; pptr = pptr->next) {
+				/* just need to check single row partitions */
+				if (pptr->num_rows > 1)
+					continue;
+				k = pptr->num_rows * this_node->sockets;
+				for (j = 0; j < k; j++) {
+					count += p_ptr->alloc_cores[j];
 				}
-				break;
-			default:
-				break;
+				if (count)
+					break;
 			}
-#if(CR_DEBUG)
-			info("cons_res %u _clear_select_jobinfo (-) node %s "
-			     "alloc_ s %u lps %u",
-			     job->job_id, this_node->node_ptr->name, 
-			     this_node->alloc_sockets, 
-			     this_node->alloc_lps);
-			if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY))
-				for (j =0; j < this_node->num_sockets; j++)
-					info("cons_res %u _clear_select_jobinfo (-) "
-					     " node %s alloc_  c %u",
-					     job->job_id, this_node->node_ptr->name, 
-					     this_node->alloc_cores[j]);
-#endif
+			if (count == 0)
+				this_node->node_state = NODE_CR_AVAILABLE;
 		}
-	out:
-		slurm_mutex_lock(&cr_mutex);
-		list_remove(iterator);
-		slurm_mutex_unlock(&cr_mutex);
-		_xfree_select_cr_job(job);
-		break;
-	}
-	list_iterator_destroy(iterator);
-
-	debug3("cons_res: _clear_select_jobinfo Job_id %u: "
-	       "list_count: %d", job_ptr->job_id, 
-	       list_count(select_cr_job_list));
 
+		debug3("%s: Job %u (-) node %s alloc_mem %u offset %d",
+			pre_err, job->job_id, this_node->node_ptr->name,
+			this_node->alloc_memory, offset);
+		for (j = 0; j < this_node->sockets; j++)
+			debug3("cons_res: %s: Job %u (-) node %s alloc_cores[%d] %u",
+				pre_err, job->job_id, 
+				node_record_table_ptr[host_index].name, 
+				j, p_ptr->alloc_cores[offset+j]);
+	}
+	last_cr_update_time = time(NULL);
 	return rc;
 }
 
-static bool
-_enough_nodes(int avail_nodes, int rem_nodes, 
-	      uint32_t min_nodes, uint32_t req_nodes)
+static bool _enough_nodes(int avail_nodes, int rem_nodes, 
+			  uint32_t min_nodes, uint32_t req_nodes)
 {
 	int needed_nodes;
 
@@ -855,10 +1110,13 @@ _enough_nodes(int avail_nodes, int rem_nodes,
 extern int init(void)
 {
 #ifdef HAVE_XCPU
-	error("%s presently incompatible with XCPU use", plugin_name);
-	return SLURM_ERROR;
+	error("%s is incompatible with XCPU use", plugin_name);
+	fatal("Use SelectType=select/linear");
+#endif
+#ifdef HAVE_BG
+	error("%s is incompatable with BlueGene", plugin_name);
+	fatal("Use SelectType=select/bluegene");
 #endif
-
 	cr_type = (select_type_plugin_info_t)
 			slurmctld_conf.select_type_param;
 	info("%s loaded with argument %d ", plugin_name, cr_type);
@@ -877,11 +1135,6 @@ extern int fini(void)
 	_xfree_select_nodes(select_node_ptr, select_node_cnt);
 	select_node_ptr = NULL;
 	select_node_cnt = 0;
-	xfree(cr_node_hash_table);
-
-	_xfree_select_nodes(prev_select_node_ptr, prev_select_node_cnt);
-	prev_select_node_ptr = NULL;
-	prev_select_node_cnt = 0;
 
 	verbose("%s shutting down ...", plugin_name);
 	return SLURM_SUCCESS;
@@ -964,17 +1217,19 @@ static int _cr_read_state_buffer(int fd, char **data_p, int *data_size_p)
 static int _cr_pack_job(struct select_cr_job *job, Buf buffer)
 {
     	int i;
-	uint16_t nhosts = job->nhosts;
+	uint32_t nhosts = job->nhosts;
 
+	/* Do not write job->state since we re-establish
+	 * the job's state on the nodes at restart time.
+	 * Likewise for job_ptr and node_bitmap. */
 	pack32(job->job_id, buffer);
-	pack16(job->state, buffer);
 	pack32(job->nprocs, buffer);
-	pack16(job->nhosts, buffer);
+	pack32(job->nhosts, buffer);
+	pack16(job->node_req, buffer);
 
-	packstr_array(job->host, nhosts, buffer);
 	pack16_array(job->cpus, nhosts, buffer);
-	pack16_array(job->alloc_lps, nhosts, buffer);
-	pack16_array(job->alloc_sockets, nhosts, buffer);
+	pack16_array(job->alloc_cpus, nhosts, buffer);
+	pack16_array(job->node_offset, nhosts, buffer);
 
 	if (job->alloc_cores) {
 		pack16((uint16_t) 1, buffer);
@@ -988,48 +1243,27 @@ static int _cr_pack_job(struct select_cr_job *job, Buf buffer)
 	}
 	pack32_array(job->alloc_memory, nhosts, buffer);
 
-	pack16(job->max_sockets, buffer);
-	pack16(job->max_cores, buffer);
-	pack16(job->max_threads, buffer);
-	pack16(job->min_sockets, buffer);
-	pack16(job->min_cores, buffer);
-	pack16(job->min_threads, buffer);
-	pack16(job->ntasks_per_node, buffer);
-	pack16(job->ntasks_per_socket, buffer);
-	pack16(job->ntasks_per_core, buffer);
-	pack16(job->cpus_per_task, buffer);
-
-	pack_bit_fmt(job->node_bitmap, buffer);
-	pack16(_bitstr_bits(job->node_bitmap), buffer);
-
 	return 0;
 }
 
 static int _cr_unpack_job(struct select_cr_job *job, Buf buffer)
 {
     	int i;
-    	uint16_t len16, have_alloc_cores;
+    	uint16_t have_alloc_cores;
     	uint32_t len32;
-	int32_t nhosts = 0;
-	char *bit_fmt = NULL;
-	uint16_t bit_cnt; 
+	uint32_t nhosts = 0;
+	uint16_t bit_cnt;
 
 	safe_unpack32(&job->job_id, buffer);
-	safe_unpack16(&job->state, buffer);
 	safe_unpack32(&job->nprocs, buffer);
-	safe_unpack16(&job->nhosts, buffer);
+	safe_unpack32(&job->nhosts, buffer);
+	safe_unpack16(&bit_cnt, buffer);
 	nhosts = job->nhosts;
-
-	safe_unpackstr_array(&job->host, &len16, buffer);
-	if (len16 != nhosts) {
-		error("cons_res unpack_job: expected %u hosts, saw %u",
-				nhosts, len16);
-		goto unpack_error;
-	}
+	job->node_req = bit_cnt;
 
 	safe_unpack16_array(&job->cpus, &len32, buffer);
-	safe_unpack16_array(&job->alloc_lps, &len32, buffer);
-	safe_unpack16_array(&job->alloc_sockets, &len32, buffer);
+	safe_unpack16_array(&job->alloc_cpus, &len32, buffer);
+	safe_unpack16_array(&job->node_offset, &len32, buffer);
 
 	safe_unpack16(&have_alloc_cores, buffer);
 	if (have_alloc_cores) {
@@ -1048,34 +1282,10 @@ static int _cr_unpack_job(struct select_cr_job *job, Buf buffer)
 	if (len32 != nhosts)
 		 goto unpack_error;
 
-	safe_unpack16(&job->max_sockets, buffer);
-	safe_unpack16(&job->max_cores, buffer);
-	safe_unpack16(&job->max_threads, buffer);
-	safe_unpack16(&job->min_sockets, buffer);
-	safe_unpack16(&job->min_cores, buffer);
-	safe_unpack16(&job->min_threads, buffer);
-	safe_unpack16(&job->ntasks_per_node, buffer);
-	safe_unpack16(&job->ntasks_per_socket, buffer);
-	safe_unpack16(&job->ntasks_per_core, buffer);
-	safe_unpack16(&job->cpus_per_task, buffer);
-
-	safe_unpackstr_xmalloc(&bit_fmt, &len16, buffer);
-	safe_unpack16(&bit_cnt, buffer);
-	if (bit_fmt) {
-                job->node_bitmap = bit_alloc(bit_cnt);
-                if (job->node_bitmap == NULL)
-                        fatal("bit_alloc: %m");
-                if (bit_unfmt(job->node_bitmap, bit_fmt)) {
-                        error("error recovering exit_node_bitmap from %s",
-                                bit_fmt);
-                }
-                xfree(bit_fmt);
-	}
 	return 0;
 
 unpack_error:
 	_xfree_select_cr_job(job);
-	xfree(bit_fmt);
 	return -1;
 }
 
@@ -1085,7 +1295,7 @@ extern int select_p_state_save(char *dir_name)
 	ListIterator job_iterator;
 	struct select_cr_job *job = NULL;
 	Buf buffer = NULL;
-	int state_fd, i;
+	int state_fd;
 	uint16_t job_cnt;
 	char *file_name = NULL;
 	static time_t last_save_time;
@@ -1101,8 +1311,8 @@ extern int select_p_state_save(char *dir_name)
         (void) unlink(file_name);
         state_fd = creat (file_name, 0600);
         if (state_fd < 0) {
-                error ("Can't save state, error creating file %s",
-                        file_name);
+                error("Can't save state, error creating file %s", file_name);
+		xfree(file_name);
                 return SLURM_ERROR;
 	}
 
@@ -1126,25 +1336,6 @@ extern int select_p_state_save(char *dir_name)
 		list_iterator_destroy(job_iterator);
 	} else
 		pack16((uint16_t) 0, buffer);	/* job count */
-
-	/*** pack the node_cr_record array ***/
-	pack32((uint32_t)select_node_cnt, buffer);
-	for (i = 0; i < select_node_cnt; i++) {
-		/*** don't save select_node_ptr[i].node_ptr ***/
-		packstr((char*)select_node_ptr[i].node_ptr->name, buffer);
-		pack16(select_node_ptr[i].alloc_lps, buffer);
-		pack16(select_node_ptr[i].alloc_sockets, buffer);
-		pack32(select_node_ptr[i].alloc_memory, buffer);
-		pack16(select_node_ptr[i].num_sockets, buffer);
-		if (select_node_ptr[i].alloc_cores) {
-			uint16_t nsockets = select_node_ptr[i].num_sockets;
-			pack16((uint16_t) 1, buffer);
-			pack16_array(select_node_ptr[i].alloc_cores,
-							nsockets, buffer);
-		} else {
-			pack16((uint16_t) 0, buffer);
-		}
-	}
 	slurm_mutex_unlock(&cr_mutex);
 
 	/*** close the state file ***/
@@ -1160,101 +1351,10 @@ extern int select_p_state_save(char *dir_name)
 }
 
 
-/* _cr_find_prev_node
- *	Return the index in the previous node list for the host
- *	with the given name.  The previous index matched is used
- *	as a starting point in to achieve O(1) performance when
- *	matching node data in sequence between two identical lists
- *	of hosts
+/* This is Part 2 of a 4-part procedure which can be found in
+ * src/slurmctld/read_config.c. See select_p_node_init for the
+ * whole story.
  */
-static int _cr_find_prev_node(char *name, int prev_i)
-{
-    	int i, cnt = 0;
-    	if (prev_i < 0) {
-	    	prev_i = -1;
-	}
-
-	/* scan forward from previous index for a match */
-	for (i = prev_i + 1; i < prev_select_node_cnt; i++) {
-		cnt++;
-		if (strcmp(name, prev_select_node_ptr[i].name) == 0) {
-			debug3("_cr_find_prev_node fwd: %d %d cmp", i, cnt);
-		    	return i;
-		}
-	}
-
-	/* if not found, scan from beginning to previous index for a match */
-	for (i = 0; i < MIN(prev_i + 1, prev_select_node_cnt); i++) {
-		cnt++;
-		if (strcmp(name, prev_select_node_ptr[i].name) == 0) {
-			debug3("_cr_find_prev_node beg: %d %d cmp", i, cnt);
-		    	return i;
-		}
-	}
-
-	debug3("_cr_find_prev_node none: %d %d cmp", -1, cnt);
-	return -1;	/* no match found */
-}
-
-static void _cr_restore_node_data(void)
-{
-	int i, j, tmp, prev_i;
-
-    	if ((select_node_ptr == NULL) || (select_node_cnt <= 0)) {
-	    	/* can't restore, nodes not yet initialized */
-		/* will attempt restore later in select_p_node_init */
-	    	return;
-	}
-
-    	if ((prev_select_node_ptr == NULL) || (prev_select_node_cnt <= 0)) {
-	    	/* can't restore, node restore data not present */
-		/* will attempt restore later in select_p_state_restore */
-	    	return;
-	}
-
-	prev_i = -1;		/* index of previous matched node */
-	for (i = 0; i < select_node_cnt; i++) {
-		tmp = _cr_find_prev_node(select_node_ptr[i].name, prev_i);
-		if (tmp < 0) {		/* not found in prev node list */
-		    	continue;	/* skip update for this node */
-		}
-		prev_i = tmp;	/* found a match */
-
-		debug2("recovered cons_res node data for %s",
-				    select_node_ptr[i].name);
-		
-		/* set alloc_lps/sockets/memory/cores to 0, and let
-		 * select_p_update_nodeinfo to recover the current info
-		 * from jobs (update_nodeinfo is called from reset_job_bitmaps) */
-		select_node_ptr[i].alloc_lps = 0;
-		select_node_ptr[i].alloc_sockets = 0;
-		select_node_ptr[i].alloc_memory = 0;
-		/* select_node_ptr[i].alloc_lps */
-		/*	= prev_select_node_ptr[prev_i].alloc_lps; */
-		/* select_node_ptr[i].alloc_sockets */
-		/*	= prev_select_node_ptr[prev_i].alloc_sockets; */
-		/* select_node_ptr[i].alloc_memory */
-		/*	= prev_select_node_ptr[prev_i].alloc_memory; */
-		if (select_node_ptr[i].alloc_cores &&
-			prev_select_node_ptr[prev_i].alloc_cores) {
-			chk_resize_node(&(select_node_ptr[i]),
-			    prev_select_node_ptr[prev_i].num_sockets);
-			select_node_ptr[i].num_sockets = 
-			    prev_select_node_ptr[prev_i].num_sockets;
-			for (j = 0; j < select_node_ptr[i].num_sockets; j++) {
-				select_node_ptr[i].alloc_cores[j] = 0;
-				/* select_node_ptr[i].alloc_cores[j] */
-				/*	 = prev_select_node_ptr[prev_i].alloc_cores[j]; */
-			}
-		}
-	}
-
-	/* Release any previous node data */
-	_xfree_select_nodes(prev_select_node_ptr, prev_select_node_cnt);
-	prev_select_node_ptr = NULL;
-	prev_select_node_cnt = 0;
-}
-
 extern int select_p_state_restore(char *dir_name)
 {
 	int error_code = SLURM_SUCCESS;
@@ -1262,7 +1362,6 @@ extern int select_p_state_restore(char *dir_name)
 	char *file_name = NULL;
 	struct select_cr_job *job;
 	Buf buffer = NULL;
-	uint16_t len16;
 	uint32_t len32;
 	char *data = NULL;
 	int data_size = 0;
@@ -1274,6 +1373,9 @@ extern int select_p_state_restore(char *dir_name)
 
 	info("cons_res: select_p_state_restore");
 
+	if (select_cr_job_list)		/* preserve current job info */
+		return SLURM_SUCCESS;
+
 	if (!dir_name) {
 		info("Starting cons_res with clean slate");
 		return SLURM_SUCCESS;
@@ -1304,7 +1406,7 @@ extern int select_p_state_restore(char *dir_name)
 	data = NULL;    /* now in buffer, don't xfree() */
 
 	/*** retrieve the plugin type ***/
-	safe_unpackstr_xmalloc(&restore_plugin_type, &len16, buffer);
+	safe_unpackstr_xmalloc(&restore_plugin_type, &len32, buffer);
 	safe_unpack32(&restore_plugin_version, buffer);
 	safe_unpack16(&restore_plugin_crtype,  buffer);
 	safe_unpack32(&restore_pstate_version, buffer);
@@ -1315,7 +1417,7 @@ extern int select_p_state_restore(char *dir_name)
 	    (restore_plugin_version != plugin_version) ||
 	    (restore_plugin_crtype  != cr_type) ||
 	    (restore_pstate_version != pstate_version)) { 
-		error ("Can't restore state, state version mismtach: "
+		error ("Can't restore state, state version mismatch: "
 			"saw %s/%u/%u/%u, expected %s/%u/%u/%u",
 			restore_plugin_type,
 			restore_plugin_version,
@@ -1346,39 +1448,17 @@ extern int select_p_state_restore(char *dir_name)
 		job = xmalloc(sizeof(struct select_cr_job));
 		if (_cr_unpack_job(job, buffer) != 0)
 			goto unpack_error;
-		if (find_job_record(job->job_id) != NULL) {
-			list_append(select_cr_job_list, job);
-			debug2("recovered cons_res job data for job %u", job->job_id);
-		} else {
-			debug2("recovered cons_res job data for unexistent job %u", 
+		job->job_ptr = find_job_record(job->job_id);
+		if (job->job_ptr == NULL) {
+			error("cons_res: recovered non-existent job %u",
 				job->job_id);
 			_xfree_select_cr_job(job);
-		}
-	}
-
-	/*** unpack the node_cr_record array ***/
-	if (prev_select_node_ptr) {	/* clear any existing data */
-		_xfree_select_nodes(prev_select_node_ptr, prev_select_node_cnt);
-		prev_select_node_ptr = NULL;
-		prev_select_node_cnt = 0;
-	}
-	safe_unpack32((uint32_t*)&prev_select_node_cnt, buffer);
-	prev_select_node_ptr = xmalloc(sizeof(struct node_cr_record) *
-							(prev_select_node_cnt));
-	for (i = 0; i < prev_select_node_cnt; i++) {
-		uint16_t have_alloc_cores = 0;
-		/*** don't restore prev_select_node_ptr[i].node_ptr ***/
-		safe_unpackstr_xmalloc(&(prev_select_node_ptr[i].name), 
-				       &len16, buffer);
-		safe_unpack16(&prev_select_node_ptr[i].alloc_lps, buffer);
-		safe_unpack16(&prev_select_node_ptr[i].alloc_sockets, buffer);
-		safe_unpack32(&prev_select_node_ptr[i].alloc_memory, buffer);
-		safe_unpack16(&prev_select_node_ptr[i].num_sockets, buffer);
-		safe_unpack16(&have_alloc_cores, buffer);
-		if (have_alloc_cores) {
-			safe_unpack16_array(
-			    	&prev_select_node_ptr[i].alloc_cores,
-				&len32, buffer);
+		} else {
+			/* NOTE: Nodes can be added or removed from the
+			 * system on a restart */
+			list_append(select_cr_job_list, job);
+			debug2("recovered cons_res job data for job %u", 
+				job->job_id);
 		}
 	}
 
@@ -1388,8 +1468,6 @@ extern int select_p_state_restore(char *dir_name)
         xfree(restore_plugin_type);
 	xfree(file_name);
 
-	_cr_restore_node_data();	/* if nodes already initialized */
-
 	return SLURM_SUCCESS;
 
 unpack_error:
@@ -1397,29 +1475,78 @@ unpack_error:
                 free_buf(buffer);
         xfree(restore_plugin_type);
 
-	/* don't keep possibly invalid prev_select_node_ptr */
-	_xfree_select_nodes(prev_select_node_ptr, prev_select_node_cnt);
-	prev_select_node_ptr = NULL;
-	prev_select_node_cnt = 0;
-
 	error ("Can't restore state, error unpacking file %s", file_name);
 	error ("Starting cons_res with clean slate");
 	return SLURM_SUCCESS;
 }
 
+/* This is Part 3 of a 4-part procedure which can be found in
+ * src/slurmctld/read_config.c. See select_p_node_init for the
+ * whole story.
+ */
 extern int select_p_job_init(List job_list)
 {
+	struct select_cr_job *job = NULL;
+	ListIterator iterator;
+	int suspend;
+
 	info("cons_res: select_p_job_init");
 
-    	if (!select_cr_job_list) {
+	/* Note: select_cr_job_list restored in select_p_state_restore
+	 * except on a cold-start */
+	if (!select_cr_job_list) {
 		select_cr_job_list = list_create(NULL);
+		return SLURM_SUCCESS;
 	}
 
-	/* Note: select_cr_job_list restored in select_p_state_restore */
+	/* Now synchronize the node information to the active jobs */
+	if (list_count(select_cr_job_list) == 0)
+		return SLURM_SUCCESS;
+
+	iterator = list_iterator_create(select_cr_job_list);
+	while ((job = (struct select_cr_job *) list_next(iterator))) {
+		job->job_ptr = find_job_record(job->job_id);
+		if (job->job_ptr == NULL) {
+			error("select_p_job_init: could not find job %u",
+			      job->job_id);
+			list_remove(iterator);
+			continue;
+		}
+		if (job->job_ptr->job_state == JOB_SUSPENDED)
+			suspend = 1;
+		else
+			suspend = 0;
+		if ((job->job_ptr->nodes == NULL) ||
+		    (node_name2bitmap(job->job_ptr->nodes, true,
+				      &job->node_bitmap))) {
+			error("cons_res: job %u has no allocated nodes",
+				job->job_id);
+			job->node_bitmap = bit_alloc(node_record_count);
+		}
+		_add_job_to_nodes(job, "select_p_job_init", suspend);
+	}
+	list_iterator_destroy(iterator);
+	last_cr_update_time = time(NULL);
 
 	return SLURM_SUCCESS;
 }
 
+/* This is Part 1 of a 4-part procedure which can be found in
+ * src/slurmctld/read_config.c. The whole story goes like this:
+ *
+ * Step 1: select_g_node_init       : initializes 'select_node_ptr' global array
+ *                                    sets node_ptr, node_name, and num_sockets
+ * Step 2: select_g_state_restore   : IFF a cons_res state file exists:
+ *                                    loads global 'select_cr_job_list' with
+ *                                    saved job data
+ * Step 3: select_g_job_init        : creates global 'select_cr_job_list' if
+ *                                    nothing was recovered from state file.
+ *                                    Rebuilds select_node_ptr global array.
+ * Step 4: select_g_update_nodeinfo : called from reset_job_bitmaps() with each
+ *                                    valid recovered job_ptr AND from
+ *                                    select_nodes(), this procedure adds job
+ *                                    data to the 'select_node_ptr' global array
+ */
 extern int select_p_node_init(struct node_record *node_ptr, int node_cnt)
 {
 	int i;
@@ -1441,31 +1568,31 @@ extern int select_p_node_init(struct node_record *node_ptr, int node_cnt)
 	select_node_cnt = node_cnt;
 	select_node_ptr = xmalloc(sizeof(struct node_cr_record) *
 							select_node_cnt);
+	select_fast_schedule = slurm_get_fast_schedule();
 
 	for (i = 0; i < select_node_cnt; i++) {
 		select_node_ptr[i].node_ptr = &node_ptr[i];
-		select_node_ptr[i].name     = xstrdup(node_ptr[i].name);
-		select_node_ptr[i].alloc_lps      = 0;
-		select_node_ptr[i].alloc_sockets  = 0;
-		select_node_ptr[i].alloc_memory   = 0;
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			info("select_g_node_init node:%s sockets:%u",
-			     select_node_ptr[i].name, 
-			     select_node_ptr[i].node_ptr->sockets);
-			select_node_ptr[i].num_sockets =
-			     select_node_ptr[i].node_ptr->sockets;
-			select_node_ptr[i].alloc_cores    = 
-				xmalloc(sizeof(int) * 
-					select_node_ptr[i].num_sockets);
+		if (select_fast_schedule) {
+			struct config_record *config_ptr;
+			config_ptr = node_ptr[i].config_ptr;
+			select_node_ptr[i].cpus        = config_ptr->cpus;
+			select_node_ptr[i].sockets     = config_ptr->sockets;
+			select_node_ptr[i].cores       = config_ptr->cores;
+			select_node_ptr[i].threads     = config_ptr->threads;
+			select_node_ptr[i].real_memory = config_ptr->real_memory;
+		} else {
+			select_node_ptr[i].cpus        = node_ptr[i].cpus;
+			select_node_ptr[i].sockets     = node_ptr[i].sockets;
+			select_node_ptr[i].cores       = node_ptr[i].cores;
+			select_node_ptr[i].threads     = node_ptr[i].threads;
+			select_node_ptr[i].real_memory = node_ptr[i].real_memory;
 		}
+		select_node_ptr[i].node_state = NODE_CR_AVAILABLE;
+		/* xmalloc initialized everything to zero, 
+		 * including alloc_memory and parts */
+		_create_node_part_array(&(select_node_ptr[i]));
 	}
 
-	_cr_restore_node_data();	/* if restore data present */
-
-	select_fast_schedule = slurm_get_fast_schedule();
-
-	_build_cr_node_hash_table();
-
 	return SLURM_SUCCESS;
 }
 
@@ -1474,36 +1601,38 @@ extern int select_p_block_init(List part_list)
 	return SLURM_SUCCESS;
 }
 
-/*
- * select_p_job_test - Given a specification of scheduling requirements, 
- *	identify the nodes which "best" satisfy the request.
- * 	"best" is defined as either single set of consecutive nodes satisfying 
- *	the request and leaving the minimum number of unused nodes OR 
- *	the fewest number of consecutive node sets
- * IN job_ptr - pointer to job being scheduled
- * IN/OUT bitmap - usable nodes are set on input, nodes not required to 
- *	satisfy the request are cleared, other left set
- * IN min_nodes - minimum count of nodes
- * IN req_nodes - requested (or desired) count of nodes
- * IN max_nodes - maximum count of nodes (0==don't care)
- * IN test_only - if true, only test if ever could run, not necessarily now,
- *	not used in this implementation
- * RET zero on success, EINVAL otherwise
- * globals (passed via select_p_node_init): 
- *	node_record_count - count of nodes configured
- *	node_record_table_ptr - pointer to global node table
- * NOTE: the job information that is considered for scheduling includes:
- *	req_node_bitmap: bitmap of specific nodes required by the job
- *	contiguous: allocated nodes must be sequentially located
- *	num_procs: minimum number of processors required by the job
- * NOTE: bitmap must be a superset of req_nodes at the time that 
- *	select_p_job_test is called
- */
-extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
-			     uint32_t min_nodes, uint32_t max_nodes, 
-			     uint32_t req_nodes, bool test_only)
+/* return the number of tasks that the given
+ * job can run on the indexed node */
+static int _get_task_cnt(struct job_record *job_ptr, const int node_index,
+			 int *task_cnt, int *freq, int size)
+{
+	int i, pos, tasks;
+	uint16_t * layout_ptr = NULL;
+
+	layout_ptr = job_ptr->details->req_node_layout;
+
+	pos = 0;
+	for (i = 0; i < size; i++) {
+		if (pos+freq[i] > node_index)
+			break;
+		pos += freq[i];
+	}
+	tasks = task_cnt[i];
+	if (layout_ptr && bit_test(job_ptr->details->req_node_bitmap, i)) {
+		pos = bit_get_pos_num(job_ptr->details->req_node_bitmap, i);
+		tasks = MIN(tasks, layout_ptr[pos]);
+	} else if (layout_ptr) {
+		tasks = 0; /* should not happen? */
+	}
+	return tasks;
+}
+
+static int _eval_nodes(struct job_record *job_ptr, bitstr_t * bitmap,
+		       uint32_t min_nodes, uint32_t max_nodes,
+		       uint32_t req_nodes, int *task_cnt, int *freq, 
+		       int array_size)
 {
-	int i, index, error_code = SLURM_ERROR, sufficient;
+	int i, f, index, error_code = SLURM_ERROR;
 	int *consec_nodes;	/* how many nodes we can add from this 
 				 * consecutive set of nodes */
 	int *consec_cpus;	/* how many nodes we can add from this 
@@ -1512,24 +1641,23 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 	int *consec_end;	/* where this consecutive set ends (index) */
 	int *consec_req;	/* are nodes from this set required 
 				 * (in req_bitmap) */
-	int consec_index, consec_size;
+	int consec_index, consec_size, sufficient;
 	int rem_cpus, rem_nodes;	/* remaining resources desired */
 	int best_fit_nodes, best_fit_cpus, best_fit_req;
-	int best_fit_location = 0, best_fit_sufficient;
-	int avail_cpus;
-	uint16_t plane_size = 0;
-	//int asockets, acores, athreads, acpus;
-	bool all_avail = false;
+	int best_fit_sufficient, best_fit_index = 0;
+	int avail_cpus, ll;	/* ll = layout array index */
 	struct multi_core_data *mc_ptr = NULL;
-	int ll; /* layout array index */
 	uint16_t * layout_ptr = NULL;
-
-	if (job_ptr->details)
-		layout_ptr = job_ptr->details->req_node_layout;
+	bool required_node;
 
 	xassert(bitmap);
+	
+	if (bit_set_count(bitmap) < min_nodes)
+		return error_code;
+
+	layout_ptr = job_ptr->details->req_node_layout;
+	mc_ptr = job_ptr->details->mc_ptr;
 
-	consec_index = 0;
 	consec_size = 50;	/* start allocation for 50 sets of 
 				 * consecutive nodes */
 	consec_cpus  = xmalloc(sizeof(int) * consec_size);
@@ -1539,53 +1667,50 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 	consec_req   = xmalloc(sizeof(int) * consec_size);
 
 	/* Build table with information about sets of consecutive nodes */
+	consec_index = 0;
 	consec_cpus[consec_index] = consec_nodes[consec_index] = 0;
 	consec_req[consec_index] = -1;	/* no required nodes here by default */
 
-	if (job_ptr->details)
-		mc_ptr = job_ptr->details->mc_ptr;
-
-	/* This is the case if -O/--overcommit  is true */ 
-	debug3("job_ptr->num_procs %u", job_ptr->num_procs);
-	if (mc_ptr && (job_ptr->num_procs == job_ptr->details->min_nodes)) {
-		job_ptr->num_procs *= MAX(1,mc_ptr->min_threads);
-		job_ptr->num_procs *= MAX(1,mc_ptr->min_cores);
-		job_ptr->num_procs *= MAX(1,mc_ptr->min_sockets);
-	}
-
 	rem_cpus = job_ptr->num_procs;
 	if (req_nodes > min_nodes)
 		rem_nodes = req_nodes;
 	else
 		rem_nodes = min_nodes;
-	for (index = 0, ll = -1; index < select_node_cnt; index++) {
-		if (layout_ptr && bit_test(job_ptr->details->req_node_bitmap, index))
+
+	i = 0;
+	f = 0;
+	for (index = 0, ll = -1; index < select_node_cnt; index++, f++) {
+		if (f >= freq[i]) {
+			f = 0;
+			i++;
+		}
+		if (job_ptr->details->req_node_bitmap) {
+			required_node =
+				bit_test(job_ptr->details->req_node_bitmap,
+					 index);
+		} else
+			required_node = false;
+		if (layout_ptr && required_node)
 			ll++;
 		if (bit_test(bitmap, index)) {
 			if (consec_nodes[consec_index] == 0)
 				consec_start[consec_index] = index;
-			if (!test_only)
-				all_avail = false;
-			else
-				all_avail = true;
-			avail_cpus = _get_avail_lps(job_ptr, index, all_avail);
-			if (layout_ptr
-			    && bit_test(job_ptr->details->req_node_bitmap, index)) {
+			avail_cpus = task_cnt[i];
+			if (layout_ptr && required_node){
 				avail_cpus = MIN(avail_cpus, layout_ptr[ll]);
 			} else if (layout_ptr) {
 				avail_cpus = 0; /* should not happen? */
 			}
-			if (job_ptr->details->req_node_bitmap 
-			    &&  bit_test(job_ptr->details->req_node_bitmap, index)
-			    &&  (max_nodes > 0)) {
+			if ((max_nodes > 0) && required_node) {
 				if (consec_req[consec_index] == -1) {
 					/* first required node in set */
 					consec_req[consec_index] = index;
 				}
 				rem_cpus -= avail_cpus;
 				rem_nodes--;
+				/* leaving bitmap set, decrement max limit */
 				max_nodes--;
-			} else {	/* node not required (yet) */
+			} else {	/* node not selected (yet) */
 				bit_clear(bitmap, index);
 				consec_cpus[consec_index] += avail_cpus;
 				consec_nodes[consec_index]++;
@@ -1598,16 +1723,11 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 			consec_end[consec_index] = index - 1;
 			if (++consec_index >= consec_size) {
 				consec_size *= 2;
-				xrealloc(consec_cpus,
-					 sizeof(int) * consec_size);
-				xrealloc(consec_nodes,
-					 sizeof(int) * consec_size);
-				xrealloc(consec_start,
-					 sizeof(int) * consec_size);
-				xrealloc(consec_end,
-					 sizeof(int) * consec_size);
-				xrealloc(consec_req,
-					 sizeof(int) * consec_size);
+				xrealloc(consec_cpus, sizeof(int)*consec_size);
+				xrealloc(consec_nodes, sizeof(int)*consec_size);
+				xrealloc(consec_start, sizeof(int)*consec_size);
+				xrealloc(consec_end, sizeof(int)*consec_size);
+				xrealloc(consec_req, sizeof(int)*consec_size);
 			}
 			consec_cpus[consec_index] = 0;
 			consec_nodes[consec_index] = 0;
@@ -1617,6 +1737,12 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 	if (consec_nodes[consec_index] != 0)
 		consec_end[consec_index++] = index - 1;
 	
+	for (i = 0; i < consec_index; i++) {
+		debug3("cons_res: eval_nodes: %d consec c=%d n=%d b=%d e=%d r=%d",
+			i, consec_cpus[i], consec_nodes[i], consec_start[i],
+			consec_end[i], consec_req[i]);
+	}
+	
 	/* accumulate nodes from these sets of consecutive nodes until */
 	/*   sufficient resources have been accumulated */
 	while (consec_index && (max_nodes > 0)) {
@@ -1635,15 +1761,13 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 			/* tightest fit (less resource waste) OR */
 			/* nothing yet large enough, but this is biggest */
 			if ((best_fit_nodes == 0) ||
-			    ((best_fit_req == -1) && (consec_req[i] != -1))
-			    || (sufficient && (best_fit_sufficient == 0))
-			    || (sufficient
-				&& (consec_cpus[i] < best_fit_cpus))
-			    || ((sufficient == 0)
-				&& (consec_cpus[i] > best_fit_cpus))) {
+			    ((best_fit_req == -1) && (consec_req[i] != -1)) ||
+			    (sufficient && (best_fit_sufficient == 0)) ||
+			    (sufficient && (consec_cpus[i] < best_fit_cpus)) ||
+			    (!sufficient && (consec_cpus[i] > best_fit_cpus))) {
 				best_fit_cpus = consec_cpus[i];
 				best_fit_nodes = consec_nodes[i];
-				best_fit_location = i;
+				best_fit_index = i;
 				best_fit_req = consec_req[i];
 				best_fit_sufficient = sufficient;
 			}
@@ -1660,7 +1784,7 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 			 * select nodes from this set, first working up
 			 * then down from the required nodes */
 			for (i = best_fit_req;
-			     i <= consec_end[best_fit_location]; i++) {
+			     i <= consec_end[best_fit_index]; i++) {
 				if ((max_nodes <= 0)
 				    ||  ((rem_nodes <= 0) && (rem_cpus <= 0)))
 					break;
@@ -1669,41 +1793,21 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 				bit_set(bitmap, i);
 				rem_nodes--;
 				max_nodes--;
-				if (!test_only)
-					all_avail = false;
-				else
-					all_avail = true;
-				avail_cpus = _get_avail_lps(job_ptr, i, all_avail);
-				if (layout_ptr
-				    && bit_test(job_ptr->details->req_node_bitmap, i)) {
-					ll = bit_get_pos_num(job_ptr->details->
-							req_node_bitmap, i);
-					avail_cpus = MIN(avail_cpus, layout_ptr[ll]);
-				} else if (layout_ptr) {
-					avail_cpus = 0; /* should not happen? */
-				}
+				avail_cpus = _get_task_cnt(job_ptr, i,
+							   task_cnt, freq,
+							   array_size);
 				rem_cpus -= avail_cpus;
 			}
 			for (i = (best_fit_req - 1);
-			     i >= consec_start[best_fit_location]; i--) {
+			     i >= consec_start[best_fit_index]; i--) {
 				if ((max_nodes <= 0)
 				    ||  ((rem_nodes <= 0) && (rem_cpus <= 0)))
 					break;
 				if (bit_test(bitmap, i)) 
 					continue;
-				if (!test_only)
-					all_avail = false;
-				else
-					all_avail = true;
-				avail_cpus = _get_avail_lps(job_ptr, i, all_avail);
-				if (layout_ptr
-				    && bit_test(job_ptr->details->req_node_bitmap, i)) {
-					ll = bit_get_pos_num(job_ptr->details->
-							req_node_bitmap, i);
-					avail_cpus = MIN(avail_cpus, layout_ptr[ll]);
-				} else if (layout_ptr) {
-					avail_cpus = 0; /* should not happen? */
-				}
+				avail_cpus = _get_task_cnt(job_ptr, i,
+							   task_cnt, freq,
+							   array_size);
 				if(avail_cpus <= 0)
 					continue;
 				rem_cpus -= avail_cpus;
@@ -1712,26 +1816,16 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 				max_nodes--;
 			}
 		} else {
-			for (i = consec_start[best_fit_location];
-			     i <= consec_end[best_fit_location]; i++) {
+			for (i = consec_start[best_fit_index];
+			     i <= consec_end[best_fit_index]; i++) {
 				if ((max_nodes <= 0)
 				    || ((rem_nodes <= 0) && (rem_cpus <= 0)))
 					break;
 				if (bit_test(bitmap, i))
 					continue;
-				if (!test_only)
-					all_avail = false;
-				else
-					all_avail = true;
-				avail_cpus = _get_avail_lps(job_ptr, i, all_avail);
-				if (layout_ptr
-				    && bit_test(job_ptr->details->req_node_bitmap, i)) {
-					ll = bit_get_pos_num(job_ptr->details->
-							req_node_bitmap, i);
-					avail_cpus = MIN(avail_cpus, layout_ptr[ll]);
-				} else if (layout_ptr) {
-					avail_cpus = 0; /* should not happen? */
-				}
+				avail_cpus = _get_task_cnt(job_ptr, i,
+							   task_cnt, freq,
+							   array_size);
 				if(avail_cpus <= 0)
 					continue;
 				rem_cpus -= avail_cpus;
@@ -1746,162 +1840,14 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 			error_code = SLURM_SUCCESS;
 			break;
 		}
-		consec_cpus[best_fit_location] = 0;
-		consec_nodes[best_fit_location] = 0;
+		consec_cpus[best_fit_index] = 0;
+		consec_nodes[best_fit_index] = 0;
 	}
 	
 	if (error_code && (rem_cpus <= 0)
 	    && _enough_nodes(0, rem_nodes, min_nodes, req_nodes))
 		error_code = SLURM_SUCCESS;
 
-	if (error_code != SLURM_SUCCESS)
-		goto cleanup;
-	
-	if (!test_only) {
-		int jobid, job_nodecnt, j, k;
-		bitoff_t size;
-		static struct select_cr_job *job;
-		job = xmalloc(sizeof(struct select_cr_job));
-		jobid = job_ptr->job_id;
-		job->job_id = jobid;
-		job_nodecnt = bit_set_count(bitmap);
-		job->nhosts = job_nodecnt;
-		job->nprocs = MAX(job_ptr->num_procs, job_nodecnt);
-		job->cpus_per_task = job_ptr->details->cpus_per_task;
-		job->ntasks_per_node = job_ptr->details->ntasks_per_node;
-		if (mc_ptr) {
-			plane_size       = mc_ptr->plane_size;
-			job->max_sockets = mc_ptr->max_sockets;
-			job->max_cores   = mc_ptr->max_cores;
-			job->max_threads = mc_ptr->max_threads;
-			job->min_sockets = mc_ptr->min_sockets;
-			job->min_cores   = mc_ptr->min_cores;
-			job->min_threads = mc_ptr->min_threads;
-			job->ntasks_per_socket = mc_ptr->ntasks_per_socket;
-			job->ntasks_per_core   = mc_ptr->ntasks_per_core;
-		} else {
-			job->max_sockets = 0xffff;
-			job->max_cores   = 0xffff;
-			job->max_threads = 0xffff;
-			job->min_sockets = 1;
-			job->min_cores   = 1;
-			job->min_threads = 1;
-			job->ntasks_per_socket = 0;
-			job->ntasks_per_core   = 0;
-		}
-
-		size = bit_size(bitmap);
-		job->node_bitmap = (bitstr_t *) bit_alloc(size);
-		if (job->node_bitmap == NULL)
-			fatal("bit_alloc malloc failure");
-		for (i = 0; i < size; i++) {
-			if (!bit_test(bitmap, i))
-				continue;
-			bit_set(job->node_bitmap, i);
-		}
-		
-		job->host          = (char **)    xmalloc(job->nhosts * sizeof(char *));
-		job->cpus          = (uint16_t *) xmalloc(job->nhosts * sizeof(uint16_t));
-		job->alloc_lps     = (uint16_t *) xmalloc(job->nhosts * sizeof(uint16_t));
-		job->alloc_sockets = (uint16_t *) xmalloc(job->nhosts * sizeof(uint16_t));
-		job->alloc_memory  = (uint32_t *) xmalloc(job->nhosts * sizeof(uint32_t));
-		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-			job->num_sockets = (uint16_t *)  xmalloc(job->nhosts * sizeof(uint16_t));
-			job->alloc_cores = (uint16_t **) xmalloc(job->nhosts * sizeof(uint16_t *));
-			for (i = 0; i < job->nhosts; i++) {
-				job->num_sockets[i] = 
-					node_record_table_ptr[i].sockets;
-				job->alloc_cores[i] = (uint16_t *) xmalloc(
-					job->num_sockets[i] * sizeof(uint16_t));
-			}
-		}
-
-		j = 0;
-		for (i = 0, ll = -1; i < node_record_count; i++) {
-			if (layout_ptr
-			    && bit_test(job_ptr->details->req_node_bitmap, i)) {
-				ll ++;
-			}
-			if (bit_test(bitmap, i) == 0)
-				continue;
-			if (j >= job->nhosts) {
-				error("select_cons_res: job nhosts too small\n");
-				break;
-			}
-			job->host[j] = xstrdup(node_record_table_ptr[i].name);
-			job->cpus[j] = node_record_table_ptr[i].cpus;
-			if (layout_ptr
-			    && bit_test(job_ptr->details->req_node_bitmap, i)) {
-				job->cpus[j] = MIN(job->cpus[j], layout_ptr[ll]);
-			} else if (layout_ptr) {
-				job->cpus[j] = 0;
-			}
-			job->alloc_lps[j] = 0;
-			job->alloc_sockets[j] = 0;
-			job->alloc_memory[j] = job_ptr->details->job_max_memory; 
-			if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)) {
-				chk_resize_job(job, j, node_record_table_ptr[i].sockets);
-				job->num_sockets[j] = node_record_table_ptr[i].sockets;
-				for (k = 0; k < job->num_sockets[j]; k++)
-					job->alloc_cores[j][k]   = 0;
-			}
-			j++;
-		}
-
-		if (job_ptr->details->shared == 0) {
-			/* Nodes need to be allocated in dedicated
-			   mode. User has specified the --exclusive
-			   switch */
-			error_code = cr_exclusive_dist(job, cr_type);
-		} else {
-			/* Determine the number of logical processors
-			   per node needed for this job */
-			/* Make sure below matches the layouts in
-			 * lllp_distribution in
-			 * plugins/task/affinity/dist_task.c */
-			switch(job_ptr->details->task_dist) {
-			case SLURM_DIST_BLOCK_BLOCK:
-			case SLURM_DIST_CYCLIC_BLOCK:
-				error_code = cr_dist(job, 0, 
-						     cr_type,
-						     select_fast_schedule); 
-				break;
-			case SLURM_DIST_BLOCK:
-			case SLURM_DIST_CYCLIC:				
-			case SLURM_DIST_BLOCK_CYCLIC:
-			case SLURM_DIST_CYCLIC_CYCLIC:
-			case SLURM_DIST_UNKNOWN:
-				error_code = cr_dist(job, 1, 
-						     cr_type,
-						     select_fast_schedule); 
-				break;
-			case SLURM_DIST_PLANE:
-				error_code = cr_plane_dist(job, 
-							   plane_size,
-							   cr_type); 
-				break;
-			case SLURM_DIST_ARBITRARY:
-			default:
-				error_code = compute_c_b_task_dist(job, 
-								   cr_type,
-								   select_fast_schedule);
-				if (error_code != SLURM_SUCCESS) {
-					error(" Error in compute_c_b_task_dist");
-					return error_code;
-				}
-				break;
-			}
-		}
-		if (error_code != SLURM_SUCCESS) {
-			_xfree_select_cr_job(job);
-			goto cleanup;
-		}
-
-		_append_to_job_list(job);
-		last_cr_update_time = time(NULL);
-	}
-	
- cleanup:
 	xfree(consec_cpus);
 	xfree(consec_nodes);
 	xfree(consec_start);
@@ -1910,256 +1856,912 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 	return error_code;
 }
 
-extern int select_p_job_begin(struct job_record *job_ptr)
+/* this is an intermediary step between select_p_job_test and _eval_nodes
+ * to tackle the knapsack problem. This code incrementally removes nodes
+ * with low task counts for the job and re-evaluates each result */
+static int _select_nodes(struct job_record *job_ptr, bitstr_t * bitmap,
+			 uint32_t min_nodes, uint32_t max_nodes, 
+			 uint32_t req_nodes, int *task_cnt, int *freq, 
+			 int array_size)
 {
-	return SLURM_SUCCESS;
-}
+	int i, b, count, ec, most_tasks = 0;
+	bitstr_t *origmap, *reqmap = NULL;
 
-extern int select_p_job_ready(struct job_record *job_ptr)
-{
-	return SLURM_SUCCESS;
-}
+	/* allocated node count should never exceed num_procs, right? 
+	 * if so, then this should be done earlier and max_nodes
+	 * could be used to make this process more efficient (truncate
+	 * # of available nodes when (# of idle nodes == max_nodes)*/
+	if (max_nodes > job_ptr->num_procs)
+		max_nodes = job_ptr->num_procs;
 
-extern int select_p_job_fini(struct job_record *job_ptr)
-{
-	int rc = SLURM_SUCCESS;
-	rc = _clear_select_jobinfo(job_ptr);
-	last_cr_update_time = time(NULL);
-	if (rc != SLURM_SUCCESS) {
-		error(" error for %u in select/cons_res: "
-		      "_clear_select_jobinfo",
-		      job_ptr->job_id);
+	origmap = bit_copy(bitmap);
+	if (origmap == NULL)
+		fatal("bit_copy malloc failure");
+
+	ec = _eval_nodes(job_ptr, bitmap, min_nodes, max_nodes,
+			 req_nodes, task_cnt, freq, array_size);
+
+	if (ec == SLURM_SUCCESS) {
+		bit_free(origmap);
+		return ec;
 	}
 
-	return rc;
-}
+	/* This nodeset didn't work. To avoid a possible knapsack problem, 
+	 * incrementally remove nodes with low task counts and retry */
 
-extern int select_p_job_suspend(struct job_record *job_ptr)
-{
-	ListIterator job_iterator;
-	struct select_cr_job *job;
-	int i, j, rc = ESLURM_INVALID_JOB_ID;
- 
-	xassert(job_ptr);
-	xassert(select_cr_job_list);
+	for (i = 0; i < array_size; i++) {
+		if (task_cnt[i] > most_tasks)
+			most_tasks = task_cnt[i];
+	}
 
-	job_iterator = list_iterator_create(select_cr_job_list);
-	if (job_iterator == NULL)
-		fatal("list_iterator_create: %m");
-	while ((job = (struct select_cr_job *) list_next(job_iterator))) {
-		if (job->job_id != job_ptr->job_id)
+	if (job_ptr->details->req_node_bitmap)
+		reqmap = job_ptr->details->req_node_bitmap;
+	
+	for (count = 0; count < most_tasks; count++) {
+		int nochange = 1;
+		bit_or(bitmap, origmap);
+		for (i = 0, b = 0; i < array_size; i++) {
+			if (task_cnt[i] != -1 && task_cnt[i] <= count) {
+				int j = 0, x = b;
+				for (; j < freq[i]; j++, x++) {
+					if (!bit_test(bitmap, x))
+						continue;
+					if (reqmap && bit_test(reqmap, x)) {
+						bit_free(origmap);
+						return SLURM_ERROR;
+					}
+					nochange = 0;
+					bit_clear(bitmap, x);
+					bit_clear(origmap, x);
+				}
+			}
+			b += freq[i];
+		}
+		if (nochange)
 			continue;
-		if (job->state & CR_JOB_STATE_SUSPENDED) {
-			error("cons_res: job %u already suspended",
-				job->job_id);
-			break;
+		ec = _eval_nodes(job_ptr, bitmap, min_nodes, max_nodes,
+				 req_nodes, task_cnt, freq, array_size);
+		if (ec == SLURM_SUCCESS) {
+			bit_free(origmap);
+			return ec;
 		}
+	}
+	bit_free(origmap);
+	return ec;
+}
 
-		rc = SLURM_SUCCESS;
-		last_cr_update_time = time(NULL);
-		job->state |= CR_JOB_STATE_SUSPENDED;
-		for (i = 0; i < job->nhosts; i++) {
-			struct node_cr_record *this_node;
-			this_node = find_cr_node_record(job->host[i]);
-			if (this_node == NULL) {
-				error("cons_res: could not find node %s",
-				      job->host[i]);
-				rc = SLURM_ERROR; 
-				break;
-			}
-			
-			/* Updating this node allocated resources */
-			switch(cr_type) {
-			case CR_SOCKET:
-			case CR_SOCKET_MEMORY:
-				if (this_node->alloc_lps >= job->alloc_lps[i])
-					this_node->alloc_lps -= job->alloc_lps[i];
-				else {
-					error("cons_res: alloc_lps underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;
-				}
-				if (this_node->alloc_sockets >= 
-						job->alloc_sockets[i]) {
-					this_node->alloc_sockets -= 
-						job->alloc_sockets[i];
-				} else {
-					error("cons_res: alloc_sockets underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;
-				}
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;  
-				}
-				if (rc == SLURM_ERROR) {
-					this_node->alloc_lps = 0;
-					this_node->alloc_sockets = 0;
-					this_node->alloc_memory = 0;
-				}
+/* test to see if any shared partitions are running jobs */
+static int _is_node_sharing(struct node_cr_record *this_node)
+{
+	int i, size;
+	struct part_cr_record *p_ptr = this_node->parts;
+	for (; p_ptr; p_ptr = p_ptr->next) {
+		if (p_ptr->num_rows < 2)
+			continue;
+		size = p_ptr->num_rows * this_node->sockets;
+		for (i = 0; i < size; i++) {
+			if (p_ptr->alloc_cores[i])
+				return 1;
+		}
+	}
+	return 0;
+
+}
+
+/* test to see if the given node has any jobs running on it */
+static int _is_node_busy(struct node_cr_record *this_node)
+{
+	int i, size;
+	struct part_cr_record *p_ptr = this_node->parts;
+	for (; p_ptr; p_ptr = p_ptr->next) {
+		size = p_ptr->num_rows * this_node->sockets;
+		for (i = 0; i < size; i++) {
+			if (p_ptr->alloc_cores[i])
+				return 1;
+		}
+	}
+	return 0;
+}
+
+/*
+ * Determine which of these nodes are usable by this job
+ *
+ * Remove nodes from the bitmap that don't have enough memory to
+ * support the job. Return SLURM_ERROR if a required node doesn't
+ * have enough memory.
+ *
+ * if node_state = NODE_CR_RESERVED, clear bitmap (if node is required
+ *                                   then should we return NODE_BUSY!?!)
+ *
+ * if node_state = NODE_CR_ONE_ROW, then this node can only be used by
+ *                                  another NODE_CR_ONE_ROW job
+ *
+ * if node_state = NODE_CR_AVAILABLE AND:
+ *  - job_node_req = NODE_CR_RESERVED, then we need idle nodes
+ *  - job_node_req = NODE_CR_ONE_ROW, then we need idle or non-sharing nodes
+ */
+static int _verify_node_state(struct node_cr_record *select_node_ptr,
+			      struct job_record *job_ptr, bitstr_t * bitmap,
+			      enum node_cr_state job_node_req)
+{
+	int i;
+	uint32_t free_mem;
+
+	for (i = 0; i < select_node_cnt; i++) {
+		if (!bit_test(bitmap, i))
+			continue;
+
+		if ((job_ptr->details->job_min_memory) &&
+		    ((cr_type == CR_CORE_MEMORY) || (cr_type == CR_CPU_MEMORY) || 
+		     (cr_type == CR_MEMORY) || (cr_type == CR_SOCKET_MEMORY))) {
+			free_mem = select_node_ptr[i].real_memory;
+			free_mem -= select_node_ptr[i].alloc_memory;
+			if (free_mem < job_ptr->details->job_min_memory)
+				goto clear_bit;
+		}
+
+		if (select_node_ptr[i].node_state == NODE_CR_RESERVED) {
+			goto clear_bit;
+		} else if (select_node_ptr[i].node_state == NODE_CR_ONE_ROW) {
+			if ((job_node_req == NODE_CR_RESERVED) ||
+			    (job_node_req == NODE_CR_AVAILABLE))
+				goto clear_bit;
+			/* cannot use this node if it is running jobs
+			 * in sharing partitions */
+			if ( _is_node_sharing(&(select_node_ptr[i])) )
+				goto clear_bit;
+		} else {	/* node_state = NODE_CR_AVAILABLE */
+			if (job_node_req == NODE_CR_RESERVED) {
+				if ( _is_node_busy(&(select_node_ptr[i])) )
+					goto clear_bit;
+			} else if (job_node_req == NODE_CR_ONE_ROW) {
+				if ( _is_node_sharing(&(select_node_ptr[i])) )
+					goto clear_bit;
+			}
+		}
+		continue;	/* node is usable, test next node */
+
+		/* This node is not usable by this job */
+ clear_bit:	bit_clear(bitmap, i);
+		if (job_ptr->details->req_node_bitmap &&
+		    bit_test(job_ptr->details->req_node_bitmap, i))
+			return SLURM_ERROR;
+
+	}
+
+	return SLURM_SUCCESS;
+}
+
+/* Determine the node requirements for the job:
+ * - does the job need exclusive nodes? (NODE_CR_RESERVED)
+ * - can the job run on shared nodes?   (NODE_CR_ONE_ROW)
+ * - can the job run on overcommitted resources? (NODE_CR_AVAILABLE)
+ */
+static enum node_cr_state _get_job_node_req(struct job_record *job_ptr)
+{
+	int max_share = job_ptr->part_ptr->max_share;
+	
+	if (max_share == 0)
+		return NODE_CR_RESERVED;
+	
+	if (max_share & SHARED_FORCE)
+		return NODE_CR_AVAILABLE;
+
+	/* Shared=NO or Shared=YES */
+	if (job_ptr->details->shared == 0)
+		/* user has requested exclusive nodes */
+		return NODE_CR_RESERVED;
+	if ((max_share > 1) && (job_ptr->details->shared == 1))
+		/* part allows sharing, and
+		 * the user has requested it */
+		return NODE_CR_AVAILABLE;
+	return NODE_CR_ONE_ROW;
+}
+
+/* for a given node and partition return the count of rows (time slices)
+ * that have resources allocated */
+static int _get_allocated_rows(struct node_cr_record *select_node_ptr,
+			       struct job_record *job_ptr, int n,
+			       enum node_cr_state job_node_req)
+{
+	struct part_cr_record *p_ptr;
+	int i, j, rows = 0;
+	
+	p_ptr = get_cr_part_ptr(&(select_node_ptr[n]), job_ptr->part_ptr);
+	if (p_ptr == NULL)
+		return rows;
+
+	for (i = 0; i < p_ptr->num_rows; i++) {
+		int offset = i * select_node_ptr[n].sockets;
+		for (j = 0; j < select_node_ptr[n].sockets; j++){
+			if (p_ptr->alloc_cores[offset+j]) {
+				rows++;
 				break;
-			case CR_CORE:
-			case CR_CORE_MEMORY:
-				if (this_node->alloc_lps >= job->alloc_lps[i])
-					this_node->alloc_lps -= job->alloc_lps[i];
-				else {
-					error("cons_res: alloc_lps underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;
-				}
-				chk_resize_node(this_node, 
-						this_node->node_ptr->sockets);
-				chk_resize_job(job, i, this_node->num_sockets);
-				for (j =0; j < this_node->num_sockets; j++) {
-					if (this_node->alloc_cores[j] >= 
-							job->alloc_cores[i][j]) {
-						this_node->alloc_cores[j] -= 
-								job->alloc_cores[i][j];
-					} else {
-						error("cons_res: alloc_cores underflow on %s",
-						      this_node->node_ptr->name);
-						rc = SLURM_ERROR;
+			}
+		}
+	}
+	return rows;
+}
+
+static int _load_arrays(struct node_cr_record *select_node_ptr,
+			struct job_record *job_ptr, bitstr_t *bitmap, 
+			int **a_rows, int **s_tasks, int **a_tasks, 
+			int **freq, bool test_only,
+			enum node_cr_state job_node_req)
+{
+	int i, index = 0, size = 32;
+	int *busy_rows, *shr_tasks, *all_tasks, *num_nodes;
+	
+	busy_rows = xmalloc (sizeof(int)*size); /* allocated rows */
+	shr_tasks = xmalloc (sizeof(int)*size); /* max free cpus */
+	all_tasks = xmalloc (sizeof(int)*size); /* all cpus */
+	num_nodes = xmalloc (sizeof(int)*size); /* number of nodes */
+	/* above arrays are all zero filled by xmalloc() */
+
+	for (i = 0; i < select_node_cnt; i++) {
+		if (bit_test(bitmap, i)) {
+			int rows;
+			uint16_t atasks, ptasks;
+			rows = _get_allocated_rows(select_node_ptr, job_ptr, 
+						   i, job_node_req);
+			/* false = use free rows (if available) */
+			atasks = _get_task_count(select_node_ptr, job_ptr, i, 
+						 test_only, false,
+						 job_node_req);
+			if (test_only) {
+				ptasks = atasks;
+			} else {
+				/* true = try using an already allocated row */
+				ptasks = _get_task_count(select_node_ptr, 
+							 job_ptr, i, test_only,
+							 true, job_node_req);
+			}
+			if (rows   != busy_rows[index] ||
+			    ptasks != shr_tasks[index] ||
+			    atasks != all_tasks[index]) {
+				if (num_nodes[index]) {
+					index++;
+					if (index >= size) {
+						size *= 2;
+						xrealloc(busy_rows,
+							 sizeof(int)*size);
+						xrealloc(shr_tasks,
+							 sizeof(int)*size);
+						xrealloc(all_tasks,
+							 sizeof(int)*size);
+						xrealloc(num_nodes,
+							 sizeof(int)*size);
 					}
+					num_nodes[index] = 0;
 				}
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					rc = SLURM_ERROR;  
-				}
-				if (rc == SLURM_ERROR) {
-					this_node->alloc_lps = 0;
-					for (j =0; j < this_node->num_sockets; j++) {
-						this_node->alloc_cores[j] = 0;
+				busy_rows[index] = rows;
+				shr_tasks[index] = ptasks;
+				all_tasks[index] = atasks;
+			}
+		} else {
+			if (busy_rows[index] != -1) {
+				if (num_nodes[index] > 0) {
+					index++;
+					if (index >= size) {
+						size *= 2;
+						xrealloc(busy_rows,
+							 sizeof(int)*size);
+						xrealloc(shr_tasks,
+							 sizeof(int)*size);
+						xrealloc(all_tasks,
+							 sizeof(int)*size);
+						xrealloc(num_nodes,
+							 sizeof(int)*size);
 					}
-					this_node->alloc_memory = 0;
+					num_nodes[index] = 0;
 				}
-				break;
-			case CR_MEMORY:
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					this_node->alloc_memory = 0;
-					rc = SLURM_ERROR;  
-				}
-				break;
-			case CR_CPU:
-			case CR_CPU_MEMORY:
-				if (this_node->alloc_lps >= job->alloc_lps[i])
-					this_node->alloc_lps -= job->alloc_lps[i];
-				else {
-					error("cons_res: alloc_lps underflow on %s",
-					      this_node->node_ptr->name);
-					this_node->alloc_lps = 0;
-					rc = SLURM_ERROR;  
-				}
-				if (cr_type == CR_CPU)
-					break;
-
-				if (this_node->alloc_memory >= job->alloc_memory[i])
-					this_node->alloc_memory -= job->alloc_memory[i];
-				else {
-					error("cons_res: alloc_memory underflow on %s",
-					      this_node->node_ptr->name);
-					this_node->alloc_memory = 0;
-					rc = SLURM_ERROR;  
-				}
-				break;
-			default:
-				break;
+				busy_rows[index] = -1;
+				shr_tasks[index]  = -1;
+				all_tasks[index]  = -1;
 			}
 		}
-		rc = SLURM_SUCCESS;
-		break;
+		num_nodes[index]++;
 	}
-	list_iterator_destroy(job_iterator);
+	/* array_index becomes "array size" */
+	index++;
 
-	return rc;
+#if (CR_DEBUG)
+	for (i = 0; i < index; i++) {
+		info("cons_res: i %d row %d ptasks %d atasks %d freq %d",
+		     i, busy_rows[i], shr_tasks[i], all_tasks[i], num_nodes[i]);
+	}
+#endif
+
+	*a_rows  = busy_rows;
+	*s_tasks = shr_tasks;
+	*a_tasks = all_tasks;
+	*freq    = num_nodes;
+
+	return index;
 }
 
-extern int select_p_job_resume(struct job_record *job_ptr)
+/*
+ * select_p_job_test - Given a specification of scheduling requirements, 
+ *	identify the nodes which "best" satisfy the request.
+ * 	"best" is defined as either a minimal number of consecutive nodes
+ *	or if sharing resources then sharing them with a job of similar size.
+ * IN/OUT job_ptr - pointer to job being considered for initiation,
+ *                  set's start_time when job expected to start
+ * IN/OUT bitmap - usable nodes are set on input, nodes not required to 
+ *	satisfy the request are cleared, other left set
+ * IN min_nodes - minimum count of nodes
+ * IN req_nodes - requested (or desired) count of nodes
+ * IN max_nodes - maximum count of nodes (0==don't care)
+ * IN mode - SELECT_MODE_RUN_NOW: try to schedule job now
+ *           SELECT_MODE_TEST_ONLY: test if job can ever run
+ *           SELECT_MODE_WILL_RUN: determine when and where job can run
+ * RET zero on success, EINVAL otherwise
+ * globals (passed via select_p_node_init): 
+ *	node_record_count - count of nodes configured
+ *	node_record_table_ptr - pointer to global node table
+ * NOTE: the job information that is considered for scheduling includes:
+ *	req_node_bitmap: bitmap of specific nodes required by the job
+ *	contiguous: allocated nodes must be sequentially located
+ *	num_procs: minimum number of processors required by the job
+ * NOTE: bitmap must be a superset of req_nodes at the time that 
+ *	select_p_job_test is called
+ */
+extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
+			     uint32_t min_nodes, uint32_t max_nodes, 
+			     uint32_t req_nodes, int mode)
 {
-	ListIterator job_iterator;
-	struct select_cr_job *job;
-	int i, j, rc = ESLURM_INVALID_JOB_ID;
+	enum node_cr_state job_node_req;
 
-	xassert(job_ptr);
-	xassert(select_cr_job_list);
+	xassert(bitmap);
 
-	job_iterator = list_iterator_create(select_cr_job_list);
-	if (job_iterator == NULL)
-		fatal("list_iterator_create: %m");
+	if (!job_ptr->details)
+		return EINVAL;
 
-	while ((job = (struct select_cr_job *) list_next(job_iterator))) {
-		if (job->job_id != job_ptr->job_id)
+	if (!job_ptr->details->mc_ptr)
+		job_ptr->details->mc_ptr = create_default_mc();
+	job_node_req = _get_job_node_req(job_ptr);
+
+	debug3("cons_res: select_p_job_test: job %d node_req %d, mode %d",
+	       job_ptr->job_id, job_node_req, mode);
+	debug3("cons_res: select_p_job_test: min_n %u max_n %u req_n %u",
+	       min_nodes, max_nodes, req_nodes);
+
+#if (CR_DEBUG)
+	_dump_state(select_node_ptr);
+#endif
+	if (mode == SELECT_MODE_WILL_RUN) {
+		return _will_run_test(job_ptr, bitmap, min_nodes, max_nodes,
+				      req_nodes, job_node_req);
+	}
+
+	return _job_test(job_ptr, bitmap, min_nodes, max_nodes, req_nodes, 
+			 mode, job_node_req, select_node_ptr);
+}
+
+/*
+ * select_p_job_list_test - Given a list of select_will_run_t's in
+ *	accending priority order we will see if we can start and
+ *	finish all the jobs without increasing the start times of the
+ *	jobs specified and fill in the est_start of requests with no
+ *	est_start.  If you are looking to see if one job will ever run
+ *	then use select_p_job_test instead.
+ * IN/OUT req_list - list of select_will_run_t's in asscending
+ *	             priority order on success of placement fill in
+ *	             est_start of request with time.
+ * RET zero on success, EINVAL otherwise
+ */
+extern int select_p_job_list_test(List req_list)
+{
+	/* not currently supported */
+	return EINVAL;
+}
+
+
+/* _will_run_test - determine when and where a pending job can start, removes 
+ *	jobs from node table at termination time and run _test_job() after 
+ *	each one. */
+static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
+			uint32_t min_nodes, uint32_t max_nodes, 
+			uint32_t req_nodes, enum node_cr_state job_node_req)
+{
+	struct node_cr_record *exp_node_cr;
+	struct job_record *tmp_job_ptr, **tmp_job_pptr;
+	struct select_cr_job *job;
+	List cr_job_list;
+	ListIterator job_iterator;
+	bitstr_t *orig_map;
+	int rc = SLURM_ERROR;
+	uint16_t saved_state;
+
+	orig_map = bit_copy(bitmap);
+
+	/* Try to run with currently available nodes */
+	rc = _job_test(job_ptr, bitmap, min_nodes, max_nodes, req_nodes, 
+		       SELECT_MODE_WILL_RUN, job_node_req, select_node_ptr);
+	if (rc == SLURM_SUCCESS) {
+		bit_free(orig_map);
+		job_ptr->start_time = time(NULL);
+		return SLURM_SUCCESS;
+	}
+
+	/* Job is still pending. Simulate termination of jobs one at a time 
+	 * to determine when and where the job can start. */
+	exp_node_cr = _dup_node_cr(select_node_ptr);
+	if (exp_node_cr == NULL) {
+		bit_free(orig_map);
+		return SLURM_ERROR;
+	}
+
+	/* Build list of running jobs */
+	cr_job_list = list_create(_cr_job_list_del);
+	job_iterator = list_iterator_create(job_list);
+	while ((tmp_job_ptr = (struct job_record *) list_next(job_iterator))) {
+		if (tmp_job_ptr->job_state != JOB_RUNNING)
 			continue;
-		if ((job->state & CR_JOB_STATE_SUSPENDED) == 0) {
-			error("select: job %s not suspended",
-				job->job_id);
+		if (tmp_job_ptr->end_time == 0) {
+			error("Job %u has zero end_time", tmp_job_ptr->job_id);
+			continue;
+		}
+		tmp_job_pptr = xmalloc(sizeof(struct job_record *));
+		*tmp_job_pptr = tmp_job_ptr;
+		list_append(cr_job_list, tmp_job_pptr);
+	}
+	list_iterator_destroy(job_iterator);
+	list_sort(cr_job_list, _cr_job_list_sort);
+
+	/* Remove the running jobs one at a time from exp_node_cr and try
+	 * scheduling the pending job after each one */
+	job_iterator = list_iterator_create(cr_job_list);
+	while ((tmp_job_pptr = (struct job_record **) list_next(job_iterator))) {
+		tmp_job_ptr = *tmp_job_pptr;
+		job = list_find_first(select_cr_job_list, _find_job_by_id,
+				      &tmp_job_ptr->job_id);
+		if (!job) {
+			error("cons_res: could not find job %u", 
+			      tmp_job_ptr->job_id);
+			continue;
+		}
+		saved_state = job->state;
+		_rm_job_from_nodes(exp_node_cr, job, "_will_run_test", 1);
+		job->state = saved_state;
+		bit_or(bitmap, orig_map);
+		rc = _job_test(job_ptr, bitmap, min_nodes, max_nodes, 
+			       req_nodes, SELECT_MODE_WILL_RUN, job_node_req,
+			       exp_node_cr);
+		if (rc == SLURM_SUCCESS) {
+			job_ptr->start_time = tmp_job_ptr->end_time;
 			break;
 		}
+	}
+	list_iterator_destroy(job_iterator);
+	list_destroy(cr_job_list);
+	_destroy_node_part_array(exp_node_cr);
+	bit_free(orig_map);
+	return rc;
+}
 
-		rc = SLURM_SUCCESS;
-		last_cr_update_time = time(NULL);
-		job->state &= (~CR_JOB_STATE_SUSPENDED);
+/* _job_test - does most of the real work for select_p_job_test(), which 
+ *	pretty much just handles load-leveling and max_share logic */
+static int _job_test(struct job_record *job_ptr, bitstr_t *bitmap,
+			uint32_t min_nodes, uint32_t max_nodes, 
+			uint32_t req_nodes, int mode, 
+			enum node_cr_state job_node_req,
+			struct node_cr_record *select_node_ptr)
+{
+	int a, f, i, j, k, error_code, ll; /* ll = layout array index */
+	struct multi_core_data *mc_ptr = NULL;
+	static struct select_cr_job *job;
+	uint16_t * layout_ptr = NULL;
+	int  array_size;
+	int *busy_rows, *sh_tasks, *al_tasks, *freq;
+	bitstr_t *origmap, *reqmap = NULL;
+	int row, rows, try;
+	bool test_only;
+	uint32_t save_mem = 0;
+
+	layout_ptr = job_ptr->details->req_node_layout;
+	mc_ptr = job_ptr->details->mc_ptr;
+	reqmap = job_ptr->details->req_node_bitmap;
+
+	/* check node_state and update bitmap as necessary */
+	if (mode == SELECT_MODE_TEST_ONLY) {
+		test_only = true;
+		save_mem = job_ptr->details->job_min_memory;
+		job_ptr->details->job_min_memory = 0;
+	} else	/* SELECT_MODE_RUN_NOW || SELECT_MODE_WILL_RUN  */ 
+		test_only = false;
 
-		for (i = 0; i < job->nhosts; i++) {
-			struct node_cr_record *this_node;
-			this_node = find_cr_node_record(job->host[i]);
-			if (this_node == NULL) {
-				error("cons_res: could not find node %s",
-				      job->host[i]);
-				rc = SLURM_ERROR; 
-				break;
-			}
-			
-			/* Updating this node allocated resources */
-			switch(cr_type) {
-			case CR_SOCKET:
-			case CR_SOCKET_MEMORY:
-				this_node->alloc_lps += job->alloc_lps[i];
-				this_node->alloc_sockets += 
-						job->alloc_sockets[i];
-				this_node->alloc_memory += job->alloc_memory[i];
-				break;
-			case CR_CORE:
-			case CR_CORE_MEMORY:
-				this_node->alloc_lps += job->alloc_lps[i];
-				chk_resize_node(this_node, 
-						this_node->node_ptr->sockets);
-				chk_resize_job(job, i, this_node->num_sockets);
-				for (j =0; j < this_node->num_sockets; j++) {
-					this_node->alloc_cores[j] += 
-							job->alloc_cores[i][j];
+	if (!test_only) {
+		error_code = _verify_node_state(select_node_ptr, job_ptr, 
+						bitmap, job_node_req);
+		if (error_code != SLURM_SUCCESS)
+			return error_code;
+	}
+
+	/* This is the case if -O/--overcommit  is true */ 
+	if (job_ptr->num_procs == job_ptr->details->min_nodes) {
+		job_ptr->num_procs *= MAX(1, mc_ptr->min_threads);
+		job_ptr->num_procs *= MAX(1, mc_ptr->min_cores);
+		job_ptr->num_procs *= MAX(1, mc_ptr->min_sockets);
+	}
+
+	/* compute condensed arrays of node allocation data */
+	array_size = _load_arrays(select_node_ptr, job_ptr, bitmap, &busy_rows,
+				  &sh_tasks, &al_tasks, &freq, test_only, 
+				  job_node_req);
+
+	if (test_only) {
+        	/* try with all nodes and all possible cpus */
+		error_code = _select_nodes(job_ptr, bitmap, min_nodes,
+					   max_nodes, req_nodes, al_tasks, freq,
+					   array_size);
+		xfree(busy_rows);
+		xfree(sh_tasks);
+		xfree(al_tasks);
+		xfree(freq);
+		if (save_mem)
+			job_ptr->details->job_min_memory = save_mem;
+		return error_code;
+	}
+
+	origmap = bit_copy(bitmap);
+	if (origmap == NULL)
+		fatal("bit_copy malloc failure");
+
+	error_code = SLURM_ERROR;
+	rows = job_ptr->part_ptr->max_share & ~SHARED_FORCE;
+	rows = MAX(1, rows);	/* max_share == 0 for EXCLUSIVE */
+	for (row = 1; row <= rows; row++) {
+
+		/*
+		 * first try : try "as is"
+		 * second try: only add a row to nodes with no free cpus
+		 * third try : add a row to nodes with some alloc cpus
+		 */
+		for (try = 0; try < 3; try++) {
+			bit_or(bitmap, origmap);
+
+			debug3("cons_res: cur row = %d, try = %d", row, try);
+
+			for (i = 0, f = 0; i < array_size; i++) {
+
+				/* Step 1:
+				 * remove nodes from bitmap (unless required)
+				 * who's busy_rows value is bigger than 'row'.
+				 * Why? to enforce "least-loaded" over
+				 *      "contiguous" */
+				if ((busy_rows[i] > row) ||
+				    (busy_rows[i] == row && sh_tasks[i] == 0)) {
+					for (j = f; j < f+freq[i]; j++) {
+						if (reqmap &&
+						    bit_test(reqmap, j))
+							continue;
+						bit_clear(bitmap, j);
+					}
 				}
-				this_node->alloc_memory += job->alloc_memory[i];
-				break;
-			case CR_MEMORY:
-				this_node->alloc_memory += job->alloc_memory[i];
-				break;
-			case CR_CPU:
-			case CR_CPU_MEMORY:
-				this_node->alloc_lps += job->alloc_lps[i];
-				if (cr_type == CR_CPU)
-					break;
-				this_node->alloc_memory += job->alloc_memory[i];
+				f += freq[i];
+
+				if (try == 0)
+					continue;
+				/* Step 2:
+				 * set sh_tasks = al_tasks for nodes who's
+				 *      busy_rows value is < 'row'.
+				 * Why? to select a new row for these
+				 *      nodes when appropriate */
+				if ((busy_rows[i] == -1) || 
+				    (busy_rows[i] >= row))
+					continue;
+				if (sh_tasks[i] == al_tasks[i])
+					continue;
+				if ((try == 1) && (sh_tasks[i] != 0))
+					continue;
+				sh_tasks[i] = al_tasks[i];
+			}
+			if (bit_set_count(bitmap) < min_nodes)
 				break;
-			default:
+
+#if (CR_DEBUG)
+			for (i = 0; i < array_size; i++) {
+				info("cons_res: try:%d i:%d busy_rows:%d "
+				     "sh_tasks:%d al_tasks:%d freq:%d",
+				     try, i, busy_rows[i], sh_tasks[i],
+				     al_tasks[i], freq[i]);
+			}
+#endif
+
+			if (row > 1) {
+				/* We need to share resources. 
+				 * Try to find suitable job to share nodes with. */
+
+				/* FIXME: To be added. There is some simple logic 
+				 * to do this in select/linear.c:_find_job_mate(), 
+				 * but the data structures here are very different */
+			}
+
+			error_code = _select_nodes(job_ptr, bitmap, min_nodes,
+						   max_nodes, req_nodes,
+						   sh_tasks, freq, array_size);
+			if (error_code == SLURM_SUCCESS)
 				break;
+		}
+		if (error_code == SLURM_SUCCESS)
+			break;
+	}
+
+	bit_free(origmap);
+
+	if ((mode != SELECT_MODE_WILL_RUN) && (job_ptr->part_ptr == NULL))
+		error_code = EINVAL;
+	if ((error_code == SLURM_SUCCESS) && (mode == SELECT_MODE_WILL_RUN)) {
+		if (job_ptr->details->shared == 0) {
+			uint16_t procs;
+			job_ptr->total_procs = 0;
+			for (i = 0; i < select_node_cnt; i++) {
+				if (!bit_test(bitmap, i))
+					continue;
+				procs = select_node_ptr[i].cpus;
+				job_ptr->total_procs += procs;
+			}
+		} else {
+			job_ptr->total_procs = job_ptr->num_procs;
+			if (job_ptr->details->cpus_per_task &&
+			    (job_ptr->details->cpus_per_task != 
+			     (uint16_t) NO_VAL)) {
+				job_ptr->total_procs *= job_ptr->details->
+							cpus_per_task;
 			}
 		}
-		rc = SLURM_SUCCESS;
-		break;
 	}
-	list_iterator_destroy(job_iterator);
+	if ((error_code != SLURM_SUCCESS) || (mode != SELECT_MODE_RUN_NOW)) {
+		xfree(busy_rows);
+		xfree(sh_tasks);
+		xfree(al_tasks);
+		xfree(freq);
+		return error_code;
+	}
+	
+	/* allocate the job and distribute the tasks appropriately */
+	job = xmalloc(sizeof(struct select_cr_job));
+	job->job_ptr = job_ptr;
+	job->job_id = job_ptr->job_id;
+	job->nhosts = bit_set_count(bitmap);
+	job->nprocs = MAX(job_ptr->num_procs, job->nhosts);
+	job->node_req  = job_node_req;
+
+	job->node_bitmap = bit_copy(bitmap);
+	if (job->node_bitmap == NULL)
+		fatal("bit_copy malloc failure");
+
+	job->cpus          = (uint16_t *) xmalloc(job->nhosts * sizeof(uint16_t));
+	job->alloc_cpus    = (uint16_t *) xmalloc(job->nhosts * sizeof(uint16_t));
+	job->node_offset   = (uint16_t *) xmalloc(job->nhosts * sizeof(uint16_t));
+	job->alloc_memory  = (uint32_t *) xmalloc(job->nhosts * sizeof(uint32_t));
+
+	if ((cr_type == CR_CORE)   || (cr_type == CR_CORE_MEMORY) ||
+	    (cr_type == CR_SOCKET) || (cr_type == CR_SOCKET_MEMORY)) {
+		job->num_sockets   = (uint16_t *)  xmalloc(job->nhosts * 
+							   sizeof(uint16_t));
+		job->alloc_cores   = (uint16_t **) xmalloc(job->nhosts * 
+							   sizeof(uint16_t *));
+		j = 0;
+		for (i = 0; i < select_node_cnt; i++) {
+			if (!bit_test(job->node_bitmap, i))
+				continue;
+			job->num_sockets[j] = select_node_ptr[i].sockets;
+			job->alloc_cores[j] = (uint16_t *) xmalloc(
+				job->num_sockets[j] * sizeof(uint16_t));
+			j++;
+		}
+	}
 
-	return rc;
+	j = 0;
+	a = 0;
+	f = 0;
+	row = 0; /* total up all available cpus for --overcommit scenarios */
+	for (i = 0, ll = -1; i < node_record_count; i++, f++) {
+		if (f >= freq[a]) {
+			f = 0;
+			a++;
+		}
+		if (layout_ptr
+		    && bit_test(job_ptr->details->req_node_bitmap, i)) {
+			ll++;
+		}
+		if (bit_test(bitmap, i) == 0)
+			continue;
+		if (j >= job->nhosts) {
+			error("select_cons_res: job nhosts too small\n");
+			break;
+		}
+		job->cpus[j] = sh_tasks[a];
+		row += sh_tasks[a];
+		if (layout_ptr
+		    && bit_test(job_ptr->details->req_node_bitmap, i)) {
+			job->cpus[j] = MIN(job->cpus[j], layout_ptr[ll]);
+		} else if (layout_ptr) {
+			job->cpus[j] = 0;
+		}
+		job->alloc_cpus[j] = 0;
+		if ((cr_type == CR_CORE_MEMORY) || (cr_type == CR_CPU_MEMORY) ||
+		    (cr_type == CR_MEMORY) || (cr_type == CR_SOCKET_MEMORY))
+			job->alloc_memory[j] = job_ptr->details->job_min_memory; 
+		if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY)||
+		    (cr_type == CR_SOCKET) || (cr_type == CR_SOCKET_MEMORY)) {
+			_chk_resize_job(job, j, job->num_sockets[j]);
+			for (k = 0; k < job->num_sockets[j]; k++)
+				job->alloc_cores[j][k] = 0;
+		}
+		j++;
+	}
+
+	xfree(busy_rows);
+	xfree(sh_tasks);
+	xfree(al_tasks);
+	xfree(freq);
+
+	/* When 'srun --overcommit' is used, nprocs is set to a minimum value
+	 * in order to allocate the appropriate number of nodes based on the
+	 * job request.
+	 * For cons_res, all available logical processors will be allocated on
+	 * each allocated node in order to accommodate the overcommit request.
+	 */
+	if (job_ptr->details->overcommit)
+		job->nprocs = MIN(row, job_ptr->details->num_tasks);
+
+	if (job_ptr->details->shared == 0) {
+		/* Nodes need to be allocated in dedicated
+		   mode. User has specified the --exclusive switch */
+		error_code = cr_exclusive_dist(job, cr_type);
+	} else {
+		/* Determine the number of logical processors
+		 * per node needed for this job.
+		 * Make sure below matches the layouts in
+		 * lllp_distribution in
+		 * plugins/task/affinity/dist_task.c */
+		switch(job_ptr->details->task_dist) {
+		case SLURM_DIST_BLOCK_BLOCK:
+		case SLURM_DIST_CYCLIC_BLOCK:
+			error_code = cr_dist(job, 0, cr_type); 
+			break;
+		case SLURM_DIST_BLOCK:
+		case SLURM_DIST_CYCLIC:				
+		case SLURM_DIST_BLOCK_CYCLIC:
+		case SLURM_DIST_CYCLIC_CYCLIC:
+		case SLURM_DIST_UNKNOWN:
+			error_code = cr_dist(job, 1, cr_type); 
+			break;
+		case SLURM_DIST_PLANE:
+			error_code = cr_plane_dist(job, mc_ptr->plane_size, cr_type); 
+			break;
+		case SLURM_DIST_ARBITRARY:
+		default:
+			error_code = compute_c_b_task_dist(job);
+			if (error_code != SLURM_SUCCESS) {
+				error(" Error in compute_c_b_task_dist");
+			}
+			break;
+		}
+	}
+	if (error_code != SLURM_SUCCESS) {
+		_xfree_select_cr_job(job);
+		return error_code;
+	}
+
+	_append_to_job_list(job);
+	last_cr_update_time = time(NULL);
+
+	return error_code;
+}
+
+extern int select_p_job_begin(struct job_record *job_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int select_p_job_ready(struct job_record *job_ptr)
+{
+	return SLURM_SUCCESS;
+}
+
+extern int select_p_job_fini(struct job_record *job_ptr)
+{
+	struct select_cr_job *job = NULL;
+	ListIterator iterator;
+
+	xassert(job_ptr);
+	xassert(job_ptr->magic == JOB_MAGIC);
+
+	if (list_count(select_cr_job_list) == 0)
+		return SLURM_SUCCESS;
+
+	iterator = list_iterator_create(select_cr_job_list);
+	while ((job = (struct select_cr_job *) list_next(iterator))) {
+		if (job->job_id == job_ptr->job_id)
+			break;
+	}
+	if (!job) {
+		error("select_p_job_fini: could not find data for job %d",
+			job_ptr->job_id);
+		list_iterator_destroy(iterator);
+		return SLURM_ERROR;
+	}
+	
+	_rm_job_from_nodes(select_node_ptr, job, "select_p_job_fini", 1);
+
+	slurm_mutex_lock(&cr_mutex);
+	list_remove(iterator);
+	slurm_mutex_unlock(&cr_mutex);
+	_xfree_select_cr_job(job);
+	list_iterator_destroy(iterator);
+
+	debug3("cons_res: select_p_job_fini Job_id %u: list_count: %d",
+		job_ptr->job_id, list_count(select_cr_job_list));
+
+	_verify_select_job_list(job_ptr->job_id);
+	last_cr_update_time = time(NULL);
+
+	return SLURM_SUCCESS;
+}
+
+/* NOTE: This function is not called with sched/gang because it needs
+ * to track how many jobs are running or suspended on each node.
+ * This sum is compared with the partition's Shared parameter */
+extern int select_p_job_suspend(struct job_record *job_ptr)
+{
+	struct select_cr_job *job;
+	int rc;
+ 
+	xassert(job_ptr);
+	xassert(select_cr_job_list);
+
+	job = list_find_first(select_cr_job_list, _find_job_by_id,
+			      &job_ptr->job_id);
+	if (!job)
+		return ESLURM_INVALID_JOB_ID;
+
+	rc = _rm_job_from_nodes(select_node_ptr, job, 
+				"select_p_job_suspend", 0);
+	return SLURM_SUCCESS;
+}
+
+/* See NOTE with select_p_job_suspend above */
+extern int select_p_job_resume(struct job_record *job_ptr)
+{
+	struct select_cr_job *job;
+	int rc;
+
+	xassert(job_ptr);
+	xassert(select_cr_job_list);
+
+	job = list_find_first(select_cr_job_list, _find_job_by_id,
+			      &job_ptr->job_id);
+	if (!job)
+		return ESLURM_INVALID_JOB_ID;
+	
+	rc = _add_job_to_nodes(job, "select_p_job_resume", 0);
+	return SLURM_SUCCESS;
+}
+
+extern uint16_t select_p_get_job_cores(uint32_t job_id, int alloc_index, int s)
+{
+	struct select_cr_job *job = list_find_first(select_cr_job_list,
+						    _find_job_by_id, &job_id);
+	if (!job || alloc_index >= job->nhosts)
+		return 0;
+	if (cr_type == CR_CORE   || cr_type == CR_CORE_MEMORY ||
+	    cr_type == CR_SOCKET || cr_type == CR_SOCKET_MEMORY) {
+		if (job->num_sockets == NULL || job->alloc_cores == NULL)
+			return 0;
+		if (s >= job->num_sockets[alloc_index]) 
+			return 0;
+
+		return job->alloc_cores[alloc_index][s];
+	}
+	/* else return the total cpu count for the given node */
+	if (job->alloc_cpus == NULL)
+		return 0;
+
+	return job->alloc_cpus[alloc_index];
 }
 
 extern int select_p_pack_node_info(time_t last_query_time,
@@ -2174,108 +2776,59 @@ extern int select_p_get_extra_jobinfo(struct node_record *node_ptr,
 				      enum select_data_info cr_info,
 				      void *data)
 {
-	int rc = SLURM_SUCCESS, i, avail = 0;
-	uint32_t *tmp_32 = (uint32_t *) data;
+	int rc = SLURM_SUCCESS, i, index, node_offset, node_inx;
+	struct select_cr_job *job;
+	struct node_cr_record *this_cr_node;
 	uint16_t *tmp_16 = (uint16_t *) data;
 
 	xassert(job_ptr);
 	xassert(job_ptr->magic == JOB_MAGIC);
+	xassert(node_ptr);
 
 	switch (cr_info) {
-	case SELECT_AVAIL_MEMORY:
-	{
-		switch(cr_type) {		
-		case CR_MEMORY:	
-		case CR_CPU_MEMORY:	
-		case CR_SOCKET_MEMORY:	
-		case CR_CORE_MEMORY:	
-			*tmp_32 = 0;
-			for (i = 0; i < node_record_count; i++) {
-				if (bit_test(job_ptr->details->req_node_bitmap, i) != 1)
-					continue;
-				avail = _get_avail_memory(i, false);
-				if (avail < 0) {
-					rc = SLURM_ERROR;
-					return rc;
-				}
-			}
+	case SELECT_AVAIL_CPUS:
+		*tmp_16 = 0;
+		job = list_find_first(select_cr_job_list, _find_job_by_id, 
+				      &job_ptr->job_id);
+		if (job == NULL) {
+			error("cons_res: job %u not active", job_ptr->job_id);
 			break;
-		default:
-			*tmp_32 = 0;
 		}
-		break;
-	}
-	case SELECT_CPU_COUNT:
-	{
-		struct multi_core_data *mc_ptr = job_ptr->details->mc_ptr;
-
-		if (mc_ptr &&
-		    ((job_ptr->details->cpus_per_task > 1) || 
-		     (mc_ptr->max_sockets > 1)   ||
-		     (mc_ptr->max_cores > 1)     ||
-		     (mc_ptr->max_threads > 1))) {
-			*tmp_16 = 0;
-			for (i = 0; i < node_record_count; i++) {
-				if (bit_test(job_ptr->details->req_node_bitmap, i) != 1)
-					continue;
-				/* req_node_layout info is not supported for
-				 * socket/core/threads/cpus_per task, but
-				 * probably there should be something in
-				 * here... */
-				*tmp_16 += _get_avail_lps(job_ptr, i, false);
-			}
-		} else {
-			_count_cpus(job_ptr->details->
-				    req_node_bitmap, tmp_16);
-		}
-		break;
-	}
-	case SELECT_AVAIL_CPUS:
-	{
-		struct select_cr_job *job = NULL;
-		ListIterator iterator =
-			list_iterator_create(select_cr_job_list);
-		xassert(node_ptr);
-		xassert(node_ptr->magic == NODE_MAGIC);
 
-		*tmp_16 = 0;
-		while ((job =
-			(struct select_cr_job *) list_next(iterator)) != NULL) {
-			if (job->job_id != job_ptr->job_id)
+		node_offset = -1;
+		node_inx = node_ptr - node_record_table_ptr;
+		for (i = 0; i < node_record_count; i++) {
+			if (bit_test(job->node_bitmap, i) == 0)
 				continue;
-			for (i = 0; i < job->nhosts; i++) { 
-				if (strcmp(node_ptr->name, job->host[i]) != 0)
-					continue;
-				/* Usable and "allocated" resources for this 
-				 * given job for a specific node --> based 
-				 * on the output from _cr_dist */
-				switch(cr_type) {
-				case CR_MEMORY:
-					*tmp_16 = node_ptr->cpus;
-					break;
-				case CR_SOCKET:
-				case CR_SOCKET_MEMORY:
-				case CR_CORE: 
-				case CR_CORE_MEMORY: 
-				case CR_CPU:
-				case CR_CPU_MEMORY:
-				default:
-					*tmp_16 = job->alloc_lps[i];
-					break;
-				}
-				goto cleanup;
+			node_offset++;
+			if (i != node_inx)
+				continue;
+			/* Usable and "allocated" resources for this 
+			 * given job for a specific node --> based 
+			 * on the output from _cr_dist */
+			switch(cr_type) {
+			case CR_MEMORY:
+				index = node_ptr - node_record_table_ptr;
+				this_cr_node = select_node_ptr + index;
+				*tmp_16 = this_cr_node->cpus;
+				break;
+			case CR_SOCKET:
+			case CR_SOCKET_MEMORY:
+			case CR_CORE: 
+			case CR_CORE_MEMORY: 
+			case CR_CPU:
+			case CR_CPU_MEMORY:
+			default:
+				*tmp_16 = job->alloc_cpus[node_offset];
+				break;
 			}
+			break;
+		}
+		if (i >= node_record_count) {
 			error("cons_res could not find %s", node_ptr->name); 
 			rc = SLURM_ERROR;
 		}
-		if (!job) {
-			debug3("cons_res: job %u not active", job_ptr->job_id);
-			*tmp_16 = 0;
-		}
-	     cleanup:
-		list_iterator_destroy(iterator);
 		break;
-	}
 	default:
 		error("select_g_get_extra_jobinfo cr_info %d invalid", cr_info);
 		rc = SLURM_ERROR;
@@ -2289,76 +2842,34 @@ extern int select_p_get_select_nodeinfo(struct node_record *node_ptr,
 					enum select_data_info dinfo,
 					void *data)
 {
-	int rc = SLURM_SUCCESS, i;
+	int index, i, j, rc = SLURM_SUCCESS;
 	struct node_cr_record *this_cr_node;
+	struct part_cr_record *p_ptr;
+	uint16_t *tmp_16;
 
 	xassert(node_ptr);
-	xassert(node_ptr->magic == NODE_MAGIC);
 
 	switch (dinfo) {
-	case SELECT_AVAIL_MEMORY:
-	case SELECT_ALLOC_MEMORY: 
-	{
-		uint32_t *tmp_32 = (uint32_t *) data;
-
-		*tmp_32 = 0;
-		switch(cr_type) {
-		case CR_MEMORY:
-		case CR_SOCKET_MEMORY:
-		case CR_CORE_MEMORY:
-		case CR_CPU_MEMORY:
-			this_cr_node = find_cr_node_record (node_ptr->name);
-			if (this_cr_node == NULL) {
-				error(" cons_res: could not find node %s",
-				      node_ptr->name);
-				rc = SLURM_ERROR;
-				return rc;
-			}
-			if (dinfo == SELECT_ALLOC_MEMORY) {
-				*tmp_32 = this_cr_node->alloc_memory;
-			} else  
-				*tmp_32 = 
-					this_cr_node->node_ptr->real_memory - 
-					this_cr_node->alloc_memory;
-			break;
-		default:
-			*tmp_32 = 0;
-			break;
-		}
-		break;
-	}
 	case SELECT_ALLOC_CPUS: 
-	{
-		uint16_t *tmp_16 = (uint16_t *) data;
+		tmp_16 = (uint16_t *) data;
 		*tmp_16 = 0;
-	        this_cr_node = find_cr_node_record (node_ptr->name);
-		if (this_cr_node == NULL) {
-		        error(" cons_res: could not find node %s",
-			      node_ptr->name);
-			rc = SLURM_ERROR;
-			return rc;
-		}
-		switch(cr_type) {
-		case CR_SOCKET:
-		case CR_SOCKET_MEMORY:
-			*tmp_16 = this_cr_node->alloc_sockets *
-			        node_ptr->cores * node_ptr->threads;
-			break;
-		case CR_CORE:
-		case CR_CORE_MEMORY:
-			for (i = 0; i < this_cr_node->num_sockets; i++)  
-				*tmp_16 += this_cr_node->alloc_cores[i] *
-					node_ptr->threads;
-			break;
-		case CR_MEMORY:
-		case CR_CPU:
-		case CR_CPU_MEMORY:
-		default:
-			*tmp_16 = this_cr_node->alloc_lps;
-			break;
+		index = node_ptr - node_record_table_ptr;
+	        this_cr_node = select_node_ptr + index;
+
+		/* determine the highest number of allocated cores from */
+		/* all rows of all partitions */
+		for (p_ptr = this_cr_node->parts; p_ptr; p_ptr = p_ptr->next) {
+			i = 0;
+			for (j = 0; j < p_ptr->num_rows; j++) {
+				uint16_t tmp = 0;
+				for (; i < this_cr_node->sockets; i++)
+					tmp += p_ptr->alloc_cores[i] *
+					       this_cr_node->threads;
+				if (tmp > *tmp_16)
+					*tmp_16 = tmp;
+			}
 		}
 		break;
-	}
 	default:
 		error("select_g_get_select_nodeinfo info %d invalid", dinfo);
 		rc = SLURM_ERROR;
@@ -2369,108 +2880,22 @@ extern int select_p_get_select_nodeinfo(struct node_record *node_ptr,
 
 extern int select_p_update_nodeinfo(struct job_record *job_ptr)
 {
-	int rc = SLURM_SUCCESS, i, j, job_id, nodes;
-	struct select_cr_job *job = NULL;
-	ListIterator iterator;
+	int rc = SLURM_SUCCESS;
+	struct select_cr_job *job;
 
 	xassert(job_ptr);
 	xassert(job_ptr->magic == JOB_MAGIC);
 
 	if ((job_ptr->job_state != JOB_RUNNING)
 	&&  (job_ptr->job_state != JOB_SUSPENDED))
-		return rc;
-
-	job_id = job_ptr->job_id;
-
-	iterator = list_iterator_create(select_cr_job_list);
-	while ((job = (struct select_cr_job *) list_next(iterator)) 
-	       != NULL) {
-		if (job->job_id != job_id)
-			continue;
+		return SLURM_SUCCESS;
 
-		if (job_ptr->job_state == JOB_SUSPENDED) {
-			job->state |= CR_JOB_STATE_SUSPENDED;
-			nodes = 0;
-		} else {
-			job->state &= (~CR_JOB_STATE_SUSPENDED);
-			nodes = job->nhosts;
-		}
-
-		for (i = 0; i < nodes; i++) {
-			struct node_cr_record *this_node;
-			this_node = find_cr_node_record (job->host[i]);
-			if (this_node == NULL) {
-				error(" cons_res: could not find node %s",
-				      job->host[i]);
-				rc = SLURM_ERROR;
-				goto cleanup;
-			}
-			/* Updating this node's allocated resources */
-			switch (cr_type) {
-			case CR_SOCKET_MEMORY:
-				this_node->alloc_memory += job->alloc_memory[i];
-			case CR_SOCKET:
-				this_node->alloc_lps     += job->alloc_lps[i];
-				this_node->alloc_sockets += job->alloc_sockets[i];
-				if (this_node->alloc_sockets > this_node->node_ptr->sockets)
-					error("Job %u Host %s too many allocated sockets %u",
-					      job->job_id, this_node->node_ptr->name, 
-					      this_node->alloc_sockets);
-				break;
-			case CR_CORE_MEMORY:
-				this_node->alloc_memory += job->alloc_memory[i];
-			case CR_CORE:
-				this_node->alloc_lps   += job->alloc_lps[i];
-				if (this_node->alloc_lps >  this_node->node_ptr->cpus)
-					error("Job %u Host %s too many allocated lps %u",
-					      job->job_id, this_node->node_ptr->name, 
-					      this_node->alloc_lps);
-				chk_resize_node(this_node, this_node->node_ptr->sockets);
-				chk_resize_job(job, i, this_node->num_sockets);
-				for (j = 0; j < this_node->num_sockets; j++)
-					this_node->alloc_cores[j] += job->alloc_cores[i][j];
-				for (j = 0; j < this_node->num_sockets; j++)
-					if (this_node->alloc_cores[j] <= 
-					    this_node->node_ptr->cores)
-						continue;
-					else
-						error("Job %u Host %s too many allocated "
-						      "cores %u for socket %d",
-						      job->job_id, this_node->node_ptr->name, 
-						      this_node->alloc_cores[j], j);
-				break;
-			case CR_CPU_MEMORY:
-				this_node->alloc_memory += job->alloc_memory[i];
-			case CR_CPU:
-				this_node->alloc_lps     += job->alloc_lps[i];				
-				break;
-			case CR_MEMORY: 
-				this_node->alloc_memory += job->alloc_memory[i];
-				break;
-			default:
-				error("select_g_update_nodeinfo info %d invalid", cr_type);
-				rc = SLURM_ERROR;
-				break;
-			}
-#if(CR_DEBUG)
-			/* Remove debug only */
-			info("cons_res %u update_nodeinfo (+) node %s "
-			     "alloc_ lps %u sockets %u mem %u",
-			     job->job_id, this_node->node_ptr->name, this_node->alloc_lps, 
-			     this_node->alloc_sockets, this_node->alloc_memory);
-			if ((cr_type == CR_CORE) || (cr_type == CR_CORE_MEMORY))
-				for (j = 0; j < this_node->num_sockets; j++)
-					info("cons_res %u update_nodeinfo (+) "
-					     "node %s alloc_ cores %u",
-					     job->job_id, this_node->node_ptr->name, 
-					     this_node->alloc_cores[j]);
-#endif
-		}
-		break;
-	}
- cleanup:
-	list_iterator_destroy(iterator);
+	job = list_find_first(select_cr_job_list, _find_job_by_id,
+			      &job_ptr->job_id);
+	if (!job)
+		return SLURM_SUCCESS;
 	
+	rc = _add_job_to_nodes(job, "select_p_update_nodeinfo", 0);
 	return rc;
 }
 
@@ -2530,3 +2955,207 @@ extern int select_p_alter_node_cnt(enum select_node_cnt type, void *data)
 {
 	return SLURM_SUCCESS;
 }
+
+extern int select_p_reconfigure(void)
+{
+	ListIterator job_iterator;
+	struct select_cr_job *job;
+	struct job_record *job_ptr;
+	int rc, suspend;
+
+	info("cons_res: select_p_reconfigure");
+	select_fast_schedule = slurm_get_fast_schedule();
+
+	/* Refresh the select_node_ptr global array in case nodes
+	 * have been added or removed. This procedure will clear all
+	 * partition information and all allocated resource usage.
+	 */
+	rc = select_p_node_init(node_record_table_ptr, node_record_count);
+
+	/* reload all of the allocated resource usage from job data */
+	if (select_cr_job_list == NULL)
+	    	return SLURM_SUCCESS;
+
+	slurm_mutex_lock(&cr_mutex);
+	job_iterator = list_iterator_create(select_cr_job_list);
+	while ((job = (struct select_cr_job *) list_next(job_iterator))) {
+		suspend = 0;
+		job_ptr = find_job_record(job->job_id);
+		if ((job_ptr == NULL) ||
+		    (job_ptr->part_ptr == NULL) ||
+		    ((job_ptr->job_state != JOB_RUNNING) &&
+		     (job_ptr->job_state != JOB_SUSPENDED))) {
+			list_remove(job_iterator);
+			error("cons_res: select_p_reconfigure: removing "
+				"nonexistent/invalid job %u", job->job_id);
+			_xfree_select_cr_job(job);
+			continue;
+		}
+
+		if (job_ptr->job_state == JOB_SUSPENDED)
+			suspend = 1;
+		if ((job->state & CR_JOB_ALLOCATED_MEM) ||
+		    (job->state & CR_JOB_ALLOCATED_CPUS)) {
+			job->state = 0;
+			_add_job_to_nodes(job, "select_p_reconfigure", suspend);
+			/* ignore any errors. partition and/or node config 
+			 * may have changed while jobs remain running */
+		}
+	}
+	list_iterator_destroy(job_iterator);
+	slurm_mutex_unlock(&cr_mutex);
+	last_cr_update_time = time(NULL);
+
+	return SLURM_SUCCESS;
+}
+
+extern struct multi_core_data * create_default_mc(void)
+{
+	struct multi_core_data *mc_ptr;
+	mc_ptr = xmalloc(sizeof(struct multi_core_data));
+	mc_ptr->min_sockets = 1;
+	mc_ptr->max_sockets = 0xffff;
+	mc_ptr->min_cores   = 1;
+	mc_ptr->max_cores   = 0xffff;
+	mc_ptr->min_threads = 1;
+	mc_ptr->max_threads = 0xffff;
+/*	mc_ptr is initialized to zero by xmalloc*/
+/*	mc_ptr->ntasks_per_socket = 0; */
+/*	mc_ptr->ntasks_per_core   = 0; */
+/*	mc_ptr->plane_size        = 0; */
+	return mc_ptr;
+}
+
+extern int select_p_step_begin(struct step_record *step_ptr)
+{
+	slurm_step_layout_t *step_layout = step_ptr->step_layout;
+	struct select_cr_job *job;
+	struct node_cr_record *this_node;
+	int job_node_inx, step_node_inx, host_index;
+	uint32_t avail_mem, step_mem;
+ 
+	xassert(select_cr_job_list);
+	xassert(step_ptr->job_ptr);
+	xassert(step_ptr->job_ptr->details);
+	xassert(step_ptr->step_node_bitmap);
+
+	if (step_layout == NULL)
+		return SLURM_SUCCESS;	/* batch script */
+	if (step_ptr->job_ptr->details->job_min_memory)
+		return SLURM_SUCCESS;
+	if ((cr_type != CR_CORE_MEMORY) && (cr_type != CR_CPU_MEMORY) &&
+	    (cr_type != CR_MEMORY) && (cr_type != CR_SOCKET_MEMORY))
+		return SLURM_SUCCESS;
+
+	job = list_find_first(select_cr_job_list, _find_job_by_id,
+			      &step_ptr->job_ptr->job_id);
+	if (!job) {
+		error("select_p_step_begin: could not find step %u.%u",
+		      step_ptr->job_ptr->job_id, step_ptr->step_id);
+		return ESLURM_INVALID_JOB_ID;
+	}
+
+	/* test if there is sufficient memory */
+	step_node_inx = -1;
+	for (host_index = 0; host_index < select_node_cnt; host_index++) {
+		if (bit_test(step_ptr->step_node_bitmap, host_index) == 0)
+			continue;
+		step_node_inx++;
+
+		this_node = &select_node_ptr[host_index];
+		step_mem = step_layout->tasks[step_node_inx] * 
+			   step_ptr->mem_per_task;
+		avail_mem = select_node_ptr[host_index].real_memory;
+		if ((this_node->alloc_memory + step_mem) > avail_mem)
+			return SLURM_ERROR;	/* no room */
+	}
+
+	/* reserve the memory */
+	job_node_inx = -1;
+	step_node_inx = -1;
+	for (host_index = 0; host_index < select_node_cnt; host_index++) {
+		if (bit_test(job->node_bitmap, host_index) == 0)
+			continue;
+		job_node_inx++;
+		if (bit_test(step_ptr->step_node_bitmap, host_index) == 0)
+			continue;
+		step_node_inx++;
+
+		this_node = &select_node_ptr[host_index];
+		step_mem = step_layout->tasks[step_node_inx] * 
+			   step_ptr->mem_per_task;
+		job->alloc_memory[job_node_inx] += step_mem;
+		this_node->alloc_memory += step_mem;
+	}
+	last_cr_update_time = time(NULL);
+	return SLURM_SUCCESS;
+}
+
+extern int select_p_step_fini(struct step_record *step_ptr)
+{
+	slurm_step_layout_t *step_layout = step_ptr->step_layout;
+	struct select_cr_job *job;
+	struct node_cr_record *this_node;
+	int job_node_inx, step_node_inx, host_index, rc = SLURM_SUCCESS;
+	uint32_t step_mem;
+ 
+	xassert(select_cr_job_list);
+	xassert(step_ptr->job_ptr);
+	xassert(step_ptr->job_ptr->details);
+	xassert(step_ptr->step_node_bitmap);
+
+	if (step_layout == NULL)
+		return SLURM_SUCCESS;	/* batch script */
+	if (step_ptr->job_ptr->details->job_min_memory)
+		return SLURM_SUCCESS;
+	if ((cr_type != CR_CORE_MEMORY) && (cr_type != CR_CPU_MEMORY) &&
+	    (cr_type != CR_MEMORY) && (cr_type != CR_SOCKET_MEMORY))
+		return SLURM_SUCCESS;
+
+	job = list_find_first(select_cr_job_list, _find_job_by_id,
+			      &step_ptr->job_ptr->job_id);
+	if (!job) {
+		error("select_p_step_fini: could not find step %u.%u",
+		      step_ptr->job_ptr->job_id, step_ptr->step_id);
+		return ESLURM_INVALID_JOB_ID;
+	}
+
+	job_node_inx = -1;
+	step_node_inx = -1;
+	for (host_index = 0; host_index < select_node_cnt; host_index++) {
+		if (bit_test(job->node_bitmap, host_index) == 0)
+			continue;
+		job_node_inx++;
+		if (bit_test(step_ptr->step_node_bitmap, host_index) == 0)
+			continue;
+		step_node_inx++;
+
+		this_node = &select_node_ptr[host_index];
+		step_mem = step_layout->tasks[step_node_inx] * 
+			   step_ptr->mem_per_task;
+		if (job->alloc_memory[job_node_inx] >= step_mem)
+			job->alloc_memory[job_node_inx] -= step_mem;
+		else {
+			if (rc == SLURM_SUCCESS) {
+				error("select_p_step_fini: job alloc_memory "
+				      "underflow on %s",
+				      this_node->node_ptr->name);
+				rc = SLURM_ERROR;  
+			}
+			job->alloc_memory[host_index] = 0;
+		}
+		if (this_node->alloc_memory >= step_mem)
+			this_node->alloc_memory -= step_mem;
+		else {
+			if (rc == SLURM_SUCCESS) {
+				error("select_p_step_fini: node alloc_memory "
+				      "underflow on %s",
+				      this_node->node_ptr->name);
+				rc = SLURM_ERROR;  
+			}
+			this_node->alloc_memory = 0;
+		}
+	}
+	last_cr_update_time = time(NULL);
+	return rc;
+}
diff --git a/src/plugins/select/cons_res/select_cons_res.h b/src/plugins/select/cons_res/select_cons_res.h
index 3a494f505610854099b86c6001d9109bc866294a..63f50c6d63a7434ddc7393afec438465db34a979 100644
--- a/src/plugins/select/cons_res/select_cons_res.h
+++ b/src/plugins/select/cons_res/select_cons_res.h
@@ -5,7 +5,7 @@
  *****************************************************************************
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -41,12 +41,14 @@
 
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <slurm/slurm.h>
 #include <slurm/slurm_errno.h>
 
 #include "src/common/list.h"
 #include "src/common/log.h"
 #include "src/common/node_select.h"
+#include "src/common/pack.h"
 #include "src/common/slurm_protocol_api.h"
 #include "src/common/xassert.h"
 #include "src/common/xmalloc.h"
@@ -56,31 +58,54 @@
 
 #include "src/slurmd/slurmd/slurmd.h"
 
+/* part_cr_record keeps track of the allocated cores of a node that
+ * has been assigned to a partition. SLURM allows a node to be
+ * assigned to more than one partition. One or more partitions
+ * may be configured to share the cores with more than one job.
+ */
+struct part_cr_record {
+	struct part_record *part_ptr;	/* ptr to slurmctld partition record */
+	uint16_t *alloc_cores;		/* core count per socket reserved by
+					 * already scheduled jobs */
+	uint16_t num_rows;		/* number of rows in alloc_cores. The
+					 * length of alloc_cores is
+					 * num_sockets * num_rows. */
+	struct part_cr_record *next;	/* ptr to next part_cr_record */
+};
+
+/*
+ * node_cr_record.node_state assists with the unique state of each node.
+ * NOTES:
+ * - If node is in use by Shared=NO part, some CPUs/memory may be available
+ * - Caution with NODE_CR_AVAILABLE: a Sharing partition could be full!!
+ */
+enum node_cr_state {
+	NODE_CR_RESERVED, /* node is NOT available for use by any other jobs */
+	NODE_CR_ONE_ROW,  /* node is in use by Shared=NO part */
+	NODE_CR_AVAILABLE /* The node may be IDLE or IN USE by Sharing part(s)*/
+};
+
 /* node_cr_record keeps track of the resources within a node which 
  * have been reserved by already scheduled jobs. 
+ *
+ * NOTE: The locations of these entries are synchronized with the 
+ * job records in slurmctld (entry X in both tables are the same).
  */
-/*** NOTE: If any changes are made here, the following data structure has
- ***       persistent state which is maintained by select_cons_res.c:
- ***		select_p_state_save
- ***		select_p_state_restore
- ***		select_p_node_init
- *** 
- *** as well as tracked by version control
- ***		select_cons_res.c:pstate_version
- *** which should be incremented if any changes are made.
- **/
 struct node_cr_record {
-	struct node_record *node_ptr;	/* ptr to the node that own these resources */
-	char *name;		/* reference copy of node_ptr name */
-	uint16_t alloc_lps;	/* cpu count reserved by already scheduled jobs */
-	uint16_t alloc_sockets;	/* socket count reserved by already scheduled jobs */
-	uint16_t num_sockets;	/* number of sockets in alloc_cores */
-	uint16_t *alloc_cores;	/* core count per socket reserved by
-				 * already scheduled jobs */
-	uint32_t alloc_memory;	/* real memory reserved by already scheduled jobs */
-	struct node_cr_record *node_next;/* next entry with same hash index */
+	struct node_record *node_ptr;	/* ptr to the actual node */
+	uint16_t cpus;			/* count of processors configured */
+	uint16_t sockets;		/* count of sockets configured */
+	uint16_t cores;			/* count of cores configured */
+	uint16_t threads;		/* count of threads configured */
+	uint32_t real_memory;		/* MB of real memory configured */
+	enum node_cr_state node_state;	/* see node_cr_state comments */
+	struct part_cr_record *parts;	/* ptr to singly-linked part_cr_record
+					 * list that contains alloc_core info */
+	uint32_t alloc_memory;		/* real memory reserved by already
+					 * scheduled jobs */
 };
-
+extern struct node_cr_record *select_node_ptr;
+extern uint16_t select_fast_schedule;
 
 /*** NOTE: If any changes are made here, the following data structure has
  ***       persistent state which is maintained by select_cons_res.c:
@@ -92,46 +117,48 @@ struct node_cr_record {
  *** which should be incremented if any changes are made.
  **/
 struct select_cr_job {
+	/* Information preserved across reboots */
 	uint32_t job_id;	/* job ID, default set by SLURM        */
-	uint16_t state;		/* job state information               */
+	enum node_cr_state node_req;    /* see node_cr_state comments */
 	uint32_t nprocs;	/* --nprocs=n,      -n n               */
-	uint16_t nhosts;	/* number of hosts allocated to job    */
-	char **host;		/* hostname vector                     */
+	uint32_t nhosts;	/* number of hosts allocated to job    */
 	uint16_t *cpus;		/* number of processors on each host,
 				 * if using Moab scheduler (sched/wiki2)
 				 * then this will be initialized to the
 				 * number of CPUs desired on the node	*/
-	uint16_t *alloc_lps;	/* number of allocated threads/lps on
+	uint16_t *alloc_cpus;	/* number of allocated threads/cpus on
 				 * each host */
-	uint16_t *alloc_sockets;/* number of allocated sockets on each
-				 * host */
 	uint16_t *num_sockets;	/* number of sockets in alloc_cores[node] */
 	uint16_t **alloc_cores;	/* number of allocated cores on each
 				 * host */
 	uint32_t *alloc_memory;	/* number of allocated MB of real
 				 * memory on each host */
-	uint16_t max_sockets;
-	uint16_t max_cores;
-	uint16_t max_threads;
-	uint16_t min_sockets;
-	uint16_t min_cores;
-	uint16_t min_threads;
-	uint16_t ntasks_per_node;
-	uint16_t ntasks_per_socket;
-	uint16_t ntasks_per_core;
-	uint16_t cpus_per_task;      
-	bitstr_t *node_bitmap;	/* bitmap of nodes allocated to job    */
+	uint16_t *node_offset;	/* the node_cr_record->alloc_cores row to
+				 * which this job was assigned */
+
+	/* Information re-established after reboot */
+	struct job_record *job_ptr;	/* pointer to slurmctld job record */
+	uint16_t state;		/* job state information               */
+	bitstr_t *node_bitmap;	/* bitmap of nodes allocated to job, 
+				 * NOTE: The node_bitmap in slurmctld's job
+				 * structure clears bits as on completion.
+				 * This bitmap is persistent through lifetime
+				 * of the job. */
 };
 
 struct node_cr_record * find_cr_node_record (const char *name);
 
+/* Find a partition record based upon pointer to slurmctld record */
+struct part_cr_record *get_cr_part_ptr(struct node_cr_record *this_node,
+				      struct part_record *part_ptr);
+
 void get_resources_this_node(uint16_t *cpus, 
 			     uint16_t *sockets, 
 			     uint16_t *cores,
 			     uint16_t *threads, 
 			     struct node_cr_record *this_cr_node,
-			     uint16_t *alloc_sockets, 
-			     uint16_t *alloc_lps,
-			     uint32_t *jobid);
+			     uint32_t jobid);
+
+extern struct multi_core_data * create_default_mc(void);
 
 #endif /* !_CONS_RES_H */
diff --git a/src/plugins/select/linear/Makefile.am b/src/plugins/select/linear/Makefile.am
index 97fd5647b703ccb0745337e40071c3a46a5259a9..b398747c96cf8b2d5873a6d5a610f8c9d56e66a5 100644
--- a/src/plugins/select/linear/Makefile.am
+++ b/src/plugins/select/linear/Makefile.am
@@ -9,7 +9,6 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
 pkglib_LTLIBRARIES = select_linear.la
 
 # Linear node selection plugin.
-select_linear_la_SOURCES = select_linear.c
+select_linear_la_SOURCES = select_linear.c select_linear.h
 select_linear_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-select_linear_la_LIBADD  = $(top_builddir)/src/common/libcommon.la
 
diff --git a/src/plugins/select/linear/Makefile.in b/src/plugins/select/linear/Makefile.in
index b18586a04e2a2666d12749d6c4a701de59309b33..b97714262a529ec7515ed5aecdd3bbe7d9882fab 100644
--- a/src/plugins/select/linear/Makefile.in
+++ b/src/plugins/select/linear/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,14 +75,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-select_linear_la_DEPENDENCIES =  \
-	$(top_builddir)/src/common/libcommon.la
+select_linear_la_LIBADD =
 am_select_linear_la_OBJECTS = select_linear.lo
 select_linear_la_OBJECTS = $(am_select_linear_la_OBJECTS)
 select_linear_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(select_linear_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -120,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -259,9 +271,8 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
 pkglib_LTLIBRARIES = select_linear.la
 
 # Linear node selection plugin.
-select_linear_la_SOURCES = select_linear.c
+select_linear_la_SOURCES = select_linear.c select_linear.h
 select_linear_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-select_linear_la_LIBADD = $(top_builddir)/src/common/libcommon.la
 all: all-am
 
 .SUFFIXES:
@@ -301,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -310,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -365,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -378,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -389,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/select/linear/select_linear.c b/src/plugins/select/linear/select_linear.c
index ec46310a6083fb6fa7d48f366c16043464a21ce4..28c8ddc8ea3a3dfeded36e844e115b2a0255ecac 100644
--- a/src/plugins/select/linear/select_linear.c
+++ b/src/plugins/select/linear/select_linear.c
@@ -3,12 +3,13 @@
  *  address space. Selects nodes for a job so as to minimize the number 
  *  of sets of consecutive nodes using a best-fit algorithm.
  *
- *  $Id: select_linear.c 13767 2008-04-02 17:29:59Z jette $
+ *  $Id: select_linear.c 14103 2008-05-21 20:31:22Z jette $
  *****************************************************************************
- *  Copyright (C) 2004-2006 The Regents of the University of California.
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -61,15 +62,46 @@
 #include "src/common/node_select.h"
 #include "src/common/parse_time.h"
 #include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_resource_info.h"
 #include "src/common/xassert.h"
 #include "src/common/xmalloc.h"
 
-#include "src/common/slurm_resource_info.h"
-
 #include "src/slurmctld/slurmctld.h"
 #include "src/slurmctld/proc_req.h"
-
-#define SELECT_DEBUG 0
+#include "src/plugins/select/linear/select_linear.h"
+
+#define SELECT_DEBUG	0
+#define NO_SHARE_LIMIT	0xfffe
+
+static int  _add_job_to_nodes(struct node_cr_record *node_cr_ptr,
+			      struct job_record *job_ptr, char *pre_err, 
+			      int suspended);
+static int  _add_step(struct step_record *step_ptr);
+static void _cr_job_list_del(void *x);
+static int  _cr_job_list_sort(void *x, void *y);
+static void _del_list_step(void *x);
+static void _dump_node_cr(struct node_cr_record *node_cr_ptr);
+static struct node_cr_record *_dup_node_cr(struct node_cr_record *node_cr_ptr);
+static int  _find_job_mate(struct job_record *job_ptr, bitstr_t *bitmap,
+			   uint32_t min_nodes, uint32_t max_nodes,
+			   uint32_t req_nodes);
+static int  _find_step(struct step_record *step_ptr);
+static void _free_node_cr(struct node_cr_record *node_cr_ptr);
+static void _init_node_cr(void);
+static int _job_count_bitmap(struct node_cr_record *node_cr_ptr,
+			     struct job_record *job_ptr, 
+			     bitstr_t * bitmap, bitstr_t * jobmap, 
+			     int run_job_cnt, int tot_job_cnt);
+static int _job_test(struct job_record *job_ptr, bitstr_t *bitmap,
+		     uint32_t min_nodes, uint32_t max_nodes, 
+		     uint32_t req_nodes);
+static int _remove_step(struct step_record *step_ptr);
+static int _rm_job_from_nodes(struct node_cr_record *node_cr_ptr,
+			      struct job_record *job_ptr, char *pre_err, 
+			      int remove_all);
+static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
+			  uint32_t min_nodes, uint32_t max_nodes, 
+			  int max_share, uint32_t req_nodes);
 
 /*
  * These variables are required by the generic plugin interface.  If they
@@ -106,6 +138,11 @@ const uint32_t plugin_version	= 90;
 static struct node_record *select_node_ptr = NULL;
 static int select_node_cnt = 0;
 static uint16_t select_fast_schedule;
+static uint16_t cr_type;
+
+static struct node_cr_record *node_cr_ptr = NULL;
+static pthread_mutex_t cr_mutex = PTHREAD_MUTEX_INITIALIZER;
+static List step_cr_list = NULL;
 
 #ifdef HAVE_XCPU
 #define XCPU_POLL_TIME 120
@@ -186,7 +223,7 @@ static int _init_status_pthread(void)
 
 static int _fini_status_pthread(void)
 {
-	int i, rc=SLURM_SUCCESS;
+	int i, rc = SLURM_SUCCESS;
 
 	slurm_mutex_lock( &thread_flag_mutex );
 	if ( xcpu_thread ) {
@@ -208,8 +245,7 @@ static int _fini_status_pthread(void)
 }
 #endif
 
-static bool 
-_enough_nodes(int avail_nodes, int rem_nodes, 
+static bool _enough_nodes(int avail_nodes, int rem_nodes, 
 		uint32_t min_nodes, uint32_t req_nodes)
 {
 	int needed_nodes;
@@ -232,6 +268,12 @@ extern int init ( void )
 #ifdef HAVE_XCPU
 	rc = _init_status_pthread();
 #endif
+#ifdef HAVE_BG
+	error("%s is incompatable with BlueGene", plugin_name);
+	fatal("Use SelectType=select/bluegene");
+#endif
+	cr_type = (select_type_plugin_info_t)
+			slurmctld_conf.select_type_param;
 	return rc;
 }
 
@@ -241,6 +283,13 @@ extern int fini ( void )
 #ifdef HAVE_XCPU
 	rc = _fini_status_pthread();
 #endif
+	slurm_mutex_lock(&cr_mutex);
+	_free_node_cr(node_cr_ptr);
+	node_cr_ptr = NULL;
+	if (step_cr_list)
+		list_destroy(step_cr_list);
+	step_cr_list = NULL;
+	slurm_mutex_unlock(&cr_mutex);
 	return rc;
 }
 
@@ -276,6 +325,17 @@ extern int select_p_node_init(struct node_record *node_ptr, int node_cnt)
 		return SLURM_ERROR;
 	}
 
+	/* NOTE: We free the consumable resources info here, but
+	 * can't rebuild it since the partition and node structures
+	 * have not yet had node bitmaps reset. */
+	slurm_mutex_lock(&cr_mutex);
+	_free_node_cr(node_cr_ptr);
+	node_cr_ptr = NULL;
+	if (step_cr_list)
+		list_destroy(step_cr_list);
+	step_cr_list = NULL;
+	slurm_mutex_unlock(&cr_mutex);
+
 	select_node_ptr = node_ptr;
 	select_node_cnt = node_cnt;
 	select_fast_schedule = slurm_get_fast_schedule();
@@ -307,19 +367,19 @@ static uint16_t _get_avail_cpus(struct job_record *job_ptr, int index)
 	multi_core_data_t *mc_ptr = NULL;
 	int min_sockets = 0, min_cores = 0;
 
-	if (job_ptr->details) {
-		if (job_ptr->details->cpus_per_task)
-			cpus_per_task = job_ptr->details->cpus_per_task;
-		if (job_ptr->details->ntasks_per_node)
-			ntasks_per_node = job_ptr->details->ntasks_per_node;
-		mc_ptr = job_ptr->details->mc_ptr;
-	}
-	if (mc_ptr) {
-		max_sockets       = job_ptr->details->mc_ptr->max_sockets;
-		max_cores         = job_ptr->details->mc_ptr->max_cores;
-		max_threads       = job_ptr->details->mc_ptr->max_threads;
-		ntasks_per_socket = job_ptr->details->mc_ptr->ntasks_per_socket;
-		ntasks_per_core   = job_ptr->details->mc_ptr->ntasks_per_core;
+	if (job_ptr->details == NULL)
+		return (uint16_t) 0;
+
+	if (job_ptr->details->cpus_per_task)
+		cpus_per_task = job_ptr->details->cpus_per_task;
+	if (job_ptr->details->ntasks_per_node)
+		ntasks_per_node = job_ptr->details->ntasks_per_node;
+	if ((mc_ptr = job_ptr->details->mc_ptr)) {
+		max_sockets       = mc_ptr->max_sockets;
+		max_cores         = mc_ptr->max_cores;
+		max_threads       = mc_ptr->max_threads;
+		ntasks_per_socket = mc_ptr->ntasks_per_socket;
+		ntasks_per_core   = mc_ptr->ntasks_per_core;
 	}
 
 	node_ptr = &(select_node_ptr[index]);
@@ -347,8 +407,7 @@ static uint16_t _get_avail_cpus(struct job_record *job_ptr, int index)
 			max_sockets, max_cores, max_threads, 
 			min_sockets, min_cores, cpus_per_task,
 			ntasks_per_node, ntasks_per_socket, ntasks_per_core,
-	    		&cpus, &sockets, &cores, &threads, 
-			(uint16_t) 0, NULL, (uint16_t) 0, 
+	    		&cpus, &sockets, &cores, &threads, NULL, 
 			SELECT_TYPE_INFO_NONE,
 			job_ptr->job_id, node_ptr->name);
 
@@ -366,14 +425,16 @@ static uint16_t _get_avail_cpus(struct job_record *job_ptr, int index)
  * 	"best" is defined as either single set of consecutive nodes satisfying 
  *	the request and leaving the minimum number of unused nodes OR 
  *	the fewest number of consecutive node sets
- * IN job_ptr - pointer to job being scheduled
+ * IN/OUT job_ptr - pointer to job being considered for initiation,
+ *                  set's start_time when job expected to start
  * IN/OUT bitmap - usable nodes are set on input, nodes not required to 
  *	satisfy the request are cleared, other left set
  * IN min_nodes - minimum count of nodes
  * IN req_nodes - requested (or desired) count of nodes
  * IN max_nodes - maximum count of nodes (0==don't care)
- * IN test_only - if true, only test if ever could run, not necessarily now,
- *	not used in this implementation of plugin
+ * IN mode - SELECT_MODE_RUN_NOW: try to schedule job now
+ *           SELECT_MODE_TEST_ONLY: test if job can ever run
+ *           SELECT_MODE_WILL_RUN: determine when and where job can run
  * RET zero on success, EINVAL otherwise
  * globals (passed via select_p_node_init): 
  *	node_record_count - count of nodes configured
@@ -387,7 +448,224 @@ static uint16_t _get_avail_cpus(struct job_record *job_ptr, int index)
  */
 extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 			uint32_t min_nodes, uint32_t max_nodes, 
-			uint32_t req_nodes, bool test_only)
+			uint32_t req_nodes, int mode)
+{
+	bitstr_t *orig_map;
+	int max_run_job, j, sus_jobs, rc = EINVAL, prev_cnt = -1;
+	int min_share = 0, max_share = 0;
+	uint32_t save_mem = 0;
+
+	xassert(bitmap);
+	if (job_ptr->details == NULL)
+		return EINVAL;
+
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL) {
+		_init_node_cr();
+		if (node_cr_ptr == NULL) {
+			slurm_mutex_unlock(&cr_mutex);
+			error("select_p_job_test: node_cr_ptr not initialized");
+			return SLURM_ERROR;
+		}
+	}
+
+	if (bit_set_count(bitmap) < min_nodes) {
+		slurm_mutex_unlock(&cr_mutex);
+		return EINVAL;
+	}
+
+	if (mode != SELECT_MODE_TEST_ONLY) {
+		if (job_ptr->details->shared == 1) {
+			max_share = job_ptr->part_ptr->max_share & 
+					~SHARED_FORCE;
+		} else	/* ((shared == 0) || (shared == (uint16_t) NO_VAL)) */
+			max_share = 1;
+	}
+
+	if (mode == SELECT_MODE_WILL_RUN) {
+		rc = _will_run_test(job_ptr, bitmap, min_nodes, max_nodes,
+				    max_share, req_nodes);
+		slurm_mutex_unlock(&cr_mutex);
+		return rc;
+	} else if (mode == SELECT_MODE_TEST_ONLY) {
+		min_share = NO_SHARE_LIMIT;
+		max_share = min_share + 1;
+		save_mem = job_ptr->details->job_min_memory;
+		job_ptr->details->job_min_memory = 0;
+	}
+
+	orig_map = bit_copy(bitmap);
+	for (max_run_job=min_share; max_run_job<max_share; max_run_job++) {
+		bool last_iteration = (max_run_job == (max_share -1));
+		for (sus_jobs=0; ((sus_jobs<5) && (rc != SLURM_SUCCESS)); 
+		     sus_jobs++) {
+			if (last_iteration)
+				sus_jobs = NO_SHARE_LIMIT;
+			j = _job_count_bitmap(node_cr_ptr, job_ptr, 
+					      orig_map, bitmap, 
+					      max_run_job, 
+					      max_run_job + sus_jobs);
+			if ((j == prev_cnt) || (j < min_nodes))
+				continue;
+			prev_cnt = j;
+			if ((mode == SELECT_MODE_RUN_NOW) && (max_run_job > 0)) {
+				/* We need to share. 
+				 * Try to find suitable job to share nodes with */
+				rc = _find_job_mate(job_ptr, bitmap, min_nodes, 
+						    max_nodes, req_nodes);
+				if (rc == SLURM_SUCCESS)
+					break;
+			}
+			rc = _job_test(job_ptr, bitmap, min_nodes, max_nodes, 
+				       req_nodes);
+			if (rc == SLURM_SUCCESS)
+				break;
+			continue;
+		}
+	}
+	bit_free(orig_map);
+	slurm_mutex_unlock(&cr_mutex);
+	if (save_mem)
+		job_ptr->details->job_min_memory = save_mem;
+	return rc;
+}
+
+/*
+ * select_p_job_list_test - Given a list of select_will_run_t's in
+ *	accending priority order we will see if we can start and
+ *	finish all the jobs without increasing the start times of the
+ *	jobs specified and fill in the est_start of requests with no
+ *	est_start.  If you are looking to see if one job will ever run
+ *	then use select_p_job_test instead.
+ * IN/OUT req_list - list of select_will_run_t's in asscending
+ *	             priority order on success of placement fill in
+ *	             est_start of request with time.
+ * RET zero on success, EINVAL otherwise
+ */
+extern int select_p_job_list_test(List req_list)
+{
+	/* not currently supported */
+	return EINVAL;
+}
+
+/*
+ * Set the bits in 'jobmap' that correspond to bits in the 'bitmap'
+ * that are running 'run_job_cnt' jobs or less, and clear the rest.
+ */
+static int _job_count_bitmap(struct node_cr_record *node_cr_ptr,
+			     struct job_record *job_ptr, 
+			     bitstr_t * bitmap, bitstr_t * jobmap, 
+			     int run_job_cnt, int tot_job_cnt)
+{
+	int i, count = 0, total_jobs, total_run_jobs;
+	struct part_cr_record *part_cr_ptr;
+	uint32_t job_memory = 0;
+	bool exclusive;
+
+	xassert(node_cr_ptr);
+
+	/* Jobs submitted to a partition with 
+	 * Shared=FORCE:1 may share resources with jobs in other partitions
+	 * Shared=NO  may not share resources with jobs in other partitions */
+	if (run_job_cnt || (job_ptr->part_ptr->max_share & SHARED_FORCE))
+		exclusive = false;
+	else
+		exclusive = true;
+
+	if (job_ptr->details->job_min_memory  && (cr_type == CR_MEMORY))
+		job_memory = job_ptr->details->job_min_memory;
+
+	for (i = 0; i < node_record_count; i++) {
+		if (!bit_test(bitmap, i)) {
+			bit_clear(jobmap, i);
+			continue;
+		}
+
+		if (select_fast_schedule) {
+			if ((node_cr_ptr[i].alloc_memory + job_memory) >
+			     node_record_table_ptr[i].config_ptr->real_memory) {
+				bit_clear(jobmap, i);
+				continue;
+			}
+		} else {
+			if ((node_cr_ptr[i].alloc_memory + job_memory) >
+			     node_record_table_ptr[i].real_memory) {
+				bit_clear(jobmap, i);
+				continue;
+			}
+		}
+
+		if ((run_job_cnt != NO_SHARE_LIMIT) &&
+		    (node_cr_ptr[i].exclusive_jobid != 0)) {
+			/* already reserved by some exclusive job */
+			bit_clear(jobmap, i);
+			continue;
+		}
+
+		total_jobs = 0;
+		total_run_jobs = 0;
+		part_cr_ptr = node_cr_ptr[i].parts;
+		while (part_cr_ptr) {
+			if (exclusive) {      /* count jobs in all partitions */
+				total_run_jobs += part_cr_ptr->run_job_cnt;
+				total_jobs     += part_cr_ptr->tot_job_cnt;
+			} else if (part_cr_ptr->part_ptr == job_ptr->part_ptr) {
+				total_run_jobs += part_cr_ptr->run_job_cnt;
+				total_jobs     += part_cr_ptr->tot_job_cnt; 
+				break;
+			}
+			part_cr_ptr = part_cr_ptr->next;
+		}
+		if ((run_job_cnt != 0) && (part_cr_ptr == NULL)) {
+			error("_job_count_bitmap: could not find "
+				"partition %s for node %s",
+				job_ptr->part_ptr->name,
+				node_record_table_ptr[i].name);
+		}
+		if ((total_run_jobs <= run_job_cnt) &&
+		    (total_jobs     <= tot_job_cnt)) {
+			bit_set(jobmap, i);
+			count++;
+		} else {
+			bit_clear(jobmap, i);
+		}
+
+	}
+	return count;
+}
+
+/* _find_job_mate - does most of the real work for select_p_job_test(), 
+ *	in trying to find a suitable job to mate this one with. This is 
+ *	a pretty simple algorithm now, but could try to match the job 
+ *	with multiple jobs that add up to the proper size or a single 
+ *	job plus a few idle nodes. */
+static int _find_job_mate(struct job_record *job_ptr, bitstr_t *bitmap,
+			  uint32_t min_nodes, uint32_t max_nodes,
+			  uint32_t req_nodes)
+{
+	ListIterator job_iterator;
+	struct job_record *job_scan_ptr;
+
+	job_iterator = list_iterator_create(job_list);
+	while ((job_scan_ptr = (struct job_record *) list_next(job_iterator))) {
+		if ((job_scan_ptr->part_ptr == job_ptr->part_ptr) &&
+		    (job_scan_ptr->job_state == JOB_RUNNING) &&
+		    (job_scan_ptr->node_cnt == req_nodes) &&
+		    (job_scan_ptr->total_procs >= job_ptr->num_procs) &&
+		    bit_super_set(job_scan_ptr->node_bitmap, bitmap)) {
+			bit_and(bitmap, job_scan_ptr->node_bitmap);
+			return SLURM_SUCCESS;
+		}
+	}
+	list_iterator_destroy(job_iterator);
+	return EINVAL;
+}
+
+/* _job_test - does most of the real work for select_p_job_test(), which 
+ *	pretty much just handles load-leveling and max_share logic */
+static int _job_test(struct job_record *job_ptr, bitstr_t *bitmap,
+			uint32_t min_nodes, uint32_t max_nodes, 
+			uint32_t req_nodes)
 {
 	int i, index, error_code = EINVAL, sufficient;
 	int *consec_nodes;	/* how many nodes we can add from this 
@@ -402,20 +680,11 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 	int rem_cpus, rem_nodes;	/* remaining resources desired */
 	int best_fit_nodes, best_fit_cpus, best_fit_req;
 	int best_fit_location = 0, best_fit_sufficient;
-	int avail_cpus;
-	multi_core_data_t *mc_ptr = job_ptr->details->mc_ptr;
+	int avail_cpus, alloc_cpus = 0;
 
-	xassert(bitmap);
-	if (mc_ptr) {
-		debug3("job min-[max]: -N %u-[%u]:%u-[%u]:%u-[%u]:%u-[%u]",
-			job_ptr->details->min_nodes,   job_ptr->details->max_nodes,
-			mc_ptr->min_sockets, mc_ptr->max_sockets,
-			mc_ptr->min_cores,   mc_ptr->max_cores,
-			mc_ptr->min_threads, mc_ptr->max_threads);
-		debug3("job ntasks-per: -node=%u -socket=%u -core=%u",
-			job_ptr->details->ntasks_per_node,
-			mc_ptr->ntasks_per_socket, mc_ptr->ntasks_per_core);
-	}
+	if ((job_ptr->details->req_node_bitmap) &&
+	    (!bit_super_set(job_ptr->details->req_node_bitmap, bitmap)))
+		return error_code;
 
 	consec_index = 0;
 	consec_size  = 50;	/* start allocation for 50 sets of 
@@ -450,7 +719,8 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 					/* first required node in set */
 					consec_req[consec_index] = index;
 				}
-				rem_cpus -= avail_cpus;
+				rem_cpus   -= avail_cpus;
+				alloc_cpus += avail_cpus;
 				rem_nodes--;
 				max_nodes--;
 			} else {	 /* node not required (yet) */
@@ -556,7 +826,8 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 				rem_nodes--;
 				max_nodes--;
 				avail_cpus = _get_avail_cpus(job_ptr, i);
-				rem_cpus -= avail_cpus;
+				rem_cpus   -= avail_cpus;
+				alloc_cpus += avail_cpus;
 			}
 			for (i = (best_fit_req - 1);
 			     i >= consec_start[best_fit_location]; i--) {
@@ -569,7 +840,8 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 				rem_nodes--;
 				max_nodes--;
 				avail_cpus = _get_avail_cpus(job_ptr, i);
-				rem_cpus -= avail_cpus;
+				rem_cpus   -= avail_cpus;
+				alloc_cpus += avail_cpus;
 			}
 		} else {
 			for (i = consec_start[best_fit_location];
@@ -583,7 +855,8 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 				rem_nodes--;
 				max_nodes--;
 				avail_cpus = _get_avail_cpus(job_ptr, i);
-				rem_cpus -= avail_cpus;
+				rem_cpus   -= avail_cpus;
+				alloc_cpus += avail_cpus;
 			}
 		}
 		if (job_ptr->details->contiguous || 
@@ -599,6 +872,10 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 	&&  _enough_nodes(0, rem_nodes, min_nodes, req_nodes)) {
 		error_code = SLURM_SUCCESS;
 	}
+	if (error_code == SLURM_SUCCESS) {
+		/* job's total_procs is needed for SELECT_MODE_WILL_RUN */
+		job_ptr->total_procs = alloc_cpus;
+	}
 
 	xfree(consec_cpus);
 	xfree(consec_nodes);
@@ -610,9 +887,9 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap,
 
 extern int select_p_job_begin(struct job_record *job_ptr)
 {
+	int rc = SLURM_SUCCESS;
 #ifdef HAVE_XCPU
 	int i;
-	int rc = SLURM_SUCCESS;
 	char clone_path[128];
 
 	xassert(job_ptr);
@@ -633,10 +910,13 @@ extern int select_p_job_begin(struct job_record *job_ptr)
 				job_ptr->user_id);
 		}
 	}
-	return rc;
-#else
-	return SLURM_SUCCESS;
 #endif
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL)
+		_init_node_cr();
+	_add_job_to_nodes(node_cr_ptr, job_ptr, "select_p_job_begin", 1);
+	slurm_mutex_unlock(&cr_mutex);
+	return rc;
 }
 
 extern int select_p_job_fini(struct job_record *job_ptr)
@@ -660,19 +940,39 @@ extern int select_p_job_fini(struct job_record *job_ptr)
 		}
 	}
 #endif
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL)
+		_init_node_cr();
+	_rm_job_from_nodes(node_cr_ptr, job_ptr, "select_p_job_fini", 1);
+	slurm_mutex_unlock(&cr_mutex);
 	return rc;
 }
 
 extern int select_p_job_suspend(struct job_record *job_ptr)
 {
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL)
+		_init_node_cr();
+	_rm_job_from_nodes(node_cr_ptr, job_ptr, "select_p_job_suspend", 0);
+	slurm_mutex_unlock(&cr_mutex);
 	return SLURM_SUCCESS;
 }
 
 extern int select_p_job_resume(struct job_record *job_ptr)
 {
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL)
+		_init_node_cr();
+	_add_job_to_nodes(node_cr_ptr, job_ptr, "select_p_job_resume", 0);
+	slurm_mutex_unlock(&cr_mutex);
 	return SLURM_SUCCESS;
 }
 
+extern int select_p_get_job_cores(uint32_t job_id, int alloc_index, int s)
+{
+	return 0;
+}
+
 extern int select_p_job_ready(struct job_record *job_ptr)
 {
 	if (job_ptr->job_state != JOB_RUNNING)
@@ -696,7 +996,52 @@ extern int select_p_get_select_nodeinfo (struct node_record *node_ptr,
 
 extern int select_p_update_nodeinfo (struct job_record *job_ptr)
 {
-       return SLURM_SUCCESS;
+	int i, node_inx;
+	ListIterator step_iterator;
+	struct step_record *step_ptr;
+	uint32_t step_mem;
+
+	xassert(job_ptr);
+
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL)
+		_init_node_cr();
+	slurm_mutex_unlock(&cr_mutex);
+
+	if ((job_ptr->job_state != JOB_RUNNING)
+	&&  (job_ptr->job_state != JOB_SUSPENDED))
+		return SLURM_SUCCESS;
+	if ((cr_type != CR_MEMORY) || (job_ptr->details == NULL) || 
+	    (job_ptr->details->shared == 0) || job_ptr->details->job_min_memory)
+		return SLURM_SUCCESS;
+
+	slurm_mutex_lock(&cr_mutex);
+	step_iterator = list_iterator_create (job_ptr->step_list);
+	while ((step_ptr = (struct step_record *) list_next (step_iterator))) {
+		if ((step_ptr->step_node_bitmap == NULL) ||
+		    (step_ptr->step_layout == NULL) ||
+		    (step_ptr->mem_per_task == 0) ||
+		    (_find_step(step_ptr)))	/* already added */
+			continue;
+#if SELECT_DEBUG
+		info("select_p_update_nodeinfo: %u.%u mem:%u", 
+		     step_ptr->job_ptr->job_id, step_ptr->step_id, 
+		     step_ptr->mem_per_task);
+#endif
+		node_inx = -1;
+		for (i = 0; i < select_node_cnt; i++) {
+			if (bit_test(step_ptr->step_node_bitmap, i) == 0)
+				continue;
+			node_inx++;
+			step_mem = step_ptr->step_layout->tasks[node_inx] * 
+				   step_ptr->mem_per_task;
+			node_cr_ptr[i].alloc_memory += step_mem;
+		}
+		_add_step(step_ptr);
+	}
+	list_iterator_destroy (step_iterator);
+	slurm_mutex_unlock(&cr_mutex);
+	return SLURM_SUCCESS;
 }
 
 extern int select_p_update_block (update_part_msg_t *part_desc_ptr)
@@ -714,14 +1059,14 @@ extern int select_p_get_extra_jobinfo (struct node_record *node_ptr,
                                        void *data)
 {
 	int rc = SLURM_SUCCESS;
+	uint16_t *tmp_16;
 
 	xassert(job_ptr);
 	xassert(job_ptr->magic == JOB_MAGIC);
 
 	switch (info) {
 	case SELECT_AVAIL_CPUS:
-	{
-		uint16_t *tmp_16 = (uint16_t *) data;
+		tmp_16 = (uint16_t *) data;
 
 		if (job_ptr->details &&
 		    ((job_ptr->details->cpus_per_task > 1) ||
@@ -736,7 +1081,6 @@ extern int select_p_get_extra_jobinfo (struct node_record *node_ptr,
 			}
 		}
 		break;
-	}
 	default:
 		error("select_g_get_extra_jobinfo info %d invalid", info);
 		rc = SLURM_ERROR;
@@ -761,3 +1105,635 @@ extern int select_p_alter_node_cnt(enum select_node_cnt type, void *data)
 {
 	return SLURM_SUCCESS;
 }
+
+extern int select_p_reconfigure(void)
+{
+	slurm_mutex_lock(&cr_mutex);
+	_free_node_cr(node_cr_ptr);
+	node_cr_ptr = NULL;
+	if (step_cr_list)
+		list_destroy(step_cr_list);
+	step_cr_list = NULL;
+	_init_node_cr();
+	slurm_mutex_unlock(&cr_mutex);
+
+	return SLURM_SUCCESS;
+}
+
+/*
+ * deallocate resources that were assigned to this job 
+ *
+ * if remove_all = 0: the job has been suspended, so just deallocate CPUs
+ * if remove_all = 1: deallocate all resources
+ */
+static int _rm_job_from_nodes(struct node_cr_record *node_cr_ptr,
+			      struct job_record *job_ptr, char *pre_err, 
+			      int remove_all)
+{
+	int i, rc = SLURM_SUCCESS;
+	struct part_cr_record *part_cr_ptr;
+	uint32_t job_memory = 0;
+
+	if (node_cr_ptr == NULL) {
+		error("%s: node_cr_ptr not initialized", pre_err);
+		return SLURM_ERROR;
+	}
+
+	if (remove_all && job_ptr->details && 
+	    job_ptr->details->job_min_memory && (cr_type == CR_MEMORY))
+		job_memory = job_ptr->details->job_min_memory;
+
+	for (i = 0; i < select_node_cnt; i++) {
+		if (bit_test(job_ptr->node_bitmap, i) == 0)
+			continue;
+		if (node_cr_ptr[i].alloc_memory >= job_memory)
+			node_cr_ptr[i].alloc_memory -= job_memory;
+		else {
+			node_cr_ptr[i].alloc_memory = 0;
+			error("%s: memory underflow for node %s",
+				pre_err, node_record_table_ptr[i].name);
+		}
+		if (node_cr_ptr[i].exclusive_jobid == job_ptr->job_id)
+			node_cr_ptr[i].exclusive_jobid = 0;
+		part_cr_ptr = node_cr_ptr[i].parts;
+		while (part_cr_ptr) {
+			if (part_cr_ptr->part_ptr != job_ptr->part_ptr) {
+				part_cr_ptr = part_cr_ptr->next;
+				continue;
+			}
+			if (part_cr_ptr->run_job_cnt > 0)
+				part_cr_ptr->run_job_cnt--;
+			else {
+				error("%s: run_job_cnt underflow for node %s",
+					pre_err, node_record_table_ptr[i].name);
+			}
+			if (remove_all) {
+				if (part_cr_ptr->tot_job_cnt > 0)
+					part_cr_ptr->tot_job_cnt--;
+				else {
+					error("%s: tot_job_cnt underflow "
+						"for node %s", pre_err,
+						node_record_table_ptr[i].name);
+				}
+				if ((part_cr_ptr->tot_job_cnt == 0) &&
+				    (part_cr_ptr->run_job_cnt)) {
+					part_cr_ptr->run_job_cnt = 0;
+					error("%s: run_job_count out of sync "
+						"for node %s", pre_err,
+						node_record_table_ptr[i].name);
+				}
+			}
+			break;
+		}
+		if (part_cr_ptr == NULL) {
+			error("%s: could not find partition %s for node %s",
+				pre_err, job_ptr->part_ptr->name,
+				node_record_table_ptr[i].name);
+			rc = SLURM_ERROR;
+		}
+	}
+
+	return rc;
+}
+
+/*
+ * allocate resources to the given job
+ *
+ * if alloc_all = 0: the job has been suspended, so just re-allocate CPUs
+ * if alloc_all = 1: allocate all resources (CPUs and memory)
+ */
+static int _add_job_to_nodes(struct node_cr_record *node_cr_ptr,
+			     struct job_record *job_ptr, char *pre_err, 
+			     int alloc_all)
+{
+	int i, rc = SLURM_SUCCESS, exclusive = 0;
+	struct part_cr_record *part_cr_ptr;
+	uint32_t job_memory = 0;
+
+	if (node_cr_ptr == NULL) {
+		error("%s: node_cr_ptr not initialized", pre_err);
+		return SLURM_ERROR;
+	}
+
+	if (alloc_all && job_ptr->details && 
+	    job_ptr->details->job_min_memory && (cr_type == CR_MEMORY))
+		job_memory = job_ptr->details->job_min_memory;
+	if (job_ptr->details->shared == 0)
+		exclusive = 1;
+
+	for (i = 0; i < select_node_cnt; i++) {
+		if (bit_test(job_ptr->node_bitmap, i) == 0)
+			continue;
+		node_cr_ptr[i].alloc_memory += job_memory;
+		if (exclusive) {
+			if (node_cr_ptr[i].exclusive_jobid) {
+				error("select/linear: conflicting exclusive "
+				      "jobs %u and %u on %s",
+				      job_ptr->job_id, 
+				      node_cr_ptr[i].exclusive_jobid,
+				      node_record_table_ptr[i].name);
+			}
+			node_cr_ptr[i].exclusive_jobid = job_ptr->job_id;
+		}
+
+		part_cr_ptr = node_cr_ptr[i].parts;
+		while (part_cr_ptr) {
+			if (part_cr_ptr->part_ptr != job_ptr->part_ptr) {
+				part_cr_ptr = part_cr_ptr->next;
+				continue;
+			}
+			if (alloc_all)
+				part_cr_ptr->tot_job_cnt++;
+			part_cr_ptr->run_job_cnt++;
+			break;
+		}
+		if (part_cr_ptr == NULL) {
+			error("%s: could not find partition %s for node %s",
+				pre_err, job_ptr->part_ptr->name,
+				node_record_table_ptr[i].name);
+			rc = SLURM_ERROR;
+		}
+	}
+
+	return rc;
+}
+
+static void _free_node_cr(struct node_cr_record *node_cr_ptr)
+{
+	int i;
+	struct part_cr_record *part_cr_ptr1, *part_cr_ptr2;
+
+	if (node_cr_ptr == NULL)
+		return;
+
+	for (i = 0; i < select_node_cnt; i++) {
+		part_cr_ptr1 = node_cr_ptr[i].parts;
+		while (part_cr_ptr1) {
+			part_cr_ptr2 = part_cr_ptr1->next;
+			xfree(part_cr_ptr1);
+			part_cr_ptr1 = part_cr_ptr2;
+		}
+	}
+	xfree(node_cr_ptr);
+}
+
+static inline void _dump_node_cr(struct node_cr_record *node_cr_ptr)
+{
+#if SELECT_DEBUG
+	int i;
+	struct part_cr_record *part_cr_ptr;
+
+	if (node_cr_ptr == NULL)
+		return;
+
+	for (i = 0; i < select_node_cnt; i++) {
+		info("Node:%s exclusive:%u alloc_mem:%u", 
+			node_record_table_ptr[i].name,
+			node_cr_ptr[i].exclusive_jobid,
+			node_cr_ptr[i].alloc_memory);
+
+		part_cr_ptr = node_cr_ptr[i].parts;
+		while (part_cr_ptr) {
+			info("  Part:%s run:%u tot:%u", 
+				part_cr_ptr->part_ptr->name,
+				part_cr_ptr->run_job_cnt,
+				part_cr_ptr->tot_job_cnt);
+			part_cr_ptr = part_cr_ptr->next;
+		}
+	}
+#endif
+}
+
+static struct node_cr_record *_dup_node_cr(struct node_cr_record *node_cr_ptr)
+{
+	int i;
+	struct node_cr_record *new_node_cr_ptr;
+	struct part_cr_record *part_cr_ptr, *new_part_cr_ptr;
+
+	if (node_cr_ptr == NULL)
+		return NULL;
+
+	new_node_cr_ptr = xmalloc(select_node_cnt * 
+				  sizeof(struct node_cr_record));
+
+	for (i = 0; i < select_node_cnt; i++) {
+		new_node_cr_ptr[i].alloc_memory = node_cr_ptr[i].alloc_memory;
+		new_node_cr_ptr[i].exclusive_jobid = 
+				node_cr_ptr[i].exclusive_jobid;
+		part_cr_ptr = node_cr_ptr[i].parts;
+		while (part_cr_ptr) {
+			new_part_cr_ptr = xmalloc(sizeof(struct part_cr_record));
+			new_part_cr_ptr->part_ptr    = part_cr_ptr->part_ptr;
+			new_part_cr_ptr->run_job_cnt = part_cr_ptr->run_job_cnt;
+			new_part_cr_ptr->tot_job_cnt = part_cr_ptr->tot_job_cnt;
+			new_part_cr_ptr->next 	     = new_node_cr_ptr[i].parts;
+			new_node_cr_ptr[i].parts     = new_part_cr_ptr;
+			part_cr_ptr = part_cr_ptr->next;
+		}
+	}
+	return new_node_cr_ptr;
+}
+
+static void _init_node_cr(void)
+{
+	struct part_record *part_ptr;
+	struct part_cr_record *part_cr_ptr;
+	ListIterator part_iterator;
+	struct job_record *job_ptr;
+	ListIterator job_iterator;
+	uint32_t job_memory, step_mem;
+	int exclusive, i, node_inx;
+	ListIterator step_iterator;
+	struct step_record *step_ptr;
+
+	if (node_cr_ptr)
+		return;
+
+	node_cr_ptr = xmalloc(select_node_cnt * sizeof(struct node_cr_record));
+
+	/* build partition records */
+	part_iterator = list_iterator_create(part_list);
+	while ((part_ptr = (struct part_record *) list_next(part_iterator))) {
+		for (i = 0; i < select_node_cnt; i++) {
+			if (part_ptr->node_bitmap == NULL)
+				break;
+			if (!bit_test(part_ptr->node_bitmap, i))
+				continue;
+			part_cr_ptr = xmalloc(sizeof(struct part_cr_record));
+			part_cr_ptr->next = node_cr_ptr[i].parts;
+			part_cr_ptr->part_ptr = part_ptr;
+			node_cr_ptr[i].parts = part_cr_ptr;
+		}
+		
+	}
+	list_iterator_destroy(part_iterator);
+
+	/* record running and suspended jobs in node_cr_records */
+	job_iterator = list_iterator_create(job_list);
+	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
+		if ((job_ptr->job_state != JOB_RUNNING) &&
+		    (job_ptr->job_state != JOB_SUSPENDED))
+			continue;
+
+		if (job_ptr->details && 
+		    job_ptr->details->job_min_memory && (cr_type == CR_MEMORY))
+			job_memory = job_ptr->details->job_min_memory;
+		else
+			job_memory = 0;
+		if (job_ptr->details->shared == 0)
+			exclusive = 1;
+		else
+			exclusive = 0;
+
+		for (i = 0; i < select_node_cnt; i++) {
+			if (job_ptr->node_bitmap == NULL)
+				break;
+			if (!bit_test(job_ptr->node_bitmap, i))
+				continue;
+			if (exclusive) {
+				if (node_cr_ptr[i].exclusive_jobid) {
+					error("select/linear: conflicting "
+				 	      "exclusive jobs %u and %u on %s",
+				 	      job_ptr->job_id, 
+				 	      node_cr_ptr[i].exclusive_jobid,
+				 	      node_record_table_ptr[i].name);
+				}
+				node_cr_ptr[i].exclusive_jobid = job_ptr->job_id;
+			}
+			node_cr_ptr[i].alloc_memory += job_memory;
+			part_cr_ptr = node_cr_ptr[i].parts;
+			while (part_cr_ptr) {
+				if (part_cr_ptr->part_ptr != job_ptr->part_ptr) {
+					part_cr_ptr = part_cr_ptr->next;
+					continue;
+				}
+				part_cr_ptr->tot_job_cnt++;
+				if (job_ptr->job_state == JOB_RUNNING)
+					part_cr_ptr->run_job_cnt++;
+				break;
+			}
+			if (part_cr_ptr == NULL) {
+				error("_init_node_cr: could not find "
+					"partition %s for node %s",
+					job_ptr->part_ptr->name,
+					node_record_table_ptr[i].name);
+			}
+		}
+
+		if (job_ptr->details->job_min_memory || 
+		    (job_ptr->details->shared == 0) || (cr_type != CR_MEMORY))
+			continue;
+
+		step_iterator = list_iterator_create (job_ptr->step_list);
+		while ((step_ptr = (struct step_record *) list_next (step_iterator))) {
+			if ((step_ptr->step_node_bitmap == NULL) ||
+			    (step_ptr->step_layout == NULL))
+				continue;
+
+			if (_find_step(step_ptr)) {
+				slurm_mutex_unlock(&cr_mutex);
+				error("_init_node_cr: duplicate for step %u.%u",
+				      job_ptr->job_id, step_ptr->step_id);
+				continue;
+			}
+
+			node_inx = -1;
+			for (i = 0; i < select_node_cnt; i++) {
+				if (bit_test(step_ptr->step_node_bitmap, i) == 0)
+					continue;
+				node_inx++;
+				step_mem = step_ptr->step_layout->tasks[node_inx] * 
+					   step_ptr->mem_per_task;
+				node_cr_ptr[i].alloc_memory += step_mem;
+			}
+#if SELECT_DEBUG
+			info("_init_node_cr: added %u.%u mem:%u", 
+			     job_ptr->job_id, step_ptr->step_id, step_mem);
+#endif
+			_add_step(step_ptr);
+		}
+		list_iterator_destroy (step_iterator);
+	}
+	list_iterator_destroy(job_iterator);
+	_dump_node_cr(node_cr_ptr);
+}
+
+/* Determine where and when the job at job_ptr can begin execution by updating 
+ * a scratch node_cr_record structure to reflect each job terminating at the 
+ * end of its time limit and use this to show where and when the job at job_ptr 
+ * will begin execution. Used by Moab for backfill scheduling. */
+static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
+			  uint32_t min_nodes, uint32_t max_nodes, 
+			  int max_share, uint32_t req_nodes)
+{
+	struct node_cr_record *exp_node_cr;
+	struct job_record *tmp_job_ptr, **tmp_job_pptr;
+	List cr_job_list;
+	ListIterator job_iterator;
+	bitstr_t *orig_map;
+	int i, rc = SLURM_ERROR;
+	int max_run_jobs = max_share - 1;	/* exclude this job */
+
+	orig_map = bit_copy(bitmap);
+
+	/* Try to run with currently available nodes */
+	i = _job_count_bitmap(node_cr_ptr, job_ptr, orig_map, bitmap, 
+			      max_run_jobs, NO_SHARE_LIMIT);
+	if (i >= min_nodes) {
+		rc = _job_test(job_ptr, bitmap, min_nodes, max_nodes, 
+			       req_nodes);
+		if (rc == SLURM_SUCCESS) {
+			bit_free(orig_map);
+			job_ptr->start_time = time(NULL);
+			return SLURM_SUCCESS;
+		}
+	}
+
+	/* Job is still pending. Simulate termination of jobs one at a time 
+	 * to determine when and where the job can start. */
+	exp_node_cr = _dup_node_cr(node_cr_ptr);
+	if (exp_node_cr == NULL) {
+		bit_free(orig_map);
+		return SLURM_ERROR;
+	}
+
+	/* Build list of running jobs */
+	cr_job_list = list_create(_cr_job_list_del);
+	if (!cr_job_list)
+		fatal("list_create: memory allocation failure");
+	job_iterator = list_iterator_create(job_list);
+	while ((tmp_job_ptr = (struct job_record *) list_next(job_iterator))) {
+		if (tmp_job_ptr->job_state != JOB_RUNNING)
+			continue;
+		if (tmp_job_ptr->end_time == 0) {
+			error("Job %u has zero end_time", tmp_job_ptr->job_id);
+			continue;
+		}
+		tmp_job_pptr = xmalloc(sizeof(struct job_record *));
+		*tmp_job_pptr = tmp_job_ptr;
+		list_append(cr_job_list, tmp_job_pptr);
+	}
+	list_iterator_destroy(job_iterator);
+	list_sort(cr_job_list, _cr_job_list_sort);
+
+	/* Remove the running jobs one at a time from exp_node_cr and try
+	 * scheduling the pending job after each one */
+	job_iterator = list_iterator_create(cr_job_list);
+	while ((tmp_job_pptr = (struct job_record **) list_next(job_iterator))) {
+		tmp_job_ptr = *tmp_job_pptr;
+		_rm_job_from_nodes(exp_node_cr, tmp_job_ptr,
+				   "_will_run_test", 1);
+		i = _job_count_bitmap(exp_node_cr, job_ptr, orig_map, bitmap, 
+				      max_run_jobs, NO_SHARE_LIMIT);
+		if (i < min_nodes)
+			continue;
+		rc = _job_test(job_ptr, bitmap, min_nodes, max_nodes, 
+			       req_nodes);
+		if (rc != SLURM_SUCCESS)
+			continue;
+		job_ptr->start_time = tmp_job_ptr->end_time;
+		break;
+	}
+	list_iterator_destroy(job_iterator);
+	list_destroy(cr_job_list);
+	_free_node_cr(exp_node_cr);
+	bit_free(orig_map);
+	return rc;
+}
+
+static void _cr_job_list_del(void *x)
+{
+	xfree(x);
+}
+static int  _cr_job_list_sort(void *x, void *y)
+{
+	struct job_record **job1_pptr = (struct job_record **) x;
+	struct job_record **job2_pptr = (struct job_record **) y;
+	return (int) difftime(job1_pptr[0]->end_time, job2_pptr[0]->end_time);
+}
+
+extern int select_p_step_begin(struct step_record *step_ptr)
+{
+	slurm_step_layout_t *step_layout = step_ptr->step_layout;
+	int i, node_inx = -1;
+	uint32_t avail_mem, step_mem;
+
+	xassert(step_ptr->job_ptr);
+	xassert(step_ptr->job_ptr->details);
+	xassert(step_ptr->step_node_bitmap);
+
+#if SELECT_DEBUG
+	info("select_p_step_begin: mem:%u", step_ptr->mem_per_task);
+#endif
+	if (step_layout == NULL)
+		return SLURM_SUCCESS;	/* batch script */
+	/* Don't track step memory use if job has reserved memory OR
+	 * job has whole node OR we don't track memory usage */
+	if (step_ptr->job_ptr->details->job_min_memory || 
+	    (step_ptr->job_ptr->details->shared == 0) ||
+	    (cr_type != CR_MEMORY))
+		return SLURM_SUCCESS;
+
+	/* test if there is sufficient memory */
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL)
+		_init_node_cr();
+	if (_find_step(step_ptr)) {
+		slurm_mutex_unlock(&cr_mutex);
+		error("select_p_step_begin: duplicate for step %u.%u",
+		      step_ptr->job_ptr->job_id, step_ptr->step_id);
+		return SLURM_SUCCESS;
+	}
+	for (i = 0; i < select_node_cnt; i++) {
+		if (bit_test(step_ptr->step_node_bitmap, i) == 0)
+			continue;
+		node_inx++;
+		step_mem = step_layout->tasks[node_inx] * step_ptr->mem_per_task;
+		if (select_fast_schedule)
+			avail_mem = node_record_table_ptr[i].
+				    config_ptr->real_memory;
+		else
+			avail_mem = node_record_table_ptr[i].real_memory;
+#if SELECT_DEBUG
+		info("alloc %u need %u avail %u", 
+		     node_cr_ptr[i].alloc_memory, step_mem, avail_mem);
+#endif
+		if ((node_cr_ptr[i].alloc_memory + step_mem) > avail_mem) {
+			slurm_mutex_unlock(&cr_mutex);
+			return SLURM_ERROR;	/* no room */
+		}
+	}
+
+	/* reserve the memory */
+	node_inx = -1;
+	for (i = 0; i < select_node_cnt; i++) {
+		if (bit_test(step_ptr->step_node_bitmap, i) == 0)
+			continue;
+		node_inx++;
+		step_mem = step_layout->tasks[node_inx] * step_ptr->mem_per_task;
+		node_cr_ptr[i].alloc_memory += step_mem;
+	}
+	_add_step(step_ptr);
+	slurm_mutex_unlock(&cr_mutex);
+	return SLURM_SUCCESS;
+}
+
+extern int select_p_step_fini(struct step_record *step_ptr)
+{
+	slurm_step_layout_t *step_layout = step_ptr->step_layout;
+	int i, node_inx = -1;
+	uint32_t step_mem;
+
+	xassert(step_ptr->job_ptr);
+	xassert(step_ptr->job_ptr->details);
+	xassert(step_ptr->step_node_bitmap);
+
+#if SELECT_DEBUG
+	info("select_p_step_fini: mem:%u", step_ptr->mem_per_task);
+#endif
+	if (step_layout == NULL)
+		return SLURM_SUCCESS;	/* batch script */
+	/* Don't track step memory use if job has reserved memory OR
+	 * job has whole node OR we don't track memory usage */
+	if (step_ptr->job_ptr->details->job_min_memory || 
+	    (step_ptr->job_ptr->details->shared == 0) ||
+	    (cr_type != CR_MEMORY))
+		return SLURM_SUCCESS;
+
+	/* release the memory */
+	slurm_mutex_lock(&cr_mutex);
+	if (node_cr_ptr == NULL)
+		_init_node_cr();
+	if (!_find_step(step_ptr)) {
+		slurm_mutex_unlock(&cr_mutex);
+		error("select_p_step_fini: could not find step %u.%u",
+		      step_ptr->job_ptr->job_id, step_ptr->step_id);
+		return SLURM_ERROR;
+	}
+	for (i = 0; i < select_node_cnt; i++) {
+		if (bit_test(step_ptr->step_node_bitmap, i) == 0)
+			continue;
+		node_inx++;
+		step_mem = step_layout->tasks[node_inx] * step_ptr->mem_per_task;
+		if (node_cr_ptr[i].alloc_memory >= step_mem)
+			node_cr_ptr[i].alloc_memory -= step_mem;
+		else {
+			node_cr_ptr[i].alloc_memory = 0;
+			error("select_p_step_fini: alloc_memory underflow on %s",
+				node_record_table_ptr[i].name);
+		}
+	}
+	_remove_step(step_ptr);
+	slurm_mutex_unlock(&cr_mutex);
+	return SLURM_SUCCESS;
+}
+
+/* return 1 if found, 0 otherwise */
+static int _find_step(struct step_record *step_ptr)
+{
+	ListIterator step_iterator;
+	struct step_cr_record *step;
+	int found = 0;
+
+	if (!step_cr_list)
+		return found;
+	step_iterator = list_iterator_create(step_cr_list);
+	if (step_iterator == NULL) {
+		fatal("list_iterator_create: memory allocation failure");
+		return found;
+	}
+	while ((step = list_next(step_iterator))) {
+		if ((step->job_id  == step_ptr->job_ptr->job_id) &&
+		    (step->step_id == step_ptr->step_id)) {
+			found = 1;
+			break;
+		}
+	}
+	list_iterator_destroy(step_iterator);
+	return found;
+}
+static int _add_step(struct step_record *step_ptr)
+{
+	struct step_cr_record *step = xmalloc(sizeof(struct step_cr_record));
+
+	step->job_id  = step_ptr->job_ptr->job_id;
+	step->step_id = step_ptr->step_id;
+	if (!step_cr_list) {
+		step_cr_list = list_create(_del_list_step);
+		if (!step_cr_list)
+			fatal("list_create: memory allocation failure");
+	}
+	if (list_append(step_cr_list, step) == NULL) {
+		fatal("list_append: memory allocation failure");
+		return SLURM_ERROR;
+	}
+	return SLURM_SUCCESS;
+}
+static int _remove_step(struct step_record *step_ptr)
+{
+	ListIterator step_iterator;
+	struct step_cr_record *step;
+	int found = 0;
+
+	if (!step_cr_list)
+		return found;
+	step_iterator = list_iterator_create(step_cr_list);
+	if (step_iterator == NULL) {
+		fatal("list_iterator_create: memory allocation failure");
+		return found;
+	}
+	while ((step = list_next(step_iterator))) {
+		if ((step->job_id  == step_ptr->job_ptr->job_id) &&
+		    (step->step_id == step_ptr->step_id)) {
+			found = 1;
+			list_delete_item(step_iterator);
+			break;
+		}
+	}
+	list_iterator_destroy(step_iterator);
+	return found;
+}
+static void _del_list_step(void *x)
+{
+	xfree(x);
+}
diff --git a/src/plugins/select/linear/select_linear.h b/src/plugins/select/linear/select_linear.h
new file mode 100644
index 0000000000000000000000000000000000000000..cd40a7fd96cb6104063820b6f6a65e686f463db0
--- /dev/null
+++ b/src/plugins/select/linear/select_linear.h
@@ -0,0 +1,81 @@
+/*****************************************************************************\
+ *  select_linear.h 
+ *****************************************************************************
+ *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
+ *  Written by Susanne M. Balle, <susanne.balle@hp.com>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *  
+ *  In addition, as a special exception, the copyright holders give permission
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and
+ *  distribute linked combinations including the two. You must obey the GNU
+ *  General Public License in all respects for all of the code used other than
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this
+ *  exception to your version of the file(s), but you are not obligated to do
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in
+ *  the program, then also delete it here.
+ *
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _SELECT_LINEAR_H
+#define _SELECT_LINEAR_H
+
+#include "src/slurmctld/slurmctld.h"
+
+/*
+ * part_cr_record keeps track of the number of running jobs on 
+ * this node in this partition. SLURM allows a node to be
+ * assigned to more than one partition. One or more partitions
+ * may be configured to share the cores with more than one job.
+ */
+
+struct part_cr_record {
+	struct part_record *part_ptr;	/* pointer to partition in slurmctld */
+	uint16_t run_job_cnt;		/* number of running jobs on this node
+					 * for this partition */
+	uint16_t tot_job_cnt;		/* number of jobs allocated to this node
+					 * for this partition */
+	struct part_cr_record *next;	/* ptr to next part_cr_record */
+};
+
+/*
+ * node_cr_record keeps track of the resources within a node which 
+ * have been reserved by already scheduled jobs. 
+ */
+struct node_cr_record {
+	struct part_cr_record *parts;	/* ptr to singly-linked part_cr_record
+					 * list that contains alloc_core info */
+	uint32_t alloc_memory;		/* real memory reserved by already
+					 * scheduled jobs */
+	uint32_t exclusive_jobid;	/* if the node is allocated exclusively
+					 * to some job, put its jobid here, 
+					 * otherwise value is zero */
+};
+
+/*
+ * step_cr_record keeps track of the steps which have been allocated memory
+ * independently of the job (ie. the job itself has no reserved memory
+ */
+struct step_cr_record {
+	uint32_t job_id;
+	uint32_t step_id;
+};
+
+#endif /* !_SELECT_LINEAR_H */
diff --git a/src/plugins/switch/Makefile.in b/src/plugins/switch/Makefile.in
index ab6e17b4feda1d7fd34bb1723b0ceee5015c47cb..a7d38ed25d9c75891dbfcb10e91c91b1f0c0f46d 100644
--- a/src/plugins/switch/Makefile.in
+++ b/src/plugins/switch/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/switch/elan/Makefile.in b/src/plugins/switch/elan/Makefile.in
index 5310a895e0d2e5c5fa6b2b665f8b5499fe53a26c..6fbf77a27e1d8101839f875140063fd81428fab7 100644
--- a/src/plugins/switch/elan/Makefile.in
+++ b/src/plugins/switch/elan/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -84,7 +86,7 @@ switch_elan_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(switch_elan_la_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_ELAN_TRUE@am_switch_elan_la_rpath = -rpath $(pkglibdir)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -125,6 +127,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -138,10 +141,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -161,7 +167,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -172,6 +181,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -187,6 +198,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -202,6 +214,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -320,8 +333,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -329,8 +342,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -385,8 +398,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -398,8 +411,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -409,13 +422,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/switch/elan/qsw.c b/src/plugins/switch/elan/qsw.c
index 3df3847ac920ce5d41d36c65294b8299233daa85..98d317af6501ee3be77ef440ccecd48fbb3e37dd 100644
--- a/src/plugins/switch/elan/qsw.c
+++ b/src/plugins/switch/elan/qsw.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  qsw.c - Library routines for initiating jobs on QsNet. 
- *  $Id: qsw.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: qsw.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -747,7 +747,7 @@ _free_hwcontext(uint32_t prog_num)
 			if (prog_num != step_ctx_p->st_prognum)
 				continue;
 			_dump_step_ctx("_free_hwcontext", step_ctx_p);
-			list_delete(iter);
+			list_delete_item(iter);
 			break;
 		}
 		if (!step_ctx_p) {
diff --git a/src/plugins/switch/elan/qsw.h b/src/plugins/switch/elan/qsw.h
index eab4eebe6d3a8946e50b5b485fe2bad8722c2f69..d82345791ba9e77c37519ce68058a48b4f81e69c 100644
--- a/src/plugins/switch/elan/qsw.h
+++ b/src/plugins/switch/elan/qsw.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jim Garlick <garlick@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/switch/elan/switch_elan.c b/src/plugins/switch/elan/switch_elan.c
index 445b8246c1019627c89cee3a8cd5d953a59d64f4..2e89fec6058ea51b0c55a5a925e5943d9b3993c3 100644
--- a/src/plugins/switch/elan/switch_elan.c
+++ b/src/plugins/switch/elan/switch_elan.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  switch_elan.c - Library routines for initiating jobs on QsNet. 
- *  $Id: switch_elan.c 10751 2007-01-11 22:19:34Z jette $
+ *  $Id: switch_elan.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2003-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -233,7 +233,7 @@ int switch_p_libstate_restore (char *dir_name, bool recover)
 	int error_code = SLURM_SUCCESS;
 	int state_fd, data_allocated = 0, data_read = 0, data_size = 0;
 	char *ver_str = NULL;
-	uint16_t ver_str_len;
+	uint32_t ver_str_len;
 
 	if (!recover)	/* clean start, no recovery */
 		return qsw_init(NULL);
@@ -271,11 +271,11 @@ int switch_p_libstate_restore (char *dir_name, bool recover)
 	if (error_code == SLURM_SUCCESS) {
 		buffer = create_buf (data, data_size);
 		data = NULL;    /* now in buffer, don't xfree() */
-		if (buffer && (size_buf(buffer) >= sizeof(uint16_t) + 
+		if (buffer && (size_buf(buffer) >= sizeof(uint32_t) + 
 				strlen(QSW_STATE_VERSION))) {
 			char *ptr = get_buf_data(buffer);
 
-			if (!memcmp(&ptr[sizeof(uint16_t)], 
+			if (!memcmp(&ptr[sizeof(uint32_t)], 
 					QSW_STATE_VERSION, 3)) {
 				unpackstr_xmalloc(&ver_str, &ver_str_len, 
 						buffer);
diff --git a/src/plugins/switch/federation/Makefile.am b/src/plugins/switch/federation/Makefile.am
index 254d85f8df5340fdf37e941da516d4cf41413037..f1517f6ffff8d691cea79ded71edbbc68bb2da9f 100644
--- a/src/plugins/switch/federation/Makefile.am
+++ b/src/plugins/switch/federation/Makefile.am
@@ -21,9 +21,8 @@ switch_federation_la_SOURCES = \
 	federation.c federation.h \
 	federation_keys.h \
 	switch_federation.c 
-switch_federation_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-
-switch_federation_la_LIBADD = $(top_builddir)/src/common/libcommon.la 
+switch_federation_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) \
+	 $(FEDERATION_LDFLAGS)
 
 else
 EXTRA_switch_federation_la_SOURCES = \
diff --git a/src/plugins/switch/federation/Makefile.in b/src/plugins/switch/federation/Makefile.in
index bfc93e746f44ed3815bded4b52e24335d4fe02c6..11c2462b2492573e922b5ff5fe71fa05012ce504 100644
--- a/src/plugins/switch/federation/Makefile.in
+++ b/src/plugins/switch/federation/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,8 +75,7 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-@HAVE_FEDERATION_TRUE@switch_federation_la_DEPENDENCIES =  \
-@HAVE_FEDERATION_TRUE@	$(top_builddir)/src/common/libcommon.la
+switch_federation_la_LIBADD =
 am__switch_federation_la_SOURCES_DIST = federation.c federation.h \
 	federation_keys.h switch_federation.c
 @HAVE_FEDERATION_TRUE@am_switch_federation_la_OBJECTS = federation.lo \
@@ -87,7 +88,7 @@ switch_federation_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(switch_federation_la_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_FEDERATION_TRUE@am_switch_federation_la_rpath = -rpath \
 @HAVE_FEDERATION_TRUE@	$(pkglibdir)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -129,6 +130,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -142,10 +144,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -165,7 +170,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -176,6 +184,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -191,6 +201,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -206,6 +217,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -275,8 +287,9 @@ pkglib_LTLIBRARIES = $(federation_lib)
 @HAVE_FEDERATION_TRUE@	federation_keys.h \
 @HAVE_FEDERATION_TRUE@	switch_federation.c 
 
-@HAVE_FEDERATION_TRUE@switch_federation_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-@HAVE_FEDERATION_TRUE@switch_federation_la_LIBADD = $(top_builddir)/src/common/libcommon.la 
+@HAVE_FEDERATION_TRUE@switch_federation_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) \
+@HAVE_FEDERATION_TRUE@	 $(FEDERATION_LDFLAGS)
+
 @HAVE_FEDERATION_FALSE@EXTRA_switch_federation_la_SOURCES = \
 @HAVE_FEDERATION_FALSE@	federation.c federation.h \
 @HAVE_FEDERATION_FALSE@	federation_keys.h \
@@ -321,8 +334,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -330,8 +343,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -386,8 +399,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -399,8 +412,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -410,13 +423,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/switch/federation/federation.c b/src/plugins/switch/federation/federation.c
index f741b44f7d50aa02d40333c7eae48ba5942a7d0a..3010298bfb87da5c4998929279a4d842d59c817e 100644
--- a/src/plugins/switch/federation/federation.c
+++ b/src/plugins/switch/federation/federation.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  **  federation.c - Library routines for initiating jobs on IBM Federation
- **  $Id: federation.c 12736 2007-11-29 21:53:34Z jette $
+ **  $Id: federation.c 13702 2008-03-22 00:13:35Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jason King <jking@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -1134,8 +1134,8 @@ static int _fake_unpack_adapters(Buf buf)
 	safe_unpack32(&adapter_count, buf);
 	for (i = 0; i < adapter_count; i++) {
 		/* no copy, just advances buf counters */
-		unpackmem_ptr(&dummyptr, &dummy16, buf);
-		if (dummy16 != FED_ADAPTERNAME_LEN)
+		safe_unpackmem_ptr(&dummyptr, &dummy32, buf);
+		if (dummy32 != FED_ADAPTERNAME_LEN)
 			goto unpack_error;
 		safe_unpack16(&dummy16, buf);
 		safe_unpack16(&dummy16, buf);
@@ -1171,7 +1171,7 @@ _unpack_nodeinfo(fed_nodeinfo_t *n, Buf buf, bool believe_window_status)
 	int i, j;
 	fed_adapter_t *tmp_a = NULL;
 	fed_window_t *tmp_w = NULL;
-	uint16_t size;
+	uint32_t size;
 	fed_nodeinfo_t *tmp_n = NULL;
 	char *name_ptr, name[FED_HOSTLEN];
 	int magic;
@@ -1186,7 +1186,7 @@ _unpack_nodeinfo(fed_nodeinfo_t *n, Buf buf, bool believe_window_status)
 	safe_unpack32(&magic, buf);
 	if(magic != FED_NODEINFO_MAGIC)
 		slurm_seterrno_ret(EBADMAGIC_FEDNODEINFO);
-	unpackmem_ptr(&name_ptr, &size, buf);
+	safe_unpackmem_ptr(&name_ptr, &size, buf);
 	if(size != FED_HOSTLEN)
 		goto unpack_error;
 	memcpy(name, name_ptr, size);
@@ -1234,7 +1234,7 @@ _unpack_nodeinfo(fed_nodeinfo_t *n, Buf buf, bool believe_window_status)
 	safe_unpack32(&tmp_n->adapter_count, buf);
 	for(i = 0; i < tmp_n->adapter_count; i++) {
 		tmp_a = tmp_n->adapter_list + i;
-		unpackmem_ptr(&name_ptr, &size, buf);
+		safe_unpackmem_ptr(&name_ptr, &size, buf);
 		if(size != FED_ADAPTERNAME_LEN)
 			goto unpack_error;
 		memcpy(tmp_a->name, name_ptr, size);
@@ -1964,7 +1964,7 @@ fed_pack_jobinfo(fed_jobinfo_t *j, Buf buf)
 static int
 _unpack_tableinfo(fed_tableinfo_t *tableinfo, Buf buf)
 {
-	uint16_t size;
+	uint32_t size;
 	char *name_ptr;
 	int i;
 
@@ -1978,7 +1978,7 @@ _unpack_tableinfo(fed_tableinfo_t *tableinfo, Buf buf)
 		safe_unpack16(&tableinfo->table[i]->lid, buf);
 		safe_unpack16(&tableinfo->table[i]->window_id, buf);
 	}
-	unpackmem_ptr(&name_ptr, &size, buf);
+	safe_unpackmem_ptr(&name_ptr, &size, buf);
 	if (size != FED_ADAPTERNAME_LEN)
 		goto unpack_error;
 	memcpy(tableinfo->adapter_name, name_ptr, size);
@@ -1993,7 +1993,7 @@ unpack_error: /* safe_unpackXX are macros which jump to unpack_error */
 int 
 fed_unpack_jobinfo(fed_jobinfo_t *j, Buf buf)
 {
-	uint16_t size;
+	uint32_t size;
 	int i, k;
 	
 	assert(j);
@@ -2003,7 +2003,7 @@ fed_unpack_jobinfo(fed_jobinfo_t *j, Buf buf)
 	safe_unpack32(&j->magic, buf);
 	assert(j->magic == FED_JOBINFO_MAGIC);
 	safe_unpack16(&j->job_key, buf);
-	unpackmem(j->job_desc, &size, buf);
+	safe_unpackmem(j->job_desc, &size, buf);
 	if(size != DESCLEN)
 		goto unpack_error;
 	safe_unpack32(&j->window_memory, buf);
@@ -2234,7 +2234,8 @@ _wait_for_all_windows(fed_tableinfo_t *tableinfo)
 			if (err != SLURM_SUCCESS) {
 				error("Window %hu adapter %s did not become"
 				      " free within %d seconds",
-				      lid, tableinfo->table[i]->window_id, i);
+				      lid, tableinfo->table[i]->window_id, 
+				      retry);
 				rc = err;
 				retry = 2;
 			}
diff --git a/src/plugins/switch/federation/federation.h b/src/plugins/switch/federation/federation.h
index 0d8ddb700329e38dfac8c454ce6831fa069aad97..7b321609c5699e3f787b85ca27d6a73e16946fbe 100644
--- a/src/plugins/switch/federation/federation.h
+++ b/src/plugins/switch/federation/federation.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  **  federation.h - Library routines for initiating jobs on IBM Federation
- **  $Id: federation.h 10574 2006-12-15 23:38:29Z jette $
+ **  $Id: federation.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jason King <jking@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/switch/federation/federation_keys.h b/src/plugins/switch/federation/federation_keys.h
index 315ab1e0eebc84827ed632d0f375206c851a1cc3..9f785dcda735e2592a0e121cb3ac648329f81119 100644
--- a/src/plugins/switch/federation/federation_keys.h
+++ b/src/plugins/switch/federation/federation_keys.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  **  federation_keys.h - Key definitions used by the get_jobinfo functions
- **  $Id: federation_keys.h 10574 2006-12-15 23:38:29Z jette $
+ **  $Id: federation_keys.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jason King <jking@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/switch/federation/switch_federation.c b/src/plugins/switch/federation/switch_federation.c
index 04484e9918a56d696223f46f5ce6955b9dd79862..1e8bd41c2500c019e5d69b8beb672063f5c71e54 100644
--- a/src/plugins/switch/federation/switch_federation.c
+++ b/src/plugins/switch/federation/switch_federation.c
@@ -1,12 +1,12 @@
 /***************************************************************************** \
  **  switch_federation.c - Library routines for initiating jobs on IBM 
  **	Federation
- **  $Id: switch_federation.c 10574 2006-12-15 23:38:29Z jette $
+ **  $Id: switch_federation.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2004-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jason King <jking@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/switch/none/Makefile.am b/src/plugins/switch/none/Makefile.am
index 2d74f777c9b0cf6aa209f14ec65b72be82314985..58a8ad437586b519e59951969aa94f126147aad6 100644
--- a/src/plugins/switch/none/Makefile.am
+++ b/src/plugins/switch/none/Makefile.am
@@ -11,7 +11,3 @@ pkglib_LTLIBRARIES = switch_none.la
 # Null switch plugin.
 switch_none_la_SOURCES = switch_none.c
 switch_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-
-if HAVE_AIX
-switch_none_la_LIBADD = $(top_builddir)/src/common/libcommon.la
-endif
diff --git a/src/plugins/switch/none/Makefile.in b/src/plugins/switch/none/Makefile.in
index 7c080e967e93b01790ef0e4c5b6212e833430a34..ba48b744f0acae5cc8c583df8b28af86a07aaa3a 100644
--- a/src/plugins/switch/none/Makefile.in
+++ b/src/plugins/switch/none/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,14 +75,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-@HAVE_AIX_TRUE@switch_none_la_DEPENDENCIES =  \
-@HAVE_AIX_TRUE@	$(top_builddir)/src/common/libcommon.la
+switch_none_la_LIBADD =
 am_switch_none_la_OBJECTS = switch_none.lo
 switch_none_la_OBJECTS = $(am_switch_none_la_OBJECTS)
 switch_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(switch_none_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -120,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -261,7 +273,6 @@ pkglib_LTLIBRARIES = switch_none.la
 # Null switch plugin.
 switch_none_la_SOURCES = switch_none.c
 switch_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-@HAVE_AIX_TRUE@switch_none_la_LIBADD = $(top_builddir)/src/common/libcommon.la
 all: all-am
 
 .SUFFIXES:
@@ -301,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -310,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -365,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -378,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -389,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/switch/none/switch_none.c b/src/plugins/switch/none/switch_none.c
index f30cb0c3e713c81cb21a212ecc2c5abfa0d96c57..7d0b614f531bd01f5e53931971a557761e7009b8 100644
--- a/src/plugins/switch/none/switch_none.c
+++ b/src/plugins/switch/none/switch_none.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/task/Makefile.in b/src/plugins/task/Makefile.in
index 1ed780c15b12e6ae4104e6b5c0749bce5f5507fb..56b248579346d2e484dceb2791b4d8995f25a1de 100644
--- a/src/plugins/task/Makefile.in
+++ b/src/plugins/task/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -101,6 +103,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -114,10 +117,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -137,7 +143,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -148,6 +157,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -163,6 +174,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -178,6 +190,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -349,8 +362,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/task/affinity/Makefile.am b/src/plugins/task/affinity/Makefile.am
index c3eb2f7fbc1f518bf5eafec74f46a4c05255ea84..8fa3663995b5e4761080cc174082c08afd62f036 100644
--- a/src/plugins/task/affinity/Makefile.am
+++ b/src/plugins/task/affinity/Makefile.am
@@ -16,7 +16,7 @@ task_affinity_la_SOURCES = 	\
 	schedutils.c \
 	task_affinity.c
 task_affinity_la_LDFLAGS = $(SO_LDFLAGS) $(NUMA_LIBS) $(PLPA_LIBS) $(PLUGIN_FLAGS)
-task_affinity_la_LIBADD  = $(top_builddir)/src/common/libcommon.la
+
 else
 pkglib_LTLIBRARIES =
 EXTRA_task_affinity_la_SOURCES = \
diff --git a/src/plugins/task/affinity/Makefile.in b/src/plugins/task/affinity/Makefile.in
index e780ed3f8935504fcd063f4934cf8f6ffbb8918b..7b4b935a623314c75c56303e2008afa6400684ed 100644
--- a/src/plugins/task/affinity/Makefile.in
+++ b/src/plugins/task/affinity/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,7 +75,7 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-@HAVE_SCHED_SETAFFINITY_TRUE@task_affinity_la_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la
+task_affinity_la_LIBADD =
 am__task_affinity_la_SOURCES_DIST = affinity.c affinity.h cpuset.c \
 	dist_tasks.c dist_tasks.h numa.c schedutils.c task_affinity.c
 @HAVE_SCHED_SETAFFINITY_TRUE@am_task_affinity_la_OBJECTS =  \
@@ -89,7 +91,7 @@ task_affinity_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(task_affinity_la_LDFLAGS) $(LDFLAGS) -o $@
 @HAVE_SCHED_SETAFFINITY_TRUE@am_task_affinity_la_rpath = -rpath \
 @HAVE_SCHED_SETAFFINITY_TRUE@	$(pkglibdir)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -131,6 +133,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -144,10 +147,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -167,7 +173,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -178,6 +187,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -193,6 +204,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -208,6 +220,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -278,7 +291,6 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/common
 @HAVE_SCHED_SETAFFINITY_TRUE@	task_affinity.c
 
 @HAVE_SCHED_SETAFFINITY_TRUE@task_affinity_la_LDFLAGS = $(SO_LDFLAGS) $(NUMA_LIBS) $(PLPA_LIBS) $(PLUGIN_FLAGS)
-@HAVE_SCHED_SETAFFINITY_TRUE@task_affinity_la_LIBADD = $(top_builddir)/src/common/libcommon.la
 @HAVE_SCHED_SETAFFINITY_FALSE@EXTRA_task_affinity_la_SOURCES = \
 @HAVE_SCHED_SETAFFINITY_FALSE@	affinity.c affinity.h \
 @HAVE_SCHED_SETAFFINITY_FALSE@	cpuset.c \
@@ -326,8 +338,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -335,8 +347,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -395,8 +407,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -408,8 +420,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -419,13 +431,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/task/affinity/affinity.c b/src/plugins/task/affinity/affinity.c
index ef6593c1fdb382f32c154db57ef9fe9376781da6..f6fb3414453de2f57370b7fc381f34ff6c26cc09 100644
--- a/src/plugins/task/affinity/affinity.c
+++ b/src/plugins/task/affinity/affinity.c
@@ -41,9 +41,7 @@
 
 void slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval)
 {
-	char bind_type[42];
-	char action[42];
-	char status[42];
+	char *bind_type, *action, *status, *units;
 	char mstr[1 + CPU_SETSIZE / 4];
 	int task_gid = job->envtp->procid;
 	int task_lid = job->envtp->localid;
@@ -52,33 +50,42 @@ void slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval)
 	if (!(job->cpu_bind_type & CPU_BIND_VERBOSE))
 		return;
 
-	action[0] = '\0';
-	status[0] = '\0';
 	if (statval)
-		strcpy(status, " FAILED");
+		status = " FAILED";
+	else
+		status = "";
 
 	if (job->cpu_bind_type & CPU_BIND_NONE) {
-		strcpy(action, "");
-		strcpy(bind_type, "=NONE");
+		action = "";
+		units  = "";
+		bind_type = "NONE";
 	} else {
-		strcpy(action, " set");
+		action = " set";
+		if (job->cpu_bind_type & CPU_BIND_TO_THREADS)
+			units = "_threads";
+		else if (job->cpu_bind_type & CPU_BIND_TO_CORES)
+			units = "_cores";
+		else if (job->cpu_bind_type & CPU_BIND_TO_SOCKETS)
+			units = "_sockets";
+		else
+			units = "";
 		if (job->cpu_bind_type & CPU_BIND_RANK) {
-			strcpy(bind_type, "=RANK");
+			bind_type = "RANK";
 		} else if (job->cpu_bind_type & CPU_BIND_MAP) {
-			strcpy(bind_type, "=MAP ");
+			bind_type = "MAP ";
 		} else if (job->cpu_bind_type & CPU_BIND_MASK) {
-			strcpy(bind_type, "=MASK");
+			bind_type = "MASK";
 		} else if (job->cpu_bind_type & (~CPU_BIND_VERBOSE)) {
-			strcpy(bind_type, "=UNK ");
+			bind_type = "UNK ";
 		} else {
-			strcpy(action, "");
-			strcpy(bind_type, "=NULL");
+			action = "";
+			bind_type = "NULL";
 		}
 	}
 
-	fprintf(stderr, "cpu_bind%s - "
+	fprintf(stderr, "cpu_bind%s=%s - "
 			"%s, task %2u %2u [%u]: mask 0x%s%s%s\n",
-			bind_type,
+			units, bind_type,
 			conf->hostname,
 			task_gid,
 			task_lid,
diff --git a/src/plugins/task/affinity/affinity.h b/src/plugins/task/affinity/affinity.h
index 8f213ae368479503423c112e46f7dc63df89f7df..4ee3d27db120dc7da45913c9b40476759d6227b1 100644
--- a/src/plugins/task/affinity/affinity.h
+++ b/src/plugins/task/affinity/affinity.h
@@ -61,8 +61,13 @@
 #include <sys/utsname.h>
 #include <unistd.h>
 
-#define _GNU_SOURCE
-#define __USE_GNU
+#ifndef   _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
+#ifndef   __USE_GNU
+#define   __USE_GNU
+#endif
+
 #include <sched.h> /* SMB */
 
 #ifdef HAVE_STDLIB_H
@@ -80,7 +85,6 @@
 #include "src/common/node_select.h"
 #include "src/common/fd.h"
 #include "src/common/safeopen.h"
-#include "src/common/slurm_jobacct.h"
 #include "src/common/switch.h"
 #include "src/common/xsignal.h"
 #include "src/common/xstring.h"
diff --git a/src/plugins/task/affinity/cpuset.c b/src/plugins/task/affinity/cpuset.c
index 83bcc211d754621b53a8a6713612a7d1ced934be..dfd0a632fb5cc75ee1ad6282c83d4f19c4c320cb 100644
--- a/src/plugins/task/affinity/cpuset.c
+++ b/src/plugins/task/affinity/cpuset.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Written by Don Albert <Don.Albert@Bull.com> and 
  *             Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/task/affinity/dist_tasks.c b/src/plugins/task/affinity/dist_tasks.c
index f1ba95232f51325c5acd3add522021b70a9da1e6..9a725dc1afcfde72ffe89d2a1dea3a7e9f0600d0 100644
--- a/src/plugins/task/affinity/dist_tasks.c
+++ b/src/plugins/task/affinity/dist_tasks.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -35,13 +35,12 @@
 #include "src/plugins/task/affinity/dist_tasks.h"
 
 static slurm_lllp_ctx_t *lllp_ctx = NULL;	/* binding context */
-static struct node_gids *lllp_tasks = NULL; /* Keep track of the task count for
-			       * logical processors
-			       * socket/core/thread.
-			       */
-static uint32_t lllp_reserved_size = 0;/* size of lllp reserved array     */
-static uint32_t *lllp_reserved = NULL;    /* count of Reserved lllps (socket,
-		                                         * core, threads) */
+static struct node_gids *lllp_tasks = NULL;	/* Keep track of the task count
+						 * for logical processors
+						 * socket/core/thread. */
+static uint32_t lllp_reserved_size = 0;		/* lllp reserved array size */
+static uint32_t *lllp_reserved = NULL;   	/* count of Reserved lllps 
+						 * (socket, core, threads) */
 
 
 static void _task_layout_display_masks(launch_tasks_request_msg_t *req,
@@ -92,10 +91,8 @@ static void _get_resources_this_node(uint16_t *cpus,
 				     uint16_t *sockets,
 				     uint16_t *cores,
 				     uint16_t *threads,
-				     uint16_t *alloc_sockets,
 				     uint16_t *alloc_cores,
-				     uint16_t *alloc_lps,
-				     uint32_t *jobid);
+				     uint32_t jobid);
 static void _cr_update_reservation(int reserve, uint32_t *reserved, 
 				   bitstr_t *mask);
 
@@ -132,8 +129,8 @@ void lllp_distribution(launch_tasks_request_msg_t *req, uint32_t node_id)
 	int rc = SLURM_SUCCESS;
 	bitstr_t **masks = NULL;
 	char buf_type[100];
-	int maxtasks = req->tasks_to_launch[node_id];
-        const uint32_t *gtid = req->global_task_ids[node_id];
+	int maxtasks = req->tasks_to_launch[(int)node_id];
+        const uint32_t *gtid = req->global_task_ids[(int)node_id];
 	
 	slurm_sprint_cpu_bind_type(buf_type, req->cpu_bind_type);
 	if(req->cpu_bind_type >= CPU_BIND_NONE) {
@@ -164,24 +161,24 @@ void lllp_distribution(launch_tasks_request_msg_t *req, uint32_t node_id)
 	switch (req->task_dist) {
 	case SLURM_DIST_BLOCK_BLOCK:
 	case SLURM_DIST_CYCLIC_BLOCK:
-		_task_layout_lllp_block(req, gtid, maxtasks, &masks);
+		rc = _task_layout_lllp_block(req, gtid, maxtasks, &masks);
 		break;
 	case SLURM_DIST_CYCLIC:
 	case SLURM_DIST_BLOCK:
 	case SLURM_DIST_CYCLIC_CYCLIC:
 	case SLURM_DIST_BLOCK_CYCLIC:
-		_task_layout_lllp_cyclic(req, gtid, maxtasks, &masks); 
+		rc = _task_layout_lllp_cyclic(req, gtid, maxtasks, &masks); 
 		break;
 	case SLURM_DIST_PLANE:
-		_task_layout_lllp_plane(req, gtid, maxtasks, &masks); 
+		rc = _task_layout_lllp_plane(req, gtid, maxtasks, &masks); 
 		break;
 	default:
-		_task_layout_lllp_cyclic(req, gtid, maxtasks, &masks); 
+		rc = _task_layout_lllp_cyclic(req, gtid, maxtasks, &masks); 
 		req->task_dist = SLURM_DIST_BLOCK_CYCLIC;
 		break;
 	}
 
-	if (masks) {
+	if (rc == SLURM_SUCCESS) {
 		_task_layout_display_masks(req, gtid, maxtasks, masks); 
 		if (req->cpus_per_task > 1) {
 			_lllp_enlarge_masks(req, maxtasks, masks);
@@ -192,12 +189,8 @@ void lllp_distribution(launch_tasks_request_msg_t *req, uint32_t node_id)
 	    	_lllp_map_abstract_masks(maxtasks, masks);
 		_task_layout_display_masks(req, gtid, maxtasks, masks); 
 	    	_lllp_generate_cpu_bind(req, maxtasks, masks);
-	    	_lllp_free_masks(req, maxtasks, masks);
 	}
-
-	if(rc != SLURM_SUCCESS)
-		error (" Error in lllp_distribution_create %s ", 
-		       req->task_dist);
+	_lllp_free_masks(req, maxtasks, masks);
 }
 
 static
@@ -585,9 +578,7 @@ static void _lllp_free_masks (launch_tasks_request_msg_t *req,
 }
 
 /* 
- * _task_layout_lllp_init
- *
- * task_layout_lllp_init performs common initialization required by:
+ * _task_layout_lllp_init performs common initialization required by:
  *	_task_layout_lllp_cyclic
  *	_task_layout_lllp_block
  *	_task_layout_lllp_plane
@@ -607,8 +598,7 @@ static int _task_layout_lllp_init(launch_tasks_request_msg_t *req,
 				  uint16_t *hw_threads,
 				  uint16_t *avail_cpus)
 {
-	int i;
-	uint16_t alloc_sockets = 0, alloc_lps = 0;
+	int min_sockets = 1, min_cores = 1;
 	uint16_t alloc_cores[conf->sockets];
 
 	if (req->cpu_bind_type & CPU_BIND_TO_THREADS) {
@@ -625,15 +615,12 @@ static int _task_layout_lllp_init(launch_tasks_request_msg_t *req,
 	}
 
 	_get_resources_this_node(usable_cpus, usable_sockets, usable_cores,
-				 usable_threads, &alloc_sockets, alloc_cores,
-				 &alloc_lps, &req->job_id);
+				 usable_threads, alloc_cores, req->job_id);
 
 	*hw_sockets = *usable_sockets;
 	*hw_cores   = *usable_cores;
 	*hw_threads = *usable_threads;
 
-	int min_sockets = 1;
-	int min_cores = 1;
 	*avail_cpus = slurm_get_avail_procs(req->max_sockets, 
 					    req->max_cores, 
 					    req->max_threads, 
@@ -645,15 +632,10 @@ static int _task_layout_lllp_init(launch_tasks_request_msg_t *req,
 					    req->ntasks_per_core,
 					    usable_cpus, usable_sockets,
 					    usable_cores, usable_threads,
-					    alloc_sockets, alloc_cores,
-					    alloc_lps, conf->cr_type,
-					    req->job_id,
-					    conf->hostname);
+					    alloc_cores, conf->cr_type,
+					    req->job_id, conf->hostname);
 	/* Allocate masks array */
 	*masks_p = xmalloc(maxtasks * sizeof(bitstr_t*));
-	for (i = 0; i < maxtasks; i++) { 
-	    	(*masks_p)[i] = NULL;
-	}
 	return SLURM_SUCCESS;
 }
 
@@ -671,14 +653,11 @@ static void _get_resources_this_node(uint16_t *cpus,
 				     uint16_t *sockets,
 				     uint16_t *cores,
 				     uint16_t *threads,
-				     uint16_t *alloc_sockets,
 				     uint16_t *alloc_cores,
-				     uint16_t *alloc_lps,
-	                             uint32_t *jobid)
+	                             uint32_t jobid)
 {
 	int bit_index = 0;
-	int i, j , k;
-	int this_socket = 0, cr_core_enabled = 0;
+	int i, j, k;
 
 	/* FIX for heterogeneous socket/core/thread count per system
 	 * in future releases */
@@ -687,50 +666,30 @@ static void _get_resources_this_node(uint16_t *cpus,
 	*cores   = conf->cores;
 	*threads = conf->threads;
 
-	switch(conf->cr_type) {
-	case CR_CORE:
-	case CR_CORE_MEMORY: 
-		for(i = 0; i < *sockets; i++)
-			alloc_cores[i] = 0;
-		cr_core_enabled = 1;
-	case CR_SOCKET:
-	case CR_SOCKET_MEMORY: 
-	case CR_CPU:
-	case CR_CPU_MEMORY:
-		for(i = 0; i < *sockets; i++) {
-			this_socket = 0;
-			for(j = 0; j < *cores; j++) {
-				for(k = 0; k < *threads; k++) {
-					info("jobid %d lllp_reserved[%d]=%d", 
-					     *jobid, bit_index, lllp_reserved[bit_index]);
-					if(lllp_reserved[bit_index] > 0) {
-						*alloc_lps += 1;
-						if ((k == 0) && (cr_core_enabled)) {
-							alloc_cores[i]++;
-						}
-						this_socket++;
+	for(i = 0; i < *sockets; i++)
+		alloc_cores[i] = 0;
+
+	for(i = 0; i < *sockets; i++) {
+		for(j = 0; j < *cores; j++) {
+			for(k = 0; k < *threads; k++) {
+				info("jobid %u lllp_reserved[%d]=%d", jobid, 
+				     bit_index, lllp_reserved[bit_index]);
+				if(lllp_reserved[bit_index] > 0) {
+					if (k == 0) {
+						alloc_cores[i]++;
 					}
-					bit_index++;
 				}
-			}
-			if (this_socket > 0) {
-				*alloc_sockets += 1;
+				bit_index++;
 			}
 		}
-		
-		xassert(bit_index == (*sockets * *cores * *threads));
-		break;
-	default:
-		break;
 	}
+		
+	xassert(bit_index == (*sockets * *cores * *threads));
 
 #if(0)
-	info("_get_resources jobid %d hostname %s alloc_sockets %d alloc_lps %d ", 
-	     *jobid, conf->hostname, *alloc_sockets, *alloc_lps);
-	if (cr_core_enabled) 
-		for (i = 0; i < *sockets; i++)
-			info("_get_resources %d hostname %s socket id %d cores %d ", 
-			     *jobid, conf->hostname, i, alloc_cores[i]);
+	for (i = 0; i < *sockets; i++)
+		info("_get_resources jobid:%u hostname:%s socket id:%d cores:%u", 
+		     jobid, conf->hostname, i, alloc_cores[i]);
 #endif
 }
 	
@@ -761,8 +720,7 @@ static int _task_layout_lllp_cyclic(launch_tasks_request_msg_t *req,
 				    const uint32_t maxtasks,
 				    bitstr_t ***masks_p)
 {
-	int retval, i, taskcount = 0, taskid = 0;
-	int over_subscribe  = 0, space_remaining = 0;
+	int retval, i, last_taskcount = -1, taskcount = 0, taskid = 0;
 	uint16_t socket_index = 0, core_index = 0, thread_index = 0;
 	uint16_t hw_sockets = 0, hw_cores = 0, hw_threads = 0;
 	uint16_t usable_cpus = 0, avail_cpus = 0;
@@ -787,54 +745,41 @@ static int _task_layout_lllp_cyclic(launch_tasks_request_msg_t *req,
 					&hw_cores, 
 					&hw_threads, 
 					&avail_cpus);
-	if (retval != SLURM_SUCCESS) {
+	if (retval != SLURM_SUCCESS)
 		return retval;
-	}
 	masks = *masks_p;
 
-	for (i=0; taskcount<maxtasks; i++) { 
-		space_remaining = 0;
-		socket_index = 0;
-		for (thread_index=0; ((thread_index<usable_threads)
-				      && (taskcount<maxtasks)); thread_index++) {
-			for (core_index=0; ((core_index<usable_cores)
-					    && (taskcount<maxtasks)); core_index++) {
-				for (socket_index=0; ((socket_index<usable_sockets)
-						      && (taskcount<maxtasks)); socket_index++) {
-					if ((socket_index<usable_sockets) || over_subscribe) {
-						if ((core_index<usable_cores) || over_subscribe) {
-							if ((thread_index<usable_threads) 
-							    || over_subscribe) {
-								bitstr_t *bitmask = NULL;
-								taskid = gtid[taskcount];
-								_single_mask(hw_sockets, 
-									     hw_cores, 
-									     hw_threads,
-									     socket_index, 
-									     core_index, 
-									     thread_index, 
-									     bind_to_exact_socket, 
-									     bind_to_exact_core,
-									     bind_to_exact_thread, 
-									     &bitmask);
-								xassert(masks[taskcount] == NULL);
-								xassert(taskcount < maxtasks);
-								masks[taskcount] = bitmask;
-								taskcount++;
-								if ((thread_index+1) < usable_threads)
-									space_remaining = 1;
-							}
-							if ((core_index+1) < usable_cores)
-								space_remaining = 1;
-						}
-					}
+	for (i=0; taskcount<maxtasks; i++) {
+		if (taskcount == last_taskcount) {
+			error("_task_layout_lllp_cyclic failure");
+			return SLURM_ERROR;
+		}
+		last_taskcount = taskcount; 
+		for (thread_index=0; thread_index<usable_threads; thread_index++) {
+			for (core_index=0; core_index<usable_cores; core_index++) {
+				for (socket_index=0; socket_index<usable_sockets; 
+						     socket_index++) {
+					bitstr_t *bitmask = NULL;
+					taskid = gtid[taskcount];
+					_single_mask(hw_sockets, 
+						     hw_cores, 
+						     hw_threads,
+						     socket_index, 
+						     core_index, 
+						     thread_index, 
+						     bind_to_exact_socket, 
+						     bind_to_exact_core,
+						     bind_to_exact_thread, 
+						     &bitmask);
+					xassert(masks[taskcount] == NULL);
+					masks[taskcount] = bitmask;
+					if (++taskcount >= maxtasks)
+						goto fini;
 				}
-				if (!space_remaining)
-					over_subscribe = 1;
 			}
 		}
 	}
-	return SLURM_SUCCESS;
+ fini:	return SLURM_SUCCESS;
 }
 
 /* 
@@ -864,7 +809,7 @@ static int _task_layout_lllp_block(launch_tasks_request_msg_t *req,
 				   const uint32_t maxtasks,
 				   bitstr_t ***masks_p)
 {
-        int retval, j, k, l, m, taskcount = 0, taskid = 0;
+	int retval, j, k, l, m, last_taskcount = -1, taskcount = 0, taskid = 0;
 	int over_subscribe  = 0, space_remaining = 0;
 	uint16_t core_index = 0, thread_index = 0;
 	uint16_t hw_sockets = 0, hw_cores = 0, hw_threads = 0;
@@ -901,6 +846,11 @@ static int _task_layout_lllp_block(launch_tasks_request_msg_t *req,
 	}
 	
 	while(taskcount < maxtasks) {
+		if (taskcount == last_taskcount) {
+			error("_task_layout_lllp_block failure");
+			return SLURM_ERROR;
+		}
+		last_taskcount = taskcount;
 		for (j=0; j<usable_sockets; j++) {
 			for(core_index=0; core_index < usable_cores; core_index++) {
 				if((core_index < usable_cores) || (over_subscribe)) {
@@ -940,7 +890,7 @@ static int _task_layout_lllp_block(launch_tasks_request_msg_t *req,
 	}
 	
 	/* Distribute the tasks and create masks for the task
-	   affinity plug-in */
+	 * affinity plug-in */
 	taskid = 0;
 	taskcount = 0;
 	for (j=0; j<usable_sockets; j++) {
@@ -1003,7 +953,7 @@ static int _task_layout_lllp_plane(launch_tasks_request_msg_t *req,
 				   const uint32_t maxtasks,
 				   bitstr_t ***masks_p)
 {
-        int retval, j, k, l, m, taskid = 0, next = 0;
+	int retval, j, k, l, m, taskid = 0, last_taskcount = -1, next = 0;
 	uint16_t core_index = 0, thread_index = 0;
 	uint16_t hw_sockets = 0, hw_cores = 0, hw_threads = 0;
 	uint16_t usable_cpus = 0, avail_cpus = 0;
@@ -1039,6 +989,11 @@ static int _task_layout_lllp_plane(launch_tasks_request_msg_t *req,
 	next = 0;
 
 	for (j=0; next<maxtasks; j++) {
+		if (next == last_taskcount) {
+			error("_task_layout_lllp_plan failure");
+			return SLURM_ERROR;
+		}
+		last_taskcount = next;
 		for (k=0; k<usable_sockets; k++) {
 			max_plane_size = (plane_size > usable_cores) ? plane_size : usable_cores;
 			for (m=0; m<max_plane_size; m++) {
@@ -1147,7 +1102,7 @@ _remove_lllp_job_state(uint32_t jobid)
         i = list_iterator_create(lllp_ctx->job_list);
         while ((j = list_next(i)) && (j->jobid != jobid)) {;}
 	if (j) {
-	    	list_delete(i);
+	    	list_delete_item(i);
 	}
         list_iterator_destroy(i);
 }
@@ -1162,9 +1117,7 @@ _append_lllp_job_state(lllp_job_state_t *j)
 void
 lllp_ctx_destroy(void)
 {
-	if (lllp_reserved) {
-		xfree(lllp_reserved);
-	}
+	xfree(lllp_reserved);
 
     	if (lllp_ctx == NULL)
 		return;
@@ -1189,16 +1142,13 @@ lllp_ctx_alloc(void)
 
 	debug3("alloc LLLP");
 
-	if (lllp_reserved) {
-		xfree(lllp_reserved);
-	}
+	xfree(lllp_reserved);
 	num_lllp = conf->sockets * conf->cores * conf->threads;
 	if (conf->cpus > num_lllp) {
 	    	num_lllp = conf->cpus;
 	}
 	lllp_reserved_size = num_lllp;
 	lllp_reserved = xmalloc(num_lllp * sizeof(uint32_t));
-	memset(lllp_reserved, 0, num_lllp * sizeof(uint32_t));
 
 	if (lllp_ctx) {
 		lllp_ctx_destroy();
@@ -1255,7 +1205,7 @@ int _cleanup_lllp(void)
 		}
 		xfree(lllp_tasks->sockets[i].cores);
 	}
-	xfree(lllp_tasks->sockets);;
+	xfree(lllp_tasks->sockets);
 	xfree(lllp_tasks);
 	return SLURM_SUCCESS;
 }
@@ -1558,8 +1508,7 @@ static void _cr_update_reservation(int reserve, uint32_t *reserved,
 	int num_bits = bit_size(mask);
 
 	for(i=0; i < num_bits; i++) {
-		if (bit_test(mask,i))
-		{
+		if (bit_test(mask,i)) {
 			if (reserve) {
 				/* reserve LLLP */
 				reserved[i]++;
@@ -1597,8 +1546,7 @@ static void _cr_update_lllp(int reserve, uint32_t job_id, uint32_t job_step_id,
 
 		_cr_reserve_unit(bitmap_test, conf->cr_type);
 
-		_cr_update_reservation(reserve, lllp_reserved, 
-				       bitmap_test);
+		_cr_update_reservation(reserve, lllp_reserved, bitmap_test);
 
 		bit_free(bitmap_test);	/* not currently stored with job_id */
 
@@ -1638,7 +1586,7 @@ void cr_reserve_lllp(uint32_t job_id,
 	debug3("reserve LLLP job [%u.%u]\n", job_id, req->job_step_id);
 
 	if (req->tasks_to_launch) {
-		numtasks = req->tasks_to_launch[node_id];
+		numtasks = req->tasks_to_launch[(int)node_id];
 	}
 
 	slurm_sprint_cpu_bind_type(buf_type, cpu_bind_type);
@@ -1658,7 +1606,7 @@ void cr_reserve_lllp(uint32_t job_id,
 	if (j) {
 		_append_lllp_job_state(j);
 		_cr_update_lllp(1, job_id, req->job_step_id,
-					cpu_bind_type, cpu_bind, numtasks);
+				cpu_bind_type, cpu_bind, numtasks);
 	}
 	slurm_mutex_unlock(&lllp_ctx->mutex);
 }
@@ -1691,7 +1639,7 @@ void cr_release_lllp(uint32_t job_id)
 					cpu_bind_type, cpu_bind, numtasks);
 
 			/* done with saved state, remove entry */
-			list_delete(i);
+			list_delete_item(i);
 		}
 	}
 	list_iterator_destroy(i);
diff --git a/src/plugins/task/affinity/dist_tasks.h b/src/plugins/task/affinity/dist_tasks.h
index a5c0fc314232d4bc333a355961a5ddfa8d72f7af..92b82a91f430fb89e5728ea649e4efefddefcc81 100644
--- a/src/plugins/task/affinity/dist_tasks.h
+++ b/src/plugins/task/affinity/dist_tasks.h
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
  *  Written by Susanne M. Balle, <susanne.balle@hp.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/task/affinity/numa.c b/src/plugins/task/affinity/numa.c
index 0e62b3f9cb77cc84973b48c4e646275e78120c2b..a3d7f57b1f1e99d39282a07e82fc5116d646bf1a 100644
--- a/src/plugins/task/affinity/numa.c
+++ b/src/plugins/task/affinity/numa.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2006 The Regents of the University of California and
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/plugins/task/affinity/task_affinity.c b/src/plugins/task/affinity/task_affinity.c
index aa78c13b66812ce6c672b404efe27b17b8fa0b49..466622d180b4616f9dd98ba350a4844b77318d1a 100644
--- a/src/plugins/task/affinity/task_affinity.c
+++ b/src/plugins/task/affinity/task_affinity.c
@@ -2,12 +2,12 @@
  *  task_affinity.c - Library for task pre-launch and post_termination
  *	functions for task affinity support
  *****************************************************************************
- *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
+ *  Copyright (C) 2005-2008 Hewlett-Packard Development Company, L.P.
  *  Modified by Hewlett-Packard for task affinity support using task_none.c
- *  Copyright (C) 2005 The Regents of the University of California and
+ *  Copyright (C) 2005-2007 The Regents of the University of California
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  task_none.c Written by Morris Jette <jette1@llnl.gov>. 
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -42,6 +42,7 @@
 #  include "config.h"
 #endif
 
+#include <ctype.h>
 #include <signal.h>
 #include <sys/types.h>
 
@@ -83,7 +84,7 @@ const uint32_t plugin_version   = 100;
  * init() is called when the plugin is loaded, before any other functions
  *	are called.  Put global initialization here.
  */
-int init ( void )
+extern int init (void)
 {
 	lllp_ctx_alloc();
 	verbose("%s loaded", plugin_name);
@@ -94,20 +95,112 @@ int init ( void )
  * fini() is called when the plugin is removed. Clear any allocated 
  *	storage here.
  */
-int fini ( void )
+extern int fini (void)
 {
 	lllp_ctx_destroy();
 	verbose("%s unloaded", plugin_name);
 	return SLURM_SUCCESS;
 }
 
+/*
+ * _isvalue_task
+ * returns 1 is the argument appears to be a value, 0 otherwise
+ * this should be identical to _isvalue in src/srun/opt.c
+ */
+static int _isvalue_task(char *arg)
+{
+    	if (isdigit(*arg)) {		/* decimal values and 0x.. hex values */
+	    	return 1;
+	}
+
+	while (isxdigit(*arg)) {	/* hex values not preceded by 0x */
+		arg++;
+	}
+
+	if ((*arg == ',') || (*arg == '\0')) { /* end of field or string */
+	    	return 1;
+	}
+
+	return 0;			/* not a value */
+}
+
+/* cpu bind enforcement, update binding type based upon SLURM_ENFORCED_CPU_BIND
+ * environment variable */
+static void _update_bind_type(launch_tasks_request_msg_t *req)
+{
+	char *buf, *p, *tok;
+	char buf_type[100];
+	cpu_bind_type_t cpu_bind_type;
+	int cpu_bind_type_is_valid = 0;
+	char* cpu_bind_type_str = getenv("SLURM_ENFORCED_CPU_BIND");
+
+	if (cpu_bind_type_str == NULL)
+		return;
+
+	buf = xstrdup(cpu_bind_type_str);
+	p = buf;
+
+	/* change all ',' delimiters not followed by a digit to ';'  */
+	/* simplifies parsing tokens while keeping map/mask together */
+	while (p[0] != '\0') {
+		if ((p[0] == ',') && (!_isvalue_task(&(p[1]))))
+			p[0] = ';';
+		p++;
+	}
+
+	p = buf;
+	cpu_bind_type = 0;
+	while ((tok = strsep(&p, ";")) && !cpu_bind_type_is_valid) {
+		if ((strcasecmp(tok, "q") == 0) ||
+		    (strcasecmp(tok, "quiet") == 0)) {
+			cpu_bind_type &= ~CPU_BIND_VERBOSE;
+		} else if ((strcasecmp(tok, "v") == 0) ||
+			   (strcasecmp(tok, "verbose") == 0)) {
+			cpu_bind_type |= CPU_BIND_VERBOSE;
+		} else if ((strcasecmp(tok, "no") == 0) ||
+			   (strcasecmp(tok, "none") == 0)) {
+			cpu_bind_type |= CPU_BIND_NONE;
+			cpu_bind_type_is_valid = 1;
+		} else if ((strcasecmp(tok, "socket") == 0) ||
+			   (strcasecmp(tok, "sockets") == 0)) {
+			cpu_bind_type |= CPU_BIND_TO_SOCKETS;
+			cpu_bind_type_is_valid = 1;
+		} else if ((strcasecmp(tok, "core") == 0) ||
+			   (strcasecmp(tok, "cores") == 0)) {
+			cpu_bind_type |= CPU_BIND_TO_CORES;
+			cpu_bind_type_is_valid = 1;
+		} else if ((strcasecmp(tok, "thread") == 0) ||
+			   (strcasecmp(tok, "threads") == 0)) {
+			cpu_bind_type |= CPU_BIND_TO_THREADS;
+			cpu_bind_type_is_valid = 1;
+		} else {
+			error("task affinity : invalid enforced cpu bind "
+			      "method '%s': none or an auto binding "
+			      "(cores,sockets,threads) is required",
+			      cpu_bind_type_str);
+			cpu_bind_type_is_valid = 0;
+			break;
+		}
+	}
+	xfree(buf);
+
+	if (cpu_bind_type_is_valid) {
+		req->cpu_bind_type = cpu_bind_type;
+		slurm_sprint_cpu_bind_type(buf_type, req->cpu_bind_type);
+		info("task affinity : enforcing '%s' cpu bind method", 
+		     cpu_bind_type_str);
+	}
+}
+
 /*
  * task_slurmd_launch_request()
  */
-int task_slurmd_launch_request ( uint32_t job_id,
-			launch_tasks_request_msg_t *req, uint32_t node_id)
+extern int task_slurmd_launch_request (uint32_t job_id, 
+				       launch_tasks_request_msg_t *req, 
+				       uint32_t node_id)
 {
 	int hw_sockets, hw_cores, hw_threads;
+	char buf_type[100];
 
 	debug("task_slurmd_launch_request: %u %u", job_id, node_id);
 	hw_sockets = conf->sockets;
@@ -115,33 +208,62 @@ int task_slurmd_launch_request ( uint32_t job_id,
 	hw_threads = conf->threads;
 
 	if (((hw_sockets >= 1) && ((hw_cores > 1) || (hw_threads > 1))) 
-	    || (!(req->cpu_bind_type & CPU_BIND_NONE)))	
+	    || (!(req->cpu_bind_type & CPU_BIND_NONE))) {
+		_update_bind_type(req);
+
+		slurm_sprint_cpu_bind_type(buf_type, req->cpu_bind_type);
+		info("task affinity : before lllp distribution cpu bind "
+		     "method is '%s' (%s)", buf_type, req->cpu_bind);
+
 		lllp_distribution(req, node_id);
+		  
+		slurm_sprint_cpu_bind_type(buf_type, req->cpu_bind_type);
+		info("task affinity : after lllp distribution cpu bind "
+		     "method is '%s' (%s)", buf_type, req->cpu_bind);
+	}
+		
 	/* Remove the slurm msg timeout needs to be investigated some more */
 	/* req->cpu_bind_type = CPU_BIND_NONE; */ 
-
+	
 	return SLURM_SUCCESS;
 }
 
 /*
  * task_slurmd_reserve_resources()
  */
-int task_slurmd_reserve_resources ( uint32_t job_id,
-			launch_tasks_request_msg_t *req, uint32_t node_id)
+extern int task_slurmd_reserve_resources (uint32_t job_id, 
+					  launch_tasks_request_msg_t *req,
+					  uint32_t node_id)
 {
-	debug("task_slurmd_reserve_resources: %u",
-		job_id);
+	debug("task_slurmd_reserve_resources: %u", job_id);
 	cr_reserve_lllp(job_id, req, node_id);
 	return SLURM_SUCCESS;
 }
 
+/*
+ * task_slurmd_suspend_job()
+ */
+extern int task_slurmd_suspend_job (uint32_t job_id)
+{
+	debug("task_slurmd_suspend_job: %u", job_id);
+	return SLURM_SUCCESS;
+}
+
+/*
+ * task_slurmd_resume_job()
+ */
+extern int task_slurmd_resume_job (uint32_t job_id)
+{
+	debug("task_slurmd_resume_job: %u", job_id);
+	return SLURM_SUCCESS;
+}
+
 /*
  * task_slurmd_release_resources()
  */
-int task_slurmd_release_resources ( uint32_t job_id )
+extern int task_slurmd_release_resources (uint32_t job_id)
 {
-	debug("task_slurmd_release_resources: %u",
-		job_id);
+	debug("task_slurmd_release_resources: %u", job_id);
 	cr_release_lllp(job_id);
 	return SLURM_SUCCESS;
 }
@@ -151,7 +273,7 @@ int task_slurmd_release_resources ( uint32_t job_id )
  * user to launch his jobs. Use this to create the CPUSET directory
  * and set the owner appropriately.
  */
-int task_pre_setuid ( slurmd_job_t *job )
+extern int task_pre_setuid (slurmd_job_t *job)
 {
 	char path[PATH_MAX];
 
@@ -172,7 +294,7 @@ int task_pre_setuid ( slurmd_job_t *job )
  *	It is followed by TaskProlog program (from slurm.conf) and
  *	--task-prolog (from srun command line).
  */
-int task_pre_launch ( slurmd_job_t *job )
+extern int task_pre_launch (slurmd_job_t *job)
 {
 	char base[PATH_MAX], path[PATH_MAX];
 
@@ -256,7 +378,7 @@ int task_pre_launch ( slurmd_job_t *job )
  *	It is preceeded by --task-epilog (from srun command line)
  *	followed by TaskEpilog program (from slurm.conf).
  */
-int task_post_term ( slurmd_job_t *job )
+extern int task_post_term (slurmd_job_t *job)
 {
 	debug("affinity task_post_term: %u.%u, task %d",
 		job->jobid, job->stepid, job->envtp->procid);
diff --git a/src/plugins/task/none/Makefile.am b/src/plugins/task/none/Makefile.am
index d04c1207ca53380b2e5de104a1fad588ee1e34fc..186541c6fbfd877095679aece53a952421970a5a 100644
--- a/src/plugins/task/none/Makefile.am
+++ b/src/plugins/task/none/Makefile.am
@@ -11,7 +11,3 @@ pkglib_LTLIBRARIES = task_none.la
 # Null task plugin.
 task_none_la_SOURCES = task_none.c
 task_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-
-if HAVE_AIX
-task_none_la_LIBADD = $(top_builddir)/src/common/libcommon.la
-endif
diff --git a/src/plugins/task/none/Makefile.in b/src/plugins/task/none/Makefile.in
index 74738401de4813133c5fd1052ad4d9593ef110fc..11fc8d070979c11d1ee856a6f3791811c0bd5ff0 100644
--- a/src/plugins/task/none/Makefile.in
+++ b/src/plugins/task/none/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,14 +75,13 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-@HAVE_AIX_TRUE@task_none_la_DEPENDENCIES =  \
-@HAVE_AIX_TRUE@	$(top_builddir)/src/common/libcommon.la
+task_none_la_LIBADD =
 am_task_none_la_OBJECTS = task_none.lo
 task_none_la_OBJECTS = $(am_task_none_la_OBJECTS)
 task_none_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(task_none_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -120,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -133,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -156,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -167,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -182,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -197,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -261,7 +273,6 @@ pkglib_LTLIBRARIES = task_none.la
 # Null task plugin.
 task_none_la_SOURCES = task_none.c
 task_none_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS)
-@HAVE_AIX_TRUE@task_none_la_LIBADD = $(top_builddir)/src/common/libcommon.la
 all: all-am
 
 .SUFFIXES:
@@ -301,8 +312,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
 	  else :; fi; \
 	done
 
@@ -310,8 +321,8 @@ uninstall-pkglibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
 	@list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
 	done
 
 clean-pkglibLTLIBRARIES:
@@ -365,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -378,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -389,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/plugins/task/none/task_none.c b/src/plugins/task/none/task_none.c
index d45690f199ff730f68019febcb56b46d9ef42b30..5e852eab6596b349b6eebdf1efb47719b34bb228 100644
--- a/src/plugins/task/none/task_none.c
+++ b/src/plugins/task/none/task_none.c
@@ -2,10 +2,11 @@
  *  task_none.c - Library for task pre-launch and post_termination functions 
  *	with no actions
  *****************************************************************************
- *  Copyright (C) 2005 The Regents of the University of California.
+ *  Copyright (C) 2005-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -82,7 +83,7 @@ const uint32_t plugin_version   = 100;
  * init() is called when the plugin is loaded, before any other functions
  *	are called.  Put global initialization here.
  */
-int init ( void )
+extern int init (void)
 {
 	verbose("%s loaded", plugin_name);
 	return SLURM_SUCCESS;
@@ -92,7 +93,7 @@ int init ( void )
  * fini() is called when the plugin is removed. Clear any allocated 
  *	storage here.
  */
-int fini ( void )
+extern int fini (void)
 {
 	return SLURM_SUCCESS;
 }
@@ -100,30 +101,49 @@ int fini ( void )
 /*
  * task_slurmd_launch_request()
  */
-int task_slurmd_launch_request ( uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id)
+extern int task_slurmd_launch_request (uint32_t job_id, 
+				       launch_tasks_request_msg_t *req, 
+				       uint32_t node_id)
 {
-	debug("task_slurmd_launch_request: %u %u", 
-		job_id, node_id);
+	debug("task_slurmd_launch_request: %u %u", job_id, node_id);
 	return SLURM_SUCCESS;
 }
 
 /*
  * task_slurmd_reserve_resources()
  */
-int task_slurmd_reserve_resources ( uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id )
+extern int task_slurmd_reserve_resources (uint32_t job_id, 
+					  launch_tasks_request_msg_t *req,
+					  uint32_t node_id)
 {
-	debug("task_slurmd_reserve_resources: %u %u",
-		job_id, node_id);
+	debug("task_slurmd_reserve_resources: %u %u", job_id, node_id);
+	return SLURM_SUCCESS;
+}
+
+/*
+ * task_slurmd_suspend_job()
+ */
+extern int task_slurmd_suspend_job (uint32_t job_id)
+{
+	debug("task_slurmd_suspend_job: %u", job_id);
+	return SLURM_SUCCESS;
+}
+
+/*
+ * task_slurmd_resume_job()
+ */
+extern int task_slurmd_resume_job (uint32_t job_id)
+{
+	debug("task_slurmd_resume_job: %u", job_id);
 	return SLURM_SUCCESS;
 }
 
 /*
  * task_slurmd_release_resources()
  */
-int task_slurmd_release_resources ( uint32_t job_id )
+extern int task_slurmd_release_resources (uint32_t job_id)
 {
-	debug("task_slurmd_release_resources: %u",
-		job_id);
+	debug("task_slurmd_release_resources: %u", job_id);
 	return SLURM_SUCCESS;
 }
 
@@ -132,7 +152,7 @@ int task_slurmd_release_resources ( uint32_t job_id )
  * user to launch his jobs. Use this to create the CPUSET directory
  * and set the owner appropriately.
  */
-int task_pre_setuid ( slurmd_job_t *job )
+extern int task_pre_setuid (slurmd_job_t *job)
 {
 	return SLURM_SUCCESS;
 }
@@ -142,7 +162,7 @@ int task_pre_setuid ( slurmd_job_t *job )
  *	It is followed by TaskProlog program (from slurm.conf) and
  *	--task-prolog (from srun command line).
  */
-int task_pre_launch ( slurmd_job_t *job )
+extern int task_pre_launch (slurmd_job_t *job)
 {
 	debug("task_pre_launch: %u.%u, task %d", 
 		job->jobid, job->stepid, job->envtp->procid);
@@ -154,7 +174,7 @@ int task_pre_launch ( slurmd_job_t *job )
  *	It is preceeded by --task-epilog (from srun command line)
  *	followed by TaskEpilog program (from slurm.conf).
  */
-int task_post_term ( slurmd_job_t *job )
+extern int task_post_term (slurmd_job_t *job)
 {
 	debug("task_post_term: %u.%u, task %d",
 		job->jobid, job->stepid, job->envtp->procid);
diff --git a/src/sacct/Makefile.am b/src/sacct/Makefile.am
index 0b7a3a771e7ba4d04543d7fc3b8dd44aedd6981e..4b25bcca7f72021aded7dfbdacc15504a90165a1 100644
--- a/src/sacct/Makefile.am
+++ b/src/sacct/Makefile.am
@@ -6,7 +6,8 @@ INCLUDES = -I$(top_srcdir)
 
 bin_PROGRAMS = sacct
 
-sacct_LDADD = $(top_builddir)/src/api/libslurmhelper.la
+sacct_LDADD = 	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la
 
 noinst_HEADERS = sacct.c 
 sacct_SOURCES = sacct.c process.c print.c options.c sacct_stat.c
diff --git a/src/sacct/Makefile.in b/src/sacct/Makefile.in
index 339e1e9be0f686d02e65fd92a1bc99b1f5468e5c..c3a7b5a9bf0ee3e8cbd978b3cfad78e880a935f5 100644
--- a/src/sacct/Makefile.in
+++ b/src/sacct/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -47,6 +47,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -73,11 +75,12 @@ PROGRAMS = $(bin_PROGRAMS)
 am_sacct_OBJECTS = sacct.$(OBJEXT) process.$(OBJEXT) print.$(OBJEXT) \
 	options.$(OBJEXT) sacct_stat.$(OBJEXT)
 sacct_OBJECTS = $(am_sacct_OBJECTS)
-sacct_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
+sacct_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
+	$(top_builddir)/src/api/libslurmhelper.la
 sacct_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sacct_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -118,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -131,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -154,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -165,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -180,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -195,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -253,7 +267,9 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir)
-sacct_LDADD = $(top_builddir)/src/api/libslurmhelper.la
+sacct_LDADD = $(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la
+
 noinst_HEADERS = sacct.c 
 sacct_SOURCES = sacct.c process.c print.c options.c sacct_stat.c
 sacct_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
@@ -299,8 +315,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -366,8 +382,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -379,8 +395,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -390,13 +406,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/sacct/options.c b/src/sacct/options.c
index 6ebb7c1b1a4318ae00e4543f6c5a115083e5a4a9..330b6254884f992ab2e7481879900a90934ba5c6 100644
--- a/src/sacct/options.c
+++ b/src/sacct/options.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -41,28 +41,17 @@
 #include "sacct.h"
 #include <time.h>
 
-typedef struct expired_rec {  /* table of expired jobs */
-	uint32_t job;
-	time_t job_submit;
-	char *line;
-} expired_rec_t;
-
 void _destroy_parts(void *object);
 void _destroy_steps(void *object);
-void _destroy_exp(void *object);
-char *_convert_type(int rec_type);
-int _cmp_jrec(const void *a1, const void *a2);
-void _dump_header(acct_header_t header);
-FILE *_open_log_file(void);
 void _help_fields_msg(void);
 void _help_msg(void);
 void _usage(void);
 void _init_params();
-char *_prefix_filename(char *path, char *prefix);
 
-int selected_status[STATUS_COUNT];
+int selected_state[STATE_COUNT];
 List selected_parts = NULL;
 List selected_steps = NULL;
+void *acct_db_conn = NULL;
 
 void _destroy_parts(void *object)
 {
@@ -72,35 +61,13 @@ void _destroy_parts(void *object)
 
 void _destroy_steps(void *object)
 {
-	selected_step_t *step = (selected_step_t *)object;
+	jobacct_selected_step_t *step = (jobacct_selected_step_t *)object;
 	if(step) {
 		xfree(step->job);
 		xfree(step->step);
 		xfree(step);
 	}
 }
-void _destroy_exp(void *object)
-{
-	expired_rec_t *exp_rec = (expired_rec_t *)object;
-	if(exp_rec) {
-		xfree(exp_rec->line);
-		xfree(exp_rec);
-	}
-}
-
-char *_convert_type(int rec_type)
-{
-	switch(rec_type) {
-	case JOB_START:
-		return "JOB_START";
-	case JOB_STEP:
-		return "JOB_STEP";
-	case JOB_TERMINATED:
-		return "JOB_TERMINATED";
-	default:
-		return "UNKNOWN";
-	}
-}
 
 void _show_rec(char *f[])
 {
@@ -112,63 +79,6 @@ void _show_rec(char *f[])
 	return;
 }
 
-int _cmp_jrec(const void *a1, const void *a2) {
-	expired_rec_t *j1 = (expired_rec_t *) a1;
-	expired_rec_t *j2 = (expired_rec_t *) a2;
-
-	if (j1->job <  j2->job)
-		return -1;
-	else if (j1->job == j2->job) {
-		if(j1->job_submit == j2->job_submit)
-			return 0;
-		else 
-			return 1;
-	}
-	return 1;
-}
-
-/* _dump_header() -- dump the common fields of a record
- *
- * In:	Index into the jobs table
- * Out: Nothing.
- */
-void _dump_header(acct_header_t header)
-{
-	struct tm ts;
-	gmtime_r(&header.timestamp, &ts);
-	printf("%u %s %04d%02d%02d%02d%02d%02d %d %s %s ",
-	       header.jobnum,
-	       header.partition,
-	       1900+(ts.tm_year),
-	          1+(ts.tm_mon),
-		  ts.tm_mday,
-	          ts.tm_hour,
-		  ts.tm_min,
-		  ts.tm_sec,
-	       (int)header.job_submit,
-	       header.blockid,	/* block id */
-	       "-");	/* reserved 1 */
-}
-/* _open_log_file() -- find the current or specified log file, and open it
- *
- * IN:		Nothing
- * RETURNS:	Nothing
- *
- * Side effects:
- * 	- Sets opt_filein to the current system accounting log unless
- * 	  the user specified another file.
- */
-
-FILE *_open_log_file(void)
-{
-	FILE *fd = fopen(params.opt_filein, "r");
-	if (fd == NULL) {
-		perror(params.opt_filein);
-		exit(1);
-	}
-	return fd;
-}
-
 void _help_fields_msg(void)
 {
 	int i;
@@ -205,17 +115,17 @@ void _help_msg(void)
 	       "\n"
 	       "Options:\n"
 	       "\n"
-	       "-A, --Account\n"
-	       "    Equivalent to \"--fields=jobid,jobname,start,end,cpu,\n"
-	       "    vsize_short,status,exitcode\". This option has no effect\n"
-	       "    if --dump is specified.\n"
 	       "-a, --all\n"
 	       "    Display job accounting data for all users. By default, only\n"
 	       "    data for the current user is displayed for users other than\n"
 	       "    root.\n"
 	       "-b, --brief\n"
-	       "    Equivalent to \"--fields=jobstep,status,error\". This option\n"
+	       "    Equivalent to \"--fields=jobstep,state,error\". This option\n"
 	       "    has no effect if --dump is specified.\n"
+	       "-c, --completion\n"
+	       "    Use job completion instead of accounting data.\n"
+	       "-C, --cluster\n"
+	       "    Only send data about this cluster.\n"
 	       "-d, --dump\n"
 	       "    Dump the raw data records\n"
 	       "--duplicates\n"
@@ -223,7 +133,7 @@ void _help_msg(void)
 	       "    isn't reset at the same time (with -e, for example), some\n"
 	       "    job numbers will probably appear more than once in the\n"
 	       "    accounting log file to refer to different jobs; such jobs\n"
-	       "    can be distinguished by the \"job_submit\" time stamp in the\n"
+	       "    can be distinguished by the \"submit\" time stamp in the\n"
 	       "    data records.\n"
 	       "      When data for specific jobs are requested with\n"
 	       "    the --jobs option, we assume that the user\n"
@@ -248,14 +158,14 @@ void _help_msg(void)
 	       "-F <field-list>, --fields=<field-list>\n"
 	       "    Display the specified data (use \"--help-fields\" for a\n"
 	       "    list of available fields). If no field option is specified,\n"
-	       "    we use \"--fields=jobstep,jobname,partition,ncpus,status,error\".\n"
+	       "    we use \"--fields=jobstep,jobname,partition,alloc_cpus,state,error\".\n"
 	       "-f<file>, --file=<file>\n"
 	       "    Read data from the specified file, rather than SLURM's current\n"
 	       "    accounting log file.\n"
 	       "-l, --long\n"
 	       "    Equivalent to specifying\n"
 	       "    \"--fields=jobstep,usercpu,systemcpu,minflt,majflt,nprocs,\n"
-	       "    ncpus,elapsed,status,exitcode\"\n"
+	       "    alloc_cpus,elapsed,state,exitcode\"\n"
 	       "-O, --formatted_dump\n"
 	       "    Dump accounting records in an easy-to-read format, primarily\n"
 	       "    for debugging.\n"
@@ -281,20 +191,18 @@ void _help_msg(void)
 	       "-P --purge\n"
 	       "    Used in conjunction with --expire to remove invalid data\n"
 	       "    from the job accounting log.\n"
-	       "-r --raw\n"
-	       "    don't format data leave in raw format\n"
 	       "-s <state-list>, --state=<state-list>\n"
-	       "    Select jobs based on their current status: running (r),\n"
+	       "    Select jobs based on their current state: running (r),\n"
 	       "    completed (cd), failed (f), timeout (to), and node_fail (nf).\n"
 	       "-S, --stat\n"
-	       "    Get real time status of a jobstep supplied by the -j\n"
+	       "    Get real time state of a jobstep supplied by the -j\n"
 	       "    option\n" 
 	       "-t, --total\n"
 	       "    Only show cumulative statistics for each job, not the\n"
 	       "    intermediate steps\n"
 	       "-u <uid>, --uid <uid>\n"
 	       "    Select only jobs submitted by the user with uid <uid>.  Only\n"
-	       "    root users are allowed to specify a uid other than their own.\n"
+	       "    root users are allowed to specify a uid other than their own -1 for all users.\n"
 	       "--usage\n"
 	       "    Pointer to this message.\n"
 	       "-v, --verbose\n"
@@ -313,6 +221,8 @@ void _usage(void)
 
 void _init_params()
 {
+	params.opt_cluster = NULL;	/* --cluster */
+	params.opt_completion = 0;	/* --completion */
 	params.opt_dump = 0;		/* --dump */
 	params.opt_dup = -1;		/* --duplicates; +1 = explicitly set */
 	params.opt_fdump = 0;		/* --formattted_dump */
@@ -323,9 +233,9 @@ void _init_params()
 	params.opt_long = 0;		/* --long */
 	params.opt_lowmem = 0;		/* --low_memory */
 	params.opt_purge = 0;		/* --purge */
-	params.opt_raw = 0;		/* --raw */
 	params.opt_total = 0;		/* --total */
 	params.opt_uid = -1;		/* --uid (-1=wildcard, 0=root) */
+	params.opt_uid_set = 0;
 	params.opt_verbose = 0;		/* --verbose */
 	params.opt_expire_timespec = NULL; /* --expire= */
 	params.opt_field_list = NULL;	/* --fields= */
@@ -335,237 +245,86 @@ void _init_params()
 	params.opt_state_list = NULL;	/* --states */
 }
 
-/* prefix_filename() -- insert a filename prefix into a path
- *
- * IN:	path = fully-qualified path+file name
- *      prefix = the prefix to insert into the file name
- * RETURNS: pointer to the updated path+file name
- */
-
-char *_prefix_filename(char *path, char *prefix) {
-	char	*out;
-	int     i,
-		plen;
-
-	plen = strlen(path);
-	out = xmalloc(plen+strlen(prefix)+1);
-	for (i=plen-1; i>=0; i--)
-		if (path[i]=='/') {
-			break;
-		}
-	i++;
-	*out = 0;
-	strncpy(out, path, i);
-	out[i] = 0;
-	strcat(out, prefix);
-	strcat(out, path+i);
-	return(out);
-}
-
-int decode_status_char(char *status)
+int decode_state_char(char *state)
 {
-	if (!strcasecmp(status, "p"))
+	if (!strcasecmp(state, "p"))
 		return JOB_PENDING; 	/* we should never see this */
-	else if (!strcasecmp(status, "r"))
+	else if (!strcasecmp(state, "r"))
 		return JOB_RUNNING;
-	else if (!strcasecmp(status, "su"))
+	else if (!strcasecmp(state, "su"))
 		return JOB_SUSPENDED;
-	else if (!strcasecmp(status, "cd"))
+	else if (!strcasecmp(state, "cd"))
 		return JOB_COMPLETE;
-	else if (!strcasecmp(status, "ca"))
+	else if (!strcasecmp(state, "ca"))
 		return JOB_CANCELLED;
-	else if (!strcasecmp(status, "f"))
+	else if (!strcasecmp(state, "f"))
 		return JOB_FAILED;
-	else if (!strcasecmp(status, "to"))
+	else if (!strcasecmp(state, "to"))
 		return JOB_TIMEOUT;
-	else if (!strcasecmp(status, "nf"))
+	else if (!strcasecmp(state, "nf"))
 		return JOB_NODE_FAIL;
 	else
 		return -1; // unknown
 } 
 
-char *decode_status_int(int status)
+int get_data(void)
 {
-	switch(status & ~JOB_COMPLETING) {
-	case JOB_PENDING:
-		return "PENDING"; 	/* we should never see this */
-	case JOB_RUNNING:
-		return "RUNNING";
-	case JOB_SUSPENDED:
-		return "SUSPENDED";
-	case JOB_COMPLETE:
-		return "COMPLETED";
-	case JOB_CANCELLED:
-		return "CANCELLED";
-	case JOB_FAILED:
-		return "FAILED";
-	case JOB_TIMEOUT:
-		return "TIMEOUT";
-	case JOB_NODE_FAIL:
-		return "NODE_FAILED";
-	default:
-		return "UNKNOWN";
-	}
-}
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
 
-char *decode_status_int_abbrev(int status)
-{
-	switch(status & ~JOB_COMPLETING) {
-	case JOB_PENDING:
-		return "PD"; 	/* we should never see this */
-	case JOB_RUNNING:
-		return "R";
-	case JOB_SUSPENDED:
-		return "S";
-	case JOB_COMPLETE:
-		return "CD";
-	case JOB_CANCELLED:
-		return "CA";
-	case JOB_FAILED:
-		return "F";
-	case JOB_TIMEOUT:
-		return "TO";
-	case JOB_NODE_FAIL:
-		return "NF";
-	case JOB_END:
-		return "JOB_END";
-	default:
-		return "UNKNOWN";
+	ListIterator itr = NULL;
+	ListIterator itr_step = NULL;
+
+	if(params.opt_completion) {
+		jobs = g_slurm_jobcomp_get_jobs(selected_steps,
+						selected_parts, &params);
+		return SLURM_SUCCESS;
+	} else {
+		jobs = jobacct_storage_g_get_jobs(acct_db_conn,
+						  selected_steps,
+						  selected_parts, &params);
 	}
-}
 
-int get_data(void)
-{
-	char line[BUFFER_SIZE];
-	char *f[MAX_RECORD_FIELDS+1];    /* End list with null entry and,
-					    possibly, more data than we
-					    expected */
-	char *fptr;
-	int i;
-	FILE *fd = NULL;
-	int lc = 0;
-	int rec_type = -1;
-	selected_step_t *selected_step = NULL;
-	char *selected_part = NULL;
-	ListIterator itr = NULL;
-	int show_full = 0;
+	if (params.opt_fdump) 
+		return SLURM_SUCCESS;
 
-	fd = _open_log_file();
-	
-	while (fgets(line, BUFFER_SIZE, fd)) {
-		lc++;
-		fptr = line;	/* break the record into NULL-
-				   terminated strings */
-				
-		for (i = 0; i < MAX_RECORD_FIELDS; i++) {
-			f[i] = fptr;
-			fptr = strstr(fptr, " ");
-			if (fptr == NULL) {
-				fptr = strstr(f[i], "\n");
-				if (fptr)
-					*fptr = 0;
-				break; 
-			} else
-				*fptr++ = 0;
-		}
-		f[++i] = 0;
-		
-		if(i < HEADER_LENGTH) {
-			continue;
-		}
-		
-		rec_type = atoi(f[F_RECTYPE]);
-		
-		if (list_count(selected_steps)) {
-			itr = list_iterator_create(selected_steps);
-			while((selected_step = list_next(itr))) {
-				if (strcmp(selected_step->job, f[F_JOB]))
-					continue;
-				/* job matches; does the step? */
-				if(selected_step->step == NULL) {
-					show_full = 1;
-					list_iterator_destroy(itr);
-					goto foundjob;
-				} else if (rec_type != JOB_STEP 
-					   || !strcmp(f[F_JOBSTEP], 
-						      selected_step->step)) {
-					list_iterator_destroy(itr);
-					goto foundjob;
-				} 
-			}
-			list_iterator_destroy(itr);
-			continue;	/* no match */
-		} else {
-			show_full = 1;
-		}
-	foundjob:
-		
-		if (list_count(selected_parts)) {
-			itr = list_iterator_create(selected_parts);
-			while((selected_part = list_next(itr))) 
-				if (!strcasecmp(f[F_PARTITION], 
-						selected_part)) {
-					list_iterator_destroy(itr);
-					goto foundp;
-				}
-			list_iterator_destroy(itr);
-			continue;	/* no match */
+	if(!jobs)
+		return SLURM_ERROR;
+
+	itr = list_iterator_create(jobs);
+	while((job = list_next(itr))) {
+		if(job->user) {
+			struct	passwd *pw = NULL;		 
+			if ((pw=getpwnam(job->user)))
+				job->uid = pw->pw_uid;
 		}
-	foundp:
 		
-		if (params.opt_fdump) {
-			do_fdump(f, lc);
+		if(!list_count(job->steps)) 
 			continue;
-		}
 		
-		/* Build suitable tables with all the data */
-		switch(rec_type) {
-		case JOB_START:
-			if(i < F_JOB_ACCOUNT) {
-				printf("Bad data on a Job Start\n");
-				_show_rec(f);
-			} else 
-				process_start(f, lc, show_full, i);
-			break;
-		case JOB_STEP:
-			if(i < F_MAX_VSIZE) {
-				printf("Bad data on a Step entry\n");
-				_show_rec(f);
-			} else
-				process_step(f, lc, show_full, i);
-			break;
-		case JOB_SUSPEND:
-			if(i < JOB_TERM_LENGTH) {
-				printf("Bad data on a Suspend entry\n");
-				_show_rec(f);
-			} else
-				process_suspend(f, lc, show_full, i);
-			break;
-		case JOB_TERMINATED:
-			if(i < JOB_TERM_LENGTH) {
-				printf("Bad data on a Job Term\n");
-				_show_rec(f);
-			} else
-				process_terminated(f, lc, show_full, i);
-			break;
-		default:
-			if (params.opt_verbose > 1)
-				fprintf(stderr,
-					"Invalid record at line %d of "
-					"input file\n",
-					lc);
-			if (params.opt_verbose > 2)
-				_show_rec(f);
-			input_error++;
-			break;
+		itr_step = list_iterator_create(job->steps);
+		while((step = list_next(itr_step)) != NULL) {
+			/* now aggregate the aggregatable */
+			job->alloc_cpus = MAX(job->alloc_cpus, step->ncpus);
+
+			if(step->state < JOB_COMPLETE)
+				continue;
+			job->tot_cpu_sec += step->tot_cpu_sec;
+			job->tot_cpu_usec += step->tot_cpu_usec;
+			job->user_cpu_sec +=
+				step->user_cpu_sec;
+			job->user_cpu_usec +=
+				step->user_cpu_usec;
+			job->sys_cpu_sec +=
+				step->sys_cpu_sec;
+			job->sys_cpu_usec +=
+				step->sys_cpu_usec;
+			/* get the max for all the sacct_t struct */
+			aggregate_sacct(&job->sacct, &step->sacct);
 		}
+		list_iterator_destroy(itr_step);
 	}
-	
-	if (ferror(fd)) {
-		perror(params.opt_filein);
-		exit(1);
-	} 
-	fclose(fd);
+	list_iterator_destroy(itr);
 
 	return SLURM_SUCCESS;
 } 
@@ -575,15 +334,17 @@ void parse_command_line(int argc, char **argv)
 	extern int optind;
 	int c, i, optionIndex = 0;
 	char *end = NULL, *start = NULL, *acct_type = NULL;
-	selected_step_t *selected_step = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
 	ListIterator itr = NULL;
 	struct stat stat_buf;
 	char *dot = NULL;
+	bool brief_output = FALSE, long_output = FALSE;
 
 	static struct option long_options[] = {
 		{"all", 0,0, 'a'},
-		{"Account", 0,0, 'A'},
 		{"brief", 0, 0, 'b'},
+		{"cluster", 1, 0, 'C'},
+		{"completion", 0, &params.opt_completion, 'c'},
 		{"duplicates", 0, &params.opt_dup, 1},
 		{"dump", 0, 0, 'd'},
 		{"expire", 1, 0, 'e'},
@@ -602,7 +363,6 @@ void parse_command_line(int argc, char **argv)
 		{"noheader", 0, &params.opt_header, 0},
 		{"partition", 1, 0, 'p'},
 		{"purge", 0, 0, 'P'},
-		{"raw", 0, 0, 'r'},
 		{"state", 1, 0, 's'},
 		{"total", 0, 0,  't'},
 		{"uid", 1, 0, 'u'},
@@ -614,13 +374,14 @@ void parse_command_line(int argc, char **argv)
 
 	_init_params();
 
-	if ((i=getuid()))	/* default to current user unless root*/
+	if ((i=getuid()))
+		/* default to current user unless root*/
 		params.opt_uid = i;
 
 	opterr = 1;		/* Let getopt report problems to the user */
 
 	while (1) {		/* now cycle through the command line */
-		c = getopt_long(argc, argv, "aAbde:F:f:g:hj:J:lOPp:rs:StUu:Vv",
+		c = getopt_long(argc, argv, "abcC:de:F:f:g:hj:J:lOPp:s:StUu:Vv",
 				long_options, &optionIndex);
 		if (c == -1)
 			break;
@@ -628,26 +389,15 @@ void parse_command_line(int argc, char **argv)
 		case 'a':
 			params.opt_uid = -1;
 			break;
-		case 'A':
-			params.opt_field_list =
-				xrealloc(params.opt_field_list,
-					 (params.opt_field_list==NULL? 0 :
-					  sizeof(params.opt_field_list)) +
-					 sizeof(ACCOUNT_FIELDS)+1);
-			strcat(params.opt_field_list, ACCOUNT_FIELDS);
-			strcat(params.opt_field_list, ",");
-			break;
-			
 		case 'b':
-			params.opt_field_list =
-				xrealloc(params.opt_field_list,
-					 (params.opt_field_list==NULL? 0 :
-					  sizeof(params.opt_field_list)) +
-					 sizeof(BRIEF_FIELDS)+1);
-			strcat(params.opt_field_list, BRIEF_FIELDS);
-			strcat(params.opt_field_list, ",");
+			brief_output = true;
+			break;
+		case 'c':
+			params.opt_completion = 1;
+			break;
+		case 'C':
+			params.opt_cluster = xstrdup(optarg);
 			break;
-
 		case 'd':
 			params.opt_dump = 1;
 			break;
@@ -655,7 +405,7 @@ void parse_command_line(int argc, char **argv)
 		case 'e':
 		{	/* decode the time spec */
 			long	acc=0;
-			params.opt_expire_timespec = strdup(optarg);
+			params.opt_expire_timespec = xstrdup(optarg);
 			for (i=0; params.opt_expire_timespec[i]; i++) {
 				char	c = params.opt_expire_timespec[i];
 				if (isdigit(c)) {
@@ -755,13 +505,7 @@ void parse_command_line(int argc, char **argv)
 			break;
 
 		case 'l':
-			params.opt_field_list =
-				xrealloc(params.opt_field_list,
-					 (params.opt_field_list==NULL? 0 :
-					  strlen(params.opt_field_list)) +
-					 sizeof(LONG_FIELDS)+1);
-			strcat(params.opt_field_list, LONG_FIELDS);
-			strcat(params.opt_field_list, ",");
+			long_output = true;
 			break;
 
 		case 'O':
@@ -781,9 +525,7 @@ void parse_command_line(int argc, char **argv)
 			strcat(params.opt_partition_list, optarg);
 			strcat(params.opt_partition_list, ",");
 			break;
-		case 'r':
-			params.opt_raw = 1;
-			break;
+
 		case 's':
 			params.opt_state_list =
 				xrealloc(params.opt_state_list,
@@ -795,15 +537,12 @@ void parse_command_line(int argc, char **argv)
 			break;
 
 		case 'S':
-			params.opt_field_list =
-				xrealloc(params.opt_field_list,
-					 (params.opt_field_list==NULL? 0 :
-					  strlen(params.opt_field_list)) +
-					 sizeof(STAT_FIELDS)+1);
-			
-			strcat(params.opt_field_list, STAT_FIELDS);
-			strcat(params.opt_field_list, ",");
-			
+			if(!params.opt_field_list) {
+				params.opt_field_list = 
+					xmalloc(sizeof(STAT_FIELDS)+1);
+				strcat(params.opt_field_list, STAT_FIELDS);
+				strcat(params.opt_field_list, ",");
+			}
 			params.opt_stat = 1;
 			break;
 
@@ -816,7 +555,7 @@ void parse_command_line(int argc, char **argv)
 			break;
 
 		case 'u':
-			if (isdigit((int) *optarg))
+			if (isdigit((int) *optarg) || atoi(optarg) == -1)
 				params.opt_uid = atoi(optarg);
 			else {
 				struct passwd *pwd;
@@ -869,6 +608,8 @@ void parse_command_line(int argc, char **argv)
 
 	if (params.opt_verbose) {
 		fprintf(stderr, "Options selected:\n"
+			"\topt_cluster=%s\n"
+			"\topt_completion=%d\n"
 			"\topt_dump=%d\n"
 			"\topt_dup=%d\n"
 			"\topt_expire=%s (%lu seconds)\n"
@@ -883,11 +624,12 @@ void parse_command_line(int argc, char **argv)
 			"\topt_lowmem=%d\n"
 			"\topt_partition_list=%s\n"
 			"\topt_purge=%d\n"
-			"\topt_raw=%d\n"
 			"\topt_state_list=%s\n"
 			"\topt_total=%d\n"
 			"\topt_uid=%d\n"
 			"\topt_verbose=%d\n",
+			params.opt_cluster,
+			params.opt_completion,
 			params.opt_dump,
 			params.opt_dup,
 			params.opt_expire_timespec, params.opt_expire,
@@ -902,7 +644,6 @@ void parse_command_line(int argc, char **argv)
 			params.opt_lowmem,
 			params.opt_partition_list,
 			params.opt_purge,
-			params.opt_raw,
 			params.opt_state_list,
 			params.opt_total,
 			params.opt_uid,
@@ -910,15 +651,36 @@ void parse_command_line(int argc, char **argv)
 	}
 
 	/* check if we have accounting data to view */
-	if (params.opt_filein == NULL)
-		params.opt_filein = slurm_get_jobacct_loc();
-	acct_type = slurm_get_jobacct_type();
-	if ((strcmp(acct_type, "jobacct/none") == 0)
-	    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
-		fprintf(stderr, "SLURM accounting is disabled\n");
-		exit(1);
+	if (params.opt_filein == NULL) {
+		if(params.opt_completion) 
+			params.opt_filein = slurm_get_jobcomp_loc();
+		else
+			params.opt_filein = slurm_get_accounting_storage_loc();
+	}
+
+	if(params.opt_completion) {
+		g_slurm_jobcomp_init(params.opt_filein);
+
+		acct_type = slurm_get_jobcomp_type();
+		if ((strcmp(acct_type, "jobcomp/none") == 0)
+		    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
+			fprintf(stderr, "SLURM job completion is disabled\n");
+			exit(1);
+		}
+		xfree(acct_type);
+	} else {
+		slurm_acct_storage_init(params.opt_filein);
+		acct_db_conn = acct_storage_g_get_connection(false, false);
+		
+		acct_type = slurm_get_accounting_storage_type();
+		if ((strcmp(acct_type, "accounting_storage/none") == 0)
+		    &&  (stat(params.opt_filein, &stat_buf) != 0)) {
+			fprintf(stderr,
+				"SLURM accounting storage is disabled\n");
+			exit(1);
+		}
+		xfree(acct_type);
 	}
-	xfree(acct_type);
 
 	/* specific partitions requested? */
 	if (params.opt_partition_list) {
@@ -952,18 +714,22 @@ void parse_command_line(int argc, char **argv)
 				start++;	/* discard whitespace */
 			if(!(int)*start)
 				continue;
-			selected_step = xmalloc(sizeof(selected_step_t));
+			selected_step = 
+				xmalloc(sizeof(jobacct_selected_step_t));
 			list_append(selected_steps, selected_step);
 			
 			dot = strstr(start, ".");
 			if (dot == NULL) {
 				debug2("No jobstep requested");
 				selected_step->step = NULL;
+				selected_step->stepid = (uint32_t)NO_VAL;
 			} else {
 				*dot++ = 0;
 				selected_step->step = xstrdup(dot);
+				selected_step->stepid = atoi(dot);
 			}
 			selected_step->job = xstrdup(start);
+			selected_step->jobid = atoi(start);
 			start = end + 1;
 		}
 		if (params.opt_verbose) {
@@ -982,7 +748,7 @@ void parse_command_line(int argc, char **argv)
 		}
 	}
 
-	/* specific states (completion status) requested? */
+	/* specific states (completion state) requested? */
 	if (params.opt_state_list) {
 		start = params.opt_state_list;
 		while ((end = strstr(start, ",")) && start) {
@@ -992,18 +758,18 @@ void parse_command_line(int argc, char **argv)
 				start++;	/* discard whitespace */
 			if(!(int)*start)
 				continue;
-			c = decode_status_char(start);
+			c = decode_state_char(start);
 			if (c == -1)
 				fatal("unrecognized job state value");
-			selected_status[c] = 1;
+			selected_state[c] = 1;
 			start = end + 1;
 		}
 		if (params.opt_verbose) {
 			fprintf(stderr, "States requested:\n");
-			for(i=0; i< STATUS_COUNT; i++) {
-				if(selected_status[i]) {
+			for(i=0; i< STATE_COUNT; i++) {
+				if(selected_state[i]) {
 					fprintf(stderr, "\t: %s\n", 
-						decode_status_int(i));
+						job_state_string(i));
 					break;
 				}
 			}
@@ -1011,13 +777,48 @@ void parse_command_line(int argc, char **argv)
 	}
 
 	/* select the output fields */
+	if(brief_output) {
+		if(params.opt_completion)
+			dot = BRIEF_COMP_FIELDS;
+		else
+			dot = BRIEF_FIELDS;
+		
+		params.opt_field_list =
+			xrealloc(params.opt_field_list,
+				 (params.opt_field_list==NULL? 0 :
+				  sizeof(params.opt_field_list)) +
+				 strlen(dot)+1);
+		strcat(params.opt_field_list, dot);
+		strcat(params.opt_field_list, ",");
+	} 
+
+	if(long_output) {
+		if(params.opt_completion)
+			dot = LONG_COMP_FIELDS;
+		else
+			dot = LONG_FIELDS;
+		
+		params.opt_field_list =
+			xrealloc(params.opt_field_list,
+				 (params.opt_field_list==NULL? 0 :
+				  strlen(params.opt_field_list)) +
+				 strlen(dot)+1);
+		strcat(params.opt_field_list, dot);
+		strcat(params.opt_field_list, ",");
+	} 
+	
 	if (params.opt_field_list==NULL) {
 		if (params.opt_dump || params.opt_expire)
 			goto endopt;
-		params.opt_field_list = xmalloc(sizeof(DEFAULT_FIELDS)+1);
-		strcpy(params.opt_field_list, DEFAULT_FIELDS); 
+		if(params.opt_completion)
+			dot = DEFAULT_COMP_FIELDS;
+		else
+			dot = DEFAULT_FIELDS;
+		params.opt_field_list = xmalloc(strlen(dot)+1);
+		strcpy(params.opt_field_list, dot); 
 		strcat(params.opt_field_list, ",");
 	}
+
 	start = params.opt_field_list;
 	while ((end = strstr(start, ","))) {
 		*end = 0;
@@ -1075,24 +876,14 @@ void do_dump(void)
 {
 	ListIterator itr = NULL;
 	ListIterator itr_step = NULL;
-	job_rec_t *job = NULL;
-	step_rec_t *step = NULL;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
 	struct tm ts;
 	
 	itr = list_iterator_create(jobs);
 	while((job = list_next(itr))) {
-		if (!params.opt_dup)
-			if (job->jobnum_superseded) {
-				if (params.opt_verbose > 1)
-					fprintf(stderr,
-						"Note: Skipping older"
-						" job %u dated %d\n",
-						job->header.jobnum,
-						(int)job->header.job_submit);
-				continue;
-			}
 		if (params.opt_uid>=0)
-			if (job->header.uid != params.opt_uid)
+			if (job->uid != params.opt_uid)
 				continue;
 		if(job->sacct.min_cpu == (float)NO_VAL)
 			job->sacct.min_cpu = 0;
@@ -1106,71 +897,67 @@ void do_dump(void)
 
 		/* JOB_START */
 		if (job->show_full) {
-			if (!job->job_start_seen && job->job_step_seen) {
-				/* If we only saw JOB_TERMINATED, the
-				 * job was probably canceled. */ 
-				fprintf(stderr,
-					"Error: No JOB_START record for "
-					"job %u\n",
-					job->header.jobnum);
-			}
-			_dump_header(job->header);
+			gmtime_r(&job->start, &ts);
+			printf("%u %s %04d%02d%02d%02d%02d%02d %d %s %s ",
+			       job->jobid,
+			       job->partition,
+			       1900+(ts.tm_year),
+			       1+(ts.tm_mon),
+			       ts.tm_mday,
+			       ts.tm_hour,
+			       ts.tm_min,
+			       ts.tm_sec,
+			       (int)job->submit,
+			       job->blockid,	/* block id */
+			       "-");	/* reserved 1 */
+
 			printf("JOB_START 1 16 %d %d %s %d %d %d %s %s\n", 
-			       job->header.uid,
-			       job->header.gid,
+			       job->uid,
+			       job->gid,
 			       job->jobname,
 			       job->track_steps,
 			       job->priority,
-			       job->ncpus,
+			       job->alloc_cpus,
 			       job->nodes,
 			       job->account);
 		}
 		/* JOB_STEP */
 		itr_step = list_iterator_create(job->steps);
 		while((step = list_next(itr_step))) {
-			if (step->status == JOB_RUNNING &&
-			    job->job_terminated_seen) {
-				step->status = JOB_FAILED;
-				step->exitcode=1;
-			}
-			_dump_header(step->header);
+			gmtime_r(&step->start, &ts);
+			printf("%u %s %04d%02d%02d%02d%02d%02d %d %s %s ",
+			       job->jobid,
+			       job->partition,
+			       1900+(ts.tm_year),
+			       1+(ts.tm_mon),
+			       ts.tm_mday,
+			       ts.tm_hour,
+			       ts.tm_min,
+			       ts.tm_sec,
+			       (int)job->submit,
+			       job->blockid,	/* block id */
+			       "-");	/* reserved 1 */
 			if(step->end == 0)
 				step->end = job->end;
 				
 			gmtime_r(&step->end, &ts);
 			printf("JOB_STEP 1 50 %u %04d%02d%02d%02d%02d%02d ",
-			       step->stepnum,
+			       step->stepid,
 			       1900+(ts.tm_year), 1+(ts.tm_mon), ts.tm_mday,
 			            ts.tm_hour, ts.tm_min, ts.tm_sec);
 			printf("%s %d %d %d %d ",
-			       decode_status_int_abbrev(step->status),
+			       job_state_string_compact(step->state),
 			       step->exitcode,
-			       step->ntasks,
+			       step->ncpus,
 			       step->ncpus,
 			       step->elapsed);
-			printf("%d %d %d %d %d %d ",
+			printf("%d %d %d %d %d %d %d %d",
 			       step->tot_cpu_sec,
 			       step->tot_cpu_usec,
-			       (int)step->rusage.ru_utime.tv_sec,
-			       (int)step->rusage.ru_utime.tv_usec,
-			       (int)step->rusage.ru_stime.tv_sec,
-			       (int)step->rusage.ru_stime.tv_usec);
-			printf("%d %d %d %d %d %d %d %d %d "
-			       "%d %d %d %d %d %d %d ",
-			       (int)step->rusage.ru_maxrss,
-			       (int)step->rusage.ru_ixrss,
-			       (int)step->rusage.ru_idrss,
-			       (int)step->rusage.ru_isrss,
-			       (int)step->rusage.ru_minflt,
-			       (int)step->rusage.ru_majflt,
-			       (int)step->rusage.ru_nswap,
-			       (int)step->rusage.ru_inblock,
-			       (int)step->rusage.ru_oublock,
-			       (int)step->rusage.ru_msgsnd,
-			       (int)step->rusage.ru_msgrcv,
-			       (int)step->rusage.ru_nsignals,
-			       (int)step->rusage.ru_nvcsw,
-			       (int)step->rusage.ru_nivcsw,
+			       (int)step->user_cpu_sec,
+			       (int)step->user_cpu_usec,
+			       (int)step->sys_cpu_sec,
+			       (int)step->sys_cpu_usec,
 			       step->sacct.max_vsize/1024, 
 			       step->sacct.max_rss/1024);
 			/* Data added in Slurm v1.1 */
@@ -1197,7 +984,19 @@ void do_dump(void)
 		list_iterator_destroy(itr_step);
 		/* JOB_TERMINATED */
 		if (job->show_full) {
-			_dump_header(job->header);
+			gmtime_r(&job->start, &ts);
+			printf("%u %s %04d%02d%02d%02d%02d%02d %d %s %s ",
+			       job->jobid,
+			       job->partition,
+			       1900+(ts.tm_year),
+			       1+(ts.tm_mon),
+			       ts.tm_mday,
+			       ts.tm_hour,
+			       ts.tm_min,
+			       ts.tm_sec,
+			       (int)job->submit,
+			       job->blockid,	/* block id */
+			       "-");	/* reserved 1 */
 			gmtime_r(&job->end, &ts);
 			printf("JOB_TERMINATED 1 50 %d ",
 			       job->elapsed);
@@ -1205,34 +1004,18 @@ void do_dump(void)
 			1900+(ts.tm_year), 1+(ts.tm_mon), ts.tm_mday,
 			      ts.tm_hour, ts.tm_min, ts.tm_sec); 
 			printf("%s %d %d %d %d ",
-			       decode_status_int_abbrev(job->status),
+			       job_state_string_compact(job->state),
 			       job->exitcode,
-			       job->ntasks,
-			       job->ncpus,
+			       job->alloc_cpus,
+			       job->alloc_cpus,
 			       job->elapsed);
-			printf("%d %d %d %d %d %d ",
+			printf("%d %d %d %d %d %d %d %d",
 			       job->tot_cpu_sec,
 			       job->tot_cpu_usec,
-			       (int)job->rusage.ru_utime.tv_sec,
-			       (int)job->rusage.ru_utime.tv_usec,
-			       (int)job->rusage.ru_stime.tv_sec,
-			       (int)job->rusage.ru_stime.tv_usec);
-			printf("%d %d %d %d %d %d %d %d %d "
-			       "%d %d %d %d %d %d %d ",
-			       (int)job->rusage.ru_maxrss,
-			       (int)job->rusage.ru_ixrss,
-			       (int)job->rusage.ru_idrss,
-			       (int)job->rusage.ru_isrss,
-			       (int)job->rusage.ru_minflt,
-			       (int)job->rusage.ru_majflt,
-			       (int)job->rusage.ru_nswap,
-			       (int)job->rusage.ru_inblock,
-			       (int)job->rusage.ru_oublock,
-			       (int)job->rusage.ru_msgsnd,
-			       (int)job->rusage.ru_msgrcv,
-			       (int)job->rusage.ru_nsignals,
-			       (int)job->rusage.ru_nvcsw,
-			       (int)job->rusage.ru_nivcsw,
+			       (int)job->user_cpu_sec,
+			       (int)job->user_cpu_usec,
+			       (int)job->sys_cpu_sec,
+			       (int)job->sys_cpu_usec,
 			       job->sacct.max_vsize/1024, 
 			       job->sacct.max_rss/1024);
 			/* Data added in Slurm v1.1 */
@@ -1261,429 +1044,46 @@ void do_dump(void)
 	list_iterator_destroy(itr);		
 }
 
-/* do_expire() -- purge expired data from the accounting log file
- *
- * What we're doing:
- *  1. Open logfile.orig
- *  2. stat logfile.orig
- *     - confirm that it's not a sym link
- *     - capture the ownership and permissions
- *  3. scan logfile.orig for JOB_TERMINATED records with F_TIMESTAMP dates
- *     that precede the specified expiration date. Build exp_table as
- *     a list of expired jobs.
- *  4. Open logfile.expired for append
- *  5. Create logfile.new as ".new.<logfile>" (output with line buffering)
- *  6. Re-scan logfile.orig, writing
- *     - Expired job records to logfile.expired
- *     - Other job records to logfile.new
- *  7. Rename logfile.orig as ".old.<logfile>"
- *  8. Rename logfile.new as "<logfile>"
- *  9. Execute "scontrol reconfigure" which will cause slurmctld to
- *     start writing to logfile.new
- * 10. fseek(ftell(logfile.orig)) to clear EOF
- * 11. Copy any new records from logfile.orig to logfile.new
- * 12. Close logfile.expired, logfile.new
- * 13. Unlink .old.<logfile>
- */
-
-void do_expire(void)
+void do_dump_completion(void)
 {
-	char	line[BUFFER_SIZE],
-		*f[EXPIRE_READ_LENGTH],
-		*fptr = NULL,
-		*logfile_name = NULL,
-		*old_logfile_name = NULL;
-	int	file_err=0,
-		new_file,
-		i = 0;
-	expired_rec_t *exp_rec = NULL;
-	expired_rec_t *exp_rec2 = NULL;
-	List keep_list = list_create(_destroy_exp);
-	List exp_list = list_create(_destroy_exp);
-	List other_list = list_create(_destroy_exp);
-	struct	stat statbuf;
-	mode_t	prot = 0600;
-	uid_t	uid;
-	gid_t	gid;
-	FILE	*expired_logfile = NULL,
-		*new_logfile = NULL;
-	FILE *fd = NULL;
-	int lc=0;
-	int rec_type = -1;
 	ListIterator itr = NULL;
-	ListIterator itr2 = NULL;
-	char *temp = NULL;
-
-	/* Figure out our expiration date */
-	time_t		expiry;
-	expiry = time(NULL)-params.opt_expire;
-	if (params.opt_verbose)
-		fprintf(stderr, "Purging jobs completed prior to %d\n",
-			(int)expiry);
-
-	/* Open the current or specified logfile, or quit */
-	fd = _open_log_file();
-	if (stat(params.opt_filein, &statbuf)) {
-		perror("stat'ing logfile");
-		goto finished;
-	}
-	if ((statbuf.st_mode & S_IFLNK) == S_IFLNK) {
-		fprintf(stderr, "%s is a symbolic link; --expire requires "
-			"a hard-linked file name\n", params.opt_filein);
-		goto finished;
-	}
-	if (!(statbuf.st_mode & S_IFREG)) {
-		fprintf(stderr, "%s is not a regular file; --expire "
-			"only works on accounting log files\n",
-			params.opt_filein);
-		goto finished;
-	}
-	prot = statbuf.st_mode & 0777;
-	gid  = statbuf.st_gid;
-	uid  = statbuf.st_uid;
-	old_logfile_name = _prefix_filename(params.opt_filein, ".old.");
-	if (stat(old_logfile_name, &statbuf)) {
-		if (errno != ENOENT) {
-			fprintf(stderr,"Error checking for %s: ",
-				old_logfile_name);
-			perror("");
-			goto finished;
-		}
-	} else {
-		fprintf(stderr, "Warning! %s exists -- please remove "
-			"or rename it before proceeding\n",
-			old_logfile_name);
-		goto finished;
-	}
-
-	/* create our initial buffer */
-	while (fgets(line, BUFFER_SIZE, fd)) {
-		lc++;
-		fptr = line;	/* break the record into NULL-
-				   terminated strings */
-		exp_rec = xmalloc(sizeof(expired_rec_t));
-		exp_rec->line = xstrdup(line);
-	
-		for (i = 0; i < EXPIRE_READ_LENGTH; i++) {
-			f[i] = fptr;
-			fptr = strstr(fptr, " ");
-			if (fptr == NULL)
-				break; 
-			else
-				*fptr++ = 0;
-		}
+	jobcomp_job_rec_t *job = NULL;
 		
-		exp_rec->job = atoi(f[F_JOB]);
-		exp_rec->job_submit = atoi(f[F_JOB_SUBMIT]);
-		
-		rec_type = atoi(f[F_RECTYPE]);
-		/* Odd, but complain some other time */
-		if (rec_type == JOB_TERMINATED) {
-			if (expiry < atoi(f[F_TIMESTAMP])) {
-				list_append(keep_list, exp_rec);
-				continue;				
-			}
-			if (list_count(selected_parts)) {
-				itr = list_iterator_create(selected_parts);
-				while((temp = list_next(itr))) 
-					if(!strcasecmp(f[F_PARTITION], temp)) 
-						break;
-				list_iterator_destroy(itr);
-				if(!temp) {
-					list_append(keep_list, exp_rec);
-					continue;
-				} /* no match */
-			}
-			list_append(exp_list, exp_rec);
-			if (params.opt_verbose > 2)
-				fprintf(stderr, "Selected: %8d %d\n",
-					exp_rec->job,
-					(int)exp_rec->job_submit);
-		} else {
-			list_append(other_list, exp_rec);
-		}
-	}
-	if (!list_count(exp_list)) {
-		printf("No job records were purged.\n");
-		goto finished;
-	}
-	logfile_name = xmalloc(strlen(params.opt_filein)+sizeof(".expired"));
-	sprintf(logfile_name, "%s.expired", params.opt_filein);
-	new_file = stat(logfile_name, &statbuf);
-	if ((expired_logfile = fopen(logfile_name, "a"))==NULL) {
-		fprintf(stderr, "Error while opening %s", 
-			logfile_name);
-		perror("");
-		xfree(logfile_name);
-		goto finished;
-	}
-
-	if (new_file) {  /* By default, the expired file looks like the log */
-		chmod(logfile_name, prot);
-		chown(logfile_name, uid, gid);
-	}
-	xfree(logfile_name);
-
-	logfile_name = _prefix_filename(params.opt_filein, ".new.");
-	if ((new_logfile = fopen(logfile_name, "w"))==NULL) {
-		fprintf(stderr, "Error while opening %s",
-			logfile_name);
-		perror("");
-		fclose(expired_logfile);
-		goto finished;
-	}
-	chmod(logfile_name, prot);     /* preserve file protection */
-	chown(logfile_name, uid, gid); /* and ownership */
-	/* Use line buffering to allow us to safely write
-	 * to the log file at the same time as slurmctld. */ 
-	if (setvbuf(new_logfile, NULL, _IOLBF, 0)) {
-		perror("setvbuf()");
-		fclose(expired_logfile);
-		goto finished2;
-	}
-
-	list_sort(exp_list, (ListCmpF) _cmp_jrec);
-	list_sort(keep_list, (ListCmpF) _cmp_jrec);
-	
-	if (params.opt_verbose > 2) {
-		fprintf(stderr, "--- contents of exp_list ---");
-		itr = list_iterator_create(exp_list);
-		while((exp_rec = list_next(itr))) {
-			if (!(i%5))
-				fprintf(stderr, "\n");
-			else
-				fprintf(stderr, "\t");
-			fprintf(stderr, "%d", exp_rec->job);
-		}
-		fprintf(stderr, "\n---- end of exp_list ---\n");
-		list_iterator_destroy(itr);
-	}
-	/* write the expired file */
-	itr = list_iterator_create(exp_list);
-	while((exp_rec = list_next(itr))) {
-		itr2 = list_iterator_create(other_list);
-		while((exp_rec2 = list_next(itr2))) {
-			if((exp_rec2->job != exp_rec->job) 
-			   || (exp_rec2->job_submit != exp_rec->job_submit))
-				continue;
-			if (fputs(exp_rec2->line, expired_logfile)<0) {
-				perror("writing expired_logfile");
-				list_iterator_destroy(itr2);
-				list_iterator_destroy(itr);
-				fclose(expired_logfile);
-				goto finished2;
-			}
-			list_remove(itr2);
-			_destroy_exp(exp_rec2);
-		}
-		list_iterator_destroy(itr2);
-		if (fputs(exp_rec->line, expired_logfile)<0) {
-			perror("writing expired_logfile");
-			list_iterator_destroy(itr);
-			fclose(expired_logfile);
-			goto finished2;
-		}		
-	}
-	list_iterator_destroy(itr);
-	fclose(expired_logfile);
-	
-	/* write the new log */
-	itr = list_iterator_create(keep_list);
-	while((exp_rec = list_next(itr))) {
-		itr2 = list_iterator_create(other_list);
-		while((exp_rec2 = list_next(itr2))) {
-			if(exp_rec2->job != exp_rec->job)
-				continue;
-			if (fputs(exp_rec2->line, new_logfile)<0) {
-				perror("writing keep_logfile");
-				list_iterator_destroy(itr2);
-				list_iterator_destroy(itr);
-				goto finished2;
-			}
-			list_remove(itr2);
-			_destroy_exp(exp_rec2);
-		}
-		list_iterator_destroy(itr2);
-		if (fputs(exp_rec->line, new_logfile)<0) {
-			perror("writing keep_logfile");
-			list_iterator_destroy(itr);
-			goto finished2;
-		}		
+	itr = list_iterator_create(jobs);
+	while((job = list_next(itr))) {
+		printf("JOB %u %s %s %s %s(%u) %u(%s) %u %s %s %s %s",
+		       job->jobid, job->partition, job->start_time,
+		       job->end_time, job->uid_name, job->uid, job->gid,
+		       job->gid_name, job->node_cnt, job->nodelist, 
+		       job->jobname, job->state,
+		       job->timelimit);
+#ifdef HAVE_BG
+		if(job->blockid)
+			printf(" %s %s %s %s %u %s %s",
+			       job->blockid, job->connection, job->reboot,
+			       job->rotate, job->max_procs, job->geo,
+			       job->bg_start_point);
+#endif
+		printf("\n");
 	}
 	list_iterator_destroy(itr);
-	
-	if (rename(params.opt_filein, old_logfile_name)) {
-		perror("renaming logfile to .old.");
-		goto finished2;
-	}
-	if (rename(logfile_name, params.opt_filein)) {
-		perror("renaming new logfile");
-		/* undo it? */
-		if (!rename(old_logfile_name, params.opt_filein)) 
-			fprintf(stderr, "Please correct the problem "
-				"and try again");
-		else
-			fprintf(stderr, "SEVERE ERROR: Current accounting "
-				"log may have been renamed %s;\n"
-				"please rename it to \"%s\" if necessary, "
-			        "and try again\n",
-				old_logfile_name, params.opt_filein);
-		goto finished2;
-	}
-	fflush(new_logfile);	/* Flush the buffers before forking */
-	fflush(fd);
-	
-	file_err = slurm_reconfigure ();
-	
-	if (file_err) {
-		file_err = 1;
-		fprintf(stderr, "Error: Attempt to reconfigure "
-			"SLURM failed.\n");
-		if (rename(old_logfile_name, params.opt_filein)) {
-			perror("renaming logfile from .old.");
-			goto finished2;
-		}
-
-	}
-	if (fseek(fd, 0, SEEK_CUR)) {	/* clear EOF */
-		perror("looking for late-arriving records");
-		goto finished2;
-	}
-	while (fgets(line, BUFFER_SIZE, fd)) {
-		if (fputs(line, new_logfile)<0) {
-			perror("writing final records");
-			goto finished2;
-		}
-	}
-	
-	printf("%d jobs expired.\n", list_count(exp_list));
-finished2:
-	fclose(new_logfile);
-	if (!file_err) {
-		if (unlink(old_logfile_name) == -1)
-			error("Unable to unlink old logfile %s: %m",
-			      old_logfile_name);
-	}
-finished:
-	fclose(fd);
-	list_destroy(exp_list);
-	list_destroy(keep_list);
-	list_destroy(other_list);
-	xfree(old_logfile_name);
-	xfree(logfile_name);
 }
 
-void do_fdump(char* f[], int lc)
+/* do_expire() -- purge expired data from the accounting log file
+ */
+
+void do_expire(int dummy)
 {
-	int	i=0, j=0;
-	char **type;
-	char    *header[] = {"job",       /* F_JOB */
-			     "partition", /* F_PARTITION */
-			     "job_submit", /* F_JOB_SUBMIT */
-			     "timestamp", /* F_TIMESTAMP */
-			     "uid",	 /* F_UIDGID */
-			     "gid",	 /* F_UIDGID */
-			     "BlockID",  /* F_BLOCKID */
-			     "reserved-2",/* F_RESERVED1 */
-			     "recordType",/* F_RECTYPE */
-			     NULL};
-
-	char	*start[] = {"jobName",	 /* F_JOBNAME */ 
-			    "TrackSteps", /* F_TRACK_STEPS */
-			    "priority",	 /* F_PRIORITY */
-			    "ncpus",	 /* F_NCPUS */
-			    "nodeList", /* F_NODES */
-				"account",   /* F_JOB_ACCOUNT */
-			    NULL};
-		
-	char	*step[] = {"jobStep",	 /* F_JOBSTEP */
-			   "status",	 /* F_STATUS */ 
-			   "exitcode",	 /* F_EXITCODE */
-			   "ntasks",	 /* F_NTASKS */
-			   "ncpus",	 /* F_STEPNCPUS */
-			   "elapsed",	 /* F_ELAPSED */
-			   "cpu_sec",	 /* F_CPU_SEC */
-			   "cpu_usec",	 /* F_CPU_USEC */
-			   "user_sec",	 /* F_USER_SEC */
-			   "user_usec",	 /* F_USER_USEC */
-			   "sys_sec",	 /* F_SYS_SEC */
-			   "sys_usec",	 /* F_SYS_USEC */
-			   "rss",	 /* F_RSS */
-			   "ixrss",	 /* F_IXRSS */
-			   "idrss",	 /* F_IDRSS */
-			   "isrss",	 /* F_ISRSS */
-			   "minflt",	 /* F_MINFLT */
-			   "majflt",	 /* F_MAJFLT */
-			   "nswap",	 /* F_NSWAP */
-			   "inblocks",	 /* F_INBLOCKS */
-			   "oublocks",	 /* F_OUTBLOCKS */
-			   "msgsnd",	 /* F_MSGSND */
-			   "msgrcv",	 /* F_MSGRCV */
-			   "nsignals",	 /* F_NSIGNALS */
-			   "nvcsw",	 /* F_VCSW */
-			   "nivcsw",	 /* F_NIVCSW */
-			   "max_vsize",	 /* F_MAX_VSIZE */
-			   "max_vsize_task",	 /* F_MAX_VSIZE_TASK */
-			   "ave_vsize",	 /* F_AVE_VSIZE */
-			   "max_rss",	 /* F_MAX_RSS */
-			   "max_rss_task",	 /* F_MAX_RSS_TASK */
-			   "ave_rss",	 /* F_AVE_RSS */
-			   "max_pages",	 /* F_MAX_PAGES */
-			   "max_pages_task",	 /* F_MAX_PAGES_TASK */
-			   "ave_pages",	 /* F_AVE_PAGES */
-			   "min_cputime",	 /* F_MIN_CPU */
-			   "min_cputime_task",	 /* F_MIN_CPU_TASK */
-			   "ave_cputime",	 /* F_AVE_RSS */
-			   "StepName",	 /* F_STEPNAME */
-			   "StepNodes",	 /* F_STEPNODES */
-			   "max_vsize_node",	 /* F_MAX_VSIZE_NODE */
-			   "max_rss_node",	 /* F_MAX_RSS_NODE */
-			   "max_pages_node",	 /* F_MAX_PAGES_NODE */
-			   "min_cputime_node",	 /* F_MIN_CPU_NODE */
-			   "account",    /* F_STEP_ACCOUNT */
-			   "requid",     /* F_STEP_REQUID */
-			   NULL};
-       
-	char	*suspend[] = {"Suspend/Run time", /* F_TOT_ELAPSED */
-			      "status",	 /* F_STATUS */ 
-			      NULL};	 
-
-	char	*term[] = {"totElapsed", /* F_TOT_ELAPSED */
-			   "status",	 /* F_STATUS */ 
-			   "requid",     /* F_JOB_REQUID */
-			   NULL};	 
-		
-	i = atoi(f[F_RECTYPE]);
-	printf("\n------- Line %d %s -------\n", lc, _convert_type(i));
-
-	for(j=0; j < HEADER_LENGTH; j++) 
-		printf("%12s: %s\n", header[j], f[j]);
-	switch(i) {
-	case JOB_START:
-		type = start;
-		j = JOB_START_LENGTH;
-		break;
-	case JOB_STEP:
-		type = step;
-		j = JOB_STEP_LENGTH;
-		break;
-	case JOB_SUSPEND:
-		type = suspend;
-		j = JOB_TERM_LENGTH;
-	case JOB_TERMINATED:
-		type = term;
-		j = JOB_TERM_LENGTH;
-		break;
-	default:
-		while(f[j]) {
-			printf("      Field[%02d]: %s\n", j, f[j]); 
-			j++;
-		}
-		return;
+	if (dummy == NO_VAL) {
+		/* just load the symbol, don't want to execute */
+		slurm_reconfigure();
 	}
-	
-	for(i=HEADER_LENGTH; i < j; i++)
-       		printf("%12s: %s\n", type[i-HEADER_LENGTH], f[i]);	
+
+	if(params.opt_completion) 
+		g_slurm_jobcomp_archive(selected_parts, &params);
+	else
+		jobacct_storage_g_archive(acct_db_conn,
+					  selected_parts, &params);
 }
 
 void do_help(void)
@@ -1715,61 +1115,26 @@ void do_help(void)
 void do_list(void)
 {
 	int do_jobsteps = 1;
-	int rc = 0;
 	
 	ListIterator itr = NULL;
 	ListIterator itr_step = NULL;
-	job_rec_t *job = NULL;
-	step_rec_t *step = NULL;
+	jobacct_job_rec_t *job = NULL;
+	jobacct_step_rec_t *step = NULL;
 	
 	if (params.opt_total)
 		do_jobsteps = 0;
-	
 	itr = list_iterator_create(jobs);
 	while((job = list_next(itr))) {
-		if (!params.opt_dup)
-			if (job->jobnum_superseded) {
-				if (params.opt_verbose > 1)
-					fprintf(stderr,
-						"Note: Skipping older"
-						" job %u dated %d\n",
-						job->header.jobnum,
-						(int)job->header.job_submit);
-				continue;
-			}
-		if (!job->job_start_seen && job->job_step_seen) {
-			/* If we only saw JOB_TERMINATED, the job was
-			 * probably canceled. */
-			fprintf(stderr,
-				"Error: No JOB_START record for job %u\n",
-				job->header.jobnum);
-			if (rc<ERROR)
-				rc = ERROR;
-		}
-		if (params.opt_verbose > 1) {
-			if (!job->job_start_seen)
-				fprintf(stderr,
-					"Note: No JOB_START record for "
-					"job %u\n",
-					job->header.jobnum);
-			if (!job->job_step_seen)
-				fprintf(stderr,
-					"Note: No JOB_STEP record for "
-					"job %u\n",
-					job->header.jobnum);
-			if (!job->job_terminated_seen)
-				fprintf(stderr,
-					"Note: No JOB_TERMINATED record for "
-					"job %u\n",
-					job->header.jobnum);
-		}
-		if (params.opt_uid >= 0 && (job->header.uid != params.opt_uid))
+		/* FIX ME: this should be handled while getting the
+		   data, not afterwards.
+		*/
+		if (params.opt_uid >= 0 && (job->uid != params.opt_uid))
 			continue;
-		if (params.opt_gid >= 0 && (job->header.gid != params.opt_gid))
+		if (params.opt_gid >= 0 && (job->gid != params.opt_gid))
 			continue;
 		if(job->sacct.min_cpu == NO_VAL)
 			job->sacct.min_cpu = 0;
-		
+
 		if(list_count(job->steps)) {
 			job->sacct.ave_cpu /= list_count(job->steps);
 			job->sacct.ave_rss /= list_count(job->steps);
@@ -1779,7 +1144,7 @@ void do_list(void)
 
 		if (job->show_full) {
 			if (params.opt_state_list) {
-				if(!selected_status[job->status])
+				if(!selected_state[job->state])
 					continue;
 			}
 			print_fields(JOB, job);
@@ -1788,12 +1153,8 @@ void do_list(void)
 		if (do_jobsteps && (job->track_steps || !job->show_full)) {
 			itr_step = list_iterator_create(job->steps);
 			while((step = list_next(itr_step))) {
-				if (step->status == JOB_RUNNING 
-				    && job->job_terminated_seen) {
-					step->status = JOB_FAILED;
-				}
 				if (params.opt_state_list) {
-					if(!selected_status[step->status])
+					if(!selected_state[step->state])
 						continue;
 				}
 				if(step->end == 0)
@@ -1806,12 +1167,36 @@ void do_list(void)
 	list_iterator_destroy(itr);
 }
 
+/* do_list_completion() -- List the assembled data
+ *
+ * In:	Nothing explicit.
+ * Out:	void.
+ *
+ * At this point, we have already selected the desired data,
+ * so we just need to print it for the user.
+ */
+void do_list_completion(void)
+{
+	ListIterator itr = NULL;
+	jobcomp_job_rec_t *job = NULL;
+	
+	itr = list_iterator_create(jobs);
+	while((job = list_next(itr))) {
+		if (params.opt_uid >= 0 && (job->uid != params.opt_uid))
+			continue;
+		if (params.opt_gid >= 0 && (job->gid != params.opt_gid))
+			continue;
+		print_fields(JOBCOMP, job);
+	}
+	list_iterator_destroy(itr);
+}
+
 void do_stat()
 {
 	ListIterator itr = NULL;
 	uint32_t jobid = 0;
 	uint32_t stepid = 0;
-	selected_step_t *selected_step = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
 	
 	itr = list_iterator_create(selected_steps);
 	while((selected_step = list_next(itr))) {
@@ -1827,16 +1212,22 @@ void do_stat()
 void sacct_init()
 {
 	int i=0;
-	jobs = list_create(destroy_job);
 	selected_parts = list_create(_destroy_parts);
 	selected_steps = list_create(_destroy_steps);
-	for(i=0; i<STATUS_COUNT; i++)
-		selected_status[i] = 0;
+	for(i=0; i<STATE_COUNT; i++)
+		selected_state[i] = 0;
 }
 
 void sacct_fini()
 {
-	list_destroy(jobs);
+	if(jobs)
+		list_destroy(jobs);
 	list_destroy(selected_parts);
 	list_destroy(selected_steps);
+	if(params.opt_completion)
+		g_slurm_jobcomp_fini();
+	else {
+		acct_storage_g_close_connection(&acct_db_conn);
+		slurm_acct_storage_fini();
+	}
 }
diff --git a/src/sacct/print.c b/src/sacct/print.c
index 6a55de7a3e5527b81243934fb69e23559ca4ece4..61a70f8e4f8ca7284923fc84ef62475803c8c533 100644
--- a/src/sacct/print.c
+++ b/src/sacct/print.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -40,7 +40,7 @@
 #include "sacct.h"
 #include "src/common/parse_time.h"
 #include "slurm.h"
-#define FORMAT_STRING_SIZE 50
+#define FORMAT_STRING_SIZE 34
 
 void _elapsed_time(long secs, long usecs, char *str);
 
@@ -97,98 +97,129 @@ void print_fields(type_t type, void *object)
 
 void print_cpu(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "Cpu");
+		printf("%-15s", "Cpu");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
 		_elapsed_time(job->tot_cpu_sec, job->tot_cpu_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
 		_elapsed_time(step->tot_cpu_sec, step->tot_cpu_usec, str);
-		printf("%15s", str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
 }
 
 void print_elapsed(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "Elapsed");
+		printf("%-15s", "Elapsed");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
 		_elapsed_time(job->elapsed, 0, str);
-		printf("%15s", str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
 		_elapsed_time(step->elapsed, 0, str);
-		printf("%15s", str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
 }
 
 void print_exitcode(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char tmp[9];
+	uint16_t term_sig = 0;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "ExitCode");
+		printf("%-8s", "ExitCode");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "--------");
+		printf("%-8s", "--------");
 		break;
 	case JOB:
-		printf("%8d", job->exitcode);
+		if (WIFSIGNALED(job->exitcode))
+			term_sig = WTERMSIG(job->exitcode);
+	
+		snprintf(tmp, sizeof(tmp), "%u:%u",
+			 WEXITSTATUS(job->exitcode), term_sig);
+		printf("%-8s", tmp);
 		break;
 	case JOBSTEP:
-		printf("%8d", step->exitcode);
+		if (WIFSIGNALED(step->exitcode))
+			term_sig = WTERMSIG(step->exitcode);
+	
+		snprintf(tmp, sizeof(tmp), "%u:%u",
+			 WEXITSTATUS(step->exitcode), term_sig);
+		printf("%-8s", tmp);
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_gid(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	int32_t gid = -1;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%5s", "Gid");
+		printf("%-5s", "Gid");
 		break;
 	case UNDERSCORE:
-		printf("%5s", "-----");
+		printf("%-5s", "-----");
 		break;
 	case JOB:
-		printf("%5d", job->header.gid);
+		gid = job->gid;
+		break;
+	case JOBCOMP:
+		printf("%-5u", jobcomp->gid);
 		break;
 	case JOBSTEP:
-		printf("s%5d", step->header.gid);
+		printf("%-5s", " ");
+		break;
+	default:
+		printf("%-5s", "n/a");
 		break;
 	} 
+
+	if(gid != -1) 
+		printf("%-5d", gid);
 }
 
 void print_group(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
 	int gid = -1;
 	char	*tmp="(unknown)";
 	struct	group *gr = NULL;
@@ -201,10 +232,16 @@ void print_group(type_t type, void *object)
 		printf("%-9s", "---------");
 		break;
 	case JOB:
-		gid = job->header.gid;
+		gid = job->gid;
+		break;
+	case JOBCOMP:
+		printf("%-9s", jobcomp->gid_name);
 		break;
 	case JOBSTEP:
-		gid = step->header.gid;
+		printf("%-9s", " ");
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	}
 	if(gid != -1) {
@@ -214,125 +251,34 @@ void print_group(type_t type, void *object)
 	} 
 }
 
-void print_idrss(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-	struct rusage rusage;
-	char outbuf[FORMAT_STRING_SIZE];
-	rusage.ru_idrss = 0;
-	
-	switch(type) {
-	case HEADLINE:
-		printf("%8s", "Idrss");
-		return;
-		break;
-	case UNDERSCORE:
-		printf("%8s", "------");
-		return;
-		break;
-	case JOB:
-		rusage = job->rusage;
-		break;
-	case JOBSTEP:
-		rusage = step->rusage;
-		break;
-	} 
-	convert_num_unit((float)rusage.ru_idrss, outbuf, sizeof(outbuf),
-			 UNIT_NONE);
-	printf("%8s", outbuf);
-}
-
-void print_inblocks(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%9s", "Inblocks");
-		break;
-	case UNDERSCORE:
-		printf("%9s", "---------");
-		break;
-	case JOB:
-		printf("%9ld", job->rusage.ru_inblock);
-		break;
-	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_inblock);
-		break;
-	} 
-}
-
-void print_isrss(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%8s", "Isrss");
-		break;
-	case UNDERSCORE:
-		printf("%8s", "------");
-		break;
-	case JOB:
-		printf("%8ld", job->rusage.ru_isrss);
-		break;
-	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_isrss);
-		break;
-	} 
-
-}
-
-void print_ixrss(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%8s", "Ixrss");
-		break;
-	case UNDERSCORE:
-		printf("%8s", "------");
-		break;
-	case JOB:
-		printf("%8ld", job->rusage.ru_ixrss);
-		break;
-	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_ixrss);
-		break;
-	} 
-
-}
-
 void print_job(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%8s", "Job");
+		printf("%-8s", "Job");
 		break;
 	case UNDERSCORE:
-		printf("%8s", "--------");
+		printf("%-8s", "--------");
 		break;
 	case JOB:
-		printf("%8d", job->header.jobnum);
+		printf("%-8u", job->jobid);
 		break;
 	case JOBSTEP:
-		printf("%8d", step->header.jobnum);
+		printf("%-8s", " ");
+		break;
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
 void print_name(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -349,6 +295,15 @@ void print_name(type_t type, void *object)
 		else
 			printf("%-15.15s...", job->jobname);
 			
+		break;
+	case JOBCOMP:
+		if(!jobcomp->jobname)
+			printf("%-18s", "unknown");			     
+		else if(strlen(jobcomp->jobname)<19)
+			printf("%-18s", jobcomp->jobname);
+		else
+			printf("%-15.15s...", jobcomp->jobname);
+			
 		break;
 	case JOBSTEP:
 		if(!step->stepname)
@@ -358,13 +313,17 @@ void print_name(type_t type, void *object)
 		else
 			printf("%-15.15s...", step->stepname);
 		break;
+	default:
+		printf("%-18s", "n/a");
+		break;
 	} 
 }
 
 void print_jobid(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[10];
 
 	switch(type) {
@@ -375,148 +334,54 @@ void print_jobid(type_t type, void *object)
 		printf("%-10s", "----------");
 		break;
 	case JOB:
-		printf("%-10d", job->header.jobnum);
+		printf("%-10u", job->jobid);
+		break;
+	case JOBCOMP:
+		printf("%-10u", jobcomp->jobid);
 		break;
 	case JOBSTEP:
 		snprintf(outbuf, sizeof(outbuf), "%u.%u",
-			 step->header.jobnum,
-			 step->stepnum);
+			 step->jobid,
+			 step->stepid);
 		printf("%-10s", outbuf);
 		break;
-	} 
-
-}
-
-void print_majflt(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%8s", "Majflt");
-		break;
-	case UNDERSCORE:
-		printf("%8s", "------");
-		break;
-	case JOB:
-		printf("%8ld", job->rusage.ru_majflt);
-		break;
-	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_majflt);
-		break;
-	} 
-}
-
-void print_minflt(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%8s", "Minflt");
-		break;
-	case UNDERSCORE:
-		printf("%8s", "------");
-		break;
-	case JOB:
-		printf("%8ld", job->rusage.ru_minflt);
-		break;
-	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_minflt);
+	default:
+		printf("%-10s", "n/a");
 		break;
 	} 
-}
 
-void print_msgrcv(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%9s", "Msgrcv");
-		break;
-	case UNDERSCORE:
-		printf("%9s", "---------");
-		break;
-	case JOB:
-		printf("%9ld", job->rusage.ru_msgrcv);
-		break;
-	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_msgrcv);
-		break;
-	} 
-}
-
-void print_msgsnd(type_t type, void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%9s", "Msgsnd");
-		break;
-	case UNDERSCORE:
-		printf("%9s", "---------");
-		break;
-	case JOB:
-		printf("%9ld", job->rusage.ru_msgsnd);
-		break;
-	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_msgsnd);
-		break;
-	} 
 }
 
 void print_ncpus(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%7s", "Ncpus");
+		printf("%-7s", "Ncpus");
 		break;
 	case UNDERSCORE:
-		printf("%7s", "-------");
+		printf("%-7s", "-------");
 		break;
 	case JOB:
-		printf("%7d", job->ncpus);
+		printf("%-7u", job->alloc_cpus);
 		break;
 	case JOBSTEP:
-		printf("%7d", step->ncpus);
-		break;
-	} 
-}
-
-void print_nivcsw(type_t type, void *object)
-{ 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%9s", "Nivcsw");
-		break;
-	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-7u", step->ncpus);
 		break;
-	case JOB:
-		printf("%9ld", job->rusage.ru_nivcsw);
-		break;
-	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_nivcsw);
+	default:
+		printf("%-7s", "n/a");
 		break;
 	} 
 }
 
 void print_nodes(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	
 	switch(type) {
 	case HEADLINE:
 		printf("%-30s", "Nodes");
@@ -527,121 +392,69 @@ void print_nodes(type_t type, void *object)
 	case JOB:
 		printf("%-30s", job->nodes);
 		break;
-	case JOBSTEP:
-		printf("%-30s", "                              ");
-		break;
-	} 
-}
-
-void print_nsignals(type_t type, void *object)
-{ 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%9s", "Nsignals");
-		break;
-	case UNDERSCORE:
-		printf("%9s", "---------");
-		break;
-	case JOB:
-		printf("%9ld", job->rusage.ru_nsignals);
+	case JOBCOMP:
+		printf("%-30s", jobcomp->nodelist);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_nsignals);
-		break;
-	} 
-}
-
-void print_nswap(type_t type, void *object)
-{ 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%8s", "Nswap");
-		break;
-	case UNDERSCORE:
-		printf("%8s", "------");
-		break;
-	case JOB:
-		printf("%8ld", job->rusage.ru_nswap);
+		printf("%-30s", step->nodes);
 		break;
-	case JOBSTEP:
-		printf("%8ld", step->rusage.ru_nswap);
+	default:
+		printf("%-30s", "n/a");
 		break;
 	} 
 }
 
-void print_ntasks(type_t type, void *object)
+void print_nnodes(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	char temp[FORMAT_STRING_SIZE];
 
 	switch(type) {
 	case HEADLINE:
-		printf("%7s", "Ntasks");
+		printf("%-8s", "Node Cnt");
 		break;
 	case UNDERSCORE:
-		printf("%7s", "-------");
+		printf("%-8s", "--------");
 		break;
-	case JOB:
-		printf("%7d", job->ntasks);
+	case JOBCOMP:
+		convert_num_unit((float)jobcomp->node_cnt, temp, 
+				 sizeof(temp), UNIT_NONE);
+		printf("%-8s", temp);
 		break;
-	case JOBSTEP:
-		printf("%7d", step->ntasks);
+	default:
+		printf("%-8s", "n/a");
 		break;
 	} 
 }
 
-void print_nvcsw(type_t type, void *object)
+void print_ntasks(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%9s", "Nvcsw");
+		printf("%-7s", "Ntasks");
 		break;
 	case UNDERSCORE:
-		printf("%9s", "---------");
+		printf("%-7s", "-------");
 		break;
 	case JOB:
-		printf("%9ld", job->rusage.ru_nvcsw);
+		printf("%-7u", job->alloc_cpus);
 		break;
 	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_nvcsw);
-		break;
-	} 
-}
-
-void print_outblocks(type_t type, void *object)
-{ 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%9s", "Outblocks");
+		printf("%-7u", step->ncpus);
 		break;
-	case UNDERSCORE:
-		printf("%9s", "---------");
-		break;
-	case JOB:
-		printf("%9ld", job->rusage.ru_oublock);
-		break;
-	case JOBSTEP:
-		printf("%9ld", step->rusage.ru_oublock);
+	default:
+		printf("%-7s", "n/a");
 		break;
 	} 
 }
 
 void print_partition(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -651,30 +464,37 @@ void print_partition(type_t type, void *object)
 		printf("%-10s", "----------");
 		break;
 	case JOB:
-		if(!job->header.partition)
+		if(!job->partition)
 			printf("%-10s", "unknown");			     
-		else if(strlen(job->header.partition)<11)
-			printf("%-10s", job->header.partition);
+		else if(strlen(job->partition)<11)
+			printf("%-10s", job->partition);
 		else
-			printf("%-7.7s...", job->header.partition);
+			printf("%-7.7s...", job->partition);
 		
 		break;
-	case JOBSTEP:
-		if(!step->header.partition)
+	case JOBCOMP:
+		if(!jobcomp->partition)
 			printf("%-10s", "unknown");			     
-		else if(strlen(step->header.partition)<11)
-			printf("%-10s", step->header.partition);
+		else if(strlen(jobcomp->partition)<11)
+			printf("%-10s", jobcomp->partition);
 		else
-			printf("%-7.7s...", step->header.partition);
-	
+			printf("%-7.7s...", jobcomp->partition);
+		
+		break;
+	case JOBSTEP:
+		printf("%-10s", " ");
+		break;
+	default:
+		printf("%-10s", "n/a");
 		break;
 	} 
 }
 
+#ifdef HAVE_BG
 void print_blockid(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -684,44 +504,51 @@ void print_blockid(type_t type, void *object)
 		printf("%-16s", "----------------");
 		break;
 	case JOB:
-		if(!job->header.blockid)
+		if(!job->blockid)
 			printf("%-16s", "unknown");			     
-		else if(strlen(job->header.blockid)<17)
-			printf("%-16s", job->header.blockid);
+		else if(strlen(job->blockid)<17)
+			printf("%-16s", job->blockid);
 		else
-			printf("%-13.13s...", job->header.blockid);
+			printf("%-13.13s...", job->blockid);
 		
 		break;
-	case JOBSTEP:
-		if(!step->header.blockid)
+	case JOBCOMP:
+		if(!jobcomp->blockid)
 			printf("%-16s", "unknown");			     
-		else if(strlen(step->header.blockid)<17)
-			printf("%-16s", step->header.blockid);
+		else if(strlen(jobcomp->blockid)<17)
+			printf("%-16s", jobcomp->blockid);
 		else
-			printf("%-13.13s...", step->header.blockid);
-	
+			printf("%-13.13s...", jobcomp->blockid);
+		
+		break;
+	case JOBSTEP:
+		printf("%-16s", " ");
+		break;
+	default:
+		printf("%-16s", "n/a");
 		break;
 	} 
 }
+#endif
 
 void print_pages(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
-	char buf3[50];
+	char buf3[FORMAT_STRING_SIZE];
 	sacct_t sacct;
 	char *nodes = NULL;
 	uint32_t pos;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-50s", "MaxPages/Node:Task - Ave");
+		printf("%-34s", "MaxPages/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
-		printf("%-50s", "----------------------------------");
+		printf("%-34s", "----------------------------------");
 		break;
 	case JOB:
 		sacct = job->sacct;
@@ -742,7 +569,7 @@ void print_pages(type_t type, void *object)
 				 sacct.max_pages_id.taskid, 
 				 buf2);
 		}
-		printf("%-50s", outbuf);
+		printf("%-34s", outbuf);
 		break;
 	case JOBSTEP:
 		sacct = step->sacct;
@@ -758,29 +585,32 @@ void print_pages(type_t type, void *object)
 			 buf3,
 			 sacct.max_pages_id.taskid, 
 			 buf2);
-		printf("%-50s", outbuf);
+		printf("%-34s", outbuf);
+		break;
+	default:
+		printf("%-34s", "n/a");
 		break;
 	} 
 }
 
 void print_rss(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
-	char buf3[50];
+	char buf3[FORMAT_STRING_SIZE];
 	sacct_t sacct;
 	char *nodes = NULL;
 	uint32_t pos;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-50s", "MaxRSS/Node:Task - Ave");
+		printf("%-34s", "MaxRSS/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
-		printf("%-50s", "--------------------------------");
+		printf("%-34s", "----------------------------------");
 		break;
 	case JOB:
 		sacct = job->sacct;
@@ -801,7 +631,7 @@ void print_rss(type_t type, void *object)
 				 sacct.max_rss_id.taskid, 
 				 buf2);
 		}
-		printf("%-50s", outbuf);
+		printf("%-34s", outbuf);
 		break;
 	case JOBSTEP:
 		sacct = step->sacct;
@@ -817,48 +647,58 @@ void print_rss(type_t type, void *object)
 			 buf3, 
 			 sacct.max_rss_id.taskid, 
 			 buf2);
-		printf("%-50s", outbuf);
+		printf("%-34s", outbuf);
+		break;
+	default:
+		printf("%-34s", "n/a");
 		break;
 	} 
 }
 
-void print_status(type_t type, void *object)
+void print_state(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-20s", "Status");
+		printf("%-20s", "State");
 		break;
 	case UNDERSCORE:
 		printf("%-20s", "--------------------");
 		break;
 	case JOB:
-		if ( job->status == JOB_CANCELLED) {
+		if ( job->state == JOB_CANCELLED) {
 			printf ("%-10s by %6d",
-				decode_status_int(job->status), job->requid);
+				job_state_string(job->state), job->requid);
 		}
 		else {
-			printf("%-20s", decode_status_int(job->status));
+			printf("%-20s", job_state_string(job->state));
 		}
 		break;
+	case JOBCOMP:
+		printf("%-20s", jobcomp->state);
+		break;
 	case JOBSTEP:
-		if ( step->status == JOB_CANCELLED) {
+		if ( step->state == JOB_CANCELLED) {
 			printf ("%-10s by %6d",
-				decode_status_int(step->status), step->requid);
+				job_state_string(step->state), step->requid);
 		}
 		else {
-			printf("%-20s", decode_status_int(step->status));
+			printf("%-20s", job_state_string(step->state));
 		}
 		break;
+	default:
+		printf("%-20s", "n/a");
+		break;
 	} 
 }
 
 void print_submit(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char time_str[32];
 		
 	switch(type) {
@@ -869,148 +709,183 @@ void print_submit(type_t type, void *object)
 		printf("%-14s", "--------------");
 		break;
 	case JOB:
-		slurm_make_time_str(&job->header.job_submit, 
+		slurm_make_time_str(&job->submit, 
 				    time_str, 
 				    sizeof(time_str));
 		printf("%-14s", time_str);
 		break;
 	case JOBSTEP:
-		slurm_make_time_str(&step->header.timestamp, 
+		slurm_make_time_str(&step->start, 
 				    time_str, 
 				    sizeof(time_str));
 		printf("%-14s", time_str);
 		break;
+	default:
+		printf("%-14s", "n/a");
+		break;
 	} 
 }
 
 void print_start(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char time_str[32];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%-14s", "Start Time");
+		printf("%-19s", "Start Time");
 		break;
 	case UNDERSCORE:
-		printf("%-14s", "--------------");
+		printf("%-19s", "--------------------");
 		break;
 	case JOB:
-		if(params.opt_raw) {
-			printf("%14d", (int)job->header.timestamp);
-			break;
-		}
-		slurm_make_time_str(&job->header.timestamp, 
+		slurm_make_time_str(&job->start, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	case JOBCOMP:
+		printf("%-19s", jobcomp->start_time);
 		break;
 	case JOBSTEP:
-		if(params.opt_raw) {
-			printf("%14d", (int)step->header.timestamp);
-			break;
-		}
-		slurm_make_time_str(&step->header.timestamp, 
+		slurm_make_time_str(&step->start, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	default:
+		printf("%-19s", "n/a");
+		break;
+	} 
+}
+
+void print_timelimit(type_t type, void *object)
+{ 
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	
+	switch(type) {
+	case HEADLINE:
+		printf("%-10s", "Time Limit");
+		break;
+	case UNDERSCORE:
+		printf("%-10s", "----------");
+		break;
+	case JOBCOMP:
+		printf("%-10s", jobcomp->timelimit);
+		break;
+	default:
+		printf("%-10s", "n/a");
 		break;
 	} 
 }
 
 void print_end(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char time_str[32];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%-14s", "End Time");
+		printf("%-19s", "End Time");
 		break;
 	case UNDERSCORE:
-		printf("%-14s", "--------------");
+		printf("%-19s", "--------------------");
 		break;
 	case JOB:
-		if(params.opt_raw) {
-			printf("%14d", (int)job->end);
-			break;
-		}
 		slurm_make_time_str(&job->end, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	case JOBCOMP:
+		printf("%-19s", jobcomp->end_time);
 		break;
 	case JOBSTEP:
-		if(params.opt_raw) {
-			printf("%14d", (int)step->end);
-			break;
-		}
 		slurm_make_time_str(&step->end, 
 				    time_str, 
 				    sizeof(time_str));
-		printf("%-14s", time_str);
+		printf("%-19s", time_str);
+		break;
+	default:
+		printf("%-19s", "n/a");
 		break;
 	} 
 }
 
 void print_systemcpu(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "SystemCpu");
+		printf("%-15s", "SystemCpu");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
-		_elapsed_time(job->rusage.ru_stime.tv_sec,
-			      job->rusage.ru_stime.tv_usec, str);
-		printf("%15s", str);
+		_elapsed_time(job->sys_cpu_sec,
+			      job->sys_cpu_usec, str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
-		_elapsed_time(step->rusage.ru_stime.tv_sec,
-			      step->rusage.ru_stime.tv_usec, str);
-		printf("%15s", str);
+		_elapsed_time(step->sys_cpu_sec,
+			      step->sys_cpu_usec, str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
-
 }
 
 void print_uid(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	int32_t uid = -1;
+	struct passwd *pw = NULL;
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%5s", "Uid");
+		printf("%-5s", "Uid");
 		break;
 	case UNDERSCORE:
-		printf("%5s", "-----");
+		printf("%-5s", "-----");
 		break;
 	case JOB:
-		printf("%5d", job->header.uid);
+		if(job->user) {
+			if ((pw=getpwnam(job->user)))
+				uid = pw->pw_uid;
+		} else 
+			uid = job->uid;
+		break;
+	case JOBCOMP:
+		printf("%-5u", jobcomp->uid);
 		break;
 	case JOBSTEP:
-		printf("%5d", step->header.uid);
+		printf("%-5s", " ");
 		break;
 	} 
+
+	if(uid != -1) 
+		printf("%-5d", uid);
 }
 
 void print_user(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
 	int uid = -1;
 	char	*tmp="(unknown)";
-	struct	passwd *pw = NULL;
-	
+	struct	passwd *pw = NULL;		 
+
 	switch(type) {
 	case HEADLINE:
 		printf("%-9s", "User");
@@ -1019,10 +894,19 @@ void print_user(type_t type, void *object)
 		printf("%-9s", "---------");
 		break;
 	case JOB:
-		uid = job->header.uid;
+		if(job->user) 
+			printf("%-9s", job->user);
+		else
+			uid = job->uid;
+		break;
+	case JOBCOMP:
+		printf("%-9s", jobcomp->uid_name);
 		break;
 	case JOBSTEP:
-		uid = step->header.uid;
+		printf("%-9s", " ");
+		break;
+	default:
+		printf("%-9s", "n/a");
 		break;
 	} 
 	if(uid != -1) {
@@ -1034,26 +918,29 @@ void print_user(type_t type, void *object)
 
 void print_usercpu(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char str[FORMAT_STRING_SIZE];
 	
 	switch(type) {
 	case HEADLINE:
-		printf("%15s", "UserCpu");
+		printf("%-15s", "UserCpu");
 		break;
 	case UNDERSCORE:
-		printf("%15s", "---------------");
+		printf("%-15s", "---------------");
 		break;
 	case JOB:
-		_elapsed_time(job->rusage.ru_utime.tv_sec,
-			      job->rusage.ru_utime.tv_usec, str);
-		printf("%15s", str);
+		_elapsed_time(job->user_cpu_sec,
+			      job->user_cpu_usec, str);
+		printf("%-15s", str);
 		break;
 	case JOBSTEP:
-		_elapsed_time(step->rusage.ru_utime.tv_sec,
-			      step->rusage.ru_utime.tv_usec, str);
-		printf("%15s", str);
+		_elapsed_time(step->user_cpu_sec,
+			      step->user_cpu_usec, str);
+		printf("%-15s", str);
+		break;
+	default:
+		printf("%-15s", "n/a");
 		break;
 	} 
 
@@ -1061,22 +948,22 @@ void print_usercpu(type_t type, void *object)
 
 void print_vsize(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
-	char buf3[50];
+	char buf3[FORMAT_STRING_SIZE];
 	sacct_t sacct;
 	char *nodes = NULL;
 	uint32_t pos;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-50s", "MaxVSIZE/Node:Task - Ave");
+		printf("%-34s", "MaxVSIZE/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
-		printf("%-50s", "----------------------------------");
+		printf("%-34s", "----------------------------------");
 		break;
 	case JOB:
 		sacct = job->sacct;
@@ -1096,7 +983,7 @@ void print_vsize(type_t type, void *object)
 				 sacct.max_vsize_id.taskid, 
 				 buf2);
 		}
-		printf("%-50s", outbuf);
+		printf("%-34s", outbuf);
 		break;
 	case JOBSTEP:
 		sacct = step->sacct;
@@ -1112,69 +999,32 @@ void print_vsize(type_t type, void *object)
 			 buf3, 
 			 sacct.max_vsize_id.taskid, 
 			 buf2);
-		printf("%-50s", outbuf);
-		break;
-	} 
-}
-
-void print_vsize_short(type_t type, void *object)
-{ 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
-	char outbuf[FORMAT_STRING_SIZE];
-	char buf1[FORMAT_STRING_SIZE];
-	sacct_t sacct;
-
-	switch(type) {
-	case HEADLINE:
-		printf("%10s", "MaxVSIZE");
-		break;
-	case UNDERSCORE:
-		printf("%10s", "----------");
+		printf("%-34s", outbuf);
 		break;
-	case JOB:
-		sacct = job->sacct;
-		if(params.opt_raw) {
-			printf("%10d", sacct.max_vsize);
-			break;
-		}
-		convert_num_unit((float)sacct.max_vsize, 
-				 buf1, sizeof(buf1),UNIT_NONE);
-		snprintf(outbuf, FORMAT_STRING_SIZE, "%s", buf1);
-		printf("%10s", outbuf);
-		break;
-	case JOBSTEP:
-		sacct = step->sacct;
-		if(params.opt_raw) {
-			printf("%10d", sacct.max_vsize);
-			break;
-		}
-		convert_num_unit((float)sacct.max_vsize, 
-				 buf1, sizeof(buf1),UNIT_NONE);
-		snprintf(outbuf, FORMAT_STRING_SIZE, "%s", buf1);
-		printf("%10s", outbuf);
+	default:
+		printf("%-34s", "n/a");
 		break;
 	} 
 }
 
 void print_cputime(type_t type, void *object)
 { 
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
 	char outbuf[FORMAT_STRING_SIZE];
 	char buf1[FORMAT_STRING_SIZE];
 	char buf2[FORMAT_STRING_SIZE];
-	char buf3[50];
+	char buf3[FORMAT_STRING_SIZE];
 	sacct_t sacct;
 	char *nodes = NULL;
 	uint32_t pos;
 
 	switch(type) {
 	case HEADLINE:
-		printf("%-50s", "MinCPUtime/Node:Task - Ave");
+		printf("%-37s", "MinCPUtime/Node:Task - Ave");
 		break;
 	case UNDERSCORE:
-		printf("%-50s", "------------------------------------");
+		printf("%-37s", "-------------------------------------");
 		break;
 	case JOB:
 		sacct = job->sacct;
@@ -1194,7 +1044,7 @@ void print_cputime(type_t type, void *object)
 				 sacct.min_cpu_id.taskid, 
 				 buf2);
 		}
-		printf("%-50s", outbuf);
+		printf("%-37s", outbuf);
 		break;
 	case JOBSTEP:
 		sacct = step->sacct;
@@ -1209,15 +1059,17 @@ void print_cputime(type_t type, void *object)
 			 buf3, 
 			 sacct.min_cpu_id.taskid, 
 			 buf2);
-		printf("%-50s", outbuf);
+		printf("%-37s", outbuf);
+		break;
+	default:
+		printf("%-37s", "n/a");
 		break;
 	} 
 }
 
 void print_account(type_t type, void *object)
 {
-	job_rec_t *job = (job_rec_t *)object;
-	step_rec_t *step = (step_rec_t *)object;
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
 
 	switch(type) {
 	case HEADLINE:
@@ -1235,13 +1087,129 @@ void print_account(type_t type, void *object)
 			printf("%-13.13s...", job->account);
 		break;
 	case JOBSTEP:
-		if(!step->account)
-			printf("%-16s", "unknown");
-		else if(strlen(step->account)<17)
-			printf("%-16s", step->account);
-		else
-			printf("%-13.13s...", step->account);
+		printf("%-16s", " ");
+	default:
+		printf("%-16s", "n/a");
+		break;
+		break;
+	}
+}
+
+
+#ifdef HAVE_BG
+void print_connection(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-10s", "Connection");
+		break;
+	case UNDERSCORE:
+		printf("%-10s", "----------");
+		break;
+	case JOBCOMP:
+		printf("%-10s", job->connection);
+		break;
+	default:
+		printf("%-10s", "n/a");
+		break;
+	}
+}
+void print_geo(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-8s", "Geometry");
+		break;
+	case UNDERSCORE:
+		printf("%-8s", "--------");
+		break;
+	case JOBCOMP:
+		printf("%-8s", job->geo);
+		break;
+	default:
+		printf("%-8s", "n/a");
+		break;
+	}
+}
+void print_max_procs(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-9s", "Max Procs");
+		break;
+	case UNDERSCORE:
+		printf("%-9s", "---------");
+		break;
+	case JOBCOMP:
+		printf("%-9d", job->max_procs);
+		break;
+	default:
+		printf("%-9s", "n/a");
+		break;
+	}
+}
+void print_reboot(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-6s", "Reboot");
+		break;
+	case UNDERSCORE:
+		printf("%-6s", "------");
+		break;
+	case JOBCOMP:
+		printf("%-6s", job->reboot);
+		break;
+	default:
+		printf("%-6s", "n/a");
+		break;
+	}
+}
+void print_rotate(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-6s", "Rotate");
+		break;
+	case UNDERSCORE:
+		printf("%-6s", "------");
+		break;
+	case JOBCOMP:
+		printf("%-6s", job->rotate);
+		break;
+	default:
+		printf("%-6s", "n/a");
+		break;
+	}
+}
+void print_bg_start_point(type_t type, void *object)
+{
+	jobcomp_job_rec_t *job = (jobcomp_job_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-14s", "BG Start Point");
+		break;
+	case UNDERSCORE:
+		printf("%-14s", "--------------");
+		break;
+	case JOBCOMP:
+		printf("%-14s", job->bg_start_point);
+		break;
+	default:
+		printf("%-14s", "n/a");
 		break;
 	}
 }
+#endif
 
diff --git a/src/sacct/process.c b/src/sacct/process.c
index d09346eff49cef51e194727f1002d7db800dd70e..52808e35ecb4264e54eaf4808385dc28f8f91a91 100644
--- a/src/sacct/process.c
+++ b/src/sacct/process.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -39,503 +39,6 @@
 
 #include "sacct.h"
 
-job_rec_t *_find_job_record(acct_header_t header, int type);
-int _remove_job_record(uint32_t jobnum);
-step_rec_t *_find_step_record(job_rec_t *job, long jobstep);
-job_rec_t *_init_job_rec(acct_header_t header);
-step_rec_t *_init_step_rec(acct_header_t header);
-int _parse_line(char *f[], void **data, int len);
-
-job_rec_t *_find_job_record(acct_header_t header, int type)
-{
-	job_rec_t *job = NULL;
-	ListIterator itr = list_iterator_create(jobs);
-
-	while((job = (job_rec_t *)list_next(itr)) != NULL) {
-		if (job->header.jobnum == header.jobnum) {
-			if(job->header.job_submit == 0 && type == JOB_START) {
-				list_remove(itr);
-				destroy_job(job);
-				job = NULL;
-				break;
-			}
-		
-			if(job->header.job_submit == BATCH_JOB_TIMESTAMP) {
-				job->header.job_submit = header.job_submit;
-				break;
-			}
-			
-			if(job->header.job_submit == header.job_submit)
-				break;
-			else {
-				/* If we're looking for a later
-				 * record with this job number, we
-				 * know that this one is an older,
-				 * duplicate record.
-				 *   We assume that the newer record
-				 * will be created if it doesn't
-				 * already exist. */
-				job->jobnum_superseded = 1;
-			}
-		}
-	}
-	list_iterator_destroy(itr);
-	return job;
-}
-
-int _remove_job_record(uint32_t jobnum)
-{
-	job_rec_t *job = NULL;
-	int rc = SLURM_ERROR;
-	ListIterator itr = list_iterator_create(jobs);
-
-	while((job = (job_rec_t *)list_next(itr)) != NULL) {
-		if (job->header.jobnum == jobnum) {
-			list_remove(itr);
-			destroy_job(job);
-			rc = SLURM_SUCCESS;
-		}
-	}
-	list_iterator_destroy(itr);
-	return rc;
-}
-
-step_rec_t *_find_step_record(job_rec_t *job, long stepnum)
-{
-	step_rec_t *step = NULL;
-	ListIterator itr = NULL;
-
-	if(!list_count(job->steps))
-		return step;
-	
-	itr = list_iterator_create(job->steps);
-	while((step = (step_rec_t *)list_next(itr)) != NULL) {
-		if (step->stepnum == stepnum)
-			break;
-	}
-	list_iterator_destroy(itr);
-	return step;
-}
-
-job_rec_t *_init_job_rec(acct_header_t header)
-{
-	job_rec_t *job = xmalloc(sizeof(job_rec_t));
-	memcpy(&job->header, &header, sizeof(acct_header_t));
-	memset(&job->rusage, 0, sizeof(struct rusage));
-	memset(&job->sacct, 0, sizeof(sacct_t));
-	job->sacct.min_cpu = (float)NO_VAL;
-	job->job_start_seen = 0;
-	job->job_step_seen = 0;
-	job->job_terminated_seen = 0;
-	job->jobnum_superseded = 0;
-	job->jobname = xstrdup("(unknown)");
-	job->status = JOB_PENDING;
-	job->nodes = NULL;
-	job->jobname = NULL;
-	job->exitcode = 0;
-	job->priority = 0;
-	job->ntasks = 0;
-	job->ncpus = 0;
-	job->elapsed = 0;
-	job->tot_cpu_sec = 0;
-	job->tot_cpu_usec = 0;
-	job->steps = list_create(destroy_step);
-	job->nodes = NULL;
-	job->track_steps = 0;
-	job->account = NULL;
-	job->requid = -1;
-
-      	return job;
-}
-
-step_rec_t *_init_step_rec(acct_header_t header)
-{
-	step_rec_t *step = xmalloc(sizeof(job_rec_t));
-	memcpy(&step->header, &header, sizeof(acct_header_t));
-	memset(&step->rusage, 0, sizeof(struct rusage));
-	memset(&step->sacct, 0, sizeof(sacct_t));
-	step->stepnum = (uint32_t)NO_VAL;
-	step->nodes = NULL;
-	step->stepname = NULL;
-	step->status = NO_VAL;
-	step->exitcode = NO_VAL;
-	step->ntasks = (uint32_t)NO_VAL;
-	step->ncpus = (uint32_t)NO_VAL;
-	step->elapsed = (uint32_t)NO_VAL;
-	step->tot_cpu_sec = (uint32_t)NO_VAL;
-	step->tot_cpu_usec = (uint32_t)NO_VAL;
-	step->account = NULL;
-	step->requid = -1;
-
-	return step;
-}
-
-int _parse_header(char *f[], acct_header_t *header)
-{
-	header->jobnum = atoi(f[F_JOB]);
-	header->partition = xstrdup(f[F_PARTITION]);
-	header->job_submit = atoi(f[F_JOB_SUBMIT]);
-	header->timestamp = atoi(f[F_TIMESTAMP]);
-	header->uid = atoi(f[F_UID]);
-	header->gid = atoi(f[F_GID]);
-	header->blockid = xstrdup(f[F_BLOCKID]);
-	return SLURM_SUCCESS;
-}
-
-int _parse_line(char *f[], void **data, int len)
-{
-	int i = atoi(f[F_RECTYPE]);
-	job_rec_t **job = (job_rec_t **)data;
-	step_rec_t **step = (step_rec_t **)data;
-	acct_header_t header;
-	_parse_header(f, &header);
-		
-	switch(i) {
-	case JOB_START:
-		*job = _init_job_rec(header);
-		(*job)->jobname = xstrdup(f[F_JOBNAME]);
-		(*job)->track_steps = atoi(f[F_TRACK_STEPS]);
-		(*job)->priority = atoi(f[F_PRIORITY]);
-		(*job)->ncpus = atoi(f[F_NCPUS]);
-		(*job)->nodes = xstrdup(f[F_NODES]);
-		for (i=0; (*job)->nodes[i]; i++) { /* discard trailing <CR> */
-			if (isspace((*job)->nodes[i]))
-				(*job)->nodes[i] = '\0';
-		}
-		if (!strcmp((*job)->nodes, "(null)")) {
-			xfree((*job)->nodes);
-			(*job)->nodes = xstrdup("(unknown)");
-		}
-		if (len > F_JOB_ACCOUNT) {
-			(*job)->account = xstrdup(f[F_JOB_ACCOUNT]);
-			for (i=0; (*job)->account[i]; i++) {
-				/* discard trailing <CR> */
-				if (isspace((*job)->account[i]))
-					(*job)->account[i] = '\0';
-			}
-		}
-		break;
-	case JOB_STEP:
-		*step = _init_step_rec(header);
-		(*step)->stepnum = atoi(f[F_JOBSTEP]);
-		(*step)->status = atoi(f[F_STATUS]);
-		(*step)->exitcode = atoi(f[F_EXITCODE]);
-		(*step)->ntasks = atoi(f[F_NTASKS]);
-		(*step)->ncpus = atoi(f[F_STEPNCPUS]);
-		(*step)->elapsed = atoi(f[F_ELAPSED]);
-		(*step)->tot_cpu_sec = atoi(f[F_CPU_SEC]);
-		(*step)->tot_cpu_usec = atoi(f[F_CPU_USEC]);
-		(*step)->rusage.ru_utime.tv_sec = atoi(f[F_USER_SEC]);
-		(*step)->rusage.ru_utime.tv_usec = atoi(f[F_USER_USEC]);
-		(*step)->rusage.ru_stime.tv_sec = atoi(f[F_SYS_SEC]);
-		(*step)->rusage.ru_stime.tv_usec = atoi(f[F_SYS_USEC]);
-		(*step)->rusage.ru_maxrss = atoi(f[F_RSS]);
-		(*step)->rusage.ru_ixrss = atoi(f[F_IXRSS]);
-		(*step)->rusage.ru_idrss = atoi(f[F_IDRSS]);
-		(*step)->rusage.ru_isrss = atoi(f[F_ISRSS]);
-		(*step)->rusage.ru_minflt = atoi(f[F_MINFLT]);
-		(*step)->rusage.ru_majflt = atoi(f[F_MAJFLT]);
-		(*step)->rusage.ru_nswap = atoi(f[F_NSWAP]);
-		(*step)->rusage.ru_inblock = atoi(f[F_INBLOCKS]);
-		(*step)->rusage.ru_oublock = atoi(f[F_OUBLOCKS]);
-		(*step)->rusage.ru_msgsnd = atoi(f[F_MSGSND]);
-		(*step)->rusage.ru_msgrcv = atoi(f[F_MSGRCV]);
-		(*step)->rusage.ru_nsignals = atoi(f[F_NSIGNALS]);
-		(*step)->rusage.ru_nvcsw = atoi(f[F_NVCSW]);
-		(*step)->rusage.ru_nivcsw = atoi(f[F_NIVCSW]);
-		(*step)->sacct.max_vsize = atoi(f[F_MAX_VSIZE]) * 1024;
-		if(len > F_STEPNODES) {
-			(*step)->sacct.max_vsize_id.taskid = 
-				atoi(f[F_MAX_VSIZE_TASK]);
-			(*step)->sacct.ave_vsize = atof(f[F_AVE_VSIZE]) * 1024;
-			(*step)->sacct.max_rss = atoi(f[F_MAX_RSS]) * 1024;
-			(*step)->sacct.max_rss_id.taskid = 
-				atoi(f[F_MAX_RSS_TASK]);
-			(*step)->sacct.ave_rss = atof(f[F_AVE_RSS]) * 1024;
-			(*step)->sacct.max_pages = atoi(f[F_MAX_PAGES]);
-			(*step)->sacct.max_pages_id.taskid = 
-				atoi(f[F_MAX_PAGES_TASK]);
-			(*step)->sacct.ave_pages = atof(f[F_AVE_PAGES]);
-			(*step)->sacct.min_cpu = atof(f[F_MIN_CPU]);
-			(*step)->sacct.min_cpu_id.taskid = 
-				atoi(f[F_MIN_CPU_TASK]);
-			(*step)->sacct.ave_cpu = atof(f[F_AVE_CPU]);
-			(*step)->stepname = xstrdup(f[F_STEPNAME]);
-			(*step)->nodes = xstrdup(f[F_STEPNODES]);
-		} else {
-			(*step)->sacct.max_vsize_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_vsize = (float)NO_VAL;
-			(*step)->sacct.max_rss = (uint32_t)NO_VAL;
-			(*step)->sacct.max_rss_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_rss = (float)NO_VAL;
-			(*step)->sacct.max_pages = (uint32_t)NO_VAL;
-			(*step)->sacct.max_pages_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_pages = (float)NO_VAL;
-			(*step)->sacct.min_cpu = (uint32_t)NO_VAL;
-			(*step)->sacct.min_cpu_id.taskid = (uint16_t)NO_VAL;
-			(*step)->sacct.ave_cpu =  (float)NO_VAL;
-			(*step)->stepname = NULL;
-			(*step)->nodes = NULL;
-		}
-		if(len > F_MIN_CPU_NODE) {
-			(*step)->sacct.max_vsize_id.nodeid = 
-				atoi(f[F_MAX_VSIZE_NODE]);
-			(*step)->sacct.max_rss_id.nodeid = 
-				atoi(f[F_MAX_RSS_NODE]);
-			(*step)->sacct.max_pages_id.nodeid = 
-				atoi(f[F_MAX_PAGES_NODE]);
-			(*step)->sacct.min_cpu_id.nodeid = 
-				atoi(f[F_MIN_CPU_NODE]);
-		} else {
-			(*step)->sacct.max_vsize_id.nodeid = 
-				(uint32_t)NO_VAL;
-			(*step)->sacct.max_rss_id.nodeid = 
-				(uint32_t)NO_VAL;
-			(*step)->sacct.max_pages_id.nodeid = 
-				(uint32_t)NO_VAL;
-			(*step)->sacct.min_cpu_id.nodeid = 
-				(uint32_t)NO_VAL;
-		}
-		if(len > F_STEP_ACCOUNT)
-			(*step)->account = xstrdup(f[F_STEP_ACCOUNT]);
-		if(len > F_STEP_REQUID)
-			(*step)->requid = atoi(f[F_STEP_REQUID]);
-		break;
-	case JOB_SUSPEND:
-	case JOB_TERMINATED:
-		*job = _init_job_rec(header);
-		(*job)->elapsed = atoi(f[F_TOT_ELAPSED]);
-		(*job)->status = atoi(f[F_STATUS]);		
-		if(len > F_JOB_REQUID) 
-			(*job)->requid = atoi(f[F_JOB_REQUID]);
-		break;
-	default:
-		printf("UNKOWN TYPE %d",i);
-		break;
-	}
-	return SLURM_SUCCESS;
-}
-
-void process_start(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	job_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-	job = _find_job_record(temp->header, JOB_START);
-	if (job) {	/* Hmmm... that's odd */
-		printf("job->header.job_submit = %d", (int)job->header.job_submit);
-		if(job->header.job_submit == 0)
-			_remove_job_record(job->header.jobnum);
-		else {
-			fprintf(stderr,
-				"Conflicting JOB_START for job %u at"
-				" line %d -- ignoring it\n",
-				job->header.jobnum, lc);
-			input_error++;
-			destroy_job(temp);
-			return;
-		}
-	}
-	
-	job = temp;
-	job->show_full = show_full;
-	list_append(jobs, job);
-	job->job_start_seen = 1;
-	
-}
-
-void process_step(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	
-	step_rec_t *step = NULL;
-	step_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-
-	job = _find_job_record(temp->header, JOB_STEP);
-	
-	if (temp->stepnum == -2) {
-		destroy_step(temp);
-		return;
-	}
-	if (!job) {	/* fake it for now */
-		job = _init_job_rec(temp->header);
-		if (params.opt_verbose > 1) 
-			fprintf(stderr, 
-				"Note: JOB_STEP record %u.%u preceded "
-				"JOB_START record at line %d\n",
-				temp->header.jobnum, temp->stepnum, lc);
-	}
-	job->show_full = show_full;
-	
-	if ((step = _find_step_record(job, temp->stepnum))) {
-		
-		if (temp->status == JOB_RUNNING) {
-			destroy_step(temp);
-			return;/* if "R" record preceded by F or CD; unusual */
-		}
-		if (step->status != JOB_RUNNING) { /* if not JOB_RUNNING */
-			fprintf(stderr,
-				"Conflicting JOB_STEP record for "
-				"jobstep %u.%u at line %d "
-				"-- ignoring it\n",
-				step->header.jobnum, 
-				step->stepnum, lc);
-			input_error++;
-			
-			destroy_step(temp);
-			return;
-		}
-		step->status = temp->status;
-		step->exitcode = temp->exitcode;
-		step->ntasks = temp->ntasks;
-		step->ncpus = temp->ncpus;
-		step->elapsed = temp->elapsed;
-		step->tot_cpu_sec = temp->tot_cpu_sec;
-		step->tot_cpu_usec = temp->tot_cpu_usec;
-		job->requid = temp->requid;
-		step->requid = temp->requid;
-		memcpy(&step->rusage, &temp->rusage, sizeof(struct rusage));
-		memcpy(&step->sacct, &temp->sacct, sizeof(sacct_t));
-		xfree(step->stepname);
-		step->stepname = xstrdup(temp->stepname);
-		step->end = temp->header.timestamp;
-		destroy_step(temp);
-		goto got_step;
-	}
-	step = temp;
-	temp = NULL;
-	list_append(job->steps, step);
-	if(job->header.timestamp == 0)
-		job->header.timestamp = step->header.timestamp;
-	job->job_step_seen = 1;
-	job->ntasks += step->ntasks;
-	if(!job->nodes || !strcmp(job->nodes, "(unknown)")) {
-		xfree(job->nodes);
-		job->nodes = xstrdup(step->nodes);
-	}
-	
-got_step:
-	
-	if ( job->exitcode == 0 )
-		job->exitcode = step->exitcode;
-	
-	if (job->job_terminated_seen == 0) {	/* If the job is still running,
-						   this is the most recent
-						   status */
-		job->status = JOB_RUNNING;
-		job->elapsed = step->header.timestamp - job->header.timestamp;
-	}
-	/* now aggregate the aggregatable */
-	job->ncpus = MAX(job->ncpus, step->ncpus);
-	if(step->status < JOB_COMPLETE)
-		return;
-	job->tot_cpu_sec += step->tot_cpu_sec;
-	job->tot_cpu_usec += step->tot_cpu_usec;
-	job->rusage.ru_utime.tv_sec += step->rusage.ru_utime.tv_sec;
-	job->rusage.ru_utime.tv_usec += step->rusage.ru_utime.tv_usec;
-	job->rusage.ru_stime.tv_sec += step->rusage.ru_stime.tv_sec;
-	job->rusage.ru_stime.tv_usec += step->rusage.ru_stime.tv_usec;
-	job->rusage.ru_inblock += step->rusage.ru_inblock;
-	job->rusage.ru_oublock += step->rusage.ru_oublock;
-	job->rusage.ru_msgsnd += step->rusage.ru_msgsnd;
-	job->rusage.ru_msgrcv += step->rusage.ru_msgrcv;
-	job->rusage.ru_nsignals += step->rusage.ru_nsignals;
-	job->rusage.ru_nvcsw += step->rusage.ru_nvcsw;
-	job->rusage.ru_nivcsw += step->rusage.ru_nivcsw;
-		
-	/* and finally the maximums for any process */
-	job->rusage.ru_maxrss = MAX(job->rusage.ru_maxrss, 
-				    step->rusage.ru_maxrss);
-	job->rusage.ru_ixrss = MAX(job->rusage.ru_ixrss,
-				   step->rusage.ru_ixrss);
-	job->rusage.ru_idrss = MAX(job->rusage.ru_idrss,
-				   step->rusage.ru_idrss);
-	job->rusage.ru_isrss = MAX(job->rusage.ru_isrss,
-				   step->rusage.ru_isrss);
-	job->rusage.ru_minflt = MAX(job->rusage.ru_minflt,
-				    step->rusage.ru_minflt);
-	job->rusage.ru_majflt = MAX(job->rusage.ru_majflt,
-				    step->rusage.ru_majflt);
-	job->rusage.ru_nswap = MAX(job->rusage.ru_nswap,
-				   step->rusage.ru_nswap);
-
-	/* get the max for all the sacct_t struct */
-	aggregate_sacct(&job->sacct, &step->sacct);
-}
-
-void process_suspend(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	job_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-	job = _find_job_record(temp->header, JOB_SUSPEND);
-	if (!job)    
-		job = _init_job_rec(temp->header);
-	
-	job->show_full = show_full;
-	if (job->status == JOB_SUSPENDED) 
-		job->elapsed -= temp->elapsed;
-
-	//job->header.timestamp = temp->header.timestamp;
-	job->status = temp->status;
-	destroy_job(temp);
-}
-	
-void process_terminated(char *f[], int lc, int show_full, int len)
-{
-	job_rec_t *job = NULL;
-	job_rec_t *temp = NULL;
-
-	_parse_line(f, (void **)&temp, len);
-	job = _find_job_record(temp->header, JOB_TERMINATED);
-	if (!job) {	/* fake it for now */
-		job = _init_job_rec(temp->header);
-		if (params.opt_verbose > 1) 
-			fprintf(stderr, "Note: JOB_TERMINATED record for job "
-				"%u preceded "
-				"other job records at line %d\n",
-				temp->header.jobnum, lc);
-	} else if (job->job_terminated_seen) {
-		if (temp->status == JOB_NODE_FAIL) {
-			/* multiple node failures - extra TERMINATED records */
-			if (params.opt_verbose > 1)
-				fprintf(stderr, 
-					"Note: Duplicate JOB_TERMINATED "
-					"record (nf) for job %u at "
-					"line %d\n", 
-					temp->header.jobnum, lc);
-			/* JOB_TERMINATED/NF records may be preceded
-			 * by a JOB_TERMINATED/CA record; NF is much
-			 * more interesting.
-			 */
-			job->status = temp->status;
-			goto finished;
-		}
-		
-		fprintf(stderr,
-			"Conflicting JOB_TERMINATED record (%s) for "
-			"job %u at line %d -- ignoring it\n",
-			decode_status_int(temp->status), 
-			job->header.jobnum, lc);
-		input_error++;
-		goto finished;
-	}
-	job->job_terminated_seen = 1;
-	job->elapsed = temp->elapsed;
-	job->end = temp->header.timestamp;
-	job->status = temp->status;
-	job->requid = temp->requid;
-	if(list_count(job->steps) > 1)
-		job->track_steps = 1;
-	job->show_full = show_full;
-	
-finished:
-	destroy_job(temp);
-}
 
 void find_hostname(uint32_t pos, char *hosts, char *host)
 {
@@ -554,6 +57,7 @@ void find_hostname(uint32_t pos, char *hosts, char *host)
 	} else {
 		snprintf(host, 50, "'N/A'");
 	}
+	hostlist_destroy(hostlist);
 	return;
 }
 
@@ -584,35 +88,3 @@ void aggregate_sacct(sacct_t *dest, sacct_t *from)
 	}
 	dest->ave_cpu += from->ave_cpu;
 }
-
-void destroy_acct_header(void *object)
-{
-	acct_header_t *header = (acct_header_t *)object;
-	if(header) {
-		xfree(header->partition);
-		xfree(header->blockid);
-	}
-}
-void destroy_job(void *object)
-{
-	job_rec_t *job = (job_rec_t *)object;
-	if (job) {
-		if(job->steps)
-			list_destroy(job->steps);
-		destroy_acct_header(&job->header);
-		xfree(job->jobname);
-		xfree(job->nodes);
-		xfree(job);
-	}
-}
-
-void destroy_step(void *object)
-{
-	step_rec_t *step = (step_rec_t *)object;
-	if (step) {
-		destroy_acct_header(&step->header);
-		xfree(step->stepname);
-		xfree(step->nodes);
-		xfree(step);
-	}
-}
diff --git a/src/sacct/sacct.c b/src/sacct/sacct.c
index 68002846452b7e5e8e388f0e9734a92477636e52..8206aaf844e7d0a6d5d594c90c66b734edb8415f 100644
--- a/src/sacct/sacct.c
+++ b/src/sacct/sacct.c
@@ -145,7 +145,6 @@
 
 #include "sacct.h"
 
-
 void invalidSwitchCombo(char *good, char *bad);
 void _print_header(void);
 
@@ -154,7 +153,6 @@ void _print_header(void);
  */
 sacct_parameters_t params;
 fields_t fields[] = {{"account", print_account},
-		     {"blockid", print_blockid},
 		     {"cpu", print_cpu},
 		     {"cputime", print_cputime}, 
 		     {"elapsed", print_elapsed},
@@ -163,43 +161,39 @@ fields_t fields[] = {{"account", print_account},
 		     {"finished", print_end},		/* Defunct name */ 
 		     {"gid", print_gid}, 
 		     {"group", print_group}, 
-		     {"idrss", print_idrss}, 
-		     {"inblocks", print_inblocks}, 
-		     {"isrss", print_isrss}, 
-		     {"ixrss", print_ixrss}, 
 		     {"job", print_job},
 		     {"jobid", print_jobid}, 
 		     {"jobname", print_name}, 
-		     {"majflt", print_majflt}, 
-		     {"minflt", print_minflt}, 
-		     {"msgrcv", print_msgrcv}, 
-		     {"msgsnd", print_msgsnd}, 
 		     {"ncpus", print_ncpus}, 
-		     {"nivcsw", print_nivcsw}, 
 		     {"nodes", print_nodes}, 
+		     {"nnodes", print_nnodes}, 
 		     {"nprocs", print_ntasks},
-		     {"nsignals", print_nsignals},
-		     {"nswap", print_nswap}, 
 		     {"ntasks", print_ntasks}, 
-		     {"nvcsw", print_nvcsw}, 
-		     {"outblocks", print_outblocks},
 		     {"pages", print_pages}, 
 		     {"partition", print_partition}, 
 		     {"rss", print_rss},
 		     {"start", print_start}, 
-		     {"status", print_status}, 
+		     {"state", print_state}, 
+		     {"status", print_state}, 
 		     {"submit", print_submit}, 
+		     {"timelimit", print_timelimit}, 
 		     {"submitted", print_submit},	/* Defunct name */
 		     {"systemcpu", print_systemcpu}, 
 		     {"uid", print_uid}, 
 		     {"user", print_user}, 
 		     {"usercpu", print_usercpu}, 
 		     {"vsize", print_vsize}, 
-		     {"vsize_short", print_vsize_short}, 
+#ifdef HAVE_BG
+		     {"blockid", print_blockid}, 
+		     {"connection", print_connection}, 
+		     {"geo", print_geo}, 
+		     {"max_procs", print_max_procs}, 
+		     {"reboot", print_reboot}, 
+		     {"rotate", print_rotate}, 
+		     {"bg_start_point", print_bg_start_point}, 		     
+#endif
 		     {NULL, NULL}};
 
-long input_error = 0;		/* Muddle through bad data, but complain! */
-
 List jobs = NULL;
 
 int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
@@ -208,13 +202,13 @@ int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
 int main(int argc, char **argv)
 {
 	enum {
-		DUMP,
-		EXPIRE,
-		FDUMP,
-		LIST,
-		STAT,
-		HELP,
-		USAGE
+		SACCT_DUMP,
+		SACCT_EXPIRE,
+		SACCT_FDUMP,
+		SACCT_LIST,
+		SACCT_STAT,
+		SACCT_HELP,
+		SACCT_USAGE
 	} op;
 	int rc = 0;
 	
@@ -226,9 +220,9 @@ int main(int argc, char **argv)
 	 */
 
 	if (params.opt_help)
-		op = HELP;
+		op = SACCT_HELP;
 	else if (params.opt_dump) {
-		op = DUMP;
+		op = SACCT_DUMP;
 		if (params.opt_long || params.opt_total 
 		    || params.opt_field_list || params.opt_expire) {
 			if (params.opt_verbose)
@@ -247,11 +241,11 @@ int main(int argc, char **argv)
 			goto finished;
 		}
 	} else if (params.opt_fdump) {
-		op = FDUMP;
+		op = SACCT_FDUMP;
 	} else if (params.opt_stat) {
-		op = STAT;
+		op = SACCT_STAT;
 	} else if (params.opt_expire) {
-		op = EXPIRE;
+		op = SACCT_EXPIRE;
 		if (params.opt_long || params.opt_total 
 		    || params.opt_field_list || 
 		    (params.opt_gid>=0) || (params.opt_uid>=0) ||
@@ -281,32 +275,46 @@ int main(int argc, char **argv)
 			goto finished;
 		}
 	} else
-		op = LIST;
+		op = SACCT_LIST;
 
 	
 	switch (op) {
-	case DUMP:
-		get_data();
-		do_dump();
+	case SACCT_DUMP:
+		if(get_data() == SLURM_ERROR)
+			exit(errno);
+		if(params.opt_completion) 
+			do_dump_completion();
+		else 
+			do_dump();
 		break;
-	case EXPIRE:
-		do_expire();
+	case SACCT_EXPIRE:
+		do_expire(0);
 		break;
-	case FDUMP:
-		get_data();
+	case SACCT_FDUMP:
+		if(get_data() == SLURM_ERROR)
+			exit(errno);
 		break;
-	case LIST:
+	case SACCT_LIST:
 		if (params.opt_header) 	/* give them something to look */
 			_print_header();/* at while we think...        */
-		get_data();
-		do_list();
+		if(get_data() == SLURM_ERROR)
+			exit(errno);
+		if(params.opt_completion) 
+			do_list_completion();
+		else 
+			do_list();
 		break;
-	case STAT:
+	case SACCT_STAT:
+		fprintf(stderr,
+			"This functionality has been replaced with 'sstat' "
+			"in the future please make note this will "
+			"not be supported.");
+		
 		if (params.opt_header) 	/* give them something to look */
 			_print_header();/* at while we think...        */
 		do_stat();
 		break;
-	case HELP:
+	case SACCT_HELP:
 		do_help();
 		break;
 	default:
diff --git a/src/sacct/sacct.h b/src/sacct/sacct.h
index aa36d0b8db0b81012444239de28df6674a176c96..c340bc9eeaa06877c1d729ebc2674e00a3d486a6 100644
--- a/src/sacct/sacct.h
+++ b/src/sacct/sacct.h
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -57,245 +57,60 @@
 #include "src/common/xstring.h"
 #include "src/common/list.h"
 #include "src/common/hostlist.h"
-
-#include "src/sacct/sacct_stat.h"
+#include "src/common/slurm_jobacct_gather.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurm_jobcomp.h"
 
 #define ERROR 2
 
-/* slurmd uses "(uint32_t) -2" to track data for batch allocations
- * which have no logical jobsteps. */
-#define BATCH_JOB_TIMESTAMP 0
+#define BRIEF_FIELDS "jobid,state,exitcode"
+#define BRIEF_COMP_FIELDS "jobid,uid,state"
+#define DEFAULT_FIELDS "jobid,jobname,partition,ncpus,state,exitcode"
+#define DEFAULT_COMP_FIELDS "jobid,uid,jobname,partition,nnodes,nodes,state,end"
+#define STAT_FIELDS "jobid,vsize,rss,pages,cputime,ntasks,state"
+#define LONG_FIELDS "jobid,jobname,partition,vsize,rss,pages,cputime,ntasks,ncpus,elapsed,state,exitcode"
 
-#define ACCOUNT_FIELDS "jobid,jobname,start,end,cpu,vsize_short,status,exitcode"
-#define BRIEF_FIELDS "jobid,status,exitcode"
-#define DEFAULT_FIELDS "jobid,jobname,partition,ncpus,status,exitcode"
-#define STAT_FIELDS "jobid,vsize,rss,pages,cputime,ntasks,status"
-#define LONG_FIELDS "jobid,jobname,partition,vsize,rss,pages,cputime,ntasks,ncpus,elapsed,status,exitcode"
+#ifdef HAVE_BG
+#define LONG_COMP_FIELDS "jobid,uid,jobname,partition,blockid,nnodes,nodes,state,start,end,timelimit,connection,reboot,rotate,max_procs,geo,bg_start_point"
+#else
+#define LONG_COMP_FIELDS "jobid,uid,jobname,partition,nnodes,nodes,state,start,end,timelimit"
+#endif
 
 #define BUFFER_SIZE 4096
-#define STATUS_COUNT 10
+#define STATE_COUNT 10
 
 #define MAX_PRINTFIELDS 100
-#define EXPIRE_READ_LENGTH 10
-#define MAX_RECORD_FIELDS 100
 
 #define SECONDS_IN_MINUTE 60
 #define SECONDS_IN_HOUR (60*SECONDS_IN_MINUTE)
 #define SECONDS_IN_DAY (24*SECONDS_IN_HOUR)
 
-#define TIMESTAMP_LENGTH 15
-
-/* Map field names to positions */
-
-/* Fields common to all records */
-enum {	F_JOB =	0,
-	F_PARTITION,	
-	F_JOB_SUBMIT,	
-	F_TIMESTAMP,	
-	F_UID,	
-	F_GID,	
-	F_BLOCKID,	
-	F_RESERVED2,	
-	F_RECTYPE,	
-	HEADER_LENGTH
-};
-
-/* JOB_START fields */
-enum {	F_JOBNAME = HEADER_LENGTH,
-	F_TRACK_STEPS,		
-	F_PRIORITY,	
-	F_NCPUS,		
-	F_NODES,
-	F_JOB_ACCOUNT,
-	JOB_START_LENGTH
-};
-
-/* JOB_STEP fields */
-enum {	F_JOBSTEP = HEADER_LENGTH,
-	F_STATUS,
-	F_EXITCODE,
-	F_NTASKS,
-	F_STEPNCPUS,
-	F_ELAPSED,
-	F_CPU_SEC,
-	F_CPU_USEC,
-	F_USER_SEC,
-	F_USER_USEC,
-	F_SYS_SEC,
-	F_SYS_USEC,
-	F_RSS,
-	F_IXRSS,
-	F_IDRSS,
-	F_ISRSS,
-	F_MINFLT,
-	F_MAJFLT,
-	F_NSWAP,
-	F_INBLOCKS,
-	F_OUBLOCKS,
-	F_MSGSND,
-	F_MSGRCV,
-	F_NSIGNALS,
-	F_NVCSW,
-	F_NIVCSW,
-	F_MAX_VSIZE,
-	F_MAX_VSIZE_TASK,
-	F_AVE_VSIZE,
-	F_MAX_RSS,
-	F_MAX_RSS_TASK,
-	F_AVE_RSS,
-	F_MAX_PAGES,
-	F_MAX_PAGES_TASK,
-	F_AVE_PAGES,
-	F_MIN_CPU,
-	F_MIN_CPU_TASK,
-	F_AVE_CPU,
-	F_STEPNAME,
-	F_STEPNODES,
-	F_MAX_VSIZE_NODE,
-	F_MAX_RSS_NODE,
-	F_MAX_PAGES_NODE,
-	F_MIN_CPU_NODE,
-	F_STEP_ACCOUNT,
-	F_STEP_REQUID,
-	JOB_STEP_LENGTH
-};
-
-/* JOB_TERM / JOB_SUSPEND fields */
-enum {	F_TOT_ELAPSED = HEADER_LENGTH,
-	F_TERM_STATUS,
-	F_JOB_REQUID,
-	JOB_TERM_LENGTH
-};
-
 /* On output, use fields 12-37 from JOB_STEP */
 
 typedef enum {	HEADLINE,
 		UNDERSCORE,
 		JOB,
-		JOBSTEP
+		JOBSTEP,
+		JOBCOMP
 } type_t;
 
-enum {	CANCELLED,
-	COMPLETED,
-	COMPLETING,
-	FAILED,
-	NODEFAILED,
-	PENDING,
-	RUNNING,
-	TIMEDOUT
-};
-
-typedef struct header {
-	uint32_t jobnum;
-	char	*partition;
-	char	*blockid;
-	time_t 	job_submit;
-	time_t	timestamp;
-	uint32_t uid;
-	uint32_t gid;
-	uint16_t rec_type;
-} acct_header_t;
-
-typedef struct job_rec {
-	uint32_t	job_start_seen,		/* useful flags */
-		job_step_seen,
-		job_terminated_seen,
-		jobnum_superseded;	/* older jobnum was reused */
-	acct_header_t header;
-	uint16_t show_full;
-	char	*nodes;
-	char	*jobname;
-	uint16_t track_steps;
-	int32_t priority;
-	uint32_t ncpus;
-	uint32_t ntasks;
-	int32_t	status;
-	int32_t	exitcode;
-	uint32_t elapsed;
-	time_t end;
-	uint32_t tot_cpu_sec;
-	uint32_t tot_cpu_usec;
-	struct rusage rusage;
-	sacct_t sacct;
-	List    steps;
-	char    *account;
-	uint32_t requid;
-} job_rec_t;
-
-typedef struct step_rec {
-	acct_header_t   header;
-	uint32_t	stepnum;	/* job's step number */
-	char	        *nodes;
-	char	        *stepname;
-	int32_t	        status;
-	int32_t	        exitcode;
-	uint32_t	ntasks; 
-	uint32_t        ncpus;
-	uint32_t	elapsed;
-	time_t          end;
-	uint32_t	tot_cpu_sec;
-	uint32_t        tot_cpu_usec;
-	struct rusage   rusage;
-	sacct_t         sacct;
-	char            *account;
-	uint32_t requid;
-} step_rec_t;
-
-typedef struct selected_step_t {
-	char *job;
-	char *step;
-} selected_step_t;
 
 typedef struct fields {
 	char *name;		/* Specified in --fields= */
 	void (*print_routine) ();	/* Who gets to print it? */
 } fields_t;
 
-/* Input parameters */
-typedef struct sacct_parameters {
-	int opt_dump;		/* --dump */
-	int opt_dup;		/* --duplicates; +1 = explicitly set */
-	int opt_fdump;		/* --formattted_dump */
-	int opt_stat;		/* --stat */
-	int opt_gid;		/* --gid (-1=wildcard, 0=root) */
-	int opt_header;		/* can only be cleared */
-	int opt_help;		/* --help */
-	int opt_long;		/* --long */
-	int opt_lowmem;		/* --low_memory */
-	int opt_purge;		/* --purge */
-	int opt_raw;		/* --raw */
-	int opt_total;		/* --total */
-	int opt_uid;		/* --uid (-1=wildcard, 0=root) */
-	int opt_verbose;	/* --verbose */
-	long opt_expire;		/* --expire= */ 
-	char *opt_expire_timespec; /* --expire= */
-	char *opt_field_list;	/* --fields= */
-	char *opt_filein;	/* --file */
-	char *opt_job_list;	/* --jobs */
-	char *opt_partition_list;/* --partitions */
-	char *opt_state_list;	/* --states */
-} sacct_parameters_t;
-
 extern fields_t fields[];
 extern sacct_parameters_t params;
 
-extern long input_error;	/* Muddle through bad data, but complain! */
-
 extern List jobs;
 
 extern int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
 	nprintfields;
 
 /* process.c */
-void process_start(char *f[], int lc, int show_full, int len);
-void process_step(char *f[], int lc, int show_full, int len);
-void process_suspend(char *f[], int lc, int show_full, int len);
-void process_terminated(char *f[], int lc, int show_full, int len);
 void find_hostname(uint32_t pos, char *hosts, char *host);
 void aggregate_sacct(sacct_t *dest, sacct_t *from);
-void destroy_acct_header(void *object);
-void destroy_job(void *object);
-void destroy_step(void *object);
 
 /* print.c */
 void print_fields(type_t type, void *object);
@@ -304,54 +119,55 @@ void print_elapsed(type_t type, void *object);
 void print_exitcode(type_t type, void *object);
 void print_gid(type_t type, void *object);
 void print_group(type_t type, void *object);
-void print_idrss(type_t type, void *object);
-void print_inblocks(type_t type, void *object);
-void print_isrss(type_t type, void *object);
-void print_ixrss(type_t type, void *object);
 void print_job(type_t type, void *object);
 void print_name(type_t type, void *object);
 void print_jobid(type_t type, void *object);
-void print_majflt(type_t type, void *object);
-void print_minflt(type_t type, void *object);
-void print_msgrcv(type_t type, void *object);
-void print_msgsnd(type_t type, void *object);
 void print_ncpus(type_t type, void *object);
-void print_nivcsw(type_t type, void *object);
 void print_nodes(type_t type, void *object);
-void print_nsignals(type_t type, void *object);
-void print_nswap(type_t type, void *object);
+void print_nnodes(type_t type, void *object);
 void print_ntasks(type_t type, void *object);
-void print_nvcsw(type_t type, void *object);
-void print_outblocks(type_t type, void *object);
 void print_partition(type_t type, void *object);
 void print_blockid(type_t type, void *object);
 void print_pages(type_t type, void *object);
 void print_rss(type_t type, void *object);
-void print_status(type_t type, void *object);
+void print_state(type_t type, void *object);
 void print_submit(type_t type, void *object);
 void print_start(type_t type, void *object);
 void print_end(type_t type, void *object);
 void print_systemcpu(type_t type, void *object);
+void print_timelimit(type_t type, void *object);
 void print_uid(type_t type, void *object);
 void print_user(type_t type, void *object);
 void print_usercpu(type_t type, void *object);
 void print_vsize(type_t type, void *object);
-void print_vsize_short(type_t type, void *object);
 void print_cputime(type_t type, void *object);
 void print_account(type_t type, void *object);
 
+#ifdef HAVE_BG
+void print_connection(type_t type, void *object);
+void print_geo(type_t type, void *object);
+void print_max_procs(type_t type, void *object);
+void print_reboot(type_t type, void *object);
+void print_rotate(type_t type, void *object);
+void print_bg_start_point(type_t type, void *object);
+#endif
+
 /* options.c */
-int decode_status_char(char *status);
-char *decode_status_int(int status);
+int decode_state_char(char *state);
+char *decode_state_int(int state);
 int get_data(void);
 void parse_command_line(int argc, char **argv);
 void do_dump(void);
-void do_expire(void);
-void do_fdump(char* fields[], int lc);
+void do_dump_completion(void);
+void do_expire(int dummy);
 void do_help(void);
 void do_list(void);
+void do_list_completion(void);
 void do_stat(void);
 void sacct_init();
 void sacct_fini();
 
+/* sacct_stat.c */
+extern int sacct_stat(uint32_t jobid, uint32_t stepid);
+
 #endif /* !_SACCT_H */
diff --git a/src/sacct/sacct_stat.c b/src/sacct/sacct_stat.c
index 5c4b298122fd1b06c55497b957452b955ef08a16..427fd1e82aa6b2db47fc41d534985cffab1154ab 100644
--- a/src/sacct/sacct_stat.c
+++ b/src/sacct/sacct_stat.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -17,7 +17,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -39,11 +39,10 @@
 
 #include "sacct.h"
 #include <pthread.h>
-#include "src/common/slurm_jobacct.h"
 #include "src/common/forward.h"
 #include "src/common/slurm_auth.h"
 
-step_rec_t step;
+jobacct_step_rec_t step;
 	
 int thr_finished = 0;
 	
@@ -65,7 +64,7 @@ int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 	ret_data_info_t *ret_data_info = NULL;
 	int rc = SLURM_SUCCESS;
 	int ntasks = 0;
-
+	int tot_tasks = 0;
 	debug("getting the stat of job %d on %d nodes", 
 	      job_id, step_layout->node_cnt);
 
@@ -74,20 +73,15 @@ int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 	memset(&step.sacct, 0, sizeof(sacct_t));
 	step.sacct.min_cpu = (float)NO_VAL;
 
-	step.header.jobnum = job_id;
-	step.header.partition = NULL;
-	step.header.blockid = NULL;
-	step.stepnum = step_id;
+	step.stepid = step_id;
 	step.nodes = step_layout->node_list;
 	step.stepname = NULL;
-	step.status = JOB_RUNNING;
-	step.ntasks = 0;
+	step.state = JOB_RUNNING;
 	slurm_msg_t_init(&msg);
-	
 	/* Common message contents */
 	r.job_id      = job_id;
 	r.step_id     = step_id;
-	r.jobacct     = jobacct_g_alloc(NULL);
+	r.jobacct     = jobacct_gather_g_create(NULL);
 	msg.msg_type        = MESSAGE_STAT_JOBACCT;
 	msg.data            = &r;
 	
@@ -107,7 +101,7 @@ int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 			if(jobacct_msg) {
 				debug2("got it back for job %d", 
 				       jobacct_msg->job_id);
-				jobacct_g_2_sacct(
+				jobacct_gather_g_2_sacct(
 					&temp_sacct, 
 					jobacct_msg->jobacct);
 				ntasks += jobacct_msg->num_tasks;
@@ -131,23 +125,23 @@ int _sacct_query(slurm_step_layout_t *step_layout, uint32_t job_id,
 	list_iterator_destroy(itr);
 	list_destroy(ret_list);
 
-	step.ntasks += ntasks;		
+	tot_tasks += ntasks;		
 cleanup:
 	
-	if(step.ntasks) {
+	if(tot_tasks) {
 		step.sacct.ave_rss *= 1024;
 		step.sacct.max_rss *= 1024;
 		step.sacct.ave_vsize *= 1024;
 		step.sacct.max_vsize *= 1024;
 
-		step.sacct.ave_cpu /= step.ntasks;
+		step.sacct.ave_cpu /= tot_tasks;
 		step.sacct.ave_cpu /= 100;
 		step.sacct.min_cpu /= 100;
-		step.sacct.ave_rss /= step.ntasks;
-		step.sacct.ave_vsize /= step.ntasks;
-		step.sacct.ave_pages /= step.ntasks;
+		step.sacct.ave_rss /= tot_tasks;
+		step.sacct.ave_vsize /= tot_tasks;
+		step.sacct.ave_pages /= tot_tasks;
 	}
-	jobacct_g_free(r.jobacct);	
+	jobacct_gather_g_destroy(r.jobacct);	
 	return SLURM_SUCCESS;
 }
 
@@ -198,8 +192,10 @@ int sacct_stat(uint32_t jobid, uint32_t stepid)
 	}
 
 	_sacct_query(step_layout, jobid, stepid);
-	slurm_step_layout_destroy(step_layout);	
 	
 	_process_results();
+	
+	slurm_step_layout_destroy(step_layout);	
+	
 	return rc;
 }
diff --git a/src/sacctmgr/Makefile.am b/src/sacctmgr/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..bf354ad3ed90f82e366284f815ed22edd2634a41
--- /dev/null
+++ b/src/sacctmgr/Makefile.am
@@ -0,0 +1,27 @@
+# Makefile for sacctmgr
+
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = -I$(top_srcdir)
+
+bin_PROGRAMS = sacctmgr
+
+sacctmgr_SOURCES =	\
+	account_functions.c	\
+	association_functions.c	\
+	cluster_functions.c	\
+	common.c                \
+	print.c	print.h	        \
+	sacctmgr.c sacctmgr.h	\
+	user_functions.c	
+
+sacctmgr_LDADD =  \
+	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la \
+	$(READLINE_LIBS)
+
+sacctmgr_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+
+force:
+$(convenience_libs) : force
+	@cd `dirname $@` && $(MAKE) `basename $@`
diff --git a/src/sacctmgr/Makefile.in b/src/sacctmgr/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..585445fa5aaf546dda8cac2f4e11f32e3d4fef5a
--- /dev/null
+++ b/src/sacctmgr/Makefile.in
@@ -0,0 +1,576 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for sacctmgr
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+bin_PROGRAMS = sacctmgr$(EXEEXT)
+subdir = src/sacctmgr
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_sacctmgr_OBJECTS = account_functions.$(OBJEXT) \
+	association_functions.$(OBJEXT) cluster_functions.$(OBJEXT) \
+	common.$(OBJEXT) print.$(OBJEXT) sacctmgr.$(OBJEXT) \
+	user_functions.$(OBJEXT)
+sacctmgr_OBJECTS = $(am_sacctmgr_OBJECTS)
+am__DEPENDENCIES_1 =
+sacctmgr_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
+	$(top_builddir)/src/api/libslurmhelper.la \
+	$(am__DEPENDENCIES_1)
+sacctmgr_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sacctmgr_LDFLAGS) \
+	$(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(sacctmgr_SOURCES)
+DIST_SOURCES = $(sacctmgr_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+INCLUDES = -I$(top_srcdir)
+sacctmgr_SOURCES = \
+	account_functions.c	\
+	association_functions.c	\
+	cluster_functions.c	\
+	common.c                \
+	print.c	print.h	        \
+	sacctmgr.c sacctmgr.h	\
+	user_functions.c	
+
+sacctmgr_LDADD = \
+	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la \
+	$(READLINE_LIBS)
+
+sacctmgr_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/sacctmgr/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/sacctmgr/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	     || test -f $$p1 \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+sacctmgr$(EXEEXT): $(sacctmgr_OBJECTS) $(sacctmgr_DEPENDENCIES) 
+	@rm -f sacctmgr$(EXEEXT)
+	$(sacctmgr_LINK) $(sacctmgr_OBJECTS) $(sacctmgr_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/account_functions.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/association_functions.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cluster_functions.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sacctmgr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user_functions.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-binPROGRAMS install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am \
+	uninstall-binPROGRAMS
+
+
+force:
+$(convenience_libs) : force
+	@cd `dirname $@` && $(MAKE) `basename $@`
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/sacctmgr/account_functions.c b/src/sacctmgr/account_functions.c
new file mode 100644
index 0000000000000000000000000000000000000000..ed0e3d916b9907c650fca3756c75f1ad71137b08
--- /dev/null
+++ b/src/sacctmgr/account_functions.c
@@ -0,0 +1,1174 @@
+/*****************************************************************************\
+ *  account_functions.c - functions dealing with accounts in the
+ *                        accounting system.
+ *****************************************************************************
+ *  Copyright (C) 2002-2008 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/sacctmgr/sacctmgr.h"
+#include "src/sacctmgr/print.h"
+
+static int _set_cond(int *start, int argc, char *argv[],
+		     acct_account_cond_t *acct_cond,
+		     List format_list)
+{
+	int i;
+	int a_set = 0;
+	int u_set = 0;
+	int end = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if (strncasecmp (argv[i], "Set", 3) == 0) {
+			i--;
+			break;
+		} else if (strncasecmp (argv[i], "WithAssoc", 4) == 0) {
+			acct_cond->with_assocs = 1;
+		} else if(!end) {
+			addto_char_list(acct_cond->acct_list, argv[i]);
+			addto_char_list(acct_cond->assoc_cond->acct_list,
+					argv[i]);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Clusters", 1) == 0) {
+			addto_char_list(acct_cond->assoc_cond->cluster_list,
+					argv[i]+end);
+			a_set = 1;
+		} else if (strncasecmp (argv[i], "Descriptions", 1) == 0) {
+			addto_char_list(acct_cond->description_list,
+					argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Format", 1) == 0) {
+			if(format_list)
+				addto_char_list(format_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Names", 1) == 0
+			   || strncasecmp (argv[i], "Accouts", 1) == 0) {
+			addto_char_list(acct_cond->acct_list, argv[i]+end);
+			addto_char_list(acct_cond->assoc_cond->acct_list,
+					argv[i]);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Organizations", 1) == 0) {
+			addto_char_list(acct_cond->organization_list,
+					argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Parent", 1) == 0) {
+			acct_cond->assoc_cond->parent_acct =
+				xstrdup(argv[i]+end);
+			a_set = 1;
+		} else if (strncasecmp (argv[i], "QosLevel", 1) == 0) {
+			acct_cond->qos = str_2_acct_qos(argv[i]+end);
+			u_set = 1;
+		} else {
+			printf(" Unknown condition: %s\n"
+			       " Use keyword 'set' to modify "
+			       "SLURM_PRINT_VALUE\n", argv[i]);
+		}
+	}
+	(*start) = i;
+
+	if(a_set) 
+		return 2;
+	else if(u_set)
+		return 1;
+
+	return 0;
+}
+
+static int _set_rec(int *start, int argc, char *argv[],
+		    acct_account_rec_t *acct,
+		    acct_association_rec_t *assoc)
+{
+	int i, mins;
+	int u_set = 0;
+	int a_set = 0;
+	int end = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if (strncasecmp (argv[i], "Where", 5) == 0) {
+			i--;
+			break;
+		} else if(!end) {
+			printf(" Bad format on %s: End your option with "
+			       "an '=' sign\n", argv[i]);
+		} else if (strncasecmp (argv[i], "Description", 1) == 0) {
+			acct->description = xstrdup(argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "FairShare", 1) == 0) {
+			if (get_uint(argv[i]+end, &assoc->fairshare, 
+			    "FairShare") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxCPUSec", 4) == 0) {
+			if (get_uint(argv[i]+end, &assoc->max_cpu_secs_per_job,
+			    "MaxCPUSec") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxJobs", 4) == 0) {
+			if (get_uint(argv[i]+end, &assoc->max_jobs,
+			    "MaxJobs") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxNodes", 4) == 0) {
+			if (get_uint(argv[i]+end, &assoc->max_nodes_per_job,
+			    "MaxNodes") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxWall", 4) == 0) {
+			mins = time_str2mins(argv[i]+end);
+			if (mins != NO_VAL) {
+				assoc->max_wall_duration_per_job 
+					= (uint32_t) mins;
+				a_set = 1;
+			} else {
+				printf(" Bad MaxWall time format: %s\n", 
+					argv[i]);
+			}
+		} else if (strncasecmp (argv[i], "Organization", 1) == 0) {
+			acct->organization = xstrdup(argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Parent", 1) == 0) {
+			assoc->parent_acct = xstrdup(argv[i]+end);
+			a_set = 1;
+		} else if (strncasecmp (argv[i], "QosLevel=", 1) == 0) {
+			acct->qos = str_2_acct_qos(argv[i]+end);
+			u_set = 1;
+		} else {
+			printf(" Unknown option: %s\n"
+			       " Use keyword 'where' to modify condition\n",
+			       argv[i]);
+		}
+	}
+	(*start) = i;
+
+	if(u_set && a_set)
+		return 3;
+	else if(a_set)
+		return 2;
+	else if(u_set)
+		return 1;
+	return 0;
+}
+
+/* static void _print_cond(acct_account_cond_t *acct_cond) */
+/* { */
+/* 	ListIterator itr = NULL; */
+/* 	char *tmp_char = NULL; */
+
+/* 	if(!acct_cond) { */
+/* 		error("no acct_account_cond_t * given"); */
+/* 		return; */
+/* 	} */
+
+/* 	if(acct_cond->acct_list && list_count(acct_cond->acct_list)) { */
+/* 		itr = list_iterator_create(acct_cond->acct_list); */
+/* 		printf("  Names       = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("             or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(acct_cond->description_list */
+/* 	   && list_count(acct_cond->description_list)) { */
+/* 		itr = list_iterator_create(acct_cond->description_list); */
+/* 		printf("  Description = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("             or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(acct_cond->organization_list */
+/* 	   && list_count(acct_cond->organization_list)) { */
+/* 		itr = list_iterator_create(acct_cond->organization_list); */
+/* 		printf("  Organization = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("             or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(acct_cond->qos != ACCT_QOS_NOTSET) */
+/* 		printf("  Qos     = %s\n",  */
+/* 		       acct_qos_str(acct_cond->qos)); */
+/* } */
+
+/* static void _print_rec(acct_account_rec_t *acct) */
+/* { */
+/* 	if(!acct) { */
+/* 		error("no acct_account_rec_t * given"); */
+/* 		return; */
+/* 	} */
+	
+/* 	if(acct->name)  */
+/* 		printf("  Name         = %s\n", acct->name);	 */
+		
+/* 	if(acct->description)  */
+/* 		printf("  Description  = %s\n", acct->description); */
+
+/* 	if(acct->organization)  */
+/* 		printf("  Organization = %s\n", acct->organization); */
+		
+/* 	if(acct->qos != ACCT_QOS_NOTSET) */
+/* 		printf("  Qos     = %s\n",  */
+/* 		       acct_qos_str(acct->qos)); */
+
+/* } */
+
+extern int sacctmgr_add_account(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	int i=0, mins;
+	ListIterator itr = NULL, itr_c = NULL;
+	acct_account_rec_t *acct = NULL;
+	acct_association_rec_t *assoc = NULL;
+	acct_association_cond_t assoc_cond;
+	List name_list = list_create(slurm_destroy_char);
+	List cluster_list = list_create(slurm_destroy_char);
+	char *description = NULL;
+	char *organization = NULL;
+	char *parent = NULL;
+	char *cluster = NULL;
+	char *name = NULL;
+	acct_qos_level_t qos = ACCT_QOS_NOTSET;
+	List acct_list = NULL;
+	List assoc_list = NULL;
+	List local_assoc_list = NULL;
+	List local_account_list = NULL;
+	uint32_t fairshare = NO_VAL; 
+	uint32_t max_jobs = NO_VAL;
+	uint32_t max_nodes_per_job = NO_VAL;
+	uint32_t max_wall_duration_per_job = NO_VAL;
+	uint32_t max_cpu_secs_per_job = NO_VAL;
+	char *acct_str = NULL;
+	char *assoc_str = NULL;
+	int limit_set = 0;
+	
+	for (i=0; i<argc; i++) {
+		int end = parse_option_end(argv[i]);
+		if(!end) {
+			addto_char_list(name_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Cluster", 1) == 0) {
+			addto_char_list(cluster_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Description", 1) == 0) {
+			description = xstrdup(argv[i]+end);
+		} else if (strncasecmp (argv[i], "FairShare", 1) == 0) {
+			if (get_uint(argv[i]+end, &fairshare, 
+			    "FairShare") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxCPUSecs", 4) == 0) {
+			if (get_uint(argv[i]+end, &max_cpu_secs_per_job, 
+			    "MaxCPUSecs") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxJobs", 4) == 0) {
+			if (get_uint(argv[i]+end, &max_jobs, 
+			    "MaxJobs") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxNodes", 4) == 0) {
+			if (get_uint(argv[i]+end, &max_nodes_per_job, 
+			    "MaxNodes") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxWall", 4) == 0) {
+			mins = time_str2mins(argv[i]+end);
+			if (mins != NO_VAL) {
+				max_wall_duration_per_job = (uint32_t) mins;
+				limit_set = 1;
+			} else {
+				printf(" Bad MaxWall time format: %s\n", 
+					argv[i]);
+			}
+		} else if (strncasecmp (argv[i], "Names", 1) == 0) {
+			addto_char_list(name_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Organization", 1) == 0) {
+			organization = xstrdup(argv[i]+end);
+		} else if (strncasecmp (argv[i], "Parent", 1) == 0) {
+			parent = xstrdup(argv[i]+end);
+		} else if (strncasecmp (argv[i], "QosLevel", 1) == 0) {
+			qos = str_2_acct_qos(argv[i]+end);
+		} else {
+			printf(" Unknown option: %s\n", argv[i]);
+		}		
+	}
+
+	if(!list_count(name_list)) {
+		list_destroy(name_list);
+		list_destroy(cluster_list);
+		xfree(parent);
+		xfree(description);
+		xfree(organization);
+		printf(" Need name of account to add.\n"); 
+		return SLURM_SUCCESS;
+	} else {
+		acct_account_cond_t account_cond;
+
+		memset(&account_cond, 0, sizeof(acct_account_cond_t));
+		account_cond.acct_list = name_list;
+
+		local_account_list = acct_storage_g_get_accounts(
+			db_conn, &account_cond);
+		
+	}
+	if(!local_account_list) {
+		printf(" Problem getting accounts from database.  "
+		       "Contact your admin.\n");
+		list_destroy(name_list);
+		list_destroy(cluster_list);
+		xfree(parent);
+		xfree(description);
+		xfree(organization);
+		return SLURM_ERROR;
+	}
+
+	if(!parent)
+		parent = xstrdup("root");
+
+	if(!list_count(cluster_list)) {
+		List temp_list = NULL;
+		acct_cluster_rec_t *cluster_rec = NULL;
+
+		temp_list = acct_storage_g_get_clusters(db_conn, NULL);
+		if(!cluster_list) {
+			printf(" Problem getting clusters from database.  "
+			       "Contact your admin.\n");
+			list_destroy(name_list);
+			list_destroy(cluster_list);
+			list_destroy(local_account_list);
+			xfree(parent);
+			xfree(description);
+			xfree(organization);
+			return SLURM_ERROR;
+		}
+
+		itr_c = list_iterator_create(temp_list);
+		while((cluster_rec = list_next(itr_c))) {
+			list_append(cluster_list, xstrdup(cluster_rec->name));
+		}
+		list_iterator_destroy(itr_c);
+
+		if(!list_count(cluster_list)) {
+			printf("  Can't add accounts, no cluster defined yet.\n"
+			       " Please contact your administrator.\n");
+			list_destroy(name_list);
+			list_destroy(cluster_list);
+			list_destroy(local_account_list);
+			xfree(parent);
+			xfree(description);
+			xfree(organization);
+			return SLURM_ERROR; 
+		}
+	} else {
+		List temp_list = NULL;
+		acct_cluster_cond_t cluster_cond;
+
+		memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
+		cluster_cond.cluster_list = cluster_list;
+
+		temp_list = acct_storage_g_get_clusters(db_conn, &cluster_cond);
+		
+		itr_c = list_iterator_create(cluster_list);
+		itr = list_iterator_create(temp_list);
+		while((cluster = list_next(itr_c))) {
+			acct_cluster_rec_t *cluster_rec = NULL;
+
+			list_iterator_reset(itr);
+			while((cluster_rec = list_next(itr))) {
+				if(!strcasecmp(cluster_rec->name, cluster))
+					break;
+			}
+			if(!cluster_rec) {
+				printf(" error: This cluster '%s' "
+				       "doesn't exist.\n"
+				       "        Contact your admin "
+				       "to add it to accounting.\n",
+				       cluster);
+				list_delete_item(itr_c);
+			}
+		}
+		list_iterator_destroy(itr);
+		list_iterator_destroy(itr_c);
+		list_destroy(temp_list);
+		if(!list_count(cluster_list)) {
+			list_destroy(name_list);
+			list_destroy(cluster_list);
+			list_destroy(local_account_list);
+			return SLURM_ERROR;
+		}
+	}
+
+		
+	acct_list = list_create(destroy_acct_account_rec);
+	assoc_list = list_create(destroy_acct_association_rec);
+	
+	memset(&assoc_cond, 0, sizeof(acct_association_cond_t));
+
+	assoc_cond.acct_list = list_create(NULL);
+	itr = list_iterator_create(name_list);
+	while((name = list_next(itr))) {
+		list_append(assoc_cond.acct_list, name);
+	}
+	list_iterator_destroy(itr);
+	list_append(assoc_cond.acct_list, parent);
+
+	assoc_cond.cluster_list = cluster_list;
+	local_assoc_list = acct_storage_g_get_associations(
+		db_conn, &assoc_cond);	
+	list_destroy(assoc_cond.acct_list);
+	if(!local_assoc_list) {
+		printf(" Problem getting associations from database.  "
+		       "Contact your admin.\n");
+		list_destroy(name_list);
+		list_destroy(cluster_list);
+		list_destroy(local_account_list);
+		xfree(parent);
+		xfree(description);
+		xfree(organization);
+		return SLURM_ERROR;
+	}
+
+	itr = list_iterator_create(name_list);
+	while((name = list_next(itr))) {
+		acct = NULL;
+		if(!sacctmgr_find_account_from_list(local_account_list, name)) {
+			acct = xmalloc(sizeof(acct_account_rec_t));
+			acct->assoc_list = list_create(NULL);	
+			acct->name = xstrdup(name);
+			if(description) 
+				acct->description = xstrdup(description);
+			else
+				acct->description = xstrdup(name);
+
+			if(organization)
+				acct->organization = xstrdup(organization);
+			else if(strcmp(parent, "root"))
+				acct->organization = xstrdup(parent);
+			else
+				acct->organization = xstrdup(name);
+				
+			acct->qos = qos;
+			xstrfmtcat(acct_str, "  %s\n", name);
+			list_append(acct_list, acct);
+		}
+
+		itr_c = list_iterator_create(cluster_list);
+		while((cluster = list_next(itr_c))) {
+			if(sacctmgr_find_account_base_assoc_from_list(
+				   local_assoc_list, name, cluster)) {
+				//printf(" already have this assoc\n");
+				continue;
+			}
+			if(!sacctmgr_find_account_base_assoc_from_list(
+				   local_assoc_list, parent, cluster)) {
+				printf(" error: Parent account '%s' "
+				       "doesn't exist on "
+				       "cluster %s\n"
+				       "        Contact your admin "
+				       "to add this account.\n",
+				       parent, cluster);
+				continue;
+			}
+
+			assoc = xmalloc(sizeof(acct_association_rec_t));
+			assoc->acct = xstrdup(name);
+			assoc->cluster = xstrdup(cluster);
+			assoc->parent_acct = xstrdup(parent);
+			assoc->fairshare = fairshare;
+			assoc->max_jobs = max_jobs;
+			assoc->max_nodes_per_job = max_nodes_per_job;
+			assoc->max_wall_duration_per_job =
+				max_wall_duration_per_job;
+			assoc->max_cpu_secs_per_job = 
+				max_cpu_secs_per_job;
+			if(acct) 
+				list_append(acct->assoc_list, assoc);
+			else 
+				list_append(assoc_list, assoc);
+			xstrfmtcat(assoc_str,
+				   "  A = %-10.10s"
+				   " C = %-10.10s\n",
+				   assoc->acct,
+				   assoc->cluster);		
+
+		}
+		list_iterator_destroy(itr_c);
+	}
+	list_iterator_destroy(itr);
+	list_destroy(local_account_list);
+	list_destroy(local_assoc_list);
+	list_destroy(name_list);
+	list_destroy(cluster_list);
+
+	if(!list_count(acct_list) && !list_count(assoc_list)) {
+		printf(" Nothing new added.\n");
+		goto end_it;
+	} else if(!assoc_str) {
+		printf(" Error: no associations created.\n");
+		goto end_it;
+	}
+
+	if(acct_str) {
+		printf(" Adding Account(s)\n%s", acct_str);
+		printf(" Settings\n");
+		if(description)
+			printf("  Description     = %s\n", description);
+		else
+			printf("  Description     = %s\n", "Account Name");
+			
+		if(organization)
+			printf("  Organization    = %s\n", organization);
+		else
+			printf("  Organization    = %s\n",
+			       "Parent/Account Name");
+
+		if(qos != ACCT_QOS_NOTSET)
+		   	printf("  Qos             = %s\n", acct_qos_str(qos));
+		xfree(acct_str);
+	}
+
+	if(assoc_str) {
+		printf(" Associations\n%s", assoc_str);
+		xfree(assoc_str);
+	}
+
+	if(limit_set) {
+		printf(" Settings\n");
+		if(fairshare == INFINITE)
+			printf("  Fairshare       = NONE\n");
+		else if(fairshare != NO_VAL) 
+			printf("  Fairshare       = %u\n", fairshare);
+		
+		if(max_cpu_secs_per_job == INFINITE)
+			printf("  MaxCPUSecs      = NONE\n");
+		else if(max_cpu_secs_per_job != NO_VAL) 
+			printf("  MaxCPUSecs      = %u\n",
+			       max_cpu_secs_per_job);
+		
+		if(max_jobs == INFINITE) 
+			printf("  MaxJobs         = NONE\n");
+		else if(max_jobs != NO_VAL) 
+			printf("  MaxJobs         = %u\n", max_jobs);
+		
+		if(max_nodes_per_job == INFINITE)
+			printf("  MaxNodes        = NONE\n");
+		else if(max_nodes_per_job != NO_VAL)
+			printf("  MaxNodes        = %u\n", max_nodes_per_job);
+		
+		if(max_wall_duration_per_job == INFINITE) 
+			printf("  MaxWall         = NONE\n");		
+		else if(max_wall_duration_per_job != NO_VAL) {
+			char time_buf[32];
+			mins2time_str((time_t) max_wall_duration_per_job, 
+				      time_buf, sizeof(time_buf));
+			printf("  MaxWall         = %s\n", time_buf);
+		}
+	}
+	
+	notice_thread_init();
+	if(list_count(acct_list)) 
+		rc = acct_storage_g_add_accounts(db_conn, my_uid, acct_list);
+	
+
+	if(rc == SLURM_SUCCESS) {
+		if(list_count(assoc_list)) 
+			rc = acct_storage_g_add_associations(db_conn, my_uid, 
+							     assoc_list);
+	} else {
+		printf(" error: Problem adding accounts\n");
+		rc = SLURM_ERROR;
+		notice_thread_fini();
+		goto end_it;
+	}
+	notice_thread_fini();
+	
+	if(rc == SLURM_SUCCESS) {
+		if(commit_check("Would you like to commit changes?")) {
+			acct_storage_g_commit(db_conn, 1);
+		} else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	} else {
+		printf(" error: Problem adding account associations\n");
+		rc = SLURM_ERROR;
+	}
+
+end_it:
+	list_destroy(acct_list);
+	list_destroy(assoc_list);
+		
+	xfree(parent);
+	xfree(description);
+	xfree(organization);
+
+	return rc;
+}
+
+extern int sacctmgr_list_account(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_account_cond_t *acct_cond =
+		xmalloc(sizeof(acct_account_cond_t));
+ 	List acct_list;
+	int i=0;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	acct_account_rec_t *acct = NULL;
+	acct_association_rec_t *assoc = NULL;
+	char *object;
+
+	print_field_t *field = NULL;
+
+	List format_list = list_create(slurm_destroy_char);
+	List print_fields_list; /* types are of print_field_t */
+
+	enum {
+		PRINT_ACCOUNT,
+		PRINT_CLUSTER,
+		PRINT_DESC,
+		PRINT_FAIRSHARE,
+		PRINT_ID,
+		PRINT_MAXC,
+		PRINT_MAXJ,
+		PRINT_MAXN,
+		PRINT_MAXW,
+		PRINT_ORG,
+		PRINT_QOS,
+		PRINT_PID,
+		PRINT_PNAME,
+		PRINT_PART,
+		PRINT_USER
+	};
+
+	acct_cond->acct_list = list_create(slurm_destroy_char);
+	acct_cond->description_list = list_create(slurm_destroy_char);
+	acct_cond->organization_list = list_create(slurm_destroy_char);
+	acct_cond->with_assocs = with_assoc_flag;
+
+	acct_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	acct_cond->assoc_cond->user_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->acct_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->partition_list = list_create(slurm_destroy_char);
+
+	_set_cond(&i, argc, argv, acct_cond, format_list);
+
+	if(!list_count(format_list)) {
+		addto_char_list(format_list, "A,D,O,Q");
+		if(acct_cond->with_assocs)
+			addto_char_list(format_list,
+					"C,ParentN,U,F,MaxC,MaxJ,MaxN,MaxW");
+			
+	}
+	acct_list = acct_storage_g_get_accounts(db_conn, acct_cond);	
+	destroy_acct_account_cond(acct_cond);
+
+	if(!acct_list) {
+		list_destroy(format_list);
+		return SLURM_ERROR;
+	}
+	print_fields_list = list_create(destroy_print_field);
+
+	itr = list_iterator_create(format_list);
+	while((object = list_next(itr))) {
+		field = xmalloc(sizeof(print_field_t));
+		if(!strncasecmp("Account", object, 1)) {
+			field->type = PRINT_ACCOUNT;
+			field->name = xstrdup("Account");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("Cluster", object, 1)) {
+			field->type = PRINT_CLUSTER;
+			field->name = xstrdup("Cluster");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("Description", object, 1)) {
+			field->type = PRINT_DESC;
+			field->name = xstrdup("Descr");
+			field->len = 20;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("FairShare", object, 1)) {
+			field->type = PRINT_FAIRSHARE;
+			field->name = xstrdup("FairShare");
+			field->len = 9;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("ID", object, 1)) {
+			field->type = PRINT_ID;
+			field->name = xstrdup("ID");
+			field->len = 6;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
+			field->type = PRINT_MAXC;
+			field->name = xstrdup("MaxCPUSecs");
+			field->len = 11;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxJobs", object, 4)) {
+			field->type = PRINT_MAXJ;
+			field->name = xstrdup("MaxJobs");
+			field->len = 7;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxNodes", object, 4)) {
+			field->type = PRINT_MAXN;
+			field->name = xstrdup("MaxNodes");
+			field->len = 8;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxWall", object, 4)) {
+			field->type = PRINT_MAXW;
+			field->name = xstrdup("MaxWall");
+			field->len = 11;
+			field->print_routine = print_time;
+		} else if(!strncasecmp("Organization", object, 1)) {
+			field->type = PRINT_ORG;
+			field->name = xstrdup("Org");
+			field->len = 20;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("QOS", object, 1)) {
+			field->type = PRINT_QOS;
+			field->name = xstrdup("QOS");
+			field->len = 9;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("ParentID", object, 7)) {
+			field->type = PRINT_PID;
+			field->name = xstrdup("Par ID");
+			field->len = 6;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("ParentName", object, 7)) {
+			field->type = PRINT_PNAME;
+			field->name = xstrdup("Par Name");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("User", object, 1)) {
+			field->type = PRINT_USER;
+			field->name = xstrdup("User");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else {
+			printf("Unknown field '%s'\n", object);
+			xfree(field);
+			continue;
+		}
+		list_append(print_fields_list, field);		
+	}
+	list_iterator_destroy(itr);
+
+	itr = list_iterator_create(acct_list);
+	itr2 = list_iterator_create(print_fields_list);
+	print_header(print_fields_list);
+
+	while((acct = list_next(itr))) {
+		if(acct->assoc_list && list_count(acct->assoc_list)) {
+			ListIterator itr3 =
+				list_iterator_create(acct->assoc_list);
+			
+			while((assoc = list_next(itr3))) {
+				while((field = list_next(itr2))) {
+					switch(field->type) {
+					case PRINT_ACCOUNT:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, acct->name);
+						break;
+					case PRINT_CLUSTER:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, assoc->cluster);
+						break;
+					case PRINT_DESC:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							acct->description);
+						break;
+					case PRINT_FAIRSHARE:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							assoc->fairshare);
+						break;
+					case PRINT_ID:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, assoc->id);
+						break;
+					case PRINT_MAXC:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, assoc->
+							max_cpu_secs_per_job);
+						break;
+					case PRINT_MAXJ:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, assoc->max_jobs);
+						break;
+					case PRINT_MAXN:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, assoc->
+							max_nodes_per_job);
+						break;
+					case PRINT_MAXW:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							assoc->
+							max_wall_duration_per_job);
+						break;
+					case PRINT_ORG:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							acct->organization);
+						break;
+					case PRINT_QOS:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							acct_qos_str(acct->qos));
+						break;
+					case PRINT_PID:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							assoc->parent_id);
+						break;
+					case PRINT_PNAME:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							assoc->parent_acct);
+						break;
+					case PRINT_PART:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, 
+							assoc->partition);
+						break;
+					case PRINT_USER:
+						field->print_routine(
+							SLURM_PRINT_VALUE,
+							field, assoc->user);
+						break;
+					default:
+						break;
+					}
+				}
+				list_iterator_reset(itr2);
+				printf("\n");
+			}
+			list_iterator_destroy(itr3);		
+		} else {
+			while((field = list_next(itr2))) {
+				switch(field->type) {
+				case PRINT_ACCOUNT:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, acct->name);
+					break;
+				case PRINT_CLUSTER:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_DESC:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, acct->description);
+					break;
+				case PRINT_FAIRSHARE:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_ID:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_MAXC:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_MAXJ:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_MAXN:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_MAXW:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_ORG:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, acct->organization);
+					break;
+				case PRINT_QOS:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, acct_qos_str(acct->qos));
+					break;
+				case PRINT_PID:
+					field->print_routine(
+						SLURM_PRINT_VALUE,
+						field, NULL);
+					break;
+				case PRINT_PNAME:
+					field->print_routine(
+						SLURM_PRINT_VALUE, 
+						field, NULL);
+					break;
+				case PRINT_PART:
+					field->print_routine(
+						SLURM_PRINT_VALUE, 
+						field, NULL);
+					break;
+				case PRINT_USER:
+					field->print_routine(
+						SLURM_PRINT_VALUE, 
+						field, NULL);
+					break;
+				default:
+					break;
+				}
+			}
+			list_iterator_reset(itr2);
+			printf("\n");
+		}
+	}
+
+	printf("\n");
+
+	list_iterator_destroy(itr2);
+	list_iterator_destroy(itr);
+	list_destroy(acct_list);
+	list_destroy(print_fields_list);
+
+	return rc;
+}
+
+extern int sacctmgr_modify_account(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_account_cond_t *acct_cond = 
+		xmalloc(sizeof(acct_account_cond_t));
+	acct_account_rec_t *acct = xmalloc(sizeof(acct_account_rec_t));
+	acct_association_rec_t *assoc = xmalloc(sizeof(acct_association_rec_t));
+	
+	int i=0;
+	int cond_set = 0, rec_set = 0, set = 0;
+	List ret_list = NULL;
+
+	acct_cond->acct_list = list_create(slurm_destroy_char);
+	acct_cond->description_list = list_create(slurm_destroy_char);
+	acct_cond->organization_list = list_create(slurm_destroy_char);
+
+	acct_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	acct_cond->assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->acct_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->fairshare = NO_VAL;
+	acct_cond->assoc_cond->max_cpu_secs_per_job = NO_VAL;
+	acct_cond->assoc_cond->max_jobs = NO_VAL;
+	acct_cond->assoc_cond->max_nodes_per_job = NO_VAL;
+	acct_cond->assoc_cond->max_wall_duration_per_job = NO_VAL;
+	
+	assoc->fairshare = NO_VAL;
+	assoc->max_cpu_secs_per_job = NO_VAL;
+	assoc->max_jobs = NO_VAL;
+	assoc->max_nodes_per_job = NO_VAL;
+	assoc->max_wall_duration_per_job = NO_VAL;
+
+	for (i=0; i<argc; i++) {
+		if (strncasecmp (argv[i], "Where", 5) == 0) {
+			i++;
+			cond_set = _set_cond(&i, argc, argv, acct_cond, NULL);
+		} else if (strncasecmp (argv[i], "Set", 3) == 0) {
+			i++;
+			rec_set = _set_rec(&i, argc, argv, acct, assoc);
+		} else {
+			cond_set = _set_cond(&i, argc, argv, acct_cond, NULL);
+		}
+	}
+
+	if(!rec_set) {
+		printf(" You didn't give me anything to set\n");
+		destroy_acct_account_cond(acct_cond);
+		destroy_acct_account_rec(acct);
+		destroy_acct_association_rec(assoc);
+		return SLURM_ERROR;
+	} else if(!cond_set) {
+		if(!commit_check("You didn't set any conditions with 'WHERE'.\n"
+				 "Are you sure you want to continue?")) {
+			printf("Aborted\n");
+			destroy_acct_account_cond(acct_cond);
+			destroy_acct_account_rec(acct);
+			destroy_acct_association_rec(assoc);
+			return SLURM_SUCCESS;
+		}		
+	}
+
+	notice_thread_init();
+	if(rec_set == 3 || rec_set == 1) { // process the account changes
+		if(cond_set == 2) {
+			rc = SLURM_ERROR;
+			goto assoc_start;
+		}
+		ret_list = acct_storage_g_modify_accounts(
+			db_conn, my_uid, acct_cond, acct);
+		if(ret_list && list_count(ret_list)) {
+			char *object = NULL;
+			ListIterator itr = list_iterator_create(ret_list);
+			printf(" Modified accounts...\n");
+			while((object = list_next(itr))) {
+				printf("  %s\n", object);
+			}
+			list_iterator_destroy(itr);
+		} else if(ret_list) {
+			printf(" Nothing modified\n");
+			rc = SLURM_ERROR;
+		} else {
+			printf(" Error with request\n");
+			rc = SLURM_ERROR;
+		}
+
+		if(ret_list)
+			list_destroy(ret_list);
+	}
+
+assoc_start:
+	if(rec_set == 3 || rec_set == 2) { // process the association changes
+		ret_list = acct_storage_g_modify_associations(
+			db_conn, my_uid, acct_cond->assoc_cond, assoc);
+
+		if(ret_list && list_count(ret_list)) {
+			char *object = NULL;
+			ListIterator itr = list_iterator_create(ret_list);
+			printf(" Modified account associations...\n");
+			while((object = list_next(itr))) {
+				printf("  %s\n", object);
+			}
+			list_iterator_destroy(itr);
+			set = 1;
+		} else if(ret_list) {
+			printf(" Nothing modified\n");
+		} else {
+			printf(" Error with request\n");
+			rc = SLURM_ERROR;
+		}
+
+		if(ret_list)
+			list_destroy(ret_list);
+	}
+
+	notice_thread_fini();
+	if(set) {
+		if(commit_check("Would you like to commit changes?")) 
+			acct_storage_g_commit(db_conn, 1);
+		else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	}
+	destroy_acct_account_cond(acct_cond);
+	destroy_acct_account_rec(acct);
+	destroy_acct_association_rec(assoc);	
+
+	return rc;
+}
+
+extern int sacctmgr_delete_account(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_account_cond_t *acct_cond =
+		xmalloc(sizeof(acct_account_cond_t));
+	int i=0;
+	List ret_list = NULL;
+	int set = 0;
+	
+	acct_cond->acct_list = list_create(slurm_destroy_char);
+	acct_cond->description_list = list_create(slurm_destroy_char);
+	acct_cond->organization_list = list_create(slurm_destroy_char);
+	
+	acct_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	acct_cond->assoc_cond->user_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->acct_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	acct_cond->assoc_cond->partition_list = 
+					list_create(slurm_destroy_char);
+
+	if(!(set = _set_cond(&i, argc, argv, acct_cond, NULL))) {
+		printf(" No conditions given to remove, not executing.\n");
+		destroy_acct_account_cond(acct_cond);
+		return SLURM_ERROR;
+	}
+
+	notice_thread_init();
+	if(set == 1) {
+		ret_list = acct_storage_g_remove_accounts(
+			db_conn, my_uid, acct_cond);		
+	} else if(set == 2) {
+		ret_list = acct_storage_g_remove_associations(
+			db_conn, my_uid, acct_cond->assoc_cond);
+	}
+	notice_thread_fini();
+	destroy_acct_account_cond(acct_cond);
+	
+	if(ret_list && list_count(ret_list)) {
+		char *object = NULL;
+		ListIterator itr = list_iterator_create(ret_list);
+		if(set == 1) {
+			printf(" Deleting accounts...\n");
+		} else if(set == 2) {
+			printf(" Deleting account associations...\n");
+		}
+		while((object = list_next(itr))) {
+			printf("  %s\n", object);
+		}
+		list_iterator_destroy(itr);
+		if(commit_check("Would you like to commit changes?")) {
+			acct_storage_g_commit(db_conn, 1);
+		} else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	} else if(ret_list) {
+		printf(" Nothing deleted\n");
+	} else {
+		printf(" Error with request\n");
+		rc = SLURM_ERROR;
+	} 
+
+	if(ret_list)
+		list_destroy(ret_list);
+
+	return rc;
+}
diff --git a/src/sacctmgr/association_functions.c b/src/sacctmgr/association_functions.c
new file mode 100644
index 0000000000000000000000000000000000000000..cec4ace3a0b52db86a156f640d475153ade21ffd
--- /dev/null
+++ b/src/sacctmgr/association_functions.c
@@ -0,0 +1,402 @@
+/*****************************************************************************\
+ *  association_functions.c - functions dealing with associations in the
+ *                        accounting system.
+ *****************************************************************************
+ *  Copyright (C) 2002-2008 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/sacctmgr/sacctmgr.h"
+#include "src/sacctmgr/print.h"
+
+static int _set_cond(int *start, int argc, char *argv[],
+		     acct_association_cond_t *association_cond,
+		     List format_list)
+{
+	int i, end = 0;
+	int set = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if(!end) {
+			addto_char_list(association_cond->id_list, argv[i]);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Id", 1) == 0) {
+			addto_char_list(association_cond->id_list, argv[i]+end);
+			set = 1;
+		}  else if (strncasecmp (argv[i], "Associations", 2) == 0) {
+			addto_char_list(association_cond->id_list, argv[i]+end);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Users", 1) == 0) {
+			addto_char_list(association_cond->user_list,
+					argv[i]+end);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Accounts", 2) == 0) {
+			addto_char_list(association_cond->acct_list,
+					argv[i]+end);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Clusters", 1) == 0) {
+			addto_char_list(association_cond->cluster_list,
+					argv[i]+end);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Format", 1) == 0) {
+			if(format_list)
+				addto_char_list(format_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Partitions", 4) == 0) {
+			addto_char_list(association_cond->partition_list,
+					argv[i]+end);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Parent", 4) == 0) {
+			association_cond->parent_acct =
+				strip_quotes(argv[i]+end, NULL);
+			set = 1;
+		} else {
+			printf(" Unknown condition: %s\n", argv[i]);
+		}
+	}
+	(*start) = i;
+
+	return set;
+}
+
+/* static void _print_cond(acct_association_cond_t *association_cond) */
+/* { */
+/* 	ListIterator itr = NULL; */
+/* 	char *tmp_char = NULL; */
+
+/* 	if(!association_cond) { */
+/* 		error("no acct_association_cond_t * given"); */
+/* 		return; */
+/* 	} */
+
+/* 	if(association_cond->id_list && list_count(association_cond->id_list)) { */
+/* 		itr = list_iterator_create(association_cond->id_list); */
+/* 		printf("  Id        = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("           or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(association_cond->user_list */
+/* 	   && list_count(association_cond->user_list)) { */
+/* 		itr = list_iterator_create(association_cond->user_list); */
+/* 		printf("  User      = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("           or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(association_cond->acct_list */
+/* 	   && list_count(association_cond->acct_list)) { */
+/* 		itr = list_iterator_create(association_cond->acct_list); */
+/* 		printf("  Account   = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("           or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(association_cond->cluster_list */
+/* 	   && list_count(association_cond->cluster_list)) { */
+/* 		itr = list_iterator_create(association_cond->cluster_list); */
+/* 		printf("  Cluster   = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("           or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(association_cond->partition_list */
+/* 	   && list_count(association_cond->partition_list)) { */
+/* 		itr = list_iterator_create(association_cond->partition_list); */
+/* 		printf("  Partition = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("           or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(association_cond->parent_account) */
+/* 		printf("  Parent    = %s\n", association_cond->parent_account); */
+
+/* } */
+
+/* static void _print_rec(acct_association_rec_t *association) */
+/* { */
+/* 	if(!association) { */
+/* 		error("no acct_association_rec_t * given"); */
+/* 		return; */
+/* 	} */
+	
+/* 	if(association->id)  */
+/* 		printf("  Id         = %u\n", association->id);	 */
+		
+/* 	if(association->user)  */
+/* 		printf("  User       = %s\n", association->user); */
+/* 	if(association->account)  */
+/* 		printf("  Account    = %s\n", association->account); */
+/* 	if(association->cluster)  */
+/* 		printf("  Cluster    = %s\n", association->cluster); */
+/* 	if(association->partition)  */
+/* 		printf("  Partition  = %s\n", association->partition); */
+/* 	if(association->parent_account)  */
+/* 		printf("  Parent     = %s\n", association->parent_account); */
+/* 	if(association->fairshare)  */
+/* 		printf("  FairShare  = %u\n", association->fairshare); */
+/* 	if(association->max_jobs)  */
+/* 		printf("  MaxJobs    = %u\n", association->max_jobs); */
+/* 	if(association->max_nodes_per_job)  */
+/* 		printf("  MaxNodes   = %u\n", association->max_nodes_per_job); */
+/* 	if(association->max_wall_duration_per_job) { */
+/* 		char time_buf[32]; */
+/* 		mins2time_str((time_t) association->max_wall_duration_per_job, */
+/* 			      time_buf, sizeof(time_buf)); */
+/* 		printf("  MaxWall    = %s\n", time_buf); */
+/* 	} */
+/* 	if(association->max_cpu_seconds_per_job)  */
+/* 		printf("  MaxCPUSecs = %u\n", */
+/* 		       association->max_cpu_seconds_per_job); */
+/* } */
+
+/* extern int sacctmgr_add_association(int argc, char *argv[]) */
+/* { */
+/* 	int rc = SLURM_SUCCESS; */
+
+/* 	return rc; */
+/* } */
+
+extern int sacctmgr_list_association(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_association_cond_t *assoc_cond =
+		xmalloc(sizeof(acct_association_cond_t));
+	List assoc_list = NULL;
+	acct_association_rec_t *assoc = NULL;
+	int i=0;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	char *object;
+
+	print_field_t *field = NULL;
+
+	List format_list = list_create(slurm_destroy_char);
+	List print_fields_list; /* types are of print_field_t */
+
+	enum {
+		PRINT_ACCOUNT,
+		PRINT_CLUSTER,
+		PRINT_FAIRSHARE,
+		PRINT_ID,
+		PRINT_MAXC,
+		PRINT_MAXJ,
+		PRINT_MAXN,
+		PRINT_MAXW,
+		PRINT_PID,
+		PRINT_PNAME,
+		PRINT_PART,
+		PRINT_USER
+	};
+
+	assoc_cond->id_list = list_create(slurm_destroy_char);
+	assoc_cond->user_list = list_create(slurm_destroy_char);
+	assoc_cond->acct_list = list_create(slurm_destroy_char);
+	assoc_cond->cluster_list = list_create(slurm_destroy_char);
+
+	_set_cond(&i, argc, argv, assoc_cond, format_list);
+
+	assoc_list = acct_storage_g_get_associations(db_conn, assoc_cond);
+	destroy_acct_association_cond(assoc_cond);
+	
+	if(!assoc_list) {
+		list_destroy(format_list);
+		return SLURM_ERROR;
+	}
+	print_fields_list = list_create(destroy_print_field);
+
+	if(!list_count(format_list)) 
+		addto_char_list(format_list, "C,A,U,F,MaxC,MaxJ,MaxN,MaxW");
+	
+	itr = list_iterator_create(format_list);
+	while((object = list_next(itr))) {
+		field = xmalloc(sizeof(print_field_t));
+		if(!strncasecmp("Account", object, 1)) {
+			field->type = PRINT_ACCOUNT;
+			field->name = xstrdup("Account");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("Cluster", object, 1)) {
+			field->type = PRINT_CLUSTER;
+			field->name = xstrdup("Cluster");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("FairShare", object, 1)) {
+			field->type = PRINT_FAIRSHARE;
+			field->name = xstrdup("FairShare");
+			field->len = 9;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("ID", object, 1)) {
+			field->type = PRINT_ID;
+			field->name = xstrdup("ID");
+			field->len = 6;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
+			field->type = PRINT_MAXC;
+			field->name = xstrdup("MaxCPUSecs");
+			field->len = 11;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxJobs", object, 4)) {
+			field->type = PRINT_MAXJ;
+			field->name = xstrdup("MaxJobs");
+			field->len = 7;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxNodes", object, 4)) {
+			field->type = PRINT_MAXN;
+			field->name = xstrdup("MaxNodes");
+			field->len = 8;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxWall", object, 4)) {
+			field->type = PRINT_MAXW;
+			field->name = xstrdup("MaxWall");
+			field->len = 11;
+			field->print_routine = print_time;
+		} else if(!strncasecmp("ParentID", object, 7)) {
+			field->type = PRINT_PID;
+			field->name = xstrdup("Par ID");
+			field->len = 6;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("ParentName", object, 7)) {
+			field->type = PRINT_PNAME;
+			field->name = xstrdup("Par Name");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("Partition", object, 4)) {
+			field->type = PRINT_PART;
+			field->name = xstrdup("Partition");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("User", object, 1)) {
+			field->type = PRINT_USER;
+			field->name = xstrdup("User");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else {
+			printf("Unknown field '%s'\n", object);
+			xfree(field);
+			continue;
+		}
+		list_append(print_fields_list, field);		
+	}
+	list_iterator_destroy(itr);
+
+	itr = list_iterator_create(assoc_list);
+	itr2 = list_iterator_create(print_fields_list);
+	print_header(print_fields_list);
+
+	while((assoc = list_next(itr))) {
+		while((field = list_next(itr2))) {
+			switch(field->type) {
+			case PRINT_ACCOUNT:
+				field->print_routine(SLURM_PRINT_VALUE, field, 
+						     assoc->acct);
+				break;
+			case PRINT_CLUSTER:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     assoc->cluster);
+				break;
+			case PRINT_FAIRSHARE:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     assoc->fairshare);
+				break;
+			case PRINT_ID:
+				field->print_routine(SLURM_PRINT_VALUE, field, 
+						     assoc->id);
+				break;
+			case PRINT_MAXC:
+				field->print_routine(
+					SLURM_PRINT_VALUE, field,
+					assoc->max_cpu_secs_per_job);
+				break;
+			case PRINT_MAXJ:
+				field->print_routine(SLURM_PRINT_VALUE, field, 
+						     assoc->max_jobs);
+				break;
+			case PRINT_MAXN:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     assoc->max_nodes_per_job);
+				break;
+			case PRINT_MAXW:
+				field->print_routine(
+					SLURM_PRINT_VALUE, field,
+					assoc->max_wall_duration_per_job);
+				break;
+			case PRINT_PID:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     assoc->parent_id);
+				break;
+			case PRINT_PNAME:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     assoc->parent_acct);
+				break;
+			case PRINT_PART:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     assoc->partition);
+				break;
+			case PRINT_USER:
+				field->print_routine(SLURM_PRINT_VALUE, field, 
+						     assoc->user);
+				break;
+			default:
+				break;
+			}
+		}
+		list_iterator_reset(itr2);
+		printf("\n");
+	}
+
+	printf("\n");
+
+	list_iterator_destroy(itr2);
+	list_iterator_destroy(itr);
+	list_destroy(assoc_list);
+	list_destroy(print_fields_list);
+	return rc;
+}
+
+/* extern int sacctmgr_modify_association(int argc, char *argv[]) */
+/* { */
+/* 	int rc = SLURM_SUCCESS; */
+/* 	return rc; */
+/* } */
+
+/* extern int sacctmgr_delete_association(int argc, char *argv[]) */
+/* { */
+/* 	int rc = SLURM_SUCCESS; */
+/* 	return rc; */
+/* } */
diff --git a/src/sacctmgr/cluster_functions.c b/src/sacctmgr/cluster_functions.c
new file mode 100644
index 0000000000000000000000000000000000000000..8a099cbce44662b9746c4c6c2e087614e9dde3fa
--- /dev/null
+++ b/src/sacctmgr/cluster_functions.c
@@ -0,0 +1,646 @@
+/*****************************************************************************\
+ *  cluster_functions.c - functions dealing with clusters in the
+ *                        accounting system.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/sacctmgr/sacctmgr.h"
+#include "src/sacctmgr/print.h"
+
+static int _set_cond(int *start, int argc, char *argv[],
+		     List cluster_list,
+		     List format_list)
+{
+	int i;
+	int set = 0;
+	int end = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if (strncasecmp (argv[i], "Set", 3) == 0) {
+			i--;
+			break;
+		} else if(!end) {
+			addto_char_list(cluster_list, argv[i]);
+			set = 1;
+		} else if (strncasecmp (argv[i], "Format", 1) == 0) {
+			if(format_list)
+				addto_char_list(format_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Names", 1) == 0) {
+			addto_char_list(cluster_list,
+					argv[i]+end);
+			set = 1;
+		} else {
+			printf(" Unknown condition: %s\n"
+			       "Use keyword set to modify value\n", argv[i]);
+		}
+	}
+	(*start) = i;
+
+	return set;
+}
+
+static int _set_rec(int *start, int argc, char *argv[],
+		    acct_association_rec_t *assoc)
+{
+	int i, mins;
+	int set = 0;
+	int end = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if (strncasecmp (argv[i], "Where", 5) == 0) {
+			i--;
+			break;
+		} else if(!end) {
+			printf(" Bad format on %s: End your option with "
+			       "an '=' sign\n", argv[i]);			
+		} else if (strncasecmp (argv[i], "FairShare", 1) == 0) {
+			if (get_uint(argv[i]+end, &assoc->fairshare, 
+			    "FairShare") == SLURM_SUCCESS)
+				set = 1;
+		} else if (strncasecmp (argv[i], "MaxJobs", 4) == 0) {
+			if (get_uint(argv[i]+end, &assoc->max_jobs,
+			    "MaxJobs") == SLURM_SUCCESS)
+				set = 1;
+		} else if (strncasecmp (argv[i], "MaxNodes", 4) == 0) {
+			if (get_uint(argv[i]+end, 
+			    &assoc->max_nodes_per_job,
+			    "MaxNodes") == SLURM_SUCCESS)
+				set = 1;
+		} else if (strncasecmp (argv[i], "MaxWall", 4) == 0) {
+			mins = time_str2mins(argv[i]+end);
+			if (mins != NO_VAL) {
+				assoc->max_wall_duration_per_job
+						= (uint32_t) mins;
+				set = 1;
+			} else {
+				printf(" Bad MaxWall time format: %s\n", 
+					argv[i]);
+			}
+		} else if (strncasecmp (argv[i], "MaxCPUSecs", 4) == 0) {
+			if (get_uint(argv[i]+end, 
+			     &assoc->max_cpu_secs_per_job, 
+			    "MaxCPUSecs") == SLURM_SUCCESS)
+				set = 1;
+		} else {
+			printf(" Unknown option: %s\n"
+			       " Use keyword 'where' to modify condition\n",
+			       argv[i]);
+		}
+	}
+	(*start) = i;
+
+	return set;
+
+}
+
+extern int sacctmgr_add_cluster(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	int i = 0, mins;
+	acct_cluster_rec_t *cluster = NULL;
+	List name_list = list_create(slurm_destroy_char);
+	List cluster_list = NULL;
+	uint32_t fairshare = NO_VAL; 
+	uint32_t max_cpu_secs_per_job = NO_VAL;
+	uint32_t max_jobs = NO_VAL;
+	uint32_t max_nodes_per_job = NO_VAL;
+	uint32_t max_wall_duration_per_job = NO_VAL;
+	int limit_set = 0;
+	ListIterator itr = NULL, itr_c = NULL;
+	char *name = NULL;
+
+	for (i=0; i<argc; i++) {
+		int end = parse_option_end(argv[i]);
+		if(!end) {
+			addto_char_list(name_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "FairShare", 1) == 0) {
+			fairshare = atoi(argv[i]+end);
+			limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxCPUSecs", 4) == 0) {
+			max_cpu_secs_per_job = atoi(argv[i]+end);
+			limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxJobs=", 4) == 0) {
+			max_jobs = atoi(argv[i]+end);
+			limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxNodes", 4) == 0) {
+			max_nodes_per_job = atoi(argv[i]+end);
+			limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxWall", 4) == 0) {
+			mins = time_str2mins(argv[i]+end);
+			if (mins != NO_VAL) {
+				max_wall_duration_per_job = (uint32_t) mins;
+				limit_set = 1;
+			} else {
+				printf(" Bad MaxWall time format: %s\n", 
+					argv[i]);
+			}
+		} else if (strncasecmp (argv[i], "Names", 1) == 0) {
+			addto_char_list(name_list, argv[i]+end);
+		} else {
+			printf(" Unknown option: %s\n", argv[i]);
+		}		
+	}
+
+	if(!list_count(name_list)) {
+		list_destroy(name_list);
+		printf(" Need name of cluster to add.\n"); 
+		return SLURM_ERROR;
+	} else {
+		List temp_list = NULL;
+		acct_cluster_cond_t cluster_cond;
+		char *name = NULL;
+
+		memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
+		cluster_cond.cluster_list = name_list;
+
+		temp_list = acct_storage_g_get_clusters(db_conn, &cluster_cond);
+		if(!temp_list) {
+			printf(" Problem getting clusters from database.  "
+		   	    "Contact your admin.\n");
+			return SLURM_ERROR;
+		}
+
+		itr_c = list_iterator_create(name_list);
+		itr = list_iterator_create(temp_list);
+		while((name = list_next(itr_c))) {
+			acct_cluster_rec_t *cluster_rec = NULL;
+
+			list_iterator_reset(itr);
+			while((cluster_rec = list_next(itr))) {
+				if(!strcasecmp(cluster_rec->name, name))
+					break;
+			}
+			if(cluster_rec) {
+				printf(" This cluster %s already exists.  "
+				       "Not adding.\n", name);
+				list_delete_item(itr_c);
+			}
+		}
+		list_iterator_destroy(itr);
+		list_iterator_destroy(itr_c);
+		list_destroy(temp_list);
+		if(!list_count(name_list)) {
+			list_destroy(name_list);
+			return SLURM_ERROR;
+		}
+	}
+
+	printf(" Adding Cluster(s)\n");
+	cluster_list = list_create(destroy_acct_cluster_rec);
+	itr = list_iterator_create(name_list);
+	while((name = list_next(itr))) {
+		cluster = xmalloc(sizeof(acct_cluster_rec_t));
+		cluster->name = xstrdup(name);
+		list_append(cluster_list, cluster);
+
+		printf("  Name          = %s\n", cluster->name);
+
+		cluster->default_fairshare = fairshare;		
+		cluster->default_max_cpu_secs_per_job = max_cpu_secs_per_job;
+		cluster->default_max_jobs = max_jobs;
+		cluster->default_max_nodes_per_job = max_nodes_per_job;
+		cluster->default_max_wall_duration_per_job = 
+			max_wall_duration_per_job;
+	}
+	list_iterator_destroy(itr);
+	list_destroy(name_list);
+
+	if(limit_set) {
+		printf(" User Defaults\n");
+		if(fairshare == INFINITE)
+			printf("  Fairshare       = NONE\n");
+		else if(fairshare != NO_VAL) 
+			printf("  Fairshare       = %u\n", fairshare);
+		
+		if(max_cpu_secs_per_job == INFINITE)
+			printf("  MaxCPUSecs      = NONE\n");
+		else if(max_cpu_secs_per_job != NO_VAL) 
+			printf("  MaxCPUSecs      = %u\n",
+			       max_cpu_secs_per_job);
+		
+		if(max_jobs == INFINITE) 
+			printf("  MaxJobs         = NONE\n");
+		else if(max_jobs != NO_VAL) 
+			printf("  MaxJobs         = %u\n", max_jobs);
+		
+		if(max_nodes_per_job == INFINITE)
+			printf("  MaxNodes        = NONE\n");
+		else if(max_nodes_per_job != NO_VAL)
+			printf("  MaxNodes        = %u\n", max_nodes_per_job);
+		
+		if(max_wall_duration_per_job == INFINITE) 
+			printf("  MaxWall         = NONE\n");		
+		else if(max_wall_duration_per_job != NO_VAL) {
+			char time_buf[32];
+			mins2time_str((time_t) max_wall_duration_per_job, 
+				      time_buf, sizeof(time_buf));
+			printf("  MaxWall         = %s\n", time_buf);
+		}
+	}
+
+	if(!list_count(cluster_list)) {
+		printf(" Nothing new added.\n");
+		goto end_it;
+	}
+
+	notice_thread_init();
+	rc = acct_storage_g_add_clusters(db_conn, my_uid, cluster_list);
+	notice_thread_fini();
+	if(rc == SLURM_SUCCESS) {
+		if(commit_check("Would you like to commit changes?")) {
+			acct_storage_g_commit(db_conn, 1);
+		} else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	} else {
+		printf(" error: problem adding clusters\n");
+	}
+end_it:
+	list_destroy(cluster_list);
+	
+	return rc;
+}
+
+extern int sacctmgr_list_cluster(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_cluster_cond_t *cluster_cond =
+		xmalloc(sizeof(acct_cluster_cond_t));
+	List cluster_list;
+	int i=0;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	acct_cluster_rec_t *cluster = NULL;
+	char *object;
+
+	print_field_t *field = NULL;
+
+	List format_list = list_create(slurm_destroy_char);
+	List print_fields_list; /* types are of print_field_t */
+
+	enum {
+		PRINT_CLUSTER,
+		PRINT_CHOST,
+		PRINT_CPORT,
+		PRINT_FAIRSHARE,
+		PRINT_MAXC,
+		PRINT_MAXJ,
+		PRINT_MAXN,
+		PRINT_MAXW
+	};
+
+
+	cluster_cond->cluster_list = list_create(slurm_destroy_char);
+	_set_cond(&i, argc, argv, cluster_cond->cluster_list, format_list);
+	
+	cluster_list = acct_storage_g_get_clusters(db_conn, cluster_cond);
+	destroy_acct_cluster_cond(cluster_cond);
+	
+	if(!cluster_list) {
+		list_destroy(format_list);
+		return SLURM_ERROR;
+	}
+
+	print_fields_list = list_create(destroy_print_field);
+
+	if(!list_count(format_list)) {
+		addto_char_list(format_list, 
+				"Cl,Controlh,Controlp,F,MaxC,MaxJ,MaxN,MaxW");
+	}
+
+	itr = list_iterator_create(format_list);
+	while((object = list_next(itr))) {
+		field = xmalloc(sizeof(print_field_t));
+		if(!strncasecmp("Cluster", object, 2)) {
+			field->type = PRINT_CLUSTER;
+			field->name = xstrdup("Cluster");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("ControlHost", object, 8)) {
+			field->type = PRINT_CHOST;
+			field->name = xstrdup("Control Host");
+			field->len = 12;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("ControlPort", object, 8)) {
+			field->type = PRINT_CPORT;
+			field->name = xstrdup("Control Port");
+			field->len = 12;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("FairShare", object, 1)) {
+			field->type = PRINT_FAIRSHARE;
+			field->name = xstrdup("FairShare");
+			field->len = 9;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
+			field->type = PRINT_MAXC;
+			field->name = xstrdup("MaxCPUSecs");
+			field->len = 11;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxJobs", object, 4)) {
+			field->type = PRINT_MAXJ;
+			field->name = xstrdup("MaxJobs");
+			field->len = 7;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxNodes", object, 4)) {
+			field->type = PRINT_MAXN;
+			field->name = xstrdup("MaxNodes");
+			field->len = 8;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxWall", object, 4)) {
+			field->type = PRINT_MAXW;
+			field->name = xstrdup("MaxWall");
+			field->len = 11;
+			field->print_routine = print_time;
+		} else {
+			printf("Unknown field '%s'\n", object);
+			xfree(field);
+			continue;
+		}
+		list_append(print_fields_list, field);		
+	}
+	list_iterator_destroy(itr);
+
+	itr = list_iterator_create(cluster_list);
+	itr2 = list_iterator_create(print_fields_list);
+	print_header(print_fields_list);
+
+	while((cluster = list_next(itr))) {
+		while((field = list_next(itr2))) {
+			switch(field->type) {
+			case PRINT_CLUSTER:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     cluster->name);
+				break;
+			case PRINT_CHOST:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     cluster->control_host);
+				break;
+			case PRINT_CPORT:
+				field->print_routine(SLURM_PRINT_VALUE, field,
+						     cluster->control_port);
+				break;
+			case PRINT_FAIRSHARE:
+				field->print_routine(
+					SLURM_PRINT_VALUE, field,
+					cluster->default_fairshare);
+				break;
+			case PRINT_MAXC:
+				field->print_routine(
+					SLURM_PRINT_VALUE, field,
+					cluster->default_max_cpu_secs_per_job);
+				break;
+			case PRINT_MAXJ:
+				field->print_routine(
+					SLURM_PRINT_VALUE, field, 
+					cluster->default_max_jobs);
+				break;
+			case PRINT_MAXN:
+				field->print_routine(
+					SLURM_PRINT_VALUE, field,
+					cluster->default_max_nodes_per_job);
+				break;
+			case PRINT_MAXW:
+				field->print_routine(
+					SLURM_PRINT_VALUE, field,
+					cluster->
+					default_max_wall_duration_per_job);
+				break;
+			default:
+				break;
+			}
+		}
+		list_iterator_reset(itr2);
+		printf("\n");
+	}
+
+	printf("\n");
+
+	list_iterator_destroy(itr2);
+	list_iterator_destroy(itr);
+	list_destroy(cluster_list);
+	list_destroy(print_fields_list);
+
+	return rc;
+}
+
+extern int sacctmgr_modify_cluster(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	int i=0;
+	acct_association_rec_t *assoc = xmalloc(sizeof(acct_association_rec_t));
+	acct_association_cond_t *assoc_cond =
+		xmalloc(sizeof(acct_association_cond_t));
+	int cond_set = 0, rec_set = 0, set = 0;
+	List ret_list = NULL;
+
+	assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	assoc_cond->acct_list = list_create(NULL);
+	assoc_cond->fairshare = NO_VAL;
+	assoc_cond->max_cpu_secs_per_job = NO_VAL;
+	assoc_cond->max_jobs = NO_VAL;
+	assoc_cond->max_nodes_per_job = NO_VAL;
+	assoc_cond->max_wall_duration_per_job = NO_VAL;
+	
+	assoc->fairshare = NO_VAL;
+	assoc->max_cpu_secs_per_job = NO_VAL;
+	assoc->max_jobs = NO_VAL;
+	assoc->max_nodes_per_job = NO_VAL;
+	assoc->max_wall_duration_per_job = NO_VAL;
+
+	for (i=0; i<argc; i++) {
+		if (strncasecmp (argv[i], "Where", 5) == 0) {
+			i++;
+			if(_set_cond(&i, argc, argv,
+				     assoc_cond->cluster_list, NULL))
+				cond_set = 1;
+		} else if (strncasecmp (argv[i], "Set", 3) == 0) {
+			i++;
+			if(_set_rec(&i, argc, argv, assoc))
+				rec_set = 1;
+		} else {
+			if(_set_cond(&i, argc, argv,
+				     assoc_cond->cluster_list, NULL))
+				cond_set = 1;
+		}
+	}
+
+	if(!rec_set) {
+		printf(" You didn't give me anything to set\n");
+		destroy_acct_association_rec(assoc);
+		destroy_acct_association_cond(assoc_cond);
+		return SLURM_ERROR;
+	} else if(!cond_set) {
+		if(!commit_check("You didn't set any conditions with 'WHERE'.\n"
+				 "Are you sure you want to continue?")) {
+			printf("Aborted\n");
+			destroy_acct_association_rec(assoc);
+			destroy_acct_association_cond(assoc);
+			return SLURM_SUCCESS;
+		}		
+	}
+
+	printf(" Setting\n");
+	if(rec_set) 
+		printf(" User Defaults  =\n");
+
+	if(assoc->fairshare == INFINITE)
+		printf("  Fairshare     = NONE\n");
+	else if(assoc->fairshare != NO_VAL) 
+		printf("  Fairshare     = %u\n", assoc->fairshare);
+		
+	if(assoc->max_cpu_secs_per_job == INFINITE)
+		printf("  MaxCPUSecs    = NONE\n");
+	else if(assoc->max_cpu_secs_per_job != NO_VAL) 
+		printf("  MaxCPUSecs    = %u\n",
+		       assoc->max_cpu_secs_per_job);
+		
+	if(assoc->max_jobs == INFINITE) 
+		printf("  MaxJobs       = NONE\n");
+	else if(assoc->max_jobs != NO_VAL) 
+		printf("  MaxJobs       = %u\n", assoc->max_jobs);
+		
+	if(assoc->max_nodes_per_job == INFINITE)
+		printf("  MaxNodes      = NONE\n");
+	else if(assoc->max_nodes_per_job != NO_VAL)
+		printf("  MaxNodes      = %u\n",
+		       assoc->max_nodes_per_job);
+		
+	if(assoc->max_wall_duration_per_job == INFINITE) 
+		printf("  MaxWall       = NONE\n");		
+	else if(assoc->max_wall_duration_per_job != NO_VAL) {
+		char time_buf[32];
+		mins2time_str((time_t) 
+			      assoc->max_wall_duration_per_job, 
+			      time_buf, sizeof(time_buf));
+		printf("  MaxWall       = %s\n", time_buf);
+	}
+
+	list_append(assoc_cond->acct_list, "root");
+	notice_thread_init();
+	ret_list = acct_storage_g_modify_associations(
+		db_conn, my_uid, assoc_cond, assoc);
+	
+	if(ret_list && list_count(ret_list)) {
+		char *object = NULL;
+		ListIterator itr = list_iterator_create(ret_list);
+		printf(" Modified cluster defaults for associations...\n");
+		while((object = list_next(itr))) {
+			printf("  %s\n", object);
+		}
+		list_iterator_destroy(itr);
+		set = 1;
+	} else if(ret_list) {
+		printf(" Nothing modified\n");
+	} else {
+		printf(" Error with request\n");
+		rc = SLURM_ERROR;
+	}
+
+	if(ret_list)
+		list_destroy(ret_list);
+	notice_thread_fini();
+
+	if(set) {
+		if(commit_check("Would you like to commit changes?")) 
+			acct_storage_g_commit(db_conn, 1);
+		else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	}
+	destroy_acct_association_cond(assoc_cond);
+	destroy_acct_association_rec(assoc);
+
+	return rc;
+}
+
+extern int sacctmgr_delete_cluster(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_cluster_cond_t *cluster_cond =
+		xmalloc(sizeof(acct_cluster_cond_t));
+	int i=0;
+	List ret_list = NULL;
+
+	cluster_cond->cluster_list = list_create(slurm_destroy_char);
+	
+	if(!_set_cond(&i, argc, argv, cluster_cond->cluster_list, NULL)) {
+		printf(" No conditions given to remove, not executing.\n");
+		destroy_acct_cluster_cond(cluster_cond);
+		return SLURM_ERROR;
+	}
+
+	if(!list_count(cluster_cond->cluster_list)) {
+		destroy_acct_cluster_cond(cluster_cond);
+		return SLURM_SUCCESS;
+	}
+	notice_thread_init();
+	ret_list = acct_storage_g_remove_clusters(
+		db_conn, my_uid, cluster_cond);
+	notice_thread_fini();
+
+	destroy_acct_cluster_cond(cluster_cond);
+
+	if(ret_list && list_count(ret_list)) {
+		char *object = NULL;
+		ListIterator itr = list_iterator_create(ret_list);
+		printf(" Deleting clusters...\n");
+		while((object = list_next(itr))) {
+			printf("  %s\n", object);
+		}
+		list_iterator_destroy(itr);
+		if(commit_check("Would you like to commit changes?")) {
+			acct_storage_g_commit(db_conn, 1);
+		} else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	} else if(ret_list) {
+		printf(" Nothing deleted\n");
+	} else {
+		printf(" Error with request\n");
+		rc = SLURM_ERROR;
+	}
+
+	if(ret_list)
+		list_destroy(ret_list);
+
+	return rc;
+}
diff --git a/src/sacctmgr/common.c b/src/sacctmgr/common.c
new file mode 100644
index 0000000000000000000000000000000000000000..36b2041259d0fcd1afd26f4688d82613b7a11ee7
--- /dev/null
+++ b/src/sacctmgr/common.c
@@ -0,0 +1,605 @@
+/*****************************************************************************\
+ *  common.c - definitions for functions common to all modules in sacctmgr.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/sacctmgr/sacctmgr.h"
+#include <unistd.h>
+#include <termios.h>
+
+#define FORMAT_STRING_SIZE 32
+
+static pthread_t lock_warning_thread;
+
+static void *_print_lock_warn(void *no_data)
+{
+	sleep(2);
+	printf(" Waiting for lock from other user.\n");
+
+	return NULL;
+}
+
+static void nonblock(int state)
+{
+	struct termios ttystate;
+
+	//get the terminal state
+	tcgetattr(STDIN_FILENO, &ttystate);
+
+	switch(state) {
+	case 1:
+		//turn off canonical mode
+		ttystate.c_lflag &= ~ICANON;
+		//minimum of number input read.
+		ttystate.c_cc[VMIN] = 1;
+		break;
+	default:
+		//turn on canonical mode
+		ttystate.c_lflag |= ICANON;
+	}
+	//set the terminal attributes.
+	tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);
+
+}
+
+extern int parse_option_end(char *option)
+{
+	int end = 0;
+	
+	if(!option)
+		return 0;
+
+	while(option[end] && option[end] != '=')
+		end++;
+	if(!option[end])
+		return 0;
+	end++;
+	return end;
+}
+
+/* you need to xfree whatever is sent from here */
+extern char *strip_quotes(char *option, int *increased)
+{
+	int end = 0;
+	int i=0, start=0;
+	char *meat = NULL;
+
+	if(!option)
+		return NULL;
+
+	/* first strip off the ("|')'s */
+	if (option[i] == '\"' || option[i] == '\'')
+		i++;
+	start = i;
+
+	while(option[i]) {
+		if(option[i] == '\"' || option[i] == '\'') {
+			end++;
+			break;
+		}
+		i++;
+	}
+	end += i;
+
+	meat = xmalloc((i-start)+1);
+	memcpy(meat, option+start, (i-start));
+
+	if(increased)
+		(*increased) += end;
+
+	return meat;
+}
+
+extern void addto_char_list(List char_list, char *names)
+{
+	int i=0, start=0;
+	char *name = NULL, *tmp_char = NULL;
+	ListIterator itr = list_iterator_create(char_list);
+
+	if(names && char_list) {
+		if (names[i] == '\"' || names[i] == '\'')
+			i++;
+		start = i;
+		while(names[i]) {
+			if(names[i] == '\"' || names[i] == '\'')
+				break;
+			else if(names[i] == ',') {
+				if((i-start) > 0) {
+					name = xmalloc((i-start+1));
+					memcpy(name, names+start, (i-start));
+
+					while((tmp_char = list_next(itr))) {
+						if(!strcasecmp(tmp_char, name))
+							break;
+					}
+
+					if(!tmp_char)
+						list_append(char_list, name);
+					else 
+						xfree(name);
+					list_iterator_reset(itr);
+				}
+				i++;
+				start = i;
+			}
+			i++;
+		}
+		if((i-start) > 0) {
+			name = xmalloc((i-start)+1);
+			memcpy(name, names+start, (i-start));
+			while((tmp_char = list_next(itr))) {
+				if(!strcasecmp(tmp_char, name))
+					break;
+			}
+			
+			if(!tmp_char)
+				list_append(char_list, name);
+			else 
+				xfree(name);
+		}
+	}	
+	list_iterator_destroy(itr);
+} 
+
+extern void destroy_sacctmgr_action(void *object)
+{
+	sacctmgr_action_t *action = (sacctmgr_action_t *)object;
+	
+	if(action) {
+		if(action->list)
+			list_destroy(action->list);
+			
+		switch(action->type) {
+		case SACCTMGR_ACTION_NOTSET:
+		case SACCTMGR_USER_CREATE:
+		case SACCTMGR_ACCOUNT_CREATE:
+		case SACCTMGR_CLUSTER_CREATE:
+		case SACCTMGR_ASSOCIATION_CREATE:
+			/* These only have a list so there isn't
+			 * anything else to free 
+			 */
+			break;
+		case SACCTMGR_USER_MODIFY:
+			destroy_acct_user_rec(action->rec);
+			destroy_acct_user_cond(action->cond);
+			break;
+		case SACCTMGR_USER_DELETE:
+			destroy_acct_user_cond(action->cond);
+			break;
+		case SACCTMGR_ACCOUNT_MODIFY:
+			destroy_acct_account_rec(action->rec);
+			destroy_acct_account_cond(action->cond);
+			break;
+		case SACCTMGR_ACCOUNT_DELETE:
+			destroy_acct_account_cond(action->cond);
+			break;
+		case SACCTMGR_CLUSTER_MODIFY:
+			destroy_acct_cluster_rec(action->rec);
+			destroy_acct_cluster_cond(action->cond);
+			break;
+		case SACCTMGR_CLUSTER_DELETE:
+			destroy_acct_cluster_cond(action->cond);
+			break;
+		case SACCTMGR_ASSOCIATION_MODIFY:
+			destroy_acct_association_rec(action->rec);
+			destroy_acct_association_cond(action->cond);
+			break;
+		case SACCTMGR_ASSOCIATION_DELETE:
+			destroy_acct_association_cond(action->cond);
+			break;
+		case SACCTMGR_COORD_CREATE:
+			xfree(action->rec);
+			destroy_acct_user_cond(action->cond);
+			break;
+		case SACCTMGR_COORD_DELETE:
+			xfree(action->rec);
+			destroy_acct_user_cond(action->cond);
+			break;	
+		default:
+			error("unknown action %d", action->type);
+			break;
+		}
+		xfree(action);
+	}
+}
+
+extern int notice_thread_init()
+{
+	pthread_attr_t attr;
+	
+	slurm_attr_init(&attr);
+	if(pthread_create(&lock_warning_thread, &attr, &_print_lock_warn, NULL))
+		error ("pthread_create error %m");
+	slurm_attr_destroy(&attr);
+	return SLURM_SUCCESS;
+}
+
+extern int notice_thread_fini()
+{
+	return pthread_cancel(lock_warning_thread);
+}
+
+extern int commit_check(char *warning) 
+{
+	int ans = 0;
+	char c = '\0';
+	int fd = fileno(stdin);
+	fd_set rfds;
+	struct timeval tv;
+
+	if(!rollback_flag)
+		return 1;
+
+	printf("%s (You have 30 seconds to decide)\n", warning);
+	nonblock(1);
+	while(c != 'Y' && c != 'y'
+	      && c != 'N' && c != 'n'
+	      && c != '\n') {
+		if(c) {
+			printf("Y or N please\n");
+		}
+		printf("(N/y): ");
+		fflush(stdout);
+		FD_ZERO(&rfds);
+		FD_SET(fd, &rfds);
+		/* Wait up to 30 seconds. */
+		tv.tv_sec = 30;
+		tv.tv_usec = 0;
+		if((ans = select(fd+1, &rfds, NULL, NULL, &tv)) <= 0)
+			break;
+		
+		c = getchar();
+		printf("\n");
+	}
+	nonblock(0);
+	if(ans <= 0) 
+		printf("timeout\n");
+	else if(c == 'Y' || c == 'y') 
+		return 1;			
+	
+	return 0;
+}
+
+extern acct_association_rec_t *sacctmgr_find_association(char *user,
+							 char *account,
+							 char *cluster,
+							 char *partition)
+{
+	acct_association_rec_t * assoc = NULL;
+	acct_association_cond_t assoc_cond;
+	List assoc_list = NULL;
+
+	memset(&assoc_cond, 0, sizeof(acct_association_cond_t));
+	if(account) {
+		assoc_cond.acct_list = list_create(NULL);
+		list_append(assoc_cond.acct_list, account);
+	} else {
+		error("need an account to find association");
+		return NULL;
+	}
+	if(cluster) {
+		assoc_cond.cluster_list = list_create(NULL);
+		list_append(assoc_cond.cluster_list, cluster);
+	} else {
+		if(assoc_cond.acct_list)
+			list_destroy(assoc_cond.acct_list);
+		error("need an cluster to find association");
+		return NULL;
+	}
+
+	assoc_cond.user_list = list_create(NULL);
+	if(user) 
+		list_append(assoc_cond.user_list, user);
+	else
+		list_append(assoc_cond.user_list, "");
+	
+	assoc_cond.partition_list = list_create(NULL);
+	if(partition) 
+		list_append(assoc_cond.partition_list, partition);
+	else
+		list_append(assoc_cond.partition_list, "");
+	
+	assoc_list = acct_storage_g_get_associations(db_conn, &assoc_cond);
+	
+	list_destroy(assoc_cond.acct_list);
+	list_destroy(assoc_cond.cluster_list);
+	list_destroy(assoc_cond.user_list);
+	list_destroy(assoc_cond.partition_list);
+
+	if(assoc_list)
+		assoc = list_pop(assoc_list);
+
+	list_destroy(assoc_list);
+	
+	return assoc;
+}
+
+extern acct_association_rec_t *sacctmgr_find_account_base_assoc(char *account,
+								char *cluster)
+{
+	acct_association_rec_t *assoc = NULL;
+	char *temp = "root";
+	acct_association_cond_t assoc_cond;
+	List assoc_list = NULL;
+
+	if(!cluster)
+		return NULL;
+
+	if(account)
+		temp = account;
+
+	memset(&assoc_cond, 0, sizeof(acct_association_cond_t));
+	assoc_cond.acct_list = list_create(NULL);
+	list_append(assoc_cond.cluster_list, temp);
+	assoc_cond.cluster_list = list_create(NULL);
+	list_append(assoc_cond.cluster_list, cluster);
+	assoc_cond.user_list = list_create(NULL);
+	list_append(assoc_cond.user_list, "");
+
+//	info("looking for %s %s in %d", account, cluster,
+//	     list_count(sacctmgr_association_list));
+	
+	assoc_list = acct_storage_g_get_associations(db_conn, &assoc_cond);
+
+	list_destroy(assoc_cond.acct_list);
+	list_destroy(assoc_cond.cluster_list);
+	list_destroy(assoc_cond.user_list);
+
+	if(assoc_list)
+		assoc = list_pop(assoc_list);
+
+	list_destroy(assoc_list);
+
+	return assoc;
+}
+
+extern acct_association_rec_t *sacctmgr_find_root_assoc(char *cluster)
+{
+	return sacctmgr_find_account_base_assoc(NULL, cluster);
+}
+
+extern acct_user_rec_t *sacctmgr_find_user(char *name)
+{
+	acct_user_rec_t *user = NULL;
+	acct_user_cond_t user_cond;
+	List user_list = NULL;
+	
+	if(!name)
+		return NULL;
+	
+	memset(&user_cond, 0, sizeof(acct_user_cond_t));
+	user_cond.user_list = list_create(NULL);
+	list_append(user_cond.user_list, name);
+
+	user_list = acct_storage_g_get_users(db_conn, &user_cond);
+
+	list_destroy(user_cond.user_list);
+
+	if(user_list)
+		user = list_pop(user_list);
+
+	list_destroy(user_list);
+
+	return user;
+}
+
+extern acct_account_rec_t *sacctmgr_find_account(char *name)
+{
+	acct_account_rec_t *account = NULL;
+	acct_account_cond_t account_cond;
+	List account_list = NULL;
+	
+	if(!name)
+		return NULL;
+
+	memset(&account_cond, 0, sizeof(acct_account_cond_t));
+	account_cond.acct_list = list_create(NULL);
+	list_append(account_cond.acct_list, name);
+
+	account_list = acct_storage_g_get_accounts(db_conn, &account_cond);
+	
+	list_destroy(account_cond.acct_list);
+
+	if(account_list)
+		account = list_pop(account_list);
+
+	list_destroy(account_list);
+
+	return account;
+}
+
+extern acct_cluster_rec_t *sacctmgr_find_cluster(char *name)
+{
+	acct_cluster_rec_t *cluster = NULL;
+	acct_cluster_cond_t cluster_cond;
+	List cluster_list = NULL;
+
+	if(!name)
+		return NULL;
+
+	memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
+	cluster_cond.cluster_list = list_create(NULL);
+	list_append(cluster_cond.cluster_list, name);
+
+	cluster_list = acct_storage_g_get_clusters(db_conn, &cluster_cond);
+
+	list_destroy(cluster_cond.cluster_list);
+
+	if(cluster_list) 
+		cluster = list_pop(cluster_list);
+
+	list_destroy(cluster_list);
+	
+	return cluster;
+}
+
+extern acct_association_rec_t *sacctmgr_find_association_from_list(
+	List assoc_list, char *user, char *account, 
+	char *cluster, char *partition)
+{
+	ListIterator itr = NULL;
+	acct_association_rec_t * assoc = NULL;
+	
+	if(!assoc_list)
+		return NULL;
+	
+	itr = list_iterator_create(assoc_list);
+	while((assoc = list_next(itr))) {
+		if((user && (!assoc->user || strcasecmp(user, assoc->user)))
+		   || (account && (!assoc->acct 
+				   || strcasecmp(account, assoc->acct)))
+		   || (cluster && (!assoc->cluster 
+				   || strcasecmp(cluster, assoc->cluster)))
+		   || (partition && (!assoc->partition 
+				     || strcasecmp(partition, 
+						   assoc->partition))))
+			continue;
+		break;
+	}
+	list_iterator_destroy(itr);
+	
+	return assoc;
+}
+
+extern acct_association_rec_t *sacctmgr_find_account_base_assoc_from_list(
+	List assoc_list, char *account, char *cluster)
+{
+	ListIterator itr = NULL;
+	acct_association_rec_t *assoc = NULL;
+	char *temp = "root";
+
+	if(!cluster || !assoc_list)
+		return NULL;
+
+	if(account)
+		temp = account;
+	/* info("looking for %s %s in %d", account, cluster, */
+/* 	     list_count(assoc_list)); */
+	itr = list_iterator_create(assoc_list);
+	while((assoc = list_next(itr))) {
+		/* info("is it %s %s %s", assoc->user, assoc->acct, assoc->cluster); */
+		if(assoc->user
+		   || strcasecmp(temp, assoc->acct)
+		   || strcasecmp(cluster, assoc->cluster))
+			continue;
+	/* 	info("found it"); */
+		break;
+	}
+	list_iterator_destroy(itr);
+
+	return assoc;
+}
+extern acct_user_rec_t *sacctmgr_find_user_from_list(
+	List user_list, char *name)
+{
+	ListIterator itr = NULL;
+	acct_user_rec_t *user = NULL;
+	
+	if(!name || !user_list)
+		return NULL;
+	
+	itr = list_iterator_create(user_list);
+	while((user = list_next(itr))) {
+		if(!strcasecmp(name, user->name))
+			break;
+	}
+	list_iterator_destroy(itr);
+	
+	return user;
+
+}
+
+extern acct_account_rec_t *sacctmgr_find_account_from_list(
+	List acct_list, char *name)
+{
+	ListIterator itr = NULL;
+	acct_account_rec_t *account = NULL;
+	
+	if(!name || !acct_list)
+		return NULL;
+
+	itr = list_iterator_create(acct_list);
+	while((account = list_next(itr))) {
+		if(!strcasecmp(name, account->name))
+			break;
+	}
+	list_iterator_destroy(itr);
+	
+	return account;
+
+}
+
+extern acct_cluster_rec_t *sacctmgr_find_cluster_from_list(
+	List cluster_list, char *name)
+{
+	ListIterator itr = NULL;
+	acct_cluster_rec_t *cluster = NULL;
+
+	if(!name || !cluster_list)
+		return NULL;
+
+	itr = list_iterator_create(cluster_list);
+	while((cluster = list_next(itr))) {
+		if(!strcasecmp(name, cluster->name))
+			break;
+	}
+	list_iterator_destroy(itr);
+	
+	return cluster;
+}
+
+extern int get_uint(char *in_value, uint32_t *out_value, char *type)
+{
+	char *ptr = NULL, *meat = NULL;
+	long num;
+	
+	if(!(meat = strip_quotes(in_value, NULL)))
+		return SLURM_ERROR;
+
+	num = strtol(meat, &ptr, 10);
+	if ((num == 0) && ptr && ptr[0]) {
+		error("Invalid value for %s (%s)", type, meat);
+		xfree(meat);
+		return SLURM_ERROR;
+	}
+	xfree(meat);
+	
+	if (num < 0)
+		*out_value = INFINITE;		/* flag to clear */
+	else
+		*out_value = (uint32_t) num;
+	return SLURM_SUCCESS;
+}
diff --git a/src/sacctmgr/print.c b/src/sacctmgr/print.c
new file mode 100644
index 0000000000000000000000000000000000000000..e852a4dfd3aee3b6d979e02e11f972974ee4aca1
--- /dev/null
+++ b/src/sacctmgr/print.c
@@ -0,0 +1,195 @@
+/*****************************************************************************\
+ *  print.c - definitions for all printing functions.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+#include "src/sacctmgr/print.h"
+#include "src/common/parse_time.h"
+int parsable_print = 0;
+int have_header = 1;
+
+extern void destroy_print_field(void *object)
+{
+	print_field_t *field = (print_field_t *)object;
+
+	if(field) {
+		xfree(field->name);
+		xfree(field);
+	}
+}
+
+extern void print_header(List print_fields_list)
+{
+	ListIterator itr = NULL;
+	print_field_t *object = NULL;
+
+	if(!print_fields_list || !have_header) 
+		return;
+
+	itr = list_iterator_create(print_fields_list);
+	while((object = list_next(itr))) {
+		(object->print_routine)(SLURM_PRINT_HEADLINE, object, 0);
+	}
+	list_iterator_reset(itr);
+	printf("\n");
+	if(parsable_print)
+		return;
+	while((object = list_next(itr))) {
+		(object->print_routine)(SLURM_PRINT_UNDERSCORE, object, 0);
+	}
+	list_iterator_destroy(itr);
+	printf("\n");	
+}
+
+extern void print_date(void)
+{
+	time_t now;
+
+	now = time(NULL);
+	printf("%s", ctime(&now));
+
+}
+
+extern void print_str(type_t type, print_field_t *field, char *value)
+{
+	char *print_this = value;
+
+	switch(type) {
+	case SLURM_PRINT_HEADLINE:
+		if(parsable_print)
+			printf("%s|", field->name);
+		else
+			printf("%-*.*s ", field->len, field->len, field->name);
+		break;
+	case SLURM_PRINT_UNDERSCORE:
+		if(!parsable_print)
+			printf("%-*.*s ", field->len, field->len, 
+			       "---------------------------------------");
+		break;
+	case SLURM_PRINT_VALUE:
+		if(!print_this) {
+			if(parsable_print)
+				print_this = "";
+			else
+				print_this = " ";
+		}
+
+		if(parsable_print)
+			printf("%s|", print_this);
+		else
+			printf("%-*.*s ", field->len, field->len, print_this);
+		break;
+	default:
+		if(parsable_print)
+			printf("%s|", "n/a");
+		else
+			printf("%-*s ", field->len, "n/a");
+		break;
+	}
+}
+
+extern void print_uint(type_t type, print_field_t *field, uint32_t value)
+{
+	switch(type) {
+	case SLURM_PRINT_HEADLINE:
+		if(parsable_print)
+			printf("%s|", field->name);
+		else
+			printf("%-*.*s ", field->len, field->len, field->name);
+		break;
+	case SLURM_PRINT_UNDERSCORE:
+		if(!parsable_print)
+			printf("%-*.*s ", field->len, field->len, 
+			       "---------------------------------------");
+		break;
+	case SLURM_PRINT_VALUE:
+		/* (value == unset)  || (value == cleared) */
+		if((value == NO_VAL) || (value == INFINITE)) {
+			if(parsable_print)
+				printf("|");	
+			else				
+				printf("%-*s ", field->len, " ");
+		} else {
+			if(parsable_print)
+				printf("%u|", value);	
+			else
+				printf("%*u ", field->len, value);
+		}
+		break;
+	default:
+		if(parsable_print)
+			printf("%s|", "n/a");
+		else
+			printf("%-*.*s ", field->len, field->len, "n/a");
+		break;
+	}
+}
+
+extern void print_time(type_t type, print_field_t *field, uint32_t value)
+{
+	switch(type) {
+	case SLURM_PRINT_HEADLINE:
+		if(parsable_print)
+			printf("%s|", field->name);
+		else
+			printf("%-*.*s ", field->len, field->len, field->name);
+		break;
+	case SLURM_PRINT_UNDERSCORE:
+		if(!parsable_print)
+			printf("%-*.*s ", field->len, field->len, 
+			       "---------------------------------------");
+		break;
+	case SLURM_PRINT_VALUE:
+		/* (value == unset)  || (value == cleared) */
+		if((value == NO_VAL) || (value == INFINITE)) {
+			if(parsable_print)
+				printf("|");	
+			else
+				printf("%-*s ", field->len, " ");
+		} else {
+			char time_buf[32];
+			mins2time_str((time_t) value, 
+				      time_buf, sizeof(time_buf));
+			if(parsable_print)
+				printf("%s|", time_buf);
+			else
+				printf("%*s ", field->len, time_buf);
+		}
+		break;
+	default:
+		printf("%-*.*s ", field->len, field->len, "n/a");
+		break;
+	}
+}
diff --git a/src/sacctmgr/print.h b/src/sacctmgr/print.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4f0bf760468f013ef32c9f14aeac77a8d603ab9
--- /dev/null
+++ b/src/sacctmgr/print.h
@@ -0,0 +1,93 @@
+/*****************************************************************************\
+ *  print.h - definitions for all printing functions.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+#ifndef __SACCTMGR_PRINT_H__
+#define __SACCTMGR_PRINT_H__
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_GETOPT_H
+#  include <getopt.h>
+#else
+#  include "src/common/getopt.h"
+#endif
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#  include <strings.h>
+#endif
+#include <time.h>
+#include <unistd.h>
+
+#include <slurm/slurm.h>
+
+#include "src/common/xstring.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/jobacct_common.h"
+
+typedef enum {
+	SLURM_PRINT_HEADLINE,
+	SLURM_PRINT_UNDERSCORE,
+	SLURM_PRINT_VALUE
+} type_t;
+
+typedef struct {
+	uint16_t len;  /* what is the width of the print */          
+	char *name;  /* name to be printed in header */
+	void (*print_routine) (); /* what is the function to print with  */
+	uint16_t type; /* defined in the local function */
+} print_field_t;
+
+extern int parsable_print;
+extern int have_header;
+
+extern void destroy_print_field(void *object);
+extern void print_header(List print_fields_list);
+extern void print_date(void);
+extern void print_str(type_t type, print_field_t *field, char *value);
+extern void print_uint(type_t type, print_field_t *field, uint32_t value);
+extern void print_time(type_t type, print_field_t *field, uint32_t value);
+
+#endif
diff --git a/src/sacctmgr/sacctmgr.c b/src/sacctmgr/sacctmgr.c
new file mode 100644
index 0000000000000000000000000000000000000000..c56e76ddec202171cf7f422f58a166b0ca8a738e
--- /dev/null
+++ b/src/sacctmgr/sacctmgr.c
@@ -0,0 +1,1482 @@
+/*****************************************************************************\
+ *  sacctmgr.c - administration tool for slurm's accounting. 
+ *	         provides interface to read, write, update, and configure
+ *               accounting.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/sacctmgr/sacctmgr.h"
+#include "src/sacctmgr/print.h"
+#include "src/common/xsignal.h"
+
+#define OPT_LONG_HIDE   0x102
+#define BUFFER_SIZE 4096
+
+typedef struct {
+	uint16_t admin;
+	char *def_acct;
+	char *desc;
+	uint32_t fairshare;
+	uint32_t max_cpu_secs_per_job; 
+	uint32_t max_jobs;
+	uint32_t max_nodes_per_job; 
+	uint32_t max_wall_duration_per_job;
+	char *name;
+	char *org;
+	char *part;
+	uint16_t qos;
+} sacctmgr_file_opts_t;
+
+
+char *command_name;
+int all_flag;		/* display even hidden partitions */
+int exit_code;		/* sacctmgr's exit code, =1 on any error at any time */
+int exit_flag;		/* program to terminate if =1 */
+int input_words;	/* number of words of input permitted */
+int one_liner;		/* one record per line if =1 */
+int quiet_flag;		/* quiet=1, verbose=-1, normal=0 */
+int rollback_flag;       /* immediate execute=1, else = 0 */
+int with_assoc_flag = 0;
+void *db_conn = NULL;
+uint32_t my_uid = 0;
+
+static void	_show_it (int argc, char *argv[]);
+static void	_add_it (int argc, char *argv[]);
+static void	_modify_it (int argc, char *argv[]);
+static void	_delete_it (int argc, char *argv[]);
+static void	_load_file (int argc, char *argv[]);
+static int	_get_command (int *argc, char *argv[]);
+static void     _print_version( void );
+static int	_process_command (int argc, char *argv[]);
+static void	_usage ();
+
+int 
+main (int argc, char *argv[]) 
+{
+	int error_code = SLURM_SUCCESS, i, opt_char, input_field_count;
+	char **input_fields;
+	log_options_t opts = LOG_OPTS_STDERR_ONLY ;
+
+	int option_index;
+	static struct option long_options[] = {
+		{"all",      0, 0, 'a'},
+		{"help",     0, 0, 'h'},
+		{"hide",     0, 0, OPT_LONG_HIDE},
+		{"immediate",0, 0, 'i'},
+		{"oneliner", 0, 0, 'o'},
+		{"no_header", 0, 0, 'n'},
+		{"parsable", 0, 0, 'p'},
+		{"quiet",    0, 0, 'q'},
+		{"usage",    0, 0, 'h'},
+		{"verbose",  0, 0, 'v'},
+		{"version",  0, 0, 'V'},
+		{NULL,       0, 0, 0}
+	};
+
+	command_name      = argv[0];
+	all_flag          = 0;
+	rollback_flag     = 1;
+	exit_code         = 0;
+	exit_flag         = 0;
+	input_field_count = 0;
+	quiet_flag        = 0;
+	log_init("sacctmgr", opts, SYSLOG_FACILITY_DAEMON, NULL);
+
+	if (getenv ("SACCTMGR_ALL"))
+		all_flag= 1;
+
+	while((opt_char = getopt_long(argc, argv, "ahionpqsvV",
+			long_options, &option_index)) != -1) {
+		switch (opt_char) {
+		case (int)'?':
+			fprintf(stderr, "Try \"sacctmgr --help\" "
+				"for more information\n");
+			exit(1);
+			break;
+		case (int)'a':
+			all_flag = 1;
+			break;
+		case (int)'h':
+			_usage ();
+			exit(exit_code);
+			break;
+		case OPT_LONG_HIDE:
+			all_flag = 0;
+			break;
+		case (int)'i':
+			rollback_flag = 0;
+			break;
+		case (int)'o':
+			one_liner = 1;
+			break;
+		case (int)'n':
+			have_header = 0;
+			break;
+		case (int)'p':
+			parsable_print = 1;
+			break;
+		case (int)'q':
+			quiet_flag = 1;
+			break;
+		case (int)'s':
+			with_assoc_flag = 1;
+			break;
+		case (int)'v':
+			quiet_flag = -1;
+			break;
+		case (int)'V':
+			_print_version();
+			exit(exit_code);
+			break;
+		default:
+			exit_code = 1;
+			fprintf(stderr, "getopt error, returned %c\n", 
+				opt_char);
+			exit(exit_code);
+		}
+	}
+
+	if (argc > MAX_INPUT_FIELDS)	/* bogus input, but continue anyway */
+		input_words = argc;
+	else
+		input_words = 128;
+	input_fields = (char **) xmalloc (sizeof (char *) * input_words);
+	if (optind < argc) {
+		for (i = optind; i < argc; i++) {
+			input_fields[input_field_count++] = argv[i];
+		}	
+	}
+
+	db_conn = acct_storage_g_get_connection(false, rollback_flag);
+	my_uid = getuid();
+
+	if (input_field_count)
+		exit_flag = 1;
+	else
+		error_code = _get_command (&input_field_count, input_fields);
+	while (error_code == SLURM_SUCCESS) {
+		error_code = _process_command (input_field_count, 
+					       input_fields);
+		if (error_code || exit_flag)
+			break;
+		error_code = _get_command (&input_field_count, input_fields);
+	}
+
+	acct_storage_g_close_connection(&db_conn);
+	slurm_acct_storage_fini();
+	printf("\n");
+	exit(exit_code);
+}
+
+#if !HAVE_READLINE
+/*
+ * Alternative to readline if readline is not available
+ */
+static char *
+getline(const char *prompt)
+{
+	char buf[4096];
+	char *line;
+	int len;
+	printf("%s", prompt);
+
+	fgets(buf, 4096, stdin);
+	len = strlen(buf);
+	if ((len > 0) && (buf[len-1] == '\n'))
+		buf[len-1] = '\0';
+	else
+		len++;
+	line = malloc (len * sizeof(char));
+	return strncpy(line, buf, len);
+}
+#endif
+
+/*
+ * _get_command - get a command from the user
+ * OUT argc - location to store count of arguments
+ * OUT argv - location to store the argument list
+ */
+static int 
+_get_command (int *argc, char **argv) 
+{
+	char *in_line;
+	static char *last_in_line = NULL;
+	int i, in_line_size;
+	static int last_in_line_size = 0;
+
+	*argc = 0;
+
+#if HAVE_READLINE
+	in_line = readline ("sacctmgr: ");
+#else
+	in_line = getline("sacctmgr: ");
+#endif
+	if (in_line == NULL)
+		return 0;
+	else if (strcmp (in_line, "!!") == 0) {
+		free (in_line);
+		in_line = last_in_line;
+		in_line_size = last_in_line_size;
+	} else {
+		if (last_in_line)
+			free (last_in_line);
+		last_in_line = in_line;
+		last_in_line_size = in_line_size = strlen (in_line);
+	}
+
+#if HAVE_READLINE
+	add_history(in_line);
+#endif
+
+	/* break in_line into tokens */
+	for (i = 0; i < in_line_size; i++) {
+		bool double_quote = false, single_quote = false;
+		if (in_line[i] == '\0')
+			break;
+		if (isspace ((int) in_line[i]))
+			continue;
+		if (((*argc) + 1) > MAX_INPUT_FIELDS) {	/* bogus input line */
+			exit_code = 1;
+			fprintf (stderr, 
+				 "%s: can not process over %d words\n",
+				 command_name, input_words);
+			return E2BIG;
+		}		
+		argv[(*argc)++] = &in_line[i];
+		for (i++; i < in_line_size; i++) {
+			if (in_line[i] == '\042') {
+				double_quote = !double_quote;
+				continue;
+			}
+			if (in_line[i] == '\047') {
+				single_quote = !single_quote;
+				continue;
+			}
+			if (in_line[i] == '\0')
+				break;
+			if (double_quote || single_quote)
+				continue;
+			if (isspace ((int) in_line[i])) {
+				in_line[i] = '\0';
+				break;
+			}
+		}		
+	}
+	return 0;		
+}
+
+
+static void _print_version(void)
+{
+	printf("%s %s\n", PACKAGE, SLURM_VERSION);
+	if (quiet_flag == -1) {
+		long version = slurm_api_version();
+		printf("slurm_api_version: %ld, %ld.%ld.%ld\n", version,
+			SLURM_VERSION_MAJOR(version), 
+			SLURM_VERSION_MINOR(version),
+			SLURM_VERSION_MICRO(version));
+	}
+}
+
+/*
+ * _process_command - process the user's command
+ * IN argc - count of arguments
+ * IN argv - the arguments
+ * RET 0 or errno (only for errors fatal to sacctmgr)
+ */
+static int
+_process_command (int argc, char *argv[]) 
+{
+	if (argc < 1) {
+		exit_code = 1;
+		if (quiet_flag == -1)
+			fprintf(stderr, "no input");
+	} else if (strncasecmp (argv[0], "all", 3) == 0) {
+		all_flag = 1;
+	} else if (strncasecmp (argv[0], "associations", 3) == 0) {
+		with_assoc_flag = 1;
+	} else if (strncasecmp (argv[0], "help", 2) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, 
+				 "too many arguments for keyword:%s\n",
+				 argv[0]);
+		}
+		_usage ();
+	} else if (strncasecmp (argv[0], "hide", 2) == 0) {
+		all_flag = 0;
+	} else if (strncasecmp (argv[0], "load", 2) == 0) {
+		if (argc < 2) {
+			exit_code = 1;
+			if (quiet_flag != 1)
+				fprintf(stderr, 
+				        "too few arguments for keyword:%s\n", 
+				        argv[0]);
+		} else
+			_load_file((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "oneliner", 1) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, 
+				 "too many arguments for keyword:%s\n",
+				 argv[0]);
+		}
+		one_liner = 1;
+	} else if (strncasecmp (argv[0], "quiet", 4) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, "too many arguments for keyword:%s\n",
+				 argv[0]);
+		}
+		quiet_flag = 1;
+	} else if ((strncasecmp (argv[0], "exit", 4) == 0) ||
+		   (strncasecmp (argv[0], "quit", 4) == 0)) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, 
+				 "too many arguments for keyword:%s\n", 
+				 argv[0]);
+		}
+		exit_flag = 1;
+	} else if ((strncasecmp (argv[0], "add", 3) == 0) ||
+		   (strncasecmp (argv[0], "create", 3) == 0)) {
+		if (argc < 2) {
+			exit_code = 1;
+			if (quiet_flag != 1)
+				fprintf(stderr, 
+				        "too few arguments for keyword:%s\n", 
+				        argv[0]);
+		} else
+			_add_it((argc - 1), &argv[1]);
+	} else if ((strncasecmp (argv[0], "show", 3) == 0) ||
+		   (strncasecmp (argv[0], "list", 3) == 0)) {
+		if (argc < 2) {
+			exit_code = 1;
+			if (quiet_flag != 1)
+				fprintf(stderr, 
+				        "too few arguments for keyword:%s\n", 
+				        argv[0]);
+		} else 
+			_show_it((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "modify", 1) == 0) {
+		if (argc < 2) {
+			exit_code = 1;
+			fprintf (stderr, "too few arguments for %s keyword\n",
+				 argv[0]);
+			return 0;
+		} else 		
+			_modify_it((argc - 1), &argv[1]);
+	} else if ((strncasecmp (argv[0], "delete", 3) == 0) ||
+		   (strncasecmp (argv[0], "remove", 3) == 0)) {
+		if (argc < 2) {
+			exit_code = 1;
+			fprintf (stderr, "too few arguments for %s keyword\n",
+				 argv[0]);
+			return 0;
+		} else 
+			_delete_it((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "verbose", 4) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr,
+				 "too many arguments for %s keyword\n",
+				 argv[0]);
+		}		
+		quiet_flag = -1;
+	} else if (strncasecmp (argv[0], "rollup", 2) == 0) {
+		time_t my_time = 0;
+		if (argc > 2) {
+			exit_code = 1;
+			fprintf (stderr,
+				 "too many arguments for %s keyword\n",
+				 argv[0]);
+		}
+
+		if(argc > 1)
+			my_time = parse_time(argv[1]);
+		if(acct_storage_g_roll_usage(db_conn, my_time)
+		   == SLURM_SUCCESS) {
+			if(commit_check("Would you like to commit rollup?")) {
+				acct_storage_g_commit(db_conn, 1);
+			} else {
+				printf(" Rollup Discarded\n");
+				acct_storage_g_commit(db_conn, 0);
+			}
+		}
+	} else if (strncasecmp (argv[0], "version", 4) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr,
+				 "too many arguments for %s keyword\n",
+				 argv[0]);
+		}		
+		_print_version();
+	} else {
+		exit_code = 1;
+		fprintf (stderr, "invalid keyword: %s\n", argv[0]);
+	}
+		
+	return 0;
+}
+
+/* 
+ * _add_it - add the entity per the supplied arguments 
+ * IN argc - count of arguments
+ * IN argv - list of arguments
+ */
+static void _add_it (int argc, char *argv[]) 
+{
+	int error_code = SLURM_SUCCESS;
+
+	/* First identify the entity to add */
+	if (strncasecmp (argv[0], "User", 1) == 0) {
+		error_code = sacctmgr_add_user((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Account", 1) == 0) {
+		error_code = sacctmgr_add_account((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Cluster", 1) == 0) {
+		error_code = sacctmgr_add_cluster((argc - 1), &argv[1]);
+	} else {
+		exit_code = 1;
+		fprintf(stderr, "No valid entity in add command\n");
+		fprintf(stderr, "Input line must include, ");
+		fprintf(stderr, "\"User\", \"Account\", ");
+		fprintf(stderr, "or \"Cluster\"\n");
+	}
+	
+	if (error_code) {
+		exit_code = 1;
+	}
+}
+
+/* 
+ * _show_it - list the slurm configuration per the supplied arguments 
+ * IN argc - count of arguments
+ * IN argv - list of arguments
+ */
+static void _show_it (int argc, char *argv[]) 
+{
+	int error_code = SLURM_SUCCESS;
+		
+	/* First identify the entity to list */
+	if (strncasecmp (argv[0], "User", 1) == 0) {
+		error_code = sacctmgr_list_user((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Account", 2) == 0) {
+		error_code = sacctmgr_list_account((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Association", 2) == 0) {
+		error_code = sacctmgr_list_association((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Cluster", 1) == 0) {
+		error_code = sacctmgr_list_cluster((argc - 1), &argv[1]);
+	} else {
+		exit_code = 1;
+		fprintf(stderr, "No valid entity in list command\n");
+		fprintf(stderr, "Input line must include ");
+		fprintf(stderr, "\"User\", \"Account\", \"Association\", ");
+		fprintf(stderr, "or \"Cluster\"\n");
+	} 
+	
+	if (error_code) {
+		exit_code = 1;
+	}
+}
+
+
+/* 
+ * _modify_it - modify the slurm configuration per the supplied arguments 
+ * IN argc - count of arguments
+ * IN argv - list of arguments
+ */
+static void _modify_it (int argc, char *argv[]) 
+{
+	int error_code = SLURM_SUCCESS;
+
+	/* First identify the entity to modify */
+	if (strncasecmp (argv[0], "User", 1) == 0) {
+		error_code = sacctmgr_modify_user((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Account", 1) == 0) {
+		error_code = sacctmgr_modify_account((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Cluster", 1) == 0) {
+		error_code = sacctmgr_modify_cluster((argc - 1), &argv[1]);
+	} else {
+		exit_code = 1;
+		fprintf(stderr, "No valid entity in modify command\n");
+		fprintf(stderr, "Input line must include ");
+		fprintf(stderr, "\"User\", \"Account\", ");
+		fprintf(stderr, "or \"Cluster\"\n");
+	}
+
+	if (error_code) {
+		exit_code = 1;
+	}
+}
+
+/* 
+ * _delete_it - delete the slurm configuration per the supplied arguments 
+ * IN argc - count of arguments
+ * IN argv - list of arguments
+ */
+static void _delete_it (int argc, char *argv[]) 
+{
+	int error_code = SLURM_SUCCESS;
+
+	/* First identify the entity to delete */
+	if (strncasecmp (argv[0], "User", 1) == 0) {
+		error_code = sacctmgr_delete_user((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Account", 1) == 0) {
+		error_code = sacctmgr_delete_account((argc - 1), &argv[1]);
+	} else if (strncasecmp (argv[0], "Cluster", 1) == 0) {
+		error_code = sacctmgr_delete_cluster((argc - 1), &argv[1]);
+	} else {
+		exit_code = 1;
+		fprintf(stderr, "No valid entity in delete command\n");
+		fprintf(stderr, "Input line must include ");
+		fprintf(stderr, "\"User\", \"Account\", ");
+		fprintf(stderr, "or \"Cluster\"\n");
+	}
+	
+	if (error_code) {
+		exit_code = 1;
+	}
+}
+
+static int _strip_continuation(char *buf, int len)
+{
+	char *ptr;
+	int bs = 0;
+
+	for (ptr = buf+len-1; ptr >= buf; ptr--) {
+		if (*ptr == '\\')
+			bs++;
+		else if (isspace(*ptr) && bs == 0)
+			continue;
+		else
+			break;
+	}
+	/* Check for an odd number of contiguous backslashes at
+	   the end of the line */
+	if (bs % 2 == 1) {
+		ptr = ptr + bs;
+		*ptr = '\0';
+		return (ptr - buf);
+	} else {
+		return len; /* no continuation */
+	}
+}
+
+/* Strip comments from a line by terminating the string
+ * where the comment begins.
+ * Everything after a non-escaped "#" is a comment.
+ */
+static void _strip_comments(char *line)
+{
+	int i;
+	int len = strlen(line);
+	int bs_count = 0;
+
+	for (i = 0; i < len; i++) {
+		/* if # character is preceded by an even number of
+		 * escape characters '\' */
+		if (line[i] == '#' && (bs_count%2) == 0) {
+			line[i] = '\0';
+ 			break;
+		} else if (line[i] == '\\') {
+			bs_count++;
+		} else {
+			bs_count = 0;
+		}
+	}
+}
+
+/*
+ * Strips any escape characters, "\".  If you WANT a back-slash,
+ * it must be escaped, "\\".
+ */
+static void _strip_escapes(char *line)
+{
+	int i, j;
+	int len = strlen(line);
+
+	for (i = 0, j = 0; i < len+1; i++, j++) {
+		if (line[i] == '\\')
+			i++;
+		line[j] = line[i];
+	}
+}
+
+/*
+ * Reads the next line from the "file" into buffer "buf".
+ *
+ * Concatonates together lines that are continued on
+ * the next line by a trailing "\".  Strips out comments,
+ * replaces escaped "\#" with "#", and replaces "\\" with "\".
+ */
+static int _get_next_line(char *buf, int buf_size, FILE *file)
+{
+	char *ptr = buf;
+	int leftover = buf_size;
+	int read_size, new_size;
+	int lines = 0;
+
+	while (fgets(ptr, leftover, file)) {
+		lines++;
+		_strip_comments(ptr);
+		read_size = strlen(ptr);
+		new_size = _strip_continuation(ptr, read_size);
+		if (new_size < read_size) {
+			ptr += new_size;
+			leftover -= new_size;
+		} else { /* no continuation */
+			break;
+		}
+	}
+	/* _strip_cr_nl(buf); */ /* not necessary */
+	_strip_escapes(buf);
+	
+	return lines;
+}
+
+static void _destroy_sacctmgr_file_opts(void *object)
+{
+	sacctmgr_file_opts_t *file_opts = (sacctmgr_file_opts_t *)object;
+
+	if(file_opts) {
+		xfree(file_opts->def_acct);
+		xfree(file_opts->desc);
+		xfree(file_opts->name);
+		xfree(file_opts->org);
+		xfree(file_opts->part);
+		xfree(file_opts);		
+	}
+}
+
+static sacctmgr_file_opts_t *_parse_options(char *options)
+{
+	int start=0, i=0, end=0, mins, quote = 0;
+ 	char *sub = NULL;
+	sacctmgr_file_opts_t *file_opts = xmalloc(sizeof(sacctmgr_file_opts_t));
+	char *option = NULL;
+
+	file_opts->fairshare = NO_VAL;
+	file_opts->max_cpu_secs_per_job = NO_VAL;
+	file_opts->max_jobs = NO_VAL;
+	file_opts->max_nodes_per_job = NO_VAL;
+	file_opts->max_wall_duration_per_job = NO_VAL;
+
+	while(options[i]) {
+		quote = 0;
+		start=i;
+		
+		while(options[i] && options[i] != ':' && options[i] != '\n') {
+			if(options[i] == '"') {
+				if(quote)
+					quote = 0;
+				else
+					quote = 1;
+			}
+			i++;
+		}
+		if(quote) {
+			while(options[i] && options[i] != '"') 
+				i++;
+			if(!options[i])
+				fatal("There is a problem with option "
+				      "%s with quotes.", option);
+			i++;
+		}
+		sub = xstrndup(options+start, i-start);
+		end = parse_option_end(sub);
+		
+		option = strip_quotes(sub+end, NULL);
+		
+		if(!end) {
+			if(file_opts->name) {
+				printf(" Bad format on %s: "
+				       "End your option with "
+				       "an '=' sign\n", sub);
+				_destroy_sacctmgr_file_opts(file_opts);
+				break;
+			}
+			file_opts->name = xstrdup(option);
+		} else if (strncasecmp (sub, "AdminLevel", 2) == 0) {
+			file_opts->admin = str_2_acct_admin_level(option);
+		} else if (strncasecmp (sub, "DefaultAccount", 3) == 0) {
+			file_opts->def_acct = xstrdup(option);
+		} else if (strncasecmp (sub, "Description", 3) == 0) {
+			file_opts->desc = xstrdup(option);
+		} else if (strncasecmp (sub, "FairShare", 1) == 0) {
+			if (get_uint(option, &file_opts->fairshare, 
+			    "FairShare") != SLURM_SUCCESS) {
+				printf(" Bad FairShare value: %s\n", option);
+				_destroy_sacctmgr_file_opts(file_opts);
+				break;
+			}
+		} else if (strncasecmp (sub, "MaxCPUSec", 4) == 0
+			   || strncasecmp (sub, "MaxProcSec", 4) == 0) {
+			if (get_uint(option, &file_opts->max_cpu_secs_per_job,
+			    "MaxCPUSec") != SLURM_SUCCESS) {
+				printf(" Bad MaxCPUSec value: %s\n", option);
+				_destroy_sacctmgr_file_opts(file_opts);
+				break;
+			}
+		} else if (strncasecmp (sub, "MaxJobs", 4) == 0) {
+			if (get_uint(option, &file_opts->max_jobs,
+			    "MaxJobs") != SLURM_SUCCESS) {
+				printf(" Bad MaxJobs value: %s\n", option);
+				_destroy_sacctmgr_file_opts(file_opts);
+				break;
+			}
+		} else if (strncasecmp (sub, "MaxNodes", 4) == 0) {
+			if (get_uint(option, &file_opts->max_nodes_per_job,
+			    "MaxNodes") != SLURM_SUCCESS) {
+				printf(" Bad MaxNodes value: %s\n", option);
+				_destroy_sacctmgr_file_opts(file_opts);
+				break;
+			}
+		} else if (strncasecmp (sub, "MaxWall", 4) == 0) {
+			mins = time_str2mins(option);
+			if (mins >= 0) {
+				file_opts->max_wall_duration_per_job 
+					= (uint32_t) mins;
+			} else if (strcmp(option, "-1") == 0) {
+				file_opts->max_wall_duration_per_job = -1;
+			} else {
+				printf(" Bad MaxWall time format: %s\n", 
+					option);
+				_destroy_sacctmgr_file_opts(file_opts);
+				break;
+			}
+		} else if (strncasecmp (sub, "Organization", 1) == 0) {
+			file_opts->org = xstrdup(option);
+		} else if (strncasecmp (sub, "QosLevel", 1) == 0
+			   || strncasecmp (sub, "Expedite", 1) == 0) {
+			file_opts->qos = str_2_acct_qos(option);
+		} else {
+			printf(" Unknown option: %s\n", sub);
+		}
+
+		xfree(sub);
+		xfree(option);
+
+		if(options[i] == ':')
+			i++;
+		else
+			break;
+	}
+	
+	xfree(sub);
+	xfree(option);
+
+	if(!file_opts->name) {
+		printf(" error: No name given\n");
+		_destroy_sacctmgr_file_opts(file_opts);
+	}
+	return file_opts;
+}
+
+static void _load_file (int argc, char *argv[])
+{
+	DEF_TIMERS;
+	char line[BUFFER_SIZE];
+	FILE *fd = NULL;
+	char *parent = NULL;
+	char *cluster_name = NULL;
+	char object[25];
+	int start = 0, len = 0, i = 0;
+	int lc=0, num_lines=0;
+	int rc = SLURM_SUCCESS;
+
+	sacctmgr_file_opts_t *file_opts = NULL;
+	acct_association_rec_t *assoc = NULL;
+	acct_account_rec_t *acct = NULL;
+	acct_cluster_rec_t *cluster = NULL;
+	acct_user_rec_t *user = NULL;
+
+	List curr_assoc_list = NULL;
+	List curr_acct_list = acct_storage_g_get_accounts(db_conn, NULL);
+	List curr_cluster_list = acct_storage_g_get_clusters(db_conn, NULL);
+	List curr_user_list = acct_storage_g_get_users(db_conn, NULL);
+
+	/* This will be freed in their local counter parts */
+	List acct_list = list_create(NULL);
+	List acct_assoc_list = list_create(NULL);
+	List user_list = list_create(NULL);
+	List user_assoc_list = list_create(NULL);
+
+	ListIterator itr;
+
+	List print_fields_list;
+
+	print_field_t name_field;
+	print_field_t acct_field;
+	print_field_t parent_field;
+	print_field_t fs_field;
+	print_field_t mc_field;
+	print_field_t mj_field;
+	print_field_t mn_field;
+	print_field_t mw_field;
+
+	print_field_t desc_field;
+	print_field_t org_field;
+	print_field_t qos_field;
+
+	print_field_t admin_field;
+	print_field_t dacct_field;
+	
+	int set = 0;
+	
+	fd = fopen(argv[0], "r");
+	if (fd == NULL) {
+		printf(" error: Unable to read \"%s\": %m\n", argv[0]);
+		return;
+	}
+
+	while((num_lines = _get_next_line(line, BUFFER_SIZE, fd)) > 0) {
+		lc += num_lines;
+		/* skip empty lines */
+		if (line[0] == '\0') {
+			continue;
+		}
+		len = strlen(line);
+
+		memset(object, 0, sizeof(object));
+
+		/* first find the object */
+		start=0;
+		for(i=0; i<len; i++) {
+			if(line[i] == '-') {
+				start = i;
+				if(line[i-1] == ' ') 
+					i--;
+				if(i<sizeof(object))
+					strncpy(object, line, i);
+				break;
+			} 
+		}
+		if(!object[0]) {
+			printf(" error: Misformatted line(%d): %s\n", lc, line);
+			rc = SLURM_ERROR;
+			break;
+		} 
+		while(line[start] != ' ' && start<len)
+			start++;
+		if(start>=len) {
+			printf(" error: Nothing after object "
+			       "name '%s'. line(%d)\n",
+			       object, lc);
+			rc = SLURM_ERROR;
+			break;
+			
+		}
+		start++;
+		
+		if(!strcasecmp("Machine", object) 
+		   || !strcasecmp("Cluster", object)) {
+			acct_association_cond_t assoc_cond;
+
+			if(cluster_name) {
+				printf(" You can only add one cluster "
+				       "at a time.\n");
+				rc = SLURM_ERROR;
+				break;
+			}
+			file_opts = _parse_options(line+start);
+			
+			if(!file_opts) {
+				printf(" error: Problem with line(%d)\n", lc);
+				rc = SLURM_ERROR;
+				break;
+			}
+			cluster_name = xstrdup(file_opts->name);
+			if(!sacctmgr_find_cluster_from_list(
+				   curr_cluster_list, cluster_name)) {
+				List cluster_list =
+					list_create(destroy_acct_cluster_rec);
+				cluster = xmalloc(sizeof(acct_cluster_rec_t));
+				list_append(cluster_list, cluster);
+				cluster->name = xstrdup(cluster_name);
+				cluster->default_fairshare =
+					file_opts->fairshare;		
+				cluster->default_max_cpu_secs_per_job = 
+					file_opts->max_cpu_secs_per_job;
+				cluster->default_max_jobs = file_opts->max_jobs;
+				cluster->default_max_nodes_per_job = 
+					file_opts->max_nodes_per_job;
+				cluster->default_max_wall_duration_per_job = 
+					file_opts->max_wall_duration_per_job;
+				notice_thread_init();
+				rc = acct_storage_g_add_clusters(
+					db_conn, my_uid, cluster_list);
+				notice_thread_fini();
+				list_destroy(cluster_list);
+
+				if(rc != SLURM_SUCCESS) {
+					printf(" Problem adding machine\n");
+					rc = SLURM_ERROR;
+					break;
+				}
+			}
+			info("For cluster %s", cluster_name);
+			_destroy_sacctmgr_file_opts(file_opts);
+			
+			memset(&assoc_cond, 0, sizeof(acct_association_cond_t));
+			assoc_cond.cluster_list = list_create(NULL);
+			list_append(assoc_cond.cluster_list, cluster_name);
+			curr_assoc_list = acct_storage_g_get_associations(
+				db_conn, &assoc_cond);
+			list_destroy(assoc_cond.cluster_list);
+
+			if(!curr_assoc_list) {
+				printf(" Problem getting associations "
+				       "for this cluster\n");
+				rc = SLURM_ERROR;
+				break;
+			}
+			//info("got %d assocs", list_count(curr_assoc_list));
+			continue;
+		} else if(!cluster_name) {
+			printf(" error: You need to specify a cluster name "
+			       "first with 'Cluster - name' in your file\n");
+			break;
+		}
+
+		if(!strcasecmp("Parent", object)) {
+			if(parent) 
+				xfree(parent);
+			
+			i = start;
+			while(line[i] != '\n' && i<len)
+				i++;
+			
+			if(i >= len) {
+				printf(" error: No parent name "
+				       "given line(%d)\n",
+				       lc);
+				rc = SLURM_ERROR;
+				break;
+			}
+			parent = xstrndup(line+start, i-start);
+			//info("got parent %s", parent);
+			if(!sacctmgr_find_account_base_assoc_from_list(
+				   curr_assoc_list, parent, cluster_name)
+			   && !sacctmgr_find_account_base_assoc_from_list(
+				   acct_assoc_list, parent, cluster_name)) {
+				printf(" error: line(%d) You need to add "
+				       "this parent (%s) as a child before "
+				       "you can add childern to it.\n",
+				       lc, parent);
+				break;
+			}
+			continue;
+		} else if(!parent) {
+			parent = xstrdup("root");
+			printf(" No parent given creating off root, "
+			       "If incorrect specify 'Parent - name' "
+			       "before any childern in your file\n");
+		} 
+	
+		if(!strcasecmp("Project", object)
+		   || !strcasecmp("Account", object)) {
+			file_opts = _parse_options(line+start);
+			
+			if(!file_opts) {
+				printf(" error: Problem with line(%d)\n", lc);
+				rc = SLURM_ERROR;
+				break;
+			}
+			
+			//info("got a project %s of %s", file_opts->name, parent);
+			if(!sacctmgr_find_account_from_list(
+				   curr_acct_list, file_opts->name)) {
+				acct = xmalloc(sizeof(acct_account_rec_t));
+				acct->assoc_list = NULL;	
+				acct->name = xstrdup(file_opts->name);
+				if(file_opts->desc) 
+					acct->description =
+						xstrdup(file_opts->desc);
+				else
+					acct->description = 
+						xstrdup(file_opts->name);
+				if(file_opts->org)
+					acct->organization =
+						xstrdup(file_opts->org);
+				else if(strcmp(parent, "root"))
+					acct->organization = xstrdup(parent);
+				else
+					acct->organization =
+						xstrdup(file_opts->name);
+				/* info("adding acct %s (%s) (%s)", */
+/* 				     acct->name, acct->description, */
+/* 				     acct->organization); */
+				acct->qos = file_opts->qos;
+				list_append(acct_list, acct);
+				list_append(curr_acct_list, acct);
+
+				assoc = xmalloc(sizeof(acct_association_rec_t));
+				assoc->acct = xstrdup(file_opts->name);
+				assoc->cluster = xstrdup(cluster_name);
+				assoc->parent_acct = xstrdup(parent);
+				assoc->fairshare = file_opts->fairshare;
+				assoc->max_jobs = file_opts->max_jobs;
+				assoc->max_nodes_per_job =
+					file_opts->max_nodes_per_job;
+				assoc->max_wall_duration_per_job =
+					file_opts->max_wall_duration_per_job;
+				assoc->max_cpu_secs_per_job = 
+					file_opts->max_cpu_secs_per_job;
+				list_append(acct_assoc_list, assoc);
+				/* don't add anything to the
+				   curr_assoc_list */
+			} else if(!sacctmgr_find_account_base_assoc_from_list(
+					  curr_assoc_list, file_opts->name,
+					  cluster_name) &&
+				  !sacctmgr_find_account_base_assoc_from_list(
+					  acct_assoc_list, file_opts->name,
+					  cluster_name)) {
+				assoc = xmalloc(sizeof(acct_association_rec_t));
+				assoc->acct = xstrdup(file_opts->name);
+				assoc->cluster = xstrdup(cluster_name);
+				assoc->parent_acct = xstrdup(parent);
+				assoc->fairshare = file_opts->fairshare;
+				assoc->max_jobs = file_opts->max_jobs;
+				assoc->max_nodes_per_job =
+					file_opts->max_nodes_per_job;
+				assoc->max_wall_duration_per_job =
+					file_opts->max_wall_duration_per_job;
+				assoc->max_cpu_secs_per_job = 
+					file_opts->max_cpu_secs_per_job;
+				list_append(acct_assoc_list, assoc);
+				/* don't add anything to the
+				   curr_assoc_list */
+			}
+			_destroy_sacctmgr_file_opts(file_opts);
+			continue;
+		} else if(!strcasecmp("User", object)) {
+			file_opts = _parse_options(line+start);
+			
+			if(!file_opts) {
+				printf(" error: Problem with line(%d)\n", lc);
+				rc = SLURM_ERROR;
+				break;
+			}
+			if(!sacctmgr_find_user_from_list(
+				   curr_user_list, file_opts->name)
+			   && !sacctmgr_find_user_from_list(
+				   user_list, file_opts->name)) {
+				user = xmalloc(sizeof(acct_user_rec_t));
+				user->assoc_list = NULL;
+				user->name = xstrdup(file_opts->name);
+				if(file_opts->def_acct)
+					user->default_acct = 
+						xstrdup(file_opts->def_acct);
+				else
+					user->default_acct = xstrdup(parent);
+					
+				user->qos = file_opts->qos;
+				user->admin_level = file_opts->admin;
+				
+				list_append(user_list, user);
+				/* don't add anything to the
+				   curr_user_list */
+
+				assoc = xmalloc(sizeof(acct_association_rec_t));
+				assoc->acct = xstrdup(parent);
+				assoc->cluster = xstrdup(cluster_name);
+				assoc->fairshare = file_opts->fairshare;
+				assoc->max_jobs = file_opts->max_jobs;
+				assoc->max_nodes_per_job =
+					file_opts->max_nodes_per_job;
+				assoc->max_wall_duration_per_job =
+					file_opts->max_wall_duration_per_job;
+				assoc->max_cpu_secs_per_job = 
+					file_opts->max_cpu_secs_per_job;
+				assoc->partition = xstrdup(file_opts->part);
+				assoc->user = xstrdup(file_opts->name);
+				
+				list_append(user_assoc_list, assoc);
+				/* don't add anything to the
+				   curr_assoc_list */
+			} else if(!sacctmgr_find_association_from_list(
+					  curr_assoc_list,
+					  file_opts->name, parent,
+					  cluster_name, file_opts->part)
+				&& !sacctmgr_find_association_from_list(
+					  user_assoc_list,
+					  file_opts->name, parent,
+					  cluster_name, file_opts->part)) {
+				assoc = xmalloc(sizeof(acct_association_rec_t));
+				assoc->acct = xstrdup(parent);
+				assoc->cluster = xstrdup(cluster_name);
+				assoc->fairshare = file_opts->fairshare;
+				assoc->max_jobs = file_opts->max_jobs;
+				assoc->max_nodes_per_job =
+					file_opts->max_nodes_per_job;
+				assoc->max_wall_duration_per_job =
+					file_opts->max_wall_duration_per_job;
+				assoc->max_cpu_secs_per_job = 
+					file_opts->max_cpu_secs_per_job;
+				assoc->partition = xstrdup(file_opts->part);
+				assoc->user = xstrdup(file_opts->name);
+				
+				list_append(user_assoc_list, assoc);
+				/* don't add anything to the
+				   curr_assoc_list */
+			}
+			//info("got a user %s", file_opts->name);
+			_destroy_sacctmgr_file_opts(file_opts);
+			continue;
+		} else {
+			printf(" error: Misformatted line(%d): %s\n", lc, line);
+			rc = SLURM_ERROR;
+			break;
+		}
+	}
+	fclose(fd);
+	xfree(cluster_name);
+	xfree(parent);
+
+	admin_field.name = "Admin";
+	admin_field.len = 9;
+	admin_field.print_routine = print_str;
+
+	name_field.name = "Name";
+	name_field.len = 10;
+	name_field.print_routine = print_str;
+		
+	parent_field.name = "Parent";
+	parent_field.len = 10;
+	parent_field.print_routine = print_str;
+	
+	acct_field.name = "Account";
+	acct_field.len = 10;
+	acct_field.print_routine = print_str;
+	
+	dacct_field.name = "Def Acct";
+	dacct_field.len = 10;
+	dacct_field.print_routine = print_str;
+	
+	desc_field.name = "Descr";
+	desc_field.len = 10;
+	desc_field.print_routine = print_str;
+	
+	org_field.name = "Org";
+	org_field.len = 10;
+	org_field.print_routine = print_str;
+	
+	qos_field.name = "QOS";
+	qos_field.len = 9;
+	qos_field.print_routine = print_str;
+	
+	fs_field.name = "FairShare";
+	fs_field.len = 10;
+	fs_field.print_routine = print_uint;
+
+	mc_field.name = "MaxCPUSecs";
+	mc_field.len = 10;
+	mc_field.print_routine = print_uint;
+
+	mj_field.name = "MaxJobs";
+	mj_field.len = 7;
+	mj_field.print_routine = print_uint;
+
+	mn_field.name = "MaxNodes";
+	mn_field.len = 8;
+	mn_field.print_routine = print_uint;
+
+	mw_field.name = "MaxWall";
+	mw_field.len = 7;
+	mw_field.print_routine = print_time;
+		
+	START_TIMER;
+	if(rc == SLURM_SUCCESS && list_count(acct_list)) {
+		printf("Accounts\n");
+
+		print_fields_list = list_create(NULL);
+		list_append(print_fields_list, &name_field);
+		list_append(print_fields_list, &desc_field);
+		list_append(print_fields_list, &org_field);
+		list_append(print_fields_list, &qos_field);
+
+		print_header(print_fields_list);
+
+		itr = list_iterator_create(acct_list);
+		while((acct = list_next(itr))) {
+			print_str(SLURM_PRINT_VALUE, &name_field, 
+				  acct->name);
+			print_str(SLURM_PRINT_VALUE, &desc_field, 
+				  acct->description);
+			print_str(SLURM_PRINT_VALUE, &org_field, 
+				  acct->organization);
+			print_str(SLURM_PRINT_VALUE, &qos_field, 
+				  acct_qos_str(acct->qos));
+			printf("\n");
+		}
+		list_iterator_destroy(itr);
+		list_destroy(print_fields_list);
+		rc = acct_storage_g_add_accounts(db_conn, my_uid, acct_list);
+		printf("---------------------------------------------------\n");
+		set = 1;
+	}
+	
+	if(rc == SLURM_SUCCESS && list_count(acct_assoc_list)) {
+		printf("Account Associations\n");
+
+		print_fields_list = list_create(NULL);
+		list_append(print_fields_list, &name_field);
+		list_append(print_fields_list, &parent_field);
+		list_append(print_fields_list, &fs_field);
+		list_append(print_fields_list, &mc_field);
+		list_append(print_fields_list, &mj_field);
+		list_append(print_fields_list, &mn_field);
+		list_append(print_fields_list, &mw_field);
+
+		print_header(print_fields_list);
+		
+		itr = list_iterator_create(acct_assoc_list);
+		while((assoc = list_next(itr))) {
+			print_str(SLURM_PRINT_VALUE, &name_field, assoc->acct);
+			print_str(SLURM_PRINT_VALUE, &parent_field, 
+				  assoc->parent_acct);
+			print_uint(SLURM_PRINT_VALUE, &fs_field, 
+				   assoc->fairshare);
+			print_uint(SLURM_PRINT_VALUE, &mc_field, 
+				   assoc->max_cpu_secs_per_job);
+			print_uint(SLURM_PRINT_VALUE, &mj_field, 
+				   assoc->max_jobs);
+			print_uint(SLURM_PRINT_VALUE, &mn_field, 
+				   assoc->max_nodes_per_job);
+			print_time(SLURM_PRINT_VALUE, &mw_field,
+				   assoc->max_wall_duration_per_job);
+			printf("\n");
+		}
+		list_iterator_destroy(itr);
+		list_destroy(print_fields_list);
+		
+		rc = acct_storage_g_add_associations(
+			db_conn, my_uid, acct_assoc_list);
+		printf("---------------------------------------------------\n");
+		set = 1;
+	}
+	if(rc == SLURM_SUCCESS && list_count(user_list)) {
+		printf("Users\n");
+
+		print_fields_list = list_create(NULL);
+		list_append(print_fields_list, &name_field);
+		list_append(print_fields_list, &dacct_field);
+		list_append(print_fields_list, &qos_field);
+		list_append(print_fields_list, &admin_field);
+
+		print_header(print_fields_list);
+
+		itr = list_iterator_create(user_list);
+		while((acct = list_next(itr))) {
+			print_str(SLURM_PRINT_VALUE, &name_field, user->name);
+			print_str(SLURM_PRINT_VALUE, &dacct_field, 
+				  user->default_acct);
+			print_str(SLURM_PRINT_VALUE, &qos_field, 
+				  acct_qos_str(user->qos));
+			print_str(SLURM_PRINT_VALUE, &admin_field,
+				  acct_admin_level_str(user->admin_level));
+			printf("\n");
+		}
+		list_iterator_destroy(itr);
+		list_destroy(print_fields_list);
+		
+		rc = acct_storage_g_add_users(db_conn, my_uid, user_list);
+		printf("---------------------------------------------------\n");
+		set = 1;
+	}
+
+	if(rc == SLURM_SUCCESS && list_count(user_assoc_list)) {
+		printf("User Associations\n");
+
+		print_fields_list = list_create(NULL);
+		list_append(print_fields_list, &name_field);
+		list_append(print_fields_list, &acct_field);
+		list_append(print_fields_list, &fs_field);
+		list_append(print_fields_list, &mc_field);
+		list_append(print_fields_list, &mj_field);
+		list_append(print_fields_list, &mn_field);
+		list_append(print_fields_list, &mw_field);
+
+		print_header(print_fields_list);
+		
+		itr = list_iterator_create(user_assoc_list);
+		while((assoc = list_next(itr))) {
+			print_str(SLURM_PRINT_VALUE, &name_field, assoc->user);
+			print_str(SLURM_PRINT_VALUE, &acct_field, assoc->acct);
+			print_uint(SLURM_PRINT_VALUE, &fs_field, 
+				   assoc->fairshare);
+			print_uint(SLURM_PRINT_VALUE, &mc_field, 
+				   assoc->max_cpu_secs_per_job);
+			print_uint(SLURM_PRINT_VALUE, &mj_field, 
+				   assoc->max_jobs);
+			print_uint(SLURM_PRINT_VALUE, &mn_field, 
+				   assoc->max_nodes_per_job);
+			print_uint(SLURM_PRINT_VALUE, &mw_field,
+				   assoc->max_wall_duration_per_job);
+			printf("\n");
+		}
+		list_iterator_destroy(itr);
+		list_destroy(print_fields_list);
+	
+		rc = acct_storage_g_add_associations(
+			db_conn, my_uid, user_assoc_list);
+		printf("---------------------------------------------------\n");
+		set = 1;
+	}
+	END_TIMER2("add cluster");
+		
+	info("Done adding cluster in %s", TIME_STR);
+		
+	if(rc == SLURM_SUCCESS) {
+		if(set) {
+			if(commit_check("Would you like to commit changes?")) {
+				acct_storage_g_commit(db_conn, 1);
+			} else {
+				printf(" Changes Discarded\n");
+				acct_storage_g_commit(db_conn, 0);
+			}
+		} else {
+			printf(" Nothing new added.\n");
+		}
+	} else {
+		printf(" error: Problem with requests.\n");
+	}
+
+	list_destroy(acct_list);
+	list_destroy(acct_assoc_list);
+	list_destroy(user_list);
+	list_destroy(user_assoc_list);
+	if(curr_acct_list)
+		list_destroy(curr_acct_list);
+	if(curr_assoc_list)
+		list_destroy(curr_assoc_list);
+	if(curr_cluster_list)
+		list_destroy(curr_cluster_list);
+	if(curr_user_list)
+		list_destroy(curr_user_list);
+}
+
+/* _usage - show the valid sacctmgr commands */
+void _usage () {
+	printf ("\
+sacctmgr [<OPTION>] [<COMMAND>]                                            \n\
+    Valid <OPTION> values are:                                             \n\
+     -a or --all: equivalent to \"all\" command                            \n\
+     -h or --help: equivalent to \"help\" command                          \n\
+     --hide: equivalent to \"hide\" command                                \n\
+     -i or --immediate: commit changes immediately                         \n\
+     -o or --oneliner: equivalent to \"oneliner\" command                  \n\
+     -q or --quiet: equivalent to \"quiet\" command                        \n\
+     -s or --associations: equivalent to \"associations\" command          \n\
+     -v or --verbose: equivalent to \"verbose\" command                    \n\
+     -V or --version: equivalent to \"version\" command                    \n\
+                                                                           \n\
+  <keyword> may be omitted from the execute line and sacctmgr will execute \n\
+  in interactive mode. It will process commands as entered until explicitly\n\
+  terminated.                                                              \n\
+                                                                           \n\
+    Valid <COMMAND> values are:                                            \n\
+     all                      display information about all entities,      \n\
+                              including hidden/deleted ones.               \n\
+     add <ENTITY> <SPECS>     add entity                                   \n\
+     associations             when using show/list will list the           \n\
+                              associations associated with the entity.     \n\
+     delete <ENTITY> <SPECS>  delete the specified entity(s)               \n\
+     exit                     terminate sacctmgr                           \n\
+     help                     print this description of use.               \n\
+     hide                     do not display information about             \n\
+                              hidden/deleted entities.                     \n\
+     list <ENTITY> [<SPECS>]  display info of identified entity, default   \n\
+                              is display all.                              \n\
+     modify <ENTITY> <SPECS>  modify entity                                \n\
+     no_header                no header will be added to the beginning of  \n\
+                              output.                                      \n\
+     oneliner                 report output one record per line.           \n\
+     quiet                    print no messages other than error messages. \n\
+     quit                     terminate this command.                      \n\
+     parsable                 output will be | delimited                   \n\
+     show                     same as list                                 \n\
+     verbose                  enable detailed logging.                     \n\
+     version                  display tool version number.                 \n\
+     !!                       Repeat the last command entered.             \n\
+                                                                           \n\
+  <ENTITY> may be \"cluster\", \"account\", or \"user\".                   \n\
+                                                                           \n\
+  <SPECS> are different for each command entity pair.                      \n\
+       list account       - Clusters=, Descriptions=, Format=, Names=,     \n\
+                            Organizations=, Parents=, and WithAssocs       \n\
+       add account        - Clusters=, Description=, Fairshare=,           \n\
+                            MaxCPUSecs=, MaxJobs=, MaxNodes=, MaxWall=,    \n\
+                            Names=, Organization=, Parent=, and QosLevel   \n\
+       modify account     - (set options) Description=, Fairshare=,        \n\
+                            MaxCPUSecs=, MaxJobs=, MaxNodes=, MaxWall=,    \n\
+                            Organization=, Parent=, and QosLevel=          \n\
+                            (where options) Clusters=, Descriptions=,      \n\
+                            Names=, Organizations=, Parent=, and QosLevel= \n\
+       delete account     - Clusters=, Descriptions=, Names=,              \n\
+                            Organizations=, and Parents=                   \n\
+                                                                           \n\
+       list associations  - Accounts=, Clusters=, Format=, ID=,            \n\
+                            Partitions=, Parent=, Users=                   \n\
+                                                                           \n\
+       list cluster       - Names= Format=                                 \n\
+       add cluster        - Fairshare=, MaxCPUSecs=,                       \n\
+                            MaxJobs=, MaxNodes=, MaxWall=, and Names=      \n\
+       modify cluster     - (set options) Fairshare=, MaxCPUSecs=,         \n\
+                            MaxJobs=, MaxNodes=, and MaxWall=              \n\
+                            (where options) Names=                         \n\
+       delete cluster     - Names=                                         \n\
+                                                                           \n\
+       list user          - AdminLevel=, DefaultAccounts=, Format=, Names=,\n\
+                            QosLevel=, and WithAssocs                      \n\
+       add user           - Accounts=, AdminLevel=, Clusters=,             \n\
+                            DefaultAccount=, Fairshare=, MaxCPUSecs=,      \n\
+                            MaxJobs=, MaxNodes=, MaxWall=, Names=,         \n\
+                            Partitions=, and QosLevel=                     \n\
+       modify user        - (set options) AdminLevel=, DefaultAccount=,    \n\
+                            Fairshare=, MaxCPUSecs=, MaxJobs=,             \n\
+                            MaxNodes=, MaxWall=, and QosLevel=             \n\
+                            (where options) Accounts=, AdminLevel=,        \n\
+                            Clusters=, DefaultAccounts=, Names=,           \n\
+                            Partitions=, and QosLevel=                     \n\
+       delete user        - Accounts=, AdminLevel=, Clusters=,             \n\
+                            DefaultAccounts=, and Names=                   \n\
+                                                                           \n\
+                                                                           \n\
+  All commands entitys, and options are case-insensitive.               \n\n");
+	
+}
+
diff --git a/src/sacctmgr/sacctmgr.h b/src/sacctmgr/sacctmgr.h
new file mode 100644
index 0000000000000000000000000000000000000000..00b665f568c23b17a77549549f9b6f187a3b9acd
--- /dev/null
+++ b/src/sacctmgr/sacctmgr.h
@@ -0,0 +1,185 @@
+/*****************************************************************************\
+ *  sacctmgr.h - definitions for all sacctmgr modules.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef __SACCTMGR_H__
+#define __SACCTMGR_H__
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_GETOPT_H
+#  include <getopt.h>
+#else
+#  include "src/common/getopt.h"
+#endif
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#  include <strings.h>
+#endif
+#include <time.h>
+#include <unistd.h>
+
+#if HAVE_READLINE
+#  include <readline/readline.h>
+#  include <readline/history.h>
+#endif
+
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#else  /* !HAVE_INTTYPES_H */
+#  if HAVE_STDINT_H
+#    include <stdint.h>
+#  endif
+#endif  /* HAVE_INTTYPES_H */
+
+#include <slurm/slurm.h>
+
+#include "src/common/jobacct_common.h"
+#include "src/common/parse_time.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/xstring.h"
+
+#define CKPT_WAIT	10
+#define	MAX_INPUT_FIELDS 128
+
+typedef enum {
+	SACCTMGR_ACTION_NOTSET,
+	SACCTMGR_USER_CREATE,
+	SACCTMGR_USER_MODIFY,
+	SACCTMGR_USER_DELETE,
+	SACCTMGR_ACCOUNT_CREATE,
+	SACCTMGR_ACCOUNT_MODIFY,
+	SACCTMGR_ACCOUNT_DELETE,
+	SACCTMGR_CLUSTER_CREATE,
+	SACCTMGR_CLUSTER_MODIFY,
+	SACCTMGR_CLUSTER_DELETE,
+	SACCTMGR_ASSOCIATION_CREATE,
+	SACCTMGR_ASSOCIATION_MODIFY,
+	SACCTMGR_ASSOCIATION_DELETE,
+	SACCTMGR_COORD_CREATE,
+	SACCTMGR_COORD_DELETE
+} sacctmgr_action_type_t;
+
+typedef struct {
+	sacctmgr_action_type_t type;
+	void *cond; /* if the action has a condition typecast to an
+		     * account_*_cond_t * */
+	void *rec; /* if the action has a record typecast to an
+		    * account_*_rec_t * or char * for type COORD */
+	List list; /* if the action has a list */
+} sacctmgr_action_t;
+
+extern char *command_name;
+extern int exit_code;	/* sacctmgr's exit code, =1 on any error at any time */
+extern int exit_flag;	/* program to terminate if =1 */
+extern int input_words;	/* number of words of input permitted */
+extern int one_liner;	/* one record per line if =1 */
+extern int quiet_flag;	/* quiet=1, verbose=-1, normal=0 */
+extern int rollback_flag;/* immediate execute=0, else = 1 */
+extern int with_assoc_flag;/* show acct/user associations flag */
+extern void *db_conn;
+extern uint32_t my_uid;
+
+extern int sacctmgr_add_association(int argc, char *argv[]);
+extern int sacctmgr_add_user(int argc, char *argv[]);
+extern int sacctmgr_add_account(int argc, char *argv[]);
+extern int sacctmgr_add_cluster(int argc, char *argv[]);
+
+extern int sacctmgr_list_association(int argc, char *argv[]);
+extern int sacctmgr_list_user(int argc, char *argv[]);
+extern int sacctmgr_list_account(int argc, char *argv[]);
+extern int sacctmgr_list_cluster(int argc, char *argv[]);
+
+extern int sacctmgr_modify_association(int argc, char *argv[]);
+extern int sacctmgr_modify_user(int argc, char *argv[]);
+extern int sacctmgr_modify_account(int argc, char *argv[]);
+extern int sacctmgr_modify_cluster(int argc, char *argv[]);
+
+extern int sacctmgr_delete_association(int argc, char *argv[]);
+extern int sacctmgr_delete_user(int argc, char *argv[]);
+extern int sacctmgr_delete_account(int argc, char *argv[]);
+extern int sacctmgr_delete_cluster(int argc, char *argv[]);
+
+/* common.c */
+extern int parse_option_end(char *option);
+extern char *strip_quotes(char *option, int *increased);
+extern void addto_char_list(List char_list, char *names);
+extern void destroy_sacctmgr_action(void *object);
+extern int notice_thread_init();
+extern int notice_thread_fini();
+extern int commit_check(char *warning);
+extern int get_uint(char *in_value, uint32_t *out_value, char *type);
+
+/* you need to free the objects returned from these functions */
+extern acct_association_rec_t *sacctmgr_find_association(char *user,
+							 char *account,
+							 char *cluster,
+							 char *partition);
+extern acct_association_rec_t *sacctmgr_find_account_base_assoc(
+	char *account, char *cluster);
+extern acct_association_rec_t *sacctmgr_find_root_assoc(char *cluster);
+extern acct_user_rec_t *sacctmgr_find_user(char *name);
+extern acct_account_rec_t *sacctmgr_find_account(char *name);
+extern acct_cluster_rec_t *sacctmgr_find_cluster(char *name);
+
+/* do not free any of the object returned from these functions since
+ * they are pointing to an object in the list given 
+ */
+
+extern acct_association_rec_t *sacctmgr_find_association_from_list(
+	List assoc_list, char *user, char *account, 
+	char *cluster, char *partition);
+extern acct_association_rec_t *sacctmgr_find_account_base_assoc_from_list(
+	List assoc_list, char *account, char *cluster);
+extern acct_user_rec_t *sacctmgr_find_user_from_list(
+	List user_list, char *name);
+extern acct_account_rec_t *sacctmgr_find_account_from_list(
+	List acct_list, char *name);
+extern acct_cluster_rec_t *sacctmgr_find_cluster_from_list(
+	List cluster_list, char *name);
+
+
+#endif
diff --git a/src/sacctmgr/user_functions.c b/src/sacctmgr/user_functions.c
new file mode 100644
index 0000000000000000000000000000000000000000..5891753a8beb0313b591d9c3865c5a0e1e04a6df
--- /dev/null
+++ b/src/sacctmgr/user_functions.c
@@ -0,0 +1,1224 @@
+/*****************************************************************************\
+ *  user_functions.c - functions dealing with users in the accounting system.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/sacctmgr/sacctmgr.h"
+#include "src/sacctmgr/print.h"
+
+static int _set_cond(int *start, int argc, char *argv[],
+		     acct_user_cond_t *user_cond,
+		     List format_list)
+{
+	int i;
+	int u_set = 0;
+	int a_set = 0;
+	int end = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if (strncasecmp (argv[i], "Set", 3) == 0) {
+			i--;
+			break;
+		} else if (strncasecmp (argv[i], "WithAssoc", 4) == 0) {
+			user_cond->with_assocs = 1;
+		} else if(!end) {
+			addto_char_list(user_cond->user_list, argv[i]);
+			addto_char_list(user_cond->assoc_cond->user_list,
+					argv[i]);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Account", 2) == 0) {
+			addto_char_list(user_cond->assoc_cond->acct_list,
+					argv[i]+end);
+			a_set = 1;
+		} else if (strncasecmp (argv[i], "AdminLevel", 2) == 0) {
+			user_cond->admin_level = 
+				str_2_acct_admin_level(argv[i]+end);
+			u_set = 1;			
+		} else if (strncasecmp (argv[i], "Clusters", 1) == 0) {
+			addto_char_list(user_cond->assoc_cond->cluster_list,
+					argv[i]+end);
+			a_set = 1;
+		} else if (strncasecmp (argv[i], "DefaultAccount", 1) == 0) {
+			addto_char_list(user_cond->def_acct_list,
+					argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Format", 1) == 0) {
+			if(format_list)
+				addto_char_list(format_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Names", 1) == 0
+			   || strncasecmp (argv[i], "Users", 1) == 0) {
+			addto_char_list(user_cond->user_list, argv[i]+end);
+			addto_char_list(user_cond->assoc_cond->user_list,
+					argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "Partition", 3) == 0) {
+			addto_char_list(user_cond->assoc_cond->partition_list, 
+					argv[i]+end);
+			a_set = 1;
+		} else if (strncasecmp (argv[i], "QosLevel", 1) == 0) {
+			user_cond->qos = str_2_acct_qos(argv[i]+end);
+			u_set = 1;
+		} else {
+			printf(" Unknown condition: %s\n"
+			       " Use keyword 'set' to modify value\n", argv[i]);
+		}		
+	}	
+	(*start) = i;
+
+	if(a_set) {
+		return 2;
+	} else if(u_set)
+		return 1;
+
+	return 0;
+}
+
+static int _set_rec(int *start, int argc, char *argv[],
+		    acct_user_rec_t *user,
+		    acct_association_rec_t *association)
+{
+	int i, mins;
+	int u_set = 0;
+	int a_set = 0;
+	int end = 0;
+
+	for (i=(*start); i<argc; i++) {
+		end = parse_option_end(argv[i]);
+		if (strncasecmp (argv[i], "Where", 5) == 0) {
+			i--;
+			break;
+		} else if(!end) {
+			printf(" Bad format on %s: End your option with "
+			       "an '=' sign\n", argv[i]);
+		} else if (strncasecmp (argv[i], "AdminLevel", 2) == 0) {
+			user->admin_level = 
+				str_2_acct_admin_level(argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "DefaultAccount", 1) == 0) {
+			user->default_acct = xstrdup(argv[i]+end);
+			u_set = 1;
+		} else if (strncasecmp (argv[i], "FairShare", 1) == 0) {
+			if (get_uint(argv[i]+end, &association->fairshare, 
+			    "FairShare") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxCPUSec", 4) == 0) {
+			if (get_uint(argv[i]+end, 
+			     &association->max_cpu_secs_per_job, 
+			    "MaxCPUSec") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxJobs", 4) == 0) {
+			if (get_uint(argv[i]+end, &association->max_jobs, 
+			    "MaxJobs") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxNodes", 4) == 0) {
+			if (get_uint(argv[i]+end,
+			    &association->max_nodes_per_job, 
+			    "MaxNodes") == SLURM_SUCCESS)
+				a_set = 1;
+		} else if (strncasecmp (argv[i], "MaxWall", 4) == 0) {
+			mins = time_str2mins(argv[i]+end);
+			if (mins != NO_VAL) {
+				association->max_wall_duration_per_job 
+					= (uint32_t) mins;
+				a_set = 1;
+			} else {
+				printf(" Bad MaxWall time format: %s\n", 
+					argv[i]);
+			}
+		} else if (strncasecmp (argv[i], "QosLevel", 1) == 0) {
+			user->qos = str_2_acct_qos(argv[i]+end);
+			u_set = 1;
+		} else {
+			printf(" Unknown option: %s\n"
+			       " Use keyword 'where' to modify condition\n",
+			       argv[i]);
+		}		
+	}	
+	(*start) = i;
+
+	if(u_set && a_set)
+		return 3;
+	else if(u_set)
+		return 1;
+	else if(a_set)
+		return 2;
+	return 0;
+}
+
+/* static void _print_cond(acct_user_cond_t *user_cond) */
+/* { */
+/* 	ListIterator itr = NULL; */
+/* 	char *tmp_char = NULL; */
+
+/* 	if(!user_cond) { */
+/* 		error("no acct_user_cond_t * given"); */
+/* 		return; */
+/* 	} */
+
+/* 	if(user_cond->user_list && list_count(user_cond->user_list)) { */
+/* 		itr = list_iterator_create(user_cond->user_list); */
+/* 		printf("  Names           = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("                 or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(user_cond->def_acct_list */
+/* 	   && list_count(user_cond->def_acct_list)) { */
+/* 		itr = list_iterator_create(user_cond->def_acct_list); */
+/* 		printf("  Default Account = %s\n", (char *)list_next(itr)); */
+/* 		while((tmp_char = list_next(itr))) { */
+/* 			printf("                 or %s\n", tmp_char); */
+/* 		} */
+/* 	} */
+
+/* 	if(user_cond->qos != ACCT_QOS_NOTSET) */
+/* 		printf("  Qos        = %s\n",  */
+/* 		       acct_qos_str(user_cond->qos)); */
+
+/* 	if(user_cond->admin_level != ACCT_ADMIN_NOTSET) */
+/* 		printf("  Admin Level     = %s\n",  */
+/* 		       acct_admin_level_str(user_cond->admin_level)); */
+/* } */
+
+/* static void _print_rec(acct_user_rec_t *user) */
+/* { */
+/* 	if(!user) { */
+/* 		error("no acct_user_rec_t * given"); */
+/* 		return; */
+/* 	} */
+	
+/* 	if(user->name)  */
+/* 		printf("  Name            = %s\n", user->name);	 */
+		
+/* 	if(user->default_acct)  */
+/* 		printf("  Default Account = %s\n", user->default_acct); */
+		
+/* 	if(user->qos != ACCT_QOS_NOTSET) */
+/* 		printf("  Qos        = %s\n",  */
+/* 		       acct_qos_str(user->qos)); */
+
+/* 	if(user->admin_level != ACCT_ADMIN_NOTSET) */
+/* 		printf("  Admin Level     = %s\n",  */
+/* 		       acct_admin_level_str(user->admin_level)); */
+/* } */
+
+extern int sacctmgr_add_user(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	int i=0;
+	ListIterator itr = NULL;
+	ListIterator itr_a = NULL;
+	ListIterator itr_c = NULL;
+	ListIterator itr_p = NULL;
+	acct_user_rec_t *user = NULL;
+	acct_association_rec_t *assoc = NULL;
+	char *default_acct = NULL;
+	acct_association_cond_t *assoc_cond = NULL;
+	acct_association_cond_t query_assoc_cond;
+	acct_qos_level_t qos = ACCT_QOS_NOTSET;
+	acct_admin_level_t admin_level = ACCT_ADMIN_NOTSET;
+	char *name = NULL, *account = NULL, *cluster = NULL, *partition = NULL;
+	int partition_set = 0;
+	List user_list = NULL;
+	List assoc_list = NULL;
+	List local_assoc_list = NULL;
+	List local_acct_list = NULL;
+	List local_user_list = NULL;
+	uint32_t fairshare = NO_VAL; 
+	uint32_t max_jobs = NO_VAL; 
+	uint32_t max_nodes_per_job = NO_VAL;
+	uint32_t max_wall_duration_per_job = NO_VAL;
+	uint32_t max_cpu_secs_per_job = NO_VAL;
+	char *user_str = NULL;
+	char *assoc_str = NULL;
+	int limit_set = 0, mins;
+	int first = 1;
+	int acct_first = 1;
+
+/* 	if(!list_count(sacctmgr_cluster_list)) { */
+/* 		printf(" Can't add users, no cluster defined yet.\n" */
+/* 		       " Please contact your administrator.\n"); */
+/* 		return SLURM_ERROR; */
+/* 	} */
+
+	assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	assoc_cond->user_list = list_create(slurm_destroy_char);
+	assoc_cond->acct_list = list_create(slurm_destroy_char);
+	assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	assoc_cond->partition_list = list_create(slurm_destroy_char);
+
+	for (i=0; i<argc; i++) {
+		int end = parse_option_end(argv[i]);
+		if(!end) {
+			addto_char_list(assoc_cond->user_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Accounts", 2) == 0) {
+			addto_char_list(assoc_cond->acct_list,
+					argv[i]+end);
+		} else if (strncasecmp (argv[i], "AdminLevel", 2) == 0) {
+			admin_level = str_2_acct_admin_level(argv[i]+end);
+		} else if (strncasecmp (argv[i], "Clusters", 1) == 0) {
+			addto_char_list(assoc_cond->cluster_list,
+					argv[i]+end);
+		} else if (strncasecmp (argv[i], "DefaultAccount", 1) == 0) {
+			default_acct = xstrdup(argv[i]+end);
+			addto_char_list(assoc_cond->acct_list,
+					argv[i]+end);
+		} else if (strncasecmp (argv[i], "FairShare", 1) == 0) {
+			if (get_uint(argv[i]+end, &fairshare, 
+			    "FairShare") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxCPUSecs", 4) == 0) {
+			if (get_uint(argv[i]+end, &max_cpu_secs_per_job, 
+			    "MaxCPUSecs") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxJobs", 4) == 0) {
+			if (get_uint(argv[i]+end, &max_jobs, 
+			    "MaxJobs") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxNodes", 4) == 0) {
+			if (get_uint(argv[i]+end, &max_nodes_per_job, 
+			    "MaxNodes") == SLURM_SUCCESS)
+				limit_set = 1;
+		} else if (strncasecmp (argv[i], "MaxWall", 4) == 0) {
+			mins = time_str2mins(argv[i]+end);
+			if (mins != NO_VAL) {
+				max_wall_duration_per_job = (uint32_t) mins;
+				limit_set = 1;
+			} else {
+				printf(" Bad MaxWall time format: %s\n", 
+					argv[i]);
+			}
+		} else if (strncasecmp (argv[i], "Names", 1) == 0) {
+			addto_char_list(assoc_cond->user_list, argv[i]+end);
+		} else if (strncasecmp (argv[i], "Partitions", 1) == 0) {
+			addto_char_list(assoc_cond->partition_list,
+					argv[i]+end);
+		} else if (strncasecmp (argv[i], "QosLevel", 1) == 0) {
+			qos = str_2_acct_qos(argv[i]+end);
+		} else {
+			printf(" Unknown option: %s\n", argv[i]);
+		}		
+	}
+
+	if(!list_count(assoc_cond->user_list)) {
+		destroy_acct_association_cond(assoc_cond);
+		printf(" Need name of user to add.\n"); 
+		return SLURM_ERROR;
+	} else {
+ 		acct_user_cond_t user_cond;
+
+		memset(&user_cond, 0, sizeof(acct_user_cond_t));
+		user_cond.user_list = assoc_cond->user_list;
+
+		local_user_list = acct_storage_g_get_users(
+			db_conn, &user_cond);
+		
+	}	
+	if(!local_user_list) {
+		printf(" Problem getting users from database.  "
+		       "Contact your admin.\n");
+		destroy_acct_association_cond(assoc_cond);
+		return SLURM_ERROR;
+	}
+
+
+	if(!list_count(assoc_cond->acct_list)) {
+		destroy_acct_association_cond(assoc_cond);
+		printf(" Need name of acct to add user to.\n"); 
+		return SLURM_ERROR;
+	} else {
+ 		acct_account_cond_t account_cond;
+
+		memset(&account_cond, 0, sizeof(acct_account_cond_t));
+		account_cond.acct_list = assoc_cond->acct_list;
+
+		local_acct_list = acct_storage_g_get_accounts(
+			db_conn, &account_cond);
+		
+	}	
+
+	if(!local_acct_list) {
+		printf(" Problem getting accounts from database.  "
+		       "Contact your admin.\n");
+		list_destroy(local_user_list);
+		destroy_acct_association_cond(assoc_cond);
+		return SLURM_ERROR;
+	}
+	
+	
+	if(!list_count(assoc_cond->cluster_list)) {
+		List cluster_list = NULL;
+		acct_cluster_rec_t *cluster_rec = NULL;
+
+		cluster_list = acct_storage_g_get_clusters(db_conn, NULL);
+		if(!cluster_list) {
+			printf(" Problem getting clusters from database.  "
+			       "Contact your admin.\n");
+			destroy_acct_association_cond(assoc_cond);
+			list_destroy(local_user_list);
+			list_destroy(local_acct_list);
+			return SLURM_ERROR;
+		}
+
+		itr_c = list_iterator_create(cluster_list);
+		while((cluster_rec = list_next(itr_c))) {
+			list_append(assoc_cond->cluster_list, 
+				    xstrdup(cluster_rec->name));
+		}
+		list_iterator_destroy(itr_c);
+
+		if(!list_count(assoc_cond->cluster_list)) {
+			printf("  Can't add users, no cluster defined yet.\n"
+			       " Please contact your administrator.\n");
+			destroy_acct_association_cond(assoc_cond);
+			list_destroy(local_user_list);
+			list_destroy(local_acct_list);
+			return SLURM_ERROR; 
+		}
+	}
+
+	if(!default_acct) {
+		itr_a = list_iterator_create(assoc_cond->acct_list);
+		default_acct = xstrdup(list_next(itr_a));
+		list_iterator_destroy(itr_a);
+	}
+
+	/* we are adding these lists to the global lists and will be
+	   freed when they are */
+	user_list = list_create(destroy_acct_user_rec);
+	assoc_list = list_create(destroy_acct_association_rec);
+
+	memset(&query_assoc_cond, 0, sizeof(acct_association_cond_t));
+	query_assoc_cond.acct_list = assoc_cond->acct_list;
+	query_assoc_cond.cluster_list = assoc_cond->cluster_list;
+	local_assoc_list = acct_storage_g_get_associations(
+		db_conn, &query_assoc_cond);	
+	
+	itr = list_iterator_create(assoc_cond->user_list);
+	while((name = list_next(itr))) {
+		user = NULL;
+		if(!sacctmgr_find_user_from_list(local_user_list, name)) {
+			if(!default_acct) {
+				printf(" Need a default account for "
+				       "these users to add.\n"); 
+				rc = SLURM_ERROR;
+				goto no_default;
+			}
+			if(first) {
+				if(!sacctmgr_find_account_from_list(
+					   local_acct_list, default_acct)) {
+					printf(" error: This account '%s' "
+					       "doesn't exist.\n"
+					       "        Contact your admin "
+					       "to add this account.\n",
+					       default_acct);
+					continue;
+				}
+				first = 0;				
+			}
+			user = xmalloc(sizeof(acct_user_rec_t));
+			user->assoc_list = list_create(NULL);
+			user->name = xstrdup(name);
+			user->default_acct = xstrdup(default_acct);
+			user->qos = qos;
+			user->admin_level = admin_level;
+			xstrfmtcat(user_str, "  %s\n", name);
+
+			list_append(user_list, user);
+		}
+
+		itr_a = list_iterator_create(assoc_cond->acct_list);
+		while((account = list_next(itr_a))) {
+			if(acct_first) {
+				if(!sacctmgr_find_account_from_list(
+					   local_acct_list, default_acct)) {
+					printf(" error: This account '%s' "
+					       "doesn't exist.\n"
+					       "        Contact your admin "
+					       "to add this account.\n",
+					       account);
+					continue;
+				}
+			}
+			itr_c = list_iterator_create(assoc_cond->cluster_list);
+			while((cluster = list_next(itr_c))) {
+				if(!sacctmgr_find_account_base_assoc_from_list(
+					   local_assoc_list, account,
+					   cluster)) {
+					if(acct_first)
+						printf(" error: This "
+						       "account '%s' "
+						       "doesn't exist on "
+						       "cluster %s\n"
+						       "        Contact your "
+						       "admin "
+						       "to add this account.\n",
+						       account, cluster);	
+					continue;
+				}
+				
+				itr_p = list_iterator_create(
+					assoc_cond->partition_list);
+				while((partition = list_next(itr_p))) {
+					partition_set = 1;
+					if(sacctmgr_find_association_from_list(
+						   local_assoc_list,
+						   name, account,
+						   cluster, partition))
+						continue;
+					assoc = xmalloc(
+						sizeof(acct_association_rec_t));
+					assoc->user = xstrdup(name);
+					assoc->acct = xstrdup(account);
+					assoc->cluster = xstrdup(cluster);
+					assoc->partition = xstrdup(partition);
+					assoc->fairshare = fairshare;
+					assoc->max_jobs = max_jobs;
+					assoc->max_nodes_per_job =
+						max_nodes_per_job;
+					assoc->max_wall_duration_per_job =
+						max_wall_duration_per_job;
+					assoc->max_cpu_secs_per_job =
+						max_cpu_secs_per_job;
+					if(user) 
+						list_append(user->assoc_list,
+							    assoc);
+					else 
+						list_append(assoc_list, assoc);
+					xstrfmtcat(assoc_str,
+						   "  U = %-9.9s"
+						   " A = %-10.10s"
+						   " C = %-10.10s"
+						   " P = %-10.10s\n",
+						   assoc->user, assoc->acct,
+						   assoc->cluster,
+						   assoc->partition);
+				}
+				list_iterator_destroy(itr_p);
+				if(partition_set) 
+					continue;
+
+				if(sacctmgr_find_association_from_list(
+					   local_assoc_list,
+					   name, account, cluster, NULL))
+						continue;
+					
+				assoc = xmalloc(sizeof(acct_association_rec_t));
+				assoc->user = xstrdup(name);
+				assoc->acct = xstrdup(account);
+				assoc->cluster = xstrdup(cluster);
+				assoc->fairshare = fairshare;
+				assoc->max_jobs = max_jobs;
+				assoc->max_nodes_per_job = max_nodes_per_job;
+				assoc->max_wall_duration_per_job =
+					max_wall_duration_per_job;
+				assoc->max_cpu_secs_per_job =
+					max_cpu_secs_per_job;
+				if(user) 
+					list_append(user->assoc_list, assoc);
+				else 
+					list_append(assoc_list, assoc);
+				xstrfmtcat(assoc_str,
+					   "  U = %-9.9s"
+					   " A = %-10.10s"
+					   " C = %-10.10s\n",
+					   assoc->user, assoc->acct,
+					   assoc->cluster);		
+			}
+			list_iterator_destroy(itr_c);
+		}
+		list_iterator_destroy(itr_a);
+		acct_first = 0;
+	}
+no_default:
+	list_iterator_destroy(itr);
+	list_destroy(local_user_list);
+	list_destroy(local_acct_list);
+	list_destroy(local_assoc_list);
+	destroy_acct_association_cond(assoc_cond);
+
+	if(!list_count(user_list) && !list_count(assoc_list)) {
+		printf(" Nothing new added.\n");
+		goto end_it;
+	} else if(!assoc_str) {
+		printf(" Error: no associations created.\n");
+		goto end_it;
+	}
+
+	if(user_str) {
+		printf(" Adding User(s)\n%s", user_str);
+		printf(" Settings =\n");
+		printf("  Default Account = %s\n", default_acct);
+		if(qos != ACCT_QOS_NOTSET)
+			printf("  Qos        = %s\n", acct_qos_str(qos));
+		
+		if(admin_level != ACCT_ADMIN_NOTSET)
+			printf("  Admin Level     = %s\n", 
+			       acct_admin_level_str(admin_level));
+		xfree(user_str);
+	}
+
+	if(assoc_str) {
+		printf(" Associations =\n%s", assoc_str);
+		xfree(assoc_str);
+	}
+
+	if(limit_set) {
+		        printf(" Non Default Settings\n");
+		if(fairshare == INFINITE)
+			printf("  Fairshare       = NONE\n");
+		else if(fairshare != NO_VAL) 
+			printf("  Fairshare       = %u\n", fairshare);
+		
+		if(max_cpu_secs_per_job == INFINITE)
+			printf("  MaxCPUSecs      = NONE\n");
+		else if(max_cpu_secs_per_job != NO_VAL) 
+			printf("  MaxCPUSecs      = %u\n",
+			       max_cpu_secs_per_job);
+		
+		if(max_jobs == INFINITE) 
+			printf("  MaxJobs         = NONE\n");
+		else if(max_jobs != NO_VAL) 
+			printf("  MaxJobs         = %u\n", max_jobs);
+		
+		if(max_nodes_per_job == INFINITE)
+			printf("  MaxNodes        = NONE\n");
+		else if(max_nodes_per_job != NO_VAL)
+			printf("  MaxNodes        = %u\n", max_nodes_per_job);
+		
+		if(max_wall_duration_per_job == INFINITE) 
+			printf("  MaxWall         = NONE\n");		
+		else if(max_wall_duration_per_job != NO_VAL) {
+			char time_buf[32];
+			mins2time_str((time_t) max_wall_duration_per_job, 
+				      time_buf, sizeof(time_buf));
+			printf("  MaxWall         = %s\n", time_buf);
+		}
+	}
+
+	notice_thread_init();
+	if(list_count(user_list)) {
+		rc = acct_storage_g_add_users(db_conn, my_uid, 
+					      user_list);
+	}
+
+	if(rc == SLURM_SUCCESS) {
+		if(list_count(assoc_list))
+			rc = acct_storage_g_add_associations(db_conn, my_uid, 
+							     assoc_list);
+	} else {
+		printf(" error: Problem adding users\n");
+		rc = SLURM_ERROR;
+		notice_thread_fini();
+		goto end_it;
+	}
+	notice_thread_fini();
+
+	if(rc == SLURM_SUCCESS) {
+		if(commit_check("Would you like to commit changes?")) {
+			acct_storage_g_commit(db_conn, 1);
+		} else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	} else {
+		printf(" error: Problem adding user associations\n");
+		rc = SLURM_ERROR;
+	}
+
+end_it:
+	list_destroy(user_list);
+	list_destroy(assoc_list);
+	xfree(default_acct);
+
+	return rc;
+}
+
+extern int sacctmgr_list_user(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_user_cond_t *user_cond = xmalloc(sizeof(acct_user_cond_t));
+	List user_list;
+	int i=0;
+	ListIterator itr = NULL;
+	ListIterator itr2 = NULL;
+	acct_user_rec_t *user = NULL;
+	acct_association_rec_t *assoc = NULL;
+	char *object;
+
+	print_field_t *field = NULL;
+
+	List format_list = list_create(slurm_destroy_char);
+	List print_fields_list; /* types are of print_field_t */
+
+	enum {
+		PRINT_ACCOUNT,
+		PRINT_ADMIN,
+		PRINT_CLUSTER,
+		PRINT_DACCT,
+		PRINT_FAIRSHARE,
+		PRINT_ID,
+		PRINT_MAXC,
+		PRINT_MAXJ,
+		PRINT_MAXN,
+		PRINT_MAXW,
+		PRINT_QOS,
+		PRINT_PID,
+		PRINT_PNAME,
+		PRINT_PART,
+		PRINT_USER
+	};
+
+	user_cond->user_list = list_create(slurm_destroy_char);
+	user_cond->def_acct_list = list_create(slurm_destroy_char);
+	user_cond->with_assocs = with_assoc_flag;
+
+	user_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	user_cond->assoc_cond->user_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->acct_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->partition_list = list_create(slurm_destroy_char);
+	
+	_set_cond(&i, argc, argv, user_cond, format_list);
+
+	if(!list_count(format_list)) {
+		addto_char_list(format_list, "U,D,Q,Ad");
+		if(user_cond->with_assocs)
+			addto_char_list(format_list,
+					"C,Ac,Part,F,MaxC,MaxJ,MaxN,MaxW");
+			
+	}
+
+	user_list = acct_storage_g_get_users(db_conn, user_cond);
+	destroy_acct_user_cond(user_cond);
+
+	if(!user_list) {
+		list_destroy(format_list);
+		return SLURM_ERROR;
+	}
+
+	print_fields_list = list_create(destroy_print_field);
+
+	itr = list_iterator_create(format_list);
+	while((object = list_next(itr))) {
+		field = xmalloc(sizeof(print_field_t));
+		if(!strncasecmp("Account", object, 2)) {
+			field->type = PRINT_ACCOUNT;
+			field->name = xstrdup("Account");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("AdminLevel", object, 2)) {
+			field->type = PRINT_ADMIN;
+			field->name = xstrdup("Admin");
+			field->len = 9;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("Cluster", object, 1)) {
+			field->type = PRINT_CLUSTER;
+			field->name = xstrdup("Cluster");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("Default", object, 1)) {
+			field->type = PRINT_DACCT;
+			field->name = xstrdup("Def Acct");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("FairShare", object, 1)) {
+			field->type = PRINT_FAIRSHARE;
+			field->name = xstrdup("FairShare");
+			field->len = 9;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("ID", object, 1)) {
+			field->type = PRINT_ID;
+			field->name = xstrdup("ID");
+			field->len = 6;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxCPUSecs", object, 4)) {
+			field->type = PRINT_MAXC;
+			field->name = xstrdup("MaxCPUSecs");
+			field->len = 11;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxJobs", object, 4)) {
+			field->type = PRINT_MAXJ;
+			field->name = xstrdup("MaxJobs");
+			field->len = 7;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxNodes", object, 4)) {
+			field->type = PRINT_MAXN;
+			field->name = xstrdup("MaxNodes");
+			field->len = 8;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("MaxWall", object, 4)) {
+			field->type = PRINT_MAXW;
+			field->name = xstrdup("MaxWall");
+			field->len = 11;
+			field->print_routine = print_time;
+		} else if(!strncasecmp("QOS", object, 1)) {
+			field->type = PRINT_QOS;
+			field->name = xstrdup("QOS");
+			field->len = 9;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("ParentID", object, 7)) {
+			field->type = PRINT_PID;
+			field->name = xstrdup("Par ID");
+			field->len = 6;
+			field->print_routine = print_uint;
+		} else if(!strncasecmp("Partition", object, 4)) {
+			field->type = PRINT_PART;
+			field->name = xstrdup("Partition");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else if(!strncasecmp("User", object, 1)) {
+			field->type = PRINT_USER;
+			field->name = xstrdup("User");
+			field->len = 10;
+			field->print_routine = print_str;
+		} else {
+			printf("Unknown field '%s'\n", object);
+			xfree(field);
+			continue;
+		}
+		list_append(print_fields_list, field);		
+	}
+	list_iterator_destroy(itr);
+
+	itr = list_iterator_create(user_list);
+	itr2 = list_iterator_create(print_fields_list);
+	print_header(print_fields_list);
+
+	while((user = list_next(itr))) {
+		if(user->assoc_list && list_count(user->assoc_list)) {
+			ListIterator itr3 =
+				list_iterator_create(user->assoc_list);
+			
+			while((assoc = list_next(itr3))) {
+				while((field = list_next(itr2))) {
+					switch(field->type) {
+					case PRINT_ACCOUNT:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field, 
+							assoc->acct);
+						break;
+					case PRINT_ADMIN:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							acct_admin_level_str(
+								user->
+								admin_level));
+						break;
+					case PRINT_CLUSTER:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->cluster);
+						break;
+					case PRINT_DACCT:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							user->default_acct);
+						break;
+					case PRINT_FAIRSHARE:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->fairshare);
+						break;
+					case PRINT_ID:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->id);
+						break;
+					case PRINT_MAXC:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->
+							max_cpu_secs_per_job);
+						break;
+					case PRINT_MAXJ:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field, 
+							assoc->max_jobs);
+						break;
+					case PRINT_MAXN:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->
+							max_nodes_per_job);
+						break;
+					case PRINT_MAXW:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->
+							max_wall_duration_per_job);
+						break;
+					case PRINT_QOS:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							acct_qos_str(
+								user->qos));
+						break;
+					case PRINT_PID:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->parent_id);
+						break;
+					case PRINT_PNAME:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->parent_acct);
+						break;
+					case PRINT_PART:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							assoc->partition);
+						break;
+					case PRINT_USER:
+						field->print_routine(
+							SLURM_PRINT_VALUE, 
+							field,
+							user->name);
+						break;
+					default:
+						break;
+					}
+				}
+				list_iterator_reset(itr2);
+				printf("\n");
+			}
+			list_iterator_destroy(itr3);				
+		} else {
+			while((field = list_next(itr2))) {
+				switch(field->type) {
+				case PRINT_ACCOUNT:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field, 
+						NULL);
+					break;
+				case PRINT_ADMIN:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						acct_admin_level_str(
+							user->admin_level));
+					break;
+				case PRINT_CLUSTER:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						NULL);
+					break;
+				case PRINT_DACCT:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						user->default_acct);
+					break;
+				case PRINT_FAIRSHARE:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						NULL);
+					break;
+				case PRINT_ID:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						NULL);
+					break;
+				case PRINT_MAXC:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						NULL);
+					break;
+				case PRINT_MAXJ:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field, 
+						NULL);
+					break;
+				case PRINT_MAXN:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						NULL);
+					break;
+				case PRINT_MAXW:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						NULL);
+					break;
+				case PRINT_QOS:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						acct_qos_str(user->qos));
+					break;
+				case PRINT_PID:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field,
+						NULL);
+					break;
+				case PRINT_PART:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field, 
+						NULL);
+					break;
+				case PRINT_USER:
+					field->print_routine(
+						SLURM_PRINT_VALUE, field, 
+						user->name);
+					break;
+				default:
+					break;
+				}
+			}
+			list_iterator_reset(itr2);
+			printf("\n");
+		}
+	}
+
+	printf("\n");
+
+	list_iterator_destroy(itr2);
+	list_iterator_destroy(itr);
+	list_destroy(user_list);
+	list_destroy(print_fields_list);
+
+	return rc;
+}
+
+extern int sacctmgr_modify_user(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_user_cond_t *user_cond = xmalloc(sizeof(acct_user_cond_t));
+	acct_user_rec_t *user = xmalloc(sizeof(acct_user_rec_t));
+	acct_association_rec_t *assoc = xmalloc(sizeof(acct_association_rec_t));
+	int i=0;
+	int cond_set = 0, rec_set = 0, set = 0;
+	List ret_list = NULL;
+
+	user_cond->user_list = list_create(slurm_destroy_char);
+	user_cond->def_acct_list = list_create(slurm_destroy_char);
+	
+	user_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	user_cond->assoc_cond->user_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->acct_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->partition_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->fairshare = NO_VAL;
+	user_cond->assoc_cond->max_cpu_secs_per_job = NO_VAL;
+	user_cond->assoc_cond->max_jobs = NO_VAL;
+	user_cond->assoc_cond->max_nodes_per_job = NO_VAL;
+	user_cond->assoc_cond->max_wall_duration_per_job = NO_VAL;
+	
+	assoc->fairshare = NO_VAL;
+	assoc->max_cpu_secs_per_job = NO_VAL;
+	assoc->max_jobs = NO_VAL;
+	assoc->max_nodes_per_job = NO_VAL;
+	assoc->max_wall_duration_per_job = NO_VAL;
+
+	for (i=0; i<argc; i++) {
+		if (strncasecmp (argv[i], "Where", 5) == 0) {
+			i++;
+			cond_set = _set_cond(&i, argc, argv, user_cond, NULL);
+			      
+		} else if (strncasecmp (argv[i], "Set", 3) == 0) {
+			i++;
+			rec_set = _set_rec(&i, argc, argv, user, assoc);
+		} else {
+			cond_set = _set_cond(&i, argc, argv, user_cond, NULL);
+		}
+	}
+
+	if(!rec_set) {
+		printf(" You didn't give me anything to set\n");
+		destroy_acct_user_cond(user_cond);
+		destroy_acct_user_rec(user);
+		destroy_acct_association_rec(assoc);
+		return SLURM_ERROR;
+	} else if(!cond_set) {
+		if(!commit_check("You didn't set any conditions with 'WHERE'.\n"
+				 "Are you sure you want to continue?")) {
+			printf("Aborted\n");
+			destroy_acct_user_cond(user_cond);
+			destroy_acct_user_rec(user);
+			destroy_acct_association_rec(assoc);
+			return SLURM_SUCCESS;
+		}		
+	}
+
+	notice_thread_init();
+	if(rec_set == 3 || rec_set == 1) { // process the account changes
+		if(cond_set == 2) {
+			rc = SLURM_ERROR;
+			goto assoc_start;
+		}
+		ret_list = acct_storage_g_modify_users(
+			db_conn, my_uid, user_cond, user);
+		if(ret_list && list_count(ret_list)) {
+			char *object = NULL;
+			ListIterator itr = list_iterator_create(ret_list);
+			printf(" Modified users...\n");
+			while((object = list_next(itr))) {
+				printf("  %s\n", object);
+			}
+			list_iterator_destroy(itr);
+			list_destroy(ret_list);
+			set = 1;
+		} else if(ret_list) {
+			printf(" Nothing modified\n");
+		} else {
+			printf(" Error with request\n");
+			rc = SLURM_ERROR;
+		}
+
+		if(ret_list)
+			list_destroy(ret_list);
+	}
+
+assoc_start:
+	if(rec_set == 3 || rec_set == 2) { // process the association changes
+		ret_list = acct_storage_g_modify_associations(
+			db_conn, my_uid, user_cond->assoc_cond, assoc);
+
+		if(ret_list && list_count(ret_list)) {
+			char *object = NULL;
+			ListIterator itr = list_iterator_create(ret_list);
+			printf(" Modified account associations...\n");
+			while((object = list_next(itr))) {
+				printf("  %s\n", object);
+			}
+			list_iterator_destroy(itr);
+			set = 1;
+		} else if(ret_list) {
+			printf(" Nothing modified\n");
+		} else {
+			printf(" Error with request\n");
+			rc = SLURM_ERROR;
+		}
+
+		if(ret_list)
+			list_destroy(ret_list);
+	}
+
+	notice_thread_fini();
+	if(set) {
+		if(commit_check("Would you like to commit changes?")) 
+			acct_storage_g_commit(db_conn, 1);
+		else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	}
+
+	destroy_acct_user_cond(user_cond);
+	destroy_acct_user_rec(user);	
+	destroy_acct_association_rec(assoc);
+
+	return rc;
+}
+
+extern int sacctmgr_delete_user(int argc, char *argv[])
+{
+	int rc = SLURM_SUCCESS;
+	acct_user_cond_t *user_cond = xmalloc(sizeof(acct_user_cond_t));
+	int i=0;
+	List ret_list = NULL;
+	int set = 0;
+
+	user_cond->user_list = list_create(slurm_destroy_char);
+	user_cond->def_acct_list = list_create(slurm_destroy_char);
+	
+	user_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t));
+	user_cond->assoc_cond->user_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->acct_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->cluster_list = list_create(slurm_destroy_char);
+	user_cond->assoc_cond->partition_list = list_create(slurm_destroy_char);
+
+	if(!(set = _set_cond(&i, argc, argv, user_cond, NULL))) {
+		printf(" No conditions given to remove, not executing.\n");
+		destroy_acct_user_cond(user_cond);
+		return SLURM_ERROR;
+	}
+
+	notice_thread_init();
+	if(set == 1) {
+		ret_list = acct_storage_g_remove_users(
+			db_conn, my_uid, user_cond);		
+	} else if(set == 2) {
+		ret_list = acct_storage_g_remove_associations(
+			db_conn, my_uid, user_cond->assoc_cond);
+	}
+	notice_thread_fini();
+
+	destroy_acct_user_cond(user_cond);
+
+	if(ret_list && list_count(ret_list)) {
+		char *object = NULL;
+		ListIterator itr = list_iterator_create(ret_list);
+		if(set == 1) {
+			printf(" Deleting users...\n");
+		} else if(set == 2) {
+			printf(" Deleting user associations...\n");
+		}
+		while((object = list_next(itr))) {
+			printf("  %s\n", object);
+		}
+		list_iterator_destroy(itr);
+		if(commit_check("Would you like to commit changes?")) {
+			acct_storage_g_commit(db_conn, 1);
+		} else {
+			printf(" Changes Discarded\n");
+			acct_storage_g_commit(db_conn, 0);
+		}
+	} else if(ret_list) {
+		printf(" Nothing deleted\n");
+	} else {
+		printf(" Error with request\n");
+		rc = SLURM_ERROR;
+	} 
+	
+
+	if(ret_list)
+		list_destroy(ret_list);
+
+	return rc;
+}
diff --git a/src/salloc/Makefile.am b/src/salloc/Makefile.am
index 5f65b5e67c8880e450ca314f95b77f7e96abd5b7..a27f098f63607db4138573666e471be22641aa8b 100644
--- a/src/salloc/Makefile.am
+++ b/src/salloc/Makefile.am
@@ -6,14 +6,14 @@ INCLUDES = -I$(top_srcdir)
 
 bin_PROGRAMS = salloc
 
-salloc_SOURCES = salloc.c salloc.h opt.c opt.h msg.c msg.h
+salloc_SOURCES = salloc.c salloc.h opt.c opt.h
 
 convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
 
 salloc_LDADD = \
 	$(convenience_libs) 
 
-salloc_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+salloc_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 
 force:
 $(convenience_libs) : force
diff --git a/src/salloc/Makefile.in b/src/salloc/Makefile.in
index 938fae8b1e76884d427343bf7a91e4d5cd84f793..1c34e396f741c1926c094c248169b1f903098101 100644
--- a/src/salloc/Makefile.in
+++ b/src/salloc/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -68,13 +70,13 @@ CONFIG_CLEAN_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_salloc_OBJECTS = salloc.$(OBJEXT) opt.$(OBJEXT) msg.$(OBJEXT)
+am_salloc_OBJECTS = salloc.$(OBJEXT) opt.$(OBJEXT)
 salloc_OBJECTS = $(am_salloc_OBJECTS)
 salloc_DEPENDENCIES = $(convenience_libs)
 salloc_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(salloc_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -114,6 +116,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -127,10 +130,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -150,7 +156,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -161,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -176,6 +187,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -191,6 +203,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -249,12 +262,12 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir) 
-salloc_SOURCES = salloc.c salloc.h opt.c opt.h msg.c msg.h
+salloc_SOURCES = salloc.c salloc.h opt.c opt.h
 convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
 salloc_LDADD = \
 	$(convenience_libs) 
 
-salloc_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+salloc_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -297,8 +310,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -326,7 +339,6 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/salloc.Po@am__quote@
 
@@ -362,8 +374,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +387,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +398,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/salloc/msg.h b/src/salloc/msg.h
deleted file mode 100644
index 71267db9e100d4159cbf94090ae629ed7fd21c4b..0000000000000000000000000000000000000000
--- a/src/salloc/msg.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************\
- *  src/salloc/msg.h - Message handler for salloc
- *
- *  $Id: salloc.c 8570 2006-07-13 21:12:58Z morrone $
- *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifndef _SALLOC_MSG_H
-#define _SALLOC_MSG_H
-
-#include <stdint.h>
-
-typedef struct salloc_msg_thread salloc_msg_thread_t;
-
-extern salloc_msg_thread_t *msg_thr_create(uint16_t *port);
-extern void msg_thr_destroy(salloc_msg_thread_t *msg_thr);
-
-#endif /* _SALLOC_MSG_H */
diff --git a/src/salloc/opt.c b/src/salloc/opt.c
index fc630c8c8da6688ccf3aa936a4c14d526a589324..652c91eb6d21fdbf17ebb815551000ed82574dff 100644
--- a/src/salloc/opt.c
+++ b/src/salloc/opt.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -61,6 +61,7 @@
 #include "src/common/list.h"
 #include "src/common/log.h"
 #include "src/common/parse_time.h"
+#include "src/common/proc_args.h"
 #include "src/common/slurm_protocol_api.h"
 #include "src/common/uid.h"
 #include "src/common/xmalloc.h"
@@ -87,6 +88,7 @@
 #define OPT_JOBID       0x11
 #define OPT_EXCLUSIVE   0x12
 #define OPT_OVERCOMMIT  0x13
+#define OPT_ACCTG_FREQ  0x14
 
 /* generic getopt_long flags, integers and *not* valid characters */
 #define LONG_OPT_JOBID       0x105
@@ -116,6 +118,15 @@
 #define LONG_OPT_RAMDISK_IMAGE   0x123
 #define LONG_OPT_NOSHELL         0x124
 #define LONG_OPT_GET_USER_ENV    0x125
+#define LONG_OPT_SOCKETSPERNODE  0x130
+#define LONG_OPT_CORESPERSOCKET  0x131
+#define LONG_OPT_THREADSPERCORE  0x132
+#define LONG_OPT_NTASKSPERNODE   0x136
+#define LONG_OPT_NTASKSPERSOCKET 0x137
+#define LONG_OPT_NTASKSPERCORE   0x138
+#define LONG_OPT_TASK_MEM        0x13a
+#define LONG_OPT_HINT            0x13b
+#define LONG_OPT_ACCTG_FREQ      0x13c
 
 /*---- global variables, defined in opt.h ----*/
 opt_t opt;
@@ -124,9 +135,6 @@ opt_t opt;
 
 typedef struct env_vars env_vars_t;
 
-/* return command name from its full path name */
-static char * _base_name(char* command);
-
 /* Get a decimal integer from arg */
 static int  _get_int(const char *arg, const char *what);
 
@@ -147,16 +155,9 @@ static void  _opt_list(void);
 static bool _opt_verify(void);
 
 static void  _proc_get_user_env(char *optarg);
-static void  _print_version(void);
 static void _process_env_var(env_vars_t *e, const char *val);
-static uint16_t _parse_mail_type(const char *arg);
-static char *_print_mail_type(const uint16_t type);
 static int _parse_signal(const char *signal_name);
-static long  _to_bytes(const char *arg);
 static void  _usage(void);
-static bool  _verify_node_count(const char *arg, int *min, int *max);
-static int   _verify_geometry(const char *arg, uint16_t *geometry);
-static int   _verify_conn_type(const char *arg);
 
 /*---[ end forward declarations of static functions ]---------------------*/
 
@@ -178,216 +179,6 @@ int initialize_and_process_args(int argc, char *argv[])
 
 }
 
-static void _print_version(void)
-{
-	printf("%s %s\n", PACKAGE, SLURM_VERSION);
-}
-
-/*
- * verify that a connection type in arg is of known form
- * returns the connection_type or -1 if not recognized
- */
-static int _verify_conn_type(const char *arg)
-{
-	int len = strlen(arg);
-
-	if (!strncasecmp(arg, "MESH", len))
-		return SELECT_MESH;
-	else if (!strncasecmp(arg, "TORUS", len))
-		return SELECT_TORUS;
-	else if (!strncasecmp(arg, "NAV", len))
-		return SELECT_NAV;
-
-	error("invalid --conn-type argument %s ignored.", arg);
-	return -1;
-}
-
-/*
- * verify geometry arguments, must have proper count
- * returns -1 on error, 0 otherwise
- */
-static int _verify_geometry(const char *arg, uint16_t *geometry)
-{
-	char* token, *delimiter = ",x", *next_ptr;
-	int i, rc = 0;
-	char* geometry_tmp = xstrdup(arg);
-	char* original_ptr = geometry_tmp;
-
-	token = strtok_r(geometry_tmp, delimiter, &next_ptr);
-	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-		if (token == NULL) {
-			error("insufficient dimensions in --geometry");
-			rc = -1;
-			break;
-		}
-		geometry[i] = (uint16_t)atoi(token);
-		if (geometry[i] == 0 || geometry[i] == (uint16_t)NO_VAL) {
-			error("invalid --geometry argument");
-			rc = -1;
-			break;
-		}
-		geometry_tmp = next_ptr;
-		token = strtok_r(geometry_tmp, delimiter, &next_ptr);
-	}
-	if (token != NULL) {
-		error("too many dimensions in --geometry");
-		rc = -1;
-	}
-
-	if (original_ptr)
-		xfree(original_ptr);
-
-	return rc;
-}
-
-/* Convert a string into a node count */
-static int
-_str_to_nodes(const char *num_str, char **leftover)
-{
-	long int num;
-	char *endptr;
-
-	num = strtol(num_str, &endptr, 10);
-	if (endptr == num_str) { /* no valid digits */
-		*leftover = (char *)num_str;
-		return 0;
-	} 
-	if (*endptr != '\0' && (*endptr == 'k' || *endptr == 'K')) {
-		num *= 1024;
-		endptr++;
-	}
-	*leftover = endptr;
-
-	return (int)num;
-}
-
-/* 
- * verify that a node count in arg is of a known form (count or min-max)
- * OUT min, max specified minimum and maximum node counts
- * RET true if valid
- */
-static bool 
-_verify_node_count(const char *arg, int *min_nodes, int *max_nodes)
-{
-	char *ptr, *min_str, *max_str;
-	char *leftover;
-	
-	/* Does the string contain a "-" character?  If so, treat as a range.
-	 * otherwise treat as an absolute node count. */
-	if ((ptr = index(arg, '-')) != NULL) {
-		min_str = xstrndup(arg, ptr-arg);
-		*min_nodes = _str_to_nodes(min_str, &leftover);
-		if (!xstring_is_whitespace(leftover)) {
-			error("\"%s\" is not a valid node count", min_str);
-			xfree(min_str);
-			return false;
-		}
-		xfree(min_str);
-		if (*min_nodes == 0)
-			*min_nodes = 1;
-
-		max_str = xstrndup(ptr+1, strlen(arg)-((ptr+1)-arg));
-		*max_nodes = _str_to_nodes(max_str, &leftover);
-		if (!xstring_is_whitespace(leftover)) {
-			error("\"%s\" is not a valid node count", max_str);
-			xfree(max_str);
-			return false;
-		}
-		xfree(max_str);
-	} else {
-		*min_nodes = *max_nodes = _str_to_nodes(arg, &leftover);
-		if (!xstring_is_whitespace(leftover)) {
-			error("\"%s\" is not a valid node count", arg);
-			return false;
-		}
-		if (*min_nodes == 0) {
-			/* whitespace does not a valid node count make */
-			error("\"%s\" is not a valid node count", arg);
-			return false;
-		}
-	}
-
-	if ((*max_nodes != 0) && (*max_nodes < *min_nodes)) {
-		error("Maximum node count %d is less than"
-		      " minimum node count %d",
-		      *max_nodes, *min_nodes);
-		return false;
-	}
-
-	return true;
-}
-
-/* return command name from its full path name */
-static char * _base_name(char* command)
-{
-	char *char_ptr, *name;
-	int i;
-
-	if (command == NULL)
-		return NULL;
-
-	char_ptr = strrchr(command, (int)'/');
-	if (char_ptr == NULL)
-		char_ptr = command;
-	else
-		char_ptr++;
-
-	i = strlen(char_ptr);
-	name = xmalloc(i+1);
-	strcpy(name, char_ptr);
-	return name;
-}
-
-/*
- * _to_bytes(): verify that arg is numeric with optional "G" or "M" at end
- * if "G" or "M" is there, multiply by proper power of 2 and return
- * number in bytes
- */
-static long _to_bytes(const char *arg)
-{
-	char *buf;
-	char *endptr;
-	int end;
-	int multiplier = 1;
-	long result;
-
-	buf = xstrdup(arg);
-
-	end = strlen(buf) - 1;
-
-	if (isdigit(buf[end])) {
-		result = strtol(buf, &endptr, 10);
-
-		if (*endptr != '\0')
-			result = -result;
-
-	} else {
-
-		switch (toupper(buf[end])) {
-
-		case 'G':
-			multiplier = 1024;
-			break;
-
-		case 'M':
-			/* do nothing */
-			break;
-
-		default:
-			multiplier = -1;
-		}
-
-		buf[end] = '\0';
-
-		result = multiplier * strtol(buf, &endptr, 10);
-
-		if (*endptr != '\0')
-			result = -result;
-	}
-
-	return result;
-}
-
 /*
  * print error message to stderr with opt.progname prepended
  */
@@ -435,16 +226,29 @@ static void _opt_default()
 	opt.min_nodes = 1;
 	opt.max_nodes = 0;
 	opt.nodes_set = false;
+	opt.min_sockets_per_node = NO_VAL; /* requested min/maxsockets */
+	opt.max_sockets_per_node = NO_VAL;
+	opt.min_cores_per_socket = NO_VAL; /* requested min/maxcores */
+	opt.max_cores_per_socket = NO_VAL;
+	opt.min_threads_per_core = NO_VAL; /* requested min/maxthreads */
+	opt.max_threads_per_core = NO_VAL;
+	opt.ntasks_per_node      = NO_VAL; /* ntask max limits */
+	opt.ntasks_per_socket    = NO_VAL;
+	opt.ntasks_per_core      = NO_VAL;
+	opt.cpu_bind_type = 0;		/* local dummy variable for now */
 	opt.time_limit = NO_VAL;
 	opt.time_limit_str = NULL;
 	opt.partition = NULL;
 
 	opt.job_name = NULL;
 	opt.jobid = NO_VAL;
-	opt.dependency = NO_VAL;
+	opt.dependency = NULL;
 	opt.account  = NULL;
 	opt.comment  = NULL;
 
+	opt.distribution = SLURM_DIST_UNKNOWN;
+	opt.plane_size   = NO_VAL;
+
 	opt.shared = (uint16_t)NO_VAL;
 	opt.no_kill = false;
 	opt.kill_command_signal = SIGTERM;
@@ -462,6 +266,7 @@ static void _opt_default()
 	opt.minsockets      = -1;
 	opt.mincores        = -1;
 	opt.minthreads      = -1;
+	opt.task_mem	    = -1;
 	opt.realmem	    = -1;
 	opt.tmpdisk	    = -1;
 
@@ -481,6 +286,7 @@ static void _opt_default()
 	opt.egid	    = (gid_t) -1;
 	
 	opt.bell            = BELL_AFTER_DELAY;
+	opt.acctg_freq      = -1;
 	opt.no_shell	    = false;
 	opt.get_user_env_time = -1;
 	opt.get_user_env_mode = -1;
@@ -519,6 +325,7 @@ env_vars_t env_vars[] = {
   {"SALLOC_NO_BELL",       OPT_NO_BELL,    NULL,               NULL           },
   {"SALLOC_EXCLUSIVE",     OPT_EXCLUSIVE,  NULL,               NULL           },
   {"SALLOC_OVERCOMMIT",    OPT_OVERCOMMIT, NULL,               NULL           },
+  {"SALLOC_ACCTG_FREQ",    OPT_INT,        &opt.acctg_freq,    NULL           },
   {NULL, 0, NULL, NULL}
 };
 
@@ -591,16 +398,16 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_NODES:
-		opt.nodes_set = _verify_node_count( val, 
-						    &opt.min_nodes, 
-						    &opt.max_nodes );
+		opt.nodes_set = verify_node_count( val, 
+						   &opt.min_nodes, 
+						   &opt.max_nodes );
 		if (opt.nodes_set == false) {
 			error("invalid node count in env variable, ignoring");
 		}
 		break;
 
 	case OPT_CONN_TYPE:
-		opt.conn_type = _verify_conn_type(val);
+		opt.conn_type = verify_conn_type(val);
 		break;
 
 	case OPT_NO_ROTATE:
@@ -608,7 +415,7 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_GEOMETRY:
-		if (_verify_geometry(val, opt.geometry)) {
+		if (verify_geometry(val, opt.geometry)) {
 			error("\"%s=%s\" -- invalid geometry, ignoring...",
 			      e->var, val);
 		}
@@ -665,9 +472,9 @@ void set_options(const int argc, char **argv)
 	int opt_char, option_index = 0;
 	char *tmp;
 	static struct option long_options[] = {
+		{"extra-node-info", required_argument, 0, 'B'},
 		{"cpus-per-task", required_argument, 0, 'c'},
 		{"constraint",    required_argument, 0, 'C'},
-		{"dependency",    required_argument, 0, 'd'},
 		{"chdir",         required_argument, 0, 'D'},
 		{"nodefile",      required_argument, 0, 'F'},
 		{"geometry",      required_argument, 0, 'g'},
@@ -677,11 +484,14 @@ void set_options(const int argc, char **argv)
 		{"job-name",      required_argument, 0, 'J'},
 		{"no-kill",       no_argument,       0, 'k'},
 		{"kill-command",  optional_argument, 0, 'K'},
+		{"licenses",      required_argument, 0, 'L'},
+		{"distribution",  required_argument, 0, 'm'},
 		{"tasks",         required_argument, 0, 'n'},
 		{"ntasks",        required_argument, 0, 'n'},
 		{"nodes",         required_argument, 0, 'N'},
 		{"overcommit",    no_argument,       0, 'O'},
 		{"partition",     required_argument, 0, 'p'},
+		{"dependency",    required_argument, 0, 'P'},
 		{"quiet",         no_argument,       0, 'q'},
 		{"no-rotate",     no_argument,       0, 'R'},
 		{"share",         no_argument,       0, 's'},
@@ -700,6 +510,16 @@ void set_options(const int argc, char **argv)
 		{"mincores",      required_argument, 0, LONG_OPT_MINCORES},
 		{"minthreads",    required_argument, 0, LONG_OPT_MINTHREADS},
 		{"mem",           required_argument, 0, LONG_OPT_MEM},
+		{"job-mem",       required_argument, 0, LONG_OPT_TASK_MEM},
+		{"task-mem",      required_argument, 0, LONG_OPT_TASK_MEM},
+		{"hint",          required_argument, 0, LONG_OPT_HINT},
+		{"sockets-per-node", required_argument, 0, LONG_OPT_SOCKETSPERNODE},
+		{"cores-per-socket", required_argument, 0, LONG_OPT_CORESPERSOCKET},
+		{"threads-per-core", required_argument, 0, LONG_OPT_THREADSPERCORE},
+		{"ntasks-per-node",  required_argument, 0, LONG_OPT_NTASKSPERNODE},
+		{"ntasks-per-socket",required_argument, 0, LONG_OPT_NTASKSPERSOCKET},
+		{"ntasks-per-core",  required_argument, 0, LONG_OPT_NTASKSPERCORE},
+		{"tasks-per-node",  required_argument, 0, LONG_OPT_NTASKSPERNODE},
 		{"tmp",           required_argument, 0, LONG_OPT_TMP},
 		{"uid",           required_argument, 0, LONG_OPT_UID},
 		{"gid",           required_argument, 0, LONG_OPT_GID},
@@ -717,11 +537,12 @@ void set_options(const int argc, char **argv)
 		{"linux-image",   required_argument, 0, LONG_OPT_LINUX_IMAGE},
 		{"mloader-image", required_argument, 0, LONG_OPT_MLOADER_IMAGE},
 		{"ramdisk-image", required_argument, 0, LONG_OPT_RAMDISK_IMAGE},
+		{"acctg-freq",    required_argument, 0, LONG_OPT_ACCTG_FREQ},
 		{"no-shell",      no_argument,       0, LONG_OPT_NOSHELL},
 		{"get-user-env",  optional_argument, 0, LONG_OPT_GET_USER_ENV},
 		{NULL,            0,                 0, 0}
 	};
-	char *opt_string = "+a:c:C:d:D:F:g:hHIJ:kK::n:N:Op:qR:st:uU:vVw:W:x:";
+	char *opt_string = "+a:B:c:C:d:D:F:g:hHIJ:kK:L:m:n:N:Op:P:qR:st:uU:vVw:W:x:";
 
 	opt.progname = xbasename(argv[0]);
 	optind = 0;		
@@ -734,6 +555,24 @@ void set_options(const int argc, char **argv)
 				"information\n");
 			exit(1);
 			break;
+		case 'B':
+			opt.extra_set = verify_socket_core_thread_count(
+				optarg,
+				&opt.min_sockets_per_node,
+				&opt.max_sockets_per_node,
+				&opt.min_cores_per_socket,
+				&opt.max_cores_per_socket,
+				&opt.min_threads_per_core,
+				&opt.max_threads_per_core,
+				&opt.cpu_bind_type);
+
+
+			if (opt.extra_set == false) {
+				error("invalid resource allocation -B `%s'",
+					optarg);
+				exit(1);
+			}
+			break;
 		case 'c':
 			opt.cpus_set = true;
 			opt.cpus_per_task = 
@@ -743,9 +582,7 @@ void set_options(const int argc, char **argv)
 			xfree(opt.constraints);
 			opt.constraints = xstrdup(optarg);
 			break;
-		case 'd':
-			opt.dependency = _get_int(optarg, "dependency");
-			break;
+/* 		case 'd':	see 'P' below */
 		case 'D':
 			xfree(opt.cwd);
 			opt.cwd = xstrdup(optarg);
@@ -762,7 +599,7 @@ void set_options(const int argc, char **argv)
 			}
 			break;
 		case 'g':
-			if (_verify_geometry(optarg, opt.geometry))
+			if (verify_geometry(optarg, opt.geometry))
 				exit(1);
 			break;
 		case 'h':
@@ -789,6 +626,19 @@ void set_options(const int argc, char **argv)
 			}
 			opt.kill_command_signal_set = true;
 			break;
+		case 'L':
+			xfree(opt.licenses);
+			opt.licenses = xstrdup(optarg);
+			break;
+		case 'm':
+			opt.distribution = verify_dist_type(optarg, 
+							    &opt.plane_size);
+			if (opt.distribution == SLURM_DIST_UNKNOWN) {
+				error("distribution type `%s' " 
+				      "is not recognized", optarg);
+				exit(1);
+			}
+			break;
 		case 'n':
 			opt.nprocs_set = true;
 			opt.nprocs = 
@@ -796,9 +646,9 @@ void set_options(const int argc, char **argv)
 			break;
 		case 'N':
 			opt.nodes_set = 
-				_verify_node_count(optarg, 
-						   &opt.min_nodes,
-						   &opt.max_nodes);
+				verify_node_count(optarg, 
+						  &opt.min_nodes,
+						  &opt.max_nodes);
 			if (opt.nodes_set == false) {
 				exit(1);
 			}
@@ -810,6 +660,11 @@ void set_options(const int argc, char **argv)
 			xfree(opt.partition);
 			opt.partition = xstrdup(optarg);
 			break;
+		case 'd':
+		case 'P':
+			xfree(opt.dependency);
+			opt.dependency = xstrdup(optarg);
+			break;
 		case 'q':
 			opt.quiet++;
 			break;
@@ -834,7 +689,7 @@ void set_options(const int argc, char **argv)
 			opt.verbose++;
 			break;
 		case 'V':
-			_print_version();
+			print_slurm_version();
 			exit(0);
 			break;
 		case 'w':
@@ -896,15 +751,23 @@ void set_options(const int argc, char **argv)
 			}
 			break;
 		case LONG_OPT_MEM:
-			opt.realmem = (int) _to_bytes(optarg);
+			opt.realmem = (int) str_to_bytes(optarg);
 			if (opt.realmem < 0) {
 				error("invalid memory constraint %s", 
 				      optarg);
 				exit(1);
 			}
 			break;
+		case LONG_OPT_TASK_MEM:
+			opt.task_mem = (int) str_to_bytes(optarg);
+			if (opt.task_mem < 0) {
+				error("invalid memory constraint %s", 
+				      optarg);
+				exit(1);
+			}
+			break;
 		case LONG_OPT_TMP:
-			opt.tmpdisk = _to_bytes(optarg);
+			opt.tmpdisk = str_to_bytes(optarg);
 			if (opt.tmpdisk < 0) {
 				error("invalid tmp value %s", optarg);
 				exit(1);
@@ -921,7 +784,7 @@ void set_options(const int argc, char **argv)
 				fatal ("--gid=\"%s\" invalid", optarg);
 			break;
 		case LONG_OPT_CONNTYPE:
-			opt.conn_type = _verify_conn_type(optarg);
+			opt.conn_type = verify_conn_type(optarg);
 			break;
 		case LONG_OPT_BEGIN:
 			opt.begin = parse_time(optarg);
@@ -931,7 +794,7 @@ void set_options(const int argc, char **argv)
 			}
 			break;
 		case LONG_OPT_MAIL_TYPE:
-			opt.mail_type |= _parse_mail_type(optarg);
+			opt.mail_type |= parse_mail_type(optarg);
 			if (opt.mail_type == 0)
 				fatal("--mail-type=%s invalid", optarg);
 			break;
@@ -972,6 +835,48 @@ void set_options(const int argc, char **argv)
 			xfree(opt.comment);
 			opt.comment = xstrdup(optarg);
 			break;
+		case LONG_OPT_SOCKETSPERNODE:
+			get_resource_arg_range( optarg, "sockets-per-node",
+						&opt.min_sockets_per_node,
+						&opt.max_sockets_per_node,
+						true );
+			break;
+		case LONG_OPT_CORESPERSOCKET:
+			get_resource_arg_range( optarg, "cores-per-socket",
+						&opt.min_cores_per_socket,
+						&opt.max_cores_per_socket,
+						true);
+			break;
+		case LONG_OPT_THREADSPERCORE:
+			get_resource_arg_range( optarg, "threads-per-core",
+						&opt.min_threads_per_core,
+						&opt.max_threads_per_core,
+						true );
+			break;
+		case LONG_OPT_HINT:
+			if (verify_hint(optarg,
+				&opt.min_sockets_per_node,
+				&opt.max_sockets_per_node,
+				&opt.min_cores_per_socket,
+				&opt.max_cores_per_socket,
+				&opt.min_threads_per_core,
+				&opt.max_threads_per_core,
+				&opt.cpu_bind_type)) {
+				exit(1);
+			}
+			break;
+		case LONG_OPT_NTASKSPERNODE:
+			opt.ntasks_per_node = _get_int(optarg,
+				"ntasks-per-node");
+			break;
+		case LONG_OPT_NTASKSPERSOCKET:
+			opt.ntasks_per_socket = _get_int(optarg, 
+				"ntasks-per-socket");
+			break;
+		case LONG_OPT_NTASKSPERCORE:
+			opt.ntasks_per_core = _get_int(optarg,
+				"ntasks-per-core");
+			break;
 		case LONG_OPT_REBOOT:
 			opt.reboot = true;
 			break;
@@ -991,6 +896,9 @@ void set_options(const int argc, char **argv)
 			xfree(opt.ramdiskimage);
 			opt.ramdiskimage = xstrdup(optarg);
 			break;
+		case LONG_OPT_ACCTG_FREQ:
+			opt.acctg_freq = _get_int(optarg, "acctg-freq");
+			break;
 		case LONG_OPT_NOSHELL:
 			opt.no_shell = true;
 			break;
@@ -1068,7 +976,7 @@ static bool _opt_verify(void)
 		opt.mincpus = opt.cpus_per_task;
 
 	if ((opt.job_name == NULL) && (command_argc > 0))
-		opt.job_name = _base_name(command_argv[0]);
+		opt.job_name = base_name(command_argv[0]);
 
 	if ((opt.no_shell == false) && (command_argc == 0)) {
 		error("A local command is a required parameter!");
@@ -1096,11 +1004,88 @@ static bool _opt_verify(void)
 		verified = false;
 	}
 
+        /* When CR with memory as a CR is enabled we need to assign
+	 * adequate value or check the value to opt.mem */
+	if ((opt.realmem >= -1) && (opt.task_mem > 0)) {
+		if (opt.realmem == -1) {
+			opt.realmem = opt.task_mem;
+		} else if (opt.realmem < opt.task_mem) {
+			info("mem < task-mem - resizing mem to be equal "
+			     "to task-mem");
+			opt.realmem = opt.task_mem;
+		}
+	}
+	
+        /* Check to see if user has specified enough resources to
+	 * satisfy the plane distribution with the specified
+	 * plane_size.  
+	 * if (n/plane_size < N) and ((N-1) * plane_size >= n) -->
+	 * problem Simple check will not catch all the problem/invalid
+	 * cases.
+	 * The limitations of the plane distribution in the cons_res
+	 * environment are more extensive and are documented in the
+	 * SLURM reference guide.  */
+	if (opt.distribution == SLURM_DIST_PLANE && opt.plane_size) {
+		if ((opt.nprocs/opt.plane_size) < opt.min_nodes) {
+			if (((opt.min_nodes-1)*opt.plane_size) >= opt.nprocs) {
+#if(0)
+				info("Too few processes ((n/plane_size) %d < N %d) "
+				     "and ((N-1)*(plane_size) %d >= n %d)) ",
+				     opt.nprocs/opt.plane_size, opt.min_nodes, 
+				     (opt.min_nodes-1)*opt.plane_size, opt.nprocs);
+#endif
+				error("Too few processes for the requested "
+				      "{plane,node} distribution");
+				exit(1);
+			}
+		}
+	}
+
+	/* bound max_threads/cores from ntasks_cores/sockets */ 
+	if ((opt.max_threads_per_core <= 0) &&
+	    (opt.ntasks_per_core > 0)) {
+		opt.max_threads_per_core = opt.ntasks_per_core;
+		/* if cpu_bind_type doesn't already have a auto pref,
+		 * choose the level based on the level of ntasks
+		 */
+		if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
+					   CPU_BIND_TO_CORES |
+					   CPU_BIND_TO_THREADS))) {
+			opt.cpu_bind_type |= CPU_BIND_TO_CORES;
+		}
+	}
+	if ((opt.max_cores_per_socket <= 0) &&
+	    (opt.ntasks_per_socket > 0)) {
+		opt.max_cores_per_socket = opt.ntasks_per_socket;
+		/* if cpu_bind_type doesn't already have a auto pref,
+		 * choose the level based on the level of ntasks
+		 */
+		if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
+					   CPU_BIND_TO_CORES |
+					   CPU_BIND_TO_THREADS))) {
+			opt.cpu_bind_type |= CPU_BIND_TO_SOCKETS;
+		}
+	}
+
 	/* massage the numbers */
 	if (opt.nodes_set && !opt.nprocs_set) {
 		/* 1 proc / node default */
 		opt.nprocs = opt.min_nodes;
 
+		/* 1 proc / min_[socket * core * thread] default */
+		if (opt.min_sockets_per_node > 0) {
+			opt.nprocs *= opt.min_sockets_per_node;
+			opt.nprocs_set = true;
+		}
+		if (opt.min_cores_per_socket > 0) {
+			opt.nprocs *= opt.min_cores_per_socket;
+			opt.nprocs_set = true;
+		}
+		if (opt.min_threads_per_core > 0) {
+			opt.nprocs *= opt.min_threads_per_core;
+			opt.nprocs_set = true;
+		}
+
 	} else if (opt.nodes_set && opt.nprocs_set) {
 
 		/* 
@@ -1122,7 +1107,7 @@ static bool _opt_verify(void)
 
 	if (opt.time_limit_str) {
 		opt.time_limit = time_str2mins(opt.time_limit_str);
-		if (opt.time_limit < 0) {
+		if ((opt.time_limit < 0) && (opt.time_limit != INFINITE)) {
 			error("Invalid time limit specification");
 			exit(1);
 		}
@@ -1152,40 +1137,6 @@ static bool _opt_verify(void)
 	return verified;
 }
 
-static uint16_t _parse_mail_type(const char *arg)
-{
-	uint16_t rc;
-
-	if (strcasecmp(arg, "BEGIN") == 0)
-		rc = MAIL_JOB_BEGIN;
-	else if  (strcasecmp(arg, "END") == 0)
-		rc = MAIL_JOB_END;
-	else if (strcasecmp(arg, "FAIL") == 0)
-		rc = MAIL_JOB_FAIL;
-	else if (strcasecmp(arg, "ALL") == 0)
-		rc = MAIL_JOB_BEGIN |  MAIL_JOB_END |  MAIL_JOB_FAIL;
-	else
-		rc = 0;		/* failure */
-
-	return rc;
-}
-static char *_print_mail_type(const uint16_t type)
-{
-	if (type == 0)
-		return "NONE";
-
-	if (type == MAIL_JOB_BEGIN)
-		return "BEGIN";
-	if (type == MAIL_JOB_END)
-		return "END";
-	if (type == MAIL_JOB_FAIL)
-		return "FAIL";
-	if (type == (MAIL_JOB_BEGIN |  MAIL_JOB_END |  MAIL_JOB_FAIL))
-		return "ALL";
-
-	return "MULTIPLE";
-}
-
 /* helper function for printing options
  * 
  * warning: returns pointer to memory allocated on the stack.
@@ -1197,9 +1148,21 @@ static char *print_constraints()
 	if (opt.mincpus > 0)
 		xstrfmtcat(buf, "mincpus=%d ", opt.mincpus);
 
+	if (opt.minsockets > 0)
+		xstrfmtcat(buf, "minsockets=%d ", opt.minsockets);
+
+	if (opt.mincores > 0)
+		xstrfmtcat(buf, "mincores=%d ", opt.mincores);
+
+	if (opt.minthreads > 0)
+		xstrfmtcat(buf, "minthreads=%d ", opt.minthreads);
+
 	if (opt.realmem > 0)
 		xstrfmtcat(buf, "mem=%dM ", opt.realmem);
 
+	if (opt.task_mem > 0)
+		xstrfmtcat(buf, "task-mem=%dM ", opt.task_mem);
+
 	if (opt.tmpdisk > 0)
 		xstrfmtcat(buf, "tmp=%ld ", opt.tmpdisk);
 
@@ -1218,39 +1181,6 @@ static char *print_constraints()
 	return buf;
 }
 
-static char * 
-print_commandline()
-{
-	int i;
-	char buf[256];
-
-	buf[0] = '\0';
-	for (i = 0; i < command_argc; i++)
-		snprintf(buf, 256,  "%s", command_argv[i]);
-	return xstrdup(buf);
-}
-
-static char *
-print_geometry()
-{
-	int i;
-	char buf[32], *rc = NULL;
-
-	if ((SYSTEM_DIMENSIONS == 0)
-	||  (opt.geometry[0] == (uint16_t)NO_VAL))
-		return NULL;
-
-	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-		if (i > 0)
-			snprintf(buf, sizeof(buf), "x%u", opt.geometry[i]);
-		else
-			snprintf(buf, sizeof(buf), "%u", opt.geometry[i]);
-		xstrcat(rc, buf);
-	}
-
-	return rc;
-}
-
 /*
  * Takes a string containing the number or name of a signal and returns
  * the signal number.  The signal name is case insensitive, and may be of
@@ -1333,6 +1263,9 @@ static void _opt_list()
 	info("job name       : `%s'", opt.job_name);
 	if (opt.jobid != NO_VAL)
 		info("jobid          : %u", opt.jobid);
+	info("distribution   : %s", format_task_dist_states(opt.distribution));
+	if(opt.distribution == SLURM_DIST_PLANE)
+		info("plane size   : %u", opt.plane_size);
 	info("verbose        : %d", opt.verbose);
 	info("immediate      : %s", tf_(opt.immediate));
 	info("overcommit     : %s", tf_(opt.overcommit));
@@ -1345,16 +1278,13 @@ static void _opt_list()
 		info("nice           : %d", opt.nice);
 	info("account        : %s", opt.account);
 	info("comment        : %s", opt.comment);
-	if (opt.dependency == NO_VAL)
-		info("dependency     : none");
-	else
-		info("dependency     : %u", opt.dependency);
+	info("dependency     : %s", opt.dependency);
 	str = print_constraints();
 	info("constraints    : %s", str);
 	xfree(str);
 	if (opt.conn_type >= 0)
 		info("conn_type      : %u", opt.conn_type);
-	str = print_geometry();
+	str = print_geometry(opt.geometry);
 	info("geometry       : %s", str);
 	xfree(str);
 	info("reboot         : %s", opt.reboot ? "no" : "yes");
@@ -1372,9 +1302,19 @@ static void _opt_list()
 		slurm_make_time_str(&opt.begin, time_str, sizeof(time_str));
 		info("begin          : %s", time_str);
 	}
-	info("mail_type      : %s", _print_mail_type(opt.mail_type));
+	info("mail_type      : %s", print_mail_type(opt.mail_type));
 	info("mail_user      : %s", opt.mail_user);
-	str = print_commandline();
+	info("sockets-per-node  : %d - %d", opt.min_sockets_per_node,
+					    opt.max_sockets_per_node);
+	info("cores-per-socket  : %d - %d", opt.min_cores_per_socket,
+					    opt.max_cores_per_socket);
+	info("threads-per-core  : %d - %d", opt.min_threads_per_core,
+					    opt.max_threads_per_core);
+	info("ntasks-per-node   : %d", opt.ntasks_per_node);
+	info("ntasks-per-socket : %d", opt.ntasks_per_socket);
+	info("ntasks-per-core   : %d", opt.ntasks_per_core);
+	info("plane_size        : %u", opt.plane_size);
+	str = print_commandline(command_argc, command_argv);
 	info("user command   : `%s'", str);
 	xfree(str);
 
@@ -1387,10 +1327,10 @@ static void _usage(void)
 "              [[-c cpus-per-node] [-r n] [-p partition] [--hold] [-t minutes]\n"
 "              [--immediate] [--no-kill] [--overcommit] [-D path]\n"
 "              [--share] [-J jobname] [--jobid=id]\n"
-"              [--verbose] [--gid=group] [--uid=user]\n"
+"              [--verbose] [--gid=group] [--uid=user] [--licenses=names]\n"
 "              [-W sec] [--minsockets=n] [--mincores=n] [--minthreads=n]\n"
 "              [--contiguous] [--mincpus=n] [--mem=MB] [--tmp=MB] [-C list]\n"
-"              [--account=name] [--dependency=jobid] [--comment=name]\n"
+"              [--account=name] [--dependency=type:jobid] [--comment=name]\n"
 #ifdef HAVE_BG		/* Blue gene specific options */
 "              [--geometry=XxYxZ] [--conn-type=type] [--no-rotate] [ --reboot]\n"
 "              [--blrts-image=path] [--linux-image=path]\n"
@@ -1404,6 +1344,8 @@ static void _usage(void)
 
 static void _help(void)
 {
+	slurm_ctl_conf_t *conf;
+
         printf (
 "Usage: salloc [OPTIONS...] executable [args...]\n"
 "\n"
@@ -1411,6 +1353,7 @@ static void _help(void)
 "  -N, --nodes=N               number of nodes on which to run (N = min[-max])\n"
 "  -n, --tasks=N               number of processors required\n"
 "  -c, --cpus-per-task=ncpus   number of cpus required per task\n"
+"      --ntasks-per-node=n     number of tasks to invoke on each node\n"
 "  -p, --partition=partition   partition requested\n"
 "  -H, --hold                  submit job in held state\n"
 "  -t, --time=minutes          time limit\n"
@@ -1420,17 +1363,20 @@ static void _help(void)
 "  -K, --kill-command[=signal] signal to send terminating job\n"
 "  -O, --overcommit            overcommit resources\n"
 "  -s, --share                 share nodes with other jobs\n"
+"  -m, --distribution=type     distribution method for processes to nodes\n"
+"                              (type = block|cyclic|arbitrary)\n"
 "  -J, --job-name=jobname      name of job\n"
 "      --jobid=id              specify jobid to use\n"
 "  -W, --wait=sec              seconds to wait for allocation if not\n"
 "                              immediately available\n"
 "  -v, --verbose               verbose mode (multiple -v's increase verbosity)\n"
 "  -q, --quiet                 quiet mode (suppress informational messages)\n"
-"  -d, --dependency=jobid      defer job until specified jobid completes\n"
+"  -P, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "      --nice[=value]          decrease secheduling priority by value\n"
 "  -U, --account=name          charge job to specified account\n"
 "      --begin=time            defer job until HH:MM DD/MM/YY\n"
 "      --comment=name          arbitrary comment\n"
+"  -L, --licenses=names        required license, comma separated\n"
 "      --mail-type=type        notify on state change: BEGIN, END, FAIL or ALL\n"
 "      --mail-user=user        who to send email notification for job state changes\n"
 "      --bell                  ring the terminal bell when the job is allocated\n"
@@ -1455,8 +1401,32 @@ static void _help(void)
 "Consumable resources related options:\n" 
 "      --exclusive             allocate nodes in exclusive mode when\n" 
 "                              cpu consumable resource is enabled\n"
+"      --task-mem=MB           maximum amount of real memory per task\n"
+"                              required by the job.\n" 
+"                              --mem >= --job-mem if --mem is specified.\n" 
 "\n"
+"Affinity/Multi-core options: (when the task/affinity plugin is enabled)\n" 
+"  -B --extra-node-info=S[:C[:T]]            Expands to:\n"
+"      --sockets-per-node=S    number of sockets per node to allocate\n"
+"      --cores-per-socket=C    number of cores per socket to allocate\n"
+"      --threads-per-core=T    number of threads per core to allocate\n"
+"                              each field can be 'min[-max]' or wildcard '*'\n"
+"                              total cpus requested = (N x S x C x T)\n"
+"\n"
+"      --ntasks-per-socket=n   number of tasks to invoke on each socket\n"
+"      --ntasks-per-core=n     number of tasks to invoke on each core\n");
+	conf = slurm_conf_lock();
+	if (conf->task_plugin != NULL
+	    && strcasecmp(conf->task_plugin, "task/affinity") == 0) {
+		printf(
+"      --hint=                 Bind tasks according to application hints\n"
+"                              (see \"--hint=help\" for options)\n");
+	}
+	slurm_conf_unlock();
+
+        printf("\n"
 #ifdef HAVE_BG				/* Blue gene specific options */
+"\n"
   "Blue Gene related options:\n"
   "  -g, --geometry=XxYxZ        geometry constraints of the job\n"
   "  -R, --no-rotate             disable geometry rotation\n"
diff --git a/src/salloc/opt.h b/src/salloc/opt.h
index b66a318e401eaebcb3d7830fde8e02a654c11c67..3f964a93797c0e0f3b5d8d3b21d343ea0011f51b 100644
--- a/src/salloc/opt.h
+++ b/src/salloc/opt.h
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>,
  *    Christopher J. Morrone <morrone2@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,14 +62,28 @@ typedef struct salloc_options {
 	int  min_nodes;		/* --nodes=n,       -N n	*/ 
 	int  max_nodes;		/* --nodes=x-n,       -N x-n	*/ 
 	bool nodes_set;		/* true if nodes explicitly set */
+	int min_sockets_per_node; /* --sockets-per-node=n      */
+	int max_sockets_per_node; /* --sockets-per-node=x-n    */
+	int min_cores_per_socket; /* --cores-per-socket=n      */
+	int max_cores_per_socket; /* --cores-per-socket=x-n    */
+	int min_threads_per_core; /* --threads-per-core=n      */
+	int max_threads_per_core; /* --threads-per-core=x-n    */
+	int ntasks_per_node;   /* --ntasks-per-node=n	    */
+	int ntasks_per_socket; /* --ntasks-per-socket=n     */
+	int ntasks_per_core;   /* --ntasks-per-core=n	    */
+	cpu_bind_type_t cpu_bind_type; /* --cpu_bind=           */
+	bool extra_set;		/* true if extra node info explicitly set */
 	int  time_limit;	/* --time,   -t	(int minutes)	*/
 	char *time_limit_str;	/* --time,   -t (string)	*/
 	char *partition;	/* --partition=n,   -p n   	*/
 	enum task_dist_states
 		distribution;	/* --distribution=, -m dist	*/
+        uint32_t plane_size;    /* lllp distribution -> plane_size for
+				 * when -m plane=<# of lllp per
+				 * plane> */      
 	char *job_name;		/* --job-name=,     -J name	*/
 	unsigned int jobid;	/* --jobid=jobid		*/
-	unsigned int dependency;/* --dependency, -P jobid	*/
+	char *dependency;	/* --dependency, -P type:jobid	*/
 	int nice;		/* --nice			*/
 	char *account;		/* --account, -U acct_name	*/
 	char *comment;		/* --comment			*/
@@ -78,6 +92,8 @@ typedef struct salloc_options {
 
 	bool hold;		/* --hold, -H			*/
 	bool no_kill;		/* --no-kill, -k		*/
+	int	acctg_freq;	/* --acctg-freq=secs		*/
+	char *licenses;		/* --licenses, -L		*/
 	bool overcommit;	/* --overcommit -O		*/
 	int kill_command_signal;/* --kill-command, -K           */
 	bool kill_command_signal_set;
@@ -91,6 +107,7 @@ typedef struct salloc_options {
 	int minsockets;		/* --minsockets=n		*/
 	int mincores;		/* --mincores=n			*/
 	int minthreads;		/* --minthreads=n		*/
+	int task_mem;		/* --task-mem=n			*/
 	int realmem;		/* --mem=n			*/
 	long tmpdisk;		/* --tmp=n			*/
 	char *constraints;	/* --constraints=, -C constraint*/
diff --git a/src/salloc/salloc.c b/src/salloc/salloc.c
index d78f9d900fe79b5d39f20b6b42ce7d0fe1b6c87e..df7531c47e3b62143a97b733d1e587143bcb87ba 100644
--- a/src/salloc/salloc.c
+++ b/src/salloc/salloc.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -49,7 +49,6 @@
 
 #include "src/salloc/salloc.h"
 #include "src/salloc/opt.h"
-#include "src/salloc/msg.h"
 
 #define MAX_RETRIES 3
 
@@ -70,6 +69,11 @@ static void _pending_callback(uint32_t job_id);
 static void _ignore_signal(int signo);
 static void _exit_on_signal(int signo);
 static void _signal_while_allocating(int signo);
+static void _job_complete_handler(srun_job_complete_msg_t *msg);
+static void _timeout_handler(srun_timeout_msg_t *msg);
+static void _user_msg_handler(srun_user_msg_t *msg);
+static void _ping_handler(srun_ping_msg_t *msg);
+static void _node_fail_handler(srun_node_fail_msg_t *msg);
 
 int main(int argc, char *argv[])
 {
@@ -77,7 +81,7 @@ int main(int argc, char *argv[])
 	job_desc_msg_t desc;
 	resource_allocation_response_msg_t *alloc;
 	time_t before, after;
-	salloc_msg_thread_t *msg_thr;
+	allocation_msg_thread_t *msg_thr;
 	char **env = NULL;
 	int status = 0;
 	int errnum = 0;
@@ -86,6 +90,7 @@ int main(int argc, char *argv[])
 	pid_t rc_pid = 0;
 	int rc = 0;
 	static char *msg = "Slurm job queue full, sleeping and retrying.";
+	slurm_allocation_callbacks_t callbacks;
 
 	log_init(xbasename(argv[0]), logopt, 0, NULL);
 	if (initialize_and_process_args(argc, argv) < 0) {
@@ -126,9 +131,13 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
+	callbacks.ping = _ping_handler;
+	callbacks.timeout = _timeout_handler;
+	callbacks.job_complete = _job_complete_handler;
+	callbacks.user_msg = _user_msg_handler;
+	callbacks.node_fail = _node_fail_handler;
 	/* create message thread to handle pings and such from slurmctld */
-	msg_thr = msg_thr_create(&desc.other_port);
-	desc.other_hostname = xshort_hostname();
+	msg_thr = slurm_allocation_msg_thr_create(&desc.other_port, &callbacks);
 
 	xsignal(SIGHUP, _signal_while_allocating);
 	xsignal(SIGINT, _signal_while_allocating);
@@ -160,7 +169,7 @@ int main(int argc, char *argv[])
 		} else {
 			error("Failed to allocate resources: %m");
 		}
-		msg_thr_destroy(msg_thr);
+		slurm_allocation_msg_thr_destroy(msg_thr);
 		exit(1);
 	}
 	after = time(NULL);
@@ -204,6 +213,14 @@ int main(int argc, char *argv[])
 		env_array_append_fmt(&env, "SLURM_OVERCOMMIT", "%d", 
 			opt.overcommit);
 	}
+	if (opt.acctg_freq >= 0) {
+		env_array_append_fmt(&env, "SLURM_ACCTG_FREQ", "%d",
+			opt.acctg_freq);
+	}
+	if (opt.task_mem >= 0) {
+		env_array_append_fmt(&env, "SLURM_TASK_MEM", "%d",
+			opt.task_mem);
+	}
 	env_array_set_environment(env);
 	env_array_free(env);
 	pthread_mutex_lock(&allocation_state_lock);
@@ -240,7 +257,8 @@ relinquish:
 	pthread_mutex_lock(&allocation_state_lock);
 	if (allocation_state != REVOKED) {
 		info("Relinquishing job allocation %d", alloc->job_id);
-		if (slurm_complete_job(alloc->job_id, 0) != 0)
+		if (slurm_complete_job(alloc->job_id, status)
+		    != 0)
 			error("Unable to clean up job allocation %d: %m",
 			      alloc->job_id);
 		else
@@ -249,7 +267,7 @@ relinquish:
 	pthread_mutex_unlock(&allocation_state_lock);
 
 	slurm_free_resource_allocation_response_msg(alloc);
-	msg_thr_destroy(msg_thr);
+	slurm_allocation_msg_thr_destroy(msg_thr);
 
 	/*
 	 * Figure out what return code we should use.  If the user's command
@@ -257,6 +275,7 @@ relinquish:
 	 */
 	rc = 1;
 	if (rc_pid != -1) {
+		
 		if (WIFEXITED(status)) {
 			rc = WEXITSTATUS(status);
 		} else if (WIFSIGNALED(status)) {
@@ -284,7 +303,13 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 		desc->max_nodes = opt.max_nodes;
 	desc->user_id = opt.uid;
 	desc->group_id = opt.gid;
-	desc->dependency = opt.dependency;
+	if (opt.dependency)
+		desc->dependency = xstrdup(opt.dependency);
+	desc->task_dist  = opt.distribution;
+	if (opt.plane_size != NO_VAL)
+		desc->plane_size = opt.plane_size;
+	if (opt.licenses)
+		desc->licenses = xstrdup(opt.licenses);
 	if (opt.nice)
 		desc->nice = NICE_OFFSET + opt.nice;
 	desc->mail_type = opt.mail_type;
@@ -320,6 +345,8 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 		desc->mloaderimage = xstrdup(opt.mloaderimage);
 	if (opt.ramdiskimage)
 		desc->ramdiskimage = xstrdup(opt.ramdiskimage);
+
+	/* job constraints */
 	if (opt.mincpus > -1)
 		desc->job_min_procs = opt.mincpus;
 	if (opt.minsockets > -1)
@@ -341,6 +368,27 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 		desc->num_tasks = opt.nprocs;
 	if (opt.cpus_set)
 		desc->cpus_per_task = opt.cpus_per_task;
+	if (opt.ntasks_per_node > -1)
+		desc->ntasks_per_node = opt.ntasks_per_node;
+	if (opt.ntasks_per_socket > -1)
+		desc->ntasks_per_socket = opt.ntasks_per_socket;
+	if (opt.ntasks_per_core > -1)
+		desc->ntasks_per_core = opt.ntasks_per_core;
+
+	/* node constraints */
+	if (opt.min_sockets_per_node > -1)
+		desc->min_sockets = opt.min_sockets_per_node;
+	if (opt.max_sockets_per_node > -1)
+		desc->max_sockets = opt.max_sockets_per_node;
+	if (opt.min_cores_per_socket > -1)
+		desc->min_cores = opt.min_cores_per_socket;
+	if (opt.max_cores_per_socket > -1)
+		desc->max_cores = opt.max_cores_per_socket;
+	if (opt.min_threads_per_core > -1)
+		desc->min_threads = opt.min_threads_per_core;
+	if (opt.max_threads_per_core > -1)
+		desc->max_threads = opt.max_threads_per_core;
+
 	if (opt.no_kill)
 		desc->kill_on_node_fail = 0;
 	if (opt.time_limit  != NO_VAL)
@@ -402,3 +450,67 @@ static void _exit_on_signal(int signo)
 {
 	exit_flag = true;
 }
+
+/* This typically signifies the job was cancelled by scancel */
+static void _job_complete_handler(srun_job_complete_msg_t *comp)
+{
+	if (comp->step_id == NO_VAL) {
+		pthread_mutex_lock(&allocation_state_lock);
+		if (allocation_state != REVOKED) {
+			/* If the allocation_state is already REVOKED, then
+			 * no need to print this message.  We probably
+			 * relinquished the allocation ourself.
+			 */
+			info("Job allocation %u has been revoked.",
+			     comp->job_id);
+		}
+		if (allocation_state == GRANTED
+		    && command_pid > -1
+		    && opt.kill_command_signal_set) {
+			verbose("Sending signal %d to command \"%s\", pid %d",
+				opt.kill_command_signal,
+				command_argv[0], command_pid);
+			kill(command_pid, opt.kill_command_signal);
+		}
+		allocation_state = REVOKED;
+		pthread_mutex_unlock(&allocation_state_lock);
+	} else {
+		verbose("Job step %u.%u is finished.",
+			comp->job_id, comp->step_id);
+	}
+}
+
+/*
+ * Job has been notified of it's approaching time limit. 
+ * Job will be killed shortly after timeout.
+ * This RPC can arrive multiple times with the same or updated timeouts.
+ * FIXME: We may want to signal the job or perform other action for this.
+ * FIXME: How much lead time do we want for this message? Some jobs may 
+ *	require tens of minutes to gracefully terminate.
+ */
+static void _timeout_handler(srun_timeout_msg_t *msg)
+{
+	static time_t last_timeout = 0;
+
+	if (msg->timeout != last_timeout) {
+		last_timeout = msg->timeout;
+		verbose("Job allocation time limit to be reached at %s", 
+			ctime(&msg->timeout));
+	}
+}
+
+static void _user_msg_handler(srun_user_msg_t *msg)
+{
+	info("%s", msg->msg);
+}
+
+static void _ping_handler(srun_ping_msg_t *msg) 
+{
+	/* the api will respond so there really isn't anything to do
+	   here */
+}
+
+static void _node_fail_handler(srun_node_fail_msg_t *msg)
+{
+	error("Node failure on %s", msg->nodelist);
+}
diff --git a/src/salloc/salloc.h b/src/salloc/salloc.h
index 83d41b55ef6abfe3184a6c1042b8f1e87ba95f40..fbe7c43a7ea3097e24b6cb36077f03c55ea9f7fb 100644
--- a/src/salloc/salloc.h
+++ b/src/salloc/salloc.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sattach/Makefile.am b/src/sattach/Makefile.am
index fd9e764f4408ed23d3b0f2f9b1fea4dfe640a978..e38c68075d251b6d2b971ddfa205724f1c663bed 100644
--- a/src/sattach/Makefile.am
+++ b/src/sattach/Makefile.am
@@ -17,7 +17,7 @@ convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
 sattach_LDADD = \
 	$(convenience_libs) 
 
-sattach_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+sattach_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 
 force:
 $(convenience_libs) : force
diff --git a/src/sattach/Makefile.in b/src/sattach/Makefile.in
index 64e33cbdc2e650b323b564fe3b314f3b08d4d932..45cc34b83df72cbf94f7b64baad4e703f8820a48 100644
--- a/src/sattach/Makefile.in
+++ b/src/sattach/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -75,7 +77,7 @@ sattach_DEPENDENCIES = $(convenience_libs)
 sattach_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sattach_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -115,6 +117,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -128,10 +131,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -151,7 +157,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -162,6 +171,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -177,6 +188,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -192,6 +204,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -260,7 +273,7 @@ convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
 sattach_LDADD = \
 	$(convenience_libs) 
 
-sattach_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+sattach_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -303,8 +316,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -369,8 +382,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -382,8 +395,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -393,13 +406,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/sattach/attach.c b/src/sattach/attach.c
index c19433901b6e68dee29007b0ed017b982b834fd1..e4ca98076a5cefe338b9bece1aa9914dc82ec4ac 100644
--- a/src/sattach/attach.c
+++ b/src/sattach/attach.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  attach.c - Definitions needed for parallel debugger
- *  $Id: attach.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: attach.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sattach/opt.c b/src/sattach/opt.c
index 76463f276bbee2466e4ce4ffcf21d9126fa42724..b9abbf6fa1d0c07886cf18b2ea03954644ca5bee 100644
--- a/src/sattach/opt.c
+++ b/src/sattach/opt.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  opt.c - options processing for sattach
- *  $Id: opt.c 12143 2007-08-27 15:59:41Z jette $
+ *  $Id: opt.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sattach/opt.h b/src/sattach/opt.h
index 2d9f1a0ff08606fe1caa4a6e69d3fc18feeb6ceb..84681975affcdaaed36247d1bf1b633b197bb7ce 100644
--- a/src/sattach/opt.h
+++ b/src/sattach/opt.h
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  opt.h - definitions for sattach option processing
- *  $Id: opt.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: opt.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>,
  *    Christopher J. Morrone <morrone2@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sattach/sattach.c b/src/sattach/sattach.c
index 98fe02aaa162fbc224feaedf8e602a3b98f56f60..988d5970413225dede89d6d68bb365435349dc96 100644
--- a/src/sattach/sattach.c
+++ b/src/sattach/sattach.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -365,6 +365,7 @@ static message_thread_state_t *_msg_thr_create(int num_nodes, int num_tasks)
 	eio_obj_t *obj;
 	int i;
 	message_thread_state_t *mts;
+	pthread_attr_t attr;
 
 	debug("Entering _msg_thr_create()");
 	mts = (message_thread_state_t *)xmalloc(sizeof(message_thread_state_t));
@@ -386,11 +387,14 @@ static message_thread_state_t *_msg_thr_create(int num_nodes, int num_tasks)
 		eio_new_initial_obj(mts->msg_handle, obj);
 	}
 
-	if (pthread_create(&mts->msg_thread, NULL,
+	slurm_attr_init(&attr);
+	if (pthread_create(&mts->msg_thread, &attr,
 			   _msg_thr_internal, (void *)mts) != 0) {
 		error("pthread_create of message thread: %m");
+		slurm_attr_destroy(&attr);
 		goto fail;
 	}
+	slurm_attr_destroy(&attr);
 
 	return mts;
 fail:
@@ -558,7 +562,7 @@ _exit_handler(message_thread_state_t *mts, slurm_msg_t *exit_msg)
 static void
 _handle_msg(message_thread_state_t *mts, slurm_msg_t *msg)
 {
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	static uid_t slurm_uid;
 	static bool slurm_uid_set = false;
 	uid_t uid = getuid();
diff --git a/src/sbatch/Makefile.am b/src/sbatch/Makefile.am
index de93daff02fc4f3a53042c4d3a410a857a4455d6..de4ffb6aaabc6288ff314317d396c6cf713e1f36 100644
--- a/src/sbatch/Makefile.am
+++ b/src/sbatch/Makefile.am
@@ -10,10 +10,9 @@ sbatch_SOURCES = sbatch.c opt.c opt.h
 
 convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
 
-sbatch_LDADD = \
-	$(convenience_libs) 
+sbatch_LDADD = $(convenience_libs) 
 
-sbatch_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+sbatch_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 
 force:
 $(convenience_libs) : force
diff --git a/src/sbatch/Makefile.in b/src/sbatch/Makefile.in
index f30d9b1a6ed76319a564370ad771d321e0c0ea01..7cd63bdf96e48c6720c217cb9edce25bd2d3862b 100644
--- a/src/sbatch/Makefile.in
+++ b/src/sbatch/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -74,7 +76,7 @@ sbatch_DEPENDENCIES = $(convenience_libs)
 sbatch_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sbatch_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -114,6 +116,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -127,10 +130,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -150,7 +156,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -161,6 +170,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -176,6 +187,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -191,6 +203,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -251,10 +264,8 @@ AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir) 
 sbatch_SOURCES = sbatch.c opt.c opt.h
 convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
-sbatch_LDADD = \
-	$(convenience_libs) 
-
-sbatch_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+sbatch_LDADD = $(convenience_libs) 
+sbatch_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -297,8 +308,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -361,8 +372,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -374,8 +385,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -385,13 +396,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/sbatch/opt.c b/src/sbatch/opt.c
index f3cb693939b819f2e318fe993c9a4e89b60d770d..5c3daa39e9ec61d9369e6b2e0a5b0491a5973e4c 100644
--- a/src/sbatch/opt.c
+++ b/src/sbatch/opt.c
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  opt.c - options processing for sbatch
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -60,6 +61,8 @@
 #include "src/common/list.h"
 #include "src/common/log.h"
 #include "src/common/parse_time.h"
+#include "src/common/plugstack.h"
+#include "src/common/proc_args.h"
 #include "src/common/slurm_protocol_api.h"
 #include "src/common/uid.h"
 #include "src/common/xmalloc.h"
@@ -83,6 +86,10 @@
 #define OPT_MULTI	0x0f
 #define OPT_EXCLUSIVE	0x10
 #define OPT_OVERCOMMIT	0x11
+#define OPT_OPEN_MODE	0x12
+#define OPT_ACCTG_FREQ  0x13
+#define OPT_NO_REQUEUE  0x14
+#define OPT_REQUEUE     0x15
 
 /* generic getopt_long flags, integers and *not* valid characters */
 #define LONG_OPT_PROPAGATE   0x100
@@ -107,13 +114,22 @@
 #define LONG_OPT_COMMENT     0x117
 #define LONG_OPT_WRAP        0x118
 #define LONG_OPT_REQUEUE     0x119
+#define LONG_OPT_SOCKETSPERNODE  0x130
+#define LONG_OPT_CORESPERSOCKET  0x131
+#define LONG_OPT_THREADSPERCORE  0x132
+#define LONG_OPT_NTASKSPERNODE   0x136
+#define LONG_OPT_NTASKSPERSOCKET 0x137
+#define LONG_OPT_NTASKSPERCORE   0x138
+#define LONG_OPT_TASK_MEM        0x13a
+#define LONG_OPT_HINT            0x13b
 #define LONG_OPT_BLRTS_IMAGE     0x140
 #define LONG_OPT_LINUX_IMAGE     0x141
 #define LONG_OPT_MLOADER_IMAGE   0x142
 #define LONG_OPT_RAMDISK_IMAGE   0x143
 #define LONG_OPT_REBOOT          0x144
-#define LONG_OPT_TASKSPERNODE    0x145
 #define LONG_OPT_GET_USER_ENV    0x146
+#define LONG_OPT_OPEN_MODE       0x147
+#define LONG_OPT_ACCTG_FREQ      0x148
 
 /*---- global variables, defined in opt.h ----*/
 opt_t opt;
@@ -122,10 +138,6 @@ opt_t opt;
 
 typedef struct env_vars env_vars_t;
 
-/* return command name from its full path name */
-static char * _base_name(char* command);
-
-static List  _create_path_list(void);
 
 /* Get a decimal integer from arg */
 static int  _get_int(const char *arg, const char *what);
@@ -151,203 +163,18 @@ static void  _opt_list(void);
 /* verify options sanity  */
 static bool _opt_verify(void);
 
-static void  _print_version(void);
-
 static void _process_env_var(env_vars_t *e, const char *val);
 
-static uint16_t _parse_mail_type(const char *arg);
 static uint16_t _parse_pbs_mail_type(const char *arg);
-static char *_print_mail_type(const uint16_t type);
-
-/* search PATH for command returns full path */
-static char *_search_path(char *, bool, int);
-
-static long  _to_bytes(const char *arg);
 
 static void  _usage(void);
-static bool  _verify_node_count(const char *arg, int *min, int *max);
-static int   _verify_geometry(const char *arg, uint16_t *geometry);
-static int   _verify_conn_type(const char *arg);
-static char *_fullpath(const char *filename);
+static  void _fullpath(char **filename, const char *cwd);
 static void _set_options(int argc, char **argv);
 static void _set_pbs_options(int argc, char **argv);
 static void _parse_pbs_resource_list(char *rl);
 
 /*---[ end forward declarations of static functions ]---------------------*/
 
-static void _print_version(void)
-{
-	printf("%s %s\n", PACKAGE, SLURM_VERSION);
-}
-
-/*
- * verify that a connection type in arg is of known form
- * returns the connection_type or -1 if not recognized
- */
-static int _verify_conn_type(const char *arg)
-{
-	int len = strlen(arg);
-
-	if (!strncasecmp(arg, "MESH", len))
-		return SELECT_MESH;
-	else if (!strncasecmp(arg, "TORUS", len))
-		return SELECT_TORUS;
-	else if (!strncasecmp(arg, "NAV", len))
-		return SELECT_NAV;
-
-	error("invalid --conn-type argument %s ignored.", arg);
-	return -1;
-}
-
-/*
- * verify geometry arguments, must have proper count
- * returns -1 on error, 0 otherwise
- */
-static int _verify_geometry(const char *arg, uint16_t *geometry)
-{
-	char* token, *delimiter = ",x", *next_ptr;
-	int i, rc = 0;
-	char* geometry_tmp = xstrdup(arg);
-	char* original_ptr = geometry_tmp;
-
-	token = strtok_r(geometry_tmp, delimiter, &next_ptr);
-	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-		if (token == NULL) {
-			error("insufficient dimensions in --geometry");
-			rc = -1;
-			break;
-		}
-		geometry[i] = (uint16_t)atoi(token);
-		if (geometry[i] == 0 || geometry[i] == (uint16_t)NO_VAL) {
-			error("invalid --geometry argument");
-			rc = -1;
-			break;
-		}
-		geometry_tmp = next_ptr;
-		token = strtok_r(geometry_tmp, delimiter, &next_ptr);
-	}
-	if (token != NULL) {
-		error("too many dimensions in --geometry");
-		rc = -1;
-	}
-
-	if (original_ptr)
-		xfree(original_ptr);
-
-	return rc;
-}
-
-/* 
- * verify that a node count in arg is of a known form (count or min-max)
- * OUT min, max specified minimum and maximum node counts
- * RET true if valid
- */
-static bool 
-_verify_node_count(const char *arg, int *min_nodes, int *max_nodes)
-{
-	char *end_ptr;
-	double val1, val2;
-	
-	val1 = strtod(arg, &end_ptr);
-	if (end_ptr[0] == 'k' || end_ptr[0] == 'K') {
-		val1 *= 1024;
-		end_ptr++;
-	}
-
- 	if (end_ptr[0] == '\0') {
-		*min_nodes = val1;
-		return true;
-	}
-	
-	if (end_ptr[0] != '-')
-		return false;
-
-	val2 = strtod(&end_ptr[1], &end_ptr);
-	if (end_ptr[0] == 'k' || end_ptr[0] == 'K') {
-		val2 *= 1024;
-		end_ptr++;
-	}
-
-	if (end_ptr[0] == '\0') {
-		*min_nodes = val1;
-		*max_nodes = val2;
-		return true;
-	} else
-		return false;
-
-}
-
-/* return command name from its full path name */
-static char * _base_name(char* command)
-{
-	char *char_ptr, *name;
-	int i;
-
-	if (command == NULL)
-		return NULL;
-
-	char_ptr = strrchr(command, (int)'/');
-	if (char_ptr == NULL)
-		char_ptr = command;
-	else
-		char_ptr++;
-
-	i = strlen(char_ptr);
-	name = xmalloc(i+1);
-	strcpy(name, char_ptr);
-	return name;
-}
-
-/*
- * _to_bytes(): verify that arg is numeric with optional "G" or "M" at end
- * if "G" or "M" is there, multiply by proper power of 2 and return
- * number in bytes
- */
-static long _to_bytes(const char *arg)
-{
-	char *buf;
-	char *endptr;
-	int end;
-	int multiplier = 1;
-	long result;
-
-	buf = xstrdup(arg);
-
-	end = strlen(buf) - 1;
-
-	if (isdigit(buf[end])) {
-		result = strtol(buf, &endptr, 10);
-
-		if (*endptr != '\0')
-			result = -result;
-
-	} else {
-
-		switch (toupper(buf[end])) {
-
-		case 'G':
-			multiplier = 1024;
-			break;
-
-		case 'M':
-			/* do nothing */
-			break;
-
-		default:
-			multiplier = -1;
-		}
-
-		buf[end] = '\0';
-
-		result = multiplier * strtol(buf, &endptr, 10);
-
-		if (*endptr != '\0')
-			result = -result;
-	}
-
-	return result;
-}
-
 /*
  * print error message to stderr with opt.progname prepended
  */
@@ -399,25 +226,37 @@ static void _opt_default()
 	opt.nprocs_set = false;
 	opt.cpus_per_task = 1; 
 	opt.cpus_set = false;
-	opt.min_nodes = 1;
+	opt.min_nodes = 0;
 	opt.max_nodes = 0;
-	opt.tasks_per_node   = -1;
 	opt.nodes_set = false;
+	opt.min_sockets_per_node = NO_VAL; /* requested min/maxsockets */
+	opt.max_sockets_per_node = NO_VAL;
+	opt.min_cores_per_socket = NO_VAL; /* requested min/maxcores */
+	opt.max_cores_per_socket = NO_VAL;
+	opt.min_threads_per_core = NO_VAL; /* requested min/maxthreads */
+	opt.max_threads_per_core = NO_VAL;
+	opt.ntasks_per_node      = 0;      /* ntask max limits */
+	opt.ntasks_per_socket    = NO_VAL;
+	opt.ntasks_per_core      = NO_VAL;
+	opt.cpu_bind_type = 0;		/* local dummy variable for now */
 	opt.time_limit = NO_VAL;
 	opt.partition = NULL;
 
 	opt.job_name = NULL;
 	opt.jobid    = NO_VAL;
 	opt.jobid_set = false;
-	opt.dependency = NO_VAL;
+	opt.dependency = NULL;
 	opt.account  = NULL;
 	opt.comment  = NULL;
 
+	opt.distribution = SLURM_DIST_UNKNOWN;
+	opt.plane_size   = NO_VAL;
+
 	opt.shared = (uint16_t)NO_VAL;
 	opt.no_kill = false;
 
 	opt.immediate	= false;
-	opt.no_requeue	= false;
+	opt.requeue	= NO_VAL;
 	opt.overcommit	= false;
 
 	opt.quiet = 0;
@@ -428,6 +267,7 @@ static void _opt_default()
 	opt.minsockets      = -1;
 	opt.mincores        = -1;
 	opt.minthreads      = -1;
+	opt.task_mem	    = -1;
 	opt.realmem	    = -1;
 	opt.tmpdisk	    = -1;
 
@@ -454,6 +294,7 @@ static void _opt_default()
 
 	opt.get_user_env_time = -1;
 	opt.get_user_env_mode = -1;
+	opt.acctg_freq        = -1;
 }
 
 /*---[ env var processing ]-----------------------------------------------*/
@@ -486,13 +327,16 @@ env_vars_t env_vars[] = {
   {"SBATCH_JOB_NAME",      OPT_STRING,     &opt.job_name,      NULL           },
   {"SBATCH_LINUX_IMAGE",   OPT_STRING,     &opt.linuximage,    NULL           },
   {"SBATCH_MLOADER_IMAGE", OPT_STRING,     &opt.mloaderimage,  NULL           },
-  {"SBATCH_NO_REQUEUE",    OPT_BOOL,       &opt.no_requeue,    NULL           },
+  {"SBATCH_NO_REQUEUE",    OPT_NO_REQUEUE, NULL,               NULL           },
+  {"SBATCH_REQUEUE",       OPT_REQUEUE,    NULL,               NULL           },
   {"SBATCH_NO_ROTATE",     OPT_BOOL,       &opt.no_rotate,     NULL           },
   {"SBATCH_OVERCOMMIT",    OPT_OVERCOMMIT, NULL,               NULL           },
   {"SBATCH_PARTITION",     OPT_STRING,     &opt.partition,     NULL           },
   {"SBATCH_RAMDISK_IMAGE", OPT_STRING,     &opt.ramdiskimage,  NULL           },
   {"SBATCH_TIMELIMIT",     OPT_STRING,     &opt.time_limit_str,NULL           },
   {"SBATCH_EXCLUSIVE",     OPT_EXCLUSIVE,  NULL,               NULL           },
+  {"SBATCH_OPEN_MODE",     OPT_OPEN_MODE,  NULL,               NULL           },
+  {"SBATCH_ACCTG_FREQ",    OPT_INT,        &opt.acctg_freq,    NULL           },
   {NULL, 0, NULL, NULL}
 };
 
@@ -564,9 +408,9 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_NODES:
-		opt.nodes_set = _verify_node_count( val, 
-						    &opt.min_nodes, 
-						    &opt.max_nodes );
+		opt.nodes_set = verify_node_count( val, 
+						   &opt.min_nodes, 
+						   &opt.max_nodes );
 		if (opt.nodes_set == false) {
 			error("\"%s=%s\" -- invalid node count. ignoring...",
 			      e->var, val);
@@ -574,7 +418,7 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_CONN_TYPE:
-		opt.conn_type = _verify_conn_type(val);
+		opt.conn_type = verify_conn_type(val);
 		break;
 	
 	case OPT_NO_ROTATE:
@@ -582,7 +426,7 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_GEOMETRY:
-		if (_verify_geometry(val, opt.geometry)) {
+		if (verify_geometry(val, opt.geometry)) {
 			error("\"%s=%s\" -- invalid geometry, ignoring...",
 			      e->var, val);
 		}
@@ -596,6 +440,23 @@ _process_env_var(env_vars_t *e, const char *val)
 		opt.overcommit = true;
 		break;
 
+	case OPT_OPEN_MODE:
+		if ((val[0] == 'a') || (val[0] == 'A'))
+			opt.open_mode = OPEN_MODE_APPEND;
+		else if ((val[0] == 't') || (val[0] == 'T'))
+			opt.open_mode = OPEN_MODE_TRUNCATE;
+		else
+			error("Invalid SBATCH_OPEN_MODE: %s. Ignored", val);
+		break;
+
+	case OPT_NO_REQUEUE:
+		opt.requeue = 0;
+		break;
+
+	case OPT_REQUEUE:
+		opt.requeue = 1;
+		break;
+
 	default:
 		/* do nothing */
 		break;
@@ -610,9 +471,9 @@ static struct option long_options[] = {
 							 is only here for
 							 moab tansition
 							 doesn't do anything */
+	{"extra-node-info", required_argument, 0, 'B'},
 	{"cpus-per-task", required_argument, 0, 'c'},
 	{"constraint",    required_argument, 0, 'C'},
-	{"dependency",    required_argument, 0, 'd'},
 	{"workdir",       required_argument, 0, 'D'},
 	{"error",         required_argument, 0, 'e'},
 	{"nodefile",      required_argument, 0, 'F'},
@@ -623,12 +484,15 @@ static struct option long_options[] = {
 	{"immediate",     no_argument,       0, 'I'},
 	{"job-name",      required_argument, 0, 'J'},
 	{"no-kill",       no_argument,       0, 'k'},
+	{"licenses",      required_argument, 0, 'L'},
+	{"distribution",  required_argument, 0, 'm'},
 	{"tasks",         required_argument, 0, 'n'},	
 	{"ntasks",        required_argument, 0, 'n'},
 	{"nodes",         required_argument, 0, 'N'},
 	{"output",        required_argument, 0, 'o'},
 	{"overcommit",    no_argument,       0, 'O'},
 	{"partition",     required_argument, 0, 'p'},
+	{"dependency",    required_argument, 0, 'P'},
 	{"quiet",         no_argument,       0, 'q'},
 	{"no-rotate",     no_argument,       0, 'R'},
 	{"share",         no_argument,       0, 's'},
@@ -646,6 +510,9 @@ static struct option long_options[] = {
 	{"mincores",      required_argument, 0, LONG_OPT_MINCORES},
 	{"minthreads",    required_argument, 0, LONG_OPT_MINTHREADS},
 	{"mem",           required_argument, 0, LONG_OPT_MEM},
+	{"job-mem",       required_argument, 0, LONG_OPT_TASK_MEM},
+	{"task-mem",      required_argument, 0, LONG_OPT_TASK_MEM},
+	{"hint",          required_argument, 0, LONG_OPT_HINT},
 	{"tmp",           required_argument, 0, LONG_OPT_TMP},
 	{"jobid",         required_argument, 0, LONG_OPT_JOBID},
 	{"uid",           required_argument, 0, LONG_OPT_UID},
@@ -655,24 +522,31 @@ static struct option long_options[] = {
 	{"mail-type",     required_argument, 0, LONG_OPT_MAIL_TYPE},
 	{"mail-user",     required_argument, 0, LONG_OPT_MAIL_USER},
 	{"nice",          optional_argument, 0, LONG_OPT_NICE},
-	{"requeue",       no_argument,       0, LONG_OPT_REQUEUE},
 	{"no-requeue",    no_argument,       0, LONG_OPT_NO_REQUEUE},
+	{"requeue",       no_argument,       0, LONG_OPT_REQUEUE},
 	{"comment",       required_argument, 0, LONG_OPT_COMMENT},
+	{"sockets-per-node", required_argument, 0, LONG_OPT_SOCKETSPERNODE},
+	{"cores-per-socket", required_argument, 0, LONG_OPT_CORESPERSOCKET},
+	{"threads-per-core", required_argument, 0, LONG_OPT_THREADSPERCORE},
+	{"ntasks-per-node",  required_argument, 0, LONG_OPT_NTASKSPERNODE},
+	{"ntasks-per-socket",required_argument, 0, LONG_OPT_NTASKSPERSOCKET},
+	{"ntasks-per-core",  required_argument, 0, LONG_OPT_NTASKSPERCORE},
 	{"blrts-image",   required_argument, 0, LONG_OPT_BLRTS_IMAGE},
 	{"linux-image",   required_argument, 0, LONG_OPT_LINUX_IMAGE},
 	{"mloader-image", required_argument, 0, LONG_OPT_MLOADER_IMAGE},
 	{"ramdisk-image", required_argument, 0, LONG_OPT_RAMDISK_IMAGE},
 	{"reboot",        no_argument,       0, LONG_OPT_REBOOT},
-	{"tasks-per-node",  required_argument,0,LONG_OPT_TASKSPERNODE},
-	{"ntasks-per-node", required_argument,0,LONG_OPT_TASKSPERNODE}, 
+	{"tasks-per-node",required_argument, 0, LONG_OPT_NTASKSPERNODE},
 	{"wrap",          required_argument, 0, LONG_OPT_WRAP},
 	{"get-user-env",  optional_argument, 0, LONG_OPT_GET_USER_ENV},
+	{"open-mode",     required_argument, 0, LONG_OPT_OPEN_MODE},
+	{"acctg-freq",    required_argument, 0, LONG_OPT_ACCTG_FREQ},
 	{"propagate",     optional_argument, 0, LONG_OPT_PROPAGATE},
 	{NULL,            0,                 0, 0}
 };
 
 static char *opt_string =
-	"+a:bc:C:d:D:e:F:g:hHi:IJ:kn:N:o:Op:qR:st:uU:vVw:x:";
+	"+a:bB:c:C:d:D:e:F:g:hHi:IJ:kL:m:n:N:o:Op:P:qR:st:uU:vVw:x:";
 
 
 /*
@@ -694,6 +568,12 @@ char *process_options_first_pass(int argc, char **argv)
 {
 	int opt_char, option_index = 0;
 	char *str = NULL;
+	struct option *optz = spank_option_table_create (long_options);
+
+	if (!optz) {
+		error ("Unable to create option table");
+		exit (1);
+	}
 
 	/* initialize option defaults */
 	_opt_default();
@@ -702,7 +582,7 @@ char *process_options_first_pass(int argc, char **argv)
 	optind = 0;
 
 	while((opt_char = getopt_long(argc, argv, opt_string,
-				      long_options, &option_index)) != -1) {
+				      optz, &option_index)) != -1) {
 		switch (opt_char) {
 		case '?':
 			fprintf(stderr, "Try \"sbatch --help\" for more "
@@ -723,7 +603,7 @@ char *process_options_first_pass(int argc, char **argv)
 			opt.verbose++;
 			break;
 		case 'V':
-			_print_version();
+			print_slurm_version();
 			exit(0);
 			break;
 		case LONG_OPT_WRAP:
@@ -757,7 +637,7 @@ char *process_options_first_pass(int argc, char **argv)
 		char *cmd       = opt.script_argv[0];
 		int  mode       = R_OK;
 
-		if ((fullpath = _search_path(cmd, true, mode))) {
+		if ((fullpath = search_path(opt.cwd, cmd, true, mode))) {
 			xfree(opt.script_argv[0]);
 			opt.script_argv[0] = fullpath;
 		} 
@@ -1021,10 +901,16 @@ static void _set_options(int argc, char **argv)
 {
 	int opt_char, option_index = 0;
 	char *tmp;
+	struct option *optz = spank_option_table_create (long_options);
+
+	if (!optz) {
+		error ("Unable to create option table");
+		exit (1);
+	}
 
 	optind = 0;
 	while((opt_char = getopt_long(argc, argv, opt_string,
-				      long_options, &option_index)) != -1) {
+				      optz, &option_index)) != -1) {
 		switch (opt_char) {
 		case '?':
 			fatal("Try \"sbatch --help\" for more information");
@@ -1033,6 +919,24 @@ static void _set_options(int argc, char **argv)
 			/* Only here for Moab transition not suppose
 			   to do anything */
 			break;
+		case 'B':
+			opt.extra_set = verify_socket_core_thread_count(
+				optarg,
+				&opt.min_sockets_per_node,
+				&opt.max_sockets_per_node,
+				&opt.min_cores_per_socket,
+				&opt.max_cores_per_socket,
+				&opt.min_threads_per_core,
+				&opt.max_threads_per_core,
+				&opt.cpu_bind_type);
+
+
+			if (opt.extra_set == false) {
+				error("invalid resource allocation -B `%s'",
+					optarg);
+				exit(1);
+			}
+			break;
 		case 'c':
 			opt.cpus_set = true;
 			opt.cpus_per_task = 
@@ -1042,9 +946,7 @@ static void _set_options(int argc, char **argv)
 			xfree(opt.constraints);
 			opt.constraints = xstrdup(optarg);
 			break;
-		case 'd':
-			opt.dependency = _get_int(optarg, "dependency");
-			break;
+/*		case 'd': See 'P' below */
 		case 'D':
 			xfree(opt.cwd);
 			opt.cwd = xstrdup(optarg);
@@ -1054,7 +956,7 @@ static void _set_options(int argc, char **argv)
 			if (strncasecmp(optarg, "none", (size_t)4) == 0)
 				opt.efname = xstrdup("/dev/null");
 			else
-				opt.efname = _fullpath(optarg);
+				opt.efname = xstrdup(optarg);
 			break;
 		case 'F':
 			xfree(opt.nodelist);
@@ -1068,7 +970,7 @@ static void _set_options(int argc, char **argv)
 			}
 			break;
 		case 'g':
-			if (_verify_geometry(optarg, opt.geometry))
+			if (verify_geometry(optarg, opt.geometry))
 				exit(1);
 			break;
 		case 'h':
@@ -1082,7 +984,7 @@ static void _set_options(int argc, char **argv)
 			if (strncasecmp(optarg, "none", (size_t)4) == 0)
 				opt.ifname = xstrdup("/dev/null");
 			else
-				opt.ifname = _fullpath(optarg);
+				opt.ifname = xstrdup(optarg);
 			break;
 		case 'I':
 			opt.immediate = true;
@@ -1094,6 +996,19 @@ static void _set_options(int argc, char **argv)
 		case 'k':
 			opt.no_kill = true;
 			break;
+		case 'L':
+			xfree(opt.licenses);
+			opt.licenses = xstrdup(optarg);
+			break;
+		case 'm':
+			opt.distribution = verify_dist_type(optarg, 
+							    &opt.plane_size);
+			if (opt.distribution == SLURM_DIST_UNKNOWN) {
+				error("distribution type `%s' " 
+				      "is not recognized", optarg);
+				exit(1);
+			}
+			break;
 		case 'n':
 			opt.nprocs_set = true;
 			opt.nprocs = 
@@ -1101,9 +1016,9 @@ static void _set_options(int argc, char **argv)
 			break;
 		case 'N':
 			opt.nodes_set = 
-				_verify_node_count(optarg, 
-						   &opt.min_nodes,
-						   &opt.max_nodes);
+				verify_node_count(optarg, 
+						  &opt.min_nodes,
+						  &opt.max_nodes);
 			if (opt.nodes_set == false) {
 				error("invalid node count `%s'", 
 				      optarg);
@@ -1115,7 +1030,7 @@ static void _set_options(int argc, char **argv)
 			if (strncasecmp(optarg, "none", (size_t)4) == 0)
 				opt.ofname = xstrdup("/dev/null");
 			else
-				opt.ofname = _fullpath(optarg);
+				opt.ofname = xstrdup(optarg);
 			break;
 		case 'O':
 			opt.overcommit = true;
@@ -1124,6 +1039,12 @@ static void _set_options(int argc, char **argv)
 			xfree(opt.partition);
 			opt.partition = xstrdup(optarg);
 			break;
+		case 'd':
+		case 'P':
+			/* use -P instead */
+			xfree(opt.dependency);
+			opt.dependency = xstrdup(optarg);
+			break;
 		case 'q':
 			opt.quiet++;
 			break;
@@ -1148,7 +1069,7 @@ static void _set_options(int argc, char **argv)
 			opt.verbose++;
 			break;
 		case 'V':
-			_print_version();
+			print_slurm_version();
 			exit(0);
 			break;
 		case 'w':
@@ -1207,15 +1128,24 @@ static void _set_options(int argc, char **argv)
 			}
 			break;
 		case LONG_OPT_MEM:
-			opt.realmem = (int) _to_bytes(optarg);
+			opt.realmem = (int) str_to_bytes(optarg);
 			if (opt.realmem < 0) {
 				error("invalid memory constraint %s", 
 				      optarg);
 				exit(1);
 			}
 			break;
+		case LONG_OPT_TASK_MEM:
+			opt.task_mem = (int) str_to_bytes(optarg);
+			if (opt.task_mem < 0) {
+				error("invalid memory constraint %s", 
+				      optarg);
+				exit(1);
+			}
+			setenvf(NULL, "SLURM_TASK_MEM", "%d", opt.task_mem);
+			break;
 		case LONG_OPT_TMP:
-			opt.tmpdisk = _to_bytes(optarg);
+			opt.tmpdisk = str_to_bytes(optarg);
 			if (opt.tmpdisk < 0) {
 				error("invalid tmp value %s", optarg);
 				exit(1);
@@ -1236,7 +1166,7 @@ static void _set_options(int argc, char **argv)
 				fatal ("--gid=\"%s\" invalid", optarg);
 			break;
 		case LONG_OPT_CONNTYPE:
-			opt.conn_type = _verify_conn_type(optarg);
+			opt.conn_type = verify_conn_type(optarg);
 			break;
 		case LONG_OPT_BEGIN:
 			opt.begin = parse_time(optarg);
@@ -1246,7 +1176,7 @@ static void _set_options(int argc, char **argv)
 			}
 			break;
 		case LONG_OPT_MAIL_TYPE:
-			opt.mail_type |= _parse_mail_type(optarg);
+			opt.mail_type |= parse_mail_type(optarg);
 			if (opt.mail_type == 0)
 				fatal("--mail-type=%s invalid", optarg);
 			break;
@@ -1275,15 +1205,63 @@ static void _set_options(int argc, char **argv)
 			}
 			break;
 		case LONG_OPT_NO_REQUEUE:
-			opt.no_requeue = true;
+			opt.requeue = 0;
 			break;
 		case LONG_OPT_REQUEUE:
-			opt.no_requeue = false;	/* the default */
+			opt.requeue = 1;
 			break;
 		case LONG_OPT_COMMENT:
 			xfree(opt.comment);
 			opt.comment = xstrdup(optarg);
 			break;
+		case LONG_OPT_SOCKETSPERNODE:
+			get_resource_arg_range( optarg, "sockets-per-node",
+						&opt.min_sockets_per_node,
+						&opt.max_sockets_per_node,
+						true );
+			break;
+		case LONG_OPT_CORESPERSOCKET:
+			get_resource_arg_range( optarg, "cores-per-socket",
+						&opt.min_cores_per_socket,
+						&opt.max_cores_per_socket,
+						true);
+			break;
+		case LONG_OPT_THREADSPERCORE:
+			get_resource_arg_range( optarg, "threads-per-core",
+						&opt.min_threads_per_core,
+						&opt.max_threads_per_core,
+						true );
+			break;
+		case LONG_OPT_HINT:
+			if (verify_hint(optarg,
+				&opt.min_sockets_per_node,
+				&opt.max_sockets_per_node,
+				&opt.min_cores_per_socket,
+				&opt.max_cores_per_socket,
+				&opt.min_threads_per_core,
+				&opt.max_threads_per_core,
+				&opt.cpu_bind_type)) {
+				exit(1);
+			}
+			break;
+		case LONG_OPT_NTASKSPERNODE:
+			opt.ntasks_per_node = _get_int(optarg,
+				"ntasks-per-node");
+			setenvf(NULL, "SLURM_NTASKS_PER_NODE", "%d",
+				opt.ntasks_per_node);
+			break;
+		case LONG_OPT_NTASKSPERSOCKET:
+			opt.ntasks_per_socket = _get_int(optarg, 
+				"ntasks-per-socket");
+			setenvf(NULL, "SLURM_NTASKS_PER_SOCKET", "%d",
+				opt.ntasks_per_socket);
+			break;
+		case LONG_OPT_NTASKSPERCORE:
+			opt.ntasks_per_core = _get_int(optarg,
+				"ntasks-per-core");
+			setenvf(NULL, "SLURM_NTASKS_PER_CORE", "%d",
+				opt.ntasks_per_socket);
+			break;
 		case LONG_OPT_BLRTS_IMAGE:
 			xfree(opt.blrtsimage);
 			opt.blrtsimage = xstrdup(optarg);
@@ -1303,11 +1281,6 @@ static void _set_options(int argc, char **argv)
 		case LONG_OPT_REBOOT:
 			opt.reboot = true;
 			break;
-		case LONG_OPT_TASKSPERNODE:
-			opt.tasks_per_node = _get_int(optarg, "ntasks-per-node");
-			setenvf(NULL, "SLURM_NTASKS_PER_NODE", "%d",
-				opt.tasks_per_node);
-			break;
 		case LONG_OPT_WRAP:
 			/* handled in process_options_first_pass() */
 			break;
@@ -1317,6 +1290,19 @@ static void _set_options(int argc, char **argv)
 			else
 				opt.get_user_env_time = 0;
 			break;
+		case LONG_OPT_OPEN_MODE:
+			if ((optarg[0] == 'a') || (optarg[0] == 'A'))
+				opt.open_mode = OPEN_MODE_APPEND;
+			else if ((optarg[0] == 't') || (optarg[0] == 'T'))
+				opt.open_mode = OPEN_MODE_TRUNCATE;
+			else {
+				error("Invalid --open-mode argument: %s. "
+				      "Ignored", optarg);
+			}
+			break;
+		case LONG_OPT_ACCTG_FREQ:
+			opt.acctg_freq = _get_int(optarg, "acctg-freq");
+			break;
 		case LONG_OPT_PROPAGATE:
 			xfree(opt.propagate);
 			if (optarg)
@@ -1325,14 +1311,15 @@ static void _set_options(int argc, char **argv)
 				opt.propagate = xstrdup("ALL");
 			break;
 		default:
-			fatal("Unrecognized command line parameter %c",
-			      opt_char);
+			if (spank_process_option (opt_char, optarg) < 0)
+				 exit (1);
 		}
 	}
 
 	if (optind < argc) {
 		fatal("Invalid argument: %s", argv[optind]);
 	}
+	spank_option_table_destroy (optz);
 }
 
 static void _proc_get_user_env(char *optarg)
@@ -1627,7 +1614,7 @@ static void _parse_pbs_resource_list(char *rl)
 				 */
 				temp[end] = '\0';
 			}
-			opt.tmpdisk = _to_bytes(temp);
+			opt.tmpdisk = str_to_bytes(temp);
 			if (opt.tmpdisk < 0) {
 				error("invalid tmp value %s", temp);
 				exit(1);
@@ -1651,7 +1638,7 @@ static void _parse_pbs_resource_list(char *rl)
 				 */
 				temp[end] = '\0';
 			}
-			opt.realmem = (int) _to_bytes(temp);
+			opt.realmem = (int) str_to_bytes(temp);
 			if (opt.realmem < 0) {
 				error("invalid memory constraint %s", 
 				      temp);
@@ -1732,11 +1719,15 @@ static bool _opt_verify(void)
 		verified = false;
 	}
 
+	_fullpath(&opt.efname, opt.cwd);
+	_fullpath(&opt.ifname, opt.cwd);
+	_fullpath(&opt.ofname, opt.cwd);
+
 	if (opt.mincpus < opt.cpus_per_task)
 		opt.mincpus = opt.cpus_per_task;
 
 	if ((opt.job_name == NULL) && (opt.script_argc > 0))
-		opt.job_name = _base_name(opt.script_argv[0]);
+		opt.job_name = base_name(opt.script_argv[0]);
 
 	/* check for realistic arguments */
 	if (opt.nprocs <= 0) {
@@ -1751,17 +1742,95 @@ static bool _opt_verify(void)
 		verified = false;
 	}
 
-	if ((opt.min_nodes <= 0) || (opt.max_nodes < 0) || 
+	if ((opt.min_nodes < 0) || (opt.max_nodes < 0) || 
 	    (opt.max_nodes && (opt.min_nodes > opt.max_nodes))) {
 		error("%s: invalid number of nodes (-N %d-%d)\n",
 		      opt.progname, opt.min_nodes, opt.max_nodes);
 		verified = false;
 	}
 
+        /* When CR with memory as a CR is enabled we need to assign
+	 * adequate value or check the value to opt.mem */
+	if ((opt.realmem >= -1) && (opt.task_mem > 0)) {
+		if (opt.realmem == -1) {
+			opt.realmem = opt.task_mem;
+		} else if (opt.realmem < opt.task_mem) {
+			info("mem < task-mem - resizing mem to be equal "
+			     "to task-mem");
+			opt.realmem = opt.task_mem;
+		}
+	}
+	
+        /* Check to see if user has specified enough resources to
+	 * satisfy the plane distribution with the specified
+	 * plane_size.  
+	 * if (n/plane_size < N) and ((N-1) * plane_size >= n) -->
+	 * problem Simple check will not catch all the problem/invalid
+	 * cases.
+	 * The limitations of the plane distribution in the cons_res
+	 * environment are more extensive and are documented in the
+	 * SLURM reference guide.  */
+	if (opt.distribution == SLURM_DIST_PLANE && opt.plane_size) {
+		if ((opt.min_nodes <= 0) ||	
+		    ((opt.nprocs/opt.plane_size) < opt.min_nodes)) {
+			if (((opt.min_nodes-1)*opt.plane_size) >= opt.nprocs) {
+#if(0)
+				info("Too few processes ((n/plane_size) %d < N %d) "
+				     "and ((N-1)*(plane_size) %d >= n %d)) ",
+				     opt.nprocs/opt.plane_size, opt.min_nodes, 
+				     (opt.min_nodes-1)*opt.plane_size, opt.nprocs);
+#endif
+				error("Too few processes for the requested "
+				      "{plane,node} distribution");
+				exit(1);
+			}
+		}
+	}
+
+	/* bound max_threads/cores from ntasks_cores/sockets */ 
+	if ((opt.max_threads_per_core <= 0) &&
+	    (opt.ntasks_per_core > 0)) {
+		opt.max_threads_per_core = opt.ntasks_per_core;
+		/* if cpu_bind_type doesn't already have a auto pref,
+		 * choose the level based on the level of ntasks
+		 */
+		if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
+					   CPU_BIND_TO_CORES |
+					   CPU_BIND_TO_THREADS))) {
+			opt.cpu_bind_type |= CPU_BIND_TO_CORES;
+		}
+	}
+	if ((opt.max_cores_per_socket <= 0) &&
+	    (opt.ntasks_per_socket > 0)) {
+		opt.max_cores_per_socket = opt.ntasks_per_socket;
+		/* if cpu_bind_type doesn't already have a auto pref,
+		 * choose the level based on the level of ntasks
+		 */
+		if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
+					   CPU_BIND_TO_CORES |
+					   CPU_BIND_TO_THREADS))) {
+			opt.cpu_bind_type |= CPU_BIND_TO_SOCKETS;
+		}
+	}
+
 	/* massage the numbers */
-	if (opt.nodes_set && !opt.nprocs_set) {
+	if ((opt.nodes_set || opt.extra_set) && !opt.nprocs_set) {
 		/* 1 proc / node default */
-		opt.nprocs = opt.min_nodes;
+		opt.nprocs = MAX(opt.min_nodes, 1);
+
+		/* 1 proc / min_[socket * core * thread] default */
+		if (opt.min_sockets_per_node > 0) {
+			opt.nprocs *= opt.min_sockets_per_node;
+			opt.nprocs_set = true;
+		}
+		if (opt.min_cores_per_socket > 0) {
+			opt.nprocs *= opt.min_cores_per_socket;
+			opt.nprocs_set = true;
+		}
+		if (opt.min_threads_per_core > 0) {
+			opt.nprocs *= opt.min_threads_per_core;
+			opt.nprocs_set = true;
+		}
 
 	} else if (opt.nodes_set && opt.nprocs_set) {
 
@@ -1784,7 +1853,7 @@ static bool _opt_verify(void)
 
 	if (opt.time_limit_str) {
 		opt.time_limit = time_str2mins(opt.time_limit_str);
-		if (opt.time_limit < 0) {
+		if ((opt.time_limit < 0) && (opt.time_limit != INFINITE)) {
 			error("Invalid time limit specification");
 			exit(1);
 		}
@@ -1811,30 +1880,22 @@ static bool _opt_verify(void)
 		xfree(sched_name);
 	}
 
+	if (opt.open_mode) {
+		/* Propage mode to spawned job using environment variable */
+		if (opt.open_mode == OPEN_MODE_APPEND)
+			setenvf(NULL, "SLURM_OPEN_MODE", "a");
+		else
+			setenvf(NULL, "SLURM_OPEN_MODE", "t");
+	}
 	if (opt.propagate && parse_rlimits( opt.propagate, PROPAGATE_RLIMITS)) {
 		error( "--propagate=%s is not valid.", opt.propagate );
 		verified = false;
 	}
 
-	return verified;
-}
-
-static uint16_t _parse_mail_type(const char *arg)
-{
-	uint16_t rc;
-
-	if (strcasecmp(arg, "BEGIN") == 0)
-		rc = MAIL_JOB_BEGIN;
-	else if  (strcasecmp(arg, "END") == 0)
-		rc = MAIL_JOB_END;
-	else if (strcasecmp(arg, "FAIL") == 0)
-		rc = MAIL_JOB_FAIL;
-	else if (strcasecmp(arg, "ALL") == 0)
-		rc = MAIL_JOB_BEGIN |  MAIL_JOB_END |  MAIL_JOB_FAIL;
-	else
-		rc = 0;		/* failure */
+	if (opt.acctg_freq >= 0)
+		setenvf(NULL, "SLURM_ACCTG_FREQ", "%d", opt.acctg_freq); 
 
-	return rc;
+	return verified;
 }
 
 static uint16_t _parse_pbs_mail_type(const char *arg)
@@ -1867,101 +1928,6 @@ static uint16_t _parse_pbs_mail_type(const char *arg)
 	return rc;
 }
 
-static char *_print_mail_type(const uint16_t type)
-{
-	if (type == 0)
-		return "NONE";
-
-	if (type == MAIL_JOB_BEGIN)
-		return "BEGIN";
-	if (type == MAIL_JOB_END)
-		return "END";
-	if (type == MAIL_JOB_FAIL)
-		return "FAIL";
-	if (type == (MAIL_JOB_BEGIN |  MAIL_JOB_END |  MAIL_JOB_FAIL))
-		return "ALL";
-
-	return "MULTIPLE";
-}
-
-static void
-_freeF(void *data)
-{
-	xfree(data);
-}
-
-static List
-_create_path_list(void)
-{
-	List l = list_create(_freeF);
-	char *path, *c, *lc;
-
-	c = getenv("PATH");
-	if (!c) {
-		verbose("No PATH environment variable");
-		return l;
-	}
-
-	path = xstrdup(c);
-	c = lc = path;
-	while (*c != '\0') {
-		if (*c == ':') {
-			/* nullify and push token onto list */
-			*c = '\0';
-			if (lc != NULL && strlen(lc) > 0)
-				list_append(l, xstrdup(lc));
-			lc = ++c;
-		} else
-			c++;
-	}
-
-	if (strlen(lc) > 0)
-		list_append(l, xstrdup(lc));
-
-	xfree(path);
-
-	return l;
-}
-
-static char *
-_search_path(char *cmd, bool check_current_dir, int access_mode)
-{
-	List         l        = NULL;
-	ListIterator i        = NULL;
-	char *path, *fullpath = NULL;
-
-	if (  (cmd[0] == '.' || cmd[0] == '/') 
-           && (access(cmd, access_mode) == 0 ) ) {
-		if (cmd[0] == '.')
-			xstrfmtcat(fullpath, "%s/", opt.cwd);
-		xstrcat(fullpath, cmd);
-		goto done;
-	}
-
-	l = _create_path_list();
-	if (l == NULL)
-		return NULL;
-
-	if (check_current_dir) 
-		list_prepend(l, xstrdup(opt.cwd));
-
-	i = list_iterator_create(l);
-	while ((path = list_next(i))) {
-		xstrfmtcat(fullpath, "%s/%s", path, cmd);
-
-		if (access(fullpath, access_mode) == 0)
-			goto done;
-
-		xfree(fullpath);
-		fullpath = NULL;
-	}
-  done:
-	if (l)
-		list_destroy(l);
-	return fullpath;
-}
-
-
 /* helper function for printing options
  * 
  * warning: returns pointer to memory allocated on the stack.
@@ -1973,9 +1939,21 @@ static char *print_constraints()
 	if (opt.mincpus > 0)
 		xstrfmtcat(buf, "mincpus=%d ", opt.mincpus);
 
+	if (opt.minsockets > 0)
+		xstrfmtcat(buf, "minsockets=%d ", opt.minsockets);
+
+	if (opt.mincores > 0)
+		xstrfmtcat(buf, "mincores=%d ", opt.mincores);
+
+	if (opt.minthreads > 0)
+		xstrfmtcat(buf, "minthreads=%d ", opt.minthreads);
+
 	if (opt.realmem > 0)
 		xstrfmtcat(buf, "mem=%dM ", opt.realmem);
 
+	if (opt.task_mem > 0)
+		xstrfmtcat(buf, "task-mem=%dM ", opt.task_mem);
+
 	if (opt.tmpdisk > 0)
 		xstrfmtcat(buf, "tmp=%ld ", opt.tmpdisk);
 
@@ -1994,40 +1972,6 @@ static char *print_constraints()
 	return buf;
 }
 
-static char * 
-print_commandline()
-{
-	int i;
-	char buf[256];
-
-	buf[0] = '\0';
-	for (i = 0; i < opt.script_argc; i++)
-		snprintf(buf, 256,  "%s", opt.script_argv[i]);
-	return xstrdup(buf);
-}
-
-static char *
-print_geometry()
-{
-	int i;
-	char buf[32], *rc = NULL;
-
-	if ((SYSTEM_DIMENSIONS == 0)
-	||  (opt.geometry[0] == (uint16_t)NO_VAL))
-		return NULL;
-
-	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-		if (i > 0)
-			snprintf(buf, sizeof(buf), "x%u", opt.geometry[i]);
-		else
-			snprintf(buf, sizeof(buf), "%u", opt.geometry[i]);
-		xstrcat(rc, buf);
-	}
-
-	return rc;
-}
-
-
 /*
  *  Get a decimal integer from arg.
  *
@@ -2057,23 +2001,18 @@ _get_int(const char *arg, const char *what)
  * Return an absolute path for the "filename".  If "filename" is already
  * an absolute path, it returns a copy.  Free the returned with xfree().
  */
-static char *_fullpath(const char *filename)
+static void _fullpath(char **filename, const char *cwd)
 {
-	char cwd[BUFSIZ];
 	char *ptr = NULL;
 
-	if (filename[0] == '/') {
-		return xstrdup(filename);
-	} else {
-		if (getcwd(cwd, BUFSIZ) == NULL) {
-			error("could not get current working directory");
-			return NULL;
-		}
-		ptr = xstrdup(cwd);
-		xstrcat(ptr, "/");
-		xstrcat(ptr, filename);
-		return ptr;
-	}
+	if ((*filename == NULL) || (*filename[0] == '/'))
+		return;
+
+	ptr = xstrdup(cwd);
+	xstrcat(ptr, "/");
+	xstrcat(ptr, *filename);
+	xfree(*filename);
+	*filename = ptr;
 }
 
 #define tf_(b) (b == true) ? "true" : "false"
@@ -2104,9 +2043,13 @@ static void _opt_list()
 	info("partition      : %s",
 		opt.partition == NULL ? "default" : opt.partition);
 	info("job name       : `%s'", opt.job_name);
+	info("distribution   : %s", format_task_dist_states(opt.distribution));
+	if(opt.distribution == SLURM_DIST_PLANE)
+		info("plane size   : %u", opt.plane_size);
 	info("verbose        : %d", opt.verbose);
 	info("immediate      : %s", tf_(opt.immediate));
-	info("no-requeue     : %s", tf_(opt.no_requeue));
+	if (opt.requeue != NO_VAL)
+		info("requeue        : %u", opt.requeue);
 	info("overcommit     : %s", tf_(opt.overcommit));
 	if (opt.time_limit == INFINITE)
 		info("time_limit     : INFINITE");
@@ -2116,16 +2059,13 @@ static void _opt_list()
 		info("nice           : %d", opt.nice);
 	info("account        : %s", opt.account);
 	info("comment        : %s", opt.comment);
-	if (opt.dependency == NO_VAL)
-		info("dependency     : none");
-	else
-		info("dependency     : %u", opt.dependency);
+	info("dependency     : %s", opt.dependency);
 	str = print_constraints();
 	info("constraints    : %s", str);
 	xfree(str);
 	if (opt.conn_type != (uint16_t) NO_VAL)
 		info("conn_type      : %u", opt.conn_type);
-	str = print_geometry();
+	str = print_geometry(opt.geometry);
 	info("geometry       : %s", str);
 	xfree(str);
 	info("reboot         : %s", opt.reboot ? "no" : "yes");
@@ -2145,12 +2085,21 @@ static void _opt_list()
 		slurm_make_time_str(&opt.begin, time_str, sizeof(time_str));
 		info("begin          : %s", time_str);
 	}
-	info("mail_type      : %s", _print_mail_type(opt.mail_type));
+	info("mail_type      : %s", print_mail_type(opt.mail_type));
 	info("mail_user      : %s", opt.mail_user);
-	info("tasks-per-node : %d", opt.tasks_per_node);
+	info("sockets-per-node  : %d - %d", opt.min_sockets_per_node,
+					    opt.max_sockets_per_node);
+	info("cores-per-socket  : %d - %d", opt.min_cores_per_socket,
+					    opt.max_cores_per_socket);
+	info("threads-per-core  : %d - %d", opt.min_threads_per_core,
+					    opt.max_threads_per_core);
+	info("ntasks-per-node   : %d", opt.ntasks_per_node);
+	info("ntasks-per-socket : %d", opt.ntasks_per_socket);
+	info("ntasks-per-core   : %d", opt.ntasks_per_core);
+	info("plane_size        : %u", opt.plane_size);
 	info("propagate      : %s",
 	     opt.propagate == NULL ? "NONE" : opt.propagate);
-	str = print_commandline();
+	str = print_commandline(opt.script_argc, opt.script_argv);
 	info("remote command : `%s'", str);
 	xfree(str);
 
@@ -2162,25 +2111,27 @@ static void _usage(void)
 "Usage: sbatch [-N nnodes] [-n ntasks]\n"
 "              [-c ncpus] [-r n] [-p partition] [--hold] [-t minutes]\n"
 "              [-D path] [--immediate] [--no-kill] [--overcommit]\n"
-"              [--input file] [--output file] [--error file]\n"
+"              [--input file] [--output file] [--error file]  [--licenses=names]\n"
 "              [--workdir=directory] [--share] [-m dist] [-J jobname]\n"
 "              [--jobid=id] [--verbose] [--gid=group] [--uid=user]\n"
 "              [-W sec] [--minsockets=n] [--mincores=n] [--minthreads=n]\n"
 "              [--contiguous] [--mincpus=n] [--mem=MB] [--tmp=MB] [-C list]\n"
-"              [--account=name] [--dependency=jobid] [--comment=name]\n"
+"              [--account=name] [--dependency=type:jobid] [--comment=name]\n"
 #ifdef HAVE_BG		/* Blue gene specific options */
 "              [--geometry=XxYxZ] [--conn-type=type] [--no-rotate] [ --reboot]\n"
 "              [--blrts-image=path] [--linux-image=path]\n"
 "              [--mloader-image=path] [--ramdisk-image=path]\n"
 #endif
 "              [--mail-type=type] [--mail-user=user][--nice[=value]]\n"
-"              [--no-requeue] [--ntasks-per-node=n] [--propagate]\n"
+"              [--requeue] [--no-requeue] [--ntasks-per-node=n] [--propagate]\n"
 "              [--nodefile=file] [--nodelist=hosts] [--exclude=hosts]\n"
 "              executable [args...]\n");
 }
 
 static void _help(void)
 {
+	slurm_ctl_conf_t *conf;
+
         printf (
 "Usage: sbatch [OPTIONS...] executable [args...]\n"
 "\n"
@@ -2203,19 +2154,21 @@ static void _help(void)
 "      --jobid=id              run under already allocated job\n"
 "  -v, --verbose               verbose mode (multiple -v's increase verbosity)\n"
 "  -q, --quiet                 quiet mode (suppress informational messages)\n"
-"  -d, --dependency=jobid      defer job until specified jobid completes\n"
+"  -P, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "  -D, --workdir=directory     set working directory for batch script\n"
 "      --nice[=value]          decrease secheduling priority by value\n"
 "  -O, --overcommit            overcommit resources\n"
 "  -U, --account=name          charge job to specified account\n"
 "      --begin=time            defer job until HH:MM DD/MM/YY\n"
 "      --comment=name          arbitrary comment\n"
+"  -L, --licenses=names        required license, comma separated\n"
 "      --mail-type=type        notify on state change: BEGIN, END, FAIL or ALL\n"
 "      --mail-user=user        who to send email notification for job state changes\n"
 "      --gid=group_id          group ID to run job as (user root only)\n"
 "      --uid=user_id           user ID to run job as (user root only)\n"
 "      --get-user-env          used by Moab.  See srun man page.\n"
 "      --no-requeue            if set, do not permit the job to be requeued\n"
+"      --requeue               if set, permit the job to be requeued\n"
 "      --propagate[=rlimits]   propagate all [or specific list of] rlimits\n"
 "\n"
 "Constraint options:\n"
@@ -2234,7 +2187,33 @@ static void _help(void)
 "Consumable resources related options:\n" 
 "      --exclusive             allocate nodes in exclusive mode when\n" 
 "                              cpu consumable resource is enabled\n"
+"      --task-mem=MB           maximum amount of real memory per task\n"
+"                              required by the job.\n" 
+"                              --mem >= --job-mem if --mem is specified.\n" 
+"\n"
+"Affinity/Multi-core options: (when the task/affinity plugin is enabled)\n" 
+"  -B --extra-node-info=S[:C[:T]]            Expands to:\n"
+"      --sockets-per-node=S    number of sockets per node to allocate\n"
+"      --cores-per-socket=C    number of cores per socket to allocate\n"
+"      --threads-per-core=T    number of threads per core to allocate\n"
+"                              each field can be 'min[-max]' or wildcard '*'\n"
+"                              total cpus requested = (N x S x C x T)\n"
 "\n"
+"      --ntasks-per-socket=n   number of tasks to invoke on each socket\n"
+"      --ntasks-per-core=n     number of tasks to invoke on each core\n");
+	conf = slurm_conf_lock();
+	if (conf->task_plugin != NULL
+	    && strcasecmp(conf->task_plugin, "task/affinity") == 0) {
+		printf(
+"      --hint=                 Bind tasks according to application hints\n"
+"                              (see \"--hint=help\" for options)\n");
+	}
+	slurm_conf_unlock();
+
+	printf("\n");
+	spank_print_options (stdout, 6, 30);
+
+        printf("\n"
 #ifdef HAVE_BG				/* Blue gene specific options */
 "Blue Gene related options:\n"
 "  -g, --geometry=XxYxZ        geometry constraints of the job\n"
@@ -2246,8 +2225,8 @@ static void _help(void)
 "      --linux-image=path      path to linux image for bluegene block.  Default if not set\n"
 "      --mloader-image=path    path to mloader image for bluegene block.  Default if not set\n"
 "      --ramdisk-image=path    path to ramdisk image for bluegene block.  Default if not set\n"
-"\n"
 #endif
+"\n"
 "Help options:\n"
 "  -h, --help                  show this help message\n"
 "  -u, --usage                 display brief usage message\n"
diff --git a/src/sbatch/opt.h b/src/sbatch/opt.h
index 52a2feaae92209cb968801caa41f1823c03405ab..92565efb5c2dc71e6308f7b6ea49b0c363d3b5d0 100644
--- a/src/sbatch/opt.h
+++ b/src/sbatch/opt.h
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  opt.h - definitions for srun option processing
- *  $Id: opt.h 12856 2007-12-19 00:18:44Z jette $
+ *  $Id: opt.h 13771 2008-04-02 20:03:47Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>,
  *    Christopher J. Morrone <morrone2@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -42,6 +42,7 @@
 
 #define MAX_USERNAME	9
 
+
 typedef struct sbatch_options {
 	char *progname;		/* argv[0] of this program or   */
 
@@ -63,14 +64,30 @@ typedef struct sbatch_options {
 	int  min_nodes;		/* --nodes=n,       -N n	*/ 
 	int  max_nodes;		/* --nodes=x-n,       -N x-n	*/ 
 	bool nodes_set;		/* true if nodes explicitly set */
+	int min_sockets_per_node; /* --sockets-per-node=n      */
+	int max_sockets_per_node; /* --sockets-per-node=x-n    */
+	int min_cores_per_socket; /* --cores-per-socket=n      */
+	int max_cores_per_socket; /* --cores-per-socket=x-n    */
+	int min_threads_per_core; /* --threads-per-core=n      */
+	int max_threads_per_core; /* --threads-per-core=x-n    */
+	int ntasks_per_node;   /* --ntasks-per-node=n	    */
+	int ntasks_per_socket; /* --ntasks-per-socket=n     */
+	int ntasks_per_core;   /* --ntasks-per-core=n	    */
+	cpu_bind_type_t cpu_bind_type; /* --cpu_bind=           */
+	bool extra_set;		/* true if extra node info explicitly set */
 	int  time_limit;	/* --time,   -t	(int minutes)	*/
 	char *time_limit_str;	/* --time,   -t (string)	*/
 	char *partition;	/* --partition=n,   -p n   	*/
+	enum task_dist_states
+	        distribution;	/* --distribution=, -m dist	*/
+        uint32_t plane_size;    /* lllp distribution -> plane_size for
+				 * when -m plane=<# of lllp per
+				 * plane> */      
 	char *job_name;		/* --job-name=,     -J name	*/
 	unsigned int jobid;     /* --jobid=jobid                */
 	bool jobid_set;		/* true of jobid explicitly set */
 	char *mpi_type;		/* --mpi=type			*/
-	unsigned int dependency;/* --dependency, -P jobid	*/
+	char *dependency;	/* --dependency, -P type:jobid	*/
 	int nice;		/* --nice			*/
 	char *account;		/* --account, -U acct_name	*/
 	char *comment;		/* --comment			*/
@@ -80,9 +97,12 @@ typedef struct sbatch_options {
 
 	bool hold;		/* --hold, -H			*/
 	bool no_kill;		/* --no-kill, -k		*/
-	bool no_requeue;	/* --no-requeue			*/
+	int requeue;		/* --requeue and --no-requeue	*/
+	uint8_t open_mode;	/* --open-mode			*/
+	int acctg_freq;		/* --acctg-freq=secs		*/
 	bool overcommit;	/* --overcommit -O		*/
 	uint16_t shared;	/* --share,   -s		*/
+	char *licenses;		/* --licenses, -L		*/
 	int  quiet;
 	int  verbose;
 	char *wrap;
@@ -92,9 +112,9 @@ typedef struct sbatch_options {
 	int minsockets;		/* --minsockets=n		*/
 	int mincores;		/* --mincores=n			*/
 	int minthreads;		/* --minthreads=n		*/
+	int task_mem;		/* --task-mem=n			*/
 	int realmem;		/* --mem=n			*/
 	long tmpdisk;		/* --tmp=n			*/
-	int tasks_per_node;	/* --tasks-per-node=n		*/
 	char *constraints;	/* --constraints=, -C constraint*/
 	bool contiguous;	/* --contiguous			*/
 	char *nodelist;		/* --nodelist=node1,node2,...	*/
diff --git a/src/sbatch/sbatch.c b/src/sbatch/sbatch.c
index 9ad0b2a77f610ebeb0a1dd77390b1db6c7fe15a9..1b46e78dd1ba775e2186dbcd8c866fd9b1744e16 100644
--- a/src/sbatch/sbatch.c
+++ b/src/sbatch/sbatch.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  sbatch.c - Submit a SLURM batch script.
  *
- *  $Id: sbatch.c 13231 2008-02-08 17:16:47Z jette $
+ *  $Id: sbatch.c 14068 2008-05-19 15:58:22Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -41,6 +41,7 @@
 #include <slurm/slurm.h>
 
 #include "src/common/env.h"
+#include "src/common/plugstack.h"
 #include "src/common/read_config.h"
 #include "src/common/slurm_rlimits_info.h"
 #include "src/common/xstring.h"
@@ -50,6 +51,8 @@
 
 #define MAX_RETRIES 3
 
+static void _call_spank_local_user(job_desc_msg_t desc,
+				   submit_response_msg_t *resp);
 static int   fill_job_desc_from_opts(job_desc_msg_t *desc);
 static void *get_script_buffer(const char *filename, int *size);
 static void  set_prio_process_env(void);
@@ -68,6 +71,9 @@ int main(int argc, char *argv[])
 	int retries = 0;
 
 	log_init(xbasename(argv[0]), logopt, 0, NULL);
+	if (spank_init(NULL) < 0)
+		fatal("Plug-in initialization failed");
+
 	script_name = process_options_first_pass(argc, argv);
 	/* reinit log with new verbosity (if changed by command line) */
 	if (opt.verbose || opt.quiet) {
@@ -115,14 +121,31 @@ int main(int argc, char *argv[])
 			error(msg);
 		sleep (++retries);
         }
-
+	_call_spank_local_user(desc, resp);
 	info("Submitted batch job %d", resp->job_id);
 	xfree(desc.script);
 	slurm_free_submit_response_response_msg(resp);
-
+	spank_fini(NULL);
 	return 0;
 }
 
+static void _call_spank_local_user(job_desc_msg_t desc,
+				   submit_response_msg_t *resp)
+{
+	struct spank_launcher_job_info info[1];
+
+	info->uid = desc.user_id;
+	info->gid = desc.group_id;
+	info->jobid = resp->job_id;
+	info->stepid = SLURM_BATCH_SCRIPT;
+	info->step_layout = NULL;
+	info->argc = desc.argc;
+	info->argv = desc.argv;
+
+	if (spank_local_user(info) < 0)
+		error("spank_local_user: %m");
+}
+
 /* Returns 0 on success, -1 on failure */
 static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 {
@@ -140,12 +163,21 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 	desc->req_nodes = opt.nodelist;
 	desc->exc_nodes = opt.exc_nodes;
 	desc->partition = opt.partition;
-	desc->min_nodes = opt.min_nodes;
+	if (opt.min_nodes)
+		desc->min_nodes = opt.min_nodes;
+	if (opt.licenses)
+		desc->licenses = xstrdup(opt.licenses);
 	if (opt.max_nodes)
 		desc->max_nodes = opt.max_nodes;
+	if (opt.ntasks_per_node)
+		desc->ntasks_per_node = opt.ntasks_per_node;
 	desc->user_id = opt.uid;
 	desc->group_id = opt.gid;
-	desc->dependency = opt.dependency;
+	if (opt.dependency)
+		desc->dependency = xstrdup(opt.dependency);
+	desc->task_dist  = opt.distribution;
+	if (opt.plane_size != NO_VAL)
+		desc->plane_size = opt.plane_size;
 	if (opt.nice)
 		desc->nice = NICE_OFFSET + opt.nice;
 	desc->mail_type = opt.mail_type;
@@ -182,6 +214,7 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 	if (opt.ramdiskimage)
 		desc->ramdiskimage = xstrdup(opt.ramdiskimage);
 
+	/* job constraints */
 	if (opt.mincpus > -1)
 		desc->job_min_procs = opt.mincpus;
 	if (opt.minsockets > -1)
@@ -195,16 +228,33 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 	if (opt.tmpdisk > -1)
 		desc->job_min_tmp_disk = opt.tmpdisk;
 	if (opt.overcommit) {
-		desc->num_procs = opt.min_nodes;
+		desc->num_procs = MAX(opt.min_nodes, 1);
 		desc->overcommit = opt.overcommit;
 	} else
 		desc->num_procs = opt.nprocs * opt.cpus_per_task;
-	if (opt.tasks_per_node > -1)
-		desc->ntasks_per_node = opt.tasks_per_node;
 	if (opt.nprocs_set)
 		desc->num_tasks = opt.nprocs;
 	if (opt.cpus_set)
 		desc->cpus_per_task = opt.cpus_per_task;
+	if (opt.ntasks_per_socket > -1)
+		desc->ntasks_per_socket = opt.ntasks_per_socket;
+	if (opt.ntasks_per_core > -1)
+		desc->ntasks_per_core = opt.ntasks_per_core;
+
+	/* node constraints */
+	if (opt.min_sockets_per_node > -1)
+		desc->min_sockets = opt.min_sockets_per_node;
+	if (opt.max_sockets_per_node > -1)
+		desc->max_sockets = opt.max_sockets_per_node;
+	if (opt.min_cores_per_socket > -1)
+		desc->min_cores = opt.min_cores_per_socket;
+	if (opt.max_cores_per_socket > -1)
+		desc->max_cores = opt.max_cores_per_socket;
+	if (opt.min_threads_per_core > -1)
+		desc->min_threads = opt.min_threads_per_core;
+	if (opt.max_threads_per_core > -1)
+		desc->max_threads = opt.max_threads_per_core;
+
 	if (opt.no_kill)
 		desc->kill_on_node_fail = 0;
 	if (opt.time_limit != NO_VAL)
@@ -232,7 +282,12 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 	desc->in   = opt.ifname;
 	desc->out  = opt.ofname;
 	desc->work_dir = opt.cwd;
-	desc->no_requeue = opt.no_requeue;
+	if (opt.requeue != NO_VAL)
+		desc->requeue = opt.requeue;
+	if (opt.open_mode)
+		desc->open_mode = opt.open_mode;
+	if (opt.acctg_freq >= 0)
+		desc->acctg_freq = opt.acctg_freq;
 
 	return 0;
 }
diff --git a/src/sbcast/Makefile.in b/src/sbcast/Makefile.in
index d365b134ea07ded714575ad992986d174fd6c3d2..2dc5fa5ce1a02abaccadef0021eee82890c67cee 100644
--- a/src/sbcast/Makefile.in
+++ b/src/sbcast/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -48,6 +48,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -77,7 +79,7 @@ sbcast_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 sbcast_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sbcast_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -118,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -131,10 +134,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -154,7 +160,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -165,6 +174,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -180,6 +191,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -195,6 +207,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -364,8 +377,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -377,8 +390,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -388,13 +401,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/sbcast/agent.c b/src/sbcast/agent.c
index 00bfad4692ad3da18875d3acacd86508e95dfce0..7b69d71efb2711fb0a28bcb196c1748223d2262d 100644
--- a/src/sbcast/agent.c
+++ b/src/sbcast/agent.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sbcast/opts.c b/src/sbcast/opts.c
index d23c068b0dbb3b1cc93c4bb2de2e08c726d891e4..d0b4525848fad49e4a06fbf04a782e87f3bc172f 100644
--- a/src/sbcast/opts.c
+++ b/src/sbcast/opts.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sbcast/sbcast.c b/src/sbcast/sbcast.c
index 636641107d6326bc049e4a5493064110e89e2c98..07f6e6ac24705a3151951d1d963c0a3d0d8735cf 100644
--- a/src/sbcast/sbcast.c
+++ b/src/sbcast/sbcast.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -177,14 +177,15 @@ static ssize_t _get_block(char *buffer, size_t buf_size)
 /* read and broadcast the file */
 static void _bcast_file(void)
 {
-	int buf_size, i;
-	ssize_t size_block, size_read = 0;
+	int buf_size;
+	ssize_t size_read = 0;
 	file_bcast_msg_t bcast_msg;
-	char *buffer[FILE_BLOCKS];
+	char *buffer;
 
-	/* NOTE: packmem() uses 16 bits to express a block size, 
-	 * buf_size must be no larger than 64k - 1 */
-	buf_size = MIN((63 * 1024), f_stat.st_size);
+	if (params.block_size)
+		buf_size = MIN(params.block_size, f_stat.st_size);
+	else
+		buf_size = MIN((512 * 1024), f_stat.st_size);
 
 	bcast_msg.fname		= params.dst_fname;
 	bcast_msg.block_no	= 1;
@@ -193,11 +194,9 @@ static void _bcast_file(void)
 	bcast_msg.modes		= f_stat.st_mode;
 	bcast_msg.uid		= f_stat.st_uid;
 	bcast_msg.gid		= f_stat.st_gid;
-	for (i=0; i<FILE_BLOCKS; i++) {
-		buffer[i]              = xmalloc(buf_size);
-		bcast_msg.block[i]     = buffer[i];
-		bcast_msg.block_len[i] = 0;
-	}
+	buffer			= xmalloc(buf_size);
+	bcast_msg.block		= buffer;
+	bcast_msg.block_len	= 0;
 
 	if (params.preserve) {
 		bcast_msg.atime     = f_stat.st_atime;
@@ -208,29 +207,18 @@ static void _bcast_file(void)
 	}
 
 	while (1) {
-		size_block = 0;
-		for (i=0; i<FILE_BLOCKS; i++) {
-			bcast_msg.block_len[i] = 
-				_get_block(buffer[i], buf_size);
-			debug("block %d, size %u", (bcast_msg.block_no + i),
-				bcast_msg.block_len[i]);
-			size_read += bcast_msg.block_len[i];
-			if (size_read >= f_stat.st_size)
-				bcast_msg.last_block = 1;
-			size_block += bcast_msg.block_len[i];
-			if (params.block_size
-			&&  (size_block >= params.block_size)) {
-				for (i++; i<FILE_BLOCKS; i++)
-					bcast_msg.block_len[i] = 0;
-				break;
-			}
-		}
+		bcast_msg.block_len = _get_block(buffer, buf_size);
+		debug("block %d, size %u", bcast_msg.block_no,
+			bcast_msg.block_len);
+		size_read += bcast_msg.block_len;
+		if (size_read >= f_stat.st_size)
+			bcast_msg.last_block = 1;
+			
 		send_rpc(&bcast_msg, alloc_resp);
 		if (bcast_msg.last_block)
 			break;	/* end of file */
-		bcast_msg.block_no += FILE_BLOCKS;
+		bcast_msg.block_no++;
 	}
 
-	for (i=0; i<FILE_BLOCKS; i++)
-		xfree(buffer[i]);
+	xfree(buffer);
 }
diff --git a/src/sbcast/sbcast.h b/src/sbcast/sbcast.h
index 9a14292be2935ad35eb4d4a1dfdde6db359a8c31..3560c13f4742d25b5a977e56a1b9ca5074826edd 100644
--- a/src/sbcast/sbcast.h
+++ b/src/sbcast/sbcast.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/scancel/Makefile.in b/src/scancel/Makefile.in
index f1825207cab7856a48058aa2af371c1084b4a3c9..66ffc8f2174d730c9f4b422d5314464e6003f12c 100644
--- a/src/scancel/Makefile.in
+++ b/src/scancel/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -47,6 +47,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -76,7 +78,7 @@ scancel_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 scancel_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(scancel_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -117,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -130,10 +133,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -153,7 +159,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -164,6 +173,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -179,6 +190,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -194,6 +206,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -298,8 +311,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -362,8 +375,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -375,8 +388,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -386,13 +399,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/scancel/opt.c b/src/scancel/opt.c
index 93c9409f21cef84cb00612c7b733cdd4b0ddf328..0916bf4d00f1c7d36664dd1f039fbf8c4dce735a 100644
--- a/src/scancel/opt.c
+++ b/src/scancel/opt.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/scancel/scancel.c b/src/scancel/scancel.c
index b13b8816690142906535483a4099b7e6807831d6..10fb824840cb39119893edd8b5a4b00ecd15559b 100644
--- a/src/scancel/scancel.c
+++ b/src/scancel/scancel.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -229,17 +229,20 @@ static void
 _cancel_job_id (uint32_t job_id, uint16_t sig)
 {
 	int error_code = SLURM_SUCCESS, i;
+	bool sig_set = true;
 
-	if (sig == (uint16_t)-1)
+	if (sig == (uint16_t)-1) {
 		sig = SIGKILL;
+		sig_set = false;
+	}
 
 	for (i=0; i<MAX_CANCEL_RETRY; i++) {
-		if (sig == SIGKILL)
+		if (!sig_set)
 			verbose("Terminating job %u", job_id);
 		else
 			verbose("Signal %u to job %u", sig, job_id);
 
-		if ((sig == SIGKILL) || opt.ctld) {
+		if ((!sig_set) || opt.ctld) {
 			error_code = slurm_kill_job (job_id, sig,
 						     (uint16_t)opt.batch);
 		} else {
diff --git a/src/scancel/scancel.h b/src/scancel/scancel.h
index f3a020c9dde11e0cf701af5700746da47cd58b92..333b78b8543abbeab79bc488dfc249119a508dd2 100644
--- a/src/scancel/scancel.h
+++ b/src/scancel/scancel.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette<jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/scontrol/Makefile.in b/src/scontrol/Makefile.in
index 267cab5a81b90b987398ade8f543410f705507c7..a872200ea574537d09313886b268d21286c70ff3 100644
--- a/src/scontrol/Makefile.in
+++ b/src/scontrol/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -77,7 +79,7 @@ scontrol_DEPENDENCIES = $(convenience_libs) $(am__DEPENDENCIES_1)
 scontrol_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(scontrol_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -117,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -130,10 +133,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -153,7 +159,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -164,6 +173,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -179,6 +190,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -194,6 +206,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -310,8 +323,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -379,8 +392,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -392,8 +405,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -403,13 +416,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/scontrol/info_job.c b/src/scontrol/info_job.c
index fc99620c99338bc3e6dc9239142b4c7283e88183..488ae8b683fbde6303925b0c2cf3a8378b1c44e4 100644
--- a/src/scontrol/info_job.c
+++ b/src/scontrol/info_job.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/scontrol/info_node.c b/src/scontrol/info_node.c
index f4706c57160ee50d4fe8ef1974583a7294730e19..78acfbc05a1ed55c66c23ce94731019c64ac93b2 100644
--- a/src/scontrol/info_node.c
+++ b/src/scontrol/info_node.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/scontrol/info_part.c b/src/scontrol/info_part.c
index baa6c4454e11cbf7d0c5a5fa394c006c785f9bbe..8c9e060696813ffe363deeef7c8066dcd9b40435 100644
--- a/src/scontrol/info_part.c
+++ b/src/scontrol/info_part.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/scontrol/scontrol.c b/src/scontrol/scontrol.c
index 86fc0095ce20c59c55339cab93fb82b829a678cf..5ffd7091c7413ee6f0534d62ba003ee11b6d40a6 100644
--- a/src/scontrol/scontrol.c
+++ b/src/scontrol/scontrol.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -572,7 +572,7 @@ _process_command (int argc, char *argv[])
 				        argv[0]);
 		}
 		else {
-			error_code =scontrol_checkpoint(argv[1], argv[2]);
+			error_code = scontrol_checkpoint(argv[1], argv[2]);
 			if (error_code) {
 				exit_code = 1;
 				if (quiet_flag != 1)
@@ -594,7 +594,7 @@ _process_command (int argc, char *argv[])
 					"too few arguments for keyword:%s\n",
 					argv[0]);
 		} else {
-			error_code =scontrol_requeue(argv[1]);
+			error_code = scontrol_requeue(argv[1]);
 			if (error_code) {
 				exit_code = 1;
 				if (quiet_flag != 1)
@@ -627,6 +627,51 @@ _process_command (int argc, char *argv[])
 			}
 		}
 	}
+	else if (strncasecmp (argv[0], "setdebug", 4) == 0) {
+		if (argc > 2) {
+			exit_code = 1;
+			if (quiet_flag != 1)
+				fprintf(stderr, "too many arguments for keyword:%s\n",
+					argv[0]);
+		} else if (argc < 2) {
+			exit_code = 1;
+			if (quiet_flag != 1)
+				fprintf(stderr, "too few arguments for keyword:%s\n",
+					argv[0]);
+		} else {
+			int level = -1;
+			char *endptr;
+			char *levels[] = {
+				"quiet", "fatal", "error", "info", "verbose",
+				"debug", "debug2", "debug3", "debug4", "debug5", NULL};
+			int index = 0;
+			while (levels[index]) {
+				if (strcasecmp(argv[1], levels[index]) == 0) {
+					level = index;
+					break;
+				}
+				index ++;
+			}
+			if (level == -1) {
+				level = (int)strtoul (argv[1], &endptr, 10);    /* effective levels: 0 - 9 */
+				if (*endptr != '\0' || level > 9) {
+					level = -1;
+					exit_code = 1;
+					if (quiet_flag != 1)
+						fprintf(stderr, "invalid debug level: %s\n",
+							argv[1]);
+				}
+			}
+			if (level != -1) {
+				error_code = slurm_set_debug_level(level);
+				if (error_code) {
+					exit_code = 1;
+					if (quiet_flag != 1)
+						slurm_perror ("slurm_set_debug_level error");
+				}
+			}
+		}
+	}
 	else if (strncasecmp (argv[0], "show", 3) == 0) {
 		if (argc > 3) {
 			exit_code = 1;
@@ -773,6 +818,17 @@ _process_command (int argc, char *argv[])
 					    argc <= 2 ? NULL : argv[2]);
 		}
 	}
+	else if (strncasecmp (argv[0], "notify", 6) == 0) {
+		if (argc < 3) {
+			exit_code = 1;
+			fprintf (stderr, 
+				 "too few arguments for keyword:%s\n", 
+				 argv[0]);
+		} else if (scontrol_job_notify(argc-1, &argv[1])) {
+			exit_code = 1;
+			slurm_perror("job notify failure");
+		}
+	}
 	else {
 		exit_code = 1;
 		fprintf (stderr, "invalid keyword: %s\n", argv[0]);
@@ -996,6 +1052,7 @@ scontrol [<OPTION>] [<COMMAND>]                                            \n\
                               scontrol is ran on, and only for those       \n\
                               processes spawned by SLURM and their         \n\
                               descendants)                                 \n\
+     notify <job_id> msg      send message to specified job                \n\
      oneliner                 report output one record per line.           \n\
      pidinfo <pid>            return slurm job information for given pid.  \n\
      ping                     print status of slurmctld daemons.           \n\
@@ -1003,11 +1060,13 @@ scontrol [<OPTION>] [<COMMAND>]                                            \n\
      quit                     terminate this command.                      \n\
      reconfigure              re-read configuration files.                 \n\
      requeue <job_id>         re-queue a batch job                         \n\
+     setdebug <LEVEL>         reset slurmctld debug level                  \n\
      show <ENTITY> [<ID>]     display state of identified entity, default  \n\
                               is all records.                              \n\
      shutdown                 shutdown slurm controller.                   \n\
      suspend <job_id>         susend specified job                         \n\
      resume <job_id>          resume previously suspended job              \n\
+     setdebug <level>         set slurmctld debug level                    \n\
      update <SPECIFICATIONS>  update job, node, partition, or bluegene     \n\
                               block/subbp configuration                    \n\
      verbose                  enable detailed logging.                     \n\
@@ -1025,6 +1084,10 @@ scontrol [<OPTION>] [<COMMAND>]                                            \n\
        absolute pathname of a file (with leading '/' containing host names \n\
        either separated by commas or new-lines                             \n\
                                                                            \n\
+  <LEVEL> may be an integer value like SlurmctldDebug in the slurm.conf    \n\
+       file or the name of the most detailed errors to report (e.g. \"info\",\n\
+       \"verbose\", \"debug\", \"debug2\", etc.).                          \n\
+                                                                           \n\
   Node names may be specified using simple range expressions,              \n\
   (e.g. \"lx[10-20]\" corresponsds to lx10, lx11, lx12, ...)               \n\
   The job step id is the job id followed by a period and the step id.      \n\
diff --git a/src/scontrol/scontrol.h b/src/scontrol/scontrol.h
index f943382c333f9e78287dbf4a50c8fb850bbea9ac..3fd1d289736780c86813396c74705a571e0ab513 100644
--- a/src/scontrol/scontrol.h
+++ b/src/scontrol/scontrol.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -99,6 +99,7 @@ extern int quiet_flag;	/* quiet=1, verbose=-1, normal=0 */
 
 extern int	scontrol_checkpoint(char *op, char *job_step_id_str);
 extern int	scontrol_encode_hostlist(char *hostlist);
+extern int	scontrol_job_notify(int argc, char *argv[]);
 extern int 	scontrol_load_jobs (job_info_msg_t ** job_buffer_pptr);
 extern int 	scontrol_load_nodes (node_info_msg_t ** node_buffer_pptr, 
 			uint16_t show_flags);
diff --git a/src/scontrol/update_job.c b/src/scontrol/update_job.c
index 281c27b1a590ce21459d8bae783a86af26182082..49ae2df8ab6a1baaf52ce4c9e21d80307275241b 100644
--- a/src/scontrol/update_job.c
+++ b/src/scontrol/update_job.c
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  update_job.c - update job functions for scontrol.
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -214,13 +215,13 @@ scontrol_update_job (int argc, char *argv[])
 			update_cnt++;
 		}
 		else if (strncasecmp(argv[i], "TimeLimit=", 10) == 0) {
-			if ((strcasecmp(&argv[i][10], "UNLIMITED") == 0) ||
-			    (strcasecmp(&argv[i][10], "INFINITE") == 0))
-				job_msg.time_limit = INFINITE;
-			else
-				job_msg.time_limit = 
-					(uint32_t) strtol(&argv[i][10], 
-							  (char **) NULL, 10);
+			int time_limit = time_str2mins(&argv[i][10]);
+			if ((time_limit < 0) && (time_limit != INFINITE)) {
+				error("Invalid TimeLimit value");
+				exit_code = 1;
+				return 0;
+			}
+			job_msg.time_limit = time_limit;
 			update_cnt++;
 		}
 		else if (strncasecmp(argv[i], "Priority=", 9) == 0) {
@@ -251,6 +252,12 @@ scontrol_update_job (int argc, char *argv[])
 						(char **) NULL, 10);
 			update_cnt++;
 		}
+		else if (strncasecmp(argv[i], "Requeue=", 8) == 0) {
+			job_msg.requeue = 
+				(uint16_t) strtol(&argv[i][8], 
+						(char **) NULL, 10);
+			update_cnt++;
+		}
 		else if ((strncasecmp(argv[i], "MinNodes=", 9) == 0) ||
 		         (strncasecmp(argv[i], "ReqNodes=", 9) == 0)) {
 			char *tmp;
@@ -376,9 +383,7 @@ scontrol_update_job (int argc, char *argv[])
 			update_cnt++;
 		}
 		else if (strncasecmp(argv[i], "Dependency=", 11) == 0) {
-			job_msg.dependency =
-				(uint32_t) strtol(&argv[i][11],
-					(char **) NULL, 10);
+			job_msg.dependency = &argv[i][11];
 			update_cnt++;
 		}
 #ifdef HAVE_BG
@@ -435,6 +440,10 @@ scontrol_update_job (int argc, char *argv[])
 			update_cnt++;
 		}
 #endif
+		else if (strncasecmp(argv[i], "Licenses=", 9) == 0) {
+			job_msg.licenses = &argv[i][9];
+			update_cnt++;
+		}
 		else if (strncasecmp(argv[i], "StartTime=", 10) == 0) {
 			job_msg.begin_time = parse_time(&argv[i][10]);
 			update_cnt++;
@@ -458,3 +467,35 @@ scontrol_update_job (int argc, char *argv[])
 	else
 		return 0;
 }
+
+/*
+ * Send message to stdout of specified job
+ * argv[0] == jobid
+ * argv[1]++ the message
+ */
+extern int
+scontrol_job_notify(int argc, char *argv[])
+{
+	int i;
+	uint32_t job_id;
+	char message[256];
+
+	job_id = atoi(argv[0]);
+	if (job_id <= 0) {
+		fprintf(stderr, "Invalid job_id %s", argv[0]);
+		return 1;
+	}
+
+	message[0] = '\0';
+	for (i=1; i<argc; i++) {
+		if (i > 1)
+			strncat(message, " ", sizeof(message));
+		strncat(message, argv[i], sizeof(message));
+	}
+			
+	if (slurm_notify_job(job_id, message))
+		return slurm_get_errno ();
+	else
+		return 0;
+}
+
diff --git a/src/scontrol/update_node.c b/src/scontrol/update_node.c
index fcd347790707d9b1627bcf2c9c3729b875c822b4..2623cf5b3696af8e5a621204aca39ed8229fce55 100644
--- a/src/scontrol/update_node.c
+++ b/src/scontrol/update_node.c
@@ -1,10 +1,10 @@
 /*****************************************************************************\
  *  update_node.c - node update function for scontrol.
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -103,6 +103,10 @@ scontrol_update_node (int argc, char *argv[])
 			node_msg.node_state = NODE_STATE_DRAIN;
 			update_cnt++;
 		}
+		else if (strncasecmp(argv[i], "State=FAIL", 10) == 0) {
+			node_msg.node_state = NODE_STATE_FAIL;
+			update_cnt++;
+		}
 		else if (strncasecmp(argv[i], "State=RES", 9) == 0) {
 			node_msg.node_state = NODE_RESUME;
 			update_cnt++;
@@ -121,7 +125,7 @@ scontrol_update_node (int argc, char *argv[])
 						argv[i]);
 					fprintf (stderr, "Request aborted\n");
 					fprintf (stderr, "Valid states are: ");
-					fprintf (stderr, "NoResp DRAIN RESUME ");
+					fprintf (stderr, "NoResp DRAIN FAIL RESUME ");
 					for (k = 0; k < NODE_STATE_END; k++) {
 						fprintf (stderr, "%s ", 
 						         node_state_string(k));
@@ -141,8 +145,9 @@ scontrol_update_node (int argc, char *argv[])
 		}
 	}
 
-	if ((node_msg.node_state == NODE_STATE_DRAIN)  &&
-	    (node_msg.reason == NULL)) {
+	if (((node_msg.node_state == NODE_STATE_DRAIN)
+	||   (node_msg.node_state == NODE_STATE_FAIL))
+	&&  (node_msg.reason == NULL)) {
 		fprintf (stderr, "You must specify a reason when DRAINING a "
 			"node\nRequest aborted\n");
 		goto done;
diff --git a/src/scontrol/update_part.c b/src/scontrol/update_part.c
index 4b21a854259338392f2fe18d72f275ee2ebabd68..6ec952c928b547703225e54abff50da33d4a012f 100644
--- a/src/scontrol/update_part.c
+++ b/src/scontrol/update_part.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -35,7 +35,8 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#include "scontrol.h"
+#include "src/common/proc_args.h"
+#include "src/scontrol/scontrol.h"
 
 
 /* 
@@ -49,7 +50,7 @@
 extern int
 scontrol_update_part (int argc, char *argv[]) 
 {
-	int i, update_cnt = 0;
+	int i, min, max, update_cnt = 0;
 	update_part_msg_t part_msg;
 
 	slurm_init_part_desc_msg ( &part_msg );
@@ -57,29 +58,32 @@ scontrol_update_part (int argc, char *argv[])
 		if (strncasecmp(argv[i], "PartitionName=", 14) == 0)
 			part_msg.name = &argv[i][14];
 		else if (strncasecmp(argv[i], "MaxTime=", 8) == 0) {
-			if ((strcasecmp(&argv[i][8],"UNLIMITED") == 0) ||
-			    (strcasecmp(&argv[i][8],"INFINITE") == 0))
-				part_msg.max_time = INFINITE;
-			else
-				part_msg.max_time = 
-					(uint32_t) strtol(&argv[i][8], 
-						(char **) NULL, 10);
+			int max_time = time_str2mins(&argv[i][8]);
+			if ((max_time < 0) && (max_time != INFINITE)) {
+				exit_code = 1;
+				error("Invalid input %s", argv[i]);
+				return 0;
+			}
+			part_msg.max_time = max_time;
 			update_cnt++;
 		}
 		else if (strncasecmp(argv[i], "MaxNodes=", 9) == 0) {
 			if ((strcasecmp(&argv[i][9],"UNLIMITED") == 0) ||
 			    (strcasecmp(&argv[i][8],"INFINITE") == 0))
 				part_msg.max_nodes = (uint32_t) INFINITE;
-			else
-				part_msg.max_nodes = 
-					(uint32_t) strtol(&argv[i][9], 
-						(char **) NULL, 10);
+			else {
+				min = 1;
+				get_resource_arg_range(&argv[i][9],
+					"MaxNodes", &min, &max, true);
+				part_msg.max_nodes = min;
+			}
 			update_cnt++;
 		}
 		else if (strncasecmp(argv[i], "MinNodes=", 9) == 0) {
-			part_msg.min_nodes = 
-				(uint32_t) strtol(&argv[i][9], 
-					(char **) NULL, 10);
+			min = 1;
+			get_resource_arg_range(&argv[i][9],
+				"MinNodes", &min, &max, true);
+			part_msg.min_nodes = min;
 			update_cnt++;
 		}
 		else if (strncasecmp(argv[i], "Default=", 8) == 0) {
@@ -89,10 +93,9 @@ scontrol_update_part (int argc, char *argv[])
 				part_msg.default_part = 1;
 			else {
 				exit_code = 1;
-				fprintf (stderr, "Invalid input: %s\n", 
-					 argv[i]);
-				fprintf (stderr, "Acceptable Default values "
-					"are YES and NO\n");
+				error("Invalid input: %s", argv[i]);
+				error("Acceptable Default values "
+					"are YES and NO");
 				return 0;
 			}
 			update_cnt++;
@@ -104,10 +107,9 @@ scontrol_update_part (int argc, char *argv[])
 				part_msg.hidden = 1;
 			else {
 				exit_code = 1;
-				fprintf (stderr, "Invalid input: %s\n", 
-					 argv[i]);
-				fprintf (stderr, "Acceptable Hidden values "
-					"are YES and NO\n");
+				error("Invalid input: %s", argv[i]);
+				error("Acceptable Hidden values "
+					"are YES and NO");
 				return 0;
 			}
 			update_cnt++;
@@ -119,33 +121,43 @@ scontrol_update_part (int argc, char *argv[])
 				part_msg.root_only = 1;
 			else {
 				exit_code = 1;
-				fprintf (stderr, "Invalid input: %s\n", 
-					 argv[i]);
-				fprintf (stderr, "Acceptable RootOnly values "
-					"are YES and NO\n");
+				error("Invalid input: %s", argv[i]);
+				error("Acceptable RootOnly values "
+					"are YES and NO");
 				return 0;
 			}
 			update_cnt++;
 		}
 		else if (strncasecmp(argv[i], "Shared=", 7) == 0) {
-			if (strcasecmp(&argv[i][7], "NO") == 0)
-				part_msg.shared = SHARED_NO;
-			else if (strcasecmp(&argv[i][7], "YES") == 0)
-				part_msg.shared = SHARED_YES;
-			else if (strcasecmp(&argv[i][7], "EXCLUSIVE") == 0)
-				part_msg.shared = SHARED_EXCLUSIVE;
-			else if (strcasecmp(&argv[i][7], "FORCE") == 0)
-				part_msg.shared = SHARED_FORCE;
-			else {
+			if (strncasecmp(&argv[i][7], "NO", 2) == 0) {
+				part_msg.max_share = 1;
+			} else if (strncasecmp(&argv[i][7], "EXCLUSIVE", 9) == 0) {
+				part_msg.max_share = 0;
+			} else if (strncasecmp(&argv[i][7], "YES:", 4) == 0) {
+				part_msg.max_share = (uint16_t) strtol(&argv[i][11], 
+					(char **) NULL, 10);
+			} else if (strncasecmp(&argv[i][7], "YES", 3) == 0) {
+				part_msg.max_share = (uint16_t) 4;
+			} else if (strncasecmp(&argv[i][7], "FORCE:", 6) == 0) {
+				part_msg.max_share = (uint16_t) strtol(&argv[i][13],
+					(char **) NULL, 10) | SHARED_FORCE;
+			} else if (strncasecmp(&argv[i][7], "FORCE", 5) == 0) {
+				part_msg.max_share = (uint16_t) 4 |
+					SHARED_FORCE;
+			} else {
 				exit_code = 1;
-				fprintf (stderr, "Invalid input: %s\n", 
-					 argv[i]);
-				fprintf (stderr, "Acceptable Shared values "
-					"are YES, NO and FORCE\n");
+				error("Invalid input: %s", argv[i]);
+				error("Acceptable Shared values are "
+					"NO, EXCLUSIVE, YES:#, and FORCE:#");
 				return 0;
 			}
 			update_cnt++;
 		}
+		else if (strncasecmp(argv[i], "Priority=", 9) == 0) {
+			part_msg.priority = (uint16_t) strtol(&argv[i][9], 
+					(char **) NULL, 10);
+			update_cnt++;
+		}
 		else if (strncasecmp(argv[i], "State=", 6) == 0) {
 			if (strcasecmp(&argv[i][6], "DOWN") == 0)
 				part_msg.state_up = 0;
@@ -153,10 +165,9 @@ scontrol_update_part (int argc, char *argv[])
 				part_msg.state_up = 1;
 			else {
 				exit_code = 1;
-				fprintf (stderr, "Invalid input: %s\n", 
-					 argv[i]);
-				fprintf (stderr, "Acceptable State values "
-					"are UP and DOWN\n");
+				error("Invalid input: %s", argv[i]);
+				error("Acceptable State values "
+					"are UP and DOWN");
 				return 0;
 			}
 			update_cnt++;
@@ -171,15 +182,15 @@ scontrol_update_part (int argc, char *argv[])
 		}
 		else {
 			exit_code = 1;
-			fprintf (stderr, "Invalid input: %s\n", argv[i]);
-			fprintf (stderr, "Request aborted\n");
+			error("Invalid input: %s", argv[i]);
+			error("Request aborted");
 			return 0;
 		}
 	}
 
 	if (update_cnt == 0) {
 		exit_code = 1;
-		fprintf (stderr, "No changes specified\n");
+		error("No changes specified");
 		return 0;
 	}
 
diff --git a/src/sinfo/Makefile.in b/src/sinfo/Makefile.in
index 6e9edb758fd9a52a7910679303e6f82a80f40c31..07e64aec76a356c62ddb7740c004546a6f6c4523 100644
--- a/src/sinfo/Makefile.in
+++ b/src/sinfo/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -48,6 +48,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -78,7 +80,7 @@ sinfo_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 sinfo_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sinfo_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -300,8 +313,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -366,8 +379,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -379,8 +392,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -390,13 +403,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/sinfo/opts.c b/src/sinfo/opts.c
index a01a349d487deb0b3c0ea1fd22c4978904217024..1313dfbb6d519a432f77a280f7a71d72988efbde 100644
--- a/src/sinfo/opts.c
+++ b/src/sinfo/opts.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -422,7 +422,8 @@ _parse_format( char* format )
 {
 	int field_size;
 	bool right_justify;
-	char *prefix, *suffix, *token, *tmp_char, *tmp_format;
+	char *prefix = NULL, *suffix = NULL, *token = NULL,
+		*tmp_char = NULL, *tmp_format = NULL;
 	char field[1];
 
 	if (format == NULL) {
@@ -517,6 +518,12 @@ _parse_format( char* format )
 					field_size, 
 					right_justify, 
 					suffix );
+		} else if (field[0] == 'p') {
+			params.match_flags.priority_flag = true;
+			format_add_priority( params.format_list, 
+					field_size, 
+					right_justify, 
+					suffix );
 		} else if (field[0] == 'P') {
 			params.match_flags.partition_flag = true;
 			format_add_partition( params.format_list, 
@@ -692,6 +699,8 @@ void _print_options( void )
 			"true" : "false");
 	printf("partition_flag  = %s\n", params.match_flags.partition_flag ?
 			"true" : "false");
+	printf("priority_flag   = %s\n", params.match_flags.priority_flag ?
+			"true" : "false");
 	printf("reason_flag     = %s\n", params.match_flags.reason_flag ?
 			"true" : "false");
 	printf("root_flag       = %s\n", params.match_flags.root_flag ?
diff --git a/src/sinfo/print.c b/src/sinfo/print.c
index 6e4704c245d9d170673d4e6aa984c58dfe7b3cdb..0cd867ebf8733431d10184df332c9989f3e42720 100644
--- a/src/sinfo/print.c
+++ b/src/sinfo/print.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  print.c - sinfo print job functions
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov> and 
  *  Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *   
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -170,7 +170,8 @@ static int _print_secs(long time, int width, bool right, bool cut_output)
 }
 
 static int 
-_build_min_max_16_string(char *buffer, int buf_size, uint16_t min, uint16_t max, bool range)
+_build_min_max_16_string(char *buffer, int buf_size, uint16_t min, uint16_t max, 
+			 bool range)
 {
 	char tmp_min[8];
 	char tmp_max[8];
@@ -191,7 +192,8 @@ _build_min_max_16_string(char *buffer, int buf_size, uint16_t min, uint16_t max,
 }
 
 static int 
-_build_min_max_32_string(char *buffer, int buf_size, uint32_t min, uint32_t max, bool range)
+_build_min_max_32_string(char *buffer, int buf_size, uint32_t min, uint32_t max, 
+			 bool range)
 {
 	char tmp_min[8];
 	char tmp_max[8];
@@ -631,6 +633,24 @@ int _print_prefix(sinfo_data_t * job, int width, bool right_justify,
 	return SLURM_SUCCESS;
 }
 
+int _print_priority(sinfo_data_t * sinfo_data, int width,
+			bool right_justify, char *suffix)
+{
+	char id[FORMAT_STRING_SIZE];
+
+	if (sinfo_data) {
+		_build_min_max_16_string(id, FORMAT_STRING_SIZE, 
+		                      sinfo_data->part_info->priority, 
+		                      sinfo_data->part_info->priority, true);
+		_print_str(id, width, right_justify, true);
+	} else
+		_print_str("PRIORITY", width, right_justify, true);
+
+	if (suffix)
+		printf("%s", suffix);
+	return SLURM_SUCCESS;
+}
+
 int _print_reason(sinfo_data_t * sinfo_data, int width,
 			bool right_justify, char *suffix)
 {
@@ -668,15 +688,20 @@ int _print_root(sinfo_data_t * sinfo_data, int width,
 int _print_share(sinfo_data_t * sinfo_data, int width,
 			bool right_justify, char *suffix)
 {
+	char id[FORMAT_STRING_SIZE];
+
 	if (sinfo_data) {
-		if (sinfo_data->part_info == NULL)
-			_print_str("n/a", width, right_justify, true);
-		else if (sinfo_data->part_info->shared > 1)
-			_print_str("force", width, right_justify, true);
-		else if (sinfo_data->part_info->shared)
-			_print_str("yes", width, right_justify, true);
+		bool force = sinfo_data->part_info->max_share & SHARED_FORCE;
+		uint16_t val = sinfo_data->part_info->max_share & (~SHARED_FORCE);
+		if (val == 0)
+			snprintf(id, sizeof(id), "EXCLUSIVE");
+		else if (force)
+			snprintf(id, sizeof(id), "FORCE:%u", val);
+		else if (val == 1)
+			snprintf(id, sizeof(id), "NO");
 		else
-			_print_str("no", width, right_justify, true);
+			snprintf(id, sizeof(id), "YES:%u", val);
+		_print_str(id, width, right_justify, true);
 	} else
 		_print_str("SHARE", width, right_justify, true);
 
diff --git a/src/sinfo/print.h b/src/sinfo/print.h
index 989f25b7913d1b44f3a891493f36c8ae6fd0a355..a7d01c8d580afe06a6f3670937a14824eb6eaf83 100644
--- a/src/sinfo/print.h
+++ b/src/sinfo/print.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -100,6 +100,8 @@ int  print_sinfo_list(List sinfo_list);
 	format_add_function(list,wid,right,suffix,_print_partition)
 #define format_add_prefix(list,wid,right,suffix) \
 	format_add_function(list,wid,right,suffix,_print_prefix)
+#define format_add_priority(list,wid,right,suffix) \
+	format_add_function(list,wid,right,suffix,_print_priority)
 #define format_add_reason(list,wid,right,suffix) \
 	format_add_function(list,wid,right,suffix,_print_reason)
 #define format_add_root(list,wid,right,prefix) \
@@ -155,6 +157,8 @@ int _print_partition(sinfo_data_t * sinfo_data, int width,
 			bool right_justify, char *suffix);
 int _print_prefix(sinfo_data_t * sinfo_data, int width,
 			bool right_justify, char *suffix);
+int _print_priority(sinfo_data_t * sinfo_data, int width,
+			bool right_justify, char *suffix);
 int _print_reason(sinfo_data_t * sinfo_data, int width,
 			bool right_justify, char *suffix);
 int _print_root(sinfo_data_t * sinfo_data, int width, 
diff --git a/src/sinfo/sinfo.c b/src/sinfo/sinfo.c
index 02df66be06244ec0ef57f3b46051aca5976fc80c..42239d1adb733c963eb7076bfeffb972fb4ec903 100644
--- a/src/sinfo/sinfo.c
+++ b/src/sinfo/sinfo.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  sinfo.c - Report overall state the system
  *
- *  $Id: sinfo.c 13835 2008-04-09 18:57:18Z jette $
+ *  $Id: sinfo.c 13929 2008-04-23 16:11:29Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -552,9 +552,13 @@ static bool _match_node_data(sinfo_data_t *sinfo_ptr,
 	    (_strcmp(node_ptr->reason, sinfo_ptr->reason)))
 		return false;
 
-	if (params.match_flags.state_flag &&
-	    (node_ptr->node_state != sinfo_ptr->node_state))
-		return false;
+	if (params.match_flags.state_flag) {
+		char *state1, *state2;
+		state1 = node_state_string(node_ptr->node_state);
+		state2 = node_state_string(sinfo_ptr->node_state);
+		if (strcmp(state1, state2))
+			return false;
+	}
 
 	/* If no need to exactly match sizes, just return here 
 	 * otherwise check cpus, disk, memory and weigth individually */
@@ -629,7 +633,11 @@ static bool _match_part_data(sinfo_data_t *sinfo_ptr,
 		return false;
 
 	if (params.match_flags.share_flag &&
-	    (part_ptr->shared != sinfo_ptr->part_info->shared))
+	    (part_ptr->max_share != sinfo_ptr->part_info->max_share))
+		return false;
+
+	if (params.match_flags.priority_flag &&
+	    (part_ptr->priority != sinfo_ptr->part_info->priority))
 		return false;
 
 	return true;
diff --git a/src/sinfo/sinfo.h b/src/sinfo/sinfo.h
index cae8bf0861c6603c00b49bd68ff3544ca499fce4..fbae0bded7a3e10d95037e5b0bb1cb6ec5ddebd7 100644
--- a/src/sinfo/sinfo.h
+++ b/src/sinfo/sinfo.h
@@ -1,12 +1,12 @@
 /****************************************************************************\
  *  sinfo.h - definitions used for sinfo data functions
  *
- *  $Id: sinfo.h 10732 2007-01-10 18:39:14Z da $
+ *  $Id: sinfo.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -105,7 +105,7 @@ typedef struct {
 	hostlist_t ionodes;
 #endif
 	/* part_info contains partition, avail, max_time, job_size, 
-	 * root, share, groups */
+	 * root, share, groups, priority */
 	partition_info_t* part_info;
 	uint16_t part_inx;
 } sinfo_data_t;
@@ -126,6 +126,7 @@ struct sinfo_match_flags {
 	bool max_time_flag;
 	bool memory_flag;
 	bool partition_flag;
+	bool priority_flag;
 	bool reason_flag;
 	bool root_flag;
 	bool share_flag;
diff --git a/src/sinfo/sort.c b/src/sinfo/sort.c
index 08303757f509a1cf1890b53e00d7a53681e3d82d..d49b81a2a44a4cdac211067fc770e1af4848f7de 100644
--- a/src/sinfo/sort.c
+++ b/src/sinfo/sort.c
@@ -5,7 +5,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>, 
  *             Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -63,6 +63,7 @@ static int _sort_by_node_list(void *void1, void *void2);
 static int _sort_by_nodes_ai(void *void1, void *void2);
 static int _sort_by_nodes(void *void1, void *void2);
 static int _sort_by_partition(void *void1, void *void2);
+static int _sort_by_priority(void *void1, void *void2);
 static int _sort_by_reason(void *void1, void *void2);
 static int _sort_by_reason_time(void *void1, void *void2);
 static int _sort_by_root(void *void1, void *void2);
@@ -122,6 +123,8 @@ void sort_sinfo_list(List sinfo_list)
 				list_sort(sinfo_list, _sort_by_memory);
 		else if (params.sort[i] == 'N')
 				list_sort(sinfo_list, _sort_by_node_list);
+		else if (params.sort[i] == 'p')
+				list_sort(sinfo_list, _sort_by_priority);
 		else if (params.sort[i] == 'P')
 				list_sort(sinfo_list, _sort_by_partition);
 		else if (params.sort[i] == 'r')
@@ -527,9 +530,27 @@ static int _sort_by_share(void *void1, void *void2)
 	int val1 = 0, val2 = 0;
 
 	if (sinfo1->part_info)
-		val1 = sinfo1->part_info->shared;
+		val1 = sinfo1->part_info->max_share;
 	if (sinfo2->part_info)
-		val2 = sinfo2->part_info->shared;
+		val2 = sinfo2->part_info->max_share;
+	diff = val1 - val2;
+
+	if (reverse_order)
+		diff = -diff;
+	return diff;
+}
+
+static int _sort_by_priority(void *void1, void *void2)
+{
+	int diff;
+	sinfo_data_t *sinfo1 = (sinfo_data_t *) void1;
+	sinfo_data_t *sinfo2 = (sinfo_data_t *) void2;
+	int val1 = 0, val2 = 0;
+
+	if (sinfo1->part_info)
+		val1 = sinfo1->part_info->priority;
+	if (sinfo2->part_info)
+		val2 = sinfo2->part_info->priority;
 	diff = val1 - val2;
 
 	if (reverse_order)
diff --git a/src/slaunch/Makefile.am b/src/slaunch/Makefile.am
deleted file mode 100644
index 309c40008390a2cb4910f3dc89fca9b0d1d00c06..0000000000000000000000000000000000000000
--- a/src/slaunch/Makefile.am
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-
-AUTOMAKE_OPTIONS = foreign
-
-INCLUDES = -I$(top_srcdir) 
-
-bin_PROGRAMS = slaunch
-
-slaunch_SOURCES = \
-	slaunch.c slaunch.h \
-	opt.c opt.h \
-	attach.h    \
-	attach.c    \
-	fname.c     \
-	fname.h     \
-	sigstr.c    \
-	sigstr.h    \
-	core-format.c \
-	core-format.h \
-	multi_prog.c multi_prog.h \
-	slaunch.wrapper.c
-
-convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
-
-slaunch_LDADD = \
-	$(convenience_libs) 
-
-slaunch_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
-
-force:
-$(convenience_libs) : force
-	@cd `dirname $@` && $(MAKE) `basename $@`
-
-# debugging information is required for symbols in the attach
-# module so that a debugger can attach to spawned tasks
-attach.o : attach.c
-	$(COMPILE) -c -g -o attach.o $(srcdir)/attach.c 
-
-install-exec-local:
-	umask 022; \
-	if [ -x /usr/lib/rpm/debugedit ]; then \
-	  srcdir=`cd $(top_srcdir) && pwd`; \
-	  /usr/lib/rpm/debugedit -b $$srcdir -d $(pkglibdir) \
-	                         $(DESTDIR)$(bindir)/slaunch; fi; \
-	mkdir -p -m 755 $(DESTDIR)$(pkglibdir)/src/slaunch
-	$(INSTALL) -m 644 $(top_srcdir)/src/slaunch/slaunch.wrapper.c \
-		$(DESTDIR)$(pkglibdir)/src/slaunch/slaunch.wrapper.c
diff --git a/src/slaunch/attach.c b/src/slaunch/attach.c
deleted file mode 100644
index 0a602fbd419af704285af62fbf572fd493694b34..0000000000000000000000000000000000000000
--- a/src/slaunch/attach.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************\
- *  attach.c - Definitions needed for parallel debugger
- *  $Id: attach.c 10574 2006-12-15 23:38:29Z jette $
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include "src/common/log.h"
-
-#include "src/slaunch/attach.h"
-
-/*
- *  Instantiate extern variables from attach.h
- */
-MPIR_PROCDESC *MPIR_proctable;
-int MPIR_proctable_size;
-VOLATILE int MPIR_debug_state;
-VOLATILE int MPIR_debug_gate;
-int MPIR_being_debugged;
-int MPIR_i_am_starter;
-int MPIR_acquired_pre_main;
-char *totalview_jobid;
-
-void MPIR_Breakpoint(void)
-{
-	/* 
-	 * This just notifies parallel debugger that some event of 
-	 *  interest occurred.
-	 */ 
-	debug("In MPIR_Breakpoint");
-}
-
-
diff --git a/src/slaunch/core-format.c b/src/slaunch/core-format.c
deleted file mode 100644
index 6feea50ec8648ea774efc29b4d945e52693f864e..0000000000000000000000000000000000000000
--- a/src/slaunch/core-format.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*****************************************************************************\
- * src/srun/core-format.c - Change corefile characteristics for job
- * $Id: core-format.c 10574 2006-12-15 23:38:29Z jette $
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-//#include "src/common/env.h" 
-#include "src/slaunch/core-format.h"
-#include "src/common/log.h"
-#include "src/common/env.h"
-
-#define CORE_NORMAL 0
-#define CORE_LIGHT  1 /* Default lightweight corefile from liblwcf */
-#define CORE_LCB    2 /* PTOOLS Lightweight Corefile Browser (LCB) compliant*/
-#define CORE_LIST   3 /* List core format types to stdout and exit */
-#define LIB_LIGHT   "liblwcf-preload.so"
-
-struct core_format_info {
-	core_format_t type;
-	const char *name;
-	const char *descr;
-};
-
-/*
- * Supported types for core=%s
- */
-struct core_format_info core_types[] = {
-	{ CORE_NORMAL,
-	  "normal", 
-	  "Default full corefile (do nothing)"
-        },
-	{ CORE_LIGHT,
-	  "light",
-	  "liblwcf default lightweight corefile format"
-        },
-	{ CORE_LCB,
-	  "lcb",
-	  "liblwcf Lightweight Corefile Browser compliant"
-	},
-	{ CORE_LIST, 
-	  "list",
-	  "list valid core format types"
-	},
-	{ CORE_INVALID,
-	  NULL,
-	  "Invalid format"
-	}
-};
-
-static struct core_format_info * _find_core_format_info (const char *name)
-{
-	struct core_format_info *ci;
-
-	for (ci = core_types; ci && ci->name != NULL; ci++) {
-		if ( strncasecmp (ci->name, name, strlen (ci->name)) == 0)
-			break;
-	}
-
-	return (ci);
-}
-
-static void _print_valid_core_types (void)
-{
-	struct core_format_info *ci;
-
-	info ("Valid corefile format types:");
-	for (ci = core_types; ci && ci->name != NULL; ci++) {
-		if ((ci->type == CORE_LIGHT) ||
-		    (ci->type == CORE_LCB)) {
-			struct stat buf;
-			if ((stat("/lib/"           LIB_LIGHT, &buf) < 0) &&
-			    (stat("/usr/lib/"       LIB_LIGHT, &buf) < 0) &&
-			    (stat("/usr/local/lib/" LIB_LIGHT, &buf) < 0))
-				continue;
-		}
-		if (ci->type != CORE_LIST) 
-			info (" %-8s -- %s", ci->name, ci->descr);
-	}
-	return;
-}
-
-core_format_t core_format_type (const char *str)
-{
-	struct core_format_info *ci = _find_core_format_info (str);
-
-	if (ci->type == CORE_LIST) {
-		_print_valid_core_types ();
-		exit (0);
-	}
-
-	return (ci->type);
-}
-
-const char * core_format_name (core_format_t type)
-{
-	struct core_format_info *ci;
-
-	for (ci = core_types; ci && ci->name != NULL; ci++) {
-		if (ci->type == type)
-			break;
-	}
-
-	return (ci->name);
-}
-
-int core_format_enable (core_format_t type)
-{
-	switch (type) {
-	case CORE_NORMAL: case CORE_INVALID:
-		break;
-	case CORE_LCB:
-		setenvfs ("LWCF_CORE_FORMAT=LCB");
-	case CORE_LIGHT:
-		setenvfs ("LD_PRELOAD=" LIB_LIGHT);
-		break;
-	}
-
-	return (0);
-}
-
diff --git a/src/slaunch/core-format.h b/src/slaunch/core-format.h
deleted file mode 100644
index 9c98f068717be7d354c02f8a733e9b54ef8d042d..0000000000000000000000000000000000000000
--- a/src/slaunch/core-format.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************************\
- * src/srun/core-format.h - Change corefile characteristics for job
- * $Id: core-format.h 10574 2006-12-15 23:38:29Z jette $
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifndef _HAVE_SLAUNCH_CORE_FORMAT_H
-#define _HAVE_SLAUNCH_CORE_FORMAT_H
-
-typedef int core_format_t;
-
-#define CORE_INVALID -1
-#define CORE_DEFAULT  0
-
-core_format_t core_format_type (const char *type);
-
-const char * core_format_name (core_format_t type);
-
-int core_format_enable (core_format_t type);
-
-#endif /* !_HAVE_SLAUNCH_CORE_FORMAT_H */
diff --git a/src/slaunch/fname.c b/src/slaunch/fname.c
deleted file mode 100644
index 7ecf5124f2e4d4be56590770c61b4b79db3f69e8..0000000000000000000000000000000000000000
--- a/src/slaunch/fname.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*****************************************************************************\
- *  src/slaunch/fname.h - IO filename type implementation (slaunch specific)
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "src/slaunch/fname.h"
-#include "src/slaunch/opt.h"
-
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/common/xassert.h"
-
-/* 
- * Max zero-padding width allowed
- */
-#define MAX_WIDTH 10
-
-
-/*
- * Fill in as much of filename as possible from slaunch, update
- * filename type to one of the io types ALL, NONE, PER_TASK, ONE
- */
-fname_t *
-fname_create(char *format, int jobid, int stepid)
-{
-	unsigned long int wid     = 0;
-	unsigned long int taskid  = 0;
-	fname_t *fname = NULL;
-	char *p, *q, *name;
-
-	fname = xmalloc(sizeof(*fname));
-	fname->type = IO_ALL;
-	fname->name = NULL;
-	fname->taskid = -1;
-
-	/* Handle special  cases
-	 */
-
-	if ((format == NULL)
-	    || (strncasecmp(format, "all", (size_t) 3) == 0)
-	    || (strncmp(format, "-", (size_t) 1) == 0)       ) {
-		 /* "all" explicitly sets IO_ALL and is the default */
-		return fname;
-	}
-
-	if (strncasecmp(format, "none", (size_t) 4) == 0) {
-		fname->name = xstrdup ("/dev/null");
-		return fname;
-	}
-
-	taskid = strtoul(format, &p, 10);
-	if ((*p == '\0') && ((int) taskid < opt.num_tasks)) {
-		fname->type   = IO_ONE;
-		fname->taskid = (uint32_t) taskid;
-		/* Set the name string to pass to slurmd
-		 *  to the taskid requested, so that tasks with
-		 *  no IO can open /dev/null.
-		 */
-		fname->name = xstrdup (format);
-		return fname;
-	}
-
-	name = NULL;
-	q = p = format;
-	while (*p != '\0') {
-		if (*p == '%') {
-			if (isdigit(*(++p))) {
-				xmemcat(name, q, p - 1);
-				if ((wid = strtoul(p, &p, 10)) > MAX_WIDTH)
-					wid = MAX_WIDTH;
-				q = p - 1;
-				if (*p == '\0')
-					break;
-			}
-
-			switch (*p) {
-			 case 't':  /* '%t' => taskid         */
-				 error("\"%%t\" is ignored for local files");
-				 p++;
-				 break;
-			 case 'n':  /* '%n' => nodeid         */
-				 error("\"%%n\" is ignored for local files");
-				 p++;
-				 break;
-			 case 'N':  /* '%N' => node name      */
-				 error("\"%%N\" is ignored for local files");
-				 p++;
-				 break;
-
-			 case 'J':  /* '%J' => "jobid.stepid" */
-			 case 'j':  /* '%j' => jobid          */
-
-				 xmemcat(name, q, p - 1);
-				 xstrfmtcat(name, "%0*d", wid, jobid);
-
-				 if ((*p == 'J') && (stepid != NO_VAL)) 
-					 xstrfmtcat(name, ".%d", stepid);
-				 q = ++p;
-				 break;
-
-			 case 's':  /* '%s' => stepid         */
-				 xmemcat(name, q, p - 1);
-				 xstrfmtcat(name, "%0*d", wid, stepid);
-				 q = ++p;
-				 break;
-
-			 default:
-				 break;
-			}
-			wid = 0;
-		} else
-			p++;
-	}
-
-	if (q != p) 
-		xmemcat(name, q, p);
-
-	fname->name = name;
-	return fname;
-}
-
-void 
-fname_destroy(fname_t *f)
-{
-	if (f->name)
-		xfree(f->name);
-	xfree(f);
-}
-
diff --git a/src/slaunch/fname.h b/src/slaunch/fname.h
deleted file mode 100644
index ed26b9e9c64f4df383e45a29754445cc185d74d4..0000000000000000000000000000000000000000
--- a/src/slaunch/fname.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************************\
- * fname.c - IO filename type implementation (slaunch specific)
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifndef _SLAUNCH_FNAME_H
-#define _SLAUNCH_FNAME_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif 
-
-enum io_t {
-	IO_ALL		= 0, /* multiplex output from all/bcast stdin to all */
-	IO_ONE 	        = 1, /* output from only one task/stdin to one task  */
-	IO_NONE		= 2, /* close output/close stdin                     */
-};
-
-typedef struct fname {
-	char      *name;
-	enum io_t  type;
-	int        taskid;  /* taskid for IO if IO_ONE */
-} fname_t;
-
-/*
- * Create an filename from a (probably user supplied) filename format.
- * fname_create() will expand the format as much as possible for slaunch,
- * leaving node or task specific format specifiers for the remote 
- * slurmd to handle.
- */
-fname_t *fname_create(char *format, int jobid, int stepid);
-void fname_destroy(fname_t *fname);
-
-#endif /* !_SLAUNCH_FNAME_H */
-
diff --git a/src/slaunch/multi_prog.c b/src/slaunch/multi_prog.c
deleted file mode 100644
index 84125355adb7b699ef7609099b9469090c628195..0000000000000000000000000000000000000000
--- a/src/slaunch/multi_prog.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*****************************************************************************\
- *  multi_prog.c - executing program according to task rank
- *                 set MPIR_PROCDESC accordingly
- *
- *  NOTE: The logic could be eliminated if slurmstepd kept track of the 
- *  executable name for each task and returned that inforatmion in a new
- *  launch response message (with multiple executable names).
- *****************************************************************************
- *  Produced at National University of Defense Technology (China)
- *  Written by Hongjia Cao <hjcao@nudt.edu.cn>
- *  and
- *  Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "src/common/log.h"
-#include "src/common/xassert.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/slaunch/attach.h"
-
-/* Given a program name, translate it to a fully qualified pathname
- * as needed based upon the PATH environment variable */
-static char *
-_build_path(char* fname)
-{
-	int i;
-	char *path_env = NULL, *dir = NULL, *ptrptr = NULL;
-	static char file_name[256], file_path[256];	/* return values */
-	struct stat buf;
-
-	/* make copy of file name (end at white space) */
-	snprintf(file_name, sizeof(file_name), "%s", fname);
-	for (i=0; i<sizeof(file_name); i++) {
-		if (file_name[i] == '\0')
-			break;
-		if (!isspace(file_name[i]))
-			continue;
-		file_name[i] = '\0';
-		break;
-	}
-
-	/* check if already absolute path */
-	if (file_name[0] == '/')
-		return file_name;
-
-	/* search for the file using PATH environment variable */
-	dir = getenv("PATH");
-	if (!dir) {
-		error("No PATH environment variable");
-		return NULL;
-	}
-	path_env = xstrdup(dir);
-	dir = strtok_r(path_env, ":", &ptrptr);
-	while (dir) {
-		snprintf(file_path, sizeof(file_path), "%s/%s", dir, file_name);
-		if (stat(file_path, &buf) == 0)
-			break;
-		dir = strtok_r(NULL, ":", &ptrptr);
-	}
-	if (dir == NULL) {	/* not found */
-		error("Could not find executable %s", file_name);
-		snprintf(file_path, sizeof(file_path), "%s", file_name);
-	}
-	xfree(path_env);
-	return file_path;
-}
-
-static void
-_set_range(int low_num, int high_num, char *exec_name)
-{
-	int i;
-
-	for (i=low_num; i<=high_num; i++) {
-		MPIR_PROCDESC *tv;
-		tv = &MPIR_proctable[i];
-		if (tv->executable_name) {
-			error("duplicate configuration for task %d ignored",
-				i);
-		} else
-			tv->executable_name = xstrdup(exec_name);
-	}
-}
-
-static void
-_set_exec_names(char *ranks, char *exec_name, int ntasks)
-{
-	char *range = NULL, *p = NULL, *ptrptr = NULL;
-	char *exec_path = NULL, *upper = NULL;
-	int low_num, high_num;
-
-	if (ranks[0] == '*' && ranks[1] == '\0') {
-		low_num = 0;
-		high_num = ntasks -1;
-		_set_range(low_num, high_num, exec_name);
-		return;
-	}
-	exec_path = _build_path(exec_name);
-
-	for (range = strtok_r(ranks, ",", &ptrptr);
-	     range != NULL;
-	     range = strtok_r(NULL, ",", &ptrptr)) {
-		p = range;
-		while (*p != '\0' && isdigit (*p))
-			p ++;
-
-		if (*p == '\0') { /* single rank */
-			low_num  = MAX(0, atoi(range));
-			high_num = MIN((ntasks-1), atoi(range));
-			_set_range(low_num, high_num, exec_path);
-		} else if (*p == '-') { /* lower-upper */
-			upper = ++ p;
-			while (isdigit (*p))
-				p ++;
-			if (*p != '\0') {
-				error ("Invalid task range specification (%s) "
-					"ignored.", range);
-				continue;
-			}
-			low_num  = MAX(0, atoi (range));
-			high_num = MIN((ntasks-1), atoi(upper));
-			_set_range(low_num, high_num, exec_path);
-		} else {
-			error ("Invalid task range specification (%s) ignored.",				range);
-		}
-	}
-}
-
-extern int
-mpir_set_multi_name(int ntasks, const char *config_fname)
-{
-	FILE *config_fd;
-	char line[256];
-	char *ranks = NULL, *exec_name = NULL, *p = NULL, *ptrptr = NULL;
-	int line_num = 0, i;
-
-	for (i=0; i<ntasks; i++) {
-		MPIR_PROCDESC *tv;
-		tv = &MPIR_proctable[i];
-		tv->executable_name = NULL;
-	}
-
-	config_fd = fopen(config_fname, "r");
-	if (config_fd == NULL) {
-		error("Unable to open configuration file %s", config_fname);
-		return -1;
-	}
-	while (fgets(line, sizeof(line), config_fd)) {
-		line_num ++;
-		if (strlen (line) >= (sizeof(line) - 1)) {
-			error ("Line %d of configuration file too long", 
-				line_num);
-			fclose(config_fd);
-			return -1;
-		} 
-		p = line;
-		while (*p != '\0' && isspace (*p)) /* remove leading spaces */
-			p ++;
-		
-		if (*p == '#') /* only whole-line comments handled */
-			continue;
-
-		if (*p == '\0') /* blank line ignored */
-			continue;
-
-		ranks = strtok_r(p, " \t\n", &ptrptr);
-		exec_name = strtok_r(NULL, " \t\n", &ptrptr);
-		if (!ranks || !exec_name) {
-			error("Line %d is invalid", line_num);
-			fclose(config_fd);
-			return -1;
-		}
-		_set_exec_names(ranks, exec_name, ntasks);
-	}
-	fclose(config_fd);
-	return 0;
-}
diff --git a/src/slaunch/multi_prog.h b/src/slaunch/multi_prog.h
deleted file mode 100644
index 9153b6cecbe26a43d1344ebfe45e937c566cde19..0000000000000000000000000000000000000000
--- a/src/slaunch/multi_prog.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*****************************************************************************\
- *  multi_prog.h - executing program according to task rank
- *                 set MPIR_PROCDESC accordingly
- *****************************************************************************
- *  Produced at National University of Defense Technology (China)
- *  Written by Hongjia Cao <hjcao@nudt.edu.cn>
- *  and
- *  Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-#ifndef _SLAUNCH_MULTI_PROG_H
-#define _SLAUNCH_MULTI_PROG_H
-
-/* set global MPIR_PROCDESC executable names based upon multi-program 
- * configuration file */
-extern int mpir_set_multi_name(int ntasks, const char *config_fname);
-
-#endif
-
diff --git a/src/slaunch/opt.c b/src/slaunch/opt.c
deleted file mode 100644
index de1b25d64ee66f54fa7f4838ce1edee2584b6a35..0000000000000000000000000000000000000000
--- a/src/slaunch/opt.c
+++ /dev/null
@@ -1,2138 +0,0 @@
-/*****************************************************************************\
- *  opt.c - options processing for slaunch
- *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
- *   
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <string.h>		/* strcpy, strncasecmp */
-
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
-
-#ifndef _GNU_SOURCE
-#  define _GNU_SOURCE
-#endif
-
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
-#include <fcntl.h>
-#include <stdarg.h>		/* va_start   */
-#include <stdio.h>
-#include <stdlib.h>		/* getenv     */
-#include <pwd.h>		/* getpwuid   */
-#include <ctype.h>		/* isdigit    */
-#include <sys/param.h>		/* MAXPATHLEN */
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <regex.h>
-
-#include "src/slaunch/opt.h"
-
-#include "src/common/list.h"
-#include "src/common/log.h"
-#include "src/common/parse_time.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/uid.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/common/slurm_rlimits_info.h"
-#include "src/common/plugstack.h"
-#include "src/common/optz.h"
-#include "src/common/read_config.h" /* getnodename() */
-#include "src/common/hostlist.h"
-#include "src/common/mpi.h"
-#include "src/api/pmi_server.h"
-
-#include "src/slaunch/attach.h"
-
-/* generic OPT_ definitions -- mainly for use with env vars  */
-#define OPT_NONE	0x00
-#define OPT_INT		0x01
-#define OPT_STRING	0x02
-#define OPT_DEBUG	0x03
-#define OPT_DISTRIB	0x04
-#define OPT_BOOL	0x06
-#define OPT_CORE	0x07
-#define OPT_MPI		0x0c
-#define OPT_CPU_BIND	0x0d
-#define OPT_MEM_BIND	0x0e
-#define OPT_MULTI	0x0f
-
-/* generic getopt_long flags, integers and *not* valid characters */
-#define LONG_OPT_USAGE			0x100
-#define LONG_OPT_LAUNCH			0x103
-#define LONG_OPT_JOBID			0x105
-#define LONG_OPT_UID			0x106
-#define LONG_OPT_GID			0x107
-#define LONG_OPT_MPI			0x108
-#define LONG_OPT_CORE			0x109
-#define LONG_OPT_DEBUG_TS		0x10a
-#define LONG_OPT_NETWORK		0x10b
-#define LONG_OPT_PROPAGATE		0x10c
-#define LONG_OPT_PROLOG			0x10d
-#define LONG_OPT_EPILOG			0x10e
-#define LONG_OPT_TASK_PROLOG		0x10f
-#define LONG_OPT_TASK_EPILOG		0x110
-#define LONG_OPT_CPU_BIND		0x111
-#define LONG_OPT_MEM_BIND		0x112
-#define LONG_OPT_COMM_HOSTNAME		0x113
-#define LONG_OPT_MULTI			0x114
-#define LONG_OPT_PMI_THREADS		0x115
-#define LONG_OPT_LIN_FILTER		0x116
-#define LONG_OPT_LOUT_FILTER		0x117
-#define LONG_OPT_LERR_FILTER		0x118
-#define LONG_OPT_RIN_FILTER		0x119
-#define LONG_OPT_ROUT_FILTER		0x11a
-#define LONG_OPT_RERR_FILTER		0x11b
-
-/*---- forward declarations of static functions  ----*/
-
-typedef struct env_vars env_vars_t;
-
-/* return command name from its full path name */
-static char * _base_name(char* command);
-
-static List  _create_path_list(void);
-
-/* Get a POSITIVE decimal integer from arg */
-static int  _get_pos_int(const char *arg, const char *what);
-
-/* Get a decimal integer from arg */
-static int  _get_int(const char *arg, const char *what, bool positive);
-
-static void  _help(void);
-
-/* load a multi-program configuration file */
-static void _load_multi(int *argc, char **argv);
-
-/* fill in default options  */
-static void _opt_default(void);
-
-/* set options based upon env vars  */
-static void _opt_env(void);
-
-static void _opt_args(int argc, char **argv);
-
-/* list known options and their settings  */
-static void  _opt_list(void);
-
-/* verify options sanity  */
-static bool _opt_verify(void);
-
-static void  _print_version(void);
-
-static void _process_env_var(env_vars_t *e, const char *val);
-
-/* search PATH for command returns full path */
-static char *_search_path(char *, int);
-
-static void  _usage(void);
-static int   _verify_cpu_bind(const char *arg, char **cpu_bind,
-			      cpu_bind_type_t *cpu_bind_type);
-static int   _verify_mem_bind(const char *arg, char **mem_bind,
-			      mem_bind_type_t *mem_bind_type);
-static task_dist_states_t _verify_dist_type(const char *arg, uint32_t *psize);
-
-/*---[ end forward declarations of static functions ]---------------------*/
-
-int initialize_and_process_args(int argc, char *argv[])
-{
-	/* initialize option defaults */
-	_opt_default();
-
-	/* initialize options with env vars */
-	_opt_env();
-
-	/* initialize options with argv */
-	_opt_args(argc, argv);
-
-	if (opt.verbose > 1)
-		_opt_list();
-
-	return 1;
-
-}
-
-static void _print_version(void)
-{
-	printf("%s %s\n", PACKAGE, SLURM_VERSION);
-}
-
-/*
- * _isvalue
- * returns 1 is the argument appears to be a value, 0 otherwise
- */
-static int _isvalue(char *arg) {
-    	if (isdigit(*arg)) {	 /* decimal values and 0x... hex values */
-	    	return 1;
-	}
-
-	while (isxdigit(*arg)) { /* hex values not preceded by 0x */
-		arg++;
-	}
-	if (*arg == ',' || *arg == '\0') { /* end of field or string */
-	    	return 1;
-	}
-
-	return 0;	/* not a value */
-}
-
-/*
- * verify cpu_bind arguments
- * returns -1 on error, 0 otherwise
- */
-static int _verify_cpu_bind(const char *arg, char **cpu_bind, 
-			    cpu_bind_type_t *cpu_bind_type)
-{
-	char *buf, *p, *tok;
-	if (!arg) {
-	    	return 0;
-	}
-	/* we support different launch policy names
-	 * we also allow a verbose setting to be specified
-	 *     --cpu_bind=threads
-	 *     --cpu_bind=cores
-	 *     --cpu_bind=sockets
-	 *     --cpu_bind=v
-	 *     --cpu_bind=rank,v
-	 *     --cpu_bind=rank
-	 *     --cpu_bind={MAP_CPU|MASK_CPU}:0,1,2,3,4
-	 */
-    	buf = xstrdup(arg);
-    	p = buf;
-	/* change all ',' delimiters not followed by a digit to ';'  */
-	/* simplifies parsing tokens while keeping map/mask together */
-	while (p[0] != '\0') {
-	    	if ((p[0] == ',') && (!_isvalue(&(p[1]))))
-			p[0] = ';';
-		p++;
-	}
-
-	p = buf;
-	while ((tok = strsep(&p, ";"))) {
-		if (strcasecmp(tok, "help") == 0) {
-			printf(
-"CPU bind options:\n"
-"    --cpu_bind=         Bind tasks to CPUs\n"
-"        q[uiet]         quietly bind before task runs (default)\n"
-"        v[erbose]       verbosely report binding before task runs\n"
-"        no[ne]          don't bind tasks to CPUs (default)\n"
-"        rank            bind by task rank\n"
-"        map_cpu:<list>  specify a CPU ID binding for each task\n"
-"                        where <list> is <cpuid1>,<cpuid2>,...<cpuidN>\n"
-"        mask_cpu:<list> specify a CPU ID binding mask for each task\n"
-"                        where <list> is <mask1>,<mask2>,...<maskN>\n"
-"        sockets         auto-generated masks bind to sockets\n"
-"        cores           auto-generated masks bind to cores\n"
-"        threads         auto-generated masks bind to threads\n"
-"        help            show this help message\n");
-			return 1;
-		} else if ((strcasecmp(tok, "q") == 0) ||
-			   (strcasecmp(tok, "quiet") == 0)) {
-		        *cpu_bind_type &= ~CPU_BIND_VERBOSE;
-		} else if ((strcasecmp(tok, "v") == 0) ||
-			   (strcasecmp(tok, "verbose") == 0)) {
-		        *cpu_bind_type |= CPU_BIND_VERBOSE;
-		} else if ((strcasecmp(tok, "no") == 0) ||
-			   (strcasecmp(tok, "none") == 0)) {
-			*cpu_bind_type |=  CPU_BIND_NONE;
-			*cpu_bind_type &= ~CPU_BIND_RANK;
-			*cpu_bind_type &= ~CPU_BIND_MAP;
-			*cpu_bind_type &= ~CPU_BIND_MASK;
-			xfree(*cpu_bind);
-		} else if (strcasecmp(tok, "rank") == 0) {
-			*cpu_bind_type &= ~CPU_BIND_NONE;
-			*cpu_bind_type |=  CPU_BIND_RANK;
-			*cpu_bind_type &= ~CPU_BIND_MAP;
-			*cpu_bind_type &= ~CPU_BIND_MASK;
-			xfree(*cpu_bind);
-		} else if ((strncasecmp(tok, "map_cpu", 7) == 0) ||
-		           (strncasecmp(tok, "mapcpu", 6) == 0)) {
-			char *list;
-			list = strsep(&tok, ":=");
-			list = strsep(&tok, ":=");
-			*cpu_bind_type &= ~CPU_BIND_NONE;
-			*cpu_bind_type &= ~CPU_BIND_RANK;
-			*cpu_bind_type |=  CPU_BIND_MAP;
-			*cpu_bind_type &= ~CPU_BIND_MASK;
-			xfree(*cpu_bind);
-			if (list && *list) {
-				*cpu_bind = xstrdup(list);
-			} else {
-				error("missing list for \"--cpu_bind=map_cpu:<list>\"");
-				xfree(buf);
-				return 1;
-			}
-		} else if ((strncasecmp(tok, "mask_cpu", 8) == 0) ||
-		           (strncasecmp(tok, "maskcpu", 7) == 0)) {
-			char *list;
-			list = strsep(&tok, ":=");
-			list = strsep(&tok, ":=");
-			*cpu_bind_type &= ~CPU_BIND_NONE;
-			*cpu_bind_type &= ~CPU_BIND_RANK;
-			*cpu_bind_type &= ~CPU_BIND_MAP;
-			*cpu_bind_type |=  CPU_BIND_MASK;
-			xfree(*cpu_bind);
-			if (list && *list) {
-				*cpu_bind = xstrdup(list);
-			} else {
-				error("missing list for \"--cpu_bind=mask_cpu:<list>\"");
-				xfree(buf);
-				return 1;
-			}
-		} else if ((strcasecmp(tok, "socket") == 0) ||
-		           (strcasecmp(tok, "sockets") == 0)) {
-			*cpu_bind_type |=  CPU_BIND_TO_SOCKETS;
-			*cpu_bind_type &= ~CPU_BIND_TO_CORES;
-			*cpu_bind_type &= ~CPU_BIND_TO_THREADS;
-		} else if ((strcasecmp(tok, "core") == 0) ||
-		           (strcasecmp(tok, "cores") == 0)) {
-			*cpu_bind_type &= ~CPU_BIND_TO_SOCKETS;
-			*cpu_bind_type |=  CPU_BIND_TO_CORES;
-			*cpu_bind_type &= ~CPU_BIND_TO_THREADS;
-		} else if ((strcasecmp(tok, "thread") == 0) ||
-		           (strcasecmp(tok, "threads") == 0)) {
-			*cpu_bind_type &= ~CPU_BIND_TO_SOCKETS;
-			*cpu_bind_type &= ~CPU_BIND_TO_CORES;
-			*cpu_bind_type |=  CPU_BIND_TO_THREADS;
-		} else {
-			error("unrecognized --cpu_bind argument \"%s\"", tok);
-			xfree(buf);
-			return 1;
-		}
-	}
-
-	xfree(buf);
-	return 0;
-}
-
-/*
- * verify mem_bind arguments
- * returns -1 on error, 0 otherwise
- */
-static int _verify_mem_bind(const char *arg, char **mem_bind, 
-			    mem_bind_type_t *mem_bind_type)
-{
-	char *buf, *p, *tok;
-	if (!arg) {
-	    	return 0;
-	}
-	/* we support different memory binding names
-	 * we also allow a verbose setting to be specified
-	 *     --mem_bind=v
-	 *     --mem_bind=rank,v
-	 *     --mem_bind=rank
-	 *     --mem_bind={MAP_MEM|MASK_MEM}:0,1,2,3,4
-	 */
-    	buf = xstrdup(arg);
-    	p = buf;
-	/* change all ',' delimiters not followed by a digit to ';'  */
-	/* simplifies parsing tokens while keeping map/mask together */
-	while (p[0] != '\0') {
-	    	if ((p[0] == ',') && (!_isvalue(&(p[1]))))
-			p[0] = ';';
-		p++;
-	}
-
-	p = buf;
-	while ((tok = strsep(&p, ";"))) {
-		if (strcasecmp(tok, "help") == 0) {
-			printf(
-"Memory bind options:\n"
-"    --mem_bind=         Bind memory to locality domains (ldom)\n"
-"        q[uiet]         quietly bind before task runs (default)\n"
-"        v[erbose]       verbosely report binding before task runs\n"
-"        no[ne]          don't bind tasks to memory (default)\n"
-"        rank            bind by task rank\n"
-"        local           bind to memory local to processor\n"
-"        map_mem:<list>  specify a memory binding for each task\n"
-"                        where <list> is <cpuid1>,<cpuid2>,...<cpuidN>\n"
-"        mask_mem:<list> specify a memory binding mask for each tasks\n"
-"                        where <list> is <mask1>,<mask2>,...<maskN>\n"
-"        help            show this help message\n");
-			return 1;
-			
-		} else if ((strcasecmp(tok, "q") == 0) ||
-			   (strcasecmp(tok, "quiet") == 0)) {
-		        *mem_bind_type &= ~MEM_BIND_VERBOSE;
-		} else if ((strcasecmp(tok, "v") == 0) ||
-			   (strcasecmp(tok, "verbose") == 0)) {
-		        *mem_bind_type |= MEM_BIND_VERBOSE;
-		} else if ((strcasecmp(tok, "no") == 0) ||
-			   (strcasecmp(tok, "none") == 0)) {
-			*mem_bind_type |=  MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
-			xfree(*mem_bind);
-		} else if (strcasecmp(tok, "rank") == 0) {
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type |=  MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
-			xfree(*mem_bind);
-		} else if (strcasecmp(tok, "local") == 0) {
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type |=  MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
-			xfree(*mem_bind);
-		} else if ((strncasecmp(tok, "map_mem", 7) == 0) ||
-		           (strncasecmp(tok, "mapmem", 6) == 0)) {
-			char *list;
-			list = strsep(&tok, ":=");
-			list = strsep(&tok, ":=");
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type |=  MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
-			xfree(*mem_bind);
-			if (list && *list) {
-				*mem_bind = xstrdup(list);
-			} else {
-				error("missing list for \"--mem_bind=map_mem:<list>\"");
-				xfree(buf);
-				return 1;
-			}
-		} else if ((strncasecmp(tok, "mask_mem", 8) == 0) ||
-		           (strncasecmp(tok, "maskmem", 7) == 0)) {
-			char *list;
-			list = strsep(&tok, ":=");
-			list = strsep(&tok, ":=");
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type |=  MEM_BIND_MASK;
-			xfree(*mem_bind);
-			if (list && *list) {
-				*mem_bind = xstrdup(list);
-			} else {
-				error("missing list for \"--mem_bind=mask_mem:<list>\"");
-				xfree(buf);
-				return 1;
-			}
-		} else {
-			error("unrecognized --mem_bind argument \"%s\"", tok);
-			xfree(buf);
-			return 1;
-		}
-	}
-
-	xfree(buf);
-	return 0;
-}
-/* 
- * verify that a distribution type in arg is of a known form
- * returns the task_dist_states, or -1 if state is unknown
- */
-static task_dist_states_t _verify_dist_type(const char *arg, 
-					    uint32_t *plane_size)
-{
-	int len = strlen(arg);
-	char *dist_str = NULL;
-	task_dist_states_t result = SLURM_DIST_UNKNOWN;
-	bool lllp_dist = false, plane_dist = false;
-
-	dist_str = strchr(arg,':');
-	if (dist_str != NULL) {
-		/* -m cyclic|block:cyclic|block */
-		lllp_dist = true;
-	} else {
-		/* -m plane=<plane_size> */
-		dist_str = strchr(arg,'=');
-		if(dist_str != NULL) {
-			*plane_size=atoi(dist_str+1);
-			len = dist_str-arg;
-			plane_dist = true;
-		}
-	}
-
-	if (lllp_dist) {
-		if (strcasecmp(arg, "cyclic:cyclic") == 0) {
-			result = SLURM_DIST_CYCLIC_CYCLIC;
-		} else if (strcasecmp(arg, "cyclic:block") == 0) {
-			result = SLURM_DIST_CYCLIC_BLOCK;
-		} else if (strcasecmp(arg, "block:block") == 0) {
-			result = SLURM_DIST_BLOCK_BLOCK;
-		} else if (strcasecmp(arg, "block:cyclic") == 0) {
-			result = SLURM_DIST_BLOCK_CYCLIC;
-		}
-	} else if (plane_dist) {
-		if (strncasecmp(arg, "plane", len) == 0) {
-			result = SLURM_DIST_PLANE;
-		}
-	} else {
-		if (strncasecmp(arg, "cyclic", len) == 0) {
-			result = SLURM_DIST_CYCLIC;
-		} else if (strncasecmp(arg, "block", len) == 0) {
-			result = SLURM_DIST_BLOCK;
-		} else if ((strncasecmp(arg, "arbitrary", len) == 0) ||
-		           (strncasecmp(arg, "hostfile", len) == 0)) {
-			result = SLURM_DIST_ARBITRARY;
-		}
-	}
-
-	return result;
-}
-
-/*
- *  Parse the next greatest of:
- *     CPUS(REPS),
- *  or
- *     CPUS(REPS)
- *  or
- *     CPUS,
- *  or
- *     CPUS
- *  moving "ptr" past the parsed cpu/reps pair
- *
- * Return 1 after succesfully parsing a new number or pair, and 0 otherwise.
- */
-static int _parse_cpu_rep_pair(char **ptr, uint32_t *cpu, uint32_t *rep)
-{
-	char *endptr;
-
-	*rep = 1;
-	*cpu = strtol(*ptr, &endptr, 10);
-	if (*cpu == 0 && endptr == *ptr) {
-		/* no more numbers */
-		return 0;
-	}
-
-	if (endptr[0] == (char)',') {
-		*ptr = endptr+1;
-		return 1;
-	} else if (endptr[0] == (char)'('
-		   && endptr[1] == (char)'x') {
-		*ptr = endptr+2;
-		*rep = strtol(*ptr, &endptr, 10);
-		if (*rep == 0 && endptr == *ptr) {
-			error("was expecting a number at \"%s\"", *ptr);
-			return 0;
-		}
-		if (endptr[0] != (char)')') {
-			error("was expecting a closing parenthasis at \"%s\"",
-			      endptr);
-			return 0;
-		}
-		endptr = endptr+1;
-
-		/* finally, swallow the next comma, if there is one */
-		if (endptr[0] == (char)',') {
-			*ptr = endptr + 1;
-		} else {
-			*ptr = endptr;
-		}
-		return 1;
-	} else {
-		*ptr = endptr;
-		return 1;
-	}
-}
-
-
-/* Take a string representing cpus-per-node in compressed representation,
- * and set variables in "alloc_info" pertaining to cpus-per-node.
- */
-static int _set_cpus_per_node(const char *str,
-			      resource_allocation_response_msg_t *alloc_info)
-{
-	char *ptr = (char *)str;
-	uint16_t num_cpus_groups = 0;
-	uint32_t *cpus = NULL;
-	uint32_t *cpus_reps = NULL;
-	uint32_t cpu, rep;
-
-	while (_parse_cpu_rep_pair(&ptr, &cpu, &rep)) {
-		num_cpus_groups++;
-		xrealloc(cpus, sizeof(uint32_t)*num_cpus_groups);
-		xrealloc(cpus_reps, sizeof(uint32_t)*num_cpus_groups);
-		cpus[num_cpus_groups-1] = cpu;
-		cpus_reps[num_cpus_groups-1] = rep;
-	}
-	if (num_cpus_groups == 0)
-		return 0;
-
-	alloc_info->num_cpu_groups = num_cpus_groups;
-	alloc_info->cpus_per_node = cpus;
-	alloc_info->cpu_count_reps = cpus_reps;
-
-	return 1;
-}
-
-/* return command name from its full path name */
-static char * _base_name(char* command)
-{
-	char *char_ptr, *name;
-	int i;
-
-	if (command == NULL)
-		return NULL;
-
-	char_ptr = strrchr(command, (int)'/');
-	if (char_ptr == NULL)
-		char_ptr = command;
-	else
-		char_ptr++;
-
-	i = strlen(char_ptr);
-	name = xmalloc(i+1);
-	strcpy(name, char_ptr);
-	return name;
-}
-
-/*
- * print error message to stderr with opt.progname prepended
- */
-#undef USE_ARGERROR
-#if USE_ARGERROR
-static void argerror(const char *msg, ...)
-{
-	va_list ap;
-	char buf[256];
-
-	va_start(ap, msg);
-	vsnprintf(buf, sizeof(buf), msg, ap);
-
-	fprintf(stderr, "%s: %s\n",
-		opt.progname ? opt.progname : "slaunch", buf);
-	va_end(ap);
-}
-#else
-#  define argerror error
-#endif				/* USE_ARGERROR */
-
-/*
- * _opt_default(): used by initialize_and_process_args to set defaults
- */
-static void _opt_default()
-{
-	char buf[MAXPATHLEN + 1];
-	struct passwd *pw;
-
-	if ((pw = getpwuid(getuid())) != NULL) {
-		strncpy(opt.user, pw->pw_name, MAX_USERNAME);
-		opt.uid = pw->pw_uid;
-	} else
-		error("who are you?");
-
-	opt.gid = getgid();
-
-	if ((getcwd(buf, MAXPATHLEN)) == NULL) 
-		fatal("getcwd failed: %m");
-	opt.cwd = xstrdup(buf);
-
-	opt.progname = NULL;
-
-	opt.num_tasks = 1;
-	opt.num_tasks_set = false;
-	opt.cpus_per_task = 1; 
-	opt.cpus_per_task_set = false;
-	opt.num_nodes = 1;
-	opt.num_nodes_set = false;
-	opt.cpu_bind_type = 0;
-	opt.cpu_bind = NULL;
-	opt.mem_bind_type = 0;
-	opt.mem_bind = NULL;
-	opt.relative = (uint16_t)NO_VAL;
-	opt.relative_set = false;
-
-	opt.job_name = NULL;
-	opt.jobid    = NO_VAL;
-	opt.jobid_set = false;
-
-	opt.distribution      = SLURM_DIST_UNKNOWN;
-	opt.plane_size        = NO_VAL;
-
-	opt.local_ofname = NULL;
-	opt.local_ifname = NULL;
-	opt.local_efname = NULL;
-	opt.remote_ofname = NULL;
-	opt.remote_ifname = NULL;
-	opt.remote_efname = NULL;
-	opt.local_input_filter = (uint32_t)-1;
-	opt.local_input_filter_set = false;
-	opt.local_output_filter = (uint32_t)-1;
-	opt.local_output_filter_set = false;
-	opt.local_error_filter = (uint32_t)-1;
-	opt.local_error_filter_set = false;
-	opt.remote_input_filter = (uint32_t)-1;
-	opt.remote_output_filter = (uint32_t)-1;
-	opt.remote_error_filter = (uint32_t)-1;
-
-	opt.core_type = CORE_DEFAULT;
-
-	opt.labelio = false;
-	opt.unbuffered = false;
-	opt.overcommit = false;
-	opt.no_kill = false;
-	opt.kill_bad_exit = false;
-	opt.max_wait	= slurm_get_wait_time();
-	opt.quiet = 0;
-	opt.verbose = 0;
-	opt.slurmd_debug = LOG_LEVEL_QUIET;
-	opt.nodelist	    = NULL;
-	opt.nodelist_byid   = NULL;
-	opt.task_layout = NULL;
-	opt.task_layout_file_set = false;
-
-	opt.euid	    = (uid_t) -1;
-	opt.egid	    = (gid_t) -1;
-	
-	opt.propagate	    = NULL;  /* propagate specific rlimits */
-
-	opt.prolog = slurm_get_srun_prolog();
-	opt.epilog = slurm_get_srun_epilog();
-
-	opt.task_prolog     = NULL;
-	opt.task_epilog     = NULL;
-
-	opt.comm_hostname  = xshort_hostname();
-}
-
-/*---[ env var processing ]-----------------------------------------------*/
-
-/*
- * try to use a similar scheme as popt. 
- * 
- * in order to add a new env var (to be processed like an option):
- *
- * define a new entry into env_vars[], if the option is a simple int
- * or string you may be able to get away with adding a pointer to the
- * option to set. Otherwise, process var based on "type" in _opt_env.
- */
-struct env_vars {
-	const char *var;
-	int type;
-	void *arg;
-	void *set_flag;
-};
-
-env_vars_t env_vars[] = {
-  /* SLURM_JOBID is handled like SLAUNCH_JOBID as backwards compatibility
-     with LCRM.  If we get LCRM to call a slurm API function which
-     tells LCRM which variables to set for a particular jobid number,
-     then there would be no need for LCRM's static SLURM_JOBID code or
-     the handling of SLURM_JOBID below.*/
-  {"SLURM_JOBID",          OPT_INT,       &opt.jobid,         &opt.jobid_set },
-  {"SLAUNCH_JOBID",        OPT_INT,       &opt.jobid,         &opt.jobid_set },
-  {"SLURMD_DEBUG",         OPT_INT,       &opt.slurmd_debug,  NULL           },
-  {"SLAUNCH_CORE_FORMAT",  OPT_CORE,      NULL,               NULL           },
-  {"SLAUNCH_CPU_BIND",     OPT_CPU_BIND,  NULL,               NULL           },
-  {"SLAUNCH_MEM_BIND",     OPT_MEM_BIND,  NULL,               NULL           },
-  {"SLAUNCH_DEBUG",        OPT_DEBUG,     NULL,               NULL           },
-  {"SLAUNCH_DISTRIBUTION", OPT_DISTRIB,   NULL,               NULL           },
-  {"SLAUNCH_KILL_BAD_EXIT",OPT_BOOL,      &opt.kill_bad_exit, NULL           },
-  {"SLAUNCH_LABELIO",      OPT_BOOL,      &opt.labelio,       NULL           },
-  {"SLAUNCH_OVERCOMMIT",   OPT_BOOL,      &opt.overcommit,    NULL           },
-  {"SLAUNCH_WAIT",         OPT_INT,       &opt.max_wait,      NULL           },
-  {"SLAUNCH_MPI_TYPE",     OPT_MPI,       NULL,               NULL           },
-  {"SLAUNCH_COMM_HOSTNAME",OPT_STRING,    &opt.comm_hostname, NULL           },
-  {"SLAUNCH_PROLOG",       OPT_STRING,    &opt.prolog,        NULL           },
-  {"SLAUNCH_EPILOG",       OPT_STRING,    &opt.epilog,        NULL           },
-  {"SLAUNCH_TASK_PROLOG",  OPT_STRING,    &opt.task_prolog,   NULL           },
-  {"SLAUNCH_TASK_EPILOG",  OPT_STRING,    &opt.task_epilog,   NULL           },
-
-  {NULL, 0, NULL, NULL}
-};
-
-
-/*
- * _opt_env(): used by initialize_and_process_args to set options via
- *            environment variables. See comments above for how to
- *            extend slaunch to process different vars
- */
-static void _opt_env()
-{
-	char       *val = NULL;
-	env_vars_t *e   = env_vars;
-
-	while (e->var) {
-		if ((val = getenv(e->var)) != NULL) 
-			_process_env_var(e, val);
-		e++;
-	}
-}
-
-
-static void
-_process_env_var(env_vars_t *e, const char *val)
-{
-	char *end = NULL;
-
-	debug2("now processing env var %s=%s", e->var, val);
-
-	if (e->set_flag) {
-		*((bool *) e->set_flag) = true;
-	}
-
-	switch (e->type) {
-	case OPT_STRING:
-		*((char **) e->arg) = xstrdup(val);
-		break;
-	case OPT_INT:
-		if (val != NULL) {
-			*((int *) e->arg) = (int) strtol(val, &end, 10);
-			if (!(end && *end == '\0')) 
-				error("%s=%s invalid. ignoring...", e->var, val);
-		}
-		break;
-
-	case OPT_BOOL:
-		/* A boolean env variable is true if:
-		 *  - set, but no argument
-		 *  - argument is "yes"
-		 *  - argument is a non-zero number
-		 */
-		if (val == NULL || strcmp(val, "") == 0) {
-			*((bool *)e->arg) = true;
-		} else if (strcasecmp(val, "yes") == 0) {
-			*((bool *)e->arg) = true;
-		} else if ((strtol(val, &end, 10) != 0)
-			   && end != val) {
-			*((bool *)e->arg) = true;
-		} else {
-			*((bool *)e->arg) = false;
-		}
-		break;
-
-	case OPT_DEBUG:
-		if (val != NULL) {
-			opt.verbose = (int) strtol(val, &end, 10);
-			if (!(end && *end == '\0')) 
-				error("%s=%s invalid", e->var, val);
-		}
-		break;
-
-	case OPT_DISTRIB:
-	        opt.plane_size = 0;
-		opt.distribution = _verify_dist_type(val, &opt.plane_size);
-		if (opt.distribution == SLURM_DIST_UNKNOWN) {
-			error("\"%s=%s\" -- invalid distribution type. ",
-			      e->var, val);
-			exit(1);
-		}
-		break;
-
-	case OPT_CPU_BIND:
-		if (_verify_cpu_bind(val, &opt.cpu_bind,
-				     &opt.cpu_bind_type))
-			exit(1);
-		break;
-
-	case OPT_MEM_BIND:
-		if (_verify_mem_bind(val, &opt.mem_bind,
-				     &opt.mem_bind_type))
-			exit(1);
-		break;
-
-	case OPT_CORE:
-		opt.core_type = core_format_type (val);
-		break;
-	    
-	case OPT_MPI:
-		if (mpi_hook_client_init((char *)val) == SLURM_ERROR) {
-			fatal("\"%s=%s\" -- invalid MPI type, "
-			      "--mpi=list for acceptable types.",
-			      e->var, val);
-		}
-		break;
-
-	default:
-		/* do nothing */
-		break;
-	}
-}
-
-/*
- *  Get a POSITIVE decimal integer from arg.
- *
- *  Returns the integer on success, exits program on failure.
- * 
- */
-static int
-_get_pos_int(const char *arg, const char *what)
-{
-	char *p;
-	long int result = strtol(arg, &p, 10);
-
-	if (p == arg || !xstring_is_whitespace(p) || (result < 0L)) {
-		error ("Invalid numeric value \"%s\" for %s.", arg, what);
-		exit(1);
-	}
-
-	if (result > INT_MAX) {
-		error ("Numeric argument %ld to big for %s.", result, what);
-		exit(1);
-	}
-
-	return (int) result;
-}
-
-/*
- *  Get a decimal integer from arg.
- *
- *  Returns the integer on success, exits program on failure.
- * 
- */
-static int
-_get_int(const char *arg, const char *what, bool positive)
-{
-	char *p;
-	long int result = strtol(arg, &p, 10);
-
-	if ((p == arg) || (!xstring_is_whitespace(p))
-		||  (positive && (result <= 0L))) {
-		error ("Invalid numeric value \"%s\" for %s.", arg, what);
-		exit(1);
-	}
-
-	if (result > INT_MAX) {
-		error ("Numeric argument %ld to big for %s.", result, what);
-	} else if (result < INT_MIN) {
-		error ("Numeric argument %ld to small for %s.", result, what);
-	}
-
-	return (int) result;
-}
-
-void set_options(const int argc, char **argv)
-{
-	int opt_char, option_index = 0;
-	char *tmp;
-	static struct option long_options[] = {
-		{"cpus-per-task", required_argument, 0, 'c'},
-		{"overcommit",    no_argument,       0, 'C'},
-		{"slurmd-debug",  required_argument, 0, 'd'},
-		{"workdir",       required_argument, 0, 'D'},
-		{"slaunch-error", required_argument, 0, 'e'},
-		{"task-error",    required_argument, 0, 'E'},
-		{"task-layout-file",required_argument,0,'F'},
-		{"help",          no_argument,       0, 'h'},
-		{"slaunch-input", required_argument, 0, 'i'},
-		{"task-input",    required_argument, 0, 'I'},
-		{"name",          required_argument, 0, 'J'},
-		{"kill-on-bad-exit", no_argument,    0, 'K'},
-		{"label",         no_argument,       0, 'l'},
-		{"nodelist-byid", required_argument, 0, 'L'},
-		{"distribution",  required_argument, 0, 'm'},
-		{"tasks",         required_argument, 0, 'n'},
-		{"nodes",         required_argument, 0, 'N'},
-		{"slaunch-output",required_argument, 0, 'o'},
-		{"task-output",   required_argument, 0, 'O'},
-		{"quiet",         no_argument,       0, 'q'},
-		{"relative",      required_argument, 0, 'r'},
-		{"unbuffered",    no_argument,       0, 'u'},
-		{"task-layout-byid", required_argument, 0, 'T'},
-		{"verbose",       no_argument,       0, 'v'},
-		{"version",       no_argument,       0, 'V'},
-		{"nodelist-byname", required_argument, 0, 'w'},
-		{"wait",          required_argument, 0, 'W'},
-		{"task-layout-byname", required_argument, 0, 'Y'},
-		{"cpu_bind",         required_argument, 0, LONG_OPT_CPU_BIND},
-		{"mem_bind",         required_argument, 0, LONG_OPT_MEM_BIND},
-		{"core",             required_argument, 0, LONG_OPT_CORE},
-		{"mpi",              required_argument, 0, LONG_OPT_MPI},
-		{"jobid",            required_argument, 0, LONG_OPT_JOBID},
-		{"uid",              required_argument, 0, LONG_OPT_UID},
-		{"gid",              required_argument, 0, LONG_OPT_GID},
-		/* debugger-test intentionally undocumented in the man page */
-		{"debugger-test",    no_argument,       0, LONG_OPT_DEBUG_TS},
-		{"usage",            no_argument,       0, LONG_OPT_USAGE},
-		{"network",          required_argument, 0, LONG_OPT_NETWORK},
-		{"propagate",        optional_argument, 0, LONG_OPT_PROPAGATE},
-		{"prolog",           required_argument, 0, LONG_OPT_PROLOG},
-		{"epilog",           required_argument, 0, LONG_OPT_EPILOG},
-		{"task-prolog",      required_argument, 0, LONG_OPT_TASK_PROLOG},
-		{"task-epilog",      required_argument, 0, LONG_OPT_TASK_EPILOG},
-		{"ctrl-comm-ifhn",   required_argument, 0, LONG_OPT_COMM_HOSTNAME},
-		{"multi-prog",       no_argument,       0, LONG_OPT_MULTI},
-		/* pmi-threads intentionally undocumented in the man page */
-		{"pmi-threads",	     required_argument, 0, LONG_OPT_PMI_THREADS},
-		{"slaunch-input-filter",required_argument,0, LONG_OPT_LIN_FILTER},
-		{"slaunch-output-filter",required_argument,0,LONG_OPT_LOUT_FILTER},
-		{"slaunch-error-filter",required_argument,0, LONG_OPT_LERR_FILTER},
-		/* task-*-filter are not yet functional, and intentionally
-		   undocumented in the man page */
-		{"task-input-filter", required_argument, 0, LONG_OPT_RIN_FILTER},
-		{"task-output-filter",required_argument, 0, LONG_OPT_ROUT_FILTER},
-		{"task-error-filter", required_argument, 0, LONG_OPT_RERR_FILTER},
-		{NULL,                0,                 0, 0}
-	};
-	char *opt_string =
-		"+c:Cd:D:e:E:F:hi:I:J:KlL:m:n:N:o:O:qr:T:uvVw:W:Y:";
-
-	struct option *optz = spank_option_table_create (long_options);
-
-	if (!optz) {
-		error ("Unable to create option table");
-		exit (1);
-	}
-
-	opt.progname = xbasename(argv[0]);
-
-	optind = 0;		
-	while((opt_char = getopt_long(argc, argv, opt_string,
-				      optz, &option_index)) != -1) {
-		switch (opt_char) {
-		case '?':
-			fprintf(stderr, "Try \"slaunch --help\" for more "
-				"information\n");
-			exit(1);
-			break;
-		case 'c':
-			opt.cpus_per_task_set = true;
-			opt.cpus_per_task = 
-				_get_pos_int(optarg, "cpus-per-task");
-			break;
-		case 'C':
-			opt.overcommit = true;
-			break;
-		case 'd':
-			opt.slurmd_debug = 
-				_get_pos_int(optarg, "slurmd-debug");
-			break;
-		case 'D':
-			xfree(opt.cwd);
-			opt.cwd = xstrdup(optarg);
-			break;
-		case 'e':
-			xfree(opt.local_efname);
-			if (strncasecmp(optarg, "none", (size_t) 4) == 0)
-				opt.local_efname = xstrdup("/dev/null");
-			else
-				opt.local_efname = xstrdup(optarg);
-			break;
-		case 'F':
-			xfree(opt.task_layout);
-			tmp = slurm_read_hostfile(optarg, 0);
-			if (tmp != NULL) {
-				opt.task_layout = xstrdup(tmp);
-				free(tmp);
-				opt.task_layout_file_set = true;
-			} else {
-				error("\"%s\" is not a valid task layout file");
-				exit(1);
-			}			
-			break;
-		case 'E':
-			xfree(opt.remote_efname);
-			if (strncasecmp(optarg, "none", (size_t) 4) == 0)
-				opt.remote_efname = xstrdup("/dev/null");
-			else
-				opt.remote_efname = xstrdup(optarg);
-			break;
-		case 'h':
-			_help();
-			exit(0);
-		case 'i':
-			xfree(opt.local_ifname);
-			opt.local_ifname = xstrdup(optarg);
-			break;
-		case 'I':
-			xfree(opt.remote_ifname);
-			opt.remote_ifname = xstrdup(optarg);
-			break;
-		case 'J':
-			xfree(opt.job_name);
-			opt.job_name = xstrdup(optarg);
-			break;
-		case 'K':
-			opt.kill_bad_exit = true;
-			break;
-		case 'l':
-			opt.labelio = true;
-			break;
-		case 'L':
-			xfree(opt.nodelist_byid);
-			opt.nodelist_byid = xstrdup(optarg);
-			break;
-		case 'm':
-			opt.plane_size = 0;
-			opt.distribution = _verify_dist_type(optarg, 
-							     &opt.plane_size);
-			if (opt.distribution == SLURM_DIST_UNKNOWN) {
-				error("distribution type `%s' " 
-				      "is not recognized", optarg);
-				exit(1);
-			}
-			break;
-		case 'n':
-			opt.num_tasks_set = true;
-			opt.num_tasks = _get_pos_int(optarg, "number of tasks");
-			break;
-		case 'N':
-			opt.num_nodes_set = true;
-			opt.num_nodes = _get_pos_int(optarg, "number of nodes");
-			break;
-		case 'o':
-			xfree(opt.local_ofname);
-			if (strncasecmp(optarg, "none", (size_t) 4) == 0)
-				opt.local_ofname = xstrdup("/dev/null");
-			else
-				opt.local_ofname = xstrdup(optarg);
-			break;
-		case 'O':
-			xfree(opt.remote_ofname);
-			if (strncasecmp(optarg, "none", (size_t) 4) == 0)
-				opt.remote_ofname = xstrdup("/dev/null");
-			else
-				opt.remote_ofname = xstrdup(optarg);
-			break;
-		case 'q':
-			opt.quiet++;
-			break;
-		case 'r':
-			opt.relative_set = true;
-			opt.relative = _get_int(optarg, "relative start node", 
-				false);
-			break;
-		case 'T':
-			xfree(opt.task_layout);
-			opt.task_layout_byid = xstrdup(optarg);
-			opt.task_layout_byid_set = true;
-			break;
-		case 'u':
-			opt.unbuffered = true;
-			break;
-		case 'v':
-			opt.verbose++;
-			break;
-		case 'V':
-			_print_version();
-			exit(0);
-			break;
-		case 'w':
-			xfree(opt.nodelist);
-			opt.nodelist = xstrdup(optarg);
-#ifdef HAVE_BG
-			info("\tThe nodelist option should only be used if\n"
-			     "\tthe block you are asking for can be created.\n"
-			     "\tIt should also include all the midplanes you\n"
-			     "\twant to use, partial lists may not\n"
-			     "\twork correctly.\n"
-			     "\tPlease consult smap before using this option\n"
-			     "\tor your job may be stuck with no way to run.");
-#endif
-			break;
-		case 'W':
-			opt.max_wait = _get_pos_int(optarg, "wait");
-			break;
-		case 'Y':
-			xfree(opt.task_layout);
-			opt.task_layout = xstrdup(optarg);
-			opt.task_layout_byname_set = true;
-			break;
-                case LONG_OPT_CPU_BIND:
-			if (_verify_cpu_bind(optarg, &opt.cpu_bind,
-					     &opt.cpu_bind_type))
-				exit(1);
-			break;
-		case LONG_OPT_MEM_BIND:
-			if (_verify_mem_bind(optarg, &opt.mem_bind,
-					     &opt.mem_bind_type))
-				exit(1);
-			break;
-		case LONG_OPT_CORE:
-			opt.core_type = core_format_type (optarg);
-			if (opt.core_type == CORE_INVALID)
-				error ("--core=\"%s\" Invalid -- ignoring.\n",
-				       optarg);
-			break;
-		case LONG_OPT_MPI:
-			if (mpi_hook_client_init((char *)optarg)
-			    == SLURM_ERROR) {
-				fatal("\"--mpi=%s\" -- long invalid MPI type, "
-				      "--mpi=list for acceptable types.",
-				      optarg);
-			}
-			break;
-		case LONG_OPT_JOBID:
-			opt.jobid = _get_pos_int(optarg, "jobid");
-			opt.jobid_set = true;
-			break;
-		case LONG_OPT_UID:
-			opt.euid = uid_from_string (optarg);
-			if (opt.euid == (uid_t) -1)
-				fatal ("--uid=\"%s\" invalid", optarg);
-			break;
-		case LONG_OPT_GID:
-			opt.egid = gid_from_string (optarg);
-			if (opt.egid == (gid_t) -1)
-				fatal ("--gid=\"%s\" invalid", optarg);
-			break;
-		case LONG_OPT_DEBUG_TS:
-			/* simulate running under a parallel debugger */
-			opt.debugger_test    = true;
-			MPIR_being_debugged  = 1;
-			break;
-		case LONG_OPT_USAGE:
-			_usage();
-			exit(0);
-		case LONG_OPT_NETWORK:
-			xfree(opt.network);
-			opt.network = xstrdup(optarg);
-#ifdef HAVE_AIX
-			setenv("SLURM_NETWORK", opt.network, 1);
-#endif
-			break;
-		case LONG_OPT_PROPAGATE:
-			xfree(opt.propagate);
-			if (optarg) opt.propagate = xstrdup(optarg);
-			else	    opt.propagate = xstrdup("ALL");
-			break;
-		case LONG_OPT_PROLOG:
-			xfree(opt.prolog);
-			opt.prolog = xstrdup(optarg);
-			break;
-		case LONG_OPT_EPILOG:
-			xfree(opt.epilog);
-			opt.epilog = xstrdup(optarg);
-			break;
-		case LONG_OPT_TASK_PROLOG:
-			xfree(opt.task_prolog);
-			opt.task_prolog = xstrdup(optarg);
-			break;
-		case LONG_OPT_TASK_EPILOG:
-			xfree(opt.task_epilog);
-			opt.task_epilog = xstrdup(optarg);
-			break;
-		case LONG_OPT_COMM_HOSTNAME:
-			xfree(opt.comm_hostname);
-			opt.comm_hostname = xstrdup(optarg);
-			break;
-		case LONG_OPT_MULTI:
-			opt.multi_prog = true;
-			break;
-		case LONG_OPT_PMI_THREADS: /* undocumented option */
-			pmi_server_max_threads(_get_pos_int(optarg,
-							    "pmi-threads"));
-			break;
-		case LONG_OPT_LIN_FILTER:
-			if (strcmp(optarg, "-") != 0) {
-				opt.local_input_filter =
-					_get_pos_int(optarg,
-						     "slaunch-input-filter");
-			}
-			opt.local_input_filter_set = true;
-			break;
-		case LONG_OPT_LOUT_FILTER:
-			if (strcmp(optarg, "-") != 0) {
-				opt.local_output_filter =
-					_get_pos_int(optarg,
-						     "slaunch-output-filter");
-			}
-			opt.local_output_filter_set = true;
-			break;
-		case LONG_OPT_LERR_FILTER:
-			if (strcmp(optarg, "-") != 0) {
-				opt.local_error_filter =
-					_get_pos_int(optarg,
-						     "slaunch-error-filter");
-			}
-			opt.local_error_filter_set = true;
-			break;
-		case LONG_OPT_RIN_FILTER:
-			opt.remote_input_filter =
-				_get_pos_int(optarg, "task-input-filter");
-			error("task-input-filter not yet implemented");
-			break;
-		case LONG_OPT_ROUT_FILTER:
-			opt.remote_output_filter =
-				_get_pos_int(optarg, "task-output-filter");
-			error("task-output-filter not yet implemented");
-			break;
-		case LONG_OPT_RERR_FILTER:
-			opt.remote_error_filter =
-				_get_pos_int(optarg, "task-error-filter");
-			error("task-error-filter not yet implemented");
-			break;
-		default:
-			if (spank_process_option (opt_char, optarg) < 0) {
-				exit (1);
-			}
-		}
-	}
-
-	spank_option_table_destroy (optz);
-}
-
-/*
- * Use the supplied compiled regular expression "re" to convert a string
- * into first and last numbers in the range.
- *
- * If there is only a single number in the "token" string, both
- * "first" and "last" will be set to the same value.
- *
- * Returns 1 on success, 0 on failure
- */
-static int _get_range(regex_t *re, char *token, int *first, int *last,
-		      int num_nodes)
-{
-	size_t nmatch = 8;
-	regmatch_t pmatch[8];
-	long f, l;
-	bool first_set = false;
-	char *ptr;
-	
-	*first = *last = 0;
-	memset(pmatch, 0, sizeof(regmatch_t)*nmatch);
-	if (regexec(re, token, nmatch, pmatch, 0) == REG_NOMATCH) {
-		error("\"%s\" is not a valid node index range", token);
-		return 0;
-	}
-
-	/* convert the second, possibly only, number */
-	ptr = (char *)(xstrndup(token + pmatch[3].rm_so,
-				pmatch[3].rm_eo - pmatch[3].rm_so));
-	l = strtol(ptr, NULL, 10);
-	xfree(ptr);
-	if ((l >= 0 && l >= num_nodes)
-	    || (l < 0 && l < -num_nodes)) {
-		error("\"%ld\" is beyond the range of the"
-		      " %d available nodes", l, num_nodes);
-		return 0;
-	}
-	*last = (int)l;
-	*first = (int)l;
-
-	/* convert the first number, if it exists */
-	if (pmatch[2].rm_so != -1) {
-		first_set = true;
-		ptr = (char *)(xstrndup(token + pmatch[2].rm_so,
-					pmatch[2].rm_eo - pmatch[2].rm_so));
-		f = strtol(ptr, NULL, 10);
-		xfree(ptr);
-		if ((f >= 0 && f >= num_nodes)
-		    || (f < 0 && f < -num_nodes)) {
-			error("\"%ld\" is beyond the range of the"
-			      " %d available nodes", f, num_nodes);
-			return 0;
-		}
-		*first = (int)f;
-	}
-
-	return 1;
-}
-
-/*
- * Convert a node index string into a nodelist string.
- *
- * A node index string is a string of single numbers and/or ranges seperated
- * by commas.  For instance:  2,6,-3,8,-3-2,16,2--4,7-9,0
- *
- * If both numbers in a range are of the same sign (both positive, or both
- * negative), then the range counts directly from the first number to the
- * second number; it will not wrap around the "end" of the node list.
- *
- * If the numbers in a range differ in sign, the range wraps around the
- * end of the list of nodes.
- *
- * Examples: Given a node allocation of foo[1-16]:
- *
- *	-2-3  (negative 2 to positive 3) becomes foo[15-16,1-4]
- *	3--2  (positive 3 to negative 2) becomes foo[4,3,2,1,16,15]
- *	-3--2 becomes foo[14-15]
- *	-2--3 becomes foo[15,14]
- *	2-3   becomes foo[3-4]
- *	3-2   becomes foo[4,3]
- */
-static char *_node_indices_to_nodelist(const char *indices_list,
-				       resource_allocation_response_msg_t *alloc_info)
-{
-	char *list;
-	int list_len;
-	char *start, *end;
-	hostlist_t node_l, alloc_l;
-	regex_t range_re;
-	char *range_re_pattern =
-		"^[[:space:]]*"
-		"((-?[[:digit:]]+)[[:space:]]*-)?" /* optional start */
-		"[[:space:]]*"
-		"(-?[[:digit:]]+)[[:space:]]*$";
-	char *nodelist = NULL;
-	int i, idx;
-
-	/* intialize the regular expression */
-	if (regcomp(&range_re, range_re_pattern, REG_EXTENDED) != 0) {
-		error("Node index range regex compilation failed\n");
-		return NULL;
-	}
-
-	/* Now break the string up into tokens between commas,
-	   feed each token into the regular expression, and make
-	   certain that the range numbers are valid. */
-	node_l = hostlist_create(NULL);
-	alloc_l = hostlist_create(alloc_info->node_list);
-	list = xstrdup(indices_list);
-	start = (char *)list;
-	list_len = strlen(list);
-	while (start != NULL && start < (list + list_len)) {
-		int first = 0;
-		int last = 0;
-
-		/* Find the next index range in the list */
-		end = strchr(start,',');
-		if (end == NULL) {
-			end = list + list_len;
-		}
-		*end = '\0';
-
-		/* Use the regexp to get the range numbers */
-		if (!_get_range(&range_re, start, &first, &last,
-				hostlist_count(alloc_l))) {
-			goto cleanup;
-		}
-		
-		/* Now find all nodes in this range, and add them to node_l */
-		if (first <= last) {
-			char *node;
-			for (i = first; i <= last; i++) {
-				if (i < 0)
-					idx = i + hostlist_count(alloc_l);
-				else
-					idx = i;
-				node = hostlist_nth(alloc_l, idx);
-				hostlist_push(node_l, node);
-				free(node);
-			}
-		} else { /* first > last */
-			char *node;
-			for (i = first; i >= last; i--) {
-				if (i < 0)
-					idx = i + hostlist_count(alloc_l);
-				else
-					idx = i;
-				node = hostlist_nth(alloc_l, idx);
-				hostlist_push(node_l, node);
-				free(node);
-			}
-		}
-		start = end+1;
-	}
-
-	i = 2048;
-	nodelist = NULL;
-	do {
-		i *= 2;
-		xrealloc(nodelist, i);
-	} while (hostlist_ranged_string(node_l, i, nodelist) == -1);
-
-cleanup:
-	xfree(list);
-	hostlist_destroy(alloc_l);
-	hostlist_destroy(node_l);
-	regfree(&range_re);
-
-	return nodelist;
-}
-
-
-/* Load the multi_prog config file into argv, pass the  entire file contents 
- * in order to avoid having to read the file on every node. We could parse
- * the infomration here too for loading the MPIR records for TotalView */
-static void _load_multi(int *argc, char **argv)
-{
-	int config_fd, data_read = 0, i;
-	struct stat stat_buf;
-	char *data_buf;
-
-	if ((config_fd = open(argv[0], O_RDONLY)) == -1) {
-		error("Could not open multi_prog config file %s",
-		      argv[0]);
-		exit(1);
-	}
-	if (fstat(config_fd, &stat_buf) == -1) {
-		error("Could not stat multi_prog config file %s",
-		      argv[0]);
-		exit(1);
-	}
-	if (stat_buf.st_size > 60000) {
-		error("Multi_prog config file %s is too large",
-		      argv[0]);
-		exit(1);
-	}
-	data_buf = xmalloc(stat_buf.st_size);
-	while ((i = read(config_fd, &data_buf[data_read], stat_buf.st_size 
-			 - data_read)) != 0) {
-		if (i < 0) {
-			error("Error reading multi_prog config file %s", 
-			      argv[0]);
-			exit(1);
-		} else
-			data_read += i;
-	}
-	close(config_fd);
-	for (i=1; i<*argc; i++)
-		xfree(argv[i]);
-	argv[1] = data_buf;
-	*argc = 2;
-}
-
-/*
- * _opt_args() : set options via commandline args and popt
- */
-static void _opt_args(int argc, char **argv)
-{
-	int i;
-	char **rest = NULL;
-
-	set_options(argc, argv);
-
-#ifdef HAVE_AIX
-	if (opt.network == NULL) {
-		opt.network = "us,sn_all,bulk_xfer";
-		setenv("SLURM_NETWORK", opt.network, 1);
-	}
-#endif
-
-	opt.argc = 0;
-	if (optind < argc) {
-		rest = argv + optind;
-		while (rest[opt.argc] != NULL)
-			opt.argc++;
-	}
-	opt.argv = (char **) xmalloc((opt.argc + 1) * sizeof(char *));
-	for (i = 0; i < opt.argc; i++)
-		opt.argv[i] = xstrdup(rest[i]);
-	opt.argv[i] = NULL;	/* End of argv's (for possible execv) */
-
-	if (opt.multi_prog) {
-		if (opt.argc < 1) {
-			error("configuration file not specified");
-			exit(1);
-		}
-		_load_multi(&opt.argc, opt.argv);
-
-	}
-	else if (opt.argc > 0) {
-		char *fullpath;
-
-		if ((fullpath = _search_path(opt.argv[0], R_OK|X_OK))) {
-			xfree(opt.argv[0]);
-			opt.argv[0] = fullpath;
-		} 
-	}
-
-	if (!_opt_verify())
-		exit(1);
-}
-
-static bool
-_allocation_lookup_env(resource_allocation_response_msg_t **alloc_info)
-{
-	char *ptr, *val;
-	resource_allocation_response_msg_t *alloc;
-	long l;
-
-	alloc = (resource_allocation_response_msg_t *)xmalloc(
-		sizeof(resource_allocation_response_msg_t));
-
-	/* get SLURM_JOB_ID */
-	val = getenv("SLURM_JOB_ID");
-	if (val == NULL)
-		goto fail1;
-	l = strtol(val, &ptr, 10);
-	if (ptr == val || !xstring_is_whitespace(ptr) || l < 0)
-		goto fail1;
-	alloc->job_id = (uint32_t)l;
-
-	/* get SLURM_JOB_NUM_NODES */
-	val = getenv("SLURM_JOB_NUM_NODES");
-	if (val == NULL)
-		goto fail1;
-	l = strtol(val, &ptr, 10);
-	if (ptr == val || !xstring_is_whitespace(ptr) || l < 1)
-		goto fail1;
-	alloc->node_cnt = (uint16_t)l;
-
-	/* get SLURM_JOB_NODELIST */
-	val = getenv("SLURM_JOB_NODELIST");
-	if (val == NULL)
-		goto fail1;
-	alloc->node_list = xstrdup(val);
-
-	/* get SLURM_JOB_CPUS_PER_NODE */
-	val = getenv("SLURM_JOB_CPUS_PER_NODE");
-	if (val == NULL)
-		goto fail2;
-	if (!_set_cpus_per_node(val, alloc))
-		goto fail2;
-
-	*alloc_info = alloc;
-	return true;
-
-fail2:
-	xfree(alloc->node_list);
-fail1:
-	xfree(alloc);
-	*alloc_info = NULL;
-	return false;
-}
-
-static bool
-_set_allocation_info(resource_allocation_response_msg_t **alloc_info)
-{
-	bool env_flag;
-
-	/* First, try to set the allocation info from the environment */
-	env_flag = _allocation_lookup_env(alloc_info);
-
-	/* If that fails, we need to try to get the allocation info
-	 * from the slurmctld.  We also need to talk to the slurmctld if
-	 * opt.job_id is set and does not match the information from the
-	 * environment variables.
-	 */
-	if (!env_flag || (env_flag
-			  && opt.jobid_set
-			  && opt.jobid != (*alloc_info)->job_id)) {
-		verbose("Need to look up allocation info with the controller");
-		if (slurm_allocation_lookup_lite(opt.jobid, alloc_info) < 0) {
-			error("Unable to look up job ID %u: %m", opt.jobid);
-			return false;
-		}
-	} else if (!env_flag && !opt.jobid_set) {
-		error("A job ID MUST be specified on the command line,");
-		error("or through the SLAUNCH_JOBID environment variable.");
-		return false;
-	}
-
-	return true;
-}
-
-
-/* 
- * _opt_verify : perform some post option processing verification
- *
- */
-static bool _opt_verify(void)
-{
-	bool verified = true;
-	hostlist_t task_l = NULL;
-	hostlist_t node_l = NULL;
-	resource_allocation_response_msg_t *alloc_info;
-
-	if (!_set_allocation_info(&alloc_info)) {
-		/* error messages printed under _set_allocation_info */
-		exit(1);
-	}
-
-	/*
-	 * Now set default options based on allocation info.
-	 */
-	if (!opt.jobid_set)
-		opt.jobid = alloc_info->job_id;
-	if (!opt.num_nodes_set)
-		opt.num_nodes = alloc_info->node_cnt;
-
-	if (opt.task_layout_byid_set && opt.task_layout == NULL) {
-		opt.task_layout = _node_indices_to_nodelist(
-			opt.task_layout_byid, alloc_info);
-		if (opt.task_layout == NULL)
-			verified = false;
-	}
-	if (opt.nodelist_byid != NULL && opt.nodelist == NULL) {
-		hostlist_t hl;
-		char *nodenames;
-
-		nodenames = _node_indices_to_nodelist(opt.nodelist_byid,
-						      alloc_info);
-		if (nodenames == NULL) {
-			verified = false;
-		} else {
-			hl = hostlist_create(nodenames);
-			hostlist_uniq(hl);
-			/* assumes that the sorted unique hostlist must be a
-			   shorter string than unsorted (or equal lenght) */
-			hostlist_ranged_string(hl, strlen(nodenames)+1,
-					       nodenames);
-			opt.nodelist = nodenames;
-		}
-	}
-
-	/*
-	 * Now, all the rest of the checks and setup.
-	 */
-	if (opt.task_layout_byid_set && opt.task_layout_file_set) {
-		error("-T/--task-layout-byid and -F/--task-layout-file"
-		      " are incompatible.");
-		verified = false;
-	}
-	if (opt.task_layout_byname_set && opt.task_layout_file_set) {
-		error("-Y/--task-layout-byname and -F/--task-layout-file"
-		      " are incompatible.");
-		verified = false;
-	}
-	if (opt.task_layout_byname_set && opt.task_layout_byid_set) {
-		error("-Y/--task-layout-byname and -T/--task-layout-byid"
-		      " are incompatible.");
-		verified = false;
-	}
-
-	if (opt.nodelist && (opt.task_layout_byid_set
-			     || opt.task_layout_byname_set
-			     || opt.task_layout_file_set)) {
-		error("-w/--nodelist is incompatible with task layout"
-		      " options.");
-		verified = false;
-	}
-	if (opt.nodelist && opt.task_layout_file_set) {
-		error("Only one of -w/--nodelist or -F/--task-layout-file"
-		      " may be used.");
-		verified = false;
-	}
-	if (opt.num_nodes_set && (opt.task_layout_byid_set
-				  || opt.task_layout_byname_set
-				  || opt.task_layout_file_set)) {
-		error("-N/--node is incompatible with task layout options.");
-		verified = false;
-	}
-
-	if (opt.task_layout != NULL) {
-		task_l = hostlist_create(opt.task_layout);
-		if (opt.num_tasks_set) {
-			if (opt.num_tasks < hostlist_count(task_l)) {
-				/* shrink the hostlist */
-				int i, shrink;
-				char buf[8192];
-				shrink = hostlist_count(task_l) - opt.num_tasks;
-				for (i = 0; i < shrink; i++)
-					free(hostlist_pop(task_l));
-				xfree(opt.task_layout);
-				hostlist_ranged_string(task_l, 8192, buf);
-				opt.task_layout = xstrdup(buf);
-			} else if (opt.num_tasks > hostlist_count(task_l)) {
-				error("Asked for more tasks (%d) than listed"
-				      " in the task layout (%d)",
-				      opt.num_tasks, hostlist_count(task_l));
-				verified = false;
-			} else {
-				/* they are equal, no problemo! */
-			}
-		} else {
-			opt.num_tasks = hostlist_count(task_l);
-			opt.num_tasks_set = true;
-		}
-		node_l = hostlist_copy(task_l);
-		hostlist_uniq(node_l);
-		opt.num_nodes = hostlist_count(node_l);
-		opt.num_nodes_set = true;
-		/* task_layout parameters implicitly trigger
-		   arbitrary task layout mode */
-		opt.distribution = SLURM_DIST_ARBITRARY;
-
-	} else if (opt.nodelist != NULL) {
-		hostlist_t tmp;
-		tmp = hostlist_create(opt.nodelist);
-		node_l = hostlist_copy(tmp);
-		hostlist_uniq(node_l);
-		if (hostlist_count(node_l) != hostlist_count(tmp)) {
-			error("Node names may only appear once in the"
-			      " nodelist (-w/--nodelist)");
-			verified = false;
-		}
-		hostlist_destroy(tmp);
-
-		if (opt.num_nodes_set
-		    && (opt.num_nodes != hostlist_count(node_l))) {
-			error("You asked for %d nodes (-N/--nodes), but there"
-			      " are %d nodes in the nodelist (-w/--nodelist)",
-			      opt.num_nodes, hostlist_count(node_l));
-			verified = false;
-		} else {
-			opt.num_nodes = hostlist_count(node_l);
-			opt.num_nodes_set = true;
-		}
-	}
-
-	if (opt.overcommit && opt.cpus_per_task_set) {
-		error("--overcommit/-C and --cpus-per-task/-c are incompatible");
-		verified = false;
-	}
-
-	if (!opt.num_nodes_set && opt.num_tasks_set
-	    && opt.num_tasks < opt.num_nodes)
-		opt.num_nodes = opt.num_tasks;
-
-	if (!opt.num_tasks_set) {
-		if (opt.nodelist != NULL) {
-			opt.num_tasks = hostlist_count(node_l);
-		} else {
-			opt.num_tasks = opt.num_nodes;
-		}
-	}
-
-	if (opt.quiet && opt.verbose) {
-		error ("don't specify both --verbose (-v) and --quiet (-q)");
-		verified = false;
-	}
-
-	if (opt.relative_set) {
-		if (opt.nodelist != NULL) {
-			error("-r/--relative not allowed with"
-			      " -w/--nodelist.");
-			verified = false;
-		}
-
-		if (opt.task_layout_byid_set) {
-			error("-r/--relative not allowed with"
-			      " -T/--task-layout-byid");
-			verified = false;
-		}
-
-		if (opt.task_layout_byname_set) {
-			error("-r/--relative not allowed with"
-			      " -Y/--task-layout-byname");
-			verified = false;
-		}
-
-		if (opt.task_layout_file_set) {
-			error("-r/--relative not allowed with"
-			      " -F/--task-layout-file");
-			verified = false;
-		}
-
-		/* convert a negative relative number into a positive number
-		   that the slurmctld will accept */
-		if (opt.relative < 0 && opt.relative >= -(alloc_info->node_cnt))
-			opt.relative += alloc_info->node_cnt;
-	}
-	if ((opt.job_name == NULL) && (opt.argc > 0))
-		opt.job_name = _base_name(opt.argv[0]);
-
-	if (opt.argc == 0) {
-		error("must supply remote command");
-		verified = false;
-	}
-
-
-	/* check for realistic arguments */
-	if (opt.num_tasks <= 0) {
-		error("%s: invalid number of tasks (-n %d)",
-		      opt.progname, opt.num_tasks);
-		verified = false;
-	}
-
-	if (opt.cpus_per_task <= 0) {
-		error("%s: invalid number of cpus per task (-c %d)\n",
-		      opt.progname, opt.cpus_per_task);
-		verified = false;
-	}
-
-	if (opt.num_nodes <= 0) {
-		error("%s: invalid number of nodes (-N %d)\n",
-		      opt.progname, opt.num_nodes);
-		verified = false;
-	}
-
-	core_format_enable (opt.core_type);
-
-	if (opt.labelio && opt.unbuffered) {
-		error("Do not specify both -l (--label) and " 
-		      "-u (--unbuffered)");
-		exit(1);
-	}
-
-	if ((opt.euid != (uid_t) -1) && (opt.euid != opt.uid)) 
-		opt.uid = opt.euid;
-
-	if ((opt.egid != (gid_t) -1) && (opt.egid != opt.gid)) 
-		opt.gid = opt.egid;
-
-        if ((opt.egid != (gid_t) -1) && (opt.egid != opt.gid))
-	        opt.gid = opt.egid;
-
-	if (opt.propagate && parse_rlimits( opt.propagate, PROPAGATE_RLIMITS)) {
-		error( "--propagate=%s is not valid.", opt.propagate );
-		verified = false;
-	}
-
-	/* FIXME - figure out the proper way to free alloc_info */
-	hostlist_destroy(task_l);
-	hostlist_destroy(node_l);
-	return verified;
-}
-
-static void
-_freeF(void *data)
-{
-	xfree(data);
-}
-
-static List
-_create_path_list(void)
-{
-	List l;
-	char *path = xstrdup(getenv("PATH"));
-	char *c, *lc;
-
-	if (path == NULL) {
-		error("No PATH environment variable (or empty PATH)");
-		return NULL;
-	}
-
-	l = list_create(_freeF);
-	c = lc = path;
-
-	while (*c != '\0') {
-		if (*c == ':') {
-			/* nullify and push token onto list */
-			*c = '\0';
-			if (lc != NULL && strlen(lc) > 0)
-				list_append(l, xstrdup(lc));
-			lc = ++c;
-		} else
-			c++;
-	}
-
-	if (strlen(lc) > 0)
-		list_append(l, xstrdup(lc));
-
-	xfree(path);
-
-	return l;
-}
-
-static char *
-_search_path(char *cmd, int access_mode)
-{
-	List         l        = _create_path_list();
-	ListIterator i        = NULL;
-	char *path, *fullpath = NULL;
-
-	if (l == NULL)
-		return NULL;
-
-	if ((cmd[0] == '.' || cmd[0] == '/')
-	    && (access(cmd, access_mode) == 0 ) ) {
-		if (cmd[0] == '.')
-			xstrfmtcat(fullpath, "%s/", opt.cwd);
-		xstrcat(fullpath, cmd);
-		goto done;
-	}
-
-	i = list_iterator_create(l);
-	while ((path = list_next(i))) {
-		xstrfmtcat(fullpath, "%s/%s", path, cmd);
-
-		if (access(fullpath, access_mode) == 0)
-			goto done;
-
-		xfree(fullpath);
-		fullpath = NULL;
-	}
-done:
-	list_destroy(l);
-	return fullpath;
-}
-
-
-static char *
-print_remote_command()
-{
-	int i;
-	char *buf = NULL;
-	char *space;
-
-	for (i = 0; i < opt.argc; i++) {
-		if (i == opt.argc-1) {
-			space = "";
-		} else {
-			space = " ";
-		}
-
-		xstrfmtcat(buf, "\"%s\"%s", opt.argv[i], space);
-	}
-
-	return buf;
-}
-
-#define tf_(b) (b == true) ? "true" : "false"
-
-static void _opt_list()
-{
-	char *str;
-
-	info("defined options for program \"%s\"", opt.progname);
-	info("--------------- ---------------------");
-
-	info("user              : \"%s\"", opt.user);
-	info("uid               : %ld", (long) opt.uid);
-	info("gid               : %ld", (long) opt.gid);
-	info("cwd               : %s", opt.cwd);
-	info("num_tasks         : %d %s", opt.num_tasks,
-	     opt.num_tasks_set ? "(set)" : "(default)");
-	info("cpus_per_task     : %d %s", opt.cpus_per_task,
-	     opt.cpus_per_task_set ? "(set)" : "(default)");
-	info("nodes             : %d %s",
-	     opt.num_nodes, opt.num_nodes_set ? "(set)" : "(default)");
-	info("jobid             : %u %s", opt.jobid, 
-	     opt.jobid_set ? "(set)" : "(default)");
-	info("job name          : \"%s\"", opt.job_name);
-	info("distribution      : %s",
-	     format_task_dist_states(opt.distribution));
-	info("cpu_bind          : %s", 
-	     opt.cpu_bind == NULL ? "default" : opt.cpu_bind);
-	info("mem_bind          : %s",
-	     opt.mem_bind == NULL ? "default" : opt.mem_bind);
-	info("core format       : %s", core_format_name (opt.core_type));
-	info("verbose           : %d", opt.verbose);
-	info("slurmd_debug      : %d", opt.slurmd_debug);
-	info("label output      : %s", tf_(opt.labelio));
-	info("unbuffered IO     : %s", tf_(opt.unbuffered));
-	info("overcommit        : %s", tf_(opt.overcommit));
-	info("wait              : %d", opt.max_wait);
-	info("required nodes    : %s", opt.nodelist);
-	info("network           : %s", opt.network);
-	info("propagate         : %s",
-	     opt.propagate == NULL ? "NONE" : opt.propagate);
-	info("prolog            : %s", opt.prolog);
-	info("epilog            : %s", opt.epilog);
-	info("task_prolog       : %s", opt.task_prolog);
-	info("task_epilog       : %s", opt.task_epilog);
-	info("comm_hostname     : %s", opt.comm_hostname);
-	info("multi_prog        : %s", opt.multi_prog ? "yes" : "no");
-	info("plane_size        : %u", opt.plane_size);
-	str = print_remote_command();
-	info("remote command : %s", str);
-	xfree(str);
-
-}
-
-static void _usage(void)
-{
- 	printf(
-"Usage: slaunch [-N nnodes] [-n ntasks] [-i in] [-o out] [-e err]\n"
-"               [-c ncpus] [-r n] [-t minutes]\n"
-"               [-D path] [--overcommit] [--no-kill]\n"
-"               [--label] [--unbuffered] [-m dist] [-J jobname]\n"
-"               [--jobid=id] [--batch] [--verbose] [--slurmd_debug=#]\n"
-"               [--core=type] [-W sec]\n"
-"               [--mpi=type]\n"
-"               [--kill-on-bad-exit] [--propagate[=rlimits] ]\n"
-"               [--cpu_bind=...] [--mem_bind=...]\n"
-"               [--prolog=fname] [--epilog=fname]\n"
-"               [--task-prolog=fname] [--task-epilog=fname]\n"
-"               [--comm-hostname=<hostname|address>] [--multi-prog]\n"
-"               [-w hosts...] [-L hostids...] executable [args...]\n");
-}
-
-static void _help(void)
-{
-	slurm_ctl_conf_t *conf;
-
-        printf (
-"Usage: slaunch [OPTIONS...] executable [args...]\n"
-"\n"
-"Parallel run options:\n"
-"  -n, --ntasks=ntasks         number of tasks to run\n"
-"  -N, --nodes=N               number of nodes on which to run\n"
-"  -c, --cpus-per-task=ncpus   number of cpus required per task\n"
-"  -i, --slaunch-input=file    slaunch will read stdin from \"file\"\n"
-"  -o, --slaunch-output=file   slaunch will write stdout to \"file\"\n"
-"  -e, --slaunch-error=file    slaunch will write stderr to \"file\"\n"
-"      --slaunch-input-filter=taskid  send stdin to only the specified task\n"
-"      --slaunch-output-filter=taskid only print stdout from the specified task\n"
-"      --slaunch-error-filter=taskid  only print stderr from the specified task\n"
-"  -I, --task-input=file       connect task stdin to \"file\"\n"
-"  -O, --task-output=file      connect task stdout to \"file\"\n"
-"  -E, --task-error=file       connect task stderr to \"file\"\n"
-"  -r, --relative=n            run job step relative to node n of allocation\n"
-"  -t, --time=minutes          time limit\n"
-"  -D, --workdir=path          the working directory for the launched tasks\n"
-"  -C, --overcommit            overcommit resources\n"
-"  -k, --no-kill               do not kill job on node failure\n"
-"  -K, --kill-on-bad-exit      kill the job if any task terminates with a\n"
-"                              non-zero exit code\n"
-"  -l, --label                 prepend task number to lines of stdout/err\n"
-"  -u, --unbuffered            do not line-buffer stdout/err\n"
-"  -m, --distribution=type     distribution method for processes to nodes\n"
-"                              (type = block|cyclic|hostfile)\n"
-"  -J, --job-name=jobname      name of job\n"
-"      --jobid=id              run under already allocated job\n"
-"  -W, --wait=sec              seconds to wait after first task exits\n"
-"                              before killing job\n"
-"  -v, --verbose               verbose mode (multiple -v's increase verbosity)\n"
-"  -q, --quiet                 quiet mode (suppress informational messages)\n"
-"  -d, --slurmd-debug=level    slurmd debug level\n"
-"      --core=type             change default corefile format type\n"
-"                              (type=\"list\" to list of valid formats)\n"
-"      --propagate[=rlimits]   propagate all [or specific list of] rlimits\n"
-"      --mpi=type              specifies version of MPI to use\n"
-"      --prolog=program        run \"program\" before launching job step\n"
-"      --epilog=program        run \"program\" after launching job step\n"
-"      --task-prolog=program   run \"program\" before launching task\n"
-"      --task-epilog=program   run \"program\" after launching task\n"
-"      --comm-hostname=hostname hostname for PMI communications with slaunch\n"
-"      --multi-prog            if set the program name specified is the\n"
-"                              configuration specificaiton for multiple programs\n"
-"  -w, --nodelist-byname=hosts...   request a specific list of hosts\n"
-"  -L, --nodelist-byid=hosts...     request a specific list of hosts\n");
-	conf = slurm_conf_lock();
-	if (conf->task_plugin != NULL
-	    && strcasecmp(conf->task_plugin, "task/affinity") == 0) {
-		printf(
-			"      --cpu_bind=             Bind tasks to CPUs\n"
-			"                              (see \"--cpu_bind=help\" for options)\n"
-			"      --mem_bind=             Bind memory to locality domains (ldom)\n"
-			"                              (see \"--mem_bind=help\" for options)\n"
-			);
-	}
-	slurm_conf_unlock();
-	spank_print_options (stdout, 6, 30);
-	printf("\n");
-
-        printf(
-#ifdef HAVE_AIX				/* AIX/Federation specific options */
-		"AIX related options:\n"
-		"  --network=type              communication protocol to be used\n"
-		"\n"
-#endif
-
-		"Help options:\n"
-		"  -h, --help                  show this help message\n"
-		"      --usage                 display brief usage message\n"
-		"\n"
-		"Other options:\n"
-		"  -V, --version               output version information and exit\n"
-		"\n"
-		);
-
-}
diff --git a/src/slaunch/opt.h b/src/slaunch/opt.h
deleted file mode 100644
index 1d6c18a07758d21b6172d985e5932e0cc3656d82..0000000000000000000000000000000000000000
--- a/src/slaunch/opt.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*****************************************************************************\
- *  opt.h - definitions for slaunch option processing
- *  $Id: opt.h 10574 2006-12-15 23:38:29Z jette $
- *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifndef _HAVE_SLAUNCH_OPT_H
-#define _HAVE_SLAUNCH_OPT_H
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <slurm/slurm.h>
-
-#include "src/common/macros.h" /* true and false */
-#include "src/common/env.h"
-#include "src/slaunch/core-format.h"
-//#include "src/common/mpi.h"
-
-#define MAX_USERNAME	9
-
-
-/* global variables relating to user options */
-
-#define format_task_dist_states(t) (t == SLURM_DIST_BLOCK) ? "block" :   \
-		                 (t == SLURM_DIST_CYCLIC) ? "cyclic" : \
-		                 (t == SLURM_DIST_PLANE) ? "plane" : \
-		                 (t == SLURM_DIST_CYCLIC_CYCLIC) ? "cyclic:cyclic" : \
-		                 (t == SLURM_DIST_CYCLIC_BLOCK) ? "cyclic:block" : \
-		                 (t == SLURM_DIST_BLOCK_CYCLIC) ? "block:cyclic" : \
-		                 (t == SLURM_DIST_BLOCK_BLOCK) ? "block:block" : \
-			         (t == SLURM_DIST_ARBITRARY) ? "arbitrary" : \
-			         "unknown"
-
-#define format_io_t(t) (t == IO_ONE) ? "one" : (t == IO_ALL) ? \
-                                                     "all" : "per task"
-
-typedef struct slaunch_options {
-
-	char *progname;		/* argv[0] of this program or 
-				 * configuration file if multi_prog */
-	bool multi_prog;	/* multiple programs to execute */
-	char user[MAX_USERNAME];/* local username		*/
-	uid_t uid;		/* local uid			*/
-	gid_t gid;		/* local gid			*/
-	uid_t euid;		/* effective user --uid=user	*/
-	gid_t egid;		/* effective group --gid=group	*/
-	char *cwd;		/* current working directory	*/
-
-	int  num_tasks;		/* --ntasks=n,      -n n	*/
-	bool num_tasks_set;	/* true if ntasks explicitly set */
-	uint32_t plane_size;    /* lllp distribution -> plane_size for
-				 * when -m plane=<# of lllp per
-				 * plane> */      
-	int  cpus_per_task;	/* --cpus-per-task=n, -c n	*/
-	bool cpus_per_task_set; /* true if cpus_per_task explicitly set */
-	int  num_nodes;		/* --nodes=n,       -N n	*/ 
-	bool num_nodes_set;	/* true if num_nodes explicitly set */
-	cpu_bind_type_t cpu_bind_type; /* --cpu_bind=           */
-	char *cpu_bind;		/* binding map for map/mask_cpu */
-	mem_bind_type_t mem_bind_type; /* --mem_bind=		*/
-	char *mem_bind;		/* binding map for map/mask_mem	*/
-	enum task_dist_states
-		distribution;	/* --distribution=, -m dist	*/
-	char *job_name;		/* --job-name=,     -J name	*/
-	unsigned int jobid;     /* --jobid=jobid                */
-	bool jobid_set;		/* true of jobid explicitly set */
-	char *mpi_type;		/* --mpi=type			*/
-
-	char *local_ofname;	/* --local-output, -o filename  */
-	char *local_ifname;	/* --local-input,  -i filename  */
-	char *local_efname;	/* --local-error, -e filename   */
-	uint32_t local_input_filter;
-	bool local_input_filter_set;
-	uint32_t local_output_filter;
-	bool local_output_filter_set;
-	uint32_t local_error_filter;
-	bool local_error_filter_set;
-	char *remote_ofname;	/* --remote-output filename     */
-	char *remote_ifname;	/* --remote-input filename      */
-	char *remote_efname;	/* --remote-error filename      */
-	uint32_t remote_input_filter;
-	uint32_t remote_output_filter;
-	uint32_t remote_error_filter;
-
-	int  slurmd_debug;	/* --slurmd-debug, -D           */
-	core_format_t core_type;/* --core= 	        	*/
-
-	bool labelio;		/* --label-output, -l		*/
-	bool unbuffered;        /* --unbuffered,   -u           */
-	bool overcommit;	/* --overcommit,   -O		*/
-	bool no_kill;		/* --no-kill, -k		*/
-	bool kill_bad_exit;	/* --kill-on-bad-exit, -K	*/
-	int  max_wait;		/* --wait,    -W		*/
-	int  quiet;
-	int  verbose;
-	bool debugger_test;	/* --debugger-test		*/
-	char *propagate;	/* --propagate[=RLIMIT_CORE,...]*/
-	char *task_epilog;	/* --task-epilog=		*/
-	char *task_prolog;	/* --task-prolog=		*/
-	char *nodelist;		/* -w,--nodelist=node1,node2,...*/
-	char *nodelist_byid;
-	char *task_layout;
-	char *task_layout_byid;
-	bool task_layout_byid_set;
-	bool task_layout_byname_set;
-	bool task_layout_file_set;
-	int relative;		/* --relative -r N              */
-	bool relative_set;      /* true if --relative set explicitly */
-	char *network;		/* --network=			*/
-
-	char *prolog;           /* --prolog                     */
-	char *epilog;           /* --epilog                     */
-	char *comm_hostname;	/* --comm-hostname		*/
-	int argc;		/* length of argv array		*/
-	char **argv;		/* left over on command line	*/
-} opt_t;
-
-opt_t opt;
-
-/* return whether any constraints were specified by the user 
- * (if new constraints are added above, might want to add them to this
- *  macro or move this to a function if it gets a little complicated)
- */
-#define constraints_given() opt.mincpus != -1 || opt.realmem != -1 ||\
-                            opt.tmpdisk != -1 || opt.contiguous   
-
-/* process options:
- * 1. set defaults
- * 2. update options with env vars
- * 3. update options with commandline args
- * 4. perform some verification that options are reasonable
- */
-int initialize_and_process_args(int argc, char *argv[]);
-
-/* set options based upon commandline args */
-void set_options(const int argc, char **argv);
-
-
-#endif	/* _HAVE_SLAUNCH_OPT_H */
diff --git a/src/slaunch/sigstr.c b/src/slaunch/sigstr.c
deleted file mode 100644
index 7e9dec5b250cfb0592cf8c9764ad0063133dd336..0000000000000000000000000000000000000000
--- a/src/slaunch/sigstr.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************************\
- * src/slaunch/sigstr.c - Function to convert signal to description
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by AUTHOR <AUTHOR@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <string.h>
-#include <sys/wait.h>
-
-#include "src/common/xassert.h"
-
-/*
- * Get a definition for strsignal :
- */
-#if defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL
-#  ifndef strsignal
- extern char *strsignal(int);
-#  endif
-#endif /* defined HAVE_DECL_STRSIGNAL && !HAVE_DECL_STRSIGNAL */
-
-char *
-sigstr(int status)
-{
-	xassert(WIFSIGNALED(status));
-
-	return strsignal(WTERMSIG(status));
-}
-
-
-
diff --git a/src/slaunch/sigstr.h b/src/slaunch/sigstr.h
deleted file mode 100644
index 510c588b2cf8f7ec68b8818d048840ea289027a7..0000000000000000000000000000000000000000
--- a/src/slaunch/sigstr.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************\
- * src/slaunch/sigstr.h - 
- * $Id: sigstr.h 10574 2006-12-15 23:38:29Z jette $
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifndef _SLAUNCH_SIGSTR_H
-#define _SLAUNCH_SIGSTR_H
-
-/*
- * Returns a descriptive string regarding the signal given in the
- * exit status 'status.' 
- *
- * WIFSIGNALED(status) must be true in order to call this function!
- */
-char *sigstr(int status);
-
-#endif /* !_SLAUNCH_SIGSTR_H */
diff --git a/src/slaunch/slaunch.c b/src/slaunch/slaunch.c
deleted file mode 100644
index 14000581f69dc6de580f77ba5e0873335b254682..0000000000000000000000000000000000000000
--- a/src/slaunch/slaunch.c
+++ /dev/null
@@ -1,906 +0,0 @@
-/*****************************************************************************\
- *  slaunch.c - user command for launching parallel jobs
- *
- *  $Id: slaunch.c 11250 2007-03-27 17:29:45Z jette $
- *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Christopher J. Morrone <morrone2@llnl.gov>,
- *    Mark Grondona <grondona@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif
-
-#ifdef HAVE_AIX
-#  undef HAVE_UNSETENV
-#  include <sys/checkpnt.h>
-#endif
-#ifndef HAVE_UNSETENV
-#  include "src/common/unsetenv.h"
-#endif
-
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <grp.h>
-
-#include <slurm/slurm.h>
-
-#include "src/common/macros.h"
-#include "src/common/fd.h"
-#include "src/common/log.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/switch.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xsignal.h"
-#include "src/common/xstring.h"
-#include "src/common/net.h"
-#include "src/common/mpi.h"
-#include "src/common/slurm_rlimits_info.h"
-#include "src/common/plugstack.h"
-#include "src/common/env.h"
-
-#include "src/slaunch/opt.h"
-#include "src/slaunch/sigstr.h"
-#include "src/slaunch/attach.h"
-#include "src/slaunch/slaunch.h"
-#include "src/slaunch/fname.h"
-#include "src/slaunch/multi_prog.h"
-#include "src/api/pmi_server.h"
-
-/* FIXME doesn't belong here, we don't want to expose ctx contents */
-#include "src/api/step_ctx.h"
-
-extern char **environ;
-slurm_step_ctx step_ctx;
-int global_rc;
-struct {
-	bitstr_t *start_success;
-	bitstr_t *start_failure;
-	bitstr_t *finish_normal;
-	bitstr_t *finish_abnormal;
-} task_state;
-
-/*
- * declaration of static funcs
- */
-static void _set_prio_process_env(char ***env);
-static int  _set_rlimit_env(char ***env);
-static int  _set_umask_env(char ***env);
-static char **_init_task_environment(void);
-#if 0
-static int  _become_user(uid_t uid, gid_t gid);
-#endif
-static void _run_slaunch_prolog(char **env);
-static void _run_slaunch_epilog(char **env);
-static int  _run_slaunch_script(char *script, char **env);
-static void _setup_local_fds(slurm_step_io_fds_t *cio_fds, slurm_step_ctx ctx);
-static void _task_start(launch_tasks_response_msg_t *msg);
-static void _task_finish(task_exit_msg_t *msg);
-static void _task_state_struct_init(int num_tasks);
-static void _task_state_struct_print(void);
-static void _task_state_struct_free(void);
-static void _mpir_init(int num_tasks);
-static void _mpir_cleanup(void);
-static void _mpir_set_executable_names(const char *executable_name);
-static void _mpir_dump_proctable(void);
-static void _ignore_signal(int signo);
-static void _exit_on_signal(int signo);
-static int _call_spank_local_user(slurm_step_ctx step_ctx,
-				  slurm_step_launch_params_t *step_params);
-static void  _define_symbols(void);
-
-int slaunch(int argc, char **argv)
-{
-	log_options_t logopt = LOG_OPTS_STDERR_ONLY;
-	slurm_step_ctx_params_t ctx_params[1];
-	slurm_step_launch_params_t launch_params[1];
-	slurm_step_launch_callbacks_t callbacks[1];
-	char **env;
-	uint32_t job_id, step_id;
-	int i;
-
-	log_init(xbasename(argv[0]), logopt, 0, NULL);
-
-	xsignal(SIGQUIT, _ignore_signal);
-	xsignal(SIGPIPE, _ignore_signal);
-	xsignal(SIGUSR1, _ignore_signal);
-	xsignal(SIGUSR2, _ignore_signal);
-	
-	/* Initialize plugin stack, read options from plugins, etc. */
-	if (spank_init(NULL) < 0) {
-		fatal("Plug-in initialization failed");
-		_define_symbols();
-	}
-
-	/* Be sure to call spank_fini when slaunch exits. */
-	if (atexit((void (*) (void)) spank_fini) < 0)
-		error("Failed to register atexit handler for plugins: %m");
-
-	/* set default options, process commandline arguments, and
-	 * verify some basic values
-	 */
-	if (initialize_and_process_args(argc, argv) < 0) {
-		error ("slaunch initialization failed");
-		exit (1);
-	}
-	
-	/* reinit log with new verbosity (if changed by command line) */
-	if (opt.verbose || opt.quiet) {
-		logopt.stderr_level += opt.verbose;
-		logopt.stderr_level -= opt.quiet;
-		logopt.prefix_level = 1;
-		log_alter(logopt, 0, NULL);
-	}
-	debug("slaunch pid %d", getpid());
-
-	/*
-	 * Create a job step context.
-	 */
-	slurm_step_ctx_params_t_init(ctx_params);
-	ctx_params->job_id = opt.jobid;
-	totalview_jobid = NULL;
-	xstrfmtcat(totalview_jobid, "%u", ctx_params->job_id);
-	ctx_params->node_count = opt.num_nodes;
-	ctx_params->task_count = opt.num_tasks;
-	if (opt.cpus_per_task_set) {
-		ctx_params->cpu_count = opt.num_tasks * opt.cpus_per_task;
-	} else if (opt.overcommit) {
-		ctx_params->cpu_count = 0;
-	} else {
-		ctx_params->cpu_count = opt.num_tasks;
-	}
-	ctx_params->relative = opt.relative;
-	switch (opt.distribution) {
-	case SLURM_DIST_BLOCK:
-	case SLURM_DIST_ARBITRARY:
-	case SLURM_DIST_CYCLIC:
-	case SLURM_DIST_CYCLIC_CYCLIC:
-	case SLURM_DIST_CYCLIC_BLOCK:
-	case SLURM_DIST_BLOCK_CYCLIC:
-	case SLURM_DIST_BLOCK_BLOCK:
-		ctx_params->task_dist = opt.distribution;
-		break;
-	case SLURM_DIST_PLANE:
-		ctx_params->task_dist = SLURM_DIST_PLANE;
-		ctx_params->plane_size = opt.plane_size;
-		break;
-	default:
-		ctx_params->task_dist = (ctx_params->task_count <= 
-			ctx_params->node_count) 
-			? SLURM_DIST_CYCLIC : SLURM_DIST_BLOCK;
-		break;
-
-	}
-	ctx_params->overcommit = opt.overcommit;
-
-	/* SLURM overloads the node_list parameter in the
-	 * job_step_create_request_msg_t.  It can either be a node list,
-	 * or when distribution type is SLURM_DIST_ARBITRARY, it is a list
-	 * of repeated nodenames which represent to which node each task
-	 * is assigned.
-	 */
-	if (opt.task_layout_byid_set
-	    || opt.task_layout_byname_set
-	    || opt.task_layout_file_set) {
-		ctx_params->node_list = opt.task_layout;
-	} else if (opt.nodelist != NULL) {
-		ctx_params->node_list = opt.nodelist;
-	} else {
-		ctx_params->node_list = NULL; /* let the controller pick nodes */
-	}
-
-	ctx_params->network = opt.network;
-	ctx_params->name = opt.job_name;
-	
-	for (i=0; ;i++) {
-		step_ctx = slurm_step_ctx_create(ctx_params);
-		if (step_ctx != NULL)
-			break;
-		if (slurm_get_errno() != ESLURM_DISABLED) {
-			error("Failed creating job step context: %m");
-			exit(1);
-		}
-		if (i == 0)
-			info("Job step creation temporarily disabled, retrying");
-		sleep(MIN((i*10), 60));
-	}
-
-	/* Now we can register a few more signal handlers.  It
-	 * is only safe to have _exit_on_signal call
-	 * slurm_step_launch_abort after the the step context
-	 * has been created.
-	 */
-	xsignal(SIGHUP, _exit_on_signal);
-	xsignal(SIGINT, _exit_on_signal);
-	xsignal(SIGTERM, _exit_on_signal);
-
-	/* set up environment variables */
-	env = _init_task_environment();
-
-	/*
-	 * Use the job step context to launch the tasks.
-	 */
-	_task_state_struct_init(opt.num_tasks);
-	slurm_step_launch_params_t_init(launch_params);
-	launch_params->gid = opt.gid;
-	launch_params->argc = opt.argc;
-	launch_params->argv = opt.argv;
-	launch_params->multi_prog = opt.multi_prog ? true : false;
-	launch_params->envc = envcount(env);
-	launch_params->env = env;
-	launch_params->cwd = opt.cwd;
-	launch_params->slurmd_debug = opt.slurmd_debug;
-	launch_params->buffered_stdio = opt.unbuffered ? false : true;
-	launch_params->labelio = opt.labelio ? true : false;
-	launch_params->remote_output_filename = opt.remote_ofname;
-	launch_params->remote_input_filename = opt.remote_ifname;
-	launch_params->remote_error_filename = opt.remote_efname;
-	launch_params->task_prolog = opt.task_prolog;
-	launch_params->task_epilog = opt.task_epilog;
-	launch_params->cpu_bind = opt.cpu_bind;
-	launch_params->cpu_bind_type = opt.cpu_bind_type;
-	launch_params->mem_bind = opt.mem_bind;
-	launch_params->mem_bind_type = opt.mem_bind_type;
-	
-	_setup_local_fds(&launch_params->local_fds, step_ctx);
-	if (MPIR_being_debugged) {
-		launch_params->parallel_debug = true;
-		pmi_server_max_threads(1);
-	} else {
-		launch_params->parallel_debug = false;
-	}
-	callbacks->task_start = _task_start;
-	callbacks->task_finish = _task_finish;
-
-	_run_slaunch_prolog(env);
-
-	_mpir_init(ctx_params->task_count);
-
-	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_JOBID, &job_id);
-	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_STEPID, &step_id);
-	verbose("Launching job step %u.%u", job_id, step_id);
-
-	_call_spank_local_user(step_ctx, launch_params);
-
-	if (slurm_step_launch(step_ctx, launch_params, callbacks)
-	    != SLURM_SUCCESS) {
-		error("Application launch failed: %m");
-		goto cleanup;
-	}
-
-	if (slurm_step_launch_wait_start(step_ctx) == SLURM_SUCCESS) {
-		/* Only set up MPIR structures if the step launched
-		   correctly. */
-		if (opt.multi_prog)
-			mpir_set_multi_name(ctx_params->task_count,
-					    launch_params->argv[0]);
-		else
-			_mpir_set_executable_names(launch_params->argv[0]);
-		MPIR_debug_state = MPIR_DEBUG_SPAWNED;
-		MPIR_Breakpoint();
-		if (opt.debugger_test)
-			_mpir_dump_proctable();
-	} else {
-		info("Job step aborted before step completely launched.");
-	}
-
-	slurm_step_launch_wait_finish(step_ctx);
-
-cleanup:
-	_run_slaunch_epilog(env);
-	slurm_step_ctx_destroy(step_ctx);
-	_mpir_cleanup();
-	_task_state_struct_free();
-
-	return global_rc;
-}
-
-/* Set SLURM_UMASK environment variable with current state */
-static int _set_umask_env(char ***env)
-{
-	char mask_char[5];
-	mode_t mask = (int)umask(0);
-	umask(mask);
-
-	sprintf(mask_char, "0%d%d%d", 
-		((mask>>6)&07), ((mask>>3)&07), mask&07);
-	if (!env_array_overwrite_fmt(env, "SLURM_UMASK", "%s", mask_char)) {
-		error ("unable to set SLURM_UMASK in environment");
-		return SLURM_FAILURE;
-	}
-	debug ("propagating UMASK=%s", mask_char); 
-	return SLURM_SUCCESS;
-}
-
-/*
- * _set_prio_process_env
- *
- * Set the internal SLURM_PRIO_PROCESS environment variable to support
- * the propagation of the users nice value and the "PropagatePrioProcess"
- * config keyword.
- */
-static void _set_prio_process_env(char ***env)
-{
-	int retval;
-
-	errno = 0; /* needed to detect a real failure since prio can be -1 */
-
-	if ((retval = getpriority (PRIO_PROCESS, 0)) == -1)  {
-		if (errno) {
-			error ("getpriority(PRIO_PROCESS): %m");
-			return;
-		}
-	}
-
-	if (!env_array_overwrite_fmt(env, "SLURM_PRIO_PROCESS",
-				     "%d", retval)) {
-		error ("unable to set SLURM_PRIO_PROCESS in environment");
-		return;
-	}
-
-	debug ("propagating SLURM_PRIO_PROCESS=%d", retval);
-}
-
-/* Set SLURM_RLIMIT_* environment variables with current resource 
- * limit values, reset RLIMIT_NOFILE to maximum possible value */
-static int _set_rlimit_env(char ***env)
-{
-	int                  rc = SLURM_SUCCESS;
-	struct rlimit        rlim[1];
-	unsigned long        cur;
-	char                 name[64], *format;
-	slurm_rlimits_info_t *rli;
-
-	for (rli = get_slurm_rlimits_info(); rli->name != NULL; rli++ ) {
-
-		if (getrlimit (rli->resource, rlim) < 0) {
-			error ("getrlimit (RLIMIT_%s): %m", rli->name);
-			rc = SLURM_FAILURE;
-			continue;
-		}
-		
-		cur = (unsigned long) rlim->rlim_cur;
-		snprintf(name, sizeof(name), "SLURM_RLIMIT_%s", rli->name);
-		if (opt.propagate && rli->propagate_flag == PROPAGATE_RLIMITS)
-			/*
-			 * Prepend 'U' to indicate user requested propagate
-			 */
-			format = "U%lu";
-		else
-			format = "%lu";
-		
-		if (!env_array_overwrite_fmt(env, name, format, cur)) {
-			error ("unable to set %s in environment", name);
-			rc = SLURM_FAILURE;
-			continue;
-		}
-		
-		debug ("propagating RLIMIT_%s=%lu", rli->name, cur);
-	}
-
-	/* 
-	 *  Now increase NOFILE to the max available for this slaunch
-	 */
-	if (getrlimit (RLIMIT_NOFILE, rlim) < 0)
-	 	return (error ("getrlimit (RLIMIT_NOFILE): %m"));
-
-	if (rlim->rlim_cur < rlim->rlim_max) {
-		rlim->rlim_cur = rlim->rlim_max;
-		if (setrlimit (RLIMIT_NOFILE, rlim) < 0) 
-			return (error ("Unable to increase max no. files: %m"));
-	}
-
-	return rc;
-}
-
-static char **_init_task_environment(void)
-{
-	char **env;
-
-	env = env_array_copy((const char **)environ);
-
-	(void)_set_rlimit_env(&env);
-	_set_prio_process_env(&env);
-	(void)_set_umask_env(&env);
-
-	env_array_overwrite_fmt(&env, "SLURM_CPUS_PER_TASK",
-				"%d", opt.cpus_per_task);
-
-	return env;
-}
-
-#if 0
-static int _become_user (uid_t uid, gid_t gid)
-{
-	struct passwd *pwd = getpwuid (opt.uid);
-
-	if (uid == getuid())
-		return (0);
-
-	if ((gid != (gid_t)-1) && (setgid(gid) < 0))
-		return (error("setgid: %m"));
-
-	initgroups(pwd->pw_name, pwd->pw_gid); /* Ignore errors */
-
-	if (setuid(uid) < 0)
-		return (error("setuid: %m"));
-
-	return (0);
-}
-#endif
-
-static void _run_slaunch_prolog (char **env)
-{
-	int rc;
-
-	if (opt.prolog && strcasecmp(opt.prolog, "none") != 0) {
-		rc = _run_slaunch_script(opt.prolog, env);
-		debug("slaunch prolog rc = %d", rc);
-	}
-}
-
-static void _run_slaunch_epilog (char **env)
-{
-	int rc;
-
-	if (opt.epilog && strcasecmp(opt.epilog, "none") != 0) {
-		rc = _run_slaunch_script(opt.epilog, env);
-		debug("slaunch epilog rc = %d", rc);
-	}
-}
-
-static int _run_slaunch_script (char *script, char **env)
-{
-	int status;
-	pid_t cpid;
-	int i;
-	char **args = NULL;
-
-	if (script == NULL || script[0] == '\0')
-		return 0;
-
-	if (access(script, R_OK | X_OK) < 0) {
-		info("Access denied for %s: %m", script);
-		return 0;
-	}
-
-	if ((cpid = fork()) < 0) {
-		error ("run_slaunch_script: fork: %m");
-		return -1;
-	}
-	if (cpid == 0) {
-		/* set the script's command line arguments to the arguments
-		 * for the application, but shifted one higher
-		 */
-		args = xmalloc(sizeof(char *) * (opt.argc+2));
-		args[0] = script;
-		for (i = 0; i < opt.argc; i++) {
-			args[i+1] = opt.argv[i];
-		}
-		args[i+1] = NULL;
-		execve(script, args, env);
-		error("help! %m");
-		exit(127);
-	}
-
-	do {
-		if (waitpid(cpid, &status, 0) < 0) {
-			if (errno == EINTR)
-				continue;
-			error("waidpid: %m");
-			return 0;
-		} else
-			return status;
-	} while(1);
-
-	/* NOTREACHED */
-}
-
-static int
-_taskid_to_nodeid(slurm_step_layout_t *layout, int taskid)
-{
-	int i, nodeid;
-
-	for (nodeid = 0; nodeid < layout->node_cnt; nodeid++) {
-		for (i = 0; i < layout->tasks[nodeid]; i++) {
-			if (layout->tids[nodeid][i] == taskid) {
-				debug3("task %d is on node %d",
-				       taskid, nodeid);
-				return nodeid;
-			}
-		}
-	}
-
-	return -1; /* node ID not found */
-}
-
-static void
-_setup_local_fds(slurm_step_io_fds_t *cio_fds, slurm_step_ctx ctx)
-{
-	bool err_shares_out = false;
-	fname_t *ifname, *ofname, *efname;
-	uint32_t job_id, step_id;
-
-	slurm_step_ctx_get(ctx, SLURM_STEP_CTX_JOBID, &job_id);
-	slurm_step_ctx_get(ctx, SLURM_STEP_CTX_STEPID, &step_id);
-
-	ifname = fname_create(opt.local_ifname, (int)job_id, (int)step_id);
-	ofname = fname_create(opt.local_ofname, (int)job_id, (int)step_id);
-	efname = fname_create(opt.local_efname, (int)job_id, (int)step_id);
-
-	/*
-	 * create stdin file descriptor
-	 */
-	if (ifname->name == NULL) {
-		cio_fds->in.fd = STDIN_FILENO;
-	} else {
-		cio_fds->in.fd = open(ifname->name, O_RDONLY);
-		if (cio_fds->in.fd == -1)
-			fatal("Could not open stdin file: %m");
-	}
-	/*
-	 * create stdout file descriptor
-	 */
-	if (ofname->name == NULL) {
-		cio_fds->out.fd = STDOUT_FILENO;
-	} else {
-		cio_fds->out.fd = open(ofname->name,
-				       O_CREAT|O_WRONLY|O_TRUNC, 0644);
-		if (cio_fds->out.fd == -1)
-			fatal("Could not open stdout file: %m");
-	}
-	/* FIXME - need to change condition for shared output and error */
-	if (ofname->name != NULL
-	    && efname->name != NULL
-	    && !strcmp(ofname->name, efname->name)) {
-		err_shares_out = true;
-	}
-
-	/*
-	 * create seperate stderr file descriptor only if stderr is not sharing
-	 * the stdout file descriptor
-	 */
-	if (err_shares_out) {
-		debug3("stdout and stderr sharing a file");
-		cio_fds->err.fd = cio_fds->out.fd;
-		cio_fds->err.taskid = cio_fds->out.taskid;
-	} else {
-		if (efname->name == NULL) {
-			cio_fds->err.fd = STDERR_FILENO;
-		} else {
-			cio_fds->err.fd = open(efname->name,
-					       O_CREAT|O_WRONLY|O_TRUNC, 0644);
-			if (cio_fds->err.fd == -1)
-				fatal("Could not open stderr file: %m");
-		}
-	}
-
-
-	/*
-	 * set up local standard IO filters
-	 */
-	if (opt.local_input_filter_set) {
-		cio_fds->in.taskid = opt.local_input_filter;
-	}
-	/* FIXME - don't peek into the step context, that's cheating! */
-	if (opt.local_input_filter != (uint32_t)-1) {
-		cio_fds->in.nodeid =
-			_taskid_to_nodeid(step_ctx->step_resp->step_layout,
-					  opt.local_input_filter);
-	}
-	if (opt.local_output_filter_set) {
-		cio_fds->out.taskid = opt.local_output_filter;
-	}
-	if (opt.local_error_filter_set) {
-		cio_fds->err.taskid = opt.local_error_filter;
-	} else if (opt.local_output_filter_set) {
-		cio_fds->err.taskid = opt.local_output_filter;
-	}
-}
-
-static void
-_task_start(launch_tasks_response_msg_t *msg)
-{
-	MPIR_PROCDESC *table;
-	int taskid;
-	int i;
-
-	verbose("Node %s (%d), %d tasks started",
-		msg->node_name, msg->srun_node_id, msg->count_of_pids);
-
-	for (i = 0; i < msg->count_of_pids; i++) {
-		taskid = msg->task_ids[i];
-		table = &MPIR_proctable[taskid];
-		table->host_name = xstrdup(msg->node_name);
-		/* table->executable_name is set elsewhere */
-		table->pid = msg->local_pids[i];
-
-		if (msg->return_code == 0) {
-			bit_set(task_state.start_success, taskid);
-		} else {
-			bit_set(task_state.start_failure, taskid);
-		}
-	}
-
-}
-
-static void
-_terminate_job_step(slurm_step_ctx ctx)
-{
-	uint32_t job_id, step_id;
-
-	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_JOBID, &job_id);
-	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_STEPID, &step_id);
-	info("Terminating job step %u.%u", job_id, step_id);
-	slurm_kill_job_step(job_id, step_id, SIGKILL);
-}
-
-static void
-_handle_max_wait(int signo)
-{
-	info("First task exited %ds ago", opt.max_wait);
-	_task_state_struct_print();
-	_terminate_job_step(step_ctx);
-}
-
-static void
-_task_finish(task_exit_msg_t *msg)
-{
-	static bool first_done = true;
-	static bool first_error = true;
-	int rc = 0;
-	int i;
-
-	verbose("%d tasks finished (rc=%u)",
-		msg->num_tasks, msg->return_code);
-	if (WIFEXITED(msg->return_code)) {
-		rc = WEXITSTATUS(msg->return_code);
-		if (rc != 0) {
-			for (i = 0; i < msg->num_tasks; i++) {
-				error("task %u exited with exit code %d",
-				      msg->task_id_list[i], rc);
-				bit_set(task_state.finish_abnormal,
-					msg->task_id_list[i]);
-			}
-		} else {
-			for (i = 0; i < msg->num_tasks; i++) {
-				bit_set(task_state.finish_normal,
-					msg->task_id_list[i]);
-			}
-		}
-	} else if (WIFSIGNALED(msg->return_code)) {
-		for (i = 0; i < msg->num_tasks; i++) {
-			verbose("task %u killed by signal %d",
-				msg->task_id_list[i],
-				WTERMSIG(msg->return_code));
-			bit_set(task_state.finish_abnormal,
-				msg->task_id_list[i]);
-		}
-		rc = 1;
-	}
-	global_rc = MAX(global_rc, rc);
-
-	if (first_error && rc > 0 && opt.kill_bad_exit) {
-		first_error = false;
-		_terminate_job_step(step_ctx);
-	} else if (first_done && opt.max_wait > 0) {
-		/* If these are the first tasks to finish we need to
-		 * start a timer to kill off the job step if the other
-		 * tasks don't finish within opt.max_wait seconds.
-		 */
-		first_done = false;
-		debug2("First task has exited");
-		xsignal(SIGALRM, _handle_max_wait);
-		verbose("starting alarm of %d seconds", opt.max_wait);
-		alarm(opt.max_wait);
-	}
-}
-
-static void
-_task_state_struct_init(int num_tasks)
-{
-	task_state.start_success = bit_alloc(num_tasks);
-	task_state.start_failure = bit_alloc(num_tasks);
-	task_state.finish_normal = bit_alloc(num_tasks);
-	task_state.finish_abnormal = bit_alloc(num_tasks);
-}
-
-/*
- * Tasks will most likely have bits set in multiple of the task_state
- * bit strings (e.g. a task can start normally and then later exit normally)
- * so we ensure that a task is only "seen" once.
- */
-static void
-_task_state_struct_print(void)
-{
-	bitstr_t *tmp, *seen, *not_seen;
-	char buf[BUFSIZ];
-	int len;
-
-	len = bit_size(task_state.finish_abnormal); /* all the same length */
-	tmp = bit_alloc(len);
-	seen = bit_alloc(len);
-	not_seen = bit_alloc(len);
-	bit_not(not_seen);
-
-	if (bit_set_count(task_state.finish_abnormal) > 0) {
-		bit_copybits(tmp, task_state.finish_abnormal);
-		bit_and(tmp, not_seen);
-		bit_fmt(buf, BUFSIZ, tmp);
-		info("task%s: exited abnormally", buf);
-		bit_or(seen, tmp);
-		bit_copybits(not_seen, seen);
-		bit_not(not_seen);
-	}
-
-	if (bit_set_count(task_state.finish_normal) > 0) {
-		bit_copybits(tmp, task_state.finish_normal);
-		bit_and(tmp, not_seen);
-		bit_fmt(buf, BUFSIZ, tmp);
-		info("task%s: exited", buf);
-		bit_or(seen, tmp);
-		bit_copybits(not_seen, seen);
-		bit_not(not_seen);
-	}
-
-	if (bit_set_count(task_state.start_failure) > 0) {
-		bit_copybits(tmp, task_state.start_failure);
-		bit_and(tmp, not_seen);
-		bit_fmt(buf, BUFSIZ, tmp);
-		info("task%s: failed to start", buf);
-		bit_or(seen, tmp);
-		bit_copybits(not_seen, seen);
-		bit_not(not_seen);
-	}
-
-	if (bit_set_count(task_state.start_success) > 0) {
-		bit_copybits(tmp, task_state.start_success);
-		bit_and(tmp, not_seen);
-		bit_fmt(buf, BUFSIZ, tmp);
-		info("task%s: running", buf);
-		bit_or(seen, tmp);
-		bit_copybits(not_seen, seen);
-		bit_not(not_seen);
-	}
-}
-
-static void
-_task_state_struct_free(void)
-{
-	bit_free(task_state.start_success);
-	bit_free(task_state.start_failure);
-	bit_free(task_state.finish_normal);
-	bit_free(task_state.finish_abnormal);
-}
-
-
-/* FIXME - maybe we can push this under the step_launch function? */
-static int _call_spank_local_user (slurm_step_ctx step_ctx,
-				   slurm_step_launch_params_t *step_params)
-{
-	struct spank_launcher_job_info info[1];
-	job_step_create_response_msg_t *step_resp;
-
-	info->uid = getuid();
-	info->gid = step_params->gid;
-	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_JOBID, &info->jobid);
-	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_STEPID, &info->stepid);
-	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_RESP, &step_resp);
-	info->step_layout = step_resp->step_layout;
-	info->argc = step_params->argc;
-	info->argv = step_params->argv;
-
-	return spank_local_user(info);
-}
-
-
-/**********************************************************************
- * Functions for manipulating the MPIR_* global variables which
- * are accessed by parallel debuggers which trace slaunch.
- **********************************************************************/
-static void
-_mpir_init(int num_tasks)
-{
-	MPIR_proctable_size = num_tasks;
-	MPIR_proctable = xmalloc(sizeof(MPIR_PROCDESC) * num_tasks);
-	if (MPIR_proctable == NULL)
-		fatal("Unable to initialize MPIR_proctable: %m");
-}
-
-static void
-_mpir_cleanup()
-{
-	int i;
-
-	for (i = 0; i < MPIR_proctable_size; i++) {
-		xfree(MPIR_proctable[i].host_name);
-		xfree(MPIR_proctable[i].executable_name);
-	}
-	xfree(MPIR_proctable);
-}
-
-static void
-_mpir_set_executable_names(const char *executable_name)
-{
-	int i;
-
-	for (i = 0; i < MPIR_proctable_size; i++) {
-		MPIR_proctable[i].executable_name = xstrdup(executable_name);
-		if (MPIR_proctable[i].executable_name == NULL)
-			fatal("Unable to set MPI_proctable executable_name:"
-			      " %m");
-	}
-}
-
-static void
-_mpir_dump_proctable()
-{
-	MPIR_PROCDESC *tv;
-	int i;
-
-	for (i = 0; i < MPIR_proctable_size; i++) {
-		tv = &MPIR_proctable[i];
-		if (!tv)
-			break;
-		info("task:%d, host:%s, pid:%d, executable:%s",
-		     i, tv->host_name, tv->pid, tv->executable_name);
-	}
-}
-	
-static void _ignore_signal(int signo)
-{
-	/* do nothing */
-}
-
-static void _exit_on_signal(int signo)
-{
-	slurm_step_launch_abort(step_ctx);
-}
-
-/* Plugins must be able to resolve symbols.
- * Since slaunch statically links with src/api/libslurmhelper rather than
- * dynamicaly linking with libslurm, we need to reference all needed
- * symbols within slaunch. None of the functions below are actually
- * used, but we need to load the symbols. */
-static void _define_symbols(void)
-{
-	slurm_signal_job_step(0,0,0);	/* needed by mvapich and mpichgm */
-}
-
diff --git a/src/slaunch/slaunch.h b/src/slaunch/slaunch.h
deleted file mode 100644
index f7fd2ffb7861f1aa3d8968a5896ff9cbe6de198b..0000000000000000000000000000000000000000
--- a/src/slaunch/slaunch.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************************\
- *  src/slaunch/slaunch.h - header for external functions in slaunch.c
- *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifndef _HAVE_SLAUNCH_H
-#define _HAVE_SLAUNCH_H
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#endif /* !_HAVE_SLAUNCH_H */
diff --git a/src/slaunch/slaunch.wrapper.c b/src/slaunch/slaunch.wrapper.c
deleted file mode 100644
index 0c95e444ab371cf2f17e2ff52c7f07ff885e4191..0000000000000000000000000000000000000000
--- a/src/slaunch/slaunch.wrapper.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 
- * slaunch.wrapper.c - slaunch command wrapper for use with debuggers
- *	slaunch is the SLURM parallel application launcher
- *
- * For TotalView, a parallel job debugger from Etnus <http://www.etnus.com>
- *	Type "<ctrl-a>" to specify arguments for slaunch
- *	Type "g" to start the program
- *
- * Information for other debuggers may be submitted to slurm-dev@lists.llnl.gov
- */
-
-extern int slaunch(int argc, char **argv);
-
-int main(int argc, char **argv)
-{
-	return slaunch(argc, argv);
-}
diff --git a/src/slurmctld/Makefile.am b/src/slurmctld/Makefile.am
index ce5b031cc7f2bc1065c5491ea85add6af3026b14..34db68f904dd88f3e2ed031bda5b3f1c5b56ccbd 100644
--- a/src/slurmctld/Makefile.am
+++ b/src/slurmctld/Makefile.am
@@ -4,13 +4,13 @@
 AUTOMAKE_OPTIONS = foreign
 CLEANFILES = core.*
 
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS)
+INCLUDES = -I$(top_srcdir)
 
 sbin_PROGRAMS = slurmctld
 
 slurmctld_LDADD = 					\
-	$(top_builddir)/src/common/libcommon.la    	\
-	$(top_builddir)/src/common/libdaemonize.la
+	$(top_builddir)/src/common/libdaemonize.la  \
+	$(top_builddir)/src/common/libcommon.o -ldl
 
 
 slurmctld_SOURCES = 	\
@@ -20,6 +20,9 @@ slurmctld_SOURCES = 	\
 	controller.c 	\
 	job_mgr.c 	\
 	job_scheduler.c \
+	job_scheduler.h \
+	licenses.c	\
+	licenses.h	\
 	locks.c   	\
 	locks.h  	\
 	node_mgr.c 	\
@@ -44,8 +47,8 @@ slurmctld_SOURCES = 	\
 	trigger_mgr.c	\
 	trigger_mgr.h
 
-slurmctld_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) \
-			$(FEDERATION_LDFLAGS)	
+slurmctld_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+
 
 force:
 $(slurmctld_LDADD) : force
diff --git a/src/slurmctld/Makefile.in b/src/slurmctld/Makefile.in
index c438bcabe12e7a427d91fede39bd76202a631b9a..c76c5dba49703a07192518c9b0db5edbd5e57b71 100644
--- a/src/slurmctld/Makefile.in
+++ b/src/slurmctld/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -71,18 +73,19 @@ sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(sbin_PROGRAMS)
 am_slurmctld_OBJECTS = agent.$(OBJEXT) backup.$(OBJEXT) \
 	controller.$(OBJEXT) job_mgr.$(OBJEXT) job_scheduler.$(OBJEXT) \
-	locks.$(OBJEXT) node_mgr.$(OBJEXT) node_scheduler.$(OBJEXT) \
-	partition_mgr.$(OBJEXT) ping_nodes.$(OBJEXT) \
-	power_save.$(OBJEXT) proc_req.$(OBJEXT) read_config.$(OBJEXT) \
-	sched_plugin.$(OBJEXT) srun_comm.$(OBJEXT) \
-	state_save.$(OBJEXT) step_mgr.$(OBJEXT) trigger_mgr.$(OBJEXT)
+	licenses.$(OBJEXT) locks.$(OBJEXT) node_mgr.$(OBJEXT) \
+	node_scheduler.$(OBJEXT) partition_mgr.$(OBJEXT) \
+	ping_nodes.$(OBJEXT) power_save.$(OBJEXT) proc_req.$(OBJEXT) \
+	read_config.$(OBJEXT) sched_plugin.$(OBJEXT) \
+	srun_comm.$(OBJEXT) state_save.$(OBJEXT) step_mgr.$(OBJEXT) \
+	trigger_mgr.$(OBJEXT)
 slurmctld_OBJECTS = $(am_slurmctld_OBJECTS)
-slurmctld_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
-	$(top_builddir)/src/common/libdaemonize.la
+slurmctld_DEPENDENCIES = $(top_builddir)/src/common/libdaemonize.la \
+	$(top_builddir)/src/common/libcommon.o
 slurmctld_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(slurmctld_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -122,6 +125,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -135,10 +139,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -158,7 +165,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -169,6 +179,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -184,6 +196,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -199,6 +212,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -257,10 +271,10 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 CLEANFILES = core.*
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS)
+INCLUDES = -I$(top_srcdir)
 slurmctld_LDADD = \
-	$(top_builddir)/src/common/libcommon.la    	\
-	$(top_builddir)/src/common/libdaemonize.la
+	$(top_builddir)/src/common/libdaemonize.la  \
+	$(top_builddir)/src/common/libcommon.o -ldl
 
 slurmctld_SOURCES = \
 	agent.c  	\
@@ -269,6 +283,9 @@ slurmctld_SOURCES = \
 	controller.c 	\
 	job_mgr.c 	\
 	job_scheduler.c \
+	job_scheduler.h \
+	licenses.c	\
+	licenses.h	\
 	locks.c   	\
 	locks.h  	\
 	node_mgr.c 	\
@@ -293,9 +310,7 @@ slurmctld_SOURCES = \
 	trigger_mgr.c	\
 	trigger_mgr.h
 
-slurmctld_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) \
-			$(FEDERATION_LDFLAGS)	
-
+slurmctld_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -338,8 +353,8 @@ install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -372,6 +387,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/job_mgr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/job_scheduler.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/licenses.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/locks.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node_mgr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node_scheduler.Po@am__quote@
@@ -418,8 +434,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -431,8 +447,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -442,13 +458,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/slurmctld/agent.c b/src/slurmctld/agent.c
index fff8cc7f2ba8870cc94e391a34917064a0d1fe36..89f073d9b139c19ac0564e310d0c54e49f4c81e1 100644
--- a/src/slurmctld/agent.c
+++ b/src/slurmctld/agent.c
@@ -1,14 +1,13 @@
 /*****************************************************************************\
  *  agent.c - parallel background communication functions. This is where  
  *	logic could be placed for broadcast communications.
- *
- *  $Id: agent.c 12462 2007-10-08 17:42:47Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>, et. al.
  *  Derived from pdsh written by Jim Garlick <garlick1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -89,6 +88,7 @@
 #include "src/common/uid.h"
 #include "src/common/forward.h"
 #include "src/slurmctld/agent.h"
+#include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/ping_nodes.h"
 #include "src/slurmctld/slurmctld.h"
@@ -214,8 +214,10 @@ void *agent(void *args)
 	task_info_t *task_specific_ptr;
 	time_t begin_time;
 
-	/* info("I am here and agent_cnt is %d of %d with type %d", */
-/* 	     agent_cnt, MAX_AGENT_CNT, agent_arg_ptr->msg_type); */
+#if 0
+	info("Agent_cnt is %d of %d with msg_type %d",
+	     agent_cnt, MAX_AGENT_CNT, agent_arg_ptr->msg_type);
+#endif
 	slurm_mutex_lock(&agent_cnt_mutex);
 	while (slurmctld_config.shutdown_time == 0) {
 		if (agent_cnt < MAX_AGENT_CNT) {
@@ -321,13 +323,19 @@ void *agent(void *args)
 		xfree(agent_info_ptr);
 	}
 	slurm_mutex_lock(&agent_cnt_mutex);
+	
 	if (agent_cnt > 0)
 		agent_cnt--;
-	else
+	else {
 		error("agent_cnt underflow");
-	if (agent_cnt < MAX_AGENT_CNT)
-		agent_retry(RPC_RETRY_INTERVAL);
+		agent_cnt = 0;
+	}
+
+	if (agent_cnt && agent_cnt < MAX_AGENT_CNT) 
+		agent_retry(RPC_RETRY_INTERVAL, true);
+	
 	slurm_mutex_unlock(&agent_cnt_mutex);
+	
 	pthread_cond_broadcast(&agent_cnt_cond);
 
 	return NULL;
@@ -359,7 +367,6 @@ static agent_info_t *_make_agent_info(agent_arg_t *agent_arg_ptr)
 	thd_t *thread_ptr = NULL;
 	int *span = NULL;
 	int thr_count = 0;
-       	//forward_t forward;
 	hostlist_t hl = NULL;
 	char buf[8192];
 	char *name = NULL;
@@ -384,9 +391,15 @@ static agent_info_t *_make_agent_info(agent_arg_t *agent_arg_ptr)
 	&&  (agent_arg_ptr->msg_type != SRUN_NODE_FAIL)
 	&&  (agent_arg_ptr->msg_type != SRUN_USER_MSG)
 	&&  (agent_arg_ptr->msg_type != SRUN_JOB_COMPLETE)) {
+		/* Sending message to a possibly large number of slurmd.
+		 * Push all message forwarding to slurmd in order to 
+		 * offload as much work from slurmctld as possible. */
 		agent_info_ptr->get_reply = true;
-		span = set_span(agent_arg_ptr->node_count, 0);
+		span = set_span(agent_arg_ptr->node_count, 1); 
 	} else {
+		/* Message is going to one node (for srun) or we want 
+		 * it to get processed ASAP (SHUTDOWN or RECONFIGURE).
+		 * Send the message directly to each node. */
 		span = set_span(agent_arg_ptr->node_count, 
 				agent_arg_ptr->node_count);
 	}
@@ -411,7 +424,6 @@ static agent_info_t *_make_agent_info(agent_arg_t *agent_arg_ptr)
 			name = hostlist_shift(agent_arg_ptr->hostlist);
 			if(!name)
 				break;
-			/* info("adding %s", name); */
 			hostlist_push(hl, name);
 			free(name);
 			i++;
@@ -420,9 +432,9 @@ static agent_info_t *_make_agent_info(agent_arg_t *agent_arg_ptr)
 		hostlist_ranged_string(hl, sizeof(buf), buf);
 		hostlist_destroy(hl);
 		thread_ptr[thr_count].nodelist = xstrdup(buf);
-		
-		/* info("sending to nodes %s",  */
-/* 		     thread_ptr[thr_count].nodelist); */
+#if 0
+		info("sending to nodes %s", thread_ptr[thr_count].nodelist);
+#endif
 		thr_count++;		       
 	}
 	xfree(span);
@@ -669,6 +681,9 @@ static void _notify_slurmctld_nodes(agent_info_t *agent_ptr,
 					      thread_ptr[i].start_time);
 				break;
 			case DSH_FAILED:
+#ifdef HAVE_BG
+				error("Prolog/epilog failure");
+#else
 				if(!is_ret_list) {
 					set_node_down(thread_ptr[i].nodelist, 
 						      "Prolog/epilog failure");
@@ -676,6 +691,7 @@ static void _notify_slurmctld_nodes(agent_info_t *agent_ptr,
 				}
 				set_node_down(ret_data_info->node_name,
 					      "Prolog/epilog failure");
+#endif
 				break;
 			case DSH_DONE:
 				if(!is_ret_list) {
@@ -710,6 +726,7 @@ finished:	;
 		}
 	}
 	if ((agent_ptr->msg_type == REQUEST_PING) ||
+	    (agent_ptr->msg_type == REQUEST_HEALTH_CHECK) ||
 	    (agent_ptr->msg_type == REQUEST_NODE_REGISTRATION_STATUS))
 		ping_end();
 #else
@@ -806,17 +823,21 @@ static void *_thread_per_group_rpc(void *args)
 	slurm_msg_t_init(&msg);
 	msg.msg_type = msg_type;
 	msg.data     = task_ptr->msg_args_ptr;
-/* 	info("sending message type %u to %s", msg_type,
-	thread_ptr->nodelist); */
+#if 0
+ 	info("sending message type %u to %s", msg_type, thread_ptr->nodelist);
+#endif
 	if (task_ptr->get_reply) {
 		if(thread_ptr->addr) {
 			msg.address = *thread_ptr->addr;
+			
 			if(!(ret_list = slurm_send_addr_recv_msgs(
 				     &msg, thread_ptr->nodelist, 0))) {
 				error("_thread_per_group_rpc: "
 				      "no ret_list given");
 				goto cleanup;
 			}
+			
+			
 		} else {
 			if(!(ret_list = slurm_send_recv_msgs(
 				     thread_ptr->nodelist,
@@ -829,8 +850,10 @@ static void *_thread_per_group_rpc(void *args)
 		}
 	} else {
 		if(thread_ptr->addr) {
+			//info("got the address");
 			msg.address = *thread_ptr->addr;
 		} else {
+			//info("no address given");
 			if(slurm_conf_get_addr(thread_ptr->nodelist,
 					       &msg.address) == SLURM_ERROR) {
 				error("_thread_per_group_rpc: "
@@ -839,6 +862,7 @@ static void *_thread_per_group_rpc(void *args)
 				goto cleanup;
 			}
 		}
+		//info("sending %u to %s", msg_type, thread_ptr->nodelist);
 		if (slurm_send_only_node_msg(&msg) == SLURM_SUCCESS) {
 			thread_state = DSH_DONE;
 		} else {
@@ -1087,9 +1111,12 @@ static void _list_delete_retry(void *retry_entry)
  * agent_retry - Agent for retrying pending RPCs. One pending request is 
  *	issued if it has been pending for at least min_wait seconds
  * IN min_wait - Minimum wait time between re-issue of a pending RPC
+ * IN mai_too - Send pending email too, note this performed using a 
+ *	fork/waitpid, so it can take longer than just creating  a pthread 
+ *	to send RPCs
  * RET count of queued requests remaining
  */
-extern int agent_retry (int min_wait)
+extern int agent_retry (int min_wait, bool mail_too)
 {
 	int list_size = 0;
 	time_t now = time(NULL);
@@ -1165,11 +1192,11 @@ extern int agent_retry (int min_wait)
 	if (queued_req_ptr) {
 		agent_arg_ptr = queued_req_ptr->agent_arg_ptr;
 		xfree(queued_req_ptr);
-		if (agent_arg_ptr)
+		if (agent_arg_ptr) {
 			_spawn_retry_agent(agent_arg_ptr);
-		else
+		} else
 			error("agent_retry found record with no agent_args");
-	} else {
+	} else if (mail_too) {
 		mail_info_t *mi = NULL;
 		slurm_mutex_lock(&mail_mutex);
 		if (mail_list)
@@ -1178,7 +1205,7 @@ extern int agent_retry (int min_wait)
 		if (mi)
 			_mail_proc(mi);
 	}
-
+	
 	return list_size;
 }
 
@@ -1191,7 +1218,8 @@ void agent_queue_request(agent_arg_t *agent_arg_ptr)
 {
 	queued_request_t *queued_req_ptr = NULL;
 
-	if (agent_arg_ptr->msg_type == REQUEST_SHUTDOWN) { /* execute now */
+	if (agent_arg_ptr->msg_type == REQUEST_SHUTDOWN) {
+		/* execute now */
 		pthread_attr_t attr_agent;
 		pthread_t thread_agent;
 		int rc;
@@ -1215,6 +1243,7 @@ void agent_queue_request(agent_arg_t *agent_arg_ptr)
 /*	queued_req_ptr->last_attempt  = 0; Implicit */
 
 	slurm_mutex_lock(&retry_mutex);
+
 	if (retry_list == NULL) {
 		retry_list = list_create(_list_delete_retry);
 		if (retry_list == NULL)
@@ -1222,6 +1251,10 @@ void agent_queue_request(agent_arg_t *agent_arg_ptr)
 	}
 	list_append(retry_list, (void *)queued_req_ptr);
 	slurm_mutex_unlock(&retry_mutex);
+
+	/* now process the request in a separate pthread 
+	 * (if we can create another pthread to do so) */
+	agent_retry(999, false);
 }
 
 /* _spawn_retry_agent - pthread_create an agent for the given task */
diff --git a/src/slurmctld/agent.h b/src/slurmctld/agent.h
index 11f20f4106d8e9dc78bcec6fffd696ea879707d0..73c1de8840216789311d0bb1731527397d307b31 100644
--- a/src/slurmctld/agent.h
+++ b/src/slurmctld/agent.h
@@ -2,13 +2,13 @@
  *  agent.h - data structures and function definitions for parallel 
  *	background communications
  *
- *  $Id: agent.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: agent.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov>, et. al.
  *  Derived from dsh written by Jim Garlick <garlick1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -42,7 +42,6 @@
 #ifndef _AGENT_H
 #define _AGENT_H
 
-#include "src/slurmctld/agent.h"
 #include "src/slurmctld/slurmctld.h"
 
 #define AGENT_IS_THREAD  	 1	/* set if agent itself a thread of 
@@ -88,9 +87,12 @@ extern void agent_queue_request(agent_arg_t *agent_arg_ptr);
  * agent_retry - Agent for retrying pending RPCs. One pending request is 
  *	issued if it has been pending for at least min_wait seconds
  * IN min_wait - Minimum wait time between re-issue of a pending RPC
+ * IN mai_too - Send pending email too, note this performed using a 
+ *		fork/waitpid, so it can take longer than just creating 
+ *		a pthread to send RPCs
  * RET count of queued requests remaining
  */
-extern int agent_retry (int min_wait);
+extern int agent_retry (int min_wait, bool mail_too);
 
 /* agent_purge - purge all pending RPC requests */
 extern void agent_purge (void);
diff --git a/src/slurmctld/backup.c b/src/slurmctld/backup.c
index 7951426551e23c804096ddd90edaeff9ca473d29..82c1084b4e9bf6b2f1dd80543928cf1ed61cb027 100644
--- a/src/slurmctld/backup.c
+++ b/src/slurmctld/backup.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov>, Kevin Tew <tew1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -344,7 +344,7 @@ static int _background_process_msg(slurm_msg_t * msg)
 
 	if (msg->msg_type != REQUEST_PING) {
 		bool super_user = false;
-		uid_t uid = g_slurm_auth_get_uid(msg->auth_cred);
+		uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 		if ((uid == 0) || (uid == getuid()))
 			super_user = true;
 
diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c
index 0d6bce56bd96984e1decbd68c8a5d57aa523754d..0e8f00bad41f3087b1eed8c1ec8b782e03b5f037 100644
--- a/src/slurmctld/controller.c
+++ b/src/slurmctld/controller.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  controller.c - main control machine daemon for slurm
- *  $Id: controller.c 13506 2008-03-07 00:13:15Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>, Kevin Tew <tew1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -68,7 +68,8 @@
 #include "src/common/node_select.h"
 #include "src/common/pack.h"
 #include "src/common/read_config.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobacct_gather.h"
+#include "src/common/slurm_accounting_storage.h"
 #include "src/common/slurm_auth.h"
 #include "src/common/slurm_jobcomp.h"
 #include "src/common/slurm_protocol_api.h"
@@ -76,8 +77,11 @@
 #include "src/common/uid.h"
 #include "src/common/xsignal.h"
 #include "src/common/xstring.h"
+#include "src/common/assoc_mgr.h"
 
 #include "src/slurmctld/agent.h"
+#include "src/slurmctld/job_scheduler.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/ping_nodes.h"
 #include "src/slurmctld/proc_req.h"
@@ -121,6 +125,8 @@
  *    (640 bytes), it is really not lost.
  * The _keyvalue_regex_init() function will generate two blocks "definitely
  *    lost", both of size zero. We haven't bothered to address this.
+ * On some systems dlopen() will generate a small number of "definitely
+ *    lost" blocks that are not cleared by dlclose().
  * On some systems, pthread_create() will generated a small number of 
  *    "possibly lost" blocks.
  * Otherwise the report should be free of errors. Remember to reset 
@@ -134,6 +140,9 @@ log_options_t log_opts = LOG_OPTS_INITIALIZER;
 /* Global variables */
 slurmctld_config_t slurmctld_config;
 int bg_recover = DEFAULT_RECOVER;
+char *slurmctld_cluster_name = NULL; /* name of cluster */
+void *acct_db_conn = NULL;
+int accounting_enforce = 0;
 
 /* Local variables */
 static int	daemonize = DEFAULT_DAEMONIZE;
@@ -158,8 +167,8 @@ static int controller_sigarray[] = {
 
 static void         _default_sigaction(int sig);
 inline static void  _free_server_thread(void);
-static int          _gold_cluster_ready();
-static int          _gold_mark_all_nodes_down(char *reason, time_t event_time);
+static int          _accounting_cluster_ready();
+static int          _accounting_mark_all_nodes_down(char *reason);
 static void         _init_config(void);
 static void         _init_pidfile(void);
 static void         _kill_old_slurmctld(void);
@@ -181,9 +190,12 @@ typedef struct connection_arg {
 /* main - slurmctld main function, start various threads and process RPCs */
 int main(int argc, char *argv[])
 {
-	int error_code;
+	int cnt, error_code, i;
 	pthread_attr_t thread_attr;
 	struct stat stat_buf;
+	/* Locks: Write configuration, job, node, and partition */
+	slurmctld_lock_t config_write_lock = {
+		WRITE_LOCK, WRITE_LOCK, WRITE_LOCK, WRITE_LOCK };
 
 	/*
 	 * Establish initial configuration
@@ -222,6 +234,22 @@ int main(int argc, char *argv[])
 	if (stat(slurmctld_conf.mail_prog, &stat_buf) != 0)
 		error("Configured MailProg is invalid");
 
+	if (!strcmp(slurmctld_conf.accounting_storage_type, 
+		    "accounting_storage/none")) {
+		if (strcmp(slurmctld_conf.job_acct_gather_type, 
+			   "jobacct_gather/none"))
+			error("Job accounting information gathered, "
+			      "but not stored"); 
+	} else {
+		if (!strcmp(slurmctld_conf.job_acct_gather_type, 
+			    "jobacct_gather/none"))
+			info("Job accounting information stored, "
+			     "but details not gathered");
+	}
+
+	if (license_init(slurmctld_conf.licenses) != SLURM_SUCCESS)
+		fatal("Invalid Licenses value: %s", slurmctld_conf.licenses);
+
 #ifndef NDEBUG
 #  ifdef PR_SET_DUMPABLE
 	if (prctl(PR_SET_DUMPABLE, 1) < 0)
@@ -236,11 +264,11 @@ int main(int argc, char *argv[])
 		fatal("Unable to initialize StateSaveLocation");
 
 	if (daemonize) {
-		error_code = daemon(1, 1);
+		slurmctld_config.daemonize = 1;
+		if (daemon(1, 1))
+			error("daemon(): %m");
 		log_alter(log_opts, LOG_DAEMON, 
 			  slurmctld_conf.slurmctld_logfile);
-		if (error_code)
-			error("daemon error %d", error_code);
 		if (slurmctld_conf.slurmctld_logfile
 		&&  (slurmctld_conf.slurmctld_logfile[0] == '/')) {
 			char *slash_ptr, *work_dir;
@@ -259,8 +287,25 @@ int main(int argc, char *argv[])
 					slurmctld_conf.state_save_location);
 			}
 		}
+	} else {
+		slurmctld_config.daemonize = 0;
 	}
-	info("slurmctld version %s started", SLURM_VERSION);
+
+	/* This needs to be copied for other modules to access the
+	 * memory, it will report 'HashBase' if it is not duped
+	 */
+	slurmctld_cluster_name = xstrdup(slurmctld_conf.cluster_name);
+	accounting_enforce = slurmctld_conf.accounting_storage_enforce;
+	acct_db_conn = acct_storage_g_get_connection(true, false);
+	if (assoc_mgr_init(acct_db_conn, accounting_enforce) &&
+	    accounting_enforce) {
+		error("assoc_mgr_init failure");
+		fatal("slurmdbd and/or database must be up at "
+		      "slurmctld start time");
+	}
+
+	info("slurmctld version %s started on cluster %s",
+	     SLURM_VERSION, slurmctld_cluster_name);
 
 	if ((error_code = gethostname_short(node_name, MAX_SLURM_NAME)))
 		fatal("getnodename error %s", slurm_strerror(error_code));
@@ -268,8 +313,10 @@ int main(int argc, char *argv[])
 	/* init job credential stuff */
 	slurmctld_config.cred_ctx = slurm_cred_creator_ctx_create(
 			slurmctld_conf.job_credential_private_key);
-	if (!slurmctld_config.cred_ctx)
-		fatal("slurm_cred_creator_ctx_create: %m");
+	if (!slurmctld_config.cred_ctx) {
+		fatal("slurm_cred_creator_ctx_create(%s): %m",
+			slurmctld_conf.job_credential_private_key);
+	}
 
 
 	/* Not used in creator
@@ -290,7 +337,12 @@ int main(int argc, char *argv[])
 			SLURM_SUCCESS )
 		fatal( "failed to initialize checkpoint plugin" );
 	if (slurm_select_init() != SLURM_SUCCESS )
-		fatal( "failed to initialize node selection plugin state");
+		fatal( "failed to initialize node selection plugin");
+	if (slurm_acct_storage_init(NULL) != SLURM_SUCCESS )
+		fatal( "failed to initialize accounting_storage plugin");
+
+	if (slurm_jobacct_gather_init() != SLURM_SUCCESS )
+		fatal( "failed to initialize jobacct_gather plugin");
 
 	while (1) {
 		/* initialization for each primary<->backup switch */
@@ -311,43 +363,23 @@ int main(int argc, char *argv[])
 			if (switch_restore(slurmctld_conf.state_save_location,
 					   recover ? true : false))
 				fatal(" failed to initialize switch plugin" );
+			lock_slurmctld(config_write_lock);
 			if ((error_code = read_slurm_conf(recover))) {
 				fatal("read_slurm_conf reading %s: %s",
 					slurmctld_conf.slurm_conf,
 					slurm_strerror(error_code));
 			}
+			unlock_slurmctld(config_write_lock);
 			
-			if (recover == 0)
-				_gold_mark_all_nodes_down("cold-start",
-							  time(NULL));
-			else if (!stat("/tmp/slurm_gold_first", &stat_buf)) {
-				/* this is here for when slurm is
-				 * started with gold for the first
-				 * time to log any downed nodes.
-				 */
-				struct node_record *node_ptr =
-					node_record_table_ptr;
-				int i=0;
-				time_t event_time = time(NULL);
-				debug("found /tmp/slurm_gold_first, "
-				      "setting nodes down");
-				for (i = 0;
-				     i < node_record_count;
-				     i++, node_ptr++) {
-					if (node_ptr->name == '\0'
-					    || !node_ptr->reason)
-						continue;
-					
-					if(jobacct_g_node_down(
-						   node_ptr,
-						   event_time,
-						   node_ptr->reason)
-					   == SLURM_ERROR) 
-						break;
-				}
-				 if(unlink("/tmp/slurm_gold_first") < 0)
-					 error("Error deleting "
-					       "/tmp/slurm_gold_first");
+			if ((recover == 0) || 
+			    (!stat("/tmp/slurm_accounting_first", &stat_buf))) {
+				/* When first starting to write node state
+				 * information to Gold or SlurmDBD, create 
+				 * a file called "/tmp/slurm_accounting_first" to 
+				 * capture node initialization information */
+		   
+				_accounting_mark_all_nodes_down("cold-start");
+				 unlink("/tmp/slurm_accounting_first");
 			}
 		} else {
 			error("this host (%s) not valid controller (%s or %s)",
@@ -355,8 +387,20 @@ int main(int argc, char *argv[])
 				slurmctld_conf.backup_controller);
 			exit(0);
 		}
+
+		if(!acct_db_conn) {
+			acct_db_conn = 
+				acct_storage_g_get_connection(true, false);
+			if (assoc_mgr_init(acct_db_conn, accounting_enforce) &&
+			    accounting_enforce) {
+				error("assoc_mgr_init failure");
+				fatal("slurmdbd and/or database must be up at "
+				      "slurmctld start time");
+			}
+		}
+
 		info("Running as primary controller");
-		_gold_cluster_ready();
+		_accounting_cluster_ready();
 		if (slurm_sched_init() != SLURM_SUCCESS)
 			fatal("failed to initialize scheduling plugin");
 
@@ -368,9 +412,12 @@ int main(int argc, char *argv[])
 		slurm_mutex_unlock(&slurmctld_config.thread_count_lock);
 		slurm_attr_init(&thread_attr);
 		if (pthread_create(&slurmctld_config.thread_id_rpc, 
-				&thread_attr,_slurmctld_rpc_mgr, NULL))
+				&thread_attr, _slurmctld_rpc_mgr, NULL))
 			fatal("pthread_create error %m");
 		slurm_attr_destroy(&thread_attr);
+		clusteracct_storage_g_register_ctld(
+					slurmctld_conf.cluster_name, 
+					slurmctld_conf.slurmctld_port);
 
 		/*
 		 * create attached thread for signal handling
@@ -420,6 +467,10 @@ int main(int argc, char *argv[])
 		if (slurmctld_config.resume_backup == false)
 			break;
 		recover = 2;
+
+		/* Save any pending state save RPCs */
+		acct_storage_g_close_connection(&acct_db_conn);
+		assoc_mgr_fini();
 	}
 
 	/* Since pidfile is created as user root (its owner is
@@ -428,14 +479,10 @@ int main(int argc, char *argv[])
 	if (unlink(slurmctld_conf.slurmctld_pidfile) < 0)
 		verbose("Unable to remove pidfile '%s': %m",
 			slurmctld_conf.slurmctld_pidfile);
-
-	jobacct_g_fini_slurmctld();  /* Save pending message traffic */
-
+	
 #ifdef MEMORY_LEAK_DEBUG
-{
 	/* This should purge all allocated memory,   *\
 	\*   Anything left over represents a leak.   */
-	int i, cnt;
 
 	/* Give running agents a chance to complete and free memory.
 	 * Wait up to 30 seconds (3 seconds * 10) */
@@ -458,21 +505,38 @@ int main(int argc, char *argv[])
 	/* Plugins are needed to purge job/node data structures,
 	 * unplug after other data structures are purged */
 	g_slurm_jobcomp_fini();
+	slurm_acct_storage_fini();
+	slurm_jobacct_gather_fini();
 	slurm_sched_fini();
 	slurm_select_fini();
 	checkpoint_fini();
 	slurm_auth_fini();
 	switch_fini();
+	assoc_mgr_fini();
 
 	/* purge remaining data structures */
 	slurm_cred_ctx_destroy(slurmctld_config.cred_ctx);
+	slurm_crypto_fini();	/* must be after ctx_destroy */
 	slurm_conf_destroy();
 	slurm_api_clear_config();
 	sleep(2);
-}
+#else
+	/* Give REQUEST_SHUTDOWN a chance to get propagated, 
+	 * up to 3 seconds. */
+	for (i=0; i<3; i++) {
+		agent_purge();
+		cnt = get_agent_count();
+		if (cnt == 0)
+			break;
+		sleep(1);
+	}
 #endif
 
-	info("Slurmctld shutdown completing");
+	xfree(slurmctld_cluster_name);
+	if (cnt) {
+		info("Slurmctld shutdown completing with %d active agent "
+			"threads\n\n", cnt);
+	}
 	log_fini();
 	
 	if (dump_core)
@@ -507,6 +571,7 @@ static void  _init_config(void)
 		(void) setrlimit(RLIMIT_DATA, &rlim);
 	}
 
+	slurmctld_config.boot_time      = time(NULL);
 	slurmctld_config.daemonize      = DEFAULT_DAEMONIZE;
 	slurmctld_config.resume_backup  = false;
 	slurmctld_config.server_thread_count = 0;
@@ -525,6 +590,35 @@ static void  _init_config(void)
 #endif
 }
 
+/* Read configuration file.
+ * Same name as API function for use in accounting_storage plugin */
+extern int slurm_reconfigure(void)
+{
+	/* Locks: Write configuration, job, node, and partition */
+	slurmctld_lock_t config_write_lock = { 
+		WRITE_LOCK, WRITE_LOCK, WRITE_LOCK, WRITE_LOCK };
+	int rc;
+
+	/*
+	 * XXX - need to shut down the scheduler
+	 * plugin, re-read the configuration, and then
+	 * restart the (possibly new) plugin.
+	 */
+	lock_slurmctld(config_write_lock);
+	rc = read_slurm_conf(0);
+	if (rc)
+		error("read_slurm_conf: %s", slurm_strerror(rc));
+	else {
+		_update_cred_key();
+		set_slurmctld_state_loc();
+	}
+	unlock_slurmctld(config_write_lock);
+	trigger_reconfig();
+	slurm_sched_partition_change();	/* notify sched plugin */
+	select_g_reconfigure();		/* notify select plugin too */
+	return rc;
+}
+
 /* _slurmctld_signal_hand - Process daemon-wide signals */
 static void *_slurmctld_signal_hand(void *no_data)
 {
@@ -535,9 +629,6 @@ static void *_slurmctld_signal_hand(void *no_data)
 	/* Locks: Read configuration */
 	slurmctld_lock_t config_read_lock = { 
 		READ_LOCK, NO_LOCK, NO_LOCK, NO_LOCK };
-	/* Locks: Write configuration, job, node, and partition */
-	slurmctld_lock_t config_write_lock = { 
-		WRITE_LOCK, WRITE_LOCK, WRITE_LOCK, WRITE_LOCK };
 
 	(void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
 	(void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
@@ -571,23 +662,7 @@ static void *_slurmctld_signal_hand(void *no_data)
 			break;
 		case SIGHUP:	/* kill -1 */
 			info("Reconfigure signal (SIGHUP) received");
-			/*
-			 * XXX - need to shut down the scheduler
-			 * plugin, re-read the configuration, and then
-			 * restart the (possibly new) plugin.
-			 */
-			lock_slurmctld(config_write_lock);
-			rc = read_slurm_conf(0);
-			if (rc)
-				error("read_slurm_conf: %s",
-				      slurm_strerror(rc));
-			else {
-				_update_cred_key();
-				set_slurmctld_state_loc();
-			}
-			unlock_slurmctld(config_write_lock);
-			trigger_reconfig();
-			slurm_sched_partition_change();
+			slurm_reconfigure();
 			break;
 		case SIGABRT:	/* abort */
 			info("SIGABRT received");
@@ -805,7 +880,7 @@ static void _free_server_thread(void)
 	pthread_cond_broadcast(&server_thread_cond);
 }
 
-static int _gold_cluster_ready()
+static int _accounting_cluster_ready()
 {
 	uint32_t procs = 0;
 	struct node_record *node_ptr;
@@ -827,34 +902,47 @@ static int _gold_cluster_ready()
 #endif
 	}
 
-	rc = jobacct_g_cluster_procs(procs, event_time);
+	rc = clusteracct_storage_g_cluster_procs(acct_db_conn,
+						 slurmctld_cluster_name,
+						 procs, event_time);
 
 	return rc;
 }
 
-static int _gold_mark_all_nodes_down(char *reason, time_t event_time)
+static int _accounting_mark_all_nodes_down(char *reason)
 {
 	char *state_file;
 	struct stat stat_buf;
 	struct node_record *node_ptr;
 	int i;
+	time_t event_time;
 	int rc = SLURM_ERROR;
 
 	state_file = xstrdup (slurmctld_conf.state_save_location);
 	xstrcat (state_file, "/node_state");
 	if (stat(state_file, &stat_buf)) {
-		debug("_gold_mark_all_nodes_down: could not stat(%s) "
+		debug("_accounting_mark_all_nodes_down: could not stat(%s) "
 		      "to record node down time", state_file);
-		xfree(state_file);
-		return rc;
+		event_time = time(NULL);
+	} else {
+		event_time = stat_buf.st_mtime;
 	}
 	xfree(state_file);
 
+	if((rc = acct_storage_g_flush_jobs_on_cluster(acct_db_conn,
+						      slurmctld_cluster_name,
+						      event_time))
+	   == SLURM_ERROR)
+		return rc;
+
 	node_ptr = node_record_table_ptr;
 	for (i = 0; i < node_record_count; i++, node_ptr++) {
 		if (node_ptr->name == '\0')
 			continue;
-		if((rc = jobacct_g_node_down(node_ptr, event_time, reason))
+		if((rc = clusteracct_storage_g_node_down(acct_db_conn,
+							 slurmctld_cluster_name,
+							 node_ptr, event_time,
+							 reason))
 		   == SLURM_ERROR) 
 			break;
 	}
@@ -947,9 +1035,10 @@ static void *_slurmctld_background(void *no_data)
 
 		if (difftime(now, last_timelimit_time) >= PERIODIC_TIMEOUT) {
 			last_timelimit_time = now;
-			debug2("Performing job time limit check");
+			debug2("Performing job time limit and checkpoint test");
 			lock_slurmctld(job_write_lock);
 			job_time_limit();
+			step_checkpoint();
 			unlock_slurmctld(job_write_lock);
 		}
 
@@ -978,8 +1067,8 @@ static void *_slurmctld_background(void *no_data)
 			unlock_slurmctld(job_read_lock);
 		}
 
-		/* Process pending agent work */
-		agent_retry(RPC_RETRY_INTERVAL);
+		/* Process any pending agent work */
+		agent_retry(RPC_RETRY_INTERVAL, true);
 
 		if (difftime(now, last_group_time) >= PERIODIC_GROUP_CHECK) {
 			last_group_time = now;
@@ -1020,7 +1109,7 @@ static void *_slurmctld_background(void *no_data)
 			 * or reconfigured nodes */
 			last_node_acct = now;
 			lock_slurmctld(node_read_lock);
-			_gold_cluster_ready();
+			_accounting_cluster_ready();
 			unlock_slurmctld(node_read_lock);
 		}
 		/* Reassert this machine as the primary controller.
diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index 64a03b2f0e77a74e7c271236d053b610925d03bc..918c053e2805278b713cb97e895c9afd3319fa24 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -3,12 +3,13 @@
  *	Note: there is a global job list (job_list), time stamp 
  *	(last_job_update), and hash table (job_hash)
  *
- *  $Id: job_mgr.c 13871 2008-04-15 15:47:33Z jette $
+ *  $Id: job_mgr.c 14154 2008-05-29 17:51:52Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -51,24 +52,28 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/stat.h>
 
 #include <slurm/slurm_errno.h>
 
 #include "src/api/job_info.h"
 #include "src/common/bitstring.h"
+#include "src/common/forward.h"
 #include "src/common/hostlist.h"
 #include "src/common/node_select.h"
 #include "src/common/parse_time.h"
+#include "src/common/slurm_accounting_storage.h"
 #include "src/common/slurm_jobcomp.h"
+#include "src/common/slurm_protocol_pack.h"
 #include "src/common/switch.h"
 #include "src/common/xassert.h"
 #include "src/common/xstring.h"
-#include "src/common/forward.h"
-#include "src/common/slurm_jobacct.h"
-#include "src/common/slurm_protocol_pack.h"
+#include "src/common/assoc_mgr.h"
 
 #include "src/slurmctld/agent.h"
+#include "src/slurmctld/job_scheduler.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/node_scheduler.h"
 #include "src/slurmctld/proc_req.h"
@@ -79,7 +84,6 @@
 
 #define DETAILS_FLAG 0xdddd
 #define MAX_RETRIES  10
-#define MAX_STR_LEN  1024
 #define SLURM_CREATE_JOB_FLAG_NO_ALLOCATE_0 0
 #define STEP_FLAG 0xbbbb
 #define TOP_PRIORITY 0xffff0000	/* large, but leave headroom for higher */
@@ -87,7 +91,7 @@
 #define JOB_HASH_INX(_job_id)	(_job_id % hash_table_size)
 
 /* Change JOB_STATE_VERSION value when changing the state save format */
-#define JOB_STATE_VERSION      "VER005"
+#define JOB_STATE_VERSION      "VER006"
 
 /* Global variables */
 List   job_list = NULL;		/* job_record list */
@@ -99,6 +103,8 @@ static int      hash_table_size = 0;
 static int      job_count = 0;		/* job's in the system */
 static uint32_t job_id_sequence = 0;	/* first job_id to assign new job */
 static struct   job_record **job_hash = NULL;
+static bool     wiki_sched = false;
+static bool     wiki_sched_test = false;
 
 /* Local functions */
 static void _add_job_hash(struct job_record *job_ptr);
@@ -134,7 +140,7 @@ static void _pack_pending_job_details(struct job_details *detail_ptr,
 static int  _purge_job_record(uint32_t job_id);
 static void _purge_lost_batch_jobs(int node_inx, time_t now);
 static void _read_data_array_from_file(char *file_name, char ***data,
-				       uint16_t * size);
+				       uint32_t * size);
 static void _read_data_from_file(char *file_name, char **data);
 static void _remove_defunct_batch_dirs(List batch_dirs);
 static int  _reset_detail_bitmaps(struct job_record *job_ptr);
@@ -147,13 +153,16 @@ static void _signal_job(struct job_record *job_ptr, int signal);
 static void _suspend_job(struct job_record *job_ptr, uint16_t op);
 static int  _suspend_job_nodes(struct job_record *job_ptr);
 static bool _top_priority(struct job_record *job_ptr);
+static bool _validate_acct_policy(job_desc_msg_t *job_desc,
+				  struct part_record *part_ptr,
+				  acct_association_rec_t *assoc_ptr);
 static int  _validate_job_create_req(job_desc_msg_t * job_desc);
 static int  _validate_job_desc(job_desc_msg_t * job_desc_msg, int allocate,
 			       uid_t submit_uid);
 static void _validate_job_files(List batch_dirs);
 static int  _write_data_to_file(char *file_name, char *data);
 static int  _write_data_array_to_file(char *file_name, char **data,
-				      uint16_t size);
+				      uint32_t size);
 static void _xmit_new_end_time(struct job_record *job_ptr);
 
 /* 
@@ -229,6 +238,11 @@ void delete_job_details(struct job_record *job_entry)
 	xfree(job_entry->details->out);
 	xfree(job_entry->details->work_dir);
 	xfree(job_entry->details->mc_ptr);
+	if (job_entry->details->feature_list)
+		list_destroy(job_entry->details->feature_list);
+	xfree(job_entry->details->dependency);
+	if (job_entry->details->depend_list)
+		list_destroy(job_entry->details->depend_list);
 	xfree(job_entry->details);
 }
 
@@ -355,7 +369,7 @@ int dump_all_job_state(void)
  *	checkpoint. Execute this after loading the configuration file data.
  * RET 0 or error code
  */
-int load_all_job_state(void)
+extern int load_all_job_state(void)
 {
 	int data_allocated, data_read = 0, error_code = 0;
 	uint32_t data_size = 0;
@@ -365,7 +379,7 @@ int load_all_job_state(void)
 	time_t buf_time;
 	uint32_t saved_job_id;
 	char *ver_str = NULL;
-	uint16_t ver_str_len;
+	uint32_t ver_str_len;
 
 	/* read the file */
 	state_file = xstrdup(slurmctld_conf.state_save_location);
@@ -405,30 +419,9 @@ int load_all_job_state(void)
 
 	buffer = create_buf(data, data_size);
 
-        /*
-         * The old header of the "job_state" file simply contained a
-         * timestamp, while the new header contains a "VERXXX" at the
-         * beginning (VER001, VER002, etc), a timestamp, and the last
-         * job id. To determine if we're looking at an old header or
-         * new header, we first check if the file begins with "VER".
-         *
-         * Each field is preceeded by two bytes which contains the field
-         * size.  Since we are bypassing the "pack" functions in order
-         * see if the header contains a "VERXXX" string, we need to make
-         * sure that there is enough data in the buffer to compare against.
-         */
-	if (size_buf(buffer) >= sizeof(uint16_t) + strlen(JOB_STATE_VERSION))
-	{
-	        char *ptr = get_buf_data(buffer);
-
-	        if (memcmp(&ptr[sizeof(uint16_t)], JOB_STATE_VERSION, 3) == 0)
-		{
-		        safe_unpackstr_xmalloc(&ver_str, &ver_str_len, buffer);
-		        debug3("Version string in job_state header is %s",
-			       ver_str);
-		}
-	}
-	if (ver_str && (strcmp(ver_str, JOB_STATE_VERSION) != 0)) {
+	safe_unpackstr_xmalloc(&ver_str, &ver_str_len, buffer);
+	debug3("Version string in job_state header is %s", ver_str);
+	if ((!ver_str) || strcmp(ver_str, JOB_STATE_VERSION) != 0) {
 		error("***********************************************");
 		error("Can not recover job state, incompatable version");
 		error("***********************************************");
@@ -476,33 +469,38 @@ static void _dump_job_state(struct job_record *dump_job_ptr, Buf buffer)
 	struct step_record *step_ptr;
 
 	/* Dump basic job info */
+	pack32(dump_job_ptr->assoc_id, buffer);
 	pack32(dump_job_ptr->job_id, buffer);
 	pack32(dump_job_ptr->user_id, buffer);
 	pack32(dump_job_ptr->group_id, buffer);
 	pack32(dump_job_ptr->time_limit, buffer);
 	pack32(dump_job_ptr->priority, buffer);
 	pack32(dump_job_ptr->alloc_sid, buffer);
-	pack32(dump_job_ptr->dependency, buffer);
 	pack32(dump_job_ptr->num_procs, buffer);
+	pack32(dump_job_ptr->total_procs, buffer);
 	pack32(dump_job_ptr->exit_code, buffer);
+	pack32(dump_job_ptr->db_index, buffer);
+	pack32(dump_job_ptr->assoc_id, buffer);
 
 	pack_time(dump_job_ptr->start_time, buffer);
 	pack_time(dump_job_ptr->end_time, buffer);
 	pack_time(dump_job_ptr->suspend_time, buffer);
 	pack_time(dump_job_ptr->pre_sus_time, buffer);
+	pack_time(dump_job_ptr->tot_sus_time, buffer);
 
 	pack16(dump_job_ptr->job_state, buffer);
 	pack16(dump_job_ptr->next_step_id, buffer);
 	pack16(dump_job_ptr->kill_on_node_fail, buffer);
 	pack16(dump_job_ptr->kill_on_step_done, buffer);
 	pack16(dump_job_ptr->batch_flag, buffer);
-	pack16(dump_job_ptr->alloc_resp_port, buffer);
-	pack16(dump_job_ptr->other_port, buffer);
 	pack16(dump_job_ptr->mail_type, buffer);
+	pack16(dump_job_ptr->qos, buffer);
 	pack16(dump_job_ptr->state_reason, buffer);
 
-	packstr(dump_job_ptr->alloc_resp_host, buffer);
-	packstr(dump_job_ptr->other_host, buffer);
+	packstr(dump_job_ptr->resp_host, buffer);
+	pack16(dump_job_ptr->alloc_resp_port, buffer);
+	pack16(dump_job_ptr->other_port, buffer);
+
 	if (dump_job_ptr->job_state & JOB_COMPLETING) {
 		if (dump_job_ptr->nodes_completing == NULL) {
 			dump_job_ptr->nodes_completing =
@@ -518,6 +516,7 @@ static void _dump_job_state(struct job_record *dump_job_ptr, Buf buffer)
 	packstr(dump_job_ptr->account, buffer);
 	packstr(dump_job_ptr->comment, buffer);
 	packstr(dump_job_ptr->network, buffer);
+	packstr(dump_job_ptr->licenses, buffer);
 	packstr(dump_job_ptr->mail_user, buffer);
 
 	select_g_pack_jobinfo(dump_job_ptr->select_jobinfo,
@@ -547,47 +546,53 @@ static void _dump_job_state(struct job_record *dump_job_ptr, Buf buffer)
 static int _load_job_state(Buf buffer)
 {
 	uint32_t job_id, user_id, group_id, time_limit, priority, alloc_sid;
-	uint32_t dependency, exit_code, num_procs;
-	time_t start_time, end_time, suspend_time, pre_sus_time;
+	uint32_t exit_code, num_procs, assoc_id, db_index, name_len,
+		total_procs;
+	time_t start_time, end_time, suspend_time, pre_sus_time, tot_sus_time;
 	uint16_t job_state, next_step_id, details, batch_flag, step_flag;
-	uint16_t kill_on_node_fail, kill_on_step_done, name_len;
+	uint16_t kill_on_node_fail, kill_on_step_done, qos;
 	uint16_t alloc_resp_port, other_port, mail_type, state_reason;
-	char *nodes = NULL, *partition = NULL, *name = NULL;
-	char *alloc_node = NULL, *alloc_resp_host = NULL, *other_host = NULL;
+	char *nodes = NULL, *partition = NULL, *name = NULL, *resp_host = NULL;
 	char *account = NULL, *network = NULL, *mail_user = NULL;
-	char *comment = NULL, *nodes_completing = NULL;
+	char *comment = NULL, *nodes_completing = NULL, *alloc_node = NULL;
+	char *licenses = NULL;
 	struct job_record *job_ptr;
 	struct part_record *part_ptr;
 	int error_code;
 	select_jobinfo_t select_jobinfo = NULL;
 
+	safe_unpack32(&assoc_id, buffer);
 	safe_unpack32(&job_id, buffer);
 	safe_unpack32(&user_id, buffer);
 	safe_unpack32(&group_id, buffer);
 	safe_unpack32(&time_limit, buffer);
 	safe_unpack32(&priority, buffer);
 	safe_unpack32(&alloc_sid, buffer);
-	safe_unpack32(&dependency, buffer);
 	safe_unpack32(&num_procs, buffer);
+	safe_unpack32(&total_procs, buffer);
 	safe_unpack32(&exit_code, buffer);
+	safe_unpack32(&db_index, buffer);
+	safe_unpack32(&assoc_id, buffer);
 
 	safe_unpack_time(&start_time, buffer);
 	safe_unpack_time(&end_time, buffer);
 	safe_unpack_time(&suspend_time, buffer);
 	safe_unpack_time(&pre_sus_time, buffer);
+	safe_unpack_time(&tot_sus_time, buffer);
 
 	safe_unpack16(&job_state, buffer);
 	safe_unpack16(&next_step_id, buffer);
 	safe_unpack16(&kill_on_node_fail, buffer);
 	safe_unpack16(&kill_on_step_done, buffer);
 	safe_unpack16(&batch_flag, buffer);
-	safe_unpack16(&alloc_resp_port, buffer);
-	safe_unpack16(&other_port, buffer);
 	safe_unpack16(&mail_type, buffer);
+	safe_unpack16(&qos, buffer);
 	safe_unpack16(&state_reason, buffer);
 
-	safe_unpackstr_xmalloc(&alloc_resp_host, &name_len, buffer);
-	safe_unpackstr_xmalloc(&other_host, &name_len, buffer);
+	safe_unpackstr_xmalloc(&resp_host, &name_len, buffer);
+	safe_unpack16(&alloc_resp_port, buffer);
+	safe_unpack16(&other_port, buffer);
+
 	if (job_state & JOB_COMPLETING) {
 		safe_unpackstr_xmalloc(&nodes_completing, 
 				       &name_len, buffer);
@@ -599,6 +604,7 @@ static int _load_job_state(Buf buffer)
 	safe_unpackstr_xmalloc(&account, &name_len, buffer);
 	safe_unpackstr_xmalloc(&comment, &name_len, buffer);
 	safe_unpackstr_xmalloc(&network, &name_len, buffer);
+	safe_unpackstr_xmalloc(&licenses, &name_len, buffer);
 	safe_unpackstr_xmalloc(&mail_user, &name_len, buffer);
 
 	if (select_g_alloc_jobinfo(&select_jobinfo)
@@ -627,6 +633,10 @@ static int _load_job_state(Buf buffer)
 		      job_id, kill_on_node_fail);
 		goto unpack_error;
 	}
+	if (partition == NULL) {
+		error("No partition for job %u", job_id);
+		goto unpack_error;
+	}
 	part_ptr = find_part_record (partition);
 	if (part_ptr == NULL) {
 		verbose("Invalid partition (%s) for job_id %u", 
@@ -662,59 +672,69 @@ static int _load_job_state(Buf buffer)
 		goto unpack_error;
 	}
 
-	job_ptr->user_id      = user_id;
-	job_ptr->group_id     = group_id;
-	job_ptr->time_limit   = time_limit;
-	job_ptr->priority     = priority;
+	xfree(job_ptr->account);
+	job_ptr->account = account;
+	account          = NULL;  /* reused, nothing left to free */
+	xfree(job_ptr->alloc_node);
+	job_ptr->alloc_node   = alloc_node;
+	alloc_node             = NULL;	/* reused, nothing left to free */
+	job_ptr->alloc_resp_port = alloc_resp_port;
 	job_ptr->alloc_sid    = alloc_sid;
-	job_ptr->start_time   = start_time;
+	job_ptr->assoc_id     = assoc_id;
+	job_ptr->batch_flag   = batch_flag;
+	xfree(job_ptr->comment);
+	job_ptr->comment      = comment;
+	comment               = NULL;  /* reused, nothing left to free */
+	job_ptr->db_index     = db_index;
 	job_ptr->end_time     = end_time;
-	job_ptr->suspend_time = suspend_time;
-	job_ptr->pre_sus_time = pre_sus_time;
+	job_ptr->exit_code    = exit_code;
+	job_ptr->group_id     = group_id;
 	job_ptr->job_state    = job_state;
+	job_ptr->kill_on_node_fail = kill_on_node_fail;
+	job_ptr->kill_on_step_done = kill_on_step_done;
+	xfree(job_ptr->licenses);
+	job_ptr->licenses     = licenses;
+	licenses              = NULL;	/* reused, nothing left to free */
+	job_ptr->mail_type    = mail_type;
+	xfree(job_ptr->mail_user);
+	job_ptr->mail_user    = mail_user;
+	mail_user             = NULL;	/* reused, nothing left to free */
+	xfree(job_ptr->name);		/* in case duplicate record */
+	job_ptr->name         = name;
+	name                  = NULL;	/* reused, nothing left to free */
+	xfree(job_ptr->network);
+	job_ptr->network      = network;
+	network               = NULL;  /* reused, nothing left to free */
 	job_ptr->next_step_id = next_step_id;
-	job_ptr->dependency   = dependency;
-	job_ptr->exit_code    = exit_code;
-	job_ptr->state_reason = state_reason;
-	job_ptr->num_procs    = num_procs;
-	job_ptr->time_last_active = time(NULL);
-	strncpy(job_ptr->name, name, MAX_JOBNAME_LEN);
-	xfree(name);
-	xfree(job_ptr->nodes);
-	job_ptr->nodes  = nodes;
-	nodes           = NULL;	/* reused, nothing left to free */
+	xfree(job_ptr->nodes);		/* in case duplicate record */
+	job_ptr->nodes        = nodes;
+	nodes                 = NULL;	/* reused, nothing left to free */
 	if (nodes_completing) {
 		xfree(job_ptr->nodes_completing);
 		job_ptr->nodes_completing = nodes_completing;
 		nodes_completing = NULL;  /* reused, nothing left to free */
 	}
-	xfree(job_ptr->alloc_node);
-	job_ptr->alloc_node = alloc_node;
-	alloc_node          = NULL;	/* reused, nothing left to free */
-	strncpy(job_ptr->partition, partition, MAX_SLURM_NAME);
-	xfree(partition);
-	job_ptr->account = account;
-	account          = NULL;  /* reused, nothing left to free */
-	job_ptr->comment = comment;
-	comment          = NULL;  /* reused, nothing left to free */
-	job_ptr->network = network;
-	network          = NULL;  /* reused, nothing left to free */
+	job_ptr->num_procs    = num_procs;
+	job_ptr->other_port   = other_port;
+	xfree(job_ptr->partition);
+	job_ptr->partition    = partition;
+	partition             = NULL;	/* reused, nothing left to free */
 	job_ptr->part_ptr = part_ptr;
-	job_ptr->kill_on_node_fail = kill_on_node_fail;
-	job_ptr->kill_on_step_done = kill_on_step_done;
-	job_ptr->batch_flag        = batch_flag;
-	job_ptr->alloc_resp_port   = alloc_resp_port;
-	job_ptr->alloc_resp_host   = alloc_resp_host;
-	job_ptr->other_port        = other_port;
-	job_ptr->other_host        = other_host;
-	job_ptr->mail_type         = mail_type;
-	job_ptr->mail_user         = mail_user;
-	mail_user = NULL;	/* reused, nothing left to free */
+	job_ptr->pre_sus_time = pre_sus_time;
+	job_ptr->priority     = priority;
+	job_ptr->qos          = qos;
+	xfree(job_ptr->resp_host);
+	job_ptr->resp_host    = resp_host;
+	resp_host             = NULL;	/* reused, nothing left to free */
 	job_ptr->select_jobinfo = select_jobinfo;
-
-	build_node_details(job_ptr);	/* set: num_cpu_groups, cpus_per_node, 
-					 *	cpu_count_reps, node_cnt, and
-					 *	node_addr */
+	job_ptr->start_time   = start_time;
+	job_ptr->state_reason = state_reason;
+	job_ptr->suspend_time = suspend_time;
+	job_ptr->time_last_active = time(NULL);
+	job_ptr->time_limit   = time_limit;
+	job_ptr->total_procs  = total_procs;
+	job_ptr->tot_sus_time = tot_sus_time;
+	job_ptr->user_id      = user_id;
 	info("recovered job id %u", job_id);
 
 	safe_unpack16(&step_flag, buffer);
@@ -724,12 +744,13 @@ static int _load_job_state(Buf buffer)
 		safe_unpack16(&step_flag, buffer);
 	}
 
+	build_node_details(job_ptr);	/* set: num_cpu_groups, cpus_per_node,
+					 *  cpu_count_reps, node_cnt,
+					 *  node_addr, alloc_lps, used_lps */
 	return SLURM_SUCCESS;
 
 unpack_error:
 	error("Incomplete job record");
-	xfree(alloc_resp_host);
-	xfree(other_host);
 	xfree(nodes);
 	xfree(nodes_completing);
 	xfree(partition);
@@ -737,6 +758,8 @@ unpack_error:
 	xfree(alloc_node);
 	xfree(account);
 	xfree(comment);
+	xfree(resp_host);
+	xfree(licenses);
 	xfree(mail_user);
 	select_g_free_jobinfo(&select_jobinfo);
 	return SLURM_FAILURE;
@@ -752,26 +775,28 @@ void _dump_job_details(struct job_details *detail_ptr, Buf buffer)
 {
 	pack32(detail_ptr->min_nodes, buffer);
 	pack32(detail_ptr->max_nodes, buffer);
-	pack32(detail_ptr->total_procs, buffer);
 	pack32(detail_ptr->num_tasks, buffer);
 
 	pack16(detail_ptr->shared, buffer);
 	pack16(detail_ptr->contiguous, buffer);
 	pack16(detail_ptr->cpus_per_task, buffer);
 	pack16(detail_ptr->ntasks_per_node, buffer);
-	pack16(detail_ptr->no_requeue, buffer);
-	pack16(detail_ptr->overcommit, buffer);
+	pack16(detail_ptr->requeue, buffer);
+	pack16(detail_ptr->acctg_freq, buffer);
+
+	pack8(detail_ptr->open_mode, buffer);
+	pack8(detail_ptr->overcommit, buffer);
 
 	pack32(detail_ptr->job_min_procs, buffer);
 	pack32(detail_ptr->job_min_memory, buffer);
-	pack32(detail_ptr->job_max_memory, buffer);
 	pack32(detail_ptr->job_min_tmp_disk, buffer);
 	pack_time(detail_ptr->begin_time, buffer);
 	pack_time(detail_ptr->submit_time, buffer);
 
-	packstr(detail_ptr->req_nodes, buffer);
-	packstr(detail_ptr->exc_nodes, buffer);
-	packstr(detail_ptr->features,  buffer);
+	packstr(detail_ptr->req_nodes,  buffer);
+	packstr(detail_ptr->exc_nodes,  buffer);
+	packstr(detail_ptr->features,   buffer);
+	packstr(detail_ptr->dependency, buffer);
 
 	packstr(detail_ptr->err,       buffer);
 	packstr(detail_ptr->in,        buffer);
@@ -786,14 +811,16 @@ void _dump_job_details(struct job_details *detail_ptr, Buf buffer)
 static int _load_job_details(struct job_record *job_ptr, Buf buffer)
 {
 	char *req_nodes = NULL, *exc_nodes = NULL, *features = NULL;
+	char *dependency = NULL;
 	char *err = NULL, *in = NULL, *out = NULL, *work_dir = NULL;
 	char **argv = (char **) NULL;
 	uint32_t min_nodes, max_nodes;
-	uint32_t job_min_procs, total_procs;
-	uint32_t job_min_memory, job_max_memory, job_min_tmp_disk;
-	uint32_t num_tasks;
-	uint16_t argc = 0, shared, contiguous, ntasks_per_node;
-	uint16_t cpus_per_task, name_len, no_requeue, overcommit;
+	uint32_t job_min_procs;
+	uint32_t job_min_memory, job_min_tmp_disk;
+	uint32_t num_tasks, name_len, argc = 0;
+	uint16_t shared, contiguous, ntasks_per_node;
+	uint16_t acctg_freq, cpus_per_task, requeue;
+	uint8_t open_mode, overcommit;
 	time_t begin_time, submit_time;
 	int i;
 	multi_core_data_t *mc_ptr;
@@ -801,26 +828,28 @@ static int _load_job_details(struct job_record *job_ptr, Buf buffer)
 	/* unpack the job's details from the buffer */
 	safe_unpack32(&min_nodes, buffer);
 	safe_unpack32(&max_nodes, buffer);
-	safe_unpack32(&total_procs, buffer);
 	safe_unpack32(&num_tasks, buffer);
 
 	safe_unpack16(&shared, buffer);
 	safe_unpack16(&contiguous, buffer);
 	safe_unpack16(&cpus_per_task, buffer);
 	safe_unpack16(&ntasks_per_node, buffer);
-	safe_unpack16(&no_requeue, buffer);
-	safe_unpack16(&overcommit, buffer);
+	safe_unpack16(&requeue, buffer);
+	safe_unpack16(&acctg_freq, buffer);
+
+	safe_unpack8(&open_mode, buffer);
+	safe_unpack8(&overcommit, buffer);
 
 	safe_unpack32(&job_min_procs, buffer);
 	safe_unpack32(&job_min_memory, buffer);
-	safe_unpack32(&job_max_memory, buffer);
 	safe_unpack32(&job_min_tmp_disk, buffer);
 	safe_unpack_time(&begin_time, buffer);
 	safe_unpack_time(&submit_time, buffer);
 
-	safe_unpackstr_xmalloc(&req_nodes, &name_len, buffer);
-	safe_unpackstr_xmalloc(&exc_nodes, &name_len, buffer);
-	safe_unpackstr_xmalloc(&features,  &name_len, buffer);
+	safe_unpackstr_xmalloc(&req_nodes,  &name_len, buffer);
+	safe_unpackstr_xmalloc(&exc_nodes,  &name_len, buffer);
+	safe_unpackstr_xmalloc(&features,   &name_len, buffer);
+	safe_unpackstr_xmalloc(&dependency, &name_len, buffer);
 
 	safe_unpackstr_xmalloc(&err, &name_len, buffer);
 	safe_unpackstr_xmalloc(&in,  &name_len, buffer);
@@ -837,9 +866,9 @@ static int _load_job_details(struct job_record *job_ptr, Buf buffer)
 		      job_ptr->job_id, contiguous);
 		goto unpack_error;
 	}
-	if ((no_requeue > 1) || (overcommit > 1)) {
-		error("Invalid data for job %u: no_requeue=%u overcommit=%u",
-		      no_requeue, overcommit);
+	if ((requeue > 1) || (overcommit > 1)) {
+		error("Invalid data for job %u: requeue=%u overcommit=%u",
+		      requeue, overcommit);
 		goto unpack_error;
 	}
 
@@ -860,17 +889,17 @@ static int _load_job_details(struct job_record *job_ptr, Buf buffer)
 	/* now put the details into the job record */
 	job_ptr->details->min_nodes = min_nodes;
 	job_ptr->details->max_nodes = max_nodes;
-	job_ptr->details->total_procs = total_procs;
 	job_ptr->details->num_tasks = num_tasks;
 	job_ptr->details->shared = shared;
+	job_ptr->details->acctg_freq = acctg_freq;
 	job_ptr->details->contiguous = contiguous;
 	job_ptr->details->cpus_per_task = cpus_per_task;
 	job_ptr->details->ntasks_per_node = ntasks_per_node;
 	job_ptr->details->job_min_procs = job_min_procs;
 	job_ptr->details->job_min_memory = job_min_memory;
-	job_ptr->details->job_max_memory = job_max_memory;
 	job_ptr->details->job_min_tmp_disk = job_min_tmp_disk;
-	job_ptr->details->no_requeue = no_requeue;
+	job_ptr->details->requeue = requeue;
+	job_ptr->details->open_mode = open_mode;
 	job_ptr->details->overcommit = overcommit;
 	job_ptr->details->begin_time = begin_time;
 	job_ptr->details->submit_time = submit_time;
@@ -884,6 +913,7 @@ static int _load_job_details(struct job_record *job_ptr, Buf buffer)
 	job_ptr->details->argc = argc;
 	job_ptr->details->argv = argv;
 	job_ptr->details->mc_ptr = mc_ptr;
+	job_ptr->details->dependency = dependency;
 	
 	return SLURM_SUCCESS;
 
@@ -891,6 +921,7 @@ unpack_error:
 	xfree(req_nodes);
 	xfree(exc_nodes);
 	xfree(features);
+	xfree(dependency);
 	xfree(err);
 	xfree(in);
 	xfree(out);
@@ -974,12 +1005,14 @@ extern int kill_job_by_part_name(char *part_name)
 			job_ptr->job_state = JOB_NODE_FAIL | JOB_COMPLETING;
 			job_ptr->exit_code = MAX(job_ptr->exit_code, 1);
 			job_ptr->state_reason = FAIL_DOWN_PARTITION;
-			if (suspended)
+			if (suspended) {
 				job_ptr->end_time = job_ptr->suspend_time;
-			else
-				job_ptr->end_time = time(NULL);
-			job_completion_logger(job_ptr);
+				job_ptr->tot_sus_time += 
+					difftime(now, job_ptr->suspend_time);
+			} else
+				job_ptr->end_time = now;
 			deallocate_nodes(job_ptr, false, suspended);
+			job_completion_logger(job_ptr);
 		} else if (job_ptr->job_state == JOB_PENDING) {
 			job_count++;
 			info("Killing job_id %u on defunct partition %s",
@@ -1062,15 +1095,24 @@ extern int kill_running_job_by_node_name(char *node_name, bool step_test)
 				      node_name, job_ptr->job_id);
 				_excise_node_from_job(job_ptr, node_ptr);
 			} else if (job_ptr->batch_flag && job_ptr->details &&
-			           (job_ptr->details->no_requeue == 0)) {
+			           (job_ptr->details->requeue > 0)) {
+				char requeue_msg[128];
+
 				srun_node_fail(job_ptr->job_id, node_name);
+
 				info("requeue job %u due to failure of node %s",
 				     job_ptr->job_id, node_name);
 				_set_job_prio(job_ptr);
+				snprintf(requeue_msg, sizeof(requeue_msg),
+					"Job requeued due to failure of node %s",
+					node_name);
+				slurm_sched_requeue(job_ptr, requeue_msg);
 				job_ptr->time_last_active  = now;
-				if (suspended)
+				if (suspended) {
 					job_ptr->end_time = job_ptr->suspend_time;
-				else
+					job_ptr->tot_sus_time += 
+						difftime(now, job_ptr->suspend_time);
+				} else
 					job_ptr->end_time = now;
 				
 				/* We want this job to look like it was cancelled in the
@@ -1092,10 +1134,12 @@ extern int kill_running_job_by_node_name(char *node_name, bool step_test)
 				job_ptr->exit_code = 
 					MAX(job_ptr->exit_code, 1);
 				job_ptr->state_reason = FAIL_DOWN_NODE;
-				if (suspended)
+				if (suspended) {
 					job_ptr->end_time =
 						job_ptr->suspend_time;
-				else
+					job_ptr->tot_sus_time += 
+						difftime(now, job_ptr->suspend_time);
+				} else
 					job_ptr->end_time = time(NULL);
 				deallocate_nodes(job_ptr, false, suspended);
 				job_completion_logger(job_ptr);
@@ -1134,10 +1178,10 @@ void dump_job_desc(job_desc_msg_t * job_specs)
 {
 	long job_id;
 	long job_min_procs, job_min_sockets, job_min_cores, job_min_threads;
-	long job_min_memory, job_max_memory, job_min_tmp_disk, num_procs;
-	long time_limit, priority, contiguous;
-	long kill_on_node_fail, shared, immediate, dependency;
-	long cpus_per_task, no_requeue, num_tasks, overcommit;
+	long job_min_memory, job_min_tmp_disk, num_procs;
+	long time_limit, priority, contiguous, acctg_freq;
+	long kill_on_node_fail, shared, immediate;
+	long cpus_per_task, requeue, num_tasks, overcommit;
 	long ntasks_per_node, ntasks_per_socket, ntasks_per_core;
 	char buf[100];
 
@@ -1175,12 +1219,10 @@ void dump_job_desc(job_desc_msg_t * job_specs)
 
 	job_min_memory   = (job_specs->job_min_memory != NO_VAL) ? 
 		(long) job_specs->job_min_memory : -1L;
-	job_max_memory   = (job_specs->job_max_memory != NO_VAL) ? 
-		(long) job_specs->job_max_memory : -1L;
 	job_min_tmp_disk = (job_specs->job_min_tmp_disk != NO_VAL) ? 
 		(long) job_specs->job_min_tmp_disk : -1L;
-	debug3("   job_min_memory=%ld job_max_memory=%ld job_min_tmp_disk=%ld",
-	       job_min_memory, job_max_memory, job_min_tmp_disk);
+	debug3("   job_min_memory=%ld job_min_tmp_disk=%ld",
+	       job_min_memory, job_min_tmp_disk);
 	immediate = (job_specs->immediate == 0) ? 0L : 1L;
 	debug3("   immediate=%ld features=%s",
 	       immediate, job_specs->features);
@@ -1242,31 +1284,34 @@ void dump_job_desc(job_desc_msg_t * job_specs)
 	       job_specs->work_dir,
 	       job_specs->alloc_node, job_specs->alloc_sid);
 
-	dependency = (job_specs->dependency != NO_VAL) ?
-		(long) job_specs->dependency : -1L;
-	debug3("   alloc_resp_hostname=%s alloc_resp_port=%u",
-	       job_specs->alloc_resp_hostname, job_specs->alloc_resp_port);
-	debug3("   other_hostname=%s other_port=%u",
-	       job_specs->other_hostname, job_specs->other_port);
-	debug3("   dependency=%ld account=%s comment=%s",
-	       dependency, job_specs->account, job_specs->comment);
+	debug3("   resp_host=%s alloc_resp_port=%u  other_port=%u",
+		job_specs->resp_host, 
+		job_specs->alloc_resp_port, job_specs->other_port);
+	debug3("   dependency=%s account=%s comment=%s",
+	       job_specs->dependency, job_specs->account, 
+	       job_specs->comment);
 
 	num_tasks = (job_specs->num_tasks != (uint16_t) NO_VAL) ?
 		(long) job_specs->num_tasks : -1L;
-	overcommit = (job_specs->overcommit != (uint16_t) NO_VAL) ?
+	overcommit = (job_specs->overcommit != (uint8_t) NO_VAL) ?
 		(long) job_specs->overcommit : -1L;
+	acctg_freq = (job_specs->acctg_freq  != (uint16_t) NO_VAL) ?
+		(long) job_specs->acctg_freq : -1L;
 	debug3("   mail_type=%u mail_user=%s nice=%d num_tasks=%d "
-	       "overcommit=%d",
+	       "open_mode=%u overcommit=%d acctg_freq=%d",
 	       job_specs->mail_type, job_specs->mail_user,
-	       (int)job_specs->nice - NICE_OFFSET, num_tasks, overcommit);
+	       (int)job_specs->nice - NICE_OFFSET, num_tasks,
+	       job_specs->open_mode, overcommit, acctg_freq);
 
 	slurm_make_time_str(&job_specs->begin_time, buf, sizeof(buf));
 	cpus_per_task = (job_specs->cpus_per_task != (uint16_t) NO_VAL) ?
 		(long) job_specs->cpus_per_task : -1L;
-	no_requeue = (job_specs->no_requeue != (uint16_t) NO_VAL) ?
-		(long) job_specs->no_requeue : -1L;
-	debug3("   network=%s begin=%s cpus_per_task=%ld no_requeue=%ld", 
-	       job_specs->network, buf, cpus_per_task, no_requeue);
+	requeue = (job_specs->requeue != (uint16_t) NO_VAL) ?
+		(long) job_specs->requeue : -1L;
+	debug3("   network=%s begin=%s cpus_per_task=%ld requeue=%ld "
+	       "licenses=%s", 
+	       job_specs->network, buf, cpus_per_task, requeue,
+	       job_specs->licenses);
 
 	ntasks_per_node = (job_specs->ntasks_per_node != (uint16_t) NO_VAL) ?
 		(long) job_specs->ntasks_per_node : -1L;
@@ -1336,6 +1381,7 @@ extern void rehash_jobs(void)
  * IN immediate - if set then either initiate the job immediately or fail
  * IN will_run - don't initiate the job if set, just test if it could run 
  *	now or later
+ * OUT resp - will run response (includes start location, time, etc.)
  * IN allocate - resource allocation request if set, not a full job
  * IN submit_uid -uid of user issuing the request
  * OUT job_pptr - set to pointer to job record
@@ -1351,7 +1397,7 @@ extern void rehash_jobs(void)
  * NOTE: lock_slurmctld on entry: Read config Write job, Write node, Read part
  */
 extern int job_allocate(job_desc_msg_t * job_specs, int immediate, 
-			int will_run, 
+			int will_run, will_run_response_msg_t **resp,
 			int allocate, uid_t submit_uid,
 			struct job_record **job_pptr)
 {
@@ -1376,6 +1422,8 @@ extern int job_allocate(job_desc_msg_t * job_specs, int immediate,
 	xassert(job_ptr);
 
 	independent = job_independent(job_ptr);
+	if (license_job_test(job_ptr) != SLURM_SUCCESS)
+		independent = false;
 
 	/* Avoid resource fragmentation if important */
 	if (independent && switch_no_frag() && 
@@ -1410,6 +1458,18 @@ extern int job_allocate(job_desc_msg_t * job_specs, int immediate,
 			return ESLURM_NOT_TOP_PRIORITY;
 	}
 
+	if (will_run && resp) {
+		job_desc_msg_t job_desc_msg;
+		int rc;
+		bzero(&job_desc_msg, sizeof(job_desc_msg_t));
+		job_desc_msg.job_id = job_ptr->job_id;
+		rc = job_start_data(&job_desc_msg, resp);
+		job_ptr->job_state  = JOB_FAILED;
+		job_ptr->exit_code  = 1;
+		job_ptr->start_time = job_ptr->end_time = now;
+		return rc;
+	}
+
 	test_only = will_run || (allocate == 0);
 
 	no_alloc = test_only || too_fragmented || 
@@ -1419,7 +1479,7 @@ extern int job_allocate(job_desc_msg_t * job_specs, int immediate,
 		last_job_update = now;
 		slurm_sched_schedule();	/* work for external scheduler */
 	}
-
+ 
 	if ((error_code == ESLURM_NODES_BUSY) ||
 	    (error_code == ESLURM_JOB_HELD) ||
 	    (error_code == ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE)) {
@@ -1479,9 +1539,11 @@ extern int job_fail(uint32_t job_id)
 	if ((job_ptr->job_state == JOB_RUNNING) || suspended) {
 		/* No need to signal steps, deallocate kills them */
 		job_ptr->time_last_active       = now;
-		if (suspended)
+		if (suspended) {
 			job_ptr->end_time       = job_ptr->suspend_time;
-		else
+			job_ptr->tot_sus_time  += 
+				difftime(now, job_ptr->suspend_time);
+		} else
 			job_ptr->end_time       = now;
 		last_job_update                 = now;
 		job_ptr->job_state = JOB_FAILED | JOB_COMPLETING;
@@ -1557,6 +1619,7 @@ extern int job_signal(uint32_t job_id, uint16_t signal, uint16_t batch_flag,
 	    &&  (signal == SIGKILL)) {
 		last_job_update         = now;
 		job_ptr->end_time       = job_ptr->suspend_time;
+		job_ptr->tot_sus_time  += difftime(now, job_ptr->suspend_time);
 		job_ptr->job_state      = JOB_CANCELLED | JOB_COMPLETING;
 		deallocate_nodes(job_ptr, false, true);
 		job_completion_logger(job_ptr);
@@ -1700,9 +1763,11 @@ extern int job_complete(uint32_t job_id, uid_t uid, bool requeue,
 			job_ptr->state_reason = FAIL_TIMEOUT;
 		} else
 			job_ptr->job_state = JOB_COMPLETE | job_comp_flag;
-		if (suspended)
+		if (suspended) {
 			job_ptr->end_time = job_ptr->suspend_time;
-		else
+			job_ptr->tot_sus_time += 
+				difftime(now, job_ptr->suspend_time);
+		} else
 			job_ptr->end_time = now;
 		job_completion_logger(job_ptr);
 	}
@@ -1744,6 +1809,10 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 	bool super_user = false;
 	struct job_record *job_ptr;
 	uint32_t total_nodes, max_procs;
+	acct_association_rec_t assoc_rec, *assoc_ptr;
+	List license_list = NULL;
+	bool valid;
+
 #if SYSTEM_DIMENSIONS
 	uint16_t geo[SYSTEM_DIMENSIONS];
 	uint16_t reboot;
@@ -1751,21 +1820,6 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 	uint16_t conn_type;
 #endif
 
-	debug2("before alteration asking for nodes %u-%u procs %u", 
-	       job_desc->min_nodes, job_desc->max_nodes,
-	       job_desc->num_procs);
-	select_g_alter_node_cnt(SELECT_SET_NODE_CNT, job_desc);
-	select_g_get_jobinfo(job_desc->select_jobinfo,
-			     SELECT_DATA_MAX_PROCS, &max_procs);
-	
-	debug2("after alteration asking for nodes %u-%u procs %u-%u", 
-	       job_desc->min_nodes, job_desc->max_nodes,
-	       job_desc->num_procs, max_procs);
-	
-	*job_pptr = (struct job_record *) NULL;
-	if ((error_code = _validate_job_desc(job_desc, allocate, submit_uid)))
-		return error_code;
-
 	/* find selected partition */
 	if (job_desc->partition) {
 		part_ptr = list_find_first(part_list, &list_find_part,
@@ -1784,6 +1838,40 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 		}
 		part_ptr = default_part_loc;
 	}
+	if (job_desc->min_nodes == NO_VAL)
+		job_desc->min_nodes = part_ptr->min_nodes_orig;
+	if (job_desc->max_nodes == NO_VAL) {
+#ifdef HAVE_BG
+		job_desc->max_nodes = part_ptr->min_nodes_orig;
+#else
+		;
+#endif
+	} else if (job_desc->max_nodes < part_ptr->min_nodes_orig) {
+		info("_job_create: job's max nodes less than partition's "
+		     "min nodes (%u < %u)", 
+		     job_desc->max_nodes, part_ptr->min_nodes_orig);
+		error_code = ESLURM_TOO_MANY_REQUESTED_NODES;
+		return error_code;
+	}
+
+	debug3("before alteration asking for nodes %u-%u procs %u", 
+	       job_desc->min_nodes, job_desc->max_nodes,
+	       job_desc->num_procs);
+	select_g_alter_node_cnt(SELECT_SET_NODE_CNT, job_desc);
+	select_g_get_jobinfo(job_desc->select_jobinfo,
+			     SELECT_DATA_MAX_PROCS, &max_procs);
+	debug3("after alteration asking for nodes %u-%u procs %u-%u", 
+	       job_desc->min_nodes, job_desc->max_nodes,
+	       job_desc->num_procs, max_procs);
+	
+	*job_pptr = (struct job_record *) NULL;
+	if ((error_code = _validate_job_desc(job_desc, allocate, submit_uid)))
+		return error_code;
+ 
+	if ((job_desc->user_id == 0) && part_ptr->disable_root_jobs) {
+		error("Security violation, SUBMIT_JOB for user root disabled");
+		return ESLURM_USER_ID_MISSING;
+	}
 
 	/* can this user access this partition */
 	if ((part_ptr->root_only) && (submit_uid != 0)) {
@@ -1800,6 +1888,28 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 		return error_code;
 	}
 
+	bzero(&assoc_rec, sizeof(acct_association_rec_t));
+	assoc_rec.uid       = job_desc->user_id;
+	assoc_rec.partition = part_ptr->name;
+	assoc_rec.acct      = job_desc->account;
+
+	if (assoc_mgr_fill_in_assoc(acct_db_conn, &assoc_rec,
+				    accounting_enforce, &assoc_ptr)) {
+		info("_job_create: invalid account or partition for user %u",
+		     job_desc->user_id);
+		error_code = ESLURM_INVALID_ACCOUNT;
+		return error_code;
+	}
+	if (job_desc->account == NULL)
+		job_desc->account = xstrdup(assoc_rec.acct);
+	if (accounting_enforce &&
+	    (!_validate_acct_policy(job_desc, part_ptr, &assoc_rec))) {
+		info("_job_create: exceeded association's node or time limit "
+		     "for user %u", job_desc->user_id);
+		error_code = ESLURM_ACCOUNTING_POLICY;
+		return error_code;
+	}
+
 	/* check if select partition has sufficient resources to satisfy
 	 * the request */
 
@@ -1814,10 +1924,9 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 		if (job_desc->contiguous)
 			bit_fill_gaps(req_bitmap);
 		if (bit_super_set(req_bitmap, part_ptr->node_bitmap) != 1) {
-			char *tmp = bitmap2node_name(req_bitmap);
 			info("_job_create: requested nodes %s not in "
-			     "partition %s", tmp, part_ptr->name);
-			xfree(tmp);
+			     "partition %s", 
+			     job_desc->req_nodes, part_ptr->name);
 			error_code = ESLURM_REQUESTED_NODES_NOT_IN_PARTITION;
 			goto cleanup;
 		}
@@ -1930,10 +2039,17 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 		goto cleanup;
 	}
 
+	license_list = license_job_validate(job_desc->licenses, &valid);
+	if (!valid) {
+		info("Job's requested licenses are invalid: %s", 
+		     job_desc->licenses);
+		error_code = ESLURM_INVALID_LICENSES;
+		goto cleanup;
+	}
 
 	if ((error_code =_validate_job_create_req(job_desc)))
 		goto cleanup;
-	
+
 	if ((error_code = _copy_job_desc_to_job_record(job_desc,
 						       job_pptr,
 						       part_ptr,
@@ -1942,10 +2058,11 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 		error_code = ESLURM_ERROR_ON_DESC_TO_RECORD_COPY;
 		goto cleanup;
 	}
-	
+
 	job_ptr = *job_pptr;
-	if (job_ptr->dependency == job_ptr->job_id) {
-		info("User specified self as dependent job");
+	job_ptr->assoc_id = assoc_rec.id;
+	job_ptr->assoc_ptr = (void *) assoc_ptr;
+	if (update_job_dependency(job_ptr, job_desc->dependency)) {
 		error_code = ESLURM_DEPENDENCY;
 		goto cleanup;
 	}
@@ -1965,6 +2082,9 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 	} else
 		job_ptr->batch_flag = 0;
 
+	job_ptr->license_list = license_list;
+	license_list = NULL;
+
 	/* Insure that requested partition is valid right now, 
 	 * otherwise leave job queued and provide warning code */
 	detail_ptr = job_ptr->details;
@@ -1999,6 +2119,8 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run,
 	
 	
 cleanup:
+	if (license_list)
+		list_destroy(license_list);
 	FREE_NULL_BITMAP(req_bitmap);
 	FREE_NULL_BITMAP(exc_bitmap);
 	return error_code;
@@ -2009,25 +2131,95 @@ cleanup:
  * RET 0 or error code */
 static int _validate_job_create_req(job_desc_msg_t * job_desc)
 {
+	if (job_desc->account && (strlen(job_desc->account) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(account) too big (%d)",
+		     strlen(job_desc->account));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->alloc_node && (strlen(job_desc->alloc_node) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(alloc_node) too big (%d)",
+		     strlen(job_desc->alloc_node));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->blrtsimage && (strlen(job_desc->blrtsimage) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(blrtsimage) too big (%d)",
+		     strlen(job_desc->blrtsimage));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->comment && (strlen(job_desc->comment) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(comment) too big (%d)",
+		     strlen(job_desc->comment));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->dependency && (strlen(job_desc->dependency) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(dependency) too big (%d)",
+		     strlen(job_desc->dependency));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
 	if (job_desc->err && (strlen(job_desc->err) > MAX_STR_LEN)) {
 		info("_validate_job_create_req: strlen(err) too big (%d)",
 		     strlen(job_desc->err));
 		return ESLURM_PATHNAME_TOO_LONG;
 	}
+	if (job_desc->features && (strlen(job_desc->features) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(features) too big (%d)",
+		     strlen(job_desc->features));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
 	if (job_desc->in && (strlen(job_desc->in) > MAX_STR_LEN)) {
 		info("_validate_job_create_req: strlen(in) too big (%d)",
 		     strlen(job_desc->in));
-		return  ESLURM_PATHNAME_TOO_LONG;
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->linuximage && (strlen(job_desc->linuximage) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(linuximage) too big (%d)",
+		     strlen(job_desc->linuximage));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->licenses && (strlen(job_desc->licenses) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(licenses) too big (%d)",
+		     strlen(job_desc->licenses));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->mail_user && (strlen(job_desc->mail_user) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(mail_user) too big (%d)",
+		     strlen(job_desc->mail_user));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->mloaderimage && (strlen(job_desc->mloaderimage) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(mloaderimage) too big (%d)",
+		     strlen(job_desc->features));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->name && (strlen(job_desc->name) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(name) too big (%d)",
+		     strlen(job_desc->name));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->network && (strlen(job_desc->network) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(network) too big (%d)",
+		     strlen(job_desc->network));
+		return ESLURM_PATHNAME_TOO_LONG;
 	}
 	if (job_desc->out && (strlen(job_desc->out) > MAX_STR_LEN)) {
 		info("_validate_job_create_req: strlen(out) too big (%d)",
 		     strlen(job_desc->out));
-		return  ESLURM_PATHNAME_TOO_LONG;
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->partition && (strlen(job_desc->partition) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(partition) too big (%d)",
+		     strlen(job_desc->partition));
+		return ESLURM_PATHNAME_TOO_LONG;
+	}
+	if (job_desc->ramdiskimage && (strlen(job_desc->ramdiskimage) > MAX_STR_LEN)) {
+		info("_validate_job_create_req: strlen(ramdiskimage) too big (%d)",
+		     strlen(job_desc->ramdiskimage));
+		return ESLURM_PATHNAME_TOO_LONG;
 	}
 	if (job_desc->work_dir && (strlen(job_desc->work_dir) > MAX_STR_LEN)) {
 		info("_validate_job_create_req: strlen(work_dir) too big (%d)",
 		     strlen(job_desc->work_dir));
-		return  ESLURM_PATHNAME_TOO_LONG;
+		return ESLURM_PATHNAME_TOO_LONG;
 	}
 	return SLURM_SUCCESS;
 }
@@ -2083,7 +2275,7 @@ _copy_job_desc_to_file(job_desc_msg_t * job_desc, uint32_t job_id)
  * IN size - number of elements in data
  */
 static int
-_write_data_array_to_file(char *file_name, char **data, uint16_t size)
+_write_data_array_to_file(char *file_name, char **data, uint32_t size)
 {
 	int fd, i, pos, nwrite, amount;
 
@@ -2093,8 +2285,8 @@ _write_data_array_to_file(char *file_name, char **data, uint16_t size)
 		return ESLURM_WRITING_TO_FILE;
 	}
 
-	amount = write(fd, &size, sizeof(uint16_t));
-	if (amount < sizeof(uint16_t)) {
+	amount = write(fd, &size, sizeof(uint32_t));
+	if (amount < sizeof(uint32_t)) {
 		error("Error writing file %s, %m", file_name);
 		close(fd);
 		return ESLURM_WRITING_TO_FILE;
@@ -2167,7 +2359,7 @@ static int _write_data_to_file(char *file_name, char *data)
  * RET point to array of string pointers containing environment variables
  * NOTE: READ lock_slurmctld config before entry
  */
-char **get_job_env(struct job_record *job_ptr, uint16_t * env_size)
+char **get_job_env(struct job_record *job_ptr, uint32_t * env_size)
 {
 	char job_dir[30], *file_name, **environment = NULL;
 
@@ -2210,11 +2402,11 @@ char *get_job_script(struct job_record *job_ptr)
  * NOTE: The output format of this must be identical with _xduparray2()
  */
 static void
-_read_data_array_from_file(char *file_name, char ***data, uint16_t * size)
+_read_data_array_from_file(char *file_name, char ***data, uint32_t * size)
 {
 	int fd, pos, buf_size, amount, i;
 	char *buffer, **array_ptr;
-	uint16_t rec_cnt;
+	uint32_t rec_cnt;
 
 	xassert(file_name);
 	xassert(data);
@@ -2228,8 +2420,8 @@ _read_data_array_from_file(char *file_name, char ***data, uint16_t * size)
 		return;
 	}
 
-	amount = read(fd, &rec_cnt, sizeof(uint16_t));
-	if (amount < sizeof(uint16_t)) {
+	amount = read(fd, &rec_cnt, sizeof(uint32_t));
+	if (amount < sizeof(uint32_t)) {
 		if (amount != 0)	/* incomplete write */
 			error("Error reading file %s, %m", file_name);
 		else 
@@ -2421,7 +2613,7 @@ _copy_job_desc_to_job_record(job_desc_msg_t * job_desc,
 	if (error_code)
 		return error_code;
 
-	strncpy(job_ptr->partition, part_ptr->name, MAX_SLURM_NAME);
+	job_ptr->partition = xstrdup(part_ptr->name);
 	job_ptr->part_ptr = part_ptr;
 	if (job_desc->job_id != NO_VAL)		/* already confirmed unique */
 		job_ptr->job_id = job_desc->job_id;
@@ -2429,9 +2621,8 @@ _copy_job_desc_to_job_record(job_desc_msg_t * job_desc,
 		_set_job_id(job_ptr);
 	_add_job_hash(job_ptr);
 
-	if (job_desc->name) {
-		strncpy(job_ptr->name, job_desc->name, MAX_JOBNAME_LEN);
-	}
+	if (job_desc->name)
+		job_ptr->name = xstrdup(job_desc->name);
 	job_ptr->user_id    = (uid_t) job_desc->user_id;
 	job_ptr->group_id   = (gid_t) job_desc->group_id;
 	job_ptr->job_state  = JOB_PENDING;
@@ -2441,9 +2632,22 @@ _copy_job_desc_to_job_record(job_desc_msg_t * job_desc,
 	job_ptr->account    = xstrdup(job_desc->account);
 	job_ptr->network    = xstrdup(job_desc->network);
 	job_ptr->comment    = xstrdup(job_desc->comment);
-	if (job_desc->dependency != NO_VAL) /* leave as zero */
-		job_ptr->dependency = job_desc->dependency;
-
+	if (!wiki_sched_test) {
+		char *sched_type = slurm_get_sched_type();
+		if (strcmp(sched_type, "sched/wiki") == 0)
+			wiki_sched = true;
+		xfree(sched_type);
+		wiki_sched_test = true;
+	}
+	if (wiki_sched && job_ptr->comment &&
+	    strstr(job_ptr->comment, "QOS:")) {
+		if (strstr(job_ptr->comment, "FLAGS:PREEMPTOR"))
+			job_ptr->qos = QOS_EXPEDITE;
+		else if (strstr(job_ptr->comment, "FLAGS:PREEMPTEE"))
+			job_ptr->qos = QOS_STANDBY;
+		else
+			job_ptr->qos = QOS_NORMAL;
+	}
 	if (job_desc->priority != NO_VAL) /* already confirmed submit_uid==0 */
 		job_ptr->priority = job_desc->priority;
 	else {
@@ -2454,14 +2658,14 @@ _copy_job_desc_to_job_record(job_desc_msg_t * job_desc,
 	if (job_desc->kill_on_node_fail != (uint16_t) NO_VAL)
 		job_ptr->kill_on_node_fail = job_desc->kill_on_node_fail;
 
+	job_ptr->resp_host = xstrdup(job_desc->resp_host);
 	job_ptr->alloc_resp_port = job_desc->alloc_resp_port;
-	job_ptr->alloc_resp_host = xstrdup(job_desc->alloc_resp_hostname);
 	job_ptr->other_port = job_desc->other_port;
-	job_ptr->other_host = xstrdup(job_desc->other_hostname);
 	job_ptr->time_last_active = time(NULL);
 	job_ptr->num_procs = job_desc->num_procs;
         job_ptr->cr_enabled = 0;
 
+	job_ptr->licenses  = xstrdup(job_desc->licenses);
 	job_ptr->mail_type = job_desc->mail_type;
 	job_ptr->mail_user = xstrdup(job_desc->mail_user);
 
@@ -2470,8 +2674,10 @@ _copy_job_desc_to_job_record(job_desc_msg_t * job_desc,
 	detail_ptr->argv = job_desc->argv;
 	job_desc->argv   = (char **) NULL; /* nothing left */
 	job_desc->argc   = 0;		   /* nothing left */
-	detail_ptr->min_nodes = job_desc->min_nodes;
-	detail_ptr->max_nodes = job_desc->max_nodes;
+	detail_ptr->acctg_freq = job_desc->acctg_freq;
+	detail_ptr->open_mode  = job_desc->open_mode;
+	detail_ptr->min_nodes  = job_desc->min_nodes;
+	detail_ptr->max_nodes  = job_desc->max_nodes;
 	if (job_desc->req_nodes) {
 		detail_ptr->req_nodes = 
 			_copy_nodelist_no_dup(job_desc->req_nodes);
@@ -2493,19 +2699,19 @@ _copy_job_desc_to_job_record(job_desc_msg_t * job_desc,
 	if (job_desc->task_dist != (uint16_t) NO_VAL)
 		detail_ptr->task_dist = job_desc->task_dist;
 	if (job_desc->cpus_per_task != (uint16_t) NO_VAL)
-		detail_ptr->cpus_per_task = job_desc->cpus_per_task;
+		detail_ptr->cpus_per_task = MIN(job_desc->cpus_per_task, 1);
 	if (job_desc->ntasks_per_node != (uint16_t) NO_VAL)
 		detail_ptr->ntasks_per_node = job_desc->ntasks_per_node;
-	if (job_desc->no_requeue != (uint16_t) NO_VAL)
-		detail_ptr->no_requeue = job_desc->no_requeue;
+	if (job_desc->requeue != (uint16_t) NO_VAL)
+		detail_ptr->requeue = MIN(job_desc->requeue, 1);
+	else
+		detail_ptr->requeue = slurmctld_conf.job_requeue;
 	if (job_desc->job_min_procs != (uint16_t) NO_VAL)
 		detail_ptr->job_min_procs = job_desc->job_min_procs;
 	detail_ptr->job_min_procs = MAX(detail_ptr->job_min_procs,
 					detail_ptr->cpus_per_task);
 	if (job_desc->job_min_memory != NO_VAL)
 		detail_ptr->job_min_memory = job_desc->job_min_memory;
-	if (job_desc->job_max_memory != NO_VAL)
-		detail_ptr->job_max_memory = job_desc->job_max_memory;
 	if (job_desc->job_min_tmp_disk != NO_VAL)
 		detail_ptr->job_min_tmp_disk = job_desc->job_min_tmp_disk;
 	if (job_desc->num_tasks != NO_VAL)
@@ -2518,14 +2724,13 @@ _copy_job_desc_to_job_record(job_desc_msg_t * job_desc,
 		detail_ptr->out = xstrdup(job_desc->out);
 	if (job_desc->work_dir)
 		detail_ptr->work_dir = xstrdup(job_desc->work_dir);
-	if (job_desc->overcommit != (uint16_t) NO_VAL)
+	if (job_desc->overcommit != (uint8_t) NO_VAL)
 		detail_ptr->overcommit = job_desc->overcommit;
 	if (job_desc->begin_time > time(NULL))
 		detail_ptr->begin_time = job_desc->begin_time;
 	job_ptr->select_jobinfo = 
 		select_g_copy_jobinfo(job_desc->select_jobinfo);
 	detail_ptr->mc_ptr = _set_multi_core_data(job_desc);	
-
 	*job_rec_ptr = job_ptr;
 	return SLURM_SUCCESS;
 }
@@ -2632,25 +2837,18 @@ static void _job_timed_out(struct job_record *job_ptr)
 static int _validate_job_desc(job_desc_msg_t * job_desc_msg, int allocate, 
 			      uid_t submit_uid)
 {
-	static bool wiki_sched = false;
-	static bool wiki_sched_test = false;
-
-	/* Permit normal user to specify job id only for sched/wiki
-	 * and sched/wiki2 */
+	/* Permit normal user to specify job id only for sched/wiki 
+	 * (Maui scheduler). This was also required with earlier
+	 * versions of the Moab scheduler (wiki2), but was fixed 
+	 * in early 2007 to submit jobs as user root */
 	if (!wiki_sched_test) {
 		char *sched_type = slurm_get_sched_type();
-		if ((strcmp(sched_type, "sched/wiki") == 0)
-		||  (strcmp(sched_type, "sched/wiki2") == 0))
+		if (strcmp(sched_type, "sched/wiki") == 0)
 			wiki_sched = true;
 		xfree(sched_type);
 		wiki_sched_test = true;
 	}
 
-	if ((job_desc_msg->user_id == 0) && slurmctld_conf.disable_root_jobs) {
-		error("Security violation, SUBMIT_JOB for user root disabled");
-		return ESLURM_USER_ID_MISSING;
-	}
-
 	if ((job_desc_msg->num_procs == NO_VAL)
 	    &&  (job_desc_msg->min_nodes == NO_VAL)
 	    &&  (job_desc_msg->req_nodes == NULL)) {
@@ -2670,10 +2868,6 @@ static int _validate_job_desc(job_desc_msg_t * job_desc_msg, int allocate,
 		debug("_validate_job_desc: job failed to specify group");
 		job_desc_msg->group_id = 0;	/* uses user default */
 	}
-	if ((job_desc_msg->name) &&
-	    (strlen(job_desc_msg->name) >= MAX_JOBNAME_LEN)) {
-		job_desc_msg->name[MAX_JOBNAME_LEN-1] = '\0';
-	}
 	if (job_desc_msg->contiguous == (uint16_t) NO_VAL)
 		job_desc_msg->contiguous = 0;
 
@@ -2744,9 +2938,7 @@ static int _validate_job_desc(job_desc_msg_t * job_desc_msg, int allocate,
 	if (job_desc_msg->job_min_threads == (uint16_t) NO_VAL)
 		job_desc_msg->job_min_threads = 1; /* default 1 thread per core */
 	if (job_desc_msg->job_min_memory == NO_VAL)
-		job_desc_msg->job_min_memory = 1;  /* default 1MB mem per node */
-	if (job_desc_msg->job_max_memory == NO_VAL)
-		job_desc_msg->job_max_memory = 1;  /* default 1MB mem per node */
+		job_desc_msg->job_min_memory = 0;  /* default no memory limit */
 	if (job_desc_msg->job_min_tmp_disk == NO_VAL)
 		job_desc_msg->job_min_tmp_disk = 0;/* default 0MB disk per node */
 
@@ -2781,18 +2973,23 @@ static void _list_delete_job(void *job_entry)
 
 	delete_job_details(job_ptr);
 	xfree(job_ptr->alloc_node);
+	xfree(job_ptr->name);
 	xfree(job_ptr->nodes);
 	xfree(job_ptr->nodes_completing);
 	FREE_NULL_BITMAP(job_ptr->node_bitmap);
+	xfree(job_ptr->partition);
 	xfree(job_ptr->cpus_per_node);
 	xfree(job_ptr->cpu_count_reps);
 	xfree(job_ptr->node_addr);
-	xfree(job_ptr->alloc_resp_host);
-	xfree(job_ptr->other_host);
 	xfree(job_ptr->account);
+	xfree(job_ptr->resp_host);
+	xfree(job_ptr->licenses);
+	if (job_ptr->license_list)
+		list_destroy(job_ptr->license_list);
 	xfree(job_ptr->mail_user);
 	xfree(job_ptr->network);
 	xfree(job_ptr->alloc_lps);
+	xfree(job_ptr->used_lps);
 	xfree(job_ptr->comment);
 	select_g_free_jobinfo(&job_ptr->select_jobinfo);
 	if (job_ptr->step_list) {
@@ -2893,6 +3090,10 @@ extern void pack_all_jobs(char **buffer_ptr, int *buffer_size,
 		    (job_ptr->part_ptr->hidden))
 			continue;
 
+		if (slurmctld_conf.private_data
+		&&  (job_ptr->user_id != uid) && !validate_super_user(uid))
+			continue;
+
 		pack_job(job_ptr, buffer);
 		jobs_packed++;
 	}
@@ -2938,18 +3139,13 @@ void pack_job(struct job_record *dump_job_ptr, Buf buffer)
 	else
 		pack32(dump_job_ptr->time_limit, buffer);
 
-	if (dump_job_ptr->details) {
+	if (dump_job_ptr->details)
 		pack_time(dump_job_ptr->details->submit_time, buffer);
-	} else {
+	else
 		pack_time((time_t) 0, buffer);
-	}
-	if (IS_JOB_PENDING(dump_job_ptr)) {
-		if (dump_job_ptr->details)
-			pack_time(dump_job_ptr->details->begin_time,
-				  buffer);
-		else
-			pack_time((time_t) 0, buffer);
-	} else
+	if (IS_JOB_PENDING(dump_job_ptr) && dump_job_ptr->details)
+		pack_time(dump_job_ptr->details->begin_time, buffer);
+	else
 		pack_time(dump_job_ptr->start_time, buffer);
 	pack_time(dump_job_ptr->end_time, buffer);
 	pack_time(dump_job_ptr->suspend_time, buffer);
@@ -2961,7 +3157,8 @@ void pack_job(struct job_record *dump_job_ptr, Buf buffer)
 	packstr(dump_job_ptr->account, buffer);
 	packstr(dump_job_ptr->network, buffer);
 	packstr(dump_job_ptr->comment, buffer);
-	pack32(dump_job_ptr->dependency, buffer);
+	packstr(dump_job_ptr->licenses, buffer);
+
 	pack32(dump_job_ptr->exit_code, buffer);
 
 	pack16(dump_job_ptr->num_cpu_groups, buffer);
@@ -2995,16 +3192,36 @@ void pack_job(struct job_record *dump_job_ptr, Buf buffer)
 static void _pack_default_job_details(struct job_details *detail_ptr,
 				      Buf buffer)
 {
+	int i;
+	char *cmd_line = NULL;
+
 	if (detail_ptr) {
-		packstr(detail_ptr->features, buffer);
+		packstr(detail_ptr->features,   buffer);
+		packstr(detail_ptr->work_dir,   buffer);
+		packstr(detail_ptr->dependency, buffer);
+		if (detail_ptr->argv) {
+			for (i=0; detail_ptr->argv[i]; i++) {
+				if (cmd_line)
+					xstrcat(cmd_line, " ");
+				xstrcat(cmd_line, detail_ptr->argv[i]);
+			}
+			packstr(cmd_line, buffer);
+			xfree(cmd_line);
+		} else
+			packnull(buffer);
 
 		pack32(detail_ptr->min_nodes, buffer);
 		pack32(detail_ptr->max_nodes, buffer);
+		pack16(detail_ptr->requeue,   buffer);
 	} else {
 		packnull(buffer);
+		packnull(buffer);
+		packnull(buffer);
+		packnull(buffer);
 
 		pack32((uint32_t) 0, buffer);
 		pack32((uint32_t) 0, buffer);
+		pack16((uint16_t) 0, buffer);
 	}
 }
 
@@ -3019,7 +3236,6 @@ static void _pack_pending_job_details(struct job_details *detail_ptr,
 		pack16(detail_ptr->job_min_procs, buffer);
 
 		pack32(detail_ptr->job_min_memory, buffer);
-		pack32(detail_ptr->job_max_memory, buffer);
 		pack32(detail_ptr->job_min_tmp_disk, buffer);
 
 		packstr(detail_ptr->req_nodes, buffer);
@@ -3037,7 +3253,6 @@ static void _pack_pending_job_details(struct job_details *detail_ptr,
 		pack16((uint16_t) 0, buffer);
 		pack16((uint16_t) 0, buffer);
 
-		pack32((uint32_t) 0, buffer);
 		pack32((uint32_t) 0, buffer);
 		pack32((uint32_t) 0, buffer);
 
@@ -3094,6 +3309,7 @@ void reset_job_bitmaps(void)
 	struct job_record  *job_ptr;
 	struct part_record *part_ptr;
 	bool job_fail = false;
+	time_t now = time(NULL);
 
 	xassert(job_list);
 
@@ -3101,12 +3317,19 @@ void reset_job_bitmaps(void)
 	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
 		xassert (job_ptr->magic == JOB_MAGIC);
 		job_fail = false;
-		part_ptr = list_find_first(part_list, &list_find_part,
-					   job_ptr->partition);
-		if (part_ptr == NULL) {
-			error("Invalid partition (%s) for job_id %u", 
-		    	      job_ptr->partition, job_ptr->job_id);
+
+		if (job_ptr->partition == NULL) {
+			error("No partition for job_id %u", job_ptr->job_id);
+			part_ptr = NULL;
 			job_fail = true;
+		} else {
+			part_ptr = list_find_first(part_list, &list_find_part,
+						   job_ptr->partition);
+			if (part_ptr == NULL) {
+				error("Invalid partition (%s) for job_id %u", 
+		    		      job_ptr->partition, job_ptr->job_id);
+				job_fail = true;
+			}
 		}
 		job_ptr->part_ptr = part_ptr;
 
@@ -3128,12 +3351,6 @@ void reset_job_bitmaps(void)
 		build_node_details(job_ptr);	/* set: num_cpu_groups, 
 						 * cpu_count_reps, node_cnt, 
 						 * cpus_per_node, node_addr */
-		if (select_g_update_nodeinfo(job_ptr) != SLURM_SUCCESS) {
-			error("select_g_update_nodeinfo(%u): %m", 
-				job_ptr->job_id);
-			/* not critical ... ? */
-			/* probably job_fail should be set here */
-		}
 
 		if (_reset_detail_bitmaps(job_ptr))
 			job_fail = true;
@@ -3159,6 +3376,8 @@ void reset_job_bitmaps(void)
 				job_ptr->end_time = job_ptr->suspend_time;
 				job_ptr->job_state = JOB_NODE_FAIL |
 					JOB_COMPLETING;
+				job_ptr->tot_sus_time += 
+					difftime(now, job_ptr->suspend_time);
 			}
 			job_ptr->exit_code = MAX(job_ptr->exit_code, 1);
 			job_ptr->state_reason = FAIL_DOWN_NODE;
@@ -3166,8 +3385,19 @@ void reset_job_bitmaps(void)
 		}
 	}
 
+	list_iterator_reset(job_iterator);
+	/* This will reinitialize the select plugin database, which
+	 * we can only do after ALL job's states and bitmaps are set
+	 * (i.e. it needs to be in this second loop) */
+	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
+		if (select_g_update_nodeinfo(job_ptr) != SLURM_SUCCESS) {
+			error("select_g_update_nodeinfo(%u): %m", 
+				job_ptr->job_id);
+		}
+	}
 	list_iterator_destroy(job_iterator);
-	last_job_update = time(NULL);
+
+	last_job_update = now;
 }
 
 static int _reset_detail_bitmaps(struct job_record *job_ptr)
@@ -3216,7 +3446,9 @@ static void _reset_step_bitmaps(struct job_record *job_ptr)
 			      job_ptr->job_id, step_ptr->step_id);
 			delete_step_record (job_ptr, step_ptr->step_id);
 		}
-	}		
+		if (step_ptr->step_node_bitmap)
+			step_alloc_lps(step_ptr);
+	}
 
 	list_iterator_destroy (step_iterator);
 	return;
@@ -3313,9 +3545,9 @@ void reset_job_priority(void)
 }
 
 /* 
- * _top_priority - determine if any other job for this partition has a 
- *	higher priority than specified job
- * IN job_ptr - pointer to selected partition
+ * _top_priority - determine if any other job has a higher priority than the
+ *	specified job
+ * IN job_ptr - pointer to selected job
  * RET true if selected job has highest priority
  */
 static bool _top_priority(struct job_record *job_ptr)
@@ -3345,8 +3577,11 @@ static bool _top_priority(struct job_record *job_ptr)
 				continue;
 			if (!job_independent(job_ptr2))
 				continue;
-			if ((job_ptr2->priority >  job_ptr->priority) &&
-			    (job_ptr2->part_ptr == job_ptr->part_ptr)) {
+			if ((job_ptr2->part_ptr->priority > 
+			     job_ptr ->part_ptr->priority) ||
+			    ((job_ptr2->part_ptr->priority ==
+			      job_ptr ->part_ptr->priority) &&
+			     (job_ptr2->priority >  job_ptr->priority))) {
 				top = false;
 				break;
 			}
@@ -3694,12 +3929,29 @@ int update_job(job_desc_msg_t * job_specs, uid_t uid)
 		job_specs->comment = NULL;	/* Nothing left to free */
 		info("update_job: setting comment to %s for job_id %u",
 		     job_ptr->comment, job_specs->job_id);
+
+		if (wiki_sched && strstr(job_ptr->comment, "QOS:")) {
+			if (strstr(job_ptr->comment, "FLAGS:PREEMPTOR"))
+				job_ptr->qos = QOS_EXPEDITE;
+			else if (strstr(job_ptr->comment, "FLAGS:PREEMPTEE"))
+				job_ptr->qos = QOS_STANDBY;
+			else
+				job_ptr->qos = QOS_NORMAL;
+		}
 	}
 
 	if (job_specs->name) {
-		strncpy(job_ptr->name, job_specs->name, MAX_JOBNAME_LEN);
+		xfree(job_ptr->name);
+		job_ptr->name = job_specs->name;
+		job_specs->name = NULL;		/* Nothing left to free */
 		info("update_job: setting name to %s for job_id %u",
-		     job_specs->name, job_specs->job_id);
+		     job_ptr->name, job_specs->job_id);
+	}
+
+	if (job_specs->requeue != (uint16_t) NO_VAL) {
+		detail_ptr->requeue = job_specs->requeue;
+		info("update_job: setting requeue to %u for job_id %u",
+		     job_specs->requeue, job_specs->job_id);
 	}
 
 	if (job_specs->partition) {
@@ -3709,8 +3961,25 @@ int update_job(job_desc_msg_t * job_specs, uid_t uid)
 		else if (tmp_part_ptr == NULL)
 			error_code = ESLURM_INVALID_PARTITION_NAME;
 		else if (super_user) {
-			strncpy(job_ptr->partition, job_specs->partition,
-				MAX_SLURM_NAME);
+			acct_association_rec_t assoc_rec, *assoc_ptr;
+			bzero(&assoc_rec, sizeof(acct_association_rec_t));
+			assoc_rec.uid       = job_ptr->user_id;
+			assoc_rec.partition = job_specs->partition;
+			assoc_rec.acct      = job_ptr->account;
+			if (assoc_mgr_fill_in_assoc(acct_db_conn, &assoc_rec,
+						    accounting_enforce, 
+						    &assoc_ptr)) {
+				info("job_update: invalid account %s for job %u",
+				     job_specs->account, job_ptr->job_id);
+				error_code = ESLURM_INVALID_ACCOUNT;
+				/* Let update proceed. Note there is an invalid
+				 * association ID for accounting purposes */
+			} else {
+				job_ptr->assoc_id = assoc_rec.id;
+				job_ptr->assoc_ptr = (void *) assoc_ptr;
+			}
+			xfree(job_ptr->partition);
+			job_ptr->partition = xstrdup(job_specs->partition);
 			job_ptr->part_ptr = tmp_part_ptr;
 			info("update_job: setting partition to %s for "
 			     "job_id %u", job_specs->partition, 
@@ -3781,15 +4050,39 @@ int update_job(job_desc_msg_t * job_specs, uid_t uid)
 	}
 
 	if (job_specs->account) {
-		xfree(job_ptr->account);
-		if (job_specs->account[0] != '\0') {
-			job_ptr->account = job_specs->account;
-			job_specs->account = NULL;  /* Nothing left to free */
-			info("update_job: setting account to %s for job_id %u",
-			     job_ptr->account, job_specs->job_id);
+		if ((!IS_JOB_PENDING(job_ptr)) || (detail_ptr == NULL)) {
+			info("update_job: attempt to modify account for "
+			     "non-pending job_id %u", job_specs->job_id);
+			error_code = ESLURM_DISABLED;
 		} else {
-			info("update_job: cleared account for job_id %u",
-			     job_specs->job_id);
+			acct_association_rec_t assoc_rec, *assoc_ptr;
+			bzero(&assoc_rec, sizeof(acct_association_rec_t));
+
+			assoc_rec.uid       = job_ptr->user_id;
+			assoc_rec.partition = job_ptr->partition;
+			assoc_rec.acct      = job_specs->account;
+			if (assoc_mgr_fill_in_assoc(acct_db_conn, &assoc_rec,
+						    accounting_enforce, 
+						    &assoc_ptr)) {
+				info("job_update: invalid account %s for "
+				     "job_id %u",
+				     job_specs->account, job_ptr->job_id);
+				error_code = ESLURM_INVALID_ACCOUNT;
+			} else {
+				xfree(job_ptr->account);
+				if (assoc_rec.acct[0] != '\0') {
+					job_ptr->account = xstrdup(assoc_rec.acct);
+					info("update_job: setting account to "
+					     "%s for job_id %u",
+					     assoc_rec.acct, job_ptr->job_id);
+				} else {
+					info("update_job: cleared account for "
+					     "job_id %u",
+					     job_specs->job_id);
+				}
+				job_ptr->assoc_id = assoc_rec.id;
+				job_ptr->assoc_ptr = (void *) assoc_ptr;
+			}
 		}
 	}
 
@@ -3808,15 +4101,15 @@ int update_job(job_desc_msg_t * job_specs, uid_t uid)
 		}
 	}
 
-	if (job_specs->dependency != NO_VAL) {
-		if (!IS_JOB_PENDING(job_ptr))
+	if (job_specs->dependency) {
+		if ((!IS_JOB_PENDING(job_ptr)) || (job_ptr->details == NULL))
 			error_code = ESLURM_DISABLED;
-		else if (job_specs->dependency == job_ptr->job_id)
+		else if (update_job_dependency(job_ptr, job_specs->dependency)
+			 != SLURM_SUCCESS) {
 			error_code = ESLURM_DEPENDENCY;
-		else {
-			job_ptr->dependency = job_specs->dependency;
-			info("update_job: setting dependency to %u for " 
-			     "job_id %u",  job_ptr->dependency, 
+		} else {
+			info("update_job: setting dependency to %s for " 
+			     "job_id %u",  job_ptr->details->dependency, 
 			     job_ptr->job_id);
 		}
 	}
@@ -3828,6 +4121,50 @@ int update_job(job_desc_msg_t * job_specs, uid_t uid)
 			error_code = ESLURM_DISABLED;
 	}
 
+	if (job_specs->licenses) {
+		List license_list = NULL;
+		bool valid;
+		license_list = license_job_validate(job_specs->licenses,
+						    &valid);
+
+		if (!valid) {
+			info("update_job: invalid licenses: %s",
+			     job_specs->licenses);
+			error_code = ESLURM_INVALID_LICENSES;
+		} else if (IS_JOB_PENDING(job_ptr)) {
+			if (job_ptr->license_list)
+				list_destroy(job_ptr->license_list);
+			job_ptr->license_list = license_list;
+			xfree(job_ptr->licenses);
+			job_ptr->licenses = job_specs->licenses;
+			job_specs->licenses = NULL; /* nothing to free */
+			info("update_job: setting licenses to %s for job %u",
+			     job_ptr->licenses, job_ptr->job_id);
+		} else if ((job_ptr->job_state == JOB_RUNNING) && super_user) {
+			/* NOTE: This can result in oversubscription of 
+			 * licenses */
+			license_job_return(job_ptr);
+			if (job_ptr->license_list)
+				list_destroy(job_ptr->license_list);
+			job_ptr->license_list = license_list;
+			info("update_job: changing licenses from %s to %s for "
+			     " running job %u",
+			     job_ptr->licenses, job_specs->licenses, 
+			     job_ptr->job_id);
+			xfree(job_ptr->licenses);
+			job_ptr->licenses = job_specs->licenses;
+			job_specs->licenses = NULL; /* nothing to free */
+			license_job_get(job_ptr);
+		} else {
+			/* licenses are valid, but job state or user not
+			 * allowed to make changes */
+			info("update_job: could not change licenses for job %u",
+			     job_ptr->job_id);
+			error_code = ESLURM_DISABLED;
+			list_destroy(license_list);
+		}
+	}
+
 #ifdef HAVE_BG
  {
 	 uint16_t reboot = (uint16_t) NO_VAL;
@@ -3966,50 +4303,49 @@ int update_job(job_desc_msg_t * job_specs, uid_t uid)
 /*
  * validate_jobs_on_node - validate that any jobs that should be on the node 
  *	are actually running, if not clean up the job records and/or node 
- *	records
- * IN node_name - node which should have jobs running
- * IN/OUT job_count - number of jobs which should be running on specified node
- * IN job_id_ptr - pointer to array of job_ids that should be on this node
- * IN step_id_ptr - pointer to array of job step ids that should be on node
+ *	records, call this function after validate_node_specs() sets the node 
+ *	state properly 
+ * IN reg_msg - node registration message
  */
-void
-validate_jobs_on_node(char *node_name, uint32_t * job_count,
-		      uint32_t * job_id_ptr, uint16_t * step_id_ptr)
+extern void validate_jobs_on_node(slurm_node_registration_status_msg_t *reg_msg)
 {
 	int i, node_inx, jobs_on_node;
 	struct node_record *node_ptr;
 	struct job_record *job_ptr;
 	time_t now = time(NULL);
 
-	node_ptr = find_node_record(node_name);
+	node_ptr = find_node_record(reg_msg->node_name);
 	if (node_ptr == NULL) {
-		error("slurmd registered on unknown node %s", node_name);
+		error("slurmd registered on unknown node %s", 
+			reg_msg->node_name);
 		return;
 	}
 	node_inx = node_ptr - node_record_table_ptr;
 
 	/* Check that jobs running are really supposed to be there */
-	for (i = 0; i < *job_count; i++) {
-		if ( (job_id_ptr[i] >= MIN_NOALLOC_JOBID) && 
-		     (job_id_ptr[i] <= MAX_NOALLOC_JOBID) ) {
+	for (i = 0; i < reg_msg->job_count; i++) {
+		if ( (reg_msg->job_id[i] >= MIN_NOALLOC_JOBID) && 
+		     (reg_msg->job_id[i] <= MAX_NOALLOC_JOBID) ) {
 			info("NoAllocate job %u.%u reported on node %s",
-				job_id_ptr[i], step_id_ptr[i], node_name);
+				reg_msg->job_id[i], reg_msg->step_id[i], 
+				reg_msg->node_name);
 			continue;
 		}
 
-		job_ptr = find_job_record(job_id_ptr[i]);
+		job_ptr = find_job_record(reg_msg->job_id[i]);
 		if (job_ptr == NULL) {
 			error("Orphan job %u.%u reported on node %s",
-			      job_id_ptr[i], step_id_ptr[i], node_name);
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+				reg_msg->job_id[i], reg_msg->step_id[i], 
+				reg_msg->node_name);
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 		}
 
 		else if ((job_ptr->job_state == JOB_RUNNING) ||
-				(job_ptr->job_state == JOB_SUSPENDED)) {
+			 (job_ptr->job_state == JOB_SUSPENDED)) {
 			if (bit_test(job_ptr->node_bitmap, node_inx)) {
 				debug3("Registered job %u.%u on node %s ",
-				       job_id_ptr[i], step_id_ptr[i], 
-				       node_name);
+				       reg_msg->job_id[i], reg_msg->step_id[i], 
+				       reg_msg->node_name);
 				if ((job_ptr->batch_flag) &&
 				    (node_inx == bit_ffs(
 						job_ptr->node_bitmap))) {
@@ -4018,10 +4354,10 @@ validate_jobs_on_node(char *node_name, uint32_t * job_count,
 					job_ptr->time_last_active = now;
 				}
 			} else {
-				error
-				    ("Registered job %u.%u on wrong node %s ",
-				     job_id_ptr[i], step_id_ptr[i], node_name);
-				kill_job_on_node(job_id_ptr[i], job_ptr, 
+				error("Registered job %u.%u on wrong node %s ",
+					reg_msg->job_id[i], reg_msg->step_id[i],
+					reg_msg->node_name);
+				kill_job_on_node(reg_msg->job_id[i], job_ptr, 
 						node_ptr);
 			}
 		}
@@ -4029,19 +4365,20 @@ validate_jobs_on_node(char *node_name, uint32_t * job_count,
 		else if (job_ptr->job_state & JOB_COMPLETING) {
 			/* Re-send kill request as needed, 
 			 * not necessarily an error */
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 		}
 
 
 		else if (job_ptr->job_state == JOB_PENDING) {
 			error("Registered PENDING job %u.%u on node %s ",
-			      job_id_ptr[i], step_id_ptr[i], node_name);
+				reg_msg->job_id[i], reg_msg->step_id[i], 
+				reg_msg->node_name);
 			job_ptr->job_state = JOB_FAILED;
 			job_ptr->exit_code = 1;
 			job_ptr->state_reason = FAIL_SYSTEM;
-			last_job_update    = now;
+			last_job_update = now;
 			job_ptr->start_time = job_ptr->end_time  = now;
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 			job_completion_logger(job_ptr);
 			delete_job_details(job_ptr);
 		}
@@ -4049,10 +4386,10 @@ validate_jobs_on_node(char *node_name, uint32_t * job_count,
 		else {		/* else job is supposed to be done */
 			error
 			    ("Registered job %u.%u in state %s on node %s ",
-			     job_id_ptr[i], step_id_ptr[i], 
+			     reg_msg->job_id[i], reg_msg->step_id[i], 
 			     job_state_string(job_ptr->job_state),
-			     node_name);
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+			     reg_msg->node_name);
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 		}
 	}
 
@@ -4060,14 +4397,14 @@ validate_jobs_on_node(char *node_name, uint32_t * job_count,
 	if (jobs_on_node)
 		_purge_lost_batch_jobs(node_inx, now);
 
-	if (jobs_on_node != *job_count) {
+	if (jobs_on_node != reg_msg->job_count) {
 		/* slurmd will not know of a job unless the job has
 		 * steps active at registration time, so this is not 
 		 * an error condition, slurmd is also reporting steps 
 		 * rather than jobs */
 		debug3("resetting job_count on node %s from %d to %d", 
-		     node_name, *job_count, jobs_on_node);
-		*job_count = jobs_on_node;
+			reg_msg->node_name, reg_msg->job_count, jobs_on_node);
+		reg_msg->job_count = jobs_on_node;
 	}
 
 	return;
@@ -4155,6 +4492,9 @@ job_alloc_info(uint32_t uid, uint32_t job_id, struct job_record **job_pptr)
 	if ((job_ptr->user_id != uid) && 
 	    (uid != 0) && (uid != slurmctld_conf.slurm_user_id))
 		return ESLURM_ACCESS_DENIED;
+	if (slurmctld_conf.private_data
+	&&  (job_ptr->user_id != uid) && !validate_super_user(uid))
+		return ESLURM_ACCESS_DENIED;
 	if (IS_JOB_PENDING(job_ptr))
 		return ESLURM_JOB_PENDING;
 	if (IS_JOB_FINISHED(job_ptr))
@@ -4415,6 +4755,10 @@ extern void job_completion_logger(struct job_record  *job_ptr)
 	int base_state;
 	xassert(job_ptr);
 
+	/* make sure all parts of the job are notified */
+	srun_job_complete(job_ptr);
+	
+	/* mail out notifications of completion */
 	base_state = job_ptr->job_state & (~JOB_COMPLETING);
 	if ((base_state == JOB_COMPLETE) || (base_state == JOB_CANCELLED)) {
 		if (job_ptr->mail_type & MAIL_JOB_END)
@@ -4425,7 +4769,7 @@ extern void job_completion_logger(struct job_record  *job_ptr)
 	}
 
 	g_slurm_jobcomp_write(job_ptr);
-	srun_job_complete(job_ptr);
+	jobacct_storage_g_job_complete(acct_db_conn, job_ptr);
 }
 
 /*
@@ -4436,47 +4780,50 @@ extern void job_completion_logger(struct job_record  *job_ptr)
  */
 extern bool job_independent(struct job_record *job_ptr)
 {
-	struct job_record *dep_ptr;
 	struct job_details *detail_ptr = job_ptr->details;
 	time_t now = time(NULL);
-	bool send_acct_rec = false;
+	int rc;
 
 	if (detail_ptr && (detail_ptr->begin_time > now)) {
 		job_ptr->state_reason = WAIT_TIME;
 		return false;	/* not yet time */
 	}
 
-	if (job_ptr->dependency == 0)
-		goto indi;
-
-	dep_ptr = find_job_record(job_ptr->dependency);
-	if (dep_ptr == NULL)
-		goto indi;
-
-	if (((dep_ptr->job_state & JOB_COMPLETING) == 0) &&
-	    (dep_ptr->job_state >= JOB_COMPLETE))
-		goto indi;
-
-	job_ptr->state_reason = WAIT_DEPENDENCY;
-	return false;	/* job exists and incomplete */
-
- indi:	/* job is independent, set begin time as needed */
-	if (detail_ptr && (detail_ptr->begin_time == 0)) {
-		detail_ptr->begin_time = now;
-		send_acct_rec = true;
-	} else if (job_ptr->state_reason == WAIT_TIME) {
-		job_ptr->state_reason = WAIT_NO_REASON;
-		send_acct_rec = true;
-	}
-	if (send_acct_rec) {
-		/* We want to record when a job becomes eligible in
-		 * order to calculate reserved time (a measure of
-		 * system over-subscription), job really is not
-		 * starting now */
-		jobacct_g_job_start_slurmctld(job_ptr);
+	rc = test_job_dependency(job_ptr);
+	if (rc == 0) {
+		bool send_acct_rec = false;
+		if (job_ptr->state_reason == WAIT_DEPENDENCY)
+			job_ptr->state_reason = WAIT_NO_REASON;
+		if (detail_ptr && (detail_ptr->begin_time == 0)) {
+			detail_ptr->begin_time = now;
+			send_acct_rec = true;
+		} else if (job_ptr->state_reason == WAIT_TIME) {
+			job_ptr->state_reason = WAIT_NO_REASON;
+			send_acct_rec = true;
+		}
+		if (send_acct_rec) {
+			/* We want to record when a job becomes eligible in
+			 * order to calculate reserved time (a measure of
+			 * system over-subscription), job really is not
+			 * starting now */
+			jobacct_storage_g_job_start(acct_db_conn, job_ptr);
+		}
+		return true;
+	} else if (rc == 1) {
+		job_ptr->state_reason = WAIT_DEPENDENCY;
+		return false;
+	} else {	/* rc == 2 */
+		time_t now = time(NULL);
+		info("Job dependency can't be satisfied, cancelling job %u",
+			job_ptr->job_id);
+		job_ptr->job_state	= JOB_CANCELLED;
+		job_ptr->start_time	= now;
+		job_ptr->end_time	= now;
+		job_completion_logger(job_ptr);
+		return false;
 	}
-	return true;
 }
+
 /*
  * determine if job is ready to execute per the node select plugin
  * IN job_id - job to test
@@ -4588,11 +4935,21 @@ static void _suspend_job(struct job_record *job_ptr, uint16_t op)
 /* Specified job is being suspended, release allocated nodes */
 static int _suspend_job_nodes(struct job_record *job_ptr)
 {
-	int i, rc;
+	int i, rc = SLURM_SUCCESS;
 	struct node_record *node_ptr = node_record_table_ptr;
 	uint16_t base_state, node_flags;
+	static bool sched_gang_test = false;
+	static bool sched_gang = false;
 
-	if ((rc = select_g_job_suspend(job_ptr)) != SLURM_SUCCESS)
+	if (!sched_gang_test) {
+		char *sched_type = slurm_get_sched_type();
+		if (strcmp(sched_type, "sched/gang") == 0)
+			sched_gang = true;
+		xfree(sched_type);
+		sched_gang_test = true;
+	}
+	if ((sched_gang == false) &&
+	    ((rc = select_g_job_suspend(job_ptr)) != SLURM_SUCCESS))
 		return rc;
 
 	for (i=0; i<node_record_count; i++, node_ptr++) {
@@ -4640,11 +4997,21 @@ static int _suspend_job_nodes(struct job_record *job_ptr)
 /* Specified job is being resumed, re-allocate the nodes */
 static int _resume_job_nodes(struct job_record *job_ptr)
 {
-	int i, rc;
+	int i, rc = SLURM_SUCCESS;
 	struct node_record *node_ptr = node_record_table_ptr;
 	uint16_t base_state, node_flags;
+	static bool sched_gang_test = false;
+	static bool sched_gang = false;
 
-	if ((rc = select_g_job_resume(job_ptr)) != SLURM_SUCCESS)
+	if (!sched_gang_test) {
+		char *sched_type = slurm_get_sched_type();
+		if (strcmp(sched_type, "sched/gang") == 0)
+			sched_gang = true;
+		xfree(sched_type);
+		sched_gang_test = true;
+	}
+	if ((sched_gang == false) &&
+	    ((rc = select_g_job_resume(job_ptr)) != SLURM_SUCCESS))
 		return rc;
 
 	for (i=0; i<node_record_count; i++, node_ptr++) {
@@ -4761,17 +5128,20 @@ extern int job_suspend(suspend_msg_t *sus_ptr, uid_t uid,
 			goto reply;
 		_suspend_job(job_ptr, sus_ptr->op);
 		job_ptr->job_state = JOB_RUNNING;
+		job_ptr->tot_sus_time +=
+			difftime(now, job_ptr->suspend_time);
 		if (job_ptr->time_limit != INFINITE) {
 			/* adjust effective time_limit */
 			job_ptr->end_time = now +
 				(job_ptr->time_limit * 60)
 				- job_ptr->pre_sus_time;
 		}
+		resume_job_step(job_ptr);
 	}
 
 	job_ptr->time_last_active = now;
 	job_ptr->suspend_time = now;
-	jobacct_g_suspend_slurmctld(job_ptr);
+	jobacct_storage_g_job_suspend(acct_db_conn, job_ptr);
 
     reply:
 	if (conn_fd >= 0) {
@@ -4818,7 +5188,7 @@ extern int job_requeue (uid_t uid, uint32_t job_id, slurm_fd conn_fd)
 		rc = ESLURM_ALREADY_DONE;
 		goto reply;
 	}
-	if ((job_ptr->details == NULL) || job_ptr->details->no_requeue) {
+	if ((job_ptr->details == NULL) || (job_ptr->details->requeue == 0)) {
 		rc = ESLURM_DISABLED;
 		goto reply;
 	}
@@ -4829,6 +5199,7 @@ extern int job_requeue (uid_t uid, uint32_t job_id, slurm_fd conn_fd)
 
 	/* reset the priority */
 	_set_job_prio(job_ptr);
+	slurm_sched_requeue(job_ptr, "Job requeued by user/admin");
 	last_job_update = now;
 
 	/* nothing else to do if pending */
@@ -4921,3 +5292,53 @@ extern void update_job_nodes_completing(void)
 	}
 	list_iterator_destroy(job_iterator);
 }
+
+static bool _validate_acct_policy(job_desc_msg_t *job_desc,
+				  struct part_record *part_ptr,
+				  acct_association_rec_t *assoc_ptr)
+{
+	uint32_t time_limit;
+
+	//log_assoc_rec(assoc_ptr);
+	if ((assoc_ptr->max_wall_duration_per_job != NO_VAL) &&
+	    (assoc_ptr->max_wall_duration_per_job != INFINITE)) {
+		time_limit = assoc_ptr->max_wall_duration_per_job;
+		if (job_desc->time_limit == NO_VAL) {
+			if (part_ptr->max_time == INFINITE)
+				job_desc->time_limit = time_limit;
+			else
+				job_desc->time_limit = MIN(time_limit, 
+							   part_ptr->max_time);
+		} else if (job_desc->time_limit > time_limit) {
+			info("job for user %u: "
+			     "time limit %u exceeds account max %u",
+			     job_desc->user_id, 
+			     job_desc->time_limit, time_limit);
+			return false;
+		}
+	}
+
+	if ((assoc_ptr->max_nodes_per_job != NO_VAL) &&
+	    (assoc_ptr->max_nodes_per_job != INFINITE)) {
+		if (job_desc->max_nodes == 0)
+			job_desc->max_nodes = assoc_ptr->max_nodes_per_job;
+		else if (job_desc->max_nodes > assoc_ptr->max_nodes_per_job) {
+			if (job_desc->min_nodes > 
+			    assoc_ptr->max_nodes_per_job) {
+				info("job %u for user %u: "
+				     "node limit %u exceeds account max %u",
+				     job_desc->job_id, job_desc->user_id, 
+				     job_desc->min_nodes, 
+				     assoc_ptr->max_nodes_per_job);
+				return false;
+			}
+			job_desc->max_nodes = assoc_ptr->max_nodes_per_job;
+		}
+	}
+
+	/* NOTE: We can't enforce assoc_ptr->max_cpu_secs_per_job at this
+	 * time because we don't have access to a CPU count for the job
+	 * due to how all of the job's specifications interact */
+
+	return true;
+}
diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c
index c093a9c374e6f2723017ef04843e5f31110cac90..0d496b23e2b8f7825b117ed6f30c4e4d9fc44db6 100644
--- a/src/slurmctld/job_scheduler.c
+++ b/src/slurmctld/job_scheduler.c
@@ -2,10 +2,10 @@
  * job_scheduler.c - manage the scheduling of pending jobs in priority order
  *	Note there is a global job list (job_list)
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -46,39 +46,35 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "src/common/assoc_mgr.h"
 #include "src/common/list.h"
 #include "src/common/macros.h"
 #include "src/common/node_select.h"
+#include "src/common/slurm_accounting_storage.h"
 #include "src/common/xassert.h"
 #include "src/common/xstring.h"
 
 #include "src/slurmctld/agent.h"
+#include "src/slurmctld/job_scheduler.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/node_scheduler.h"
 #include "src/slurmctld/slurmctld.h"
 #include "src/slurmctld/srun_comm.h"
 
+#define _DEBUG 0
 #define MAX_RETRIES 10
 
-struct job_queue {
-	int priority;
-	struct job_record *job_ptr;
-};
-
-static int  _build_job_queue(struct job_queue **job_queue);
-static void _launch_job(struct job_record *job_ptr);
-static void _sort_job_queue(struct job_queue *job_queue,
-			    int job_queue_size);
+static void _depend_list_del(void *dep_ptr);
 static char **_xduparray(uint16_t size, char ** array);
 
 /* 
- * _build_job_queue - build (non-priority ordered) list of pending jobs
+ * build_job_queue - build (non-priority ordered) list of pending jobs
  * OUT job_queue - pointer to job queue
  * RET number of entries in job_queue
- * global: job_list - global list of job records
  * NOTE: the buffer at *job_queue must be xfreed by the caller
  */
-static int _build_job_queue(struct job_queue **job_queue)
+extern int build_job_queue(struct job_queue **job_queue)
 {
 	ListIterator job_iterator;
 	struct job_record *job_ptr = NULL;
@@ -96,15 +92,17 @@ static int _build_job_queue(struct job_queue **job_queue)
 		    (job_ptr->job_state &  JOB_COMPLETING) ||
 		    (job_ptr->priority == 0))	/* held */
 			continue;
-		if (!job_independent(job_ptr))	/* waiting for other job */
+		if (!job_independent(job_ptr))	/* can not run now */
 			continue;
 		if (job_buffer_size <= job_queue_size) {
-			job_buffer_size += 50;
+			job_buffer_size += 200;
 			xrealloc(my_job_queue, job_buffer_size *
 				 sizeof(struct job_queue));
 		}
 		my_job_queue[job_queue_size].job_ptr  = job_ptr;
-		my_job_queue[job_queue_size].priority = job_ptr->priority;
+		my_job_queue[job_queue_size].job_priority = job_ptr->priority;
+		my_job_queue[job_queue_size].part_priority = 
+						job_ptr->part_ptr->priority;
 		job_queue_size++;
 	}
 	list_iterator_destroy(job_iterator);
@@ -177,24 +175,68 @@ extern void set_job_elig_time(void)
 	unlock_slurmctld(job_write_lock);
 }
 
+/* Test of part_ptr can still run jobs or if its nodes have
+ * already been reserved by higher priority jobs (those in
+ * the failed_parts array) */
+static bool _failed_partition(struct part_record *part_ptr,
+			      struct part_record **failed_parts, 
+			      int failed_part_cnt)
+{
+	int i;
+
+	for (i = 0; i < failed_part_cnt; i++) {
+		if (failed_parts[i] == part_ptr)
+			return true;
+	}
+	return false;
+}
+
+#ifndef HAVE_BG
+/* Add a partition to the failed_parts array, reserving its nodes
+ * from use by lower priority jobs. Also flags all partitions with
+ * nodes overlapping this partition. */
+static void _add_failed_partition(struct part_record *failed_part_ptr, 
+			      struct part_record **failed_parts, 
+			      int *failed_part_cnt)
+{
+	int count = *failed_part_cnt;
+	ListIterator part_iterator;
+	struct part_record *part_ptr;
+
+	failed_parts[count++] = failed_part_ptr;
+
+	/* We also need to add partitions that have overlapping nodes */
+	part_iterator = list_iterator_create(part_list);
+	while ((part_ptr = (struct part_record *) list_next(part_iterator))) {
+		if ((part_ptr == failed_part_ptr) ||
+		    (_failed_partition(part_ptr, failed_parts, count)) ||
+		    (!bit_super_set(failed_part_ptr->node_bitmap,
+				    part_ptr->node_bitmap)))
+			continue;
+		failed_parts[count++] = part_ptr;
+	}
+	list_iterator_destroy(part_iterator);
+
+	*failed_part_cnt = count;
+}
+#endif
+
 /* 
  * schedule - attempt to schedule all pending jobs
  *	pending jobs for each partition will be scheduled in priority  
  *	order until a request fails
  * RET count of jobs scheduled
- * global: job_list - global list of job records
- *	last_job_update - time of last update to job table
  * Note: We re-build the queue every time. Jobs can not only be added 
  *	or removed from the queue, but have their priority or partition 
  *	changed with the update_job RPC. In general nodes will be in priority 
  *	order (by submit time), so the sorting should be pretty fast.
  */
-int schedule(void)
+extern int schedule(void)
 {
 	struct job_queue *job_queue;
-	int i, j, error_code, failed_part_cnt, job_queue_size, job_cnt = 0;
+	int i, error_code, failed_part_cnt = 0, job_queue_size, job_cnt = 0;
 	struct job_record *job_ptr;
-	struct part_record **failed_parts;
+	struct part_record **failed_parts = NULL;
 	/* Locks: Read config, write job, write node, read partition */
 	slurmctld_lock_t job_write_lock =
 	    { READ_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK };
@@ -227,25 +269,48 @@ int schedule(void)
 		return SLURM_SUCCESS;
 	}
 	debug("Running job scheduler");
-	job_queue_size = _build_job_queue(&job_queue);
+	job_queue_size = build_job_queue(&job_queue);
 	if (job_queue_size == 0) {
 		unlock_slurmctld(job_write_lock);
 		return SLURM_SUCCESS;
 	}
-	_sort_job_queue(job_queue, job_queue_size);
+	sort_job_queue(job_queue, job_queue_size);
+
+	failed_parts = xmalloc(sizeof(struct part_record *) * 
+			       list_count(part_list));
 
-	failed_part_cnt = 0;
-	failed_parts = NULL;
 	for (i = 0; i < job_queue_size; i++) {
 		job_ptr = job_queue[i].job_ptr;
 		if (job_ptr->priority == 0)	/* held */
 			continue;
-		for (j = 0; j < failed_part_cnt; j++) {
-			if (failed_parts[j] == job_ptr->part_ptr)
-				break;
+		if (_failed_partition(job_ptr->part_ptr, failed_parts, 
+				      failed_part_cnt)) {
+			job_ptr->state_reason = WAIT_PRIORITY;
+			continue;
 		}
-		if (j < failed_part_cnt)
+
+		if (license_job_test(job_ptr) != SLURM_SUCCESS) {
+			job_ptr->state_reason = WAIT_LICENSES;
 			continue;
+		}
+
+		if (assoc_mgr_validate_assoc_id(acct_db_conn, job_ptr->assoc_id,
+						accounting_enforce)) {
+			/* NOTE: This only happens if a user's account is 
+			 * disabled between when the job was submitted and 
+			 * the time we consider running it. It should be 
+			 * very rare. */
+			info("schedule: JobId=%u has invalid account",
+				job_ptr->job_id);
+			last_job_update = time(NULL);		
+			job_ptr->job_state = JOB_FAILED;
+			job_ptr->exit_code = 1;
+			job_ptr->state_reason = FAIL_BANK_ACCOUNT;
+			job_ptr->start_time = job_ptr->end_time = time(NULL);
+			job_completion_logger(job_ptr);
+			delete_job_details(job_ptr);
+			continue;
+		}
 
 		error_code = select_nodes(job_ptr, false, NULL);
 		if (error_code == ESLURM_NODES_BUSY) {
@@ -263,11 +328,8 @@ int schedule(void)
 			 * group all Blue Gene job partitions of type 
 			 * 2x2x2 coprocessor mesh into a single SLURM
 			 * partition, say "co-mesh-222") */
-			xrealloc(failed_parts,
-				 (failed_part_cnt + 1) * 
-				 sizeof(struct part_record *));
-			failed_parts[failed_part_cnt++] =
-			    job_ptr->part_ptr;
+			_add_failed_partition(job_ptr->part_ptr, failed_parts,
+				      &failed_part_cnt);
 #endif
 		} else if (error_code == SLURM_SUCCESS) {	
 			/* job initiated */
@@ -278,8 +340,7 @@ int schedule(void)
 					     &ionodes);
 			if(ionodes) {
 				sprintf(tmp_char,"%s[%s]",
-						job_ptr->nodes,
-						ionodes);
+					job_ptr->nodes, ionodes);
 			} else {
 				sprintf(tmp_char,"%s",job_ptr->nodes);
 			}
@@ -291,7 +352,7 @@ int schedule(void)
 			     job_ptr->job_id, job_ptr->nodes);
 #endif
 			if (job_ptr->batch_flag)
-				_launch_job(job_ptr);
+				launch_job(job_ptr);
 			else
 				srun_allocate(job_ptr->job_id);
 			job_cnt++;
@@ -321,40 +382,57 @@ int schedule(void)
 
 
 /* 
- * _sort_job_queue - sort job_queue in decending priority order
+ * sort_job_queue - sort job_queue in decending priority order
  * IN job_queue_size - count of elements in the job queue
  * IN/OUT job_queue - pointer to sorted job queue
  */
-static void _sort_job_queue(struct job_queue *job_queue, int job_queue_size)
+extern void sort_job_queue(struct job_queue *job_queue, int job_queue_size)
 {
 	int i, j, top_prio_inx;
-	int tmp_prio, top_prio;
 	struct job_record *tmp_job_ptr;
+	uint32_t top_job_prio,  tmp_job_prio;
+	uint16_t top_part_prio, tmp_part_prio;
 
 	for (i = 0; i < job_queue_size; i++) {
-		top_prio = job_queue[i].priority;
-		top_prio_inx = i;
+		top_prio_inx  = i;
+		top_job_prio  = job_queue[i].job_priority;
+		top_part_prio = job_queue[i].part_priority;
+
 		for (j = (i + 1); j < job_queue_size; j++) {
-			if (top_prio >= job_queue[j].priority)
+			if (top_part_prio > job_queue[j].part_priority)
 				continue;
-			top_prio = job_queue[j].priority;
-			top_prio_inx = j;
+			if ((top_part_prio == job_queue[j].part_priority) &&
+			    (top_job_prio  >= job_queue[j].job_priority))
+				continue;
+
+			top_prio_inx  = j;
+			top_job_prio  = job_queue[j].job_priority;
+			top_part_prio = job_queue[j].part_priority;
 		}
 		if (top_prio_inx == i)
-			continue;
-		tmp_prio = job_queue[i].priority;
-		tmp_job_ptr = job_queue[i].job_ptr;
-		job_queue[i].priority = job_queue[top_prio_inx].priority;
-		job_queue[i].job_ptr = job_queue[top_prio_inx].job_ptr;
-		job_queue[top_prio_inx].priority = tmp_prio;
-		job_queue[top_prio_inx].job_ptr = tmp_job_ptr;
+			continue;	/* in correct order */
+
+		/* swap records at top_prio_inx and i */
+		tmp_job_ptr   = job_queue[i].job_ptr;
+		tmp_job_prio  = job_queue[i].job_priority;
+		tmp_part_prio = job_queue[i].part_priority;
+
+		job_queue[i].job_ptr       = job_queue[top_prio_inx].job_ptr;
+		job_queue[i].job_priority  = job_queue[top_prio_inx].job_priority;
+		job_queue[i].part_priority = job_queue[top_prio_inx].part_priority;
+
+		job_queue[top_prio_inx].job_ptr       = tmp_job_ptr;
+		job_queue[top_prio_inx].job_priority  = tmp_job_prio;
+		job_queue[top_prio_inx].part_priority = tmp_part_prio;
+
 	}
 }
 
-/* _launch_job - send an RPC to a slurmd to initiate a batch job 
+/*
+ * launch_job - send an RPC to a slurmd to initiate a batch job 
  * IN job_ptr - pointer to job that will be initiated
  */
-static void _launch_job(struct job_record *job_ptr)
+extern void launch_job(struct job_record *job_ptr)
 {
 	batch_job_launch_msg_t *launch_msg_ptr;
 	agent_arg_t *agent_arg_ptr;
@@ -365,9 +443,8 @@ static void _launch_job(struct job_record *job_ptr)
 		return;
 
 	/* Initialization of data structures */
-	launch_msg_ptr =
-	    (batch_job_launch_msg_t *)
-	    xmalloc(sizeof(batch_job_launch_msg_t));
+	launch_msg_ptr = (batch_job_launch_msg_t *)
+				xmalloc(sizeof(batch_job_launch_msg_t));
 	launch_msg_ptr->job_id = job_ptr->job_id;
 	launch_msg_ptr->step_id = NO_VAL;
 	launch_msg_ptr->uid = job_ptr->user_id;
@@ -375,6 +452,8 @@ static void _launch_job(struct job_record *job_ptr)
 	launch_msg_ptr->nprocs = job_ptr->details->num_tasks;
 	launch_msg_ptr->nodes = xstrdup(job_ptr->nodes);
 	launch_msg_ptr->overcommit = job_ptr->details->overcommit;
+	launch_msg_ptr->open_mode  = job_ptr->details->open_mode;
+	launch_msg_ptr->acctg_freq = job_ptr->details->acctg_freq;
 
 	if (make_batch_job_cred(launch_msg_ptr)) {
 		error("aborting batch job %u", job_ptr->job_id);
@@ -398,7 +477,7 @@ static void _launch_job(struct job_record *job_ptr)
 	launch_msg_ptr->script = get_job_script(job_ptr);
 	launch_msg_ptr->environment =
 	    get_job_env(job_ptr, &launch_msg_ptr->envc);
-
+	launch_msg_ptr->job_mem = job_ptr->details->job_min_memory;
 	launch_msg_ptr->num_cpu_groups = job_ptr->num_cpu_groups;
 	launch_msg_ptr->cpus_per_node  = xmalloc(sizeof(uint32_t) *
 			job_ptr->num_cpu_groups);
@@ -463,3 +542,324 @@ extern int make_batch_job_cred(batch_job_launch_msg_t *launch_msg_ptr)
 	error("slurm_cred_create failure for batch job %u", cred_arg.jobid);
 	return SLURM_ERROR;
 }
+
+static void _depend_list_del(void *dep_ptr)
+{
+	xfree(dep_ptr);
+}
+
+/* Print a job's dependency information based upon job_ptr->depend_list */
+extern void print_job_dependency(struct job_record *job_ptr)
+{
+	ListIterator depend_iter;
+	struct depend_spec *dep_ptr;
+	char *dep_str;
+
+	info("Dependency information for job %u", job_ptr->job_id);
+	if ((job_ptr->details == NULL) ||
+	    (job_ptr->details->depend_list == NULL))
+		return;
+
+	depend_iter = list_iterator_create(job_ptr->details->depend_list);
+	if (!depend_iter)
+		fatal("list_iterator_create memory allocation failure");
+	while ((dep_ptr = list_next(depend_iter))) {
+		if      (dep_ptr->depend_type == SLURM_DEPEND_AFTER)
+			dep_str = "after";
+		else if (dep_ptr->depend_type == SLURM_DEPEND_AFTER_ANY)
+			dep_str = "afterany";
+		else if (dep_ptr->depend_type == SLURM_DEPEND_AFTER_NOT_OK)
+			dep_str = "afternotok";
+		else if (dep_ptr->depend_type == SLURM_DEPEND_AFTER_OK)
+			dep_str = "afterok";
+		else
+			dep_str = "unknown";
+		info("  %s:%u", dep_str, dep_ptr->job_id);
+	}
+	list_iterator_destroy(depend_iter);
+}
+
+/*
+ * Determine if a job's dependencies are met
+ * RET: 0 = no dependencies
+ *      1 = dependencies remain
+ *      2 = failure (job completion code not per dependency), delete the job
+ */
+extern int test_job_dependency(struct job_record *job_ptr)
+{
+	ListIterator depend_iter;
+	struct depend_spec *dep_ptr;
+	bool failure = false;
+
+	if ((job_ptr->details == NULL) ||
+	    (job_ptr->details->depend_list == NULL))
+		return 0;
+
+	depend_iter = list_iterator_create(job_ptr->details->depend_list);
+	if (!depend_iter)
+		fatal("list_iterator_create memory allocation failure");
+	while ((dep_ptr = list_next(depend_iter))) {
+		if (dep_ptr->job_ptr->job_id != dep_ptr->job_id) {
+			/* job is gone, dependency lifted */
+			list_delete_item(depend_iter);
+		} else if (dep_ptr->depend_type == SLURM_DEPEND_AFTER) {
+			if (!IS_JOB_PENDING(dep_ptr->job_ptr))
+				list_delete_item(depend_iter);
+			else
+				break;
+		} else if (dep_ptr->depend_type == SLURM_DEPEND_AFTER_ANY) {
+			if (IS_JOB_FINISHED(dep_ptr->job_ptr))
+				list_delete_item(depend_iter);
+			else
+				break;
+		} else if (dep_ptr->depend_type == SLURM_DEPEND_AFTER_NOT_OK) {
+			if (!IS_JOB_FINISHED(dep_ptr->job_ptr))
+				break;
+			if ((dep_ptr->job_ptr->job_state & (~JOB_COMPLETING))
+			    != JOB_COMPLETE)
+				list_delete_item(depend_iter);
+			else {
+				failure = true;
+				break;
+			}
+		} else if (dep_ptr->depend_type == SLURM_DEPEND_AFTER_OK) {
+			if (!IS_JOB_FINISHED(dep_ptr->job_ptr))
+				break;
+			if ((dep_ptr->job_ptr->job_state & (~JOB_COMPLETING))
+			    == JOB_COMPLETE)
+				list_delete_item(depend_iter);
+			else {
+				failure = true;
+				break;
+			}
+		} else
+			failure = true;
+	}
+	list_iterator_destroy(depend_iter);
+
+	if (failure)
+		return 2;
+	if (dep_ptr)
+		return 1;
+	return 0;
+}
+
+/*
+ * Parse a job dependency string and use it to establish a "depend_spec" 
+ * list of dependencies. We accept both old format (a single job ID) and
+ * new format (e.g. "afterok:123:124,after:128").
+ * IN job_ptr - job record to have dependency and depend_list updated
+ * IN new_depend - new dependency description
+ * RET returns an error code from slurm_errno.h
+ */
+extern int update_job_dependency(struct job_record *job_ptr, char *new_depend)
+{
+	int rc = SLURM_SUCCESS;
+	uint16_t depend_type = 0;
+	uint32_t job_id = 0;
+	char *tok = new_depend, *sep_ptr, *sep_ptr2;
+	List new_depend_list = NULL;
+	struct depend_spec *dep_ptr;
+	struct job_record *dep_job_ptr;
+	char dep_buf[32];
+
+	if (job_ptr->details == NULL)
+		return EINVAL;
+
+	/* Clear dependencies on NULL or empty dependency input */
+	if ((new_depend == NULL) || (new_depend[0] == '\0')) {
+		xfree(job_ptr->details->dependency);
+		if (job_ptr->details->depend_list)
+			list_destroy(job_ptr->details->depend_list);
+		return rc;
+
+	}
+
+	new_depend_list = list_create(_depend_list_del);
+	/* validate new dependency string */
+	while (rc == SLURM_SUCCESS) {
+		sep_ptr = strchr(tok, ':');
+		if ((sep_ptr == NULL) && (job_id == 0)) {
+			job_id = strtol(tok, &sep_ptr, 10);
+			if ((sep_ptr == NULL) || (sep_ptr[0] != '\0') ||
+			    (job_id <= 0) || (job_id == job_ptr->job_id)) {
+				rc = EINVAL;
+				break;
+			}
+			/* old format, just a single job_id */
+			dep_job_ptr = find_job_record(job_id);
+			if (!dep_job_ptr)	/* assume already done */
+				break;
+			snprintf(dep_buf, sizeof(dep_buf), "afterany:%u", job_id);
+			new_depend = dep_buf;
+			dep_ptr = xmalloc(sizeof(struct depend_spec));
+			dep_ptr->depend_type = SLURM_DEPEND_AFTER_ANY;
+			dep_ptr->job_id = job_id;
+			dep_ptr->job_ptr = dep_job_ptr;
+			if (!list_append(new_depend_list, dep_ptr))
+				fatal("list_append memory allocation failure");
+			break;
+		}
+
+		if      (strncasecmp(tok, "afternotok", 10) == 0)
+			depend_type = SLURM_DEPEND_AFTER_NOT_OK;
+		else if (strncasecmp(tok, "afterany", 8) == 0)
+			depend_type = SLURM_DEPEND_AFTER_ANY;
+		else if (strncasecmp(tok, "afterok", 7) == 0)
+			depend_type = SLURM_DEPEND_AFTER_OK;
+		else if (strncasecmp(tok, "after", 5) == 0)
+			depend_type = SLURM_DEPEND_AFTER;
+		else {
+			rc = EINVAL;
+			break;
+		}
+		sep_ptr++;	/* skip over ":" */
+		while (rc == SLURM_SUCCESS) {
+			job_id = strtol(sep_ptr, &sep_ptr2, 10);
+			if ((sep_ptr2 == NULL) || 
+			    (job_id <= 0) || (job_id == job_ptr->job_id) ||
+			    ((sep_ptr2[0] != '\0') && (sep_ptr2[0] != ',') && 
+			     (sep_ptr2[0] != ':'))) {
+				rc = EINVAL;
+				break;
+			}
+			dep_job_ptr = find_job_record(job_id);
+			if (dep_job_ptr) {	/* job still active */
+				dep_ptr = xmalloc(sizeof(struct depend_spec));
+				dep_ptr->depend_type = depend_type;
+				dep_ptr->job_id = job_id;
+				dep_ptr->job_ptr = dep_job_ptr;
+				if (!list_append(new_depend_list, dep_ptr)) {
+					fatal("list_append memory allocation "
+						"failure");
+				}
+			}
+			if (sep_ptr2[0] != ':')
+				break;
+			sep_ptr = sep_ptr2 + 1;	/* skip over ":" */
+		}
+		if (sep_ptr2[0] == ',')
+			tok = sep_ptr2 + 1;
+		else
+			break;
+	}
+
+	if (rc == SLURM_SUCCESS) {
+		xfree(job_ptr->details->dependency);
+		job_ptr->details->dependency = xstrdup(new_depend);
+		if (job_ptr->details->depend_list)
+			list_destroy(job_ptr->details->depend_list);
+		job_ptr->details->depend_list = new_depend_list;
+#if _DEBUG
+		print_job_dependency(job_ptr);
+#endif
+	} else {
+		list_destroy(new_depend_list);
+	}
+	return rc;
+}
+
+/* Determine if a pending job will run using only the specified nodes
+ * (in job_desc_msg->req_nodes), build response message and return 
+ * SLURM_SUCCESS on success. Otherwise return an error code. Caller 
+ * must free response message */
+extern int job_start_data(job_desc_msg_t *job_desc_msg, 
+			  will_run_response_msg_t **resp)
+{
+	struct job_record *job_ptr;
+	struct part_record *part_ptr;
+	bitstr_t *avail_bitmap = NULL;
+	uint32_t min_nodes, max_nodes, req_nodes;
+	int rc = SLURM_SUCCESS;
+
+	job_ptr = find_job_record(job_desc_msg->job_id);
+	if (job_ptr == NULL)
+		return ESLURM_INVALID_JOB_ID;
+
+	part_ptr = job_ptr->part_ptr;
+	if (part_ptr == NULL)
+		return ESLURM_INVALID_PARTITION_NAME;
+
+	if ((job_ptr->details == NULL) ||
+	    (job_ptr->job_state != JOB_PENDING))
+		return ESLURM_DISABLED;
+
+	if ((job_desc_msg->req_nodes == NULL) || 
+	    (job_desc_msg->req_nodes == '\0')) {
+		/* assume all nodes available to job for testing */
+		avail_bitmap = bit_copy(avail_node_bitmap);
+	} else if (node_name2bitmap(job_desc_msg->req_nodes, false, 
+				    &avail_bitmap) != 0) {
+		return ESLURM_INVALID_NODE_NAME;
+	}
+
+	/* Only consider nodes that are not DOWN or DRAINED */
+	bit_and(avail_bitmap, avail_node_bitmap);
+
+	/* Consider only nodes in this job's partition */
+	if (part_ptr->node_bitmap)
+		bit_and(avail_bitmap, part_ptr->node_bitmap);
+	else
+		rc = ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
+
+	if (job_req_node_filter(job_ptr, avail_bitmap))
+		rc = ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
+	if (job_ptr->details->exc_node_bitmap) {
+		bitstr_t *exc_node_mask = NULL;
+		exc_node_mask = bit_copy(job_ptr->details->exc_node_bitmap);
+		if (exc_node_mask == NULL)
+			fatal("bit_copy malloc failure");
+		bit_not(exc_node_mask);
+		bit_and(avail_bitmap, exc_node_mask);
+		FREE_NULL_BITMAP(exc_node_mask);
+	}
+	if (job_ptr->details->req_node_bitmap) {
+		if (!bit_super_set(job_ptr->details->req_node_bitmap, 
+				   avail_bitmap)) {
+			rc = ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
+		}
+	}
+
+	if (rc == SLURM_SUCCESS) {
+		min_nodes = MAX(job_ptr->details->min_nodes, 
+				part_ptr->min_nodes);
+		if (job_ptr->details->max_nodes == 0)
+			max_nodes = part_ptr->max_nodes;
+		else
+			max_nodes = MIN(job_ptr->details->max_nodes, 
+					part_ptr->max_nodes);
+		max_nodes = MIN(max_nodes, 500000);	/* prevent overflows */
+		if (job_ptr->details->max_nodes)
+			req_nodes = max_nodes;
+		else
+			req_nodes = min_nodes;
+
+		rc = select_g_job_test(job_ptr, avail_bitmap,
+				min_nodes, max_nodes, req_nodes, 
+				SELECT_MODE_WILL_RUN);
+	}
+
+	if (rc == SLURM_SUCCESS) {
+		will_run_response_msg_t *resp_data;
+		resp_data = xmalloc(sizeof(will_run_response_msg_t));
+		resp_data->job_id     = job_ptr->job_id;
+#ifdef HAVE_BG
+		select_g_get_jobinfo(job_ptr->select_jobinfo,
+                        	     SELECT_DATA_NODE_CNT, 
+				     &resp_data->proc_cnt);
+
+#else
+		resp_data->proc_cnt = job_ptr->total_procs;
+#endif
+		resp_data->start_time = job_ptr->start_time;
+		job_ptr->start_time   = 0;  /* restore pending job start time */
+		resp_data->node_list  = bitmap2node_name(avail_bitmap);
+		FREE_NULL_BITMAP(avail_bitmap);
+		*resp = resp_data;
+		return SLURM_SUCCESS;
+	} else {
+		FREE_NULL_BITMAP(avail_bitmap);
+		return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+	}
+
+}
diff --git a/src/slurmctld/job_scheduler.h b/src/slurmctld/job_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..b40310137dcf06f569fa9b53d8370ce9c5b4e265
--- /dev/null
+++ b/src/slurmctld/job_scheduler.h
@@ -0,0 +1,135 @@
+/*****************************************************************************\
+ *  job_scheduler.h - data structures and function definitions for scheduling
+ *	of pending jobs in priority order
+ *****************************************************************************
+ *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette@llnl.gov>, et. al.
+ *  Derived from dsh written by Jim Garlick <garlick1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _JOB_SCHEDULER_H
+#define _JOB_SCHEDULER_H
+
+#include "src/slurmctld/slurmctld.h"
+
+struct job_queue {
+	struct job_record *job_ptr;
+	uint32_t job_priority;
+	uint16_t part_priority;
+};
+
+/* 
+ * build_job_queue - build (non-priority ordered) list of pending jobs
+ * OUT job_queue - pointer to job queue
+ * RET number of entries in job_queue
+ * NOTE: the buffer at *job_queue must be xfreed by the caller
+ */
+extern int build_job_queue(struct job_queue **job_queue);
+
+/*
+ * job_is_completing - Determine if jobs are in the process of completing.
+ * RET - True of any job is in the process of completing
+ * NOTE: This function can reduce resource fragmentation, which is a 
+ * critical issue on Elan interconnect based systems.
+ */
+
+extern bool job_is_completing(void);
+
+/* Determine if a pending job will run using only the specified nodes
+ * (in job_desc_msg->req_nodes), build response message and return 
+ * SLURM_SUCCESS on success. Otherwise return an error code. Caller 
+ * must free response message */
+extern int job_start_data(job_desc_msg_t *job_desc_msg, 
+			  will_run_response_msg_t **resp);
+
+/*
+ * launch_job - send an RPC to a slurmd to initiate a batch job 
+ * IN job_ptr - pointer to job that will be initiated
+ */
+extern void launch_job(struct job_record *job_ptr);
+
+/*
+ * make_batch_job_cred - add a job credential to the batch_job_launch_msg
+ * IN/OUT launch_msg_ptr - batch_job_launch_msg in which job_id, step_id, 
+ *                         uid and nodes have already been set 
+ * RET 0 or error code
+ */
+extern int make_batch_job_cred(batch_job_launch_msg_t *launch_msg_ptr);
+
+/* Print a job's dependency information based upon job_ptr->depend_list */
+extern void print_job_dependency(struct job_record *job_ptr);
+
+/* 
+ * schedule - attempt to schedule all pending jobs
+ *	pending jobs for each partition will be scheduled in priority  
+ *	order until a request fails
+ * RET count of jobs scheduled
+ * Note: We re-build the queue every time. Jobs can not only be added 
+ *	or removed from the queue, but have their priority or partition 
+ *	changed with the update_job RPC. In general nodes will be in priority 
+ *	order (by submit time), so the sorting should be pretty fast.
+ */
+extern int schedule(void);
+
+/*
+ * set_job_elig_time - set the eligible time for pending jobs once their 
+ *	dependencies are lifted (in job->details->begin_time)
+ */
+extern void set_job_elig_time(void);
+
+/* 
+ * sort_job_queue - sort job_queue in decending priority order
+ * IN job_queue_size - count of elements in the job queue
+ * IN/OUT job_queue - pointer to sorted job queue
+ */
+extern void sort_job_queue(struct job_queue *job_queue, int job_queue_size);
+
+/*
+ * Determine if a job's dependencies are met
+ * RET: 0 = no dependencies
+ *      1 = dependencies remain
+ *      2 = failure (job completion code not per dependency), delete the job
+ */
+extern int test_job_dependency(struct job_record *job_ptr);
+
+/*
+ * Parse a job dependency string and use it to establish a "depend_spec" 
+ * list of dependencies. We accept both old format (a single job ID) and
+ * new format (e.g. "afterok:123:124,after:128").
+ * IN job_ptr - job record to have dependency and depend_list updated
+ * IN new_depend - new dependency description
+ * RET returns an error code from slurm_errno.h
+ */
+extern int update_job_dependency(struct job_record *job_ptr, char *new_depend);
+
+#endif /* !_JOB_SCHEDULER_H */
diff --git a/src/slurmctld/licenses.c b/src/slurmctld/licenses.c
new file mode 100644
index 0000000000000000000000000000000000000000..002c07d507e3a5266617d45a37d62de78ac28465
--- /dev/null
+++ b/src/slurmctld/licenses.c
@@ -0,0 +1,394 @@
+/*****************************************************************************\
+ *  licenses.c - Functions for handling cluster-wide consumable resources
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette@llnl.gov>, et. al.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include <ctype.h>
+#include <errno.h>
+#include <pthread.h>
+#include <slurm/slurm_errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "src/common/list.h"
+#include "src/common/log.h"
+#include "src/common/macros.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+#include "src/slurmctld/licenses.h"
+#include "src/slurmctld/slurmctld.h"
+
+#define _DEBUG 0
+
+List license_list = (List) NULL;
+static pthread_mutex_t license_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* Print all licenses on a list */
+static inline void _licenses_print(char *header, List licenses)
+{
+#if _DEBUG
+	ListIterator iter;
+	licenses_t *license_entry;
+
+	info("licenses: %s", header);
+	if (licenses == NULL)
+		return;
+
+	iter = list_iterator_create(licenses);
+	if (iter == NULL)
+		fatal("malloc failure from list_iterator_create");
+	while ((license_entry = (licenses_t *) list_next(iter))) {
+		info("name:%s total:%u used:%u", license_entry->name, 
+		     license_entry->total, license_entry->used);
+	}
+	list_iterator_destroy(iter);
+#endif
+}
+
+/* Free a license_t record (for use by list_destroy) */
+static void _license_free_rec(void *x)
+{
+	licenses_t *license_entry = (licenses_t *) x;
+
+	if (license_entry) {
+		xfree(license_entry->name);
+		xfree(license_entry);
+	}
+}
+
+/* Find a license_t record by license name (for use by list_find_first) */
+static int _license_find_rec(void *x, void *key)
+{
+	licenses_t *license_entry = (licenses_t *) x;
+	char *name = (char *) key;
+
+	if ((license_entry->name == NULL) || (name == NULL))
+		return 0;
+	if (strcmp(license_entry->name, name))
+		return 0;
+	return 1;
+}
+
+/* Given a license string, return a list of license_t records */
+static List _build_license_list(char *licenses, bool *valid)
+{
+	int i;
+	char *end_num, *tmp_str, *token, *last;
+	licenses_t *license_entry;
+	List lic_list;
+
+	*valid = true;
+	if ((licenses == NULL) || (licenses[0] == '\0'))
+		return NULL;
+
+	lic_list = list_create(_license_free_rec);
+	tmp_str = xstrdup(licenses);
+	token = strtok_r(tmp_str, ",;", &last);
+	while (token && *valid) {
+		uint16_t num = 1;
+		for (i=0; token[i]; i++) {
+			if (isspace(token[i])) {
+				*valid = false;
+				break;
+			}
+			if (token[i] == '*') {
+				token[i++] = '\0';
+				num = (uint16_t)strtol(&token[i], &end_num, 10);
+			}
+		}
+		if (num <= 0) {
+			*valid = false;
+			break;
+		}
+		license_entry = xmalloc(sizeof(licenses_t));
+		license_entry->name = xstrdup(token);
+		license_entry->total = num;
+		list_push(lic_list, license_entry);
+		token = strtok_r(NULL, ",;", &last);
+	}
+	xfree(tmp_str);
+
+	if (*valid == false) {
+		list_destroy(lic_list);
+		lic_list = NULL;
+	}
+	return lic_list;
+}
+
+/* Initialize licenses on this system based upon slurm.conf */
+extern int license_init(char *licenses)
+{
+	bool valid;
+
+	slurm_mutex_lock(&license_mutex);
+	if (license_list)
+		fatal("license_list already defined");
+
+	license_list = _build_license_list(licenses, &valid);
+	if (!valid)
+		fatal("Invalid configured licenses: %s", licenses);
+
+	_licenses_print("licences_init", license_list);
+	slurm_mutex_unlock(&license_mutex);
+	return SLURM_SUCCESS;
+}
+
+
+/* Update licenses on this system based upon slurm.conf.
+ * Preserve all previously allocated licenses */
+extern int license_update(char *licenses)
+{
+	ListIterator iter;
+	licenses_t *license_entry, *match;
+	List new_list;
+	bool valid;
+
+	new_list = _build_license_list(licenses, &valid);
+	if (!valid)
+		fatal("Invalid configured licenses: %s", licenses);
+
+	slurm_mutex_lock(&license_mutex);
+	if (!license_list) {	/* no licenses before now */
+		license_list = new_list;
+		slurm_mutex_unlock(&license_mutex);
+		return SLURM_SUCCESS;
+	}
+
+	iter = list_iterator_create(license_list);
+	if (iter == NULL)
+		fatal("malloc failure from list_iterator_create");
+	while ((license_entry = (licenses_t *) list_next(iter))) {
+		match = list_find_first(new_list, _license_find_rec, 
+			license_entry->name);
+		if (!match) {
+			info("license %s removed with %u in use",
+			     license_entry->name, license_entry->used);
+		} else {
+			match->used = license_entry->used;
+			if (match->used > match->total)
+				info("license %s count decreased", match->name);
+		}
+	}
+	list_iterator_destroy(iter);
+
+	list_destroy(license_list);
+	license_list = new_list;
+	_licenses_print("licences_update", license_list);
+	slurm_mutex_unlock(&license_mutex);
+	return SLURM_SUCCESS;
+}
+
+/* Free memory associated with licenses on this system */
+extern void license_free(void)
+{
+	slurm_mutex_lock(&license_mutex);
+	if (license_list) {
+		list_destroy(license_list);
+		license_list = (List) NULL;
+	}
+	slurm_mutex_unlock(&license_mutex);
+}
+
+/*
+ * license_job_validate - Test if the licenses required by a job are valid
+ * IN licenses - required licenses
+ * OUT valid - true if required licenses are valid and a sufficient number
+ *             are configured (though not necessarily available now)
+ * RET license_list, must be destroyed by caller
+ */ 
+extern List license_job_validate(char *licenses, bool *valid)
+{
+	ListIterator iter;
+	licenses_t *license_entry, *match;
+	List job_license_list;
+
+	job_license_list = _build_license_list(licenses, valid);
+	_licenses_print("job_validate", job_license_list);
+	if (!job_license_list)
+		return job_license_list;
+
+	slurm_mutex_lock(&license_mutex);
+	iter = list_iterator_create(job_license_list);
+	if (iter == NULL)
+		fatal("malloc failure from list_iterator_create");
+	while ((license_entry = (licenses_t *) list_next(iter))) {
+		if (license_list) {
+			match = list_find_first(license_list,
+				_license_find_rec, license_entry->name);
+		} else
+			match = NULL;
+		if (!match) {
+			debug("could not find license %s for job",
+			      license_entry->name);
+			*valid = false;
+			break;
+		} else if (license_entry->total > match->total) {
+			debug("job wants more %s licenses than configured",
+			     match->name);
+			*valid = false;
+			break;
+		}
+	}
+	list_iterator_destroy(iter);
+	slurm_mutex_unlock(&license_mutex);
+
+	if (!(*valid)) {
+		list_destroy(job_license_list);
+		job_license_list = NULL;
+	}
+	return job_license_list;
+}
+
+/*
+ * license_job_test - Test if the licenses required for a job are available
+ * IN job_ptr - job identification
+ * RET: SLURM_SUCCESS, EAGAIN (not available now), SLURM_ERROR (never runnable)
+ */ 
+extern int license_job_test(struct job_record *job_ptr)
+{
+	ListIterator iter;
+	licenses_t *license_entry, *match;
+	int rc = SLURM_SUCCESS;
+
+	if (!job_ptr->license_list)	/* no licenses needed */
+		return rc;
+
+	slurm_mutex_lock(&license_mutex);
+	iter = list_iterator_create(job_ptr->license_list);
+	if (iter == NULL)
+		fatal("malloc failure from list_iterator_create");
+	while ((license_entry = (licenses_t *) list_next(iter))) {
+		match = list_find_first(license_list, _license_find_rec, 
+			license_entry->name);
+		if (!match) {
+			error("could not find license %s for job %u",
+			      license_entry->name, job_ptr->job_id);
+			rc = SLURM_ERROR;
+			break;
+		} else if (license_entry->total > match->total) {
+			info("job %u wants more %s licenses than configured",
+			     job_ptr->job_id, match->name);
+			rc = SLURM_ERROR;
+			break;
+		} else if ((license_entry->total + match->used) > 
+			   match->total) {
+			rc = EAGAIN;
+			break;
+		}
+	}
+	list_iterator_destroy(iter);
+	slurm_mutex_unlock(&license_mutex);
+	return rc;
+}
+
+/*
+ * license_job_get - Get the licenses required for a job
+ * IN job_ptr - job identification
+ * RET SLURM_SUCCESS or failure code
+ */ 
+extern int license_job_get(struct job_record *job_ptr)
+{
+	ListIterator iter;
+	licenses_t *license_entry, *match;
+	int rc = SLURM_SUCCESS;
+
+	if (!job_ptr->license_list)	/* no licenses needed */
+		return rc;
+
+	slurm_mutex_lock(&license_mutex);
+	iter = list_iterator_create(job_ptr->license_list);
+	if (iter == NULL)
+		fatal("malloc failure from list_iterator_create");
+	while ((license_entry = (licenses_t *) list_next(iter))) {
+		match = list_find_first(license_list, _license_find_rec, 
+			license_entry->name);
+		if (match) {
+			match->used += license_entry->total;
+			license_entry->used += license_entry->total;
+		} else {
+			error("could not find license %s for job %u",
+			      license_entry->name, job_ptr->job_id);
+			rc = SLURM_ERROR;
+		}
+	}
+	list_iterator_destroy(iter);
+	_licenses_print("licences_job_get", license_list);
+	slurm_mutex_unlock(&license_mutex);
+	return rc;
+}
+
+/*
+ * license_job_return - Return the licenses allocated to a job
+ * IN job_ptr - job identification
+ * RET SLURM_SUCCESS or failure code
+ */ 
+extern int license_job_return(struct job_record *job_ptr)
+{
+	ListIterator iter;
+	licenses_t *license_entry, *match;
+	int rc = SLURM_SUCCESS;
+
+	if (!job_ptr->license_list)	/* no licenses needed */
+		return rc;
+
+	slurm_mutex_lock(&license_mutex);
+	iter = list_iterator_create(job_ptr->license_list);
+	if (iter == NULL)
+		fatal("malloc failure from list_iterator_create");
+	while ((license_entry = (licenses_t *) list_next(iter))) {
+		match = list_find_first(license_list, _license_find_rec, 
+			license_entry->name);
+		if (match) {
+			if (match->used >= license_entry->total)
+				match->used -= license_entry->total;
+			else {
+				error("license use count underflow for %s",
+				      match->name);
+				match->used = 0;
+				rc = SLURM_ERROR;
+			}
+			license_entry->used = 0;
+		} else {
+			/* This can happen after a reconfiguration */
+			error("job returning unknown license %s", 
+			      license_entry->name);
+		}
+	}
+	list_iterator_destroy(iter);
+	_licenses_print("licences_job_return", license_list);
+	slurm_mutex_unlock(&license_mutex);
+	return rc;
+}
+
diff --git a/src/slurmctld/licenses.h b/src/slurmctld/licenses.h
new file mode 100644
index 0000000000000000000000000000000000000000..449e1002b1138748518a997500cd6affaf62e2d5
--- /dev/null
+++ b/src/slurmctld/licenses.h
@@ -0,0 +1,94 @@
+/*****************************************************************************\
+ *  licenses.h - Definitions for handling cluster-wide consumable resources
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette@llnl.gov>, et. al.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _LICENSES_H
+#define _LICENSES_H
+
+#include "src/common/list.h"
+#include "src/slurmctld/slurmctld.h"
+
+typedef struct licenses {
+	char *		name;		/* name associated with a license */
+	uint16_t	total;		/* total license configued */
+	uint16_t	used;		/* used licenses */
+} licenses_t;
+
+extern List license_list;
+
+
+/* Initialize licenses on this system based upon slurm.conf */
+extern int license_init(char *licenses);
+
+/* Update licenses on this system based upon slurm.conf.
+ * Preserve all previously allocated licenses */
+extern int license_update(char *licenses);
+
+/* Free memory associated with licenses on this system */
+extern void license_free(void);
+
+
+/*
+ * license_job_get - Get the licenses required for a job
+ * IN job_ptr - job identification
+ * RET SLURM_SUCCESS or failure code
+ */ 
+extern int license_job_get(struct job_record *job_ptr);
+
+/*
+ * license_job_return - Return the licenses allocated to a job
+ * IN job_ptr - job identification
+ * RET SLURM_SUCCESS or failure code
+ */ 
+extern int license_job_return(struct job_record *job_ptr);
+
+/*
+ * license_job_test - Test if the licenses required for a job are available
+ * IN job_ptr - job identification
+ * RET SLURM_SUCCESS, EAGAIN (not available now), SLURM_ERROR (never runnable)
+ */ 
+extern int license_job_test(struct job_record *job_ptr);
+
+/*
+ * license_job_validate - Test if the licenses required by a job are valid
+ * IN licenses - required licenses
+ * OUT valid - true if required licenses are valid and a sufficient number
+ *             are configured (though not necessarily available now)
+ * RET license_list, must be destroyed by caller
+ */ 
+extern List license_job_validate(char *licenses, bool *valid);
+
+#endif /* !_LICENSES_H */
diff --git a/src/slurmctld/locks.c b/src/slurmctld/locks.c
index b1e4cb6cd14ab4dd95a8329cd65c4cb40243650a..71eca604beb63c3b813192e746095330e2a4431d 100644
--- a/src/slurmctld/locks.c
+++ b/src/slurmctld/locks.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov>, Randy Sanchez <rsancez@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmctld/locks.h b/src/slurmctld/locks.h
index f43f35928a166ec7f936ebd5caa3e8742e9eba2c..997f35722a0d5c1b02d28a545acfc3bd23801fc0 100644
--- a/src/slurmctld/locks.h
+++ b/src/slurmctld/locks.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov>, Randy Sanchez <rsancez@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmctld/node_mgr.c b/src/slurmctld/node_mgr.c
index 44e9992d5f79e9e3d1a1be3575a7d0b1a7904f93..7772adb0a35feb33c29d3bc9584ec64f984825a1 100644
--- a/src/slurmctld/node_mgr.c
+++ b/src/slurmctld/node_mgr.c
@@ -4,12 +4,12 @@
  *	hash table (node_hash_table), time stamp (last_node_update) and 
  *	configuration list (config_list)
  *
- *  $Id: node_mgr.c 13869 2008-04-15 00:51:16Z jette $
+ *  $Id: node_mgr.c 14124 2008-05-23 21:12:21Z da $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,7 +62,7 @@
 #include "src/common/xstring.h"
 #include "src/common/node_select.h"
 #include "src/common/read_config.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_accounting_storage.h"
 #include "src/slurmctld/agent.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/ping_nodes.h"
@@ -188,7 +188,6 @@ create_node_record (struct config_record *config_ptr, char *node_name)
 	last_node_update = time (NULL);
 	xassert(config_ptr);
 	xassert(node_name); 
-	xassert(strlen (node_name) < MAX_SLURM_NAME);
 
 	/* round up the buffer size to reduce overhead of xrealloc */
 	old_buffer_size = (node_record_count) * sizeof (struct node_record);
@@ -204,7 +203,7 @@ create_node_record (struct config_record *config_ptr, char *node_name)
 	else if (old_buffer_size != new_buffer_size)
 		xrealloc (node_record_table_ptr, new_buffer_size);
 	node_ptr = node_record_table_ptr + (node_record_count++);
-	strcpy (node_ptr->name, node_name);
+	node_ptr->name = xstrdup(node_name);
 	node_ptr->last_response = (time_t)0;
 	node_ptr->config_ptr = config_ptr;
 	node_ptr->part_cnt = 0;
@@ -404,15 +403,14 @@ extern int load_all_node_state ( bool state_only )
 {
 	char *node_name, *reason = NULL, *data = NULL, *state_file, *features;
 	int data_allocated, data_read = 0, error_code = 0, node_cnt = 0;
-	uint16_t node_state, name_len;
+	uint16_t node_state;
 	uint16_t cpus = 1, sockets = 1, cores = 1, threads = 1;
-	uint32_t real_memory, tmp_disk, data_size = 0;
+	uint32_t real_memory, tmp_disk, data_size = 0, name_len;
 	struct node_record *node_ptr;
 	int state_fd;
 	time_t time_stamp, now = time(NULL);
 	Buf buffer;
 	char *ver_str = NULL;
-	uint16_t ver_str_len;
 
 	/* read the file */
 	state_file = xstrdup (slurmctld_conf.state_save_location);
@@ -449,26 +447,18 @@ extern int load_all_node_state ( bool state_only )
 
 	buffer = create_buf (data, data_size);
 
-	/*
-	 * Check the data version so that when the format changes, we 
-	 * we don't try to unpack data using the wrong format routines
-	 */
-	if (size_buf(buffer) >= sizeof(uint16_t) + strlen(NODE_STATE_VERSION)) {
-		char *ptr = get_buf_data(buffer);
-
-		if (memcmp( &ptr[sizeof(uint16_t)], NODE_STATE_VERSION, 3) == 0) {
-			safe_unpackstr_xmalloc( &ver_str, &ver_str_len, buffer);
-			debug3("Version string in node_state header is %s",
-				ver_str);
-		}
-	}
-	if (ver_str && (strcmp(ver_str, NODE_STATE_VERSION) != 0)) {
+	safe_unpackstr_xmalloc( &ver_str, &name_len, buffer);
+	debug3("Version string in node_state header is %s", ver_str);
+	if ((!ver_str) || (strcmp(ver_str, NODE_STATE_VERSION) != 0)) {
+		error("*****************************************************");
 		error("Can not recover node state, data version incompatable");
+		error("*****************************************************");
 		xfree(ver_str);
 		free_buf(buffer);
 		return EFAULT;
 	}
 	xfree(ver_str);
+
 	safe_unpack_time (&time_stamp, buffer);
 
 	while (remaining_buf (buffer) > 0) {
@@ -521,7 +511,11 @@ extern int load_all_node_state ( bool state_only )
 						| orig_flags;
 				}
 				if (node_state & NODE_STATE_DRAIN)
-					node_ptr->node_state |= NODE_STATE_DRAIN;
+					 node_ptr->node_state |=
+						 NODE_STATE_DRAIN;
+				if (node_state & NODE_STATE_FAIL)
+					node_ptr->node_state |=
+						NODE_STATE_FAIL;
 			}
 			if (node_ptr->reason == NULL)
 				node_ptr->reason = reason;
@@ -596,7 +590,7 @@ find_node_record (char *name)
 		if ((node_record_count == 1)
 		&&  (strcmp(node_record_table_ptr[0].name, "localhost") == 0))
 			return (&node_record_table_ptr[0]);
-
+	       
 		error ("find_node_record: lookup failure for %s", name);
 	} 
 
@@ -655,7 +649,12 @@ int init_node_conf (void)
 	int i;
 
 	for (i=0; i<node_record_count; i++) {
+		xfree(node_record_table_ptr[i].arch);
+		xfree(node_record_table_ptr[i].comm_name);
 		xfree(node_record_table_ptr[i].features);
+		xfree(node_record_table_ptr[i].name);
+		xfree(node_record_table_ptr[i].os);
+		xfree(node_record_table_ptr[i].part_pptr);
 		xfree(node_record_table_ptr[i].reason);
 	}
 
@@ -845,6 +844,9 @@ extern void pack_all_node (char **buffer_ptr, int *buffer_size,
 		if (((show_flags & SHOW_ALL) == 0)
 		&&  (_node_is_hidden(node_ptr)))
 			continue;
+		if ((node_ptr->name == NULL) ||
+		    (node_ptr->name[0] == '\0'))
+			continue;
 
 		_pack_node(node_ptr, cr_flag, buffer);
 		nodes_packed ++ ;
@@ -909,12 +911,17 @@ static void _pack_node (struct node_record *dump_node_ptr, bool cr_flag,
 		pack16(allocated_cpus, buffer);
 	} else if ((dump_node_ptr->node_state & NODE_STATE_COMPLETING) ||
 		   (dump_node_ptr->node_state == NODE_STATE_ALLOCATED)) {
-		pack16(dump_node_ptr->config_ptr->cpus, buffer);
+		if (slurmctld_conf.fast_schedule)
+			pack16(dump_node_ptr->config_ptr->cpus, buffer);
+		else
+			pack16(dump_node_ptr->cpus, buffer);
 	} else {
 		pack16((uint16_t) 0, buffer);
 	}
 
+	packstr (dump_node_ptr->arch, buffer);
 	packstr (dump_node_ptr->config_ptr->feature, buffer);
+	packstr (dump_node_ptr->os, buffer);
 	packstr (dump_node_ptr->reason, buffer);
 }
 
@@ -928,17 +935,19 @@ static void _pack_node (struct node_record *dump_node_ptr, bool cr_flag,
 void rehash_node (void) 
 {
 	int i, inx;
+	struct node_record *node_ptr = node_record_table_ptr;
 
 	xfree (node_hash_table);
 	node_hash_table = xmalloc (sizeof (struct node_record *) * 
 				node_record_count);
 
-	for (i = 0; i < node_record_count; i++) {
-		if (strlen (node_record_table_ptr[i].name) == 0)
+	for (i = 0; i < node_record_count; i++, node_ptr++) {
+		if ((node_ptr->name == NULL) ||
+		    (node_ptr->name[0] == '\0'))
 			continue;	/* vestigial record */
-		inx = _hash_index (node_record_table_ptr[i].name);
-		node_record_table_ptr[i].node_next = node_hash_table[inx];
-		node_hash_table[inx] = &node_record_table_ptr[i];
+		inx = _hash_index (node_ptr->name);
+		node_ptr->node_next = node_hash_table[inx];
+		node_hash_table[inx] = node_ptr;
 	}
 
 #if _DEBUG
@@ -961,7 +970,8 @@ void set_slurmd_addr (void)
 
 	START_TIMER;
 	for (i = 0; i < node_record_count; i++, node_ptr++) {
-		if (node_ptr->name[0] == '\0')
+		if ((node_ptr->name == NULL) ||
+		    (node_ptr->name[0] == '\0'))
 			continue;
 		if (node_ptr->port == 0)
 			node_ptr->port = slurmctld_conf.slurmd_port;
@@ -1044,10 +1054,18 @@ int update_node ( update_node_msg_t * update_node_msg )
 			if (state_val == NODE_RESUME) {
 				base_state &= NODE_STATE_BASE;
 				if ((base_state == NODE_STATE_IDLE) &&
-					   (node_ptr->node_state & NODE_STATE_DRAIN)) {
-					jobacct_g_node_up(node_ptr, now);
+				    ((node_ptr->node_state & NODE_STATE_DRAIN) 
+				     || (node_ptr->node_state &
+					 NODE_STATE_FAIL))) {
+					clusteracct_storage_g_node_up(
+						acct_db_conn, 
+						slurmctld_cluster_name,
+						node_ptr,
+						now);
 				}
 				node_ptr->node_state &= (~NODE_STATE_DRAIN);
+				node_ptr->node_state &= (~NODE_STATE_FAIL);
+				base_state &= NODE_STATE_BASE;
 				if (base_state == NODE_STATE_DOWN)
 					state_val = NODE_STATE_IDLE;
 				else
@@ -1061,17 +1079,29 @@ int update_node ( update_node_msg_t * update_node_msg )
 							       false);
 			}
 			else if (state_val == NODE_STATE_IDLE) {
+				/* assume they want to clear DRAIN and
+				 * FAIL flags too */
 				base_state &= NODE_STATE_BASE;
 				if (base_state == NODE_STATE_DOWN) {
 					trigger_node_up(node_ptr);
-					jobacct_g_node_up(node_ptr, now);
+					clusteracct_storage_g_node_up(
+						acct_db_conn, 
+						slurmctld_cluster_name,
+						node_ptr,
+						now);
 				} else if ((base_state == NODE_STATE_IDLE) &&
-					   (node_ptr->node_state & NODE_STATE_DRAIN)) {
-					jobacct_g_node_up(node_ptr, now);
+					   ((node_ptr->node_state &
+					     NODE_STATE_DRAIN) ||
+					    (node_ptr->node_state &
+					     NODE_STATE_FAIL))) {
+					clusteracct_storage_g_node_up(
+						acct_db_conn, 
+						slurmctld_cluster_name,
+						node_ptr,
+						now);
 				}
-
-				/* assume they want to clear DRAIN flag too */
 				node_ptr->node_state &= (~NODE_STATE_DRAIN);
+				node_ptr->node_state &= (~NODE_STATE_FAIL);
 				bit_set (avail_node_bitmap, node_inx);
 				bit_set (idle_node_bitmap, node_inx);
 				bit_set (up_node_bitmap, node_inx);
@@ -1079,7 +1109,8 @@ int update_node ( update_node_msg_t * update_node_msg )
 				reset_job_priority();
 			}
 			else if (state_val == NODE_STATE_ALLOCATED) {
-				if (!(node_ptr->node_state & NODE_STATE_DRAIN))
+				if (!(node_ptr->node_state & (NODE_STATE_DRAIN
+						| NODE_STATE_FAIL)))
 					bit_set (up_node_bitmap, node_inx);
 				bit_set   (avail_node_bitmap, node_inx);
 				bit_clear (idle_node_bitmap, node_inx);
@@ -1088,10 +1119,26 @@ int update_node ( update_node_msg_t * update_node_msg )
 				bit_clear (avail_node_bitmap, node_inx);
 				state_val = node_ptr->node_state |
 					NODE_STATE_DRAIN;
+				if ((node_ptr->run_job_cnt  == 0) &&
+				    (node_ptr->comp_job_cnt == 0)) {
+					trigger_node_drained(node_ptr);
+					clusteracct_storage_g_node_down(
+						acct_db_conn, 
+						slurmctld_cluster_name,
+						node_ptr, now, NULL);
+				}
+			}
+			else if (state_val == NODE_STATE_FAIL) {
+				bit_clear (avail_node_bitmap, node_inx);
+				state_val = node_ptr->node_state |
+					NODE_STATE_FAIL;
+				trigger_node_failing(node_ptr);
 				if ((node_ptr->run_job_cnt  == 0) &&
 				    (node_ptr->comp_job_cnt == 0))
-					jobacct_g_node_down(node_ptr, now,
-							    NULL);
+					clusteracct_storage_g_node_down(
+						acct_db_conn, 
+						slurmctld_cluster_name,
+						node_ptr, now, NULL);
 			}
 			else {
 				info ("Invalid node state specified %d", 
@@ -1116,7 +1163,8 @@ int update_node ( update_node_msg_t * update_node_msg )
 
 		base_state = node_ptr->node_state & NODE_STATE_BASE;
 		if ((base_state != NODE_STATE_DOWN)
-		&&  ((node_ptr->node_state & NODE_STATE_DRAIN) == 0))
+		&&  ((node_ptr->node_state & (NODE_STATE_DRAIN |
+				NODE_STATE_FAIL)) == 0))
 			xfree(node_ptr->reason);
 
 		free (this_node_name);
@@ -1323,7 +1371,10 @@ extern int drain_nodes ( char *nodes, char *reason )
 		if ((node_ptr->run_job_cnt  == 0) &&
 		    (node_ptr->comp_job_cnt == 0)) {
 			/* no jobs, node is drained */
-			jobacct_g_node_down(node_ptr, now, NULL);
+			trigger_node_drained(node_ptr);
+			clusteracct_storage_g_node_down(acct_db_conn, 
+							slurmctld_cluster_name,
+							node_ptr, now, NULL);
 		}
 
 		select_g_update_node_state(node_inx, node_ptr->node_state);
@@ -1346,6 +1397,7 @@ static bool _valid_node_state_change(uint16_t old, uint16_t new)
 	switch (new) {
 		case NODE_STATE_DOWN:
 		case NODE_STATE_DRAIN:
+		case NODE_STATE_FAIL:
 			return true;
 			break;
 
@@ -1353,7 +1405,8 @@ static bool _valid_node_state_change(uint16_t old, uint16_t new)
 			if (base_state == NODE_STATE_UNKNOWN)
 				return false;
 			if ((base_state == NODE_STATE_DOWN)
-			||  (node_flags & NODE_STATE_DRAIN))
+			||  (node_flags & NODE_STATE_DRAIN)
+			||  (node_flags & NODE_STATE_FAIL))
 				return true;
 			break;
 
@@ -1377,25 +1430,12 @@ static bool _valid_node_state_change(uint16_t old, uint16_t new)
 
 /*
  * validate_node_specs - validate the node's specifications as valid, 
- *   if not set state to down, in any case update last_response
- * IN node_name - name of the node
- * IN cpus - number of cpus measured
- * IN sockets - number of sockets per cpu measured
- * IN cores - number of cores per socket measured
- * IN threads - number of threads per core measured
- * IN real_memory - mega_bytes of real_memory measured
- * IN tmp_disk - mega_bytes of tmp_disk measured
- * IN job_count - number of jobs allocated to this node
- * IN status - node status code
+ *	if not set state to down, in any case update last_response
+ * IN reg_msg - node registration message
  * RET 0 if no error, ENOENT if no such node, EINVAL if values too low
- * global: node_record_table_ptr - pointer to global node table
  * NOTE: READ lock_slurmctld config before entry
  */
-extern int 
-validate_node_specs (char *node_name, uint16_t cpus, 
-			uint16_t sockets, uint16_t cores, uint16_t threads,
-			uint32_t real_memory, uint32_t tmp_disk, 
-			uint32_t job_count, uint32_t status)
+extern int validate_node_specs(slurm_node_registration_status_msg_t *reg_msg)
 {
 	int error_code, i;
 	struct config_record *config_ptr;
@@ -1404,7 +1444,7 @@ validate_node_specs (char *node_name, uint16_t cpus,
 	uint16_t base_state, node_flags;
 	time_t now = time(NULL);
 
-	node_ptr = find_node_record (node_name);
+	node_ptr = find_node_record (reg_msg->node_name);
 	if (node_ptr == NULL)
 		return ENOENT;
 	node_ptr->last_response = now;
@@ -1417,78 +1457,90 @@ validate_node_specs (char *node_name, uint16_t cpus,
 	 * an error if the user did not specify the values on slurm.conf
 	 * for a multi-core system */
 	if ((slurmctld_conf.fast_schedule != 2)
-	&&  (sockets < config_ptr->sockets)) {
-		error("Node %s has low socket count %u", node_name, sockets);
+	&&  (reg_msg->sockets < config_ptr->sockets)) {
+		error("Node %s has low socket count %u", 
+			reg_msg->node_name, reg_msg->sockets);
 		error_code  = EINVAL;
 		reason_down = "Low socket count";
 	}
-	node_ptr->sockets = sockets;
+	node_ptr->sockets = reg_msg->sockets;
 
 	if ((slurmctld_conf.fast_schedule != 2)
-	&&  (cores < config_ptr->cores)) {
-		error("Node %s has low core count %u", node_name, cores);
+	&&  (reg_msg->cores < config_ptr->cores)) {
+		error("Node %s has low core count %u", 
+			reg_msg->node_name, reg_msg->cores);
 		error_code  = EINVAL;
 		reason_down = "Low core count";
 	}
-	node_ptr->cores = cores;
+	node_ptr->cores = reg_msg->cores;
 
 	if ((slurmctld_conf.fast_schedule != 2)
-	&&  (threads < config_ptr->threads)) {
-		error("Node %s has low thread count %u", node_name, threads);
+	&&  (reg_msg->threads < config_ptr->threads)) {
+		error("Node %s has low thread count %u", 
+			reg_msg->node_name, reg_msg->threads);
 		error_code  = EINVAL;
 		reason_down = "Low thread count";
 	}
-	node_ptr->threads = threads;
+	node_ptr->threads = reg_msg->threads;
 #else
 	if (slurmctld_conf.fast_schedule != 2) {
 		int tot1, tot2;
-		tot1 = sockets * cores * threads;
+		tot1 = reg_msg->sockets * reg_msg->cores * reg_msg->threads;
 		tot2 = config_ptr->sockets * config_ptr->cores *
 			config_ptr->threads;
 		if (tot1 < tot2) {
 			error("Node %s has low socket*core*thread count %u",
-				node_name, tot1);
+				reg_msg->node_name, tot1);
 			error_code = EINVAL;
 			reason_down = "Low socket*core*thread count";
 		}
 	}
-	node_ptr->sockets = sockets;
-	node_ptr->cores   = cores;
-	node_ptr->threads = threads;
+	node_ptr->sockets = reg_msg->sockets;
+	node_ptr->cores   = reg_msg->cores;
+	node_ptr->threads = reg_msg->threads;
 #endif
 
 	if ((slurmctld_conf.fast_schedule != 2)
-	&&  (cpus < config_ptr->cpus)) {
-		error ("Node %s has low cpu count %u", node_name, cpus);
+	&&  (reg_msg->cpus < config_ptr->cpus)) {
+		error ("Node %s has low cpu count %u", 
+			reg_msg->node_name, reg_msg->cpus);
 		error_code  = EINVAL;
 		reason_down = "Low CPUs";
 	}
-	if ((node_ptr->cpus != cpus)
+	if ((node_ptr->cpus != reg_msg->cpus)
 	&&  (slurmctld_conf.fast_schedule == 0)) {
 		for (i=0; i<node_ptr->part_cnt; i++) {
 			node_ptr->part_pptr[i]->total_cpus += 
-				(cpus - node_ptr->cpus);
+				(reg_msg->cpus - node_ptr->cpus);
 		}
 	}
-	node_ptr->cpus = cpus;
+	node_ptr->cpus = reg_msg->cpus;
 
 	if ((slurmctld_conf.fast_schedule != 2) 
-	&&  (real_memory < config_ptr->real_memory)) {
+	&&  (reg_msg->real_memory < config_ptr->real_memory)) {
 		error ("Node %s has low real_memory size %u", 
-		       node_name, real_memory);
+		       reg_msg->node_name, reg_msg->real_memory);
 		error_code  = EINVAL;
 		reason_down = "Low RealMemory";
 	}
-	node_ptr->real_memory = real_memory;
+	node_ptr->real_memory = reg_msg->real_memory;
 
 	if ((slurmctld_conf.fast_schedule != 2)
-	&&  (tmp_disk < config_ptr->tmp_disk)) {
+	&&  (reg_msg->tmp_disk < config_ptr->tmp_disk)) {
 		error ("Node %s has low tmp_disk size %u",
-		       node_name, tmp_disk);
+		       reg_msg->node_name, reg_msg->tmp_disk);
 		error_code = EINVAL;
 		reason_down = "Low TmpDisk";
 	}
-	node_ptr->tmp_disk = tmp_disk;
+	node_ptr->tmp_disk = reg_msg->tmp_disk;
+
+	xfree(node_ptr->arch);
+	node_ptr->arch = reg_msg->arch;
+	reg_msg->arch = NULL;	/* Nothing left to free */
+
+	xfree(node_ptr->os);
+	node_ptr->os = reg_msg->os;
+	reg_msg->os = NULL;	/* Nothing left to free */
 
 	if (node_ptr->node_state & NODE_STATE_NO_RESPOND) {
 		last_node_update = time (NULL);
@@ -1498,25 +1550,31 @@ validate_node_specs (char *node_name, uint16_t cpus,
 	base_state = node_ptr->node_state & NODE_STATE_BASE;
 	node_flags = node_ptr->node_state & NODE_STATE_FLAGS;
 	if (error_code) {
-		if (base_state != NODE_STATE_DOWN)
-			error ("Setting node %s state to DOWN", node_name);
+		if (base_state != NODE_STATE_DOWN) {
+			error ("Setting node %s state to DOWN", 
+				reg_msg->node_name);
+		}
 		last_node_update = time (NULL);
-		set_node_down(node_name, reason_down);
-		_sync_bitmaps(node_ptr, job_count);
-	} else if (status == ESLURMD_PROLOG_FAILED) {
-		if ((node_flags & NODE_STATE_DRAIN) == 0) {
+		set_node_down(reg_msg->node_name, reason_down);
+		_sync_bitmaps(node_ptr, reg_msg->job_count);
+	} else if (reg_msg->status == ESLURMD_PROLOG_FAILED) {
+		if ((node_flags & (NODE_STATE_DRAIN | NODE_STATE_FAIL)) == 0) {
+#ifdef HAVE_BG
+			info("Prolog failure on node %s", reg_msg->node_name);
+#else
 			last_node_update = time (NULL);
-			error ("Prolog failure on node %s, state to DOWN",
-				node_name);
-			set_node_down(node_name, "Prolog failed");
+			error("Prolog failure on node %s, state to DOWN",
+				reg_msg->node_name);
+			set_node_down(reg_msg->node_name, "Prolog failed");
+#endif
 		}
 	} else {
 		if (base_state == NODE_STATE_UNKNOWN) {
 			last_node_update = time (NULL);
 			reset_job_priority();
 			debug("validate_node_specs: node %s has registered", 
-				node_name);
-			if (job_count) {
+				reg_msg->node_name);
+			if (reg_msg->job_count) {
 				node_ptr->node_state = NODE_STATE_ALLOCATED |
 					node_flags;
 			} else {
@@ -1526,14 +1584,16 @@ validate_node_specs (char *node_name, uint16_t cpus,
 			}
 			if ((node_flags & NODE_STATE_DRAIN) == 0)
 				xfree(node_ptr->reason);
-			jobacct_g_node_up(node_ptr, now);
+			clusteracct_storage_g_node_up(acct_db_conn, 
+						      slurmctld_cluster_name,
+						      node_ptr, now);
 		} else if ((base_state == NODE_STATE_DOWN) &&
 		           (slurmctld_conf.ret2service == 1) &&
 			   (node_ptr->reason != NULL) && 
 			   (strncmp(node_ptr->reason, "Not responding", 14) 
 					== 0)) {
 			last_node_update = time (NULL);
-			if (job_count) {
+			if (reg_msg->job_count) {
 				node_ptr->node_state = NODE_STATE_ALLOCATED |
 					node_flags;
 			} else {
@@ -1541,24 +1601,26 @@ validate_node_specs (char *node_name, uint16_t cpus,
 					node_flags;
 				node_ptr->last_idle = now;
 			}
-			info ("node %s returned to service", node_name);
+			info ("node %s returned to service", reg_msg->node_name);
 			xfree(node_ptr->reason);
 			reset_job_priority();
 			trigger_node_up(node_ptr);
-			jobacct_g_node_up(node_ptr, now);
+			clusteracct_storage_g_node_up(acct_db_conn, 
+						      slurmctld_cluster_name,
+						      node_ptr, now);
 		} else if ((base_state == NODE_STATE_ALLOCATED) &&
-			   (job_count == 0)) {	/* job vanished */
+			   (reg_msg->job_count == 0)) {	/* job vanished */
 			last_node_update = now;
 			node_ptr->node_state = NODE_STATE_IDLE | node_flags;
 			node_ptr->last_idle = now;
 		} else if ((node_flags & NODE_STATE_COMPLETING) &&
-			   (job_count == 0)) {	/* job already done */
+			   (reg_msg->job_count == 0)) {	/* job already done */
 			last_node_update = now;
 			node_ptr->node_state &= (~NODE_STATE_COMPLETING);
 		}
 		select_g_update_node_state((node_ptr - node_record_table_ptr),
 					   node_ptr->node_state);
-		_sync_bitmaps(node_ptr, job_count);
+		_sync_bitmaps(node_ptr, reg_msg->job_count);
 	}
 
 	return error_code;
@@ -1568,20 +1630,18 @@ validate_node_specs (char *node_name, uint16_t cpus,
  * validate_nodes_via_front_end - validate all nodes on a cluster as having
  *	a valid configuration as soon as the front-end registers. Individual
  *	nodes will not register with this configuration
- * IN job_count - number of jobs which should be running on cluster
- * IN job_id_ptr - pointer to array of job_ids that should be on cluster
- * IN step_id_ptr - pointer to array of job step ids that should be on cluster
- * IN status - cluster status code
+ * IN reg_msg - node registration message
  * RET 0 if no error, SLURM error code otherwise
- * global: node_record_table_ptr - pointer to global node table
  * NOTE: READ lock_slurmctld config before entry
  */
-extern int validate_nodes_via_front_end(uint32_t job_count, 
-			uint32_t *job_id_ptr, uint16_t *step_id_ptr,
-			uint32_t status)
+extern int validate_nodes_via_front_end(
+		slurm_node_registration_status_msg_t *reg_msg)
 {
 	int error_code = 0, i, jobs_on_node;
 	bool updated_job = false;
+#ifdef HAVE_BG
+	bool failure_logged = false;
+#endif
 	struct job_record *job_ptr;
 	struct config_record *config_ptr;
 	struct node_record *node_ptr;
@@ -1595,25 +1655,25 @@ extern int validate_nodes_via_front_end(uint32_t job_count,
 	/* First validate the job info */
 	node_ptr = &node_record_table_ptr[0];	/* All msg send to node zero,
 				 * the front-end for the wholel cluster */
-	for (i = 0; i < job_count; i++) {
-		if ( (job_id_ptr[i] >= MIN_NOALLOC_JOBID) && 
-		     (job_id_ptr[i] <= MAX_NOALLOC_JOBID) ) {
+	for (i = 0; i < reg_msg->job_count; i++) {
+		if ( (reg_msg->job_id[i] >= MIN_NOALLOC_JOBID) && 
+		     (reg_msg->job_id[i] <= MAX_NOALLOC_JOBID) ) {
 			info("NoAllocate job %u.%u reported",
-				job_id_ptr[i], step_id_ptr[i]);
+				reg_msg->job_id[i], reg_msg->step_id[i]);
 			continue;
 		}
 
-		job_ptr = find_job_record(job_id_ptr[i]);
+		job_ptr = find_job_record(reg_msg->job_id[i]);
 		if (job_ptr == NULL) {
 			error("Orphan job %u.%u reported",
-			      job_id_ptr[i], step_id_ptr[i]);
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+			      reg_msg->job_id[i], reg_msg->step_id[i]);
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 		}
 
-		else if ((job_ptr->job_state == JOB_RUNNING)
-		||       (job_ptr->job_state == JOB_SUSPENDED)) {
+		else if ((job_ptr->job_state == JOB_RUNNING) ||
+		         (job_ptr->job_state == JOB_SUSPENDED)) {
 			debug3("Registered job %u.%u",
-			       job_id_ptr[i], step_id_ptr[i]);
+			       reg_msg->job_id[i], reg_msg->step_id[i]);
 			if (job_ptr->batch_flag) {
 				/* NOTE: Used for purging defunct batch jobs */
 				job_ptr->time_last_active = now;
@@ -1623,37 +1683,37 @@ extern int validate_nodes_via_front_end(uint32_t job_count,
 		else if (job_ptr->job_state & JOB_COMPLETING) {
 			/* Re-send kill request as needed, 
 			 * not necessarily an error */
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 		}
 
 
 		else if (job_ptr->job_state == JOB_PENDING) {
 			error("Registered PENDING job %u.%u",
-				job_id_ptr[i], step_id_ptr[i]);
+				reg_msg->job_id[i], reg_msg->step_id[i]);
 			/* FIXME: Could possibly recover the job */
 			job_ptr->job_state = JOB_FAILED;
 			job_ptr->exit_code = 1;
 			job_ptr->state_reason = FAIL_SYSTEM;
 			last_job_update    = now;
-			job_ptr->start_time = job_ptr->end_time  = now;
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+			job_ptr->start_time = job_ptr->end_time = now;
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 			job_completion_logger(job_ptr);
 			delete_job_details(job_ptr);
 		}
 
 		else {		/* else job is supposed to be done */
 			error("Registered job %u.%u in state %s",
-				job_id_ptr[i], step_id_ptr[i], 
+				reg_msg->job_id[i], reg_msg->step_id[i], 
 				job_state_string(job_ptr->job_state));
-			kill_job_on_node(job_id_ptr[i], job_ptr, node_ptr);
+			kill_job_on_node(reg_msg->job_id[i], job_ptr, node_ptr);
 		}
 	}
 
 	/* purge orphan batch jobs */
 	job_iterator = list_iterator_create(job_list);
 	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
-		if ((job_ptr->job_state != JOB_RUNNING)
-		||  (job_ptr->batch_flag == 0))
+		if ((job_ptr->job_state != JOB_RUNNING) ||
+		    (job_ptr->batch_flag == 0))
 			continue;
 #ifdef HAVE_BG
 		    /* slurmd does not report job presence until after prolog 
@@ -1685,8 +1745,15 @@ extern int validate_nodes_via_front_end(uint32_t job_count,
 					(~NODE_STATE_NO_RESPOND);
 		}
 
-		if (status == ESLURMD_PROLOG_FAILED) {
-			if (!(node_ptr->node_state & NODE_STATE_DRAIN)) {
+		if (reg_msg->status == ESLURMD_PROLOG_FAILED) {
+			if (!(node_ptr->node_state & (NODE_STATE_DRAIN | 
+						      NODE_STATE_FAIL))) {
+#ifdef HAVE_BG
+				if (!failure_logged) {
+					error("Prolog failure");
+					failure_logged = true;
+				}
+#else
 				updated_job = true;
 				if (prolog_hostlist)
 					(void) hostlist_push_host(
@@ -1696,6 +1763,7 @@ extern int validate_nodes_via_front_end(uint32_t job_count,
 					prolog_hostlist = hostlist_create(
 						node_ptr->name);
 				set_node_down(node_ptr->name, "Prolog failed");
+#endif
 			}
 		} else {
 			base_state = node_ptr->node_state & NODE_STATE_BASE;
@@ -1719,7 +1787,13 @@ extern int validate_nodes_via_front_end(uint32_t job_count,
 					node_ptr->last_idle = now;
 				}
 				xfree(node_ptr->reason);
-				jobacct_g_node_up(node_ptr, now);
+				if ((node_flags & 
+				     (NODE_STATE_DRAIN | NODE_STATE_FAIL)) == 0)
+					clusteracct_storage_g_node_up(
+						acct_db_conn, 
+						slurmctld_cluster_name,
+						node_ptr,
+						now);
 			} else if ((base_state == NODE_STATE_DOWN) &&
 			           (slurmctld_conf.ret2service == 1)) {
 				updated_job = true;
@@ -1735,23 +1809,30 @@ extern int validate_nodes_via_front_end(uint32_t job_count,
 				}
 				if (return_hostlist)
 					(void) hostlist_push_host(
-						return_hostlist, node_ptr->name);
+						return_hostlist,
+						node_ptr->name);
 				else
 					return_hostlist = hostlist_create(
 						node_ptr->name);
 				xfree(node_ptr->reason);
 				trigger_node_up(node_ptr);
-				jobacct_g_node_up(node_ptr, now);
+				clusteracct_storage_g_node_up(
+					acct_db_conn, 
+					slurmctld_cluster_name,
+					node_ptr, now);
 			} else if ((base_state == NODE_STATE_ALLOCATED) &&
-				   (jobs_on_node == 0)) {	/* job vanished */
+				   (jobs_on_node == 0)) {
+				/* job vanished */
 				updated_job = true;
 				node_ptr->node_state = NODE_STATE_IDLE |
 					node_flags;
 				node_ptr->last_idle = now;
 			} else if ((node_flags & NODE_STATE_COMPLETING) &&
-			           (jobs_on_node == 0)) {  /* job already done */
+			           (jobs_on_node == 0)) {  
+				/* job already done */
 				updated_job = true;
-				node_ptr->node_state &= (~NODE_STATE_COMPLETING);
+				node_ptr->node_state &=
+					(~NODE_STATE_COMPLETING);
 			}
 			select_g_update_node_state(
 				(node_ptr - node_record_table_ptr),
@@ -1786,7 +1867,7 @@ extern int validate_nodes_via_front_end(uint32_t job_count,
 		last_node_update = time (NULL);
 		reset_job_priority();
 	}
-	return error_code;;
+	return error_code;
 }
 
 /* Sync idle, share, and avail_node_bitmaps for a given node */
@@ -1801,7 +1882,7 @@ static void _sync_bitmaps(struct node_record *node_ptr, int job_count)
 	}
 	base_state = node_ptr->node_state & NODE_STATE_BASE;
 	if ((base_state == NODE_STATE_DOWN)
-	||  (node_ptr->node_state & NODE_STATE_DRAIN))
+	||  (node_ptr->node_state & (NODE_STATE_DRAIN | NODE_STATE_FAIL)))
 		bit_clear (avail_node_bitmap, node_inx);
 	else
 		bit_set   (avail_node_bitmap, node_inx);
@@ -1859,7 +1940,10 @@ static void _node_did_resp(struct node_record *node_ptr)
 		last_node_update = now;
 		node_ptr->last_idle = now;
 		node_ptr->node_state = NODE_STATE_IDLE | node_flags;
-		jobacct_g_node_up(node_ptr, now);
+		if ((node_flags & (NODE_STATE_DRAIN | NODE_STATE_FAIL)) == 0)
+			clusteracct_storage_g_node_up(acct_db_conn, 
+						      slurmctld_cluster_name,
+						      node_ptr, now);
 	}
 	if ((base_state == NODE_STATE_DOWN) &&
 	    (slurmctld_conf.ret2service == 1) &&
@@ -1872,7 +1956,10 @@ static void _node_did_resp(struct node_record *node_ptr)
 			node_ptr->name);
 		xfree(node_ptr->reason);
 		trigger_node_up(node_ptr);
-		jobacct_g_node_up(node_ptr, now);
+		if ((node_flags & (NODE_STATE_DRAIN | NODE_STATE_FAIL)) == 0)
+			clusteracct_storage_g_node_up(acct_db_conn, 
+						      slurmctld_cluster_name,
+						      node_ptr, now);
 	}
 	base_state = node_ptr->node_state & NODE_STATE_BASE;
 	if ((base_state == NODE_STATE_IDLE) 
@@ -1881,7 +1968,7 @@ static void _node_did_resp(struct node_record *node_ptr)
 		bit_set (share_node_bitmap, node_inx);
 	}
 	if ((base_state == NODE_STATE_DOWN)
-	||  (node_flags & NODE_STATE_DRAIN))
+	||  (node_flags & (NODE_STATE_DRAIN | NODE_STATE_FAIL)))
 		bit_clear (avail_node_bitmap, node_inx);
 	else
 		bit_set   (avail_node_bitmap, node_inx);
@@ -1946,8 +2033,8 @@ static void _node_not_resp (struct node_record *node_ptr, time_t msg_time)
 }
 
 /*
- * set_node_down - make the specified node's state DOWN if possible
- *	(not in a DRAIN state), kill jobs as needed 
+ * set_node_down - make the specified node's state DOWN and
+ *	kill jobs as needed 
  * IN name - name of the node 
  * IN reason - why the node is DOWN
  */
@@ -2173,8 +2260,13 @@ extern void make_node_comp(struct node_record *node_ptr,
 	if ((node_ptr->run_job_cnt  == 0)
 	&&  (node_ptr->comp_job_cnt == 0)) {
 		bit_set(idle_node_bitmap, inx);
-		if (node_ptr->node_state & NODE_STATE_DRAIN)
-			jobacct_g_node_down(node_ptr, now, NULL);
+		if ((node_ptr->node_state & NODE_STATE_DRAIN) ||
+		    (node_ptr->node_state & NODE_STATE_FAIL)) {
+			trigger_node_drained(node_ptr);
+			clusteracct_storage_g_node_down(acct_db_conn, 
+							slurmctld_cluster_name,
+							node_ptr, now, NULL);
+		}
 	}
 
 	if (base_state == NODE_STATE_DOWN) {
@@ -2205,7 +2297,9 @@ static void _make_node_down(struct node_record *node_ptr, time_t event_time)
 	bit_clear (up_node_bitmap,    inx);
 	select_g_update_node_state(inx, node_ptr->node_state);	
 	trigger_node_down(node_ptr);
-	jobacct_g_node_down(node_ptr, event_time, NULL);
+	clusteracct_storage_g_node_down(acct_db_conn, 
+					slurmctld_cluster_name,
+					node_ptr, event_time, NULL);
 }
 
 /*
@@ -2270,7 +2364,7 @@ void make_node_idle(struct node_record *node_ptr,
 	if (base_state == NODE_STATE_DOWN) {
 		debug3("make_node_idle: Node %s being left DOWN",
 			node_ptr->name);
-	} else if ((node_ptr->node_state & NODE_STATE_DRAIN) &&
+	} else if ((node_flags & (NODE_STATE_DRAIN | NODE_STATE_FAIL)) &&
 	           (node_ptr->run_job_cnt == 0) &&
 	           (node_ptr->comp_job_cnt == 0)) {
 		node_ptr->node_state = NODE_STATE_IDLE | node_flags;
@@ -2279,7 +2373,10 @@ void make_node_idle(struct node_record *node_ptr,
 		debug3("make_node_idle: Node %s is DRAINED", 
 		       node_ptr->name);
 		node_ptr->last_idle = now;
-		jobacct_g_node_down(node_ptr, now, NULL);
+		trigger_node_drained(node_ptr);
+		clusteracct_storage_g_node_down(acct_db_conn, 
+						slurmctld_cluster_name,
+						node_ptr, now, NULL);
 	} else if (node_ptr->run_job_cnt) {
 		node_ptr->node_state = NODE_STATE_ALLOCATED | node_flags;
 	} else {
@@ -2302,8 +2399,12 @@ void node_fini(void)
 	}
 
 	for (i=0; i< node_record_count; i++) {
-		xfree(node_record_table_ptr[i].part_pptr);
+		xfree(node_record_table_ptr[i].arch);
+		xfree(node_record_table_ptr[i].comm_name);
 		xfree(node_record_table_ptr[i].features);
+		xfree(node_record_table_ptr[i].name);
+		xfree(node_record_table_ptr[i].os);
+		xfree(node_record_table_ptr[i].part_pptr);
 		xfree(node_record_table_ptr[i].reason);
 	}
 
diff --git a/src/slurmctld/node_scheduler.c b/src/slurmctld/node_scheduler.c
index b92527b9a37b954f7e6418495f826f47a88e3742..2798ba45ecfed288d005fe274f874c05c87dfa97 100644
--- a/src/slurmctld/node_scheduler.c
+++ b/src/slurmctld/node_scheduler.c
@@ -1,13 +1,12 @@
 /*****************************************************************************\
  *  node_scheduler.c - select and allocated nodes to jobs 
  *	Note: there is a global node table (node_record_table_ptr) 
- *
- *  $Id: node_scheduler.c 13639 2008-03-18 19:25:32Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -57,19 +56,19 @@
 #include <slurm/slurm_errno.h>
 
 #include "src/common/hostlist.h"
+#include "src/common/list.h"
 #include "src/common/node_select.h"
 #include "src/common/xassert.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_accounting_storage.h"
 
 #include "src/slurmctld/agent.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/node_scheduler.h"
 #include "src/slurmctld/sched_plugin.h"
 #include "src/slurmctld/slurmctld.h"
 
-#define FEATURE_OP_OR  0
-#define FEATURE_OP_AND 1
 #define MAX_FEATURES  32	/* max exclusive features "[fs1|fs2]"=2 */
 #define MAX_RETRIES   10
 
@@ -82,44 +81,37 @@ struct node_set {		/* set of nodes with same configuration */
 	uint32_t real_memory;
 	uint32_t nodes;
 	uint32_t weight;
+	char     *features;
 	bitstr_t *feature_bits;
 	bitstr_t *my_bitmap;
 };
 
-static int _add_node_set_info(struct node_set *node_set_ptr, 
-			      bitstr_t ** node_bitmap, 
-			      int *node_cnt, int *cpu_cnt, 
-			      const int mem_cnt, int cr_enabled,
-			      struct job_record *job);
+static int  _build_feature_list(struct job_record *job_ptr);
 static int  _build_node_list(struct job_record *job_ptr, 
 			     struct node_set **node_set_pptr,
 			     int *node_set_size);
+static void _feature_list_delete(void *x);
 static void _filter_nodes_in_set(struct node_set *node_set_ptr,
 				 struct job_details *detail_ptr);
-static int _job_count_bitmap(bitstr_t * bitmap, bitstr_t * jobmap,
-			     int job_cnt); 
 static int _match_feature(char *seek, char *available);
 static int _nodes_in_sets(bitstr_t *req_bitmap, 
 			  struct node_set * node_set_ptr, 
 			  int node_set_size);
-static int _pick_best_load(struct job_record *job_ptr, bitstr_t * bitmap, 
-			uint32_t min_nodes, uint32_t max_nodes, 
-			uint32_t req_nodes, bool test_only);
 static int _pick_best_nodes(struct node_set *node_set_ptr,
 			    int node_set_size, bitstr_t ** select_bitmap,
 			    struct job_record *job_ptr,
 			    struct part_record *part_ptr,
 			    uint32_t min_nodes, uint32_t max_nodes,
-			    uint32_t req_nodes);
-static bitstr_t *_valid_features(char *requested, char *available);
+			    uint32_t req_nodes, bool test_only);
+static void _print_feature_list(uint32_t job_id, List feature_list);
+static bitstr_t *_valid_features(struct job_details *detail_ptr, 
+				 char *available);
 
 
 /*
  * allocate_nodes - change state of specified nodes to NODE_STATE_ALLOCATED
+ *	also claim required licenses
  * IN job_ptr - job being allocated resources
- * globals: node_record_count - number of nodes in the system
- *	node_record_table_ptr - pointer to global node table
- *	last_node_update - last update time of node table
  */
 extern void allocate_nodes(struct job_record *job_ptr)
 {
@@ -131,44 +123,21 @@ extern void allocate_nodes(struct job_record *job_ptr)
 		if (bit_test(job_ptr->node_bitmap, i))
 			make_node_alloc(&node_record_table_ptr[i], job_ptr);
 	}
-	return;
-}
-
-
-/*
- * count_cpus - report how many cpus are associated with the identified nodes 
- * IN bitmap - map of nodes to tally
- * RET cpu count
- * globals: node_record_count - number of nodes configured
- *	node_record_table_ptr - pointer to global node table
- */
-extern int count_cpus(bitstr_t *bitmap)
-{
-	int i, sum;
 
-	sum = 0;
-	for (i = 0; i < node_record_count; i++) {
-		if (bit_test(bitmap, i) != 1)
-			continue;
-		if (slurmctld_conf.fast_schedule)
-			sum += node_record_table_ptr[i].config_ptr->cpus;
-		else
-			sum += node_record_table_ptr[i].cpus;
-	}
-	return sum;
+	license_job_get(job_ptr);
+	return;
 }
 
 
 /*
  * deallocate_nodes - for a given job, deallocate its nodes and make 
  *	their state NODE_STATE_COMPLETING
+ *	also release the job's licenses
  * IN job_ptr - pointer to terminating job (already in some COMPLETING state)
  * IN timeout - true if job exhausted time limit, send REQUEST_KILL_TIMELIMIT
  *	RPC instead of REQUEST_TERMINATE_JOB
  * IN suspended - true if job was already suspended (node's job_run_cnt 
  *	already decremented);
- * globals: node_record_count - number of nodes in the system
- *	node_record_table_ptr - pointer to global node table
  */
 extern void deallocate_nodes(struct job_record *job_ptr, bool timeout, 
 		bool suspended)
@@ -182,6 +151,9 @@ extern void deallocate_nodes(struct job_record *job_ptr, bool timeout,
 	xassert(job_ptr);
 	xassert(job_ptr->details);
 
+	license_job_return(job_ptr);
+	if (slurm_sched_freealloc(job_ptr) != SLURM_SUCCESS)
+		error("slurm_sched_freealloc(%u): %m", job_ptr->job_id);
 	if (select_g_job_fini(job_ptr) != SLURM_SUCCESS)
 		error("select_g_job_fini(%u): %m", job_ptr->job_id);
 	
@@ -193,11 +165,12 @@ extern void deallocate_nodes(struct job_record *job_ptr, bool timeout,
 	agent_args->retry = 0;	/* re_kill_job() resends as needed */
 	agent_args->hostlist = hostlist_create("");
 	kill_job = xmalloc(sizeof(kill_job_msg_t));
-	last_node_update = time(NULL);
-	kill_job->job_id  = job_ptr->job_id;
-	kill_job->job_uid = job_ptr->user_id;
-	kill_job->nodes   = xstrdup(job_ptr->nodes);
-	kill_job->time    = time(NULL);
+	last_node_update    = time(NULL);
+	kill_job->job_id    = job_ptr->job_id;
+	kill_job->job_state = job_ptr->job_state;
+	kill_job->job_uid   = job_ptr->user_id;
+	kill_job->nodes     = xstrdup(job_ptr->nodes);
+	kill_job->time      = time(NULL);
 	kill_job->select_jobinfo = select_g_copy_jobinfo(
 			job_ptr->select_jobinfo);
 
@@ -237,10 +210,6 @@ extern void deallocate_nodes(struct job_record *job_ptr, bool timeout,
 		return;
 	}
 	
-	/* log this in the accounting plugin since it was allocated
-	 * something */
-	jobacct_g_job_complete_slurmctld(job_ptr);
-	
 	agent_args->msg_args = kill_job;
 	agent_queue_request(agent_args);
 	return;
@@ -260,7 +229,7 @@ static int _match_feature(char *seek, char *available)
 	if (seek == NULL)
 		return 1;	/* nothing to look for */
 	if (available == NULL)
-		return SLURM_SUCCESS;	/* nothing to find */
+		return 0;	/* nothing to find */
 
 	tmp_available = xstrdup(available);
 	found = 0;
@@ -278,135 +247,213 @@ static int _match_feature(char *seek, char *available)
 }
 
 
-/*
- * _pick_best_load - Given a specification of scheduling requirements, 
- *	identify the nodes which "best" satisfy the request.
- * 	"best" is defined as the least loaded nodes
- * IN job_ptr - pointer to job being scheduled
- * IN/OUT bitmap - usable nodes are set on input, nodes not required to 
- *	satisfy the request are cleared, other left set
- * IN min_nodes - minimum count of nodes
- * IN max_nodes - maximum count of nodes (0==don't care)
- * IN req_nodes - requested (or desired) count of nodes
- * RET zero on success, EINVAL otherwise
- * globals: node_record_count - count of nodes configured
- *	node_record_table_ptr - pointer to global node table
- * NOTE: bitmap must be a superset of req_nodes at the time that 
- *	_pick_best_load is called
- */
-static int
-_pick_best_load(struct job_record *job_ptr, bitstr_t * bitmap, 
-		uint32_t min_nodes, uint32_t max_nodes, 
-		uint32_t req_nodes, bool test_only)
-{
-	bitstr_t *basemap;
-	int i, max_bit, error_code = EINVAL;
-	int  node_cnt = 0, prev_cnt = 0, set_cnt;
-
-	set_cnt = bit_set_count(bitmap);
-	if ((set_cnt < min_nodes) ||
-	    ((req_nodes > min_nodes) && (set_cnt < req_nodes)))
-		return error_code;	/* not usable */
-
-	if (job_ptr->details && job_ptr->details->req_node_bitmap &&
-	    (!bit_super_set(job_ptr->details->req_node_bitmap, bitmap)))
-		return error_code;	/* required nodes not available */
-
-	basemap = bit_copy(bitmap);
-	if (basemap == NULL)
-		fatal("bit_copy malloc failure");
-
-	max_bit = bit_size(bitmap) - 1;
-	for (i=0; node_cnt<set_cnt; i++) {
-		/* if req_nodes, then start with those as a baseline */
-		if (job_ptr->details && job_ptr->details->req_node_bitmap) {
-			bit_copybits(bitmap, job_ptr->details->req_node_bitmap);
-		} else {
-			bit_nclear(bitmap, 0, max_bit);
-		}
-		node_cnt = _job_count_bitmap(basemap, bitmap, i);
-		if ((node_cnt == 0) || (node_cnt == prev_cnt))
-			continue;	/* nothing new to test */
-		if ((node_cnt < min_nodes) ||
-		    ((req_nodes > min_nodes) && (node_cnt < req_nodes)))
-			continue;	/* need more nodes */
-		error_code = select_g_job_test(job_ptr, bitmap, 
-					       min_nodes, max_nodes, 
-					       req_nodes, test_only);
-		if (!error_code)
-			break;
-		prev_cnt = node_cnt;
-	}
-
-	FREE_NULL_BITMAP(basemap);
-	return error_code;
-}
-
-/*
- * Set the bits in 'jobmap' that correspond to bits in the 'bitmap'
- * that are running 'job_cnt' jobs or less.
- */
-static int
-_job_count_bitmap(bitstr_t * bitmap, bitstr_t * jobmap, int job_cnt) 
-{
-	int i, count = 0;
-	bitoff_t size = bit_size(bitmap);
-
-	for (i = 0; i < size; i++) {
-		if (bit_test(bitmap, i) &&
-		    (node_record_table_ptr[i].run_job_cnt <= job_cnt)) {
-			bit_set(jobmap, i);
-			count++;
-		}
-	}
-	return count;
-}
-
 /*
  * Decide if a job can share nodes with other jobs based on the
  * following three input parameters:
  *
  * IN user_flag - may be 0 (do not share nodes), 1 (node sharing allowed),
  *                or any other number means "don't care"
- * IN part_enum - current partition's node sharing policy
+ * IN part_max_share - current partition's node sharing policy
  * IN cons_res_flag - 1 if the consumable resources flag is enable, 0 otherwise
  *
  * RET - 1 if nodes can be shared, 0 if nodes cannot be shared
+ *
+ *
+ * The followed table details the node SHARED state for the various scenarios
+ *
+ *					part=	part=	part=	part=
+ *	cons_res	user_request	EXCLUS	NO	YES	FORCE
+ *	--------	------------	------	-----	-----	-----
+ *	no		default/exclus	whole	whole	whole	share/O
+ *	no		share=yes	whole	whole	share/O	share/O
+ *	yes		default		whole	share	share/O	share/O
+ *	yes		exclusive	whole	whole	whole	share/O
+ *	yes		share=yes	whole	share	share/O	share/O
+ *
+ * whole   = whole node is allocated exclusively to the user
+ * share   = nodes may be shared but the resources are not overcommitted
+ * share/O = nodes are shared and the resources can be overcommitted
+ *
+ * part->max_share:
+ *	&SHARED_FORCE 	= FORCE
+ *	0		= EXCLUSIVE
+ *	1		= NO
+ *	> 1		= YES
+ *
+ * job_ptr->details->shared:
+ *	(uint16_t)NO_VAL	= default
+ *	0			= exclusive
+ *	1			= share=yes
  */
 static int
-_resolve_shared_status(uint16_t user_flag, uint16_t part_enum,
+_resolve_shared_status(uint16_t user_flag, uint16_t part_max_share,
 		       int cons_res_flag)
 {
-	int shared;
+	/* no sharing if part=EXCLUSIVE */
+	if (part_max_share == 0)
+		return 0;
+	/* sharing if part=FORCE */
+	if (part_max_share & SHARED_FORCE)
+		return 1;
 
 	if (cons_res_flag) {
-		/*
-		 * Consumable resources will always share nodes by default,
-		 * the partition or user has to explicitly disable sharing to
-		 * get exclusive nodes.
-		 */
-		if ((part_enum == SHARED_EXCLUSIVE) || (user_flag == 0))
-			shared = 0;
-		else
-			shared = 1;
+		/* sharing unless user requested exclusive */
+		if (user_flag == 0)
+			return 0;
+		return 1;
 	} else {
-		/* The partition sharing option is only used if
-		 * the consumable resources plugin is NOT in use.
-		 */
-		if (part_enum == SHARED_FORCE)   /* shared=force */
-			shared = 1;
-		else if (part_enum == SHARED_NO) /* can't share */
-			shared = 0;
-		else
-			shared = (user_flag == 1) ? 1 : 0;
+		/* no sharing if part=NO */
+		if (part_max_share == 1)
+			return 0;
+		/* share if the user requested it */
+		if (user_flag == 1)
+			return 1;
 	}
+	return 0;
+}
+
+/*
+ * If the job has required feature counts, then accumulate those 
+ * required resources using multiple calls to _pick_best_nodes()
+ * and adding those selected nodes to the job's required node list.
+ * Upon completion, return job's requirements to match the values
+ * which were in effect upon calling this function.
+ * Input and output are the same as _pick_best_nodes().
+ */
+static int
+_get_req_features(struct node_set *node_set_ptr, int node_set_size,
+		  bitstr_t ** select_bitmap, struct job_record *job_ptr,
+		  struct part_record *part_ptr,
+		  uint32_t min_nodes, uint32_t max_nodes, uint32_t req_nodes,
+		  bool test_only)
+{
+	uint32_t saved_min_nodes, saved_job_min_nodes;
+	bitstr_t *saved_req_node_bitmap = NULL;
+	uint32_t saved_num_procs, saved_req_nodes;
+	int tmp_node_set_size;
+	struct node_set *tmp_node_set_ptr;
+	int error_code = SLURM_SUCCESS, i;
+	bitstr_t *feature_bitmap, *accumulate_bitmap = NULL;
 
-	return shared;
+	/* save job and request state */
+	saved_min_nodes = min_nodes;
+	saved_req_nodes = req_nodes;
+	saved_job_min_nodes = job_ptr->details->min_nodes;
+	if (job_ptr->details->req_node_bitmap) {
+		saved_req_node_bitmap = job_ptr->details->req_node_bitmap;
+		job_ptr->details->req_node_bitmap = NULL;
+	}
+	saved_num_procs = job_ptr->num_procs;
+	job_ptr->num_procs = 1;
+	tmp_node_set_ptr = xmalloc(sizeof(struct node_set) * node_set_size);
+
+	/* Accumulate nodes with required feature counts.
+	 * Ignored if job_ptr->details->req_node_layout is set (by wiki2).
+	 * Selected nodes become part of job's required node list. */
+	if (job_ptr->details->feature_list &&
+	    (job_ptr->details->req_node_layout == NULL)) {
+		ListIterator feat_iter;
+		struct feature_record *feat_ptr;
+		feat_iter = list_iterator_create(job_ptr->details->feature_list);
+		while((feat_ptr = (struct feature_record *)
+				list_next(feat_iter))) {
+			if (feat_ptr->count == 0)
+				continue;
+			tmp_node_set_size = 0;
+			/* _pick_best_nodes() is destructive of the node_set
+			 * data structure, so we need to make a copy then 
+			 * purge it */
+			for (i=0; i<node_set_size; i++) {
+				if (!_match_feature(feat_ptr->name, 
+						node_set_ptr[i].features))
+					continue;
+				tmp_node_set_ptr[tmp_node_set_size].cpus_per_node =
+					node_set_ptr[i].cpus_per_node;
+				tmp_node_set_ptr[tmp_node_set_size].real_memory =
+					node_set_ptr[i].real_memory;
+				tmp_node_set_ptr[tmp_node_set_size].nodes =
+					node_set_ptr[i].nodes;
+				tmp_node_set_ptr[tmp_node_set_size].weight =
+					node_set_ptr[i].weight;
+				tmp_node_set_ptr[tmp_node_set_size].features = 
+					xstrdup(node_set_ptr[i].features);
+				tmp_node_set_ptr[tmp_node_set_size].feature_bits = 
+					bit_copy(node_set_ptr[i].feature_bits);
+				tmp_node_set_ptr[tmp_node_set_size].my_bitmap = 
+					bit_copy(node_set_ptr[i].my_bitmap);
+				tmp_node_set_size++;
+			}
+			feature_bitmap = NULL;
+			min_nodes = feat_ptr->count;
+			req_nodes = feat_ptr->count;
+			job_ptr->details->min_nodes = feat_ptr->count;
+			job_ptr->num_procs = feat_ptr->count;
+			error_code = _pick_best_nodes(tmp_node_set_ptr, 
+					tmp_node_set_size, &feature_bitmap, 
+					job_ptr, part_ptr, min_nodes, 
+					max_nodes, req_nodes, test_only);
+#if 0
+{
+			char *tmp_str = bitmap2node_name(feature_bitmap);
+			info("job %u needs %u nodes with feature %s, using %s", 
+				job_ptr->job_id, feat_ptr->count, 
+				feat_ptr->name, tmp_str);
+			xfree(tmp_str);
 }
+#endif
+			for (i=0; i<tmp_node_set_size; i++) {
+				xfree(tmp_node_set_ptr[i].features);
+				FREE_NULL_BITMAP(tmp_node_set_ptr[i].feature_bits);
+				FREE_NULL_BITMAP(tmp_node_set_ptr[i].my_bitmap);
+			}
+			if (error_code != SLURM_SUCCESS)
+				break;
+			if (feature_bitmap) {
+				if (accumulate_bitmap) {
+					bit_or(accumulate_bitmap, feature_bitmap);
+					bit_free(feature_bitmap);
+				} else
+					accumulate_bitmap = feature_bitmap;
+			}
+		}
+		list_iterator_destroy(feat_iter);
+	}
+
+	/* restore most of job state and accumulate remaining resources */
+	min_nodes = saved_min_nodes;
+	req_nodes = saved_req_nodes;
+	job_ptr->details->min_nodes = saved_job_min_nodes;
+	job_ptr->num_procs = saved_num_procs;
+	if (saved_req_node_bitmap) {
+		FREE_NULL_BITMAP(job_ptr->details->req_node_bitmap);
+		job_ptr->details->req_node_bitmap = 
+				bit_copy(saved_req_node_bitmap);
+	}
+	if (accumulate_bitmap) {
+		if (job_ptr->details->req_node_bitmap) {
+			bit_or(job_ptr->details->req_node_bitmap, 
+				accumulate_bitmap);
+			FREE_NULL_BITMAP(accumulate_bitmap);
+		} else
+			job_ptr->details->req_node_bitmap = accumulate_bitmap;
+	}
+	xfree(tmp_node_set_ptr);
+	if (error_code == SLURM_SUCCESS) {
+		error_code = _pick_best_nodes(node_set_ptr, node_set_size,
+				select_bitmap, job_ptr, part_ptr, min_nodes, 
+				max_nodes, req_nodes, test_only);
+	}
 
+	/* restore job's initial required node bitmap */
+	FREE_NULL_BITMAP(job_ptr->details->req_node_bitmap);
+	job_ptr->details->req_node_bitmap = saved_req_node_bitmap;
+
+
+	return error_code;
+}
 
 /*
- * _pick_best_nodes - from a weigh order list of all nodes satisfying a 
+ * _pick_best_nodes - from a weight order list of all nodes satisfying a 
  *	job's specifications, select the "best" for use
  * IN node_set_ptr - pointer to node specification information
  * IN node_set_size - number of entries in records pointed to by node_set_ptr
@@ -416,6 +463,7 @@ _resolve_shared_status(uint16_t user_flag, uint16_t part_enum,
  * IN min_nodes - minimum count of nodes required by the job
  * IN max_nodes - maximum count of nodes required by the job (0==no limit)
  * IN req_nodes - requested (or desired) count of nodes
+ * IN test_only - do not actually allocate resources
  * RET SLURM_SUCCESS on success, 
  *	ESLURM_NODES_BUSY if request can not be satisfied now, 
  *	ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE if request can never 
@@ -431,9 +479,8 @@ _resolve_shared_status(uint16_t user_flag, uint16_t part_enum,
  *	3) For each feature: find matching node table entries, identify nodes 
  *	   that are up and available (idle or shared) and add them to a bit 
  *	   map
- *	4) If nodes _not_ shared then call select_g_job_test() to select the 
- *	   "best" of those based upon topology, else call _pick_best_load()
- *	   to pick the "best" nodes in terms of workload
+ *	4) Select_g_job_test() to select the "best" of those based upon 
+ *	   topology and/or workload
  *	5) If request can't be satisfied now, execute select_g_job_test() 
  *	   against the list of nodes that exist in any state (perhaps DOWN 
  *	   DRAINED or ALLOCATED) to determine if the request can
@@ -443,62 +490,60 @@ static int
 _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 		 bitstr_t ** select_bitmap, struct job_record *job_ptr,
 		 struct part_record *part_ptr,
-		 uint32_t min_nodes, uint32_t max_nodes, uint32_t req_nodes)
+		 uint32_t min_nodes, uint32_t max_nodes, uint32_t req_nodes,
+		 bool test_only)
 {
 	int error_code = SLURM_SUCCESS, i, j, pick_code;
-	int total_nodes = 0, total_cpus = 0; 
-	uint32_t total_mem = 0; /* total_: total resources configured in
-			      partition */
-	int avail_nodes = 0, avail_cpus = 0;	
-	int avail_mem = 0; /* avail_: resources available for use now */
+	int total_nodes = 0, avail_nodes = 0;	
 	bitstr_t *avail_bitmap = NULL, *total_bitmap = NULL;
 	bitstr_t *backup_bitmap = NULL;
-	bitstr_t *partially_idle_node_bitmap = NULL, *possible_bitmap = NULL;
+	bitstr_t *possible_bitmap = NULL;
+	bitstr_t *partially_idle_node_bitmap = NULL;
 	int max_feature, min_feature;
 	bool runable_ever  = false;	/* Job can ever run */
 	bool runable_avail = false;	/* Job can run with available nodes */
-	bool pick_light_load = false;
-	uint32_t cr_enabled = 0;
-	int shared = 0;
+	bool tried_sched = false;	/* Tried to schedule with avail nodes */
+	static uint32_t cr_enabled = NO_VAL;
 	select_type_plugin_info_t cr_type = SELECT_TYPE_INFO_NONE; 
+	int shared = 0, select_mode;
+
+	if (test_only)
+		select_mode = SELECT_MODE_TEST_ONLY;
+	else
+		select_mode = SELECT_MODE_RUN_NOW;
 
 	if (node_set_size == 0) {
 		info("_pick_best_nodes: empty node set for selection");
 		return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
 	}
 
-        /* Is Consumable Resources enabled? */
-        error_code = select_g_get_info_from_plugin (SELECT_CR_PLUGIN, 
-						    &cr_enabled);
-        if (error_code != SLURM_SUCCESS)
-                return error_code;
+	/* Are Consumable Resources enabled?  Check once. */
+	if (cr_enabled == NO_VAL) {
+		cr_enabled = 0;	/* select/linear and bluegene are no-ops */
+		error_code = select_g_get_info_from_plugin (SELECT_CR_PLUGIN, 
+							    &cr_enabled);
+		if (error_code != SLURM_SUCCESS) {
+			cr_enabled = NO_VAL;
+			return error_code;
+		}
+	}
 
 	shared = _resolve_shared_status(job_ptr->details->shared,
-					part_ptr->shared, cr_enabled);
+					part_ptr->max_share, cr_enabled);
 	job_ptr->details->shared = shared;
 
-        if (cr_enabled) {
-		shared = 0;
+	if (cr_enabled) {
+		/* Determine which nodes might be used by this job based upon
+		 * its ability to share resources */
 		job_ptr->cr_enabled = cr_enabled; /* CR enabled for this job */
 
-		cr_type = (select_type_plugin_info_t) slurmctld_conf.select_type_param;
-		if (cr_type == CR_MEMORY) {
-			shared = 1; /* Sharing set when only memory as a CR is enabled */
-		} else if ((cr_type == CR_SOCKET) 
-			   || (cr_type == CR_CORE) 
-			   || (cr_type == CR_CPU)) {
-			job_ptr->details->job_max_memory = 0;
-		}
-
-                debug3("Job %u in exclusive mode? "
-		     "%d cr_enabled %d CR type %d num_procs %d", 
-		     job_ptr->job_id, 
-		     job_ptr->details->shared ? 0 : 1,
-		     cr_enabled,
-		     cr_type, 
+		cr_type = (select_type_plugin_info_t) slurmctld_conf.
+							select_type_param;
+                debug3("Job %u shared %d cr_enabled %d CR type %d num_procs %d", 
+		     job_ptr->job_id, shared, cr_enabled, cr_type, 
 		     job_ptr->num_procs);
 
-		if (job_ptr->details->shared == 0) {
+		if (shared == 0) {
 			partially_idle_node_bitmap = bit_copy(idle_node_bitmap);
 		} else {
 			/* Update partially_idle_node_bitmap to reflect the
@@ -515,104 +560,52 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
         }
 
 	if (job_ptr->details->req_node_bitmap) {  /* specific nodes required */
-		/* we have already confirmed that all of these nodes have a
-		 * usable configuration and are in the proper partition */
+		/* We have already confirmed that all of these nodes have a
+		 * usable configuration and are in the proper partition.
+		 * Check that these nodes can be used by this job. */
 		if (min_nodes != 0) {
 			total_nodes = bit_set_count(
 				job_ptr->details->req_node_bitmap);
 		}
-		if (job_ptr->num_procs != 0) {
-			if (cr_enabled) {
-				uint16_t tmp16;
-				if ((cr_type == CR_MEMORY)
-				    || (cr_type == CR_SOCKET_MEMORY)
-				    || (cr_type == CR_CORE_MEMORY)
-				    || (cr_type == CR_CPU_MEMORY)) {
-					/* Check if the requested amount of
-					 * memory is available */
-					error_code = select_g_get_extra_jobinfo (
-					    NULL, 
-					    job_ptr, 
-					    SELECT_AVAIL_MEMORY, 
-					    &total_mem);
-					if (error_code != SLURM_SUCCESS) {
-						FREE_NULL_BITMAP(
-							partially_idle_node_bitmap);
-						return ESLURM_NODES_BUSY;
-					}
-				}
-				error_code = select_g_get_extra_jobinfo (
-					NULL, 
-					job_ptr, 
-					SELECT_CPU_COUNT, 
-					&tmp16);
-				if (error_code != SLURM_SUCCESS) {
-					FREE_NULL_BITMAP(
-						partially_idle_node_bitmap);
-					return error_code;
-				}
-				total_cpus = (int) tmp16;
-			} else { 
-				total_cpus = count_cpus(
-					job_ptr->details->req_node_bitmap);
-			}
+		if (total_nodes > max_nodes) {	/* exceeds node limit */
+			FREE_NULL_BITMAP(partially_idle_node_bitmap);
+			return ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
 		}
-		if (total_nodes > max_nodes) {
-			/* exceeds node limit */
-                        if (cr_enabled) 
-                                FREE_NULL_BITMAP(partially_idle_node_bitmap);
+
+		/* check the availability of these nodes */
+		/* Should we check memory availability on these nodes? */
+		if (!bit_super_set(job_ptr->details->req_node_bitmap, 
+				   avail_node_bitmap)) {
+			FREE_NULL_BITMAP(partially_idle_node_bitmap);
 			return ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
 		}
-		if ((min_nodes <= total_nodes) && 
-		    (max_nodes <= min_nodes) &&
-		    (job_ptr->num_procs <= total_cpus )) {
+
+		if (partially_idle_node_bitmap) {
 			if (!bit_super_set(job_ptr->details->req_node_bitmap, 
-                                        avail_node_bitmap)) {
-				if (cr_enabled) { 
-					FREE_NULL_BITMAP(
-						partially_idle_node_bitmap);
-				}
-				return ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
+					   partially_idle_node_bitmap)) {
+				FREE_NULL_BITMAP(partially_idle_node_bitmap);
+				return ESLURM_NODES_BUSY;
 			}
-
-			/* shared needs to be checked before cr_enabled
-			 * to make sure that CR_MEMORY works correctly */
-			if (shared) {
-				if (!bit_super_set(job_ptr->details->
-						   req_node_bitmap, 
-						   share_node_bitmap)) {
-					if (cr_enabled) {
-						FREE_NULL_BITMAP(
-							partially_idle_node_bitmap);
-					}
-					return ESLURM_NODES_BUSY;
-				}
-			} else if (cr_enabled) {
-				if (!bit_super_set(job_ptr->details->
-						   req_node_bitmap, 
-						   partially_idle_node_bitmap)) {
-					FREE_NULL_BITMAP(
-					  partially_idle_node_bitmap);
-					return ESLURM_NODES_BUSY;
-				}
-			} else {
-				if (!bit_super_set(job_ptr->details->
-						   req_node_bitmap, 
-						   idle_node_bitmap)) {
-					return ESLURM_NODES_BUSY;
-				}
+		}
+		if (shared) {
+			if (!bit_super_set(job_ptr->details->req_node_bitmap, 
+					   share_node_bitmap)) {
+				FREE_NULL_BITMAP(partially_idle_node_bitmap);
+				return ESLURM_NODES_BUSY;
+			}
+		} else {
+			if (!bit_super_set(job_ptr->details->req_node_bitmap, 
+					   idle_node_bitmap)) {
+				FREE_NULL_BITMAP(partially_idle_node_bitmap);
+				return ESLURM_NODES_BUSY;
 			}
-			/* still must go through select_g_job_test() to 
-			 * determine validity of request and/or perform
-			 * set-up before job launch */
 		}
-		total_nodes = total_cpus = 0;	/* reinitialize */
-	}
 
-#ifndef HAVE_BG
-	if (shared)
-		pick_light_load = true;
-#endif
+		/* still must go through select_g_job_test() to 
+		 * determine validity of request and/or perform
+		 * set-up before job launch */
+		total_nodes = 0;	/* reinitialize */
+	}
 		
 	/* identify the min and max feature values for exclusive OR */
 	max_feature = -1;
@@ -625,82 +618,62 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 		if ((j >= 0) && (j > max_feature))
 			max_feature = j;
 	}
-		
+
+	/* Accumulate resources for this job based upon its required 
+	 * features (possibly with node counts). */
 	for (j = min_feature; j <= max_feature; j++) {
 		for (i = 0; i < node_set_size; i++) {
 
 			if (!bit_test(node_set_ptr[i].feature_bits, j))
 				continue;
-			if (!runable_ever) {
-				int cr_disabled = 0;
-				total_mem = 0;
-				error_code = _add_node_set_info(
-					&node_set_ptr[i],
-					&total_bitmap, 
-					&total_nodes, 
-					&total_cpus,
-					total_mem, 
-					cr_disabled,
-					job_ptr);
-				if (error_code != SLURM_SUCCESS) {
-					if (cr_enabled) {
-						FREE_NULL_BITMAP(
-							partially_idle_node_bitmap);
-					}
-					FREE_NULL_BITMAP(avail_bitmap);
-					FREE_NULL_BITMAP(total_bitmap);
-					FREE_NULL_BITMAP(possible_bitmap);
-					return error_code;
-				}
+
+			if (total_bitmap)
+				bit_or(total_bitmap, node_set_ptr[i].my_bitmap);
+			else {
+				total_bitmap = bit_copy(
+						node_set_ptr[i].my_bitmap);
+				if (total_bitmap == NULL)
+					fatal("bit_copy malloc failure");
 			}
-			bit_and(node_set_ptr[i].my_bitmap, avail_node_bitmap);
 
-			/* shared needs to be checked before cr_enabled
-			 * to make sure that CR_MEMORY works correctly. */ 
+			bit_and(node_set_ptr[i].my_bitmap, avail_node_bitmap);
+			if (partially_idle_node_bitmap) {
+				bit_and(node_set_ptr[i].my_bitmap,
+					partially_idle_node_bitmap);
+			}
 			if (shared) {
 				bit_and(node_set_ptr[i].my_bitmap,
 					share_node_bitmap);
-			} else if (cr_enabled) {
-				bit_and(node_set_ptr[i].my_bitmap,
-					partially_idle_node_bitmap);
 			} else {
 				bit_and(node_set_ptr[i].my_bitmap,
 					idle_node_bitmap);
 			}
-			node_set_ptr[i].nodes =
-				bit_set_count(node_set_ptr[i].my_bitmap);
-			avail_mem = job_ptr->details->job_max_memory;
-			error_code = _add_node_set_info(&node_set_ptr[i], 
-							&avail_bitmap, 
-                                                        &avail_nodes, 
-							&avail_cpus, 
-							avail_mem,
-							cr_enabled,
-							job_ptr);
-                        if (error_code != SLURM_SUCCESS) {
-				if (cr_enabled) { 
-					FREE_NULL_BITMAP(
-						partially_idle_node_bitmap);
-				}
-				FREE_NULL_BITMAP(total_bitmap);
-				FREE_NULL_BITMAP(avail_bitmap);
-				FREE_NULL_BITMAP(possible_bitmap);
-				return error_code;
+			if (avail_bitmap)
+				bit_or(avail_bitmap, node_set_ptr[i].my_bitmap);
+			else {
+				avail_bitmap = bit_copy(
+					node_set_ptr[i].my_bitmap);
+				if (avail_bitmap == NULL)
+					fatal("bit_copy malloc failure");
+			}
+			avail_nodes = bit_set_count(avail_bitmap);
+			tried_sched = false;	/* need to test these nodes */
+
+			if (shared) {
+				/* Keep accumulating so we can pick the
+				 * most lighly loaded nodes */
+				continue;
 			}
-			if (pick_light_load)
-				continue; /* Keep accumulating */
-			if (avail_nodes == 0)
-				continue; /* Keep accumulating */
+
 			if ((job_ptr->details->req_node_bitmap) &&
 			    (!bit_super_set(job_ptr->details->req_node_bitmap, 
 					avail_bitmap)))
 				continue;
+
 			if ((avail_nodes  < min_nodes) ||
-			    ((req_nodes   > min_nodes) && 
+			    ((req_nodes   > min_nodes) &&
 			     (avail_nodes < req_nodes)))
 				continue;	/* Keep accumulating nodes */
-			if (avail_cpus   < job_ptr->num_procs)
-				continue;	/* Keep accumulating CPUs */
 
 			/* NOTE: select_g_job_test() is destructive of
 			 * avail_bitmap, so save a backup copy */
@@ -710,8 +683,7 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 						      min_nodes, 
 						      max_nodes,
 						      req_nodes,
-						      false);
-
+						      select_mode);
 			if (pick_code == SLURM_SUCCESS) {
 				FREE_NULL_BITMAP(backup_bitmap);
 				if (bit_set_count(avail_bitmap) > max_nodes) {
@@ -719,69 +691,33 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 					avail_nodes = 0; 
 					break;
 				}
+				FREE_NULL_BITMAP(partially_idle_node_bitmap);
 				FREE_NULL_BITMAP(total_bitmap);
 				FREE_NULL_BITMAP(possible_bitmap);
-				if (cr_enabled) {
-					FREE_NULL_BITMAP(
-						partially_idle_node_bitmap);
-				}
 				*select_bitmap = avail_bitmap;
 				return SLURM_SUCCESS;
 			} else {
+				tried_sched = true;	/* test failed */
 				FREE_NULL_BITMAP(avail_bitmap);
 				avail_bitmap = backup_bitmap;
 			}
 		} /* for (i = 0; i < node_set_size; i++) */
 
-		/* try picking the lightest load from all
-		   available nodes with this feature set */
-		if (pick_light_load) {
-			backup_bitmap = bit_copy(avail_bitmap);
-			pick_code = _pick_best_load(job_ptr, 
-						    avail_bitmap, 
-						    min_nodes, 
-						    max_nodes,
-						    req_nodes,
-						    false);
-			if (pick_code == SLURM_SUCCESS) {
-				FREE_NULL_BITMAP(backup_bitmap);
-				if (bit_set_count(avail_bitmap) > max_nodes) {
-					avail_nodes = 0; 
-				} else {
-					FREE_NULL_BITMAP(total_bitmap);
-					FREE_NULL_BITMAP(possible_bitmap);
-					if (cr_enabled) {
-						FREE_NULL_BITMAP(
-						    partially_idle_node_bitmap);
-					}
-					*select_bitmap = avail_bitmap;
-					return SLURM_SUCCESS;
-				}
-			} else {
-				FREE_NULL_BITMAP(avail_bitmap);
-				avail_bitmap = backup_bitmap;
-			}
-		}
-
 		/* try to get req_nodes now for this feature */
-		if (avail_bitmap
-		&&  (req_nodes   >  min_nodes) 
+		if (avail_bitmap && (!tried_sched)
 		&&  (avail_nodes >= min_nodes)
-		&&  (avail_nodes <  req_nodes)
 		&&  ((job_ptr->details->req_node_bitmap == NULL) ||
 		     bit_super_set(job_ptr->details->req_node_bitmap, 
                                         avail_bitmap))) {
 			pick_code = select_g_job_test(job_ptr, avail_bitmap, 
 						      min_nodes, max_nodes,
-						      req_nodes, false);
+						      req_nodes, 
+						      select_mode);
 			if ((pick_code == SLURM_SUCCESS) &&
 			     (bit_set_count(avail_bitmap) <= max_nodes)) {
+				FREE_NULL_BITMAP(partially_idle_node_bitmap);
 				FREE_NULL_BITMAP(total_bitmap);
 				FREE_NULL_BITMAP(possible_bitmap);
-				if (cr_enabled) { 
-					FREE_NULL_BITMAP(
-						partially_idle_node_bitmap);
-				}
 				*select_bitmap = avail_bitmap;
 				return SLURM_SUCCESS;
 			}
@@ -789,12 +725,11 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 
 		/* determine if job could possibly run (if all configured 
 		 * nodes available) */
-
+		if (total_bitmap)
+			total_nodes = bit_set_count(total_bitmap);
 		if (total_bitmap
 		&&  (!runable_ever || !runable_avail)
 		&&  (total_nodes >= min_nodes)
-		&&  ((slurmctld_conf.fast_schedule == 0) ||
-		     (total_cpus >= job_ptr->num_procs))
 		&&  ((job_ptr->details->req_node_bitmap == NULL) ||
 		     (bit_super_set(job_ptr->details->req_node_bitmap, 
 					total_bitmap)))) {
@@ -809,9 +744,7 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 							      min_nodes, 
 							      max_nodes,
 							      req_nodes,
-							      true);
-                                if (cr_enabled)
-                                        job_ptr->cr_enabled = 1;
+							      SELECT_MODE_TEST_ONLY);
 				if (pick_code == SLURM_SUCCESS) {
 					runable_ever  = true;
 					if (bit_set_count(avail_bitmap) <=
@@ -828,9 +761,7 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 							      min_nodes, 
 							      max_nodes,
 							      req_nodes, 
-							      true);
-                                if (cr_enabled)
-                                        job_ptr->cr_enabled = 1;
+							      SELECT_MODE_TEST_ONLY);
 				if (pick_code == SLURM_SUCCESS) {
 					FREE_NULL_BITMAP(possible_bitmap);
 					possible_bitmap = total_bitmap;
@@ -845,9 +776,6 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 			break;
 	}
 
-        if (cr_enabled) 
-                FREE_NULL_BITMAP(partially_idle_node_bitmap);
-
 	/* The job is not able to start right now, return a 
 	 * value indicating when the job can start */
 	if (!runable_avail)
@@ -863,134 +791,11 @@ _pick_best_nodes(struct node_set *node_set_ptr, int node_set_size,
 	} else {
 		FREE_NULL_BITMAP(possible_bitmap);
 	}
+	FREE_NULL_BITMAP(partially_idle_node_bitmap);
 	return error_code;
 }
 
 
-/*
- * _add_node_set_info - add info in node_set_ptr to node_bitmap
- * IN node_set_ptr    - node set info
- * IN/OUT node_bitmap - add nodes in set to this bitmap
- * IN/OUT node_cnt    - add count of nodes in set to this total
- * IN/OUT cpu_cnt     - add count of cpus in set to this total
- * IN/OUT mem_cnt     - add count of memory in set to this total
- * IN cr_enabled      - specify if consumable resources (of processors) is enabled
- * IN job_ptr         - the job to be updated
- */
-static int
-_add_node_set_info(struct node_set *node_set_ptr, 
-		   bitstr_t ** node_bitmap, 
-		   int *node_cnt, int *cpu_cnt, 
-		   const int mem_cnt, int cr_enabled,
-		   struct job_record * job_ptr)
-{
-        int error_code = SLURM_SUCCESS, i;
-	int this_cpu_cnt, this_mem_cnt;
-	uint32_t alloc_mem;
-	uint16_t alloc_cpus;
-	uint32_t job_id = job_ptr->job_id;
-
-        xassert(node_set_ptr->my_bitmap);
-
-        if (cr_enabled == 0) {
-		if (*node_bitmap)
-			bit_or(*node_bitmap, node_set_ptr->my_bitmap);
-		else {
-			*node_bitmap = bit_copy(node_set_ptr->my_bitmap);
-			if (*node_bitmap == NULL)
-				fatal("bit_copy malloc failure");
-		}
-                *node_cnt += node_set_ptr->nodes;
-		if (slurmctld_conf.fast_schedule) {
-			*cpu_cnt  += node_set_ptr->nodes * 
-				node_set_ptr->cpus_per_node;
-		} else {
-			for (i = 0; i < node_record_count; i++) {
-				if (bit_test (node_set_ptr->my_bitmap, i) == 0)
-					continue;
-				*cpu_cnt  += node_record_table_ptr[i].cpus;
-			}
-		}
-        } else {
-		int ll; /* layout array index */
-		uint16_t * layout_ptr = NULL;
-		if (job_ptr->details)
-			layout_ptr = job_ptr->details->req_node_layout;
-
-                for (i = 0, ll = -1; i < node_record_count; i++) {
-			if (layout_ptr &&
-			    bit_test(job_ptr->details->req_node_bitmap, i)) {
-				ll ++;
-			}
-                        if (bit_test (node_set_ptr->my_bitmap, i) == 0)
-				continue;
-                        alloc_cpus = 0;
-                        error_code = select_g_get_select_nodeinfo(
-				&node_record_table_ptr[i], 
-				SELECT_ALLOC_CPUS, 
-				&alloc_cpus);
-                        if (error_code != SLURM_SUCCESS) {
-				error("cons_res: Invalid Node reference %s", 
-				      node_record_table_ptr[i].name);
-				return error_code;
-			}
-                        alloc_mem = 0;
-                        error_code = select_g_get_select_nodeinfo(
-				&node_record_table_ptr[i], 
-				SELECT_ALLOC_MEMORY, 
-				&alloc_mem);
-                        if (error_code != SLURM_SUCCESS) {
-				error("cons_res: Invalid Node reference %s", 
-				      node_record_table_ptr[i]. name);
-				return error_code;
-			}
-
-			/* Determine processors and memory available for use */
-			if (slurmctld_conf.fast_schedule) {
-				this_cpu_cnt = node_set_ptr->cpus_per_node - 
-					alloc_cpus;
-				this_mem_cnt = (node_set_ptr->real_memory - 
-					alloc_mem) - mem_cnt;
-			} else {
-				this_cpu_cnt = node_record_table_ptr[i].cpus -
-					alloc_cpus;
-				this_mem_cnt = (node_record_table_ptr[i].real_memory -
-					alloc_mem) - mem_cnt;
-			}                       
-
-			debug3("_add_node_set_info %u %s this_cpu_cnt %d"
-				" this_mem_cnt %d", 
-				job_id, node_record_table_ptr[i].name, 
-				this_cpu_cnt, this_mem_cnt);
-
-			if (layout_ptr &&
-			    bit_test(job_ptr->details->req_node_bitmap, i)) {
-				this_cpu_cnt = MIN(this_cpu_cnt, layout_ptr[ll]);
-				debug3("_add_node_set_info %u %s this_cpu_cnt"
-				       " limited by task layout %d: %u",
-					job_id, node_record_table_ptr[i].name,
-					ll, layout_ptr[ll]);
-			} else if (layout_ptr) {
-				this_cpu_cnt = 0;
-			}
-
-			if ((this_cpu_cnt > 0) && (this_mem_cnt > 0)) {
-				*node_cnt += 1;
-				*cpu_cnt  += this_cpu_cnt;
-				
-				if (*node_bitmap)
-					bit_or(*node_bitmap, node_set_ptr->my_bitmap);
-				else {
-					*node_bitmap = bit_copy(node_set_ptr->my_bitmap);
-					if (*node_bitmap == NULL)
-						fatal("bit_copy malloc failure");
-				}
-			}
-                }
-        }
-        return error_code;
-}
-
 /*
  * select_nodes - select and allocate nodes to a specific job
  * IN job_ptr - pointer to the job record
@@ -1107,24 +912,28 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 	if (max_nodes < min_nodes) {
 		error_code = ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
 	} else {
-		error_code = _pick_best_nodes(node_set_ptr, node_set_size,
-					      &select_bitmap, job_ptr,
-					      part_ptr, min_nodes, max_nodes,
-					      req_nodes);
+		/* Select resources for the job here */
+		error_code = _get_req_features(node_set_ptr, node_set_size,
+					       &select_bitmap, job_ptr,
+					       part_ptr, min_nodes, max_nodes,
+					       req_nodes, test_only);
 	}
 
 	if (error_code) {
-		job_ptr->state_reason = WAIT_RESOURCES;
 		if (error_code == ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE) {
 			/* Required nodes are down or 
 			 * too many nodes requested */
 			debug3("JobId=%u not runnable with present config",
 			       job_ptr->job_id);
+			job_ptr->state_reason = WAIT_PART_NODE_LIMIT;
 			if (job_ptr->priority != 0)  /* Move to end of queue */
 				job_ptr->priority = 1;
 			last_job_update = now;
-		} else if (error_code == ESLURM_NODES_BUSY)
-			slurm_sched_job_is_pending();
+		} else {
+			job_ptr->state_reason = WAIT_RESOURCES;
+			if (error_code == ESLURM_NODES_BUSY)
+				slurm_sched_job_is_pending();
+		}
 		goto cleanup;
 	}
 	if (test_only) {	/* set if job not highest priority */
@@ -1140,10 +949,26 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 	xfree(job_ptr->nodes);
 
 	job_ptr->node_bitmap = select_bitmap;
+
+	/* we need to have these times set to know when the endtime
+	 * is for the job when we place it
+	 */
+	job_ptr->start_time = job_ptr->time_last_active = now;
+	if (job_ptr->time_limit == NO_VAL)
+		job_ptr->time_limit = part_ptr->max_time;
+	if (job_ptr->time_limit == INFINITE)
+		job_ptr->end_time = job_ptr->start_time + 
+				    (365 * 24 * 60 * 60); /* secs in year */
+	else
+		job_ptr->end_time = job_ptr->start_time + 
+				    (job_ptr->time_limit * 60);   /* secs */
+
 	if (select_g_job_begin(job_ptr) != SLURM_SUCCESS) {
 		/* Leave job queued, something is hosed */
 		error("select_g_job_begin(%u): %m", job_ptr->job_id);
 		error_code = ESLURM_NODES_BUSY;
+		job_ptr->start_time = job_ptr->time_last_active 
+			= job_ptr->end_time = 0;
 		goto cleanup;
 	}
 
@@ -1158,19 +983,12 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 		error("select_g_update_nodeinfo(%u): %m", job_ptr->job_id);
 		/* not critical ... by now */
 	}
-	job_ptr->start_time = job_ptr->time_last_active = now;
-	if (job_ptr->time_limit == NO_VAL)
-		job_ptr->time_limit = part_ptr->max_time;
-	if (job_ptr->time_limit == INFINITE)
-		job_ptr->end_time = job_ptr->start_time + 
-				    (365 * 24 * 60 * 60); /* secs in year */
-	else
-		job_ptr->end_time = job_ptr->start_time + 
-				    (job_ptr->time_limit * 60);   /* secs */
 	if (job_ptr->mail_type & MAIL_JOB_BEGIN)
 		mail_job_info(job_ptr, MAIL_JOB_BEGIN);
 
-	jobacct_g_job_start_slurmctld(job_ptr);
+	jobacct_storage_g_job_start(acct_db_conn, job_ptr);
+
+	slurm_sched_newalloc(job_ptr);
 
       cleanup:
 	if (select_node_bitmap)
@@ -1179,6 +997,7 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 		FREE_NULL_BITMAP(select_bitmap);
 	if (node_set_ptr) {
 		for (i = 0; i < node_set_size; i++) {
+			xfree(node_set_ptr[i].features);
 			FREE_NULL_BITMAP(node_set_ptr[i].my_bitmap);
 			FREE_NULL_BITMAP(node_set_ptr[i].feature_bits);
 		}
@@ -1187,8 +1006,247 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 	return error_code;
 }
 
+static void _print_feature_list(uint32_t job_id, List feature_list)
+{
+	ListIterator feat_iter;
+	struct feature_record *feat_ptr;
+	char *buf = NULL, tmp[16];
+	int bracket = 0;
+
+	if (feature_list == NULL) {
+		info("Job %u feature list is empty", job_id);
+		return;
+	}
+
+	feat_iter = list_iterator_create(feature_list);
+	while((feat_ptr = (struct feature_record *)list_next(feat_iter))) {
+		if (feat_ptr->op_code == FEATURE_OP_XOR) {
+			if (bracket == 0)
+				xstrcat(buf, "[");
+			bracket = 1;
+		}
+		xstrcat(buf, feat_ptr->name);
+		if (feat_ptr->count) {
+			snprintf(tmp, sizeof(tmp), "*%u", feat_ptr->count);
+			xstrcat(buf, tmp);
+		}
+		if (bracket && (feat_ptr->op_code != FEATURE_OP_XOR)) {
+			xstrcat(buf, "]");
+			bracket = 0;
+		}
+		if (feat_ptr->op_code == FEATURE_OP_AND)
+			xstrcat(buf, "&");
+		else if ((feat_ptr->op_code == FEATURE_OP_OR) ||
+			 (feat_ptr->op_code == FEATURE_OP_XOR))
+			xstrcat(buf, "|");
+	}
+	list_iterator_destroy(feat_iter);
+	info("Job %u feature list: %s", job_id, buf);
+	xfree(buf);
+}
+
+static void _feature_list_delete(void *x)
+{
+	struct feature_record *feature = (struct feature_record *)x;
+	xfree(feature->name);
+	xfree(feature);
+}
+
+/*
+ * _build_feature_list - Translate a job's feature string into a feature_list
+ * IN  details->features
+ * OUT details->feature_list
+ * RET error code
+ */
+static int _build_feature_list(struct job_record *job_ptr)
+{
+	struct job_details *detail_ptr = job_ptr->details;
+	char *tmp_requested, *str_ptr1, *str_ptr2, *feature = NULL;
+	int bracket = 0, count = 0, i;
+	bool have_count = false, have_or = false;
+	struct feature_record *feat;
+
+	if (detail_ptr->features == NULL)	/* no constraints */
+		return SLURM_SUCCESS;
+	if (detail_ptr->feature_list)		/* already processed */
+		return SLURM_SUCCESS;
+
+	tmp_requested = xstrdup(detail_ptr->features);
+	str_ptr1 = tmp_requested;
+	detail_ptr->feature_list = list_create(_feature_list_delete);
+	for (i=0; ; i++) {
+		if (tmp_requested[i] == '*') {
+			tmp_requested[i] = '\0';
+			have_count = true;
+			count = strtol(&tmp_requested[i+1], &str_ptr2, 10);
+			if ((feature == NULL) || (count <= 0)) {
+				info("Job %u invalid constraint %s", 
+					job_ptr->job_id, detail_ptr->features);
+				xfree(tmp_requested);
+				return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+			}
+			i = str_ptr2 - tmp_requested - 1;
+		} else if (tmp_requested[i] == '&') {
+			tmp_requested[i] = '\0';
+			if ((feature == NULL) || (bracket != 0)) {
+				info("Job %u invalid constraint %s", 
+					job_ptr->job_id, detail_ptr->features);
+				xfree(tmp_requested);
+				return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+			}
+			feat = xmalloc(sizeof(struct feature_record));
+			feat->name = xstrdup(feature);
+			feat->count = count;
+			feat->op_code = FEATURE_OP_AND;
+			list_append(detail_ptr->feature_list, feat);
+			feature = NULL;
+			count = 0;
+		} else if (tmp_requested[i] == '|') {
+			tmp_requested[i] = '\0';
+			have_or = true;
+			if (feature == NULL) {
+				info("Job %u invalid constraint %s", 
+					job_ptr->job_id, detail_ptr->features);
+				xfree(tmp_requested);
+				return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+			}
+			feat = xmalloc(sizeof(struct feature_record));
+			feat->name = xstrdup(feature);
+			feat->count = count;
+			if (bracket)
+				feat->op_code = FEATURE_OP_XOR;
+			else
+				feat->op_code = FEATURE_OP_OR;
+			list_append(detail_ptr->feature_list, feat);
+			feature = NULL;
+			count = 0;
+		} else if (tmp_requested[i] == '[') {
+			tmp_requested[i] = '\0';
+			if ((feature != NULL) || bracket) {
+				info("Job %u invalid constraint %s", 
+					job_ptr->job_id, detail_ptr->features);
+				xfree(tmp_requested);
+				return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+			}
+			bracket++;
+		} else if (tmp_requested[i] == ']') {
+			tmp_requested[i] = '\0';
+			if ((feature == NULL) || (bracket == 0)) {
+				info("Job %u invalid constraint %s", 
+					job_ptr->job_id, detail_ptr->features);
+				xfree(tmp_requested);
+				return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+			}
+			bracket = 0;
+		} else if (tmp_requested[i] == '\0') {
+			if (feature) {
+				feat = xmalloc(sizeof(struct feature_record));
+				feat->name = xstrdup(feature);
+				feat->count = count;
+				feat->op_code = FEATURE_OP_END;
+				list_append(detail_ptr->feature_list, feat);
+			}
+			break;
+		} else if (feature == NULL) {
+			feature = &tmp_requested[i];
+		}
+	}
+	xfree(tmp_requested);
+	if (have_count && have_or) {
+		info("Job %u invalid constraint (OR with feature count): %s", 
+			job_ptr->job_id, detail_ptr->features);
+		return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+	}
+
+	_print_feature_list(job_ptr->job_id, detail_ptr->feature_list);
+	return SLURM_SUCCESS;
+}
+
+/*
+ * job_req_node_filter - job reqeust node filter.
+ *	clear from a bitmap the nodes which can not be used for a job
+ *	test memory size, required features, processor count, etc.
+ * NOTE: Does not support exclusive OR of features or feature counts.
+ *	It just matches first element of XOR and ignores count.
+ * IN job_ptr - pointer to node to be scheduled
+ * IN/OUT bitmap - set of nodes being considered for use
+ * RET SLURM_SUCCESS or EINVAL if can't filter (exclusive OR of features)
+ */
+extern int job_req_node_filter(struct job_record *job_ptr, 
+			       bitstr_t *avail_bitmap)
+{
+	int i;
+	struct job_details *detail_ptr = job_ptr->details;
+	multi_core_data_t *mc_ptr;
+	struct node_record *node_ptr;
+	struct config_record *config_ptr;
+	bitstr_t *feature_bitmap = NULL;
+
+	if (detail_ptr == NULL) {
+		error("job_req_node_filter: job %u has no details", 
+		      job_ptr->job_id);
+		return EINVAL;
+	}
+	if (_build_feature_list(job_ptr))
+		return EINVAL;
+
+	mc_ptr = detail_ptr->mc_ptr;
+	for (i=0; i< node_record_count; i++) {
+		if (!bit_test(avail_bitmap, i))
+			continue;
+		node_ptr = node_record_table_ptr + i;
+		config_ptr = node_ptr->config_ptr;
+		feature_bitmap = _valid_features(detail_ptr, config_ptr->feature);
+		if ((feature_bitmap == NULL) || (!bit_test(feature_bitmap, 0))) {
+			bit_clear(avail_bitmap, i);
+			continue;
+		}
+		FREE_NULL_BITMAP(feature_bitmap);
+		if (slurmctld_conf.fast_schedule) {
+			if ((detail_ptr->job_min_procs    > config_ptr->cpus       )
+			||  (detail_ptr->job_min_memory   > config_ptr->real_memory) 
+			||  (detail_ptr->job_min_tmp_disk > config_ptr->tmp_disk)) {
+				bit_clear(avail_bitmap, i);
+				continue;
+			}
+			if (mc_ptr
+			&&  ((mc_ptr->min_sockets     > config_ptr->sockets  )
+			||   (mc_ptr->min_cores       > config_ptr->cores    )
+			||   (mc_ptr->min_threads     > config_ptr->threads  )
+			||   (mc_ptr->job_min_sockets > config_ptr->sockets  )
+			||   (mc_ptr->job_min_cores   > config_ptr->cores    )
+			||   (mc_ptr->job_min_threads > config_ptr->threads  ))) {
+				bit_clear(avail_bitmap, i);
+				continue;
+			}
+		} else {
+			if ((detail_ptr->job_min_procs    > node_ptr->cpus       )
+			||  (detail_ptr->job_min_memory   > node_ptr->real_memory) 
+			||  (detail_ptr->job_min_tmp_disk > node_ptr->tmp_disk)) {
+				bit_clear(avail_bitmap, i);
+				continue;
+			}
+			if (mc_ptr
+			&&  ((mc_ptr->min_sockets     > node_ptr->sockets  )
+			||   (mc_ptr->min_cores       > node_ptr->cores    )
+			||   (mc_ptr->min_threads     > node_ptr->threads  )
+			||   (mc_ptr->job_min_sockets > node_ptr->sockets  )
+			||   (mc_ptr->job_min_cores   > node_ptr->cores    )
+			||   (mc_ptr->job_min_threads > node_ptr->threads  ))) {
+				bit_clear(avail_bitmap, i);
+				continue;
+			}
+		}
+	}
+	FREE_NULL_BITMAP(feature_bitmap);
+	return SLURM_SUCCESS;
+}
+
 /*
  * _build_node_list - identify which nodes could be allocated to a job
+ *	based upon node features, memory, processors, etc. Note that a
+ *	bitmap is set to indicate which of the job's features that the
+ *	nodes satisfy.
  * IN job_ptr - pointer to node to be scheduled
  * OUT node_set_pptr - list of node sets which could be used for the job
  * OUT node_set_size - number of node_set entries
@@ -1209,6 +1267,11 @@ static int _build_node_list(struct job_record *job_ptr,
 	multi_core_data_t *mc_ptr = detail_ptr->mc_ptr;
 	bitstr_t *tmp_feature;
 
+	if (detail_ptr->features && (detail_ptr->feature_list == NULL)) {
+		int error_code = _build_feature_list(job_ptr);
+		if (error_code)
+			return error_code;
+	}
 	node_set_inx = 0;
 	node_set_ptr = (struct node_set *) 
 			xmalloc(sizeof(struct node_set) * 2);
@@ -1275,7 +1338,7 @@ static int _build_node_list(struct job_record *job_ptr,
 			continue;
 		}
 
-		tmp_feature = _valid_features(job_ptr->details->features,
+		tmp_feature = _valid_features(job_ptr->details,
 					      config_ptr->feature);
 		if (tmp_feature == NULL) {
 			FREE_NULL_BITMAP(node_set_ptr[node_set_inx].my_bitmap);
@@ -1288,7 +1351,9 @@ static int _build_node_list(struct job_record *job_ptr,
 		node_set_ptr[node_set_inx].real_memory =
 			config_ptr->real_memory;		
 		node_set_ptr[node_set_inx].weight =
-		    config_ptr->weight;
+			config_ptr->weight;
+		node_set_ptr[node_set_inx].features = 
+			xstrdup(config_ptr->feature);
 		node_set_ptr[node_set_inx].feature_bits = tmp_feature;
 		debug2("found %d usable nodes from config containing %s",
 		       node_set_ptr[node_set_inx].nodes, config_ptr->nodes);
@@ -1300,6 +1365,7 @@ static int _build_node_list(struct job_record *job_ptr,
 	}
 	list_iterator_destroy(config_iterator);
 	/* eliminate last (incomplete) node_set record */
+	xfree(node_set_ptr[node_set_inx].features);
 	FREE_NULL_BITMAP(node_set_ptr[node_set_inx].my_bitmap);
 	FREE_NULL_BITMAP(node_set_ptr[node_set_inx].feature_bits);
 	FREE_NULL_BITMAP(exc_node_mask);
@@ -1440,6 +1506,7 @@ extern void build_node_details(struct job_record *job_ptr)
 		job_ptr->node_addr = NULL;
 		job_ptr->alloc_lps_cnt = 0;
 		xfree(job_ptr->alloc_lps);
+		xfree(job_ptr->used_lps);
 		return;
 	}
 
@@ -1461,6 +1528,8 @@ extern void build_node_details(struct job_record *job_ptr)
 	job_ptr->alloc_lps_cnt = job_ptr->node_cnt;
 	xrealloc(job_ptr->alloc_lps,
 		(sizeof(uint32_t) * job_ptr->node_cnt));
+	xrealloc(job_ptr->used_lps,
+		(sizeof(uint32_t) * job_ptr->node_cnt));
 
 	while ((this_node_name = hostlist_shift(host_list))) {
 		node_ptr = find_node_record(this_node_name);
@@ -1478,6 +1547,8 @@ extern void build_node_details(struct job_record *job_ptr)
 					job_ptr->num_procs;
 				total_procs += job_ptr->num_procs;
 				job_ptr->cpu_count_reps[cpu_inx] = 1;
+				job_ptr->alloc_lps[0] = job_ptr->num_procs;
+				job_ptr->used_lps[0]  = 0;
 				goto cleanup;
 			}
 #endif
@@ -1486,14 +1557,19 @@ extern void build_node_details(struct job_record *job_ptr)
 				&usable_lps);
 			if (error_code == SLURM_SUCCESS) {
 				if (job_ptr->alloc_lps) {
+					job_ptr->used_lps[cr_count] = 0;
 					job_ptr->alloc_lps[cr_count++] =
 								usable_lps;
 				}
 			} else {
-				xfree(job_ptr->alloc_lps); 
-				job_ptr->alloc_lps_cnt = 0;
 				error("Unable to get extra jobinfo "
 				      "from JobId=%u", job_ptr->job_id);
+				/* Job is likely completed according to 
+				 * select plugin */
+				if (job_ptr->alloc_lps) {
+					job_ptr->used_lps[cr_count] = 0;
+					job_ptr->alloc_lps[cr_count++] = 0;
+				}
 			}
 			
 			memcpy(&job_ptr->node_addr[node_inx++],
@@ -1525,138 +1601,81 @@ extern void build_node_details(struct job_record *job_ptr)
 		      job_ptr->job_id, job_ptr->node_cnt, node_inx);
 	}
 	job_ptr->num_cpu_groups = cpu_inx + 1;
-	if (job_ptr->details)
-		job_ptr->details->total_procs = total_procs;
+	job_ptr->total_procs = total_procs;
 }
 
 /*
  * _valid_features - determine if the requested features are satisfied by
  *	those available
- * IN requested - requested features (by a job)
+ * IN details_ptr - job requirement details, includes requested features
  * IN available - available features (on a node)
- * RET 0 if request is not satisfied, otherwise an integer indicating which 
- *	mutually exclusive feature is satisfied. for example
- *	_valid_features("[fs1|fs2|fs3|fs4]", "fs3") returns 3. see the 
- *	slurm administrator and user guides for details. returns 1 if 
- *	requirements are satisfied without mutually exclusive feature list.
+ * RET NULL if request is not satisfied, otherwise a bitmap indicating 
+ *	which mutually exclusive features are satisfied. For example
+ *	_valid_features("[fs1|fs2|fs3|fs4]", "fs3") returns a bitmap with
+ *	the third bit set. For another example
+ *	_valid_features("[fs1|fs2|fs3|fs4]", "fs1,fs3") returns a bitmap 
+ *	with the first and third bits set. The function returns a bitmap
+ *	with the first bit set if requirements are satisfied without a 
+ *	mutually exclusive feature list.
  */
-static bitstr_t *_valid_features(char *requested, char *available)
+static bitstr_t *_valid_features(struct job_details *details_ptr, 
+				 char *available)
 {
-	char *tmp_requested, *str_ptr1;
-	int bracket, found, i, position, result;
-	int last_op;		/* last operation 0 for or, 1 for and */
-	int save_op = 0, save_result = 0;	/* for bracket support */
 	bitstr_t *result_bits = (bitstr_t *) NULL;
+	ListIterator feat_iter;
+	struct feature_record *feat_ptr;
+	int found, last_op, position = 0, result;
+	int save_op = FEATURE_OP_AND, save_result=1;
 
-	if (requested == NULL) {		/* no constraints */
+	if (details_ptr->feature_list == NULL) {/* no constraints */
 		result_bits = bit_alloc(MAX_FEATURES);
 		bit_set(result_bits, 0);
 		return result_bits;
 	}
-	if (available == NULL)			/* no features */
-		return result_bits;
 
-	tmp_requested = xstrdup(requested);
-	bracket = position = 0;
-	str_ptr1 = tmp_requested;	/* start of feature name */
-	result = 1;			/* assume good for now */
+	result = 1;				/* assume good for now */
 	last_op = FEATURE_OP_AND;
-	for (i=0; ; i++) {
-		if (tmp_requested[i] == '\0') {
-			if (strlen(str_ptr1) == 0)
-				break;
-			found = _match_feature(str_ptr1, available);
-			if (last_op == FEATURE_OP_AND)
-				result &= found;
-			else	/* FEATURE_OP_OR */
-				result |= found;
-			break;
-		}
-
-		if (tmp_requested[i] == '&') {
-			if (bracket != 0) {
-				debug("_valid_features: parsing failure on %s",
-					requested);
-				result = 0;
-				break;
-			}
-			tmp_requested[i] = '\0';
-			found = _match_feature(str_ptr1, available);
-			if (last_op == FEATURE_OP_AND)
-				result &= found;
-			else	/* FEATURE_OP_OR */
+	feat_iter = list_iterator_create(details_ptr->feature_list);
+	while ((feat_ptr = (struct feature_record *) list_next(feat_iter))) {
+		if (feat_ptr->count)
+			found = 1;	/* handle feature counts elsewhere */
+		else
+			found = _match_feature(feat_ptr->name, available);
+
+		if ((last_op == FEATURE_OP_XOR) ||
+		    (feat_ptr->op_code == FEATURE_OP_XOR)) {
+			if (position == 0) {
+				save_op = last_op;
+				save_result = result;
+				result = found;
+			} else
 				result |= found;
-			str_ptr1 = &tmp_requested[i + 1];
-			last_op = FEATURE_OP_AND;
 
-		} else if (tmp_requested[i] == '|') {
-			tmp_requested[i] = '\0';
-			found = _match_feature(str_ptr1, available);
-			if (bracket != 0) {
-				if (found) {
-					if (!result_bits)
-						result_bits = bit_alloc(MAX_FEATURES);
-					if (position < MAX_FEATURES)
-						bit_set(result_bits, (position-1));
-					else
-						error("_valid_features: overflow");
-				}
-				position++;
-			}
-			if (last_op == FEATURE_OP_AND)
-				result &= found;
-			else	/* FEATURE_OP_OR */
-				result |= found;
-			str_ptr1 = &tmp_requested[i + 1];
-			last_op = FEATURE_OP_OR;
+			if (!result_bits)
+				result_bits = bit_alloc(MAX_FEATURES);
 
-		} else if (tmp_requested[i] == '[') {
-			bracket++;
-			position = 1;
-			save_op = last_op;
-			save_result = result;
-			last_op = FEATURE_OP_AND;
-			result = 1;
-			str_ptr1 = &tmp_requested[i + 1];
+			if (!found)
+				;
+			else if (position < MAX_FEATURES)
+				bit_set(result_bits, position);
+			else
+				error("_valid_features: overflow");
+			position++;
 
-		} else if (tmp_requested[i] == ']') {
-			tmp_requested[i] = '\0';
-			found = _match_feature(str_ptr1, available);
-			if (found) {
-				if (!result_bits)
-					result_bits = bit_alloc(MAX_FEATURES);
-				if (position < MAX_FEATURES)
-					bit_set(result_bits, (position-1));
-				else
-					error("_valid_features: overflow");
+			if (feat_ptr->op_code != FEATURE_OP_XOR) {
+				if (save_op == FEATURE_OP_OR)
+					result |= save_result;
+				else /* (save_op == FEATURE_OP_AND) */
+					result &= save_result;
 			}
-			position++;
+		} else if (last_op == FEATURE_OP_OR) {
 			result |= found;
-			if (save_op == FEATURE_OP_AND)
-				result &= save_result;
-			else	/* FEATURE_OP_OR */
-				result |= save_result;
-			if ((tmp_requested[i + 1] == '&')
-			    && (bracket == 1)) {
-				last_op = FEATURE_OP_AND;
-				str_ptr1 = &tmp_requested[i + 2];
-			} else if ((tmp_requested[i + 1] == '|')
-				   && (bracket == 1)) {
-				last_op = FEATURE_OP_OR;
-				str_ptr1 = &tmp_requested[i + 2];
-			} else if ((tmp_requested[i + 1] == '\0')
-				   && (bracket == 1)) {
-				break;
-			} else {
-				debug("_valid_features: parsing failure on %s",
-					requested);
-				result = 0;
-				break;
-			}
-			bracket = 0;
+		} else if (last_op == FEATURE_OP_AND) {
+			result &= found;
 		}
+		last_op = feat_ptr->op_code;
 	}
-	xfree(tmp_requested);
+	list_iterator_destroy(feat_iter);
 
 	if (result) {
 		if (!result_bits) {
diff --git a/src/slurmctld/node_scheduler.h b/src/slurmctld/node_scheduler.h
index d44fa4eff0ccf26c3f1ea96459ef5df98cb92130..42a4bf7dfc18419ab758c73840b3561e875778d2 100644
--- a/src/slurmctld/node_scheduler.h
+++ b/src/slurmctld/node_scheduler.h
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  node_scheduler.h - definitions of functions in node_scheduler.c
  *****************************************************************************
- *  Copyright (C) 2004 The Regents of the University of California.
+ *  Copyright (C) 2004-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -40,10 +41,8 @@
 
 /*
  * allocate_nodes - change state of specified nodes to NODE_STATE_ALLOCATED
+ *	also claim required licenses
  * IN job_ptr - job being allocated resources
- * globals: node_record_count - number of nodes in the system
- *	node_record_table_ptr - pointer to global node table
- *	last_node_update - last update time of node table
  */
 extern void allocate_nodes(struct job_record *job_ptr);
 
@@ -54,25 +53,15 @@ extern void allocate_nodes(struct job_record *job_ptr);
  */
 extern void build_node_details(struct job_record *job_ptr);
 
-/*
- * count_cpus - report how many cpus are associated with the identified nodes 
- * IN bitmap - map of nodes to tally
- * RET cpu count
- * globals: node_record_count - number of nodes configured
- *	node_record_table_ptr - pointer to global node table
- */
-extern int count_cpus(bitstr_t *bitmap);
-
 /*
  * deallocate_nodes - for a given job, deallocate its nodes and make
  *	their state NODE_STATE_COMPLETING
+ *	also release the job's licenses
  * IN job_ptr - pointer to terminating job (already in some COMPLETING state)
  * IN timeout - true if job exhausted time limit, send REQUEST_KILL_TIMELIMIT
  *	RPC instead of REQUEST_TERMINATE_JOB
  * IN suspended - true if job was already suspended (node's job_run_cnt
  *	already decremented);
- * globals: node_record_count - number of nodes in the system
- *	node_record_table_ptr - pointer to global node table
  */
 extern void deallocate_nodes(struct job_record *job_ptr, bool timeout,
 		bool suspended);
diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c
index 4d31c895af885f1945209136ace689ca2f3c10f2..a88b5998b2dc82ff86a778bbc3bf3f6493d088f5 100644
--- a/src/slurmctld/partition_mgr.c
+++ b/src/slurmctld/partition_mgr.c
@@ -2,12 +2,12 @@
  *  partition_mgr.c - manage the partition information of slurm
  *	Note: there is a global partition list (part_list) and
  *	time stamp (last_part_update)
- *  $Id: partition_mgr.c 13279 2008-02-15 00:14:16Z jette $
+ *  $Id: partition_mgr.c 14068 2008-05-19 15:58:22Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -65,10 +65,13 @@
 #include "src/slurmctld/sched_plugin.h"
 #include "src/slurmctld/slurmctld.h"
 
+/* Change PART_STATE_VERSION value when changing the state save format */
+#define PART_STATE_VERSION      "VER001"
+
 /* Global variables */
 struct part_record default_part;	/* default configuration values */
 List part_list = NULL;			/* partition list */
-char default_part_name[MAX_SLURM_NAME];	/* name of default partition */
+char *default_part_name = NULL;		/* name of default partition */
 struct part_record *default_part_loc = NULL; /* default partition location */
 time_t last_part_update;	/* time of last update to partition records */
 
@@ -214,15 +217,19 @@ struct part_record *create_part_record(void)
 	    (struct part_record *) xmalloc(sizeof(struct part_record));
 
 	xassert (part_ptr->magic = PART_MAGIC);  /* set value */
-	strcpy(part_ptr->name, "DEFAULT");
-	part_ptr->hidden    = default_part.hidden;
-	part_ptr->max_time     = default_part.max_time;
-	part_ptr->max_nodes    = default_part.max_nodes;
-	part_ptr->min_nodes    = default_part.min_nodes;
-	part_ptr->root_only    = default_part.root_only;
-	part_ptr->state_up     = default_part.state_up;
-	part_ptr->shared       = default_part.shared;
-	part_ptr->node_bitmap  = NULL;
+	part_ptr->name              = xstrdup("DEFAULT");
+	part_ptr->disable_root_jobs = default_part.disable_root_jobs;
+	part_ptr->hidden            = default_part.hidden;
+	part_ptr->max_time          = default_part.max_time;
+	part_ptr->max_nodes         = default_part.max_nodes;
+	part_ptr->max_nodes_orig    = default_part.max_nodes;
+	part_ptr->min_nodes         = default_part.min_nodes;
+	part_ptr->min_nodes_orig    = default_part.min_nodes;
+	part_ptr->root_only         = default_part.root_only;
+	part_ptr->state_up          = default_part.state_up;
+	part_ptr->max_share         = default_part.max_share;
+	part_ptr->priority          = default_part.priority;
+	part_ptr->node_bitmap       = NULL;
 
 	if (default_part.allow_groups)
 		part_ptr->allow_groups = xstrdup(default_part.allow_groups);
@@ -282,6 +289,7 @@ int dump_all_part_state(void)
 
 	START_TIMER;
 	/* write header: time */
+	packstr(PART_STATE_VERSION, buffer);
 	pack_time(time(NULL), buffer);
 
 	/* write partition records to buffer */
@@ -361,19 +369,20 @@ static void _dump_part_state(struct part_record *part_ptr, Buf buffer)
 	else
 		default_part_flag = 0;
 
-	packstr(part_ptr->name, buffer);
-	pack32(part_ptr->max_time, buffer);
-	pack32(part_ptr->max_nodes, buffer);
-	pack32(part_ptr->min_nodes, buffer);
+	packstr(part_ptr->name,          buffer);
+	pack32(part_ptr->max_time,       buffer);
+	pack32(part_ptr->max_nodes_orig, buffer);
+	pack32(part_ptr->min_nodes_orig, buffer);
 
-	pack16(default_part_flag, buffer);
-	pack16(part_ptr->hidden, buffer);
-	pack16(part_ptr->root_only, buffer);
-	pack16(part_ptr->shared, buffer);
+	pack16(default_part_flag,        buffer);
+	pack16(part_ptr->hidden,         buffer);
+	pack16(part_ptr->root_only,      buffer);
+	pack16(part_ptr->max_share,      buffer);
+	pack16(part_ptr->priority,       buffer);
 
-	pack16(part_ptr->state_up, buffer);
-	packstr(part_ptr->allow_groups, buffer);
-	packstr(part_ptr->nodes, buffer);
+	pack16(part_ptr->state_up,       buffer);
+	packstr(part_ptr->allow_groups,  buffer);
+	packstr(part_ptr->nodes,         buffer);
 }
 
 /*
@@ -387,12 +396,14 @@ int load_all_part_state(void)
 	char *part_name, *allow_groups, *nodes, *state_file, *data = NULL;
 	uint32_t max_time, max_nodes, min_nodes;
 	time_t time;
-	uint16_t name_len, def_part_flag, hidden, root_only, shared, state_up;
+	uint16_t def_part_flag, hidden, root_only;
+	uint16_t max_share, priority, state_up;
 	struct part_record *part_ptr;
-	uint32_t data_size = 0;
+	uint32_t data_size = 0, name_len;
 	int data_allocated, data_read = 0, error_code = 0, part_cnt = 0;
 	int state_fd;
 	Buf buffer;
+	char *ver_str = NULL;
 
 	/* read the file */
 	state_file = xstrdup(slurmctld_conf.state_save_location);
@@ -429,6 +440,18 @@ int load_all_part_state(void)
 	unlock_state_files();
 
 	buffer = create_buf(data, data_size);
+
+	safe_unpackstr_xmalloc( &ver_str, &name_len, buffer);
+	debug3("Version string in part_state header is %s", ver_str);
+	if ((!ver_str) || (strcmp(ver_str, PART_STATE_VERSION) != 0)) {
+		error("**********************************************************");
+		error("Can not recover partition state, data version incompatable");
+		error("**********************************************************");
+		xfree(ver_str);
+		free_buf(buffer);
+		return EFAULT;
+	}
+	xfree(ver_str);
 	safe_unpack_time(&time, buffer);
 
 	while (remaining_buf(buffer) > 0) {
@@ -438,9 +461,10 @@ int load_all_part_state(void)
 		safe_unpack32(&min_nodes, buffer);
 
 		safe_unpack16(&def_part_flag, buffer);
-		safe_unpack16(&hidden, buffer);
+		safe_unpack16(&hidden,    buffer);
 		safe_unpack16(&root_only, buffer);
-		safe_unpack16(&shared, buffer);
+		safe_unpack16(&max_share, buffer);
+		safe_unpack16(&priority,  buffer);
 
 		safe_unpack16(&state_up, buffer);
 		safe_unpackstr_xmalloc(&allow_groups, &name_len, buffer);
@@ -449,10 +473,10 @@ int load_all_part_state(void)
 		/* validity test as possible */
 		if ((def_part_flag > 1) ||
 		    (root_only > 1) || (hidden > 1) ||
-		    (shared > SHARED_EXCLUSIVE) || (state_up > 1)) {
+		    (state_up > 1)) {
 			error("Invalid data for partition %s: def_part_flag=%u, "
-				"hidden=%u root_only=%u, shared=%u, state_up=%u",
-				part_name, def_part_flag, hidden, root_only, shared,
+				"hidden=%u root_only=%u, state_up=%u",
+				part_name, def_part_flag, hidden, root_only,
 				state_up);
 			error("No more partition data will be processed from "
 				"the checkpoint file");
@@ -467,19 +491,23 @@ int load_all_part_state(void)
 
 		if (part_ptr) {
 			part_cnt++;
-			part_ptr->hidden = hidden;
-			part_ptr->max_time  = max_time;
-			part_ptr->max_nodes = max_nodes;
-			part_ptr->min_nodes = min_nodes;
+			part_ptr->hidden         = hidden;
+			part_ptr->max_time       = max_time;
+			part_ptr->max_nodes      = max_nodes;
+			part_ptr->max_nodes_orig = max_nodes;
+			part_ptr->min_nodes      = min_nodes;
+			part_ptr->min_nodes_orig = min_nodes;
 			if (def_part_flag) {
-				strncpy(default_part_name, part_name, MAX_SLURM_NAME);
+				xfree(default_part_name);
+				default_part_name = xstrdup(part_name);
 				default_part_loc = part_ptr;
 			}
-			part_ptr->root_only = root_only;
-			part_ptr->shared = shared;
-			part_ptr->state_up = state_up;
+			part_ptr->root_only      = root_only;
+			part_ptr->max_share      = max_share;
+			part_ptr->priority       = priority;
+			part_ptr->state_up       = state_up;
 			xfree(part_ptr->allow_groups);
-			part_ptr->allow_groups = allow_groups;
+			part_ptr->allow_groups   = allow_groups;
 			xfree(part_ptr->nodes);
 			part_ptr->nodes = nodes;
 		} else {
@@ -525,16 +553,21 @@ int init_part_conf(void)
 {
 	last_part_update = time(NULL);
 
-	strcpy(default_part.name, "DEFAULT");
-	default_part.hidden      = 0;
-	default_part.max_time    = INFINITE;
-	default_part.max_nodes   = INFINITE;
-	default_part.min_nodes   = 1;
-	default_part.root_only   = 0;
-	default_part.state_up    = 1;
-	default_part.shared      = SHARED_NO;
-	default_part.total_nodes = 0;
-	default_part.total_cpus  = 0;
+	xfree(default_part.name);	/* needed for reconfig */
+	default_part.name           = xstrdup("DEFAULT");
+	default_part.disable_root_jobs = slurmctld_conf.disable_root_jobs;
+	default_part.hidden         = 0;
+	default_part.max_time       = INFINITE;
+	default_part.max_nodes      = INFINITE;
+	default_part.max_nodes_orig = INFINITE;
+	default_part.min_nodes      = 1;
+	default_part.min_nodes_orig = 1;
+	default_part.root_only      = 0;
+	default_part.state_up       = 1;
+	default_part.max_share      = 1;
+	default_part.priority       = 1;
+	default_part.total_nodes    = 0;
+	default_part.total_cpus     = 0;
 	xfree(default_part.nodes);
 	xfree(default_part.allow_groups);
 	xfree(default_part.allow_uids);
@@ -548,7 +581,7 @@ int init_part_conf(void)
 	if (part_list == NULL)
 		fatal ("memory allocation failure");
 
-	strcpy(default_part_name, "");
+	xfree(default_part_name);
 	default_part_loc = (struct part_record *) NULL;
 
 	return 0;
@@ -580,6 +613,7 @@ static void _list_delete_part(void *part_entry)
 			break;
 		}
 	}
+	xfree(part_ptr->name);
 	xfree(part_ptr->allow_groups);
 	xfree(part_ptr->allow_uids);
 	xfree(part_ptr->nodes);
@@ -597,11 +631,13 @@ static void _list_delete_part(void *part_entry)
  */
 int list_find_part(void *part_entry, void *key)
 {
+	if (key == NULL)
+		return 0;
+
 	if (strcmp(key, "universal_key") == 0)
 		return 1;
 
-	if (strncmp(((struct part_record *) part_entry)->name,
-		    (char *) key, MAX_SLURM_NAME) == 0)
+	if (strcmp(((struct part_record *)part_entry)->name, (char *) key) == 0)
 		return 1;
 
 	return 0;
@@ -715,14 +751,8 @@ void pack_part(struct part_record *part_ptr, Buf buffer)
 
 	packstr(part_ptr->name, buffer);
 	pack32(part_ptr->max_time, buffer);
-	altered = part_ptr->max_nodes;
-	select_g_alter_node_cnt(SELECT_APPLY_NODE_MAX_OFFSET, 
-				&altered);
-	pack32(altered, buffer);
-	altered = part_ptr->min_nodes;
-	select_g_alter_node_cnt(SELECT_APPLY_NODE_MIN_OFFSET,
- 				&altered); 
-	pack32(altered, buffer);
+	pack32(part_ptr->max_nodes_orig, buffer);
+	pack32(part_ptr->min_nodes_orig, buffer);
 	altered = part_ptr->total_nodes;
 	select_g_alter_node_cnt(SELECT_APPLY_NODE_MAX_OFFSET, 
 				&altered);
@@ -731,10 +761,12 @@ void pack_part(struct part_record *part_ptr, Buf buffer)
 				&node_scaling);
 	pack16(node_scaling, buffer);
 	pack32(part_ptr->total_cpus, buffer);
-	pack16(default_part_flag, buffer);
-	pack16(part_ptr->hidden, buffer);
-	pack16(part_ptr->root_only, buffer);
-	pack16(part_ptr->shared, buffer);
+	pack16(default_part_flag,    buffer);
+	pack16(part_ptr->disable_root_jobs, buffer);
+	pack16(part_ptr->hidden,     buffer);
+	pack16(part_ptr->root_only,  buffer);
+	pack16(part_ptr->max_share,  buffer);
+	pack16(part_ptr->priority,   buffer);
 
 	pack16(part_ptr->state_up, buffer);
 	packstr(part_ptr->allow_groups, buffer);
@@ -742,7 +774,7 @@ void pack_part(struct part_record *part_ptr, Buf buffer)
 	if (part_ptr->node_bitmap) {
 		bit_fmt(node_inx_ptr, BUF_SIZE,
 			part_ptr->node_bitmap);
-		packstr(node_inx_ptr, buffer);
+		packstr((char *)node_inx_ptr, buffer);
 	} else
 		packstr("", buffer);
 }
@@ -760,10 +792,8 @@ int update_part(update_part_msg_t * part_desc)
 	int error_code;
 	struct part_record *part_ptr;
 
-	if ((part_desc->name == NULL) ||
-	    (strlen(part_desc->name) >= MAX_SLURM_NAME)) {
-		error("update_part: invalid partition name  %s",
-		      part_desc->name);
+	if (part_desc->name == NULL) {
+		error("update_part: invalid partition name, NULL");
 		return ESLURM_INVALID_PARTITION_NAME;
 	}
 
@@ -775,14 +805,15 @@ int update_part(update_part_msg_t * part_desc)
 		info("update_part: partition %s does not exist, "
 			"being created", part_desc->name);
 		part_ptr = create_part_record();
-		strcpy(part_ptr->name, part_desc->name);
+		xfree(part_ptr->name);
+		part_ptr->name = xstrdup(part_desc->name);
 	}
 
 	last_part_update = time(NULL);
 
 	if (part_desc->hidden != (uint16_t) NO_VAL) {
-		info("update_part: setting hidden to %u for partition %s", 
-		     part_desc->hidden, part_desc->name);
+		info("update_part: setting hidden to %u for partition %s",
+			part_desc->hidden, part_desc->name);
 		part_ptr->hidden = part_desc->hidden;
 	}
 
@@ -795,13 +826,19 @@ int update_part(update_part_msg_t * part_desc)
 	if (part_desc->max_nodes != NO_VAL) {
 		info("update_part: setting max_nodes to %u for partition %s", 
 		     part_desc->max_nodes, part_desc->name);
-		part_ptr->max_nodes = part_desc->max_nodes;
+		part_ptr->max_nodes      = part_desc->max_nodes;
+		part_ptr->max_nodes_orig = part_desc->max_nodes;
+		select_g_alter_node_cnt(SELECT_SET_BP_CNT,
+					&part_ptr->max_nodes);
 	}
 
 	if (part_desc->min_nodes != NO_VAL) {
 		info("update_part: setting min_nodes to %u for partition %s", 
 		     part_desc->min_nodes, part_desc->name);
-		part_ptr->min_nodes = part_desc->min_nodes;
+		part_ptr->min_nodes      = part_desc->min_nodes;
+		part_ptr->min_nodes_orig = part_desc->min_nodes;
+		select_g_alter_node_cnt(SELECT_SET_BP_CNT,
+					&part_ptr->min_nodes);
 	}
 
 	if (part_desc->root_only != (uint16_t) NO_VAL) {
@@ -816,17 +853,39 @@ int update_part(update_part_msg_t * part_desc)
 		part_ptr->state_up = part_desc->state_up;
 	}
 
-	if (part_desc->shared != (uint16_t) NO_VAL) {
-		info("update_part: setting shared to %u for partition %s",
-		     part_desc->shared, part_desc->name);
-		part_ptr->shared = part_desc->shared;
+	if (part_desc->max_share != (uint16_t) NO_VAL) {
+		uint16_t force = part_desc->max_share & SHARED_FORCE;
+		uint16_t val = part_desc->max_share & (~SHARED_FORCE);
+		char tmp_str[24];
+		if (val == 0)
+			snprintf(tmp_str, sizeof(tmp_str), "EXCLUSIVE");
+		else if (force)
+			snprintf(tmp_str, sizeof(tmp_str), "FORCE:%u", val);
+		else if (val == 1)
+			snprintf(tmp_str, sizeof(tmp_str), "NO");
+		else
+			snprintf(tmp_str, sizeof(tmp_str), "YES:%u", val);
+		info("update_part: setting share to %s for partition %s",
+		     tmp_str, part_desc->name);
+		part_ptr->max_share = part_desc->max_share;
+	}
+
+	if (part_desc->priority != (uint16_t) NO_VAL) {
+		info("update_part: setting priority to %u for partition %s",
+		     part_desc->priority, part_desc->name);
+		part_ptr->priority = part_desc->priority;
 	}
 
-	if ((part_desc->default_part == 1) &&
-	    (strcmp(default_part_name, part_desc->name) != 0)) {
-		info("update_part: changing default partition from %s to %s", 
-		     default_part_name, part_desc->name);
-		strncpy(default_part_name, part_desc->name, MAX_SLURM_NAME);
+	if (part_desc->default_part == 1) {
+		if (default_part_name == NULL) {
+			info("update_part: setting default partition to %s", 
+			     part_desc->name);
+		} else if (strcmp(default_part_name, part_desc->name) != 0) {
+			info("update_part: changing default partition from %s to %s", 
+			     default_part_name, part_desc->name);
+		}
+		xfree(default_part_name);
+		default_part_name = xstrdup(part_desc->name);
 		default_part_loc = part_ptr;
 	}
 
@@ -876,9 +935,12 @@ int update_part(update_part_msg_t * part_desc)
 
 	if (error_code == SLURM_SUCCESS) {
 		slurm_sched_partition_change();	/* notify sched plugin */
-		reset_job_priority();	/* free jobs */
-		if (select_g_block_init(part_list) != SLURM_SUCCESS )
-			error("failed to update node selection plugin state");
+		select_g_reconfigure();		/* notify select plugin too */
+		reset_job_priority();		/* free jobs */
+		
+		/* I am not sure why this was ever there (da) */
+/* 		if (select_g_block_init(part_list) != SLURM_SUCCESS ) */
+/* 			error("failed to update node selection plugin state"); */
 	}
 
 	return error_code;
@@ -1086,6 +1148,8 @@ void part_fini (void)
 		list_destroy(part_list);
 		part_list = NULL;
 	}
+	xfree(default_part_name);
+	xfree(default_part.name);
 	default_part_loc = (struct part_record *) NULL;
 }
 
diff --git a/src/slurmctld/ping_nodes.c b/src/slurmctld/ping_nodes.c
index 9b9e3fac380bba8f919ac7807a241e778a500aea..85da41b8d238ebd0f9f2a3ec77bedb1ed96bef19 100644
--- a/src/slurmctld/ping_nodes.c
+++ b/src/slurmctld/ping_nodes.c
@@ -3,9 +3,10 @@
  *	Note: there is a global node table (node_record_table_ptr)
  *****************************************************************************
  *  Copyright (C) 2003-2006 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -65,6 +66,8 @@
 static pthread_mutex_t lock_mutex = PTHREAD_MUTEX_INITIALIZER;
 static int ping_count = 0;
 
+static void _run_health_check(void);
+
 /* struct timeval start_time, end_time; */
 
 /*
@@ -112,15 +115,17 @@ void ping_end (void)
 	else
 		fatal ("ping_count < 0");
 	slurm_mutex_unlock(&lock_mutex);
-	
-	/* gettimeofday(&end_time, NULL); */
-/* 	start = start_time.tv_sec; */
-/* 	start *= 1000000; */
-/* 	start += start_time.tv_usec; */
-/* 	end = end_time.tv_sec; */
-/* 	end *= 1000000; */
-/* 	end += end_time.tv_usec; */
-/* 	info("done with ping took %ld",(end-start)); */
+
+#if 0
+	gettimeofday(&end_time, NULL);
+	start = start_time.tv_sec;
+	start *= 1000000;
+	start += start_time.tv_usec;
+	end = end_time.tv_sec;
+	end *= 1000000;
+	end += end_time.tv_usec;
+	info("done with ping took %ld",(end-start));
+#endif
 }
 
 /*
@@ -133,12 +138,22 @@ void ping_nodes (void)
 	int i;
 	time_t now, still_live_time, node_dead_time;
 	static time_t last_ping_time = (time_t) 0;
+	static time_t last_health_check = (time_t) 0;
 	uint16_t base_state, no_resp_flag;
 	bool restart_flag;
 	hostlist_t down_hostlist = NULL;
 	char host_str[MAX_SLURM_NAME];
 	agent_arg_t *ping_agent_args = NULL;
 	agent_arg_t *reg_agent_args = NULL;
+
+	now = time (NULL);
+	if (slurmctld_conf.health_check_interval &&
+	    (difftime(now, last_health_check) >= 
+	     slurmctld_conf.health_check_interval)) {
+		last_health_check = now;
+		_run_health_check();
+		return;
+	}
 	
 	ping_agent_args = xmalloc (sizeof (agent_arg_t));
 	ping_agent_args->msg_type = REQUEST_PING;
@@ -160,7 +175,6 @@ void ping_nodes (void)
 	 * Because of this, we extend the SlurmdTimeout by the 
 	 * time needed to complete a ping of all nodes.
 	 */
-	now = time (NULL);
 	if ((slurmctld_conf.slurmd_timeout == 0) 
 	||  (last_ping_time == (time_t) 0)) {
 		node_dead_time = (time_t) 0;
@@ -270,3 +284,46 @@ void ping_nodes (void)
 		hostlist_destroy(down_hostlist);
 	}
 }
+
+static void _run_health_check(void)
+{
+	int i;
+	uint16_t base_state;
+	char host_str[MAX_SLURM_NAME];
+	agent_arg_t *check_agent_args = NULL;
+	
+	check_agent_args = xmalloc (sizeof (agent_arg_t));
+	check_agent_args->msg_type = REQUEST_HEALTH_CHECK;
+	check_agent_args->retry = 0;
+	check_agent_args->hostlist = hostlist_create("");
+
+	for (i = 0; i < node_record_count; i++) {
+		struct node_record *node_ptr;
+		
+		node_ptr   = &node_record_table_ptr[i];
+		base_state = node_ptr->node_state & NODE_STATE_BASE;
+
+		if (base_state == NODE_STATE_DOWN)
+			continue;
+
+#ifdef HAVE_FRONT_END		/* Operate only on front-end */
+		if (i > 0)
+			continue;
+#endif
+
+		hostlist_push(check_agent_args->hostlist, node_ptr->name);
+		check_agent_args->node_count++;
+	}
+
+	if (check_agent_args->node_count == 0) {
+		hostlist_destroy(check_agent_args->hostlist);
+		xfree (check_agent_args);
+	} else {
+		hostlist_uniq(check_agent_args->hostlist);
+		hostlist_ranged_string(check_agent_args->hostlist, 
+			sizeof(host_str), host_str);
+		verbose("Spawning health check agent for %s", host_str);
+		ping_begin();
+		agent_queue_request(check_agent_args);
+	}
+}
diff --git a/src/slurmctld/ping_nodes.h b/src/slurmctld/ping_nodes.h
index 23b6cd79402070909877bbdf6e646f51c69b9a70..2fae42d4b0459e4ddb29185a848a3bce91a2e707 100644
--- a/src/slurmctld/ping_nodes.h
+++ b/src/slurmctld/ping_nodes.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmctld/power_save.c b/src/slurmctld/power_save.c
index 8e894fef915c7d83673bbe3d9a189e0622e15822..4e6d3edbabc0974d6d13f43d37552c39ffdb58c0 100644
--- a/src/slurmctld/power_save.c
+++ b/src/slurmctld/power_save.c
@@ -8,7 +8,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,40 +56,15 @@
 
 #define _DEBUG 0
 
-/* NOTE: These paramters will be moved into the slurm.conf file in version 1.3
- * Directly modify the default values here in order to enable this capability
- * in SLURM version 1.2. */
-
-/* Node becomes elligible for power saving mode after being idle for
- * this number of seconds. A negative number disables power saving mode. */
-#define DEFAULT_IDLE_TIME	-1
-
-/* Maximum number of nodes to be placed into or removed from power saving mode
- * per minute. Use this to prevent rapid changes in power requirements.
- * A value of zero results in no limits being imposed. */
-#define DEFAULT_SUSPEND_RATE	60
-#define DEFAULT_RESUME_RATE	60
-
-/* Programs to be executed to place nodes or out of power saving mode. These 
- * are run as user SlurmUser. The hostname of the node to be modified will be
- * passed as an argument to the program. */
-#define DEFAULT_SUSPEND_PROGRAM	"/home/jette/slurm.mdev/sbin/slurm.node.suspend"
-#define DEFAULT_RESUME_PROGRAM	"/home/jette/slurm.mdev/sbin/slurm.node.resume"
-
-/* Individual nodes or all nodes in selected partitions can be excluded from
- * being placed into power saving mode. SLURM hostlist expressions can be used.
- * Multiple partitions may be listed with a comma separator. */
-#define DEFAULT_EXCLUDE_SUSPEND_NODES		NULL
-#define DEFAULT_EXCLUDE_SUSPEND_PARTITIONS	NULL
-
 int idle_time, suspend_rate, resume_rate;
 char *suspend_prog = NULL, *resume_prog = NULL;
 char *exc_nodes = NULL, *exc_parts = NULL;
-
+time_t last_config = (time_t) 0;
 
 bitstr_t *exc_node_bitmap = NULL;
 int suspend_cnt, resume_cnt;
 
+static void  _clear_power_config(void);
 static void  _do_power_work(void);
 static void  _do_resume(char *host);
 static void  _do_suspend(char *host);
@@ -292,22 +267,37 @@ static void  _kill_zombies(void)
 		;
 }
 
+/* Free all allocated memory */
+static void _clear_power_config(void)
+{
+	xfree(suspend_prog);
+	xfree(resume_prog);
+	xfree(exc_nodes);
+	xfree(exc_parts);
+	FREE_NULL_BITMAP(exc_node_bitmap);
+}
+
 /* Initialize power_save module paramters.
  * Return 0 on valid configuration to run power saving,
  * otherwise log the problem and return -1 */
 static int _init_power_config(void)
 {
-	idle_time     = DEFAULT_IDLE_TIME;
-	suspend_rate  = DEFAULT_SUSPEND_RATE;
-	resume_rate   = DEFAULT_RESUME_RATE;
-	if (DEFAULT_SUSPEND_PROGRAM)
-		suspend_prog = xstrdup(DEFAULT_SUSPEND_PROGRAM);
-	if (DEFAULT_RESUME_PROGRAM)
-		resume_prog = xstrdup(DEFAULT_RESUME_PROGRAM);
-	if (DEFAULT_EXCLUDE_SUSPEND_NODES)
-		exc_nodes = xstrdup(DEFAULT_EXCLUDE_SUSPEND_NODES);
-	if (DEFAULT_EXCLUDE_SUSPEND_PARTITIONS)
-		exc_parts = xstrdup(DEFAULT_EXCLUDE_SUSPEND_PARTITIONS);
+	slurm_ctl_conf_t *conf = slurm_conf_lock();
+
+	last_config   = slurmctld_conf.last_update;
+	idle_time     = conf->suspend_time - 1;
+	suspend_rate  = conf->suspend_rate;
+	resume_rate   = conf->resume_rate;
+	_clear_power_config();
+	if (conf->suspend_program)
+		suspend_prog = xstrdup(conf->suspend_program);
+	if (conf->resume_program)
+		resume_prog = xstrdup(conf->resume_program);
+	if (conf->suspend_exc_nodes)
+		exc_nodes = xstrdup(conf->suspend_exc_nodes);
+	if (conf->suspend_exc_parts)
+		exc_parts = xstrdup(conf->suspend_exc_parts);
+	slurm_conf_unlock();
 
 	if (idle_time < 0) {	/* not an error */
 		debug("power_save module disabled, idle_time < 0");
@@ -411,25 +401,22 @@ static bool _valid_prog(char *file_name)
  */
 extern void *init_power_save(void *arg)
 {
-        /* Locks: Read config, node, and partitions */
-        slurmctld_lock_t config_read_lock = {
-                READ_LOCK, NO_LOCK, READ_LOCK, READ_LOCK };
         /* Locks: Write node, read jobs and partitions */
         slurmctld_lock_t node_write_lock = {
                 NO_LOCK, READ_LOCK, WRITE_LOCK, READ_LOCK };
-	int rc;
 	time_t now, last_power_scan = 0;
 
-	lock_slurmctld(config_read_lock);
-	rc = _init_power_config();
-	unlock_slurmctld(config_read_lock);
-	if (rc)
+	if (_init_power_config())
 		goto fini;
 
 	while (slurmctld_config.shutdown_time == 0) {
 		sleep(1);
 		_kill_zombies();
 
+		if ((last_config != slurmctld_conf.last_update)
+		&&  (_init_power_config()))
+			goto fini;
+
 		/* Only run every 60 seconds or after
 		 * a node state change, whichever 
 		 * happens first */
@@ -444,11 +431,6 @@ extern void *init_power_save(void *arg)
 		last_power_scan = now;
 	}
 
-fini:	/* Free all allocated memory */
-	xfree(suspend_prog);
-	xfree(resume_prog);
-	xfree(exc_nodes);
-	xfree(exc_parts);
-	FREE_NULL_BITMAP(exc_node_bitmap);
+fini:	_clear_power_config();
 	return NULL;
 }
diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index 924a118bd54fba7299b6c676b773390c14456770..80aa09c035d9a65af0d54a63801bf13ac4f0eee9 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -1,13 +1,11 @@
 /*****************************************************************************\
  *  proc_req.c - process incomming messages to slurmctld
- *
- *  $Id: proc_req.c 13871 2008-04-15 15:47:33Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette@llnl.gov>, Kevin Tew
- *  <tew1@llnl.gov>, et. al. 
- *  UCRL-CODE-226842.
+ *  Written by Morris Jette <jette@llnl.gov>, et. al. 
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -69,18 +67,20 @@
 #include "src/common/switch.h"
 #include "src/common/xstring.h"
 #include "src/common/forward.h"
+#include "src/common/assoc_mgr.h"
 
 #include "src/slurmctld/agent.h"
+#include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/proc_req.h"
 #include "src/slurmctld/read_config.h"
 #include "src/slurmctld/sched_plugin.h"
 #include "src/slurmctld/slurmctld.h"
+#include "src/slurmctld/srun_comm.h"
 #include "src/slurmctld/state_save.h"
 #include "src/slurmctld/trigger_mgr.h"
 
 static void         _fill_ctld_conf(slurm_ctl_conf_t * build_ptr);
-static inline bool 	_is_super_user(uid_t uid);
 static void         _kill_job_on_msg_fail(uint32_t job_id);
 static int 	    _launch_batch_step(job_desc_msg_t *job_desc_msg,
 					uid_t uid, uint32_t *step_id);
@@ -89,6 +89,7 @@ static int          _make_step_cred(struct step_record *step_rec,
 inline static void  _slurm_rpc_allocate_resources(slurm_msg_t * msg);
 inline static void  _slurm_rpc_checkpoint(slurm_msg_t * msg);
 inline static void  _slurm_rpc_checkpoint_comp(slurm_msg_t * msg);
+inline static void  _slurm_rpc_checkpoint_task_comp(slurm_msg_t * msg);
 inline static void  _slurm_rpc_delete_partition(slurm_msg_t * msg);
 inline static void  _slurm_rpc_complete_job_allocation(slurm_msg_t * msg);
 inline static void  _slurm_rpc_complete_batch_script(slurm_msg_t * msg);
@@ -97,6 +98,7 @@ inline static void  _slurm_rpc_dump_jobs(slurm_msg_t * msg);
 inline static void  _slurm_rpc_dump_nodes(slurm_msg_t * msg);
 inline static void  _slurm_rpc_dump_partitions(slurm_msg_t * msg);
 inline static void  _slurm_rpc_epilog_complete(slurm_msg_t * msg);
+inline static void  _slurm_rpc_job_notify(slurm_msg_t * msg);
 inline static void  _slurm_rpc_job_ready(slurm_msg_t * msg);
 inline static void  _slurm_rpc_job_step_kill(slurm_msg_t * msg);
 inline static void  _slurm_rpc_job_step_create(slurm_msg_t * msg);
@@ -124,6 +126,8 @@ inline static void  _slurm_rpc_update_node(slurm_msg_t * msg);
 inline static void  _slurm_rpc_update_partition(slurm_msg_t * msg);
 inline static void  _slurm_rpc_end_time(slurm_msg_t * msg);
 inline static void  _update_cred_key(void);
+inline static void  _slurm_rpc_set_debug_level(slurm_msg_t *msg);
+inline static void  _slurm_rpc_accounting_update_msg(slurm_msg_t *msg);
 
 
 /*
@@ -250,6 +254,10 @@ void slurmctld_req (slurm_msg_t * msg)
 		_slurm_rpc_checkpoint_comp(msg);
 		slurm_free_checkpoint_comp_msg(msg->data);
 		break;
+	case REQUEST_CHECKPOINT_TASK_COMP:
+		_slurm_rpc_checkpoint_task_comp(msg);
+		slurm_free_checkpoint_task_comp_msg(msg->data);
+		break;
 	case REQUEST_SUSPEND:
 		_slurm_rpc_suspend(msg);
 		slurm_free_suspend_msg(msg->data);
@@ -286,6 +294,18 @@ void slurmctld_req (slurm_msg_t * msg)
 		_slurm_rpc_trigger_clear(msg);
 		slurm_free_trigger_msg(msg->data);
 		break;
+	case REQUEST_JOB_NOTIFY:
+		_slurm_rpc_job_notify(msg);
+		slurm_free_job_notify_msg(msg->data);
+		break;
+	case REQUEST_SET_DEBUG_LEVEL:
+		_slurm_rpc_set_debug_level(msg);
+		slurm_free_set_debug_level_msg(msg->data);
+		break;
+	case ACCOUNTING_UPDATE_MSG:
+		_slurm_rpc_accounting_update_msg(msg);
+		slurm_free_accounting_update_msg(msg->data);
+		break;
 	default:
 		error("invalid RPC msg_type=%d", msg->msg_type);
 		slurm_send_rc_msg(msg, EINVAL);
@@ -303,38 +323,82 @@ void _fill_ctld_conf(slurm_ctl_conf_t * conf_ptr)
 	slurm_ctl_conf_t *conf = slurm_conf_lock();
 
 	conf_ptr->last_update         = time(NULL);
+	conf_ptr->accounting_storage_enforce = conf->accounting_storage_enforce;
+	conf_ptr->accounting_storage_host =
+					xstrdup(conf->accounting_storage_host);
+	conf_ptr->accounting_storage_loc =
+					xstrdup(conf->accounting_storage_loc);
+	conf_ptr->accounting_storage_pass =
+					xstrdup(conf->accounting_storage_pass);
+	conf_ptr->accounting_storage_port = conf->accounting_storage_port;
+	conf_ptr->accounting_storage_type =
+				        xstrdup(conf->accounting_storage_type);
+	conf_ptr->accounting_storage_user =
+					xstrdup(conf->accounting_storage_user);
+	conf_ptr->accounting_storage_port = conf->accounting_storage_port;
 	conf_ptr->authtype            = xstrdup(conf->authtype);
+
 	conf_ptr->backup_addr         = xstrdup(conf->backup_addr);
 	conf_ptr->backup_controller   = xstrdup(conf->backup_controller);
+	conf_ptr->boot_time           = slurmctld_config.boot_time;
+
 	conf_ptr->cache_groups        = conf->cache_groups;
 	conf_ptr->checkpoint_type     = xstrdup(conf->checkpoint_type);
+	conf_ptr->cluster_name        = xstrdup(conf->cluster_name);
 	conf_ptr->control_addr        = xstrdup(conf->control_addr);
 	conf_ptr->control_machine     = xstrdup(conf->control_machine);
+	conf_ptr->crypto_type         = xstrdup(conf->crypto_type);
+
+	conf_ptr->def_mem_per_task    = conf->def_mem_per_task;
 	conf_ptr->disable_root_jobs   = conf->disable_root_jobs;
+
 	conf_ptr->epilog              = xstrdup(conf->epilog);
+	conf_ptr->epilog_msg_time     = conf->epilog_msg_time;
+
 	conf_ptr->fast_schedule       = conf->fast_schedule;
 	conf_ptr->first_job_id        = conf->first_job_id;
+
 	conf_ptr->inactive_limit      = conf->inactive_limit;
-	conf_ptr->job_acct_logfile    = xstrdup(conf->job_acct_logfile);
-	conf_ptr->job_acct_freq       = conf->job_acct_freq;
-	conf_ptr->job_acct_type       = xstrdup(conf->job_acct_type);
+
+	conf_ptr->health_check_interval = conf->health_check_interval;
+	conf_ptr->health_check_program = xstrdup(conf->health_check_program);
+
+	conf_ptr->job_acct_gather_freq  = conf->job_acct_gather_freq;
+	conf_ptr->job_acct_gather_type  = xstrdup(conf->job_acct_gather_type);
+
+	conf_ptr->job_comp_host       = xstrdup(conf->job_comp_host);
 	conf_ptr->job_comp_loc        = xstrdup(conf->job_comp_loc);
+	conf_ptr->job_comp_pass       = xstrdup(conf->job_comp_pass);
+	conf_ptr->job_comp_port       = conf->job_comp_port;
 	conf_ptr->job_comp_type       = xstrdup(conf->job_comp_type);
+	conf_ptr->job_comp_user       = xstrdup(conf->job_comp_user);
+
 	conf_ptr->job_credential_private_key = xstrdup(conf->
 					job_credential_private_key);
 	conf_ptr->job_credential_public_certificate = xstrdup(conf->
 					job_credential_public_certificate);
 	conf_ptr->job_file_append     = conf->job_file_append;
+	conf_ptr->job_requeue         = conf->job_requeue;
+
 	conf_ptr->get_env_timeout     = conf->get_env_timeout;
+
 	conf_ptr->kill_wait           = conf->kill_wait;
+
+	conf_ptr->licenses            = xstrdup(conf->licenses);
+
 	conf_ptr->mail_prog           = xstrdup(conf->mail_prog);
 	conf_ptr->max_job_cnt         = conf->max_job_cnt;
+	conf_ptr->max_mem_per_task    = conf->max_mem_per_task;
 	conf_ptr->min_job_age         = conf->min_job_age;
 	conf_ptr->mpi_default         = xstrdup(conf->mpi_default);
 	conf_ptr->msg_timeout         = conf->msg_timeout;
+
 	conf_ptr->next_job_id         = get_next_job_id();
+	conf_ptr->node_prefix         = xstrdup(conf->node_prefix);
+
 	conf_ptr->plugindir           = xstrdup(conf->plugindir);
 	conf_ptr->plugstack           = xstrdup(conf->plugstack);
+	conf_ptr->private_data        = conf->private_data;
 	conf_ptr->proctrack_type      = xstrdup(conf->proctrack_type);
 	conf_ptr->prolog              = xstrdup(conf->prolog);
 	conf_ptr->propagate_prio_process = 
@@ -342,9 +406,18 @@ void _fill_ctld_conf(slurm_ctl_conf_t * conf_ptr)
         conf_ptr->propagate_rlimits   = xstrdup(conf->propagate_rlimits);
         conf_ptr->propagate_rlimits_except = xstrdup(conf->
 						     propagate_rlimits_except);
+
+	conf_ptr->resume_program      = xstrdup(conf->resume_program);
+	conf_ptr->resume_rate         = conf->resume_rate;
 	conf_ptr->ret2service         = conf->ret2service;
+
+	if (conf->sched_params)
+		conf_ptr->sched_params = xstrdup(conf->sched_params);
+	else
+		conf_ptr->sched_params = slurm_sched_p_get_conf();
 	conf_ptr->schedport           = conf->schedport;
 	conf_ptr->schedrootfltr       = conf->schedrootfltr;
+	conf_ptr->sched_time_slice    = conf->sched_time_slice;
 	conf_ptr->schedtype           = xstrdup(conf->schedtype);
 	conf_ptr->select_type         = xstrdup(conf->select_type);
 	conf_ptr->select_type_param   = conf->select_type_param;
@@ -362,18 +435,25 @@ void _fill_ctld_conf(slurm_ctl_conf_t * conf_ptr)
 	conf_ptr->slurmd_spooldir     = xstrdup(conf->slurmd_spooldir);
 	conf_ptr->slurmd_timeout      = conf->slurmd_timeout;
 	conf_ptr->slurm_conf          = xstrdup(conf->slurm_conf);
+	conf_ptr->srun_prolog         = xstrdup(conf->srun_prolog);
+	conf_ptr->srun_epilog         = xstrdup(conf->srun_epilog);
 	conf_ptr->state_save_location = xstrdup(conf->state_save_location);
+	conf_ptr->suspend_exc_nodes   = xstrdup(conf->suspend_exc_nodes);
+	conf_ptr->suspend_exc_parts   = xstrdup(conf->suspend_exc_parts);
+	conf_ptr->suspend_program     = xstrdup(conf->suspend_program);
+	conf_ptr->suspend_rate        = conf->suspend_rate;
+	conf_ptr->suspend_time        = conf->suspend_time;
 	conf_ptr->switch_type         = xstrdup(conf->switch_type);
+
 	conf_ptr->task_epilog         = xstrdup(conf->task_epilog);
 	conf_ptr->task_prolog         = xstrdup(conf->task_prolog);
 	conf_ptr->task_plugin         = xstrdup(conf->task_plugin);
 	conf_ptr->task_plugin_param   = conf->task_plugin_param;
 	conf_ptr->tmp_fs              = xstrdup(conf->tmp_fs);
-	conf_ptr->wait_time           = conf->wait_time;
-	conf_ptr->srun_prolog         = xstrdup(conf->srun_prolog);
-	conf_ptr->srun_epilog         = xstrdup(conf->srun_epilog);
-	conf_ptr->node_prefix         = xstrdup(conf->node_prefix);
 	conf_ptr->tree_width          = conf->tree_width;
+
+	conf_ptr->wait_time           = conf->wait_time;
+
 	conf_ptr->use_pam             = conf->use_pam;
 	conf_ptr->unkillable_program  = xstrdup(conf->unkillable_program);
 	conf_ptr->unkillable_timeout  = conf->unkillable_timeout;
@@ -382,16 +462,15 @@ void _fill_ctld_conf(slurm_ctl_conf_t * conf_ptr)
 	return;
 }
 
-/* return true if supplied uid is a super-user: root, self, or SlurmUser */
-static inline bool _is_super_user(uid_t uid)
+/*
+ * validate_super_user - validate that the uid is authorized to see 
+ *      privileged data (either user root or SlurmUser)
+ * IN uid - user to validate
+ * RET true if permitted to run, false otherwise
+ */
+extern bool validate_super_user(uid_t uid)
 {
-	/* READ lock_slurmctld config would be ideal here, but 
-	 * that value should be identical to getuid() anyway.
-	 * privileged calls should be coming from user root too, 
-	 * so we forgo the overhead here. */
-	if ( (uid == 0) || 
-	     (uid == slurmctld_conf.slurm_user_id) ||
-	     (uid == getuid()) )
+	if ((uid == 0) || (uid == getuid()))
 		return true;
 	else
 		return false;
@@ -422,6 +501,8 @@ static int _make_step_cred(struct step_record *step_rec,
 	cred_arg.jobid    = step_rec->job_ptr->job_id;
 	cred_arg.stepid   = step_rec->step_id;
 	cred_arg.uid      = step_rec->job_ptr->user_id;
+	cred_arg.job_mem  = step_rec->job_ptr->details->job_min_memory;
+	cred_arg.task_mem = step_rec->mem_per_task;
 	cred_arg.hostlist = step_rec->step_layout->node_list;
         if(step_rec->job_ptr->details->shared == 0)
                 cred_arg.alloc_lps_cnt = 0;
@@ -459,29 +540,39 @@ static void _slurm_rpc_allocate_resources(slurm_msg_t * msg)
 	/* Locks: Read config, write job, write node, read partition */
 	slurmctld_lock_t job_write_lock = { 
 		READ_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	int immediate = job_desc_msg->immediate;
 	bool do_unlock = false;
 	bool job_waiting = false;
 	struct job_record *job_ptr;
+	uint16_t port;	/* dummy value */
+	slurm_addr resp_addr;
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_RESOURCE_ALLOCATION");
-
-	/* do RPC call */
-	dump_job_desc(job_desc_msg);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if ( (uid != job_desc_msg->user_id) && (!_is_super_user(uid)) ) {
+	if ((uid != job_desc_msg->user_id) && (!validate_super_user(uid))) {
 		error_code = ESLURM_USER_ID_MISSING;
 		error("Security violation, RESOURCE_ALLOCATE from uid=%u",
-		      (unsigned int) uid);
+			(unsigned int) uid);
 	}
+	debug2("Processing RPC: REQUEST_RESOURCE_ALLOCATION from uid=%u",
+		(unsigned int) uid);
 
+	/* do RPC call */
+	if ((job_desc_msg->alloc_node == NULL)
+	||  (job_desc_msg->alloc_node[0] == '\0')) {
+		error_code = ESLURM_INVALID_NODE_NAME;
+		error("REQUEST_RESOURCE_ALLOCATE lacks alloc_node from uid=%u",
+			(unsigned int) uid);
+	}
+	slurm_get_peer_addr(msg->conn_fd, &resp_addr);
+	job_desc_msg->resp_host = xmalloc(16);
+	slurm_get_ip_str(&resp_addr, &port, job_desc_msg->resp_host, 16);
+	dump_job_desc(job_desc_msg);
 	if (error_code == SLURM_SUCCESS) {
 		do_unlock = true;
 		lock_slurmctld(job_write_lock);
-		error_code = job_allocate(job_desc_msg,
-					  immediate, false, 
+		error_code = job_allocate(job_desc_msg, immediate, 
+					  false, NULL,
 					  true, uid, &job_ptr);
 		/* unlock after finished using the job structure data */
 		END_TIMER2("_slurm_rpc_allocate_resources");
@@ -544,12 +635,14 @@ static void _slurm_rpc_dump_conf(slurm_msg_t * msg)
 	slurm_msg_t response_msg;
 	last_update_msg_t *last_time_msg = (last_update_msg_t *) msg->data;
 	slurm_ctl_conf_info_msg_t config_tbl;
-	/* Locks: Read config */
+	/* Locks: Read config, partition*/
 	slurmctld_lock_t config_read_lock = { 
-		READ_LOCK, NO_LOCK, NO_LOCK, NO_LOCK };
+		READ_LOCK, NO_LOCK, NO_LOCK, READ_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_BUILD_INFO");
+	debug2("Processing RPC: REQUEST_BUILD_INFO from uid=%u",
+		(unsigned int) uid);
 	lock_slurmctld(config_read_lock);
 
 	/* check to see if configuration data has changed */
@@ -583,12 +676,14 @@ static void _slurm_rpc_dump_jobs(slurm_msg_t * msg)
 	slurm_msg_t response_msg;
 	job_info_request_msg_t *job_info_request_msg =
 	    (job_info_request_msg_t *) msg->data;
-	/* Locks: Read job, write node (for hiding) */
+	/* Locks: Read config job, write node (for hiding) */
 	slurmctld_lock_t job_read_lock = { 
-		NO_LOCK, READ_LOCK, NO_LOCK, WRITE_LOCK };
+		READ_LOCK, READ_LOCK, NO_LOCK, WRITE_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_JOB_INFO");
+	debug2("Processing RPC: REQUEST_JOB_INFO from uid=%u",
+		(unsigned int) uid);
 	lock_slurmctld(job_read_lock);
 
 	if ((job_info_request_msg->last_update - 1) >= last_job_update) {
@@ -598,7 +693,7 @@ static void _slurm_rpc_dump_jobs(slurm_msg_t * msg)
 	} else {
 		pack_all_jobs(&dump, &dump_size, 
 			      job_info_request_msg->show_flags, 
-			      g_slurm_auth_get_uid(msg->auth_cred));
+			      g_slurm_auth_get_uid(msg->auth_cred, NULL));
 		unlock_slurmctld(job_read_lock);
 		END_TIMER2("_slurm_rpc_dump_jobs");
 		debug2("_slurm_rpc_dump_jobs, size=%d %s",
@@ -629,9 +724,11 @@ static void _slurm_rpc_end_time(slurm_msg_t * msg)
 	/* Locks: Read job */
 	slurmctld_lock_t job_read_lock = {
 		NO_LOCK, READ_LOCK, NO_LOCK, NO_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST JOB_END_TIME");
+	debug2("Processing RPC: REQUEST JOB_END_TIME from uid=%u",
+		(unsigned int) uid);
 	lock_slurmctld(job_read_lock);
 	rc = job_end_time(time_req_msg, &timeout_msg);
 	unlock_slurmctld(job_read_lock);
@@ -662,18 +759,24 @@ static void _slurm_rpc_dump_nodes(slurm_msg_t * msg)
 	/* Locks: Read config, read node, write node (for hiding) */
 	slurmctld_lock_t node_read_lock = { 
 		READ_LOCK, NO_LOCK, READ_LOCK, WRITE_LOCK };
+        uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_NODE_INFO");
+	debug2("Processing RPC: REQUEST_NODE_INFO from uid=%u",
+		(unsigned int) uid);
 	lock_slurmctld(node_read_lock);
 
-	if ((node_req_msg->last_update - 1) >= last_node_update) {
+	if (slurmctld_conf.private_data && !validate_super_user(uid)) {
+		unlock_slurmctld(node_read_lock);
+		error("Security violation, REQUEST_NODE_INFO RPC from uid=%d", uid);
+		slurm_send_rc_msg(msg, ESLURM_USER_ID_MISSING);
+	} else if ((node_req_msg->last_update - 1) >= last_node_update) {
 		unlock_slurmctld(node_read_lock);
 		debug2("_slurm_rpc_dump_nodes, no change");
 		slurm_send_rc_msg(msg, SLURM_NO_CHANGE_IN_DATA);
 	} else {
 		pack_all_node(&dump, &dump_size, node_req_msg->show_flags, 
-			      g_slurm_auth_get_uid(msg->auth_cred));
+			      uid);
 		unlock_slurmctld(node_read_lock);
 		END_TIMER2("_slurm_rpc_dump_nodes");
 		debug2("_slurm_rpc_dump_nodes, size=%d %s",
@@ -701,22 +804,28 @@ static void _slurm_rpc_dump_partitions(slurm_msg_t * msg)
 	slurm_msg_t response_msg;
 	part_info_request_msg_t  *part_req_msg;
 
-	/* Locks: Read partition */
+	/* Locks: Read configuration and partition */
 	slurmctld_lock_t part_read_lock = { 
-		NO_LOCK, NO_LOCK, NO_LOCK, READ_LOCK };
+		READ_LOCK, NO_LOCK, NO_LOCK, READ_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_PARTITION_INFO");
+	debug2("Processing RPC: REQUEST_PARTITION_INFO uid=%u",
+		(unsigned int) uid);
 	part_req_msg = (part_info_request_msg_t  *) msg->data;
 	lock_slurmctld(part_read_lock);
 
-	if ((part_req_msg->last_update - 1) >= last_part_update) {
+	if (slurmctld_conf.private_data && !validate_super_user(uid)) {
+		unlock_slurmctld(part_read_lock);
+		debug2("Security violation, PARTITION_INFO RPC from uid=%d", uid);
+		slurm_send_rc_msg(msg, ESLURM_USER_ID_MISSING);
+	} else if ((part_req_msg->last_update - 1) >= last_part_update) {
 		unlock_slurmctld(part_read_lock);
 		debug2("_slurm_rpc_dump_partitions, no change");
 		slurm_send_rc_msg(msg, SLURM_NO_CHANGE_IN_DATA);
 	} else {
 		pack_all_part(&dump, &dump_size, part_req_msg->show_flags, 
-				g_slurm_auth_get_uid(msg->auth_cred));
+				uid);
 		unlock_slurmctld(part_read_lock);
 		END_TIMER2("_slurm_rpc_dump_partitions");
 		debug2("_slurm_rpc_dump_partitions, size=%d %s",
@@ -740,24 +849,25 @@ static void _slurm_rpc_dump_partitions(slurm_msg_t * msg)
 static void  _slurm_rpc_epilog_complete(slurm_msg_t * msg)
 {
 	DEF_TIMERS;
-	/* Locks: Write job, write node */
+	/* Locks: Read configuration, write job, write node */
 	slurmctld_lock_t job_write_lock = { 
-		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
-	uid_t uid;
+		READ_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	epilog_complete_msg_t *epilog_msg = 
 		(epilog_complete_msg_t *) msg->data;
 	bool run_scheduler = false;
 
 	START_TIMER;
-	debug2("Processing RPC: MESSAGE_EPILOG_COMPLETE");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	debug2("Processing RPC: MESSAGE_EPILOG_COMPLETE uid=%u",
+		(unsigned int) uid);
+	lock_slurmctld(job_write_lock);
+	if (slurmctld_conf.private_data && !validate_super_user(uid)) {
+		unlock_slurmctld(job_write_lock);
 		error("Security violation, EPILOG_COMPLETE RPC from uid=%u",
 		      (unsigned int) uid);
 		return;
 	}
 
-	lock_slurmctld(job_write_lock);
 	if (job_epilog_complete(epilog_msg->job_id, epilog_msg->node_name, 
 	                        epilog_msg->return_code))
 		run_scheduler = true;
@@ -795,11 +905,11 @@ static void _slurm_rpc_job_step_kill(slurm_msg_t * msg)
 	/* Locks: Read config, write job, write node */
 	slurmctld_lock_t job_write_lock = { 
 		READ_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_CANCEL_JOB_STEP");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	debug2("Processing RPC: REQUEST_CANCEL_JOB_STEP uid=%u",
+		(unsigned int) uid);
 	lock_slurmctld(job_write_lock);
 
 	/* do RPC call */
@@ -864,14 +974,14 @@ static void _slurm_rpc_complete_job_allocation(slurm_msg_t * msg)
 	slurmctld_lock_t job_write_lock = { 
 		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK
 	};
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	bool job_requeue = false;
 
 	/* init */
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_COMPLETE_JOB_ALLOCATION %u",
-	       comp_msg->job_id);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	debug2("Processing RPC: REQUEST_COMPLETE_JOB_ALLOCATION from "
+		"uid=%u, JobId=%u rc=%d",
+		uid, comp_msg->job_id, comp_msg->job_rc);
 
 	lock_slurmctld(job_write_lock);
 
@@ -908,17 +1018,17 @@ static void _slurm_rpc_complete_batch_script(slurm_msg_t * msg)
 	slurmctld_lock_t job_write_lock = { 
 		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK
 	};
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	bool job_requeue = false;
 	bool dump_job = false, dump_node = false;
 
 	/* init */
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_COMPLETE_BATCH_SCRIPT %u",
-	       comp_msg->job_id);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	debug2("Processing RPC: REQUEST_COMPLETE_BATCH_SCRIPT from "
+		"uid=%u JobId=%u",
+		uid, comp_msg->job_id);
 
-	if (!_is_super_user(uid)) {
+	if (!validate_super_user(uid)) {
 		/* Only the slurmstepd can complete a batch script */
 		END_TIMER2("_slurm_rpc_complete_batch_script");
 		return;
@@ -997,13 +1107,13 @@ static void _slurm_rpc_job_step_create(slurm_msg_t * msg)
 	/* Locks: Write jobs, read nodes */
 	slurmctld_lock_t job_write_lock = { 
 		NO_LOCK, WRITE_LOCK, READ_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_JOB_STEP_CREATE");
+	debug2("Processing RPC: REQUEST_JOB_STEP_CREATE from uid=%u",
+		(unsigned int) uid);
 
 	dump_step_desc(req_step_msg);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
 	if (uid != req_step_msg->user_id) {
 		error("Security violation, JOB_STEP_CREATE RPC from uid=%u "
 		      "to run as uid %u",
@@ -1015,7 +1125,7 @@ static void _slurm_rpc_job_step_create(slurm_msg_t * msg)
 #ifdef HAVE_FRONT_END	/* Limited job step support */
 	/* Non-super users not permitted to run job steps on front-end.
 	 * A single slurmd can not handle a heavy load. */
-	if (!_is_super_user(uid)) {
+	if (!validate_super_user(uid)) {
 		info("Attempt to execute job step by uid=%u",
 			(unsigned int) uid);
 		slurm_send_rc_msg(msg, ESLURM_BATCH_ONLY);
@@ -1075,12 +1185,14 @@ static void _slurm_rpc_job_step_get_info(slurm_msg_t * msg)
 	int error_code = SLURM_SUCCESS;
 	job_step_info_request_msg_t *request =
 	    (job_step_info_request_msg_t *) msg->data;
-	/* Locks: Read job, write partition (for filtering) */
+	/* Locks: Read config, job, write partition (for filtering) */
 	slurmctld_lock_t job_read_lock = { 
-		NO_LOCK, READ_LOCK, NO_LOCK, WRITE_LOCK };
+		READ_LOCK, READ_LOCK, NO_LOCK, WRITE_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_JOB_STEP_INFO");
+	debug2("Processing RPC: REQUEST_JOB_STEP_INFO from uid=%u",
+		(unsigned int) uid);
 
 	lock_slurmctld(job_read_lock);
 
@@ -1090,7 +1202,6 @@ static void _slurm_rpc_job_step_get_info(slurm_msg_t * msg)
 		error_code = SLURM_NO_CHANGE_IN_DATA;
 	} else {
 		Buf buffer = init_buf(BUF_SIZE);
-		uid_t uid = g_slurm_auth_get_uid(msg->auth_cred);
 		error_code = pack_ctld_job_step_info_response_msg(
 				request->job_id, request->step_id, 
 				uid, request->show_flags, buffer);
@@ -1137,24 +1248,40 @@ static void _slurm_rpc_job_will_run(slurm_msg_t * msg)
 	/* Locks: Write job, read node, read partition */
 	slurmctld_lock_t job_write_lock = { 
 		NO_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+	uint16_t port;	/* dummy value */
+	slurm_addr resp_addr;
+	will_run_response_msg_t *resp = NULL;
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_JOB_WILL_RUN");
+	debug2("Processing RPC: REQUEST_JOB_WILL_RUN from uid=%u",
+		(unsigned int) uid);
 
 	/* do RPC call */
-	dump_job_desc(job_desc_msg);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if ( (uid != job_desc_msg->user_id) && (!_is_super_user(uid)) ) {
+	if ( (uid != job_desc_msg->user_id) && (!validate_super_user(uid)) ) {
 		error_code = ESLURM_USER_ID_MISSING;
 		error("Security violation, JOB_WILL_RUN RPC from uid=%u",
-		      (unsigned int) uid);
+			(unsigned int) uid);
 	}
-
+	if ((job_desc_msg->alloc_node == NULL)
+	||  (job_desc_msg->alloc_node[0] == '\0')) {
+		error_code = ESLURM_INVALID_NODE_NAME;
+		error("REQUEST_JOB_WILL_RUN lacks alloc_node from uid=%u",
+			(unsigned int) uid);
+	}
+	slurm_get_peer_addr(msg->conn_fd, &resp_addr);
+	job_desc_msg->resp_host = xmalloc(16);
+	slurm_get_ip_str(&resp_addr, &port, job_desc_msg->resp_host, 16);
+	dump_job_desc(job_desc_msg);
 	if (error_code == SLURM_SUCCESS) {
 		lock_slurmctld(job_write_lock);
-		error_code = job_allocate(job_desc_msg, 
-				true, true, true, uid, &job_ptr);
+		if (job_desc_msg->job_id == NO_VAL) {
+			error_code = job_allocate(job_desc_msg, false, 
+						  true, &resp,
+						  true, uid, &job_ptr);
+		} else {	/* existing job test */
+			error_code = job_start_data(job_desc_msg, &resp);
+		}
 		unlock_slurmctld(job_write_lock);
 		END_TIMER2("_slurm_rpc_job_will_run");
 	}
@@ -1164,9 +1291,20 @@ static void _slurm_rpc_job_will_run(slurm_msg_t * msg)
 		debug2("_slurm_rpc_job_will_run: %s", 
 			slurm_strerror(error_code));
 		slurm_send_rc_msg(msg, error_code);
+	} else if (resp) {
+		slurm_msg_t response_msg;
+		/* init response_msg structure */
+		slurm_msg_t_init(&response_msg);
+		response_msg.address = msg->address;
+		response_msg.msg_type = RESPONSE_JOB_WILL_RUN;
+		response_msg.data = resp;
+		slurm_send_node_msg(msg->conn_fd, &response_msg);
+		slurm_free_will_run_response_msg(resp);
+		debug2("_slurm_rpc_job_will_run success %s", TIME_STR);
 	} else {
 		debug2("_slurm_rpc_job_will_run success %s", TIME_STR);
-		slurm_send_rc_msg(msg, SLURM_SUCCESS);
+		if (job_desc_msg->job_id == NO_VAL)
+			slurm_send_rc_msg(msg, SLURM_SUCCESS);
 	}
 }
 
@@ -1182,12 +1320,12 @@ static void _slurm_rpc_node_registration(slurm_msg_t * msg)
 	/* Locks: Read config, write job, write node */
 	slurmctld_lock_t job_write_lock = { 
 		READ_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: MESSAGE_NODE_REGISTRATION_STATUS");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	debug2("Processing RPC: MESSAGE_NODE_REGISTRATION_STATUS from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
 		error_code = ESLURM_USER_ID_MISSING;
 		error("Security violation, NODE_REGISTER RPC from uid=%u",
 		      (unsigned int) uid);
@@ -1196,26 +1334,10 @@ static void _slurm_rpc_node_registration(slurm_msg_t * msg)
 		/* do RPC call */
 		lock_slurmctld(job_write_lock);
 #ifdef HAVE_FRONT_END		/* Operates only on front-end */
-		error_code = validate_nodes_via_front_end(
-					node_reg_stat_msg->job_count,
-					node_reg_stat_msg->job_id,
-					node_reg_stat_msg->step_id,
-					node_reg_stat_msg->status);
+		error_code = validate_nodes_via_front_end(node_reg_stat_msg);
 #else
-		validate_jobs_on_node(node_reg_stat_msg->node_name,
-					&node_reg_stat_msg->job_count,
-					node_reg_stat_msg->job_id,
-					node_reg_stat_msg->step_id);
-		error_code =
-		    validate_node_specs(node_reg_stat_msg->node_name,
-					node_reg_stat_msg->cpus,
-					node_reg_stat_msg->sockets,
-					node_reg_stat_msg->cores,
-					node_reg_stat_msg->threads,
-					node_reg_stat_msg->real_memory_size,
-					node_reg_stat_msg->temporary_disk_space,
-					node_reg_stat_msg->job_count,
-					node_reg_stat_msg->status);
+		validate_jobs_on_node(node_reg_stat_msg);
+		error_code = validate_node_specs(node_reg_stat_msg);
 #endif
 		unlock_slurmctld(job_write_lock);
 		END_TIMER2("_slurm_rpc_node_registration");
@@ -1244,17 +1366,17 @@ static void _slurm_rpc_job_alloc_info(slurm_msg_t * msg)
 	job_alloc_info_msg_t *job_info_msg =
 	    (job_alloc_info_msg_t *) msg->data;
 	job_alloc_info_response_msg_t job_info_resp_msg;
-	/* Locks: Read job, read node */
+	/* Locks: Read config, job, read node */
 	slurmctld_lock_t job_read_lock = { 
-		NO_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };
-	uid_t uid;
+		READ_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	bool do_unlock = false;
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_JOB_ALLOCATION_INFO");
+	debug2("Processing RPC: REQUEST_JOB_ALLOCATION_INFO from uid=%u",
+		(unsigned int) uid);
 
 	/* do RPC call */
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
 	do_unlock = true;
 	lock_slurmctld(job_read_lock);
 	error_code = job_alloc_info(uid, job_info_msg->job_id, &job_ptr);
@@ -1319,17 +1441,17 @@ static void _slurm_rpc_job_alloc_info_lite(slurm_msg_t * msg)
 	job_alloc_info_msg_t *job_info_msg =
 	    (job_alloc_info_msg_t *) msg->data;
 	resource_allocation_response_msg_t job_info_resp_msg;
-	/* Locks: Read job, read node */
+	/* Locks: Read config, job, read node */
 	slurmctld_lock_t job_read_lock = { 
-		NO_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };
-	uid_t uid;
+		READ_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	bool do_unlock = false;
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_JOB_ALLOCATION_INFO_LITE");
+	debug2("Processing RPC: REQUEST_JOB_ALLOCATION_INFO_LITE from uid=%u",
+		(unsigned int) uid);
 
 	/* do RPC call */
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
 	do_unlock = true;
 	lock_slurmctld(job_read_lock);
 	error_code = job_alloc_info(uid, job_info_msg->job_id, &job_ptr);
@@ -1392,20 +1514,18 @@ static void _slurm_rpc_ping(slurm_msg_t * msg)
  *	slurmctld from configuration file */
 static void _slurm_rpc_reconfigure_controller(slurm_msg_t * msg)
 {
-	/* init */
 	int error_code = SLURM_SUCCESS;
 	static bool in_progress = false;
-
 	DEF_TIMERS;
 	/* Locks: Write configuration, job, node and partition */
 	slurmctld_lock_t config_write_lock = { 
 		WRITE_LOCK, WRITE_LOCK, WRITE_LOCK, WRITE_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	info("Processing RPC: REQUEST_RECONFIGURE");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	info("Processing RPC: REQUEST_RECONFIGURE from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
 		error("Security violation, RECONFIGURE RPC from uid=%u",
 		      (unsigned int) uid);
 		error_code = ESLURM_USER_ID_MISSING;
@@ -1438,8 +1558,9 @@ static void _slurm_rpc_reconfigure_controller(slurm_msg_t * msg)
 		info("_slurm_rpc_reconfigure_controller: completed %s", 
 			TIME_STR);
 		slurm_send_rc_msg(msg, SLURM_SUCCESS);
-		slurm_sched_partition_change();
-		schedule();	/* has its own locks */
+		slurm_sched_partition_change();	/* notify sched plugin */
+		select_g_reconfigure();		/* notify select plugin too */
+		schedule();			/* has its own locks */
 		save_all_state();
 	}
 }
@@ -1450,13 +1571,12 @@ static void _slurm_rpc_shutdown_controller(slurm_msg_t * msg)
 	int error_code = SLURM_SUCCESS, i;
 	uint16_t core_arg = 0;
 	shutdown_msg_t *shutdown_msg = (shutdown_msg_t *) msg->data;
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	/* Locks: Read node */
 	slurmctld_lock_t node_read_lock = { 
 		NO_LOCK, NO_LOCK, READ_LOCK, NO_LOCK };
 
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	if (!validate_super_user(uid)) {
 		error("Security violation, SHUTDOWN RPC from uid=%u",
 		      (unsigned int) uid);
 		error_code = ESLURM_USER_ID_MISSING;
@@ -1520,10 +1640,9 @@ static void _slurm_rpc_shutdown_controller(slurm_msg_t * msg)
 static void _slurm_rpc_shutdown_controller_immediate(slurm_msg_t * msg)
 {
 	int error_code = SLURM_SUCCESS;
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	if (!validate_super_user(uid)) {
 		error
 		    ("Security violation, SHUTDOWN_IMMEDIATE RPC from uid=%u",
 		     (unsigned int) uid);
@@ -1548,18 +1667,18 @@ static void _slurm_rpc_step_complete(slurm_msg_t *msg)
 	/* Locks: Write job, write node */
 	slurmctld_lock_t job_write_lock = {
 		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	bool job_requeue = false;
 	bool dump_job = false, dump_node = false;
 
 	/* init */
 	START_TIMER;
 	debug("Processing RPC: REQUEST_STEP_COMPLETE for %u.%u "
-		"nodes %u-%u rc=%u",
+		"nodes %u-%u rc=%u uid=%u",
 		req->job_id, req->job_step_id,
-		req->range_first, req->range_last, req->step_rc);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+		req->range_first, req->range_last, 
+		req->step_rc, (unsigned int) uid);
+	if (!validate_super_user(uid)) {
 		/* Don't trust RPC, it is not from slurmstepd */
 		error("Invalid user %d attempted REQUEST_STEP_COMPLETE",
 		      uid);
@@ -1635,15 +1754,16 @@ static void _slurm_rpc_step_layout(slurm_msg_t *msg)
 	DEF_TIMERS;
 	job_step_id_msg_t *req = (job_step_id_msg_t *)msg->data;
 	slurm_step_layout_t *step_layout = NULL;
-	/* Locks: Write job, write node */
+	/* Locks: Read config job, write node */
 	slurmctld_lock_t job_read_lock = { 
-		NO_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };
-	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred);
+		READ_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	struct job_record *job_ptr = NULL;
 	struct step_record *step_ptr = NULL;
 		
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_STEP_LAYOUT");
+	debug2("Processing RPC: REQUEST_STEP_LAYOUT, from uid=%u",
+		(unsigned int) uid);
 
 	lock_slurmctld(job_read_lock);
 	error_code = job_alloc_info(uid, req->job_id, &job_ptr);
@@ -1681,7 +1801,6 @@ static void _slurm_rpc_step_layout(slurm_msg_t *msg)
 /* _slurm_rpc_submit_batch_job - process RPC to submit a batch job */
 static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg)
 {
-	/* init */
 	int error_code = SLURM_SUCCESS;
 	DEF_TIMERS;
 	uint32_t step_id = 0;
@@ -1689,25 +1808,30 @@ static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg)
 	slurm_msg_t response_msg;
 	submit_response_msg_t submit_msg;
 	job_desc_msg_t *job_desc_msg = (job_desc_msg_t *) msg->data;
-
 	/* Locks: Write job, read node, read partition */
 	slurmctld_lock_t job_write_lock = { 
 		NO_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_SUBMIT_BATCH_JOB");
+	debug2("Processing RPC: REQUEST_SUBMIT_BATCH_JOB from uid=%u",
+		(unsigned int) uid);
 
 	slurm_msg_t_init(&response_msg);
 	/* do RPC call */
-	dump_job_desc(job_desc_msg);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if ( (uid != job_desc_msg->user_id) && (!_is_super_user(uid)) ) {
+	if ( (uid != job_desc_msg->user_id) && (!validate_super_user(uid)) ) {
 		/* NOTE: User root can submit a batch job for any other user */
 		error_code = ESLURM_USER_ID_MISSING;
 		error("Security violation, SUBMIT_JOB from uid=%u",
-		      (unsigned int) uid);
+			(unsigned int) uid);
+	}
+	if ((job_desc_msg->alloc_node == NULL)
+	||  (job_desc_msg->alloc_node[0] == '\0')) {
+		error_code = ESLURM_INVALID_NODE_NAME;
+		error("REQUEST_SUBMIT_BATCH_JOB lacks alloc_node from uid=%u",
+			(unsigned int) uid);
 	}
+	dump_job_desc(job_desc_msg);
 	if (error_code == SLURM_SUCCESS) {
 		lock_slurmctld(job_write_lock);
 		if (job_desc_msg->job_id != SLURM_BATCH_SCRIPT) {
@@ -1721,7 +1845,7 @@ static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg)
 #ifdef HAVE_FRONT_END	/* Limited job step support */
 			/* Non-super users not permitted to run job steps on front-end.
 	 		 * A single slurmd can not handle a heavy load. */
-			if (!_is_super_user(uid)) {
+			if (!validate_super_user(uid)) {
 				info("Attempt to execute batch job step by uid=%u",
 					(unsigned int) uid);
 				slurm_send_rc_msg(msg, ESLURM_BATCH_ONLY);
@@ -1769,7 +1893,8 @@ static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg)
 
 		/* Create new job allocation */
 		error_code = job_allocate(job_desc_msg, 
-				job_desc_msg->immediate, false,
+				job_desc_msg->immediate, 
+				false, NULL,
 				false, uid, &job_ptr);
 		unlock_slurmctld(job_write_lock);
 		END_TIMER2("_slurm_rpc_submit_batch_job");
@@ -1802,21 +1927,20 @@ static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg)
  *	job (e.g. priority) */
 static void _slurm_rpc_update_job(slurm_msg_t * msg)
 {
-	/* init */
 	int error_code;
 	DEF_TIMERS;
 	job_desc_msg_t *job_desc_msg = (job_desc_msg_t *) msg->data;
 	/* Locks: Write job, read node, read partition */
 	slurmctld_lock_t job_write_lock = { 
 		NO_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_UPDATE_JOB");
+	debug2("Processing RPC: REQUEST_UPDATE_JOB from uid=%u",
+		(unsigned int) uid);
 
 	/* do RPC call */
 	dump_job_desc(job_desc_msg);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
 	lock_slurmctld(job_write_lock);
 	error_code = update_job(job_desc_msg, uid);
 	unlock_slurmctld(job_write_lock);
@@ -1893,7 +2017,6 @@ extern int slurm_fail_job(uint32_t job_id)
  *	node (e.g. UP/DOWN) */
 static void _slurm_rpc_update_node(slurm_msg_t * msg)
 {
-	/* init */
 	int error_code = SLURM_SUCCESS;
 	DEF_TIMERS;
 	update_node_msg_t *update_node_msg_ptr =
@@ -1901,12 +2024,12 @@ static void _slurm_rpc_update_node(slurm_msg_t * msg)
 	/* Locks: Write job and write node */
 	slurmctld_lock_t node_write_lock = { 
 		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_UPDATE_NODE");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	debug2("Processing RPC: REQUEST_UPDATE_NODE from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
 		error_code = ESLURM_USER_ID_MISSING;
 		error("Security violation, UPDATE_NODE RPC from uid=%u",
 		      (unsigned int) uid);
@@ -1943,19 +2066,18 @@ static void _slurm_rpc_update_node(slurm_msg_t * msg)
  *	of a partition (e.g. UP/DOWN) */
 static void _slurm_rpc_update_partition(slurm_msg_t * msg)
 {
-	/* init */
 	int error_code = SLURM_SUCCESS;
 	DEF_TIMERS;
 	update_part_msg_t *part_desc_ptr = (update_part_msg_t *) msg->data;
 	/* Locks: Read config, read node, write partition */
 	slurmctld_lock_t part_write_lock = { 
 		READ_LOCK, NO_LOCK, READ_LOCK, WRITE_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_UPDATE_PARTITION");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	debug2("Processing RPC: REQUEST_UPDATE_PARTITION from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
 		error_code = ESLURM_USER_ID_MISSING;
 		error
 		    ("Security violation, UPDATE_PARTITION RPC from uid=%u",
@@ -2005,12 +2127,12 @@ static void _slurm_rpc_delete_partition(slurm_msg_t * msg)
 	/* Locks: write job, read node, write partition */
 	slurmctld_lock_t part_write_lock = { 
 		NO_LOCK, WRITE_LOCK, READ_LOCK, WRITE_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_DELETE_PARTITION");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	if (!_is_super_user(uid)) {
+	debug2("Processing RPC: REQUEST_DELETE_PARTITION from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
 		error_code = ESLURM_USER_ID_MISSING;
 		error
 		    ("Security violation, DELETE_PARTITION RPC from uid=%u",
@@ -2079,12 +2201,27 @@ static void  _slurm_rpc_node_select_info(slurm_msg_t * msg)
 	node_info_select_request_msg_t *sel_req_msg =
 		(node_info_select_request_msg_t *) msg->data;
 	slurm_msg_t response_msg;
+	/* Locks: read config */
+	slurmctld_lock_t config_read_lock = { 
+		READ_LOCK, NO_LOCK, NO_LOCK, NO_LOCK };
 	DEF_TIMERS;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_NODE_SELECT_INFO");
-	error_code = select_g_pack_node_info(sel_req_msg->last_update,
-					     &buffer);
+	debug2("Processing RPC: REQUEST_NODE_SELECT_INFO from uid=%u",
+		(unsigned int) uid);
+	lock_slurmctld(config_read_lock);
+	if (slurmctld_conf.private_data && !validate_super_user(uid)) {
+		error_code = ESLURM_USER_ID_MISSING;
+		error("Security violation, NODE_SELECT_INFO RPC from uid=u",
+			(unsigned int) uid);
+	} 
+	unlock_slurmctld(config_read_lock);
+	if (error_code == SLURM_SUCCESS) {
+		error_code = select_g_pack_node_info(
+					sel_req_msg->last_update,
+					&buffer);
+	}
 	END_TIMER2("_slurm_rpc_node_select_info");
 
 	if (error_code) {
@@ -2122,7 +2259,7 @@ inline static void _slurm_rpc_suspend(slurm_msg_t * msg)
 	/* Locks: write job and node */
 	slurmctld_lock_t job_write_lock = {
 		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	char *op;
 
 	START_TIMER;
@@ -2136,8 +2273,8 @@ inline static void _slurm_rpc_suspend(slurm_msg_t * msg)
 		default:
 			op = "unknown";
 	}
-	info("Processing RPC: REQUEST_SUSPEND(%s)", op);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	info("Processing RPC: REQUEST_SUSPEND(%s) from uid=%u", 
+		op, (unsigned int) uid);
 
 	lock_slurmctld(job_write_lock);
 	error_code = job_suspend(sus_ptr, uid, msg->conn_fd);
@@ -2165,11 +2302,11 @@ inline static void _slurm_rpc_requeue(slurm_msg_t * msg)
 	/* Locks: write job and node */
 	slurmctld_lock_t job_write_lock = {
 		NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	info("Processing RPC: REQUEST_REQUEUE");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	info("Processing RPC: REQUEST_REQUEUE from uid=%u",
+		(unsigned int) uid);
 
 	lock_slurmctld(job_write_lock);
 	error_code = job_requeue(uid, requeue_ptr->job_id, 
@@ -2197,7 +2334,7 @@ inline static void  _slurm_rpc_checkpoint(slurm_msg_t * msg)
 	/* Locks: write job */
 	slurmctld_lock_t job_write_lock = { 
 		NO_LOCK, WRITE_LOCK, NO_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	char *op;
 
 	START_TIMER;
@@ -2226,8 +2363,8 @@ inline static void  _slurm_rpc_checkpoint(slurm_msg_t * msg)
 		default:
 			op = "unknown";
 	}
-	debug2("Processing RPC: REQUEST_CHECKPOINT %s", op);
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	debug2("Processing RPC: REQUEST_CHECKPOINT(%s) from uid=%u", 
+		op, (unsigned int) uid);
 
 	/* do RPC call and send reply */
 	lock_slurmctld(job_write_lock);
@@ -2268,11 +2405,11 @@ inline static void  _slurm_rpc_checkpoint_comp(slurm_msg_t * msg)
 	/* Locks: read job */
 	slurmctld_lock_t job_read_lock = {
 		NO_LOCK, READ_LOCK, NO_LOCK, NO_LOCK };
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	START_TIMER;
-	debug2("Processing RPC: REQUEST_CHECKPOINT_COMP");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	debug2("Processing RPC: REQUEST_CHECKPOINT_COMP from uid=%u",
+		(unsigned int) uid);
 
 	/* do RPC call and send reply */
 	lock_slurmctld(job_read_lock);
@@ -2290,6 +2427,37 @@ inline static void  _slurm_rpc_checkpoint_comp(slurm_msg_t * msg)
 	}
 }
 
+inline static void  _slurm_rpc_checkpoint_task_comp(slurm_msg_t * msg)
+{
+	int error_code = SLURM_SUCCESS;
+	DEF_TIMERS;
+	checkpoint_task_comp_msg_t *ckpt_ptr;
+	/* Locks: read job */
+	slurmctld_lock_t job_read_lock = {
+		NO_LOCK, READ_LOCK, NO_LOCK, NO_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+
+	ckpt_ptr = (checkpoint_task_comp_msg_t *) msg->data;
+	START_TIMER;
+	debug2("Processing RPC: REQUEST_CHECKPOINT_TASK_COMP from uid=%u",
+		(unsigned int) uid);
+
+	/* do RPC call and send reply */
+	lock_slurmctld(job_read_lock);
+	error_code = job_step_checkpoint_task_comp(ckpt_ptr, uid, msg->conn_fd);
+	unlock_slurmctld(job_read_lock);
+	END_TIMER2("_slurm_rpc_checkpoint_task_comp");
+
+	if (error_code) {
+		info("_slurm_rpc_checkpoint_task_comp %u.%u: %s",
+			ckpt_ptr->job_id, ckpt_ptr->step_id,
+			slurm_strerror(error_code));
+	} else {
+		info("_slurm_rpc_checkpoint_task_comp %u.%u %s",
+			ckpt_ptr->job_id, ckpt_ptr->step_id, TIME_STR);
+	}
+}
+
 static char **
 _xduparray(uint16_t size, char ** array)
 {
@@ -2377,18 +2545,14 @@ int _launch_batch_step(job_desc_msg_t *job_desc_msg, uid_t uid,
 	 * to the slurmd should contain the proper allocation values
 	 * for subsequent srun jobs within the batch script.
 	 */
+	memset(&req_step_msg, 0, sizeof(job_step_create_request_msg_t));
 	req_step_msg.job_id = job_desc_msg->job_id;
 	req_step_msg.user_id = uid;
 	req_step_msg.node_count = 1;
 	req_step_msg.cpu_count = 1;
 	req_step_msg.num_tasks = 1;
-	req_step_msg.relative = 0;
 	req_step_msg.task_dist = SLURM_DIST_CYCLIC;
-	req_step_msg.port = 0;
-	req_step_msg.host = NULL;
 	req_step_msg.name = job_desc_msg->name;
-	req_step_msg.network = NULL;
-	req_step_msg.node_list = NULL;
 
 	error_code = step_create(&req_step_msg, &step_rec, false, true);
 	xfree(req_step_msg.node_list);	/* may be set by step_create */
@@ -2453,6 +2617,8 @@ int _launch_batch_step(job_desc_msg_t *job_desc_msg, uid_t uid,
 	launch_msg_ptr->err = xstrdup(job_desc_msg->err);
 	launch_msg_ptr->in = xstrdup(job_desc_msg->in);
 	launch_msg_ptr->out = xstrdup(job_desc_msg->out);
+	launch_msg_ptr->acctg_freq = job_desc_msg->acctg_freq;
+	launch_msg_ptr->open_mode = job_desc_msg->open_mode;
 	launch_msg_ptr->work_dir = xstrdup(job_desc_msg->work_dir);
 	launch_msg_ptr->argc = job_desc_msg->argc;
 	launch_msg_ptr->argv = _xduparray(job_desc_msg->argc,
@@ -2461,6 +2627,7 @@ int _launch_batch_step(job_desc_msg_t *job_desc_msg, uid_t uid,
 	launch_msg_ptr->environment = _xduparray2(job_desc_msg->env_size,
 						 job_desc_msg->environment);
 	launch_msg_ptr->envc = job_desc_msg->env_size;
+	launch_msg_ptr->job_mem = job_desc_msg->job_min_memory;
 
 	/* _max_nprocs() represents the total number of CPUs available
 	 * for this step (overcommit not supported yet). If job_desc_msg
@@ -2508,13 +2675,13 @@ int _launch_batch_step(job_desc_msg_t *job_desc_msg, uid_t uid,
 inline static void  _slurm_rpc_trigger_clear(slurm_msg_t * msg)
 {
 	int rc;
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	trigger_info_msg_t * trigger_ptr = (trigger_info_msg_t *) msg->data;
 	DEF_TIMERS;
 
 	START_TIMER;
-	debug("Processing RPC: REQUEST_TRIGGER_CLEAR");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	debug("Processing RPC: REQUEST_TRIGGER_CLEAR from uid=%u",
+		(unsigned int) uid);
 
 	rc = trigger_clear(uid, trigger_ptr);
 	END_TIMER2("_slurm_rpc_trigger_clear");
@@ -2524,15 +2691,15 @@ inline static void  _slurm_rpc_trigger_clear(slurm_msg_t * msg)
 
 inline static void  _slurm_rpc_trigger_get(slurm_msg_t * msg)
 {
-	uid_t uid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	trigger_info_msg_t *resp_data;
 	trigger_info_msg_t * trigger_ptr = (trigger_info_msg_t *) msg->data;
 	slurm_msg_t response_msg;
 	DEF_TIMERS;
 
 	START_TIMER;
-	debug("Processing RPC: REQUEST_TRIGGER_GET");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
+	debug("Processing RPC: REQUEST_TRIGGER_GET from uid=%u",
+		(unsigned int) uid);
 
 	resp_data = trigger_get(uid, trigger_ptr);
 	END_TIMER2("_slurm_rpc_trigger_get");
@@ -2548,18 +2715,164 @@ inline static void  _slurm_rpc_trigger_get(slurm_msg_t * msg)
 inline static void  _slurm_rpc_trigger_set(slurm_msg_t * msg)
 {
 	int rc;
-	uid_t uid;
-	gid_t gid;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+	gid_t gid = g_slurm_auth_get_gid(msg->auth_cred, NULL);;
 	trigger_info_msg_t * trigger_ptr = (trigger_info_msg_t *) msg->data;
 	DEF_TIMERS;
 
 	START_TIMER;
-	debug("Processing RPC: REQUEST_TRIGGER_SET");
-	uid = g_slurm_auth_get_uid(msg->auth_cred);
-	gid = g_slurm_auth_get_gid(msg->auth_cred);
+	debug("Processing RPC: REQUEST_TRIGGER_SET from uid=%u",
+		(unsigned int) uid);
 
 	rc = trigger_set(uid, gid, trigger_ptr);
 	END_TIMER2("_slurm_rpc_trigger_set");
 
 	slurm_send_rc_msg(msg, rc);
 }
+
+inline static void  _slurm_rpc_job_notify(slurm_msg_t * msg)
+{
+	int error_code = SLURM_SUCCESS;
+	/* Locks: read job */
+	slurmctld_lock_t job_read_lock = { 
+		NO_LOCK, READ_LOCK, NO_LOCK, NO_LOCK };
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+	job_notify_msg_t * notify_msg = (job_notify_msg_t *) msg->data;
+	DEF_TIMERS;
+
+	START_TIMER;
+	debug("Processing RPC: REQUEST_JOB_NOTIFY from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
+		error_code = ESLURM_USER_ID_MISSING;
+		error("Security violation, REQUEST_JOB_NOTIFY RPC from uid=%u",
+		      (unsigned int) uid);
+	}
+
+	if (error_code == SLURM_SUCCESS) {
+		/* do RPC call */
+		struct job_record *job_ptr;
+		lock_slurmctld(job_read_lock);
+		job_ptr = find_job_record(notify_msg->job_id);
+		if (job_ptr)
+			srun_user_message(job_ptr, notify_msg->message);
+		else
+			error_code = ESLURM_INVALID_JOB_ID;
+		unlock_slurmctld(job_read_lock);
+	}
+
+	END_TIMER2("_slurm_rpc_job_notify");
+	slurm_send_rc_msg(msg, error_code);
+}
+
+/* defined in controller.c */
+inline static void  _slurm_rpc_set_debug_level(slurm_msg_t *msg)
+{
+	int debug_level;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+	slurmctld_lock_t config_read_lock =
+		{ READ_LOCK, NO_LOCK, NO_LOCK, NO_LOCK };
+	set_debug_level_msg_t *request_msg = (set_debug_level_msg_t *) msg->data;
+	log_options_t log_opts = LOG_OPTS_INITIALIZER;
+	slurm_ctl_conf_t *conf;
+
+	debug2("Processing RPC: REQUEST_SET_DEBUG_LEVEL from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
+		error("set debug level request from non-super user uid=%d", 
+		      uid);
+		slurm_send_rc_msg(msg, EACCES);
+		return;
+	}
+
+	/* NOTE: not offset by LOG_LEVEL_INFO, since it's inconveniet
+	 * to provide negative values for scontrol */
+	debug_level = MIN (request_msg->debug_level, (LOG_LEVEL_END - 1));
+	debug_level = MAX (debug_level, LOG_LEVEL_QUIET);
+
+	info ("Setting debug level to %d", debug_level);
+
+	lock_slurmctld (config_read_lock);
+
+	if (slurmctld_config.daemonize) {
+		log_opts.stderr_level = LOG_LEVEL_QUIET;
+		if (slurmctld_conf.slurmctld_logfile) {
+			log_opts.logfile_level = debug_level;
+			log_opts.syslog_level = LOG_LEVEL_QUIET;
+		} else {
+			log_opts.syslog_level = debug_level;
+			log_opts.logfile_level = LOG_LEVEL_QUIET;
+		}
+	} else {
+		log_opts.syslog_level = LOG_LEVEL_QUIET;
+		log_opts.stderr_level = debug_level;
+		if (slurmctld_conf.slurmctld_logfile)
+			log_opts.logfile_level = debug_level;
+		else
+			log_opts.logfile_level = LOG_LEVEL_QUIET;
+	}
+
+	log_alter(log_opts, LOG_DAEMON, slurmctld_conf.slurmctld_logfile);
+
+	unlock_slurmctld (config_read_lock);
+
+	conf = slurm_conf_lock();
+	conf->slurmctld_debug = debug_level;
+	slurm_conf_unlock();
+	slurmctld_conf.last_update = time(NULL);
+
+	slurm_send_rc_msg(msg, SLURM_SUCCESS);
+}
+
+inline static void  _slurm_rpc_accounting_update_msg(slurm_msg_t *msg)
+{
+	int rc = SLURM_SUCCESS;
+	uid_t uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+	ListIterator itr = NULL;
+	accounting_update_msg_t *update_ptr =
+		(accounting_update_msg_t *) msg->data;
+	acct_update_object_t *object = NULL;
+	
+	DEF_TIMERS;
+
+	START_TIMER;
+	debug2("Processing RPC: ACCOUNTING_UPDATE_MSG from uid=%u",
+		(unsigned int) uid);
+	if (!validate_super_user(uid)) {
+		error("Update Association request from non-super user uid=%d", 
+		      uid);
+		slurm_send_rc_msg(msg, EACCES);
+		return;
+	}
+	if(update_ptr->update_list && list_count(update_ptr->update_list)) {
+		itr = list_iterator_create(update_ptr->update_list);
+		while((object = list_next(itr))) {
+			if(!object->objects || !list_count(object->objects))
+				continue;
+			switch(object->type) {
+			case ACCT_MODIFY_USER:
+			case ACCT_ADD_USER:
+			case ACCT_REMOVE_USER:
+				rc = assoc_mgr_update_local_users(object);
+				break;
+			case ACCT_ADD_ASSOC:
+			case ACCT_MODIFY_ASSOC:
+			case ACCT_REMOVE_ASSOC:
+				rc = assoc_mgr_update_local_assocs(
+					object);
+				break;
+			case ACCT_UPDATE_NOTSET:
+			default:
+				error("unknown type set in update_object: %d",
+				      object->type);
+				break;
+			}
+		}
+		list_iterator_destroy(itr);
+	}
+	
+	END_TIMER2("_slurm_rpc_accounting_update_msg");
+
+	slurm_send_rc_msg(msg, rc);
+}
+
diff --git a/src/slurmctld/proc_req.h b/src/slurmctld/proc_req.h
index 3d1fe46ee2a6017410745dc87179a49eb14809df..e3f3ed89b6f93b3c33d62947c804313a6c1e88df 100644
--- a/src/slurmctld/proc_req.h
+++ b/src/slurmctld/proc_req.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> and Kevin Tew <tew1@llnl.gov> 
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c
index 49b8d18fd0f51117143ab402b8fb231fb791e42b..bf839eb66c2be017df165ddffbc3cfa31fdb9bcf 100644
--- a/src/slurmctld/read_config.c
+++ b/src/slurmctld/read_config.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,12 +62,12 @@
 #include "src/common/parse_spec.h"
 #include "src/common/read_config.h"
 #include "src/common/slurm_jobcomp.h"
+#include "src/common/slurm_rlimits_info.h"
 #include "src/common/switch.h"
 #include "src/common/xstring.h"
-#include "src/common/node_select.h"
-#include "src/common/slurm_jobacct.h"
-#include "src/common/slurm_rlimits_info.h"
 
+#include "src/slurmctld/job_scheduler.h"
+#include "src/slurmctld/licenses.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/node_scheduler.h"
 #include "src/slurmctld/proc_req.h"
@@ -77,17 +77,19 @@
 #include "src/slurmctld/trigger_mgr.h"
 
 static int  _build_bitmaps(void);
+static void _build_bitmaps_pre_select(void);
 static int  _init_all_slurm_conf(void);
 static void _purge_old_node_state(struct node_record *old_node_table_ptr, 
 				int old_node_record_count);
-static void _restore_node_state(struct node_record *old_node_table_ptr, 
+static int  _restore_job_dependencies(void);
+static int  _restore_node_state(struct node_record *old_node_table_ptr, 
 				int old_node_record_count);
 static int  _preserve_select_type_param(slurm_ctl_conf_t * ctl_conf_ptr, 
 					select_type_plugin_info_t old_select_type_p);
 static int  _preserve_plugins(slurm_ctl_conf_t * ctl_conf_ptr, 
 				char *old_auth_type, char *old_checkpoint_type,
-				char *old_sched_type, char *old_select_type,
-				char *old_switch_type);
+				char *old_crypto_type, char *old_sched_type, 
+				char *old_select_type, char *old_switch_type);
 static int  _sync_nodes_to_comp_job(void);
 static int  _sync_nodes_to_jobs(void);
 static int  _sync_nodes_to_active_job(struct job_record *job_ptr);
@@ -95,12 +97,60 @@ static int  _sync_nodes_to_active_job(struct job_record *job_ptr);
 static void _validate_node_proc_count(void);
 #endif
 
-static char highest_node_name[MAX_SLURM_NAME] = "";
+static char *highest_node_name = NULL;
 int node_record_count = 0;
 
 /* FIXME - declarations for temporarily moved functions */
 #define MULTIPLE_VALUE_MSG "Multiple values for %s, latest one used"
 
+/*
+ * _build_bitmaps_pre_select - recover some state for jobs and nodes prior to 
+ *	calling the select_* functions
+ */
+static void _build_bitmaps_pre_select(void)
+{
+	struct part_record   *part_ptr;
+	struct node_record   *node_ptr;
+	ListIterator part_iterator;
+	int i;
+	
+
+	/* scan partition table and identify nodes in each */
+	part_iterator = list_iterator_create(part_list);
+	if (part_iterator == NULL)
+		fatal ("memory allocation failure");
+
+	while ((part_ptr = (struct part_record *) list_next(part_iterator))) {
+		FREE_NULL_BITMAP(part_ptr->node_bitmap);
+
+		if ((part_ptr->nodes == NULL) || (part_ptr->nodes[0] == '\0'))
+			continue;
+
+		if (node_name2bitmap(part_ptr->nodes, false, 
+				     &part_ptr->node_bitmap)) {
+			fatal("Invalid node names in partition %s",
+			      part_ptr->name);
+		}
+
+		for (i=0; i<node_record_count; i++) {
+			if (bit_test(part_ptr->node_bitmap, i) == 0)
+				continue;
+			node_ptr = &node_record_table_ptr[i];
+			part_ptr->total_nodes++;
+			if (slurmctld_conf.fast_schedule)
+				part_ptr->total_cpus += 
+					node_ptr->config_ptr->cpus;
+			else
+				part_ptr->total_cpus += node_ptr->cpus;
+			node_ptr->part_cnt++;
+			xrealloc(node_ptr->part_pptr, (node_ptr->part_cnt *
+				sizeof(struct part_record *)));
+			node_ptr->part_pptr[node_ptr->part_cnt-1] = part_ptr;
+		}
+	}
+	list_iterator_destroy(part_iterator);
+	return;	
+}
 
 /*
  * _build_bitmaps - build node bitmaps to define which nodes are in which 
@@ -114,16 +164,11 @@ int node_record_count = 0;
  */
 static int _build_bitmaps(void)
 {
-	int i, j, error_code = SLURM_SUCCESS;
-	char *this_node_name;
+	int i, error_code = SLURM_SUCCESS;
 	ListIterator config_iterator;
-	ListIterator part_iterator;
 	struct config_record *config_ptr;
-	struct part_record   *part_ptr;
-	struct node_record   *node_ptr;
 	struct job_record    *job_ptr;
 	ListIterator job_iterator;
-	hostlist_t host_list;
 
 	last_node_update = time(NULL);
 	last_part_update = time(NULL);
@@ -189,7 +234,7 @@ static int _build_bitmaps(void)
 		base_state = node_record_table_ptr[i].node_state & 
 				NODE_STATE_BASE;
 		drain_flag = node_record_table_ptr[i].node_state &
-				NODE_STATE_DRAIN; 
+				(NODE_STATE_DRAIN | NODE_STATE_FAIL);
 		no_resp_flag = node_record_table_ptr[i].node_state & 
 				NODE_STATE_NO_RESPOND;
 		job_cnt = node_record_table_ptr[i].run_job_cnt +
@@ -208,56 +253,6 @@ static int _build_bitmaps(void)
 			bit_set(node_record_table_ptr[i].config_ptr->
 				node_bitmap, i);
 	}
-
-	/* scan partition table and identify nodes in each */
-	part_iterator = list_iterator_create(part_list);
-	if (part_iterator == NULL)
-		fatal ("memory allocation failure");
-
-	while ((part_ptr = (struct part_record *) list_next(part_iterator))) {
-		FREE_NULL_BITMAP(part_ptr->node_bitmap);
-		part_ptr->node_bitmap =
-		    (bitstr_t *) bit_alloc(node_record_count);
-		if (part_ptr->node_bitmap == NULL)
-			fatal ("bit_alloc malloc failure");
-
-		/* check for each node in the partition */
-		if ((part_ptr->nodes == NULL) || (part_ptr->nodes[0] == '\0'))
-			continue;
-
-		if ((host_list = hostlist_create(part_ptr->nodes)) == NULL) {
-			fatal("hostlist_create error for %s, %m",
-			      part_ptr->nodes);
-			continue;
-		}
-
-		while ((this_node_name = hostlist_shift(host_list))) {
-			node_ptr = find_node_record(this_node_name);
-			if (node_ptr == NULL) {
-				fatal("_build_bitmaps: node %s is referenced "
-					"but not defined in slurm.conf "
-					"(no NodeName specification)", 
-					this_node_name);
-				free(this_node_name);
-				continue;
-			}
-			j = node_ptr - node_record_table_ptr;
-			bit_set(part_ptr->node_bitmap, j);
-			part_ptr->total_nodes++;
-			if (slurmctld_conf.fast_schedule)
-				part_ptr->total_cpus += 
-					node_ptr->config_ptr->cpus;
-			else
-				part_ptr->total_cpus += node_ptr->cpus;
-			node_ptr->part_cnt++;
-			xrealloc(node_ptr->part_pptr, (node_ptr->part_cnt *
-				sizeof(struct part_record *)));
-			node_ptr->part_pptr[node_ptr->part_cnt-1] = part_ptr;
-			free(this_node_name);
-		}
-		hostlist_destroy(host_list);
-	}
-	list_iterator_destroy(part_iterator);
 	return error_code;
 }
 
@@ -286,7 +281,7 @@ static int _init_all_slurm_conf(void)
 	if ((error_code = init_job_conf()))
 		return error_code;
 
-	strcpy(highest_node_name, "");
+	xfree(highest_node_name);
 	return 0;
 }
 
@@ -303,9 +298,12 @@ static int _state_str2int(const char *state_str)
 			break;
 		}
 	}
-	if ((i >= NODE_STATE_END)
-	&&  (strncasecmp("DRAIN", state_str, 5) == 0))
-		state_val = NODE_STATE_UNKNOWN | NODE_STATE_DRAIN;
+	if (i >= NODE_STATE_END) {
+		if (strncasecmp("DRAIN", state_str, 5) == 0)
+			state_val = NODE_STATE_UNKNOWN | NODE_STATE_DRAIN;
+		else if (strncasecmp("FAIL", state_str, 4) == 0)
+			state_val = NODE_STATE_IDLE | NODE_STATE_FAIL;
+	}
 	if (state_val == NO_VAL) {
 		error("invalid node state %s", state_str);
 		errno = EINVAL;
@@ -344,6 +342,7 @@ static void _set_node_prefix(const char *nodenames, slurm_ctl_conf_t *conf)
 	debug3("Prefix is %s %s %d", conf->node_prefix, nodenames, i);
 }
 #endif /* HAVE_BG */
+
 /* 
  * _build_single_nodeline_info - From the slurm.conf reader, build table,
  * 	and set values
@@ -391,7 +390,8 @@ static int _build_single_nodeline_info(slurm_conf_node_t *node_ptr,
 	}
 
 #ifdef HAVE_BG
-	_set_node_prefix(node_ptr->nodenames, conf);
+	if (conf->node_prefix == NULL)
+		_set_node_prefix(node_ptr->nodenames, conf);
 #endif
 
 	/* some sanity checks */
@@ -422,14 +422,16 @@ static int _build_single_nodeline_info(slurm_conf_node_t *node_ptr,
 		hostname = hostlist_shift(hostname_list);
 		address = hostlist_shift(address_list);
 #endif		
-		if (strcmp(alias, highest_node_name) <= 0) {
+		if (highest_node_name &&
+		    (strcmp(alias, highest_node_name) <= 0)) {
 			/* find_node_record locks this to get the
 			   alias so we need to unlock */
 			slurm_conf_unlock();
 			node_rec = find_node_record(alias);
 			slurm_conf_lock();			
 		} else {
-			strncpy(highest_node_name, alias, MAX_SLURM_NAME);
+			xfree(highest_node_name);
+			highest_node_name = xstrdup(alias);
 			node_rec = NULL;
 		}
 
@@ -439,7 +441,7 @@ static int _build_single_nodeline_info(slurm_conf_node_t *node_ptr,
 			    (state_val != NODE_STATE_UNKNOWN))
 				node_rec->node_state = state_val;
 			node_rec->last_response = (time_t) 0;
-			strncpy(node_rec->comm_name, address, MAX_SLURM_NAME);
+			node_rec->comm_name = xstrdup(address);
 
 			node_rec->port = node_ptr->port;
 			node_rec->reason = xstrdup(node_ptr->reason);
@@ -567,6 +569,22 @@ static int _build_all_nodeline_info(slurm_ctl_conf_t *conf)
 
 		_build_single_nodeline_info(node, config_ptr, conf);
 	}
+	xfree(highest_node_name);
+#ifdef HAVE_BG
+{
+	char *node_000 = NULL;
+	struct node_record *node_rec = NULL;
+	if (conf->node_prefix)
+		node_000 = xstrdup(conf->node_prefix);
+	xstrcat(node_000, "000");
+	slurm_conf_unlock();
+	node_rec = find_node_record(node_000);
+	slurm_conf_lock();
+	if (node_rec == NULL)
+		fatal("No node %s configured", node_000);
+	xfree(node_000);
+}
+#endif
 	return SLURM_SUCCESS;
 }
 
@@ -582,37 +600,44 @@ static int _build_single_partitionline_info(slurm_conf_partition_t *part)
 {
 	struct part_record *part_ptr;
 
-	if (strlen(part->name) >= MAX_SLURM_NAME) {
-		error("_parse_part_spec: partition name %s too long",
-		      part->name);
-		return EINVAL;
-	}
-
 	part_ptr = list_find_first(part_list, &list_find_part, part->name);
 	if (part_ptr == NULL) {
 		part_ptr = create_part_record();
-		strcpy(part_ptr->name, part->name);
+		xfree(part_ptr->name);
+		part_ptr->name = xstrdup(part->name);
 	} else {
 		verbose("_parse_part_spec: duplicate entry for partition %s",
 			part->name);
 	}
 
 	if (part->default_flag) {
-		if ((strlen(default_part_name) > 0)
+		if (default_part_name
 		&&  strcmp(default_part_name, part->name))
 			info("_parse_part_spec: changing default partition "
 				"from %s to %s", 
 				default_part_name, part->name);
-		strcpy(default_part_name, part->name);
+		xfree(default_part_name);
+		default_part_name = xstrdup(part->name);
 		default_part_loc = part_ptr;
 	}
-	part_ptr->hidden    = part->hidden_flag ? 1 : 0;
-	part_ptr->max_time  = part->max_time;
-	part_ptr->max_nodes = part->max_nodes;
-	part_ptr->min_nodes = part->min_nodes;
-	part_ptr->root_only = part->root_only_flag ? 1 : 0;
-	part_ptr->state_up  = part->state_up_flag ? 1 : 0;
-	part_ptr->shared    = part->shared;
+	if(part->disable_root_jobs == (uint16_t)NO_VAL)
+		part_ptr->disable_root_jobs = slurmctld_conf.disable_root_jobs;
+	else
+		part_ptr->disable_root_jobs = part->disable_root_jobs;
+	
+	if(part_ptr->disable_root_jobs) 
+		debug2("partition %s does not allow root jobs", part_ptr->name);
+	
+	part_ptr->hidden         = part->hidden_flag ? 1 : 0;
+	part_ptr->max_time       = part->max_time;
+	part_ptr->max_share      = part->max_share;
+	part_ptr->max_nodes      = part->max_nodes;
+	part_ptr->max_nodes_orig = part->max_nodes;
+	part_ptr->min_nodes      = part->min_nodes;
+	part_ptr->min_nodes_orig = part->min_nodes;
+	part_ptr->priority       = part->priority;
+	part_ptr->root_only      = part->root_only_flag ? 1 : 0;
+	part_ptr->state_up       = part->state_up_flag ? 1 : 0;
 	if (part->allow_groups) {
 		xfree(part_ptr->allow_groups);
 		part_ptr->allow_groups = xstrdup(part->allow_groups);
@@ -677,19 +702,20 @@ static int _build_all_partitionline_info()
  *              state information depending upon value
  *              0 = use no saved state information
  *              1 = recover saved job and trigger state, 
- *                  node DOWN/DRAIN state and reason information
+ *                  node DOWN/DRAIN/FAIL state and reason information
  *              2 = recover all state saved from last slurmctld shutdown
- * RET 0 if no error, otherwise an error code
+ * RET SLURM_SUCCESS if no error, otherwise an error code
  * Note: Operates on common variables only
  */
 int read_slurm_conf(int recover)
 {
 	DEF_TIMERS;
-	int error_code, i;
+	int error_code, i, rc;
 	int old_node_record_count;
 	struct node_record *old_node_table_ptr;
 	char *old_auth_type       = xstrdup(slurmctld_conf.authtype);
 	char *old_checkpoint_type = xstrdup(slurmctld_conf.checkpoint_type);
+	char *old_crypto_type     = xstrdup(slurmctld_conf.crypto_type);
 	char *old_sched_type      = xstrdup(slurmctld_conf.schedtype);
 	char *old_select_type     = xstrdup(slurmctld_conf.select_type);
 	char *old_switch_type     = xstrdup(slurmctld_conf.switch_type);
@@ -711,9 +737,16 @@ int read_slurm_conf(int recover)
 	old_node_record_count = node_record_count;
 	old_node_table_ptr    = node_record_table_ptr;
 	for (i=0; i<node_record_count; i++) {
+		xfree(old_node_table_ptr[i].arch);
 		xfree(old_node_table_ptr[i].features);
+		xfree(old_node_table_ptr[i].os);
 		old_node_table_ptr[i].features = xstrdup(
 			old_node_table_ptr[i].config_ptr->feature);
+		/* Store the original configured CPU count somewhere
+		 * (port is reused here for that purpose) so we can
+		 * report changes in its configuration. */
+		old_node_table_ptr[i].port = old_node_table_ptr[i].
+					     config_ptr->cpus;
 	}
 	node_record_table_ptr = NULL;
 	node_record_count = 0;
@@ -729,7 +762,6 @@ int read_slurm_conf(int recover)
 	_build_all_partitionline_info();
 
 	update_logging();
-	jobacct_g_init_slurmctld(slurmctld_conf.job_acct_logfile);
 	g_slurm_jobcomp_init(slurmctld_conf.job_comp_loc);
 	slurm_sched_init();
 	if (switch_init() < 0)
@@ -757,22 +789,24 @@ int read_slurm_conf(int recover)
 		(void) load_all_job_state();
 	} else {	/* Load no info, preserve all state */
 		if (old_node_table_ptr) {
-			debug("restoring original state of nodes");
-			_restore_node_state(old_node_table_ptr, 
-					    old_node_record_count);
+			info("restoring original state of nodes");
+			rc = _restore_node_state(old_node_table_ptr, 
+						 old_node_record_count);
+			error_code = MAX(error_code, rc);  /* not fatal */
 		}
 		reset_first_job_id();
 		(void) slurm_sched_reconfig();
 		xfree(state_save_dir);
 	}
 
+	_build_bitmaps_pre_select();
 	if ((select_g_node_init(node_record_table_ptr, node_record_count)
-			!= SLURM_SUCCESS) 
+	     != SLURM_SUCCESS) 
 	    || (select_g_block_init(part_list) != SLURM_SUCCESS) 
 	    || (select_g_state_restore(state_save_dir) != SLURM_SUCCESS) 
 	    || (select_g_job_init(job_list) != SLURM_SUCCESS)) {
-		error("failed to initialize node selection plugin state");
-		abort();
+		fatal("failed to initialize node selection plugin state, "
+		      "Clean start required.");
 	}
 	xfree(state_save_dir);
 	reset_job_bitmaps();		/* must follow select_g_job_init() */
@@ -781,8 +815,14 @@ int read_slurm_conf(int recover)
 	(void) sync_job_files();
 	_purge_old_node_state(old_node_table_ptr, old_node_record_count);
 
-	if ((error_code = _build_bitmaps()))
-		return error_code;
+	if ((rc = _build_bitmaps()))
+		return rc;	/* fatal error */
+
+	license_free();
+	if (license_init(slurmctld_conf.licenses) != SLURM_SUCCESS)
+		fatal("Invalid Licenses value: %s", slurmctld_conf.licenses);
+
+	_restore_job_dependencies();
 	restore_node_features();
 #ifdef 	HAVE_ELAN
 	_validate_node_proc_count();
@@ -797,15 +837,16 @@ int read_slurm_conf(int recover)
 	list_sort(config_list, &list_compare_config);
 
 	/* Update plugins as possible */
-	error_code = _preserve_plugins(&slurmctld_conf,
-			old_auth_type, old_checkpoint_type,
-			old_sched_type, old_select_type,
-			old_switch_type);
+	rc = _preserve_plugins(&slurmctld_conf,
+			       old_auth_type, old_checkpoint_type,
+			       old_crypto_type, old_sched_type, 
+			       old_select_type, old_switch_type);
+	error_code = MAX(error_code, rc);	/* not fatal */
 
 	/* Update plugin parameters as possible */
-	error_code = _preserve_select_type_param(
-		        &slurmctld_conf,
-			old_select_type_p);
+	rc = _preserve_select_type_param(&slurmctld_conf,
+					 old_select_type_p);
+	error_code = MAX(error_code, rc);	/* not fatal */
 
 	slurmctld_conf.last_update = time(NULL);
 	END_TIMER2("read_slurm_conf");
@@ -815,11 +856,11 @@ int read_slurm_conf(int recover)
 
 /* Restore node state and size information from saved records.
  * If a node was re-configured to be down or drained, we set those states */
-static void _restore_node_state(struct node_record *old_node_table_ptr, 
+static int _restore_node_state(struct node_record *old_node_table_ptr, 
 				int old_node_record_count)
 {
 	struct node_record *node_ptr;
-	int i;
+	int i, rc = SLURM_SUCCESS;
 
 	for (i = 0; i < old_node_record_count; i++) {
 		uint16_t drain_flag = false, down_flag = false;
@@ -840,6 +881,12 @@ static void _restore_node_state(struct node_record *old_node_table_ptr,
 			node_ptr->node_state |= NODE_STATE_DRAIN; 
 			
 		node_ptr->last_response = old_node_table_ptr[i].last_response;
+		if (old_node_table_ptr[i].port != node_ptr->config_ptr->cpus) {
+			rc = ESLURM_NEED_RESTART;
+			error("Configured cpu count change on %s (%u to %u)", 
+			      node_ptr->name, old_node_table_ptr[i].port, 
+			      node_ptr->config_ptr->cpus);
+		}
 		node_ptr->cpus          = old_node_table_ptr[i].cpus;
 		node_ptr->sockets       = old_node_table_ptr[i].sockets;
 		node_ptr->cores         = old_node_table_ptr[i].cores;
@@ -856,7 +903,18 @@ static void _restore_node_state(struct node_record *old_node_table_ptr,
 			node_ptr->features = old_node_table_ptr[i].features;
 			old_node_table_ptr[i].features = NULL;
 		}
+		if (old_node_table_ptr[i].arch) {
+			xfree(node_ptr->arch);
+			node_ptr->arch = old_node_table_ptr[i].arch;
+			old_node_table_ptr[i].arch = NULL;
+		}
+		if (old_node_table_ptr[i].os) {
+			xfree(node_ptr->os);
+			node_ptr->os = old_node_table_ptr[i].os;
+			old_node_table_ptr[i].os = NULL;
+		}
 	}
+	return rc;
 }
 
 /* Purge old node state information */
@@ -866,8 +924,12 @@ static void _purge_old_node_state(struct node_record *old_node_table_ptr,
 	int i;
 
 	for (i = 0; i < old_node_record_count; i++) {
-		xfree(old_node_table_ptr[i].part_pptr);
+		xfree(old_node_table_ptr[i].arch);
+		xfree(old_node_table_ptr[i].comm_name);
 		xfree(old_node_table_ptr[i].features);
+		xfree(old_node_table_ptr[i].name);
+		xfree(old_node_table_ptr[i].os);
+		xfree(old_node_table_ptr[i].part_pptr);
 		xfree(old_node_table_ptr[i].reason);
 	}
 	xfree(old_node_table_ptr);
@@ -904,8 +966,8 @@ static int  _preserve_select_type_param(slurm_ctl_conf_t *ctl_conf_ptr,
  */
 static int  _preserve_plugins(slurm_ctl_conf_t * ctl_conf_ptr, 
 		char *old_auth_type, char *old_checkpoint_type,
-		char *old_sched_type, char *old_select_type, 
-		char *old_switch_type)
+		char *old_crypto_type, char *old_sched_type, 
+		char *old_select_type, char *old_switch_type)
 {
 	int rc = SLURM_SUCCESS;
 
@@ -928,6 +990,16 @@ static int  _preserve_plugins(slurm_ctl_conf_t * ctl_conf_ptr,
 			xfree(old_checkpoint_type);
 	}
 
+	if (old_crypto_type) {
+		if (strcmp(old_crypto_type,
+				ctl_conf_ptr->crypto_type)) {
+			xfree(ctl_conf_ptr->crypto_type);
+			ctl_conf_ptr->crypto_type = old_crypto_type;
+			rc = ESLURM_INVALID_CRYPTO_TYPE_CHANGE;
+		} else
+			xfree(old_crypto_type);
+	}
+
 	if (old_sched_type) {
 		if (strcmp(old_sched_type, ctl_conf_ptr->schedtype)) {
 			xfree(ctl_conf_ptr->schedtype);
@@ -1101,3 +1173,41 @@ static void _validate_node_proc_count(void)
 }
 #endif
 
+/*
+ * _restore_job_dependencies - Build depend_list and license_list for every job
+ */
+static int _restore_job_dependencies(void)
+{
+	int error_code = SLURM_SUCCESS, rc;
+	struct job_record *job_ptr;
+	ListIterator job_iterator;
+	char *new_depend;
+	bool valid;
+	List license_list;
+
+	job_iterator = list_iterator_create(job_list);
+	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
+		license_list = license_job_validate(job_ptr->licenses, &valid);
+		if (job_ptr->license_list)
+			list_destroy(job_ptr->license_list);
+		if (valid)
+			job_ptr->license_list = license_list;
+		if (job_ptr->job_state == JOB_RUNNING) 
+			license_job_get(job_ptr);
+
+		if ((job_ptr->details == NULL) ||
+		    (job_ptr->details->dependency == NULL))
+			continue;
+		new_depend = job_ptr->details->dependency;
+		job_ptr->details->dependency = NULL;
+		rc = update_job_dependency(job_ptr, new_depend);
+		if (rc != SLURM_SUCCESS) {
+			error("Invalid dependencies discarded for job %u: %s",
+				job_ptr->job_id, new_depend);
+			error_code = rc;
+		}
+		xfree(new_depend);
+	}
+	list_iterator_destroy(job_iterator);
+	return error_code;
+}
diff --git a/src/slurmctld/read_config.h b/src/slurmctld/read_config.h
index bc1fe154ad1e9b8a5a4b7497377f6e036b323f8e..2305565ae553b02c2d5084430a4de621264a19e2 100644
--- a/src/slurmctld/read_config.h
+++ b/src/slurmctld/read_config.h
@@ -1,10 +1,10 @@
 /*****************************************************************************\
- *  read_config.h - header to manager node ping
+ *  read_config.h - functions for reading slurmctld configuration
  *****************************************************************************
  *  Copyright (C) 2003 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -48,7 +48,7 @@
  *                  node DOWN/DRAIN state and reason information
  *              1 = recover only saved job state information
  *              2 = recover all state saved from last slurmctld shutdown
- * RET 0 if no error, otherwise an error code
+ * RET SLURM_SUCCESS if no error, otherwise an error code
  * Note: Operates on common variables only
  */
 extern int read_slurm_conf(int recover);
diff --git a/src/slurmctld/sched_plugin.c b/src/slurmctld/sched_plugin.c
index 8b3febb539ee421e9d60c18234fe59f38ae2e82c..fea958bde17635fb2f314df4dfbcc7b9edd02055 100644
--- a/src/slurmctld/sched_plugin.c
+++ b/src/slurmctld/sched_plugin.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -52,6 +52,8 @@
 /* ************************************************************************ */
 typedef struct slurm_sched_ops {
 	int		(*schedule)		( void );
+	int		(*newalloc)		( struct job_record * );
+	int		(*freealloc)		( struct job_record * );
 	uint32_t	(*initial_priority)	( uint32_t, 
 						  struct job_record * );
 	void            (*job_is_pending)     	( void );
@@ -59,6 +61,9 @@ typedef struct slurm_sched_ops {
 	void            (*partition_change)    	( void );
 	int		(*get_errno)		( void );
 	char *		(*strerror)		( int );
+	void		(*job_requeue)		( struct job_record *,
+						  char *reason );
+	char *		(*get_conf)		( void );
 } slurm_sched_ops_t;
 
 
@@ -88,12 +93,16 @@ slurm_sched_get_ops( slurm_sched_context_t *c )
 	 */
 	static const char *syms[] = {
 		"slurm_sched_plugin_schedule",
+		"slurm_sched_plugin_newalloc",
+		"slurm_sched_plugin_freealloc",
 		"slurm_sched_plugin_initial_priority",
 		"slurm_sched_plugin_job_is_pending",
 		"slurm_sched_plugin_reconfig",
 		"slurm_sched_plugin_partition_change",
 		"slurm_sched_get_errno",
-		"slurm_sched_strerror"
+		"slurm_sched_strerror",
+		"slurm_sched_plugin_requeue",
+		"slurm_sched_get_conf"
 	};
 	int n_syms = sizeof( syms ) / sizeof( char * );
 
@@ -260,6 +269,30 @@ slurm_sched_schedule( void )
 	return (*(g_sched_context->ops.schedule))();
 }
 
+/* *********************************************************************** */
+/*  TAG(                        slurm_sched_newalloc                    )  */
+/* *********************************************************************** */
+int
+slurm_sched_newalloc( struct job_record *job_ptr )
+{
+	if ( slurm_sched_init() < 0 )
+		return SLURM_ERROR;
+	
+	return (*(g_sched_context->ops.newalloc))( job_ptr );
+}
+
+/* *********************************************************************** */
+/*  TAG(                        slurm_sched_freealloc                    )  */
+/* *********************************************************************** */
+int
+slurm_sched_freealloc( struct job_record *job_ptr )
+{
+	if ( slurm_sched_init() < 0 )
+		return SLURM_ERROR;
+	
+	return (*(g_sched_context->ops.freealloc))( job_ptr );
+}
+
 
 /* *********************************************************************** */
 /*  TAG(                   slurm_sched_initital_priority                )  */
@@ -322,3 +355,29 @@ slurm_sched_p_strerror( int errnum )
 
 	return (*(g_sched_context->ops.strerror))( errnum );
 }
+
+/* *********************************************************************** */
+/*  TAG(                   slurm_sched_requeue                          )  */
+/* *********************************************************************** */
+void
+slurm_sched_requeue( struct job_record *job_ptr, char *reason )
+{
+        if ( slurm_sched_init() < 0 )
+                return;
+
+        (*(g_sched_context->ops.job_requeue))( job_ptr, reason );
+}
+
+/* *********************************************************************** */
+/*  TAG(                   slurm_sched_p_get_conf                       )  */
+/* *********************************************************************** */
+char *
+slurm_sched_p_get_conf( void )
+{
+        if ( slurm_sched_init() < 0 )
+                return NULL;
+
+        return (*(g_sched_context->ops.get_conf))( );
+}
+
+
diff --git a/src/slurmctld/sched_plugin.h b/src/slurmctld/sched_plugin.h
index e3dc03a983ae4cdaa8ad0476c364e6c4f7ed4e92..de16bb45133c5ed7edc8db0108155311412b28fb 100644
--- a/src/slurmctld/sched_plugin.h
+++ b/src/slurmctld/sched_plugin.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -71,12 +71,27 @@ int slurm_sched_reconfig( void );
  */
 int slurm_sched_schedule( void );
 
+/*
+ * Note the successful allocation of resources to a job.
+ */
+int slurm_sched_newalloc( struct job_record *job_ptr );
+
+/*
+ * Note the successful release of resources to a job.
+ */
+int slurm_sched_freealloc( struct job_record *job_ptr );
+
 /*
  * Supply the initial SLURM priority for a newly-submitted job.
  */
 uint32_t slurm_sched_initial_priority( uint32_t max_prio, 
 				       struct job_record *job_ptr );
 
+/*
+ * Requeue a job
+ */
+void slurm_sched_requeue( struct job_record *job_ptr, char *reason );
+
 /*
  * Note that some job is pending.
  */
@@ -97,4 +112,10 @@ int slurm_sched_p_get_errno( void );
  */
 char *slurm_sched_p_strerror( int errnum );
 
+/*
+ * Return any plugin-specific configuration information
+ * Caller must xfree return value
+ */
+char *slurm_sched_p_get_conf( void );
+
 #endif /*__SLURM_CONTROLLER_SCHED_PLUGIN_API_H__*/
diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h
index 8c7d733d77d0ce7627ab24206d2a1dd628d36674..6ff3e1ee44dbebf9d50fec6e9a4a9076242cfa06 100644
--- a/src/slurmctld/slurmctld.h
+++ b/src/slurmctld/slurmctld.h
@@ -1,12 +1,11 @@
 /*****************************************************************************\
  *  slurmctld.h - definitions of functions and structures for slurmcltd use
- *
- *  $Id: slurmctld.h 13061 2008-01-22 21:23:56Z da $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -92,7 +91,11 @@
  *  GENERAL CONFIGURATION parameters and data structures
 \*****************************************************************************/
 /* Maximum parallel threads to service incoming RPCs */
-#define MAX_SERVER_THREADS 60
+#define MAX_SERVER_THREADS 100
+
+/* Maximum size we want to support for user strings (e.g. job comment).
+ * Try to prevent user from filling slurmctld's memory */
+#define MAX_STR_LEN  64 * 1024
 
 /* Perform full slurmctld's state every PERIODIC_CHECKPOINT seconds */
 #define	PERIODIC_CHECKPOINT	300
@@ -135,6 +138,7 @@
 typedef struct slurmctld_config {
 	int	daemonize;
 	bool	resume_backup;
+	time_t	boot_time;
 	time_t	shutdown_time;
 	int	server_thread_count;
 
@@ -158,11 +162,13 @@ typedef struct slurmctld_config {
 
 extern slurmctld_config_t slurmctld_config;
 extern int bg_recover;		/* state recovery mode */
+extern char *slurmctld_cluster_name; /* name of cluster */
+extern void *acct_db_conn;
+extern int accounting_enforce;
 
 /*****************************************************************************\
  *  NODE parameters and data structures
 \*****************************************************************************/
-#define MAX_JOBNAME_LEN 256
 #define CONFIG_MAGIC 0xc065eded
 #define NODE_MAGIC   0x0de575ed
 
@@ -185,7 +191,7 @@ extern List config_list;	/* list of config_record entries */
 
 struct node_record {
 	uint32_t magic;			/* magic cookie for data integrity */
-	char name[MAX_SLURM_NAME];	/* name of the node. NULL==defunct */
+	char *name;			/* name of the node. NULL==defunct */
 	uint16_t node_state;		/* enum node_states, ORed with 
 					 * NODE_STATE_NO_RESPOND if not 
 					 * responding */
@@ -201,7 +207,7 @@ struct node_record {
 	uint16_t part_cnt;		/* number of associated partitions */
 	struct part_record **part_pptr;	/* array of pointers to partitions 
 					 * associated with this node*/
-	char comm_name[MAX_SLURM_NAME];	/* communications path name to node */
+	char *comm_name;		/* communications path name to node */
 	uint16_t port;			/* TCP port number of the slurmd */
 	slurm_addr slurm_addr;		/* network address */
 	uint16_t comp_job_cnt;		/* count of jobs completing on node */
@@ -212,6 +218,8 @@ struct node_record {
 	char *features;			/* associated features, used only
 					 * for state save/restore, DO NOT
 					 * use for scheduling purposes */
+	char *arch;			/* computer architecture */
+	char *os;			/* operating system currently running */
 	struct node_record *node_next;	/* next entry with same hash index */ 
 };
 
@@ -233,19 +241,23 @@ extern bitstr_t *up_node_bitmap;	/* bitmap of up nodes, not DOWN */
 #define PART_MAGIC 0xaefe8495
 
 struct part_record {
+	uint16_t disable_root_jobs; /* if set then user root can't run jobs */
 	uint32_t magic;		/* magic cookie to test data integrity */
-	char name[MAX_SLURM_NAME];/* name of the partition */
+	char *name;		/* name of the partition */
 	uint16_t hidden;	/* 1 if hidden by default */
 	uint32_t max_time;	/* minutes or INFINITE */
 	uint32_t max_nodes;	/* per job or INFINITE */
+	uint32_t max_nodes_orig;/* unscaled value (c-nodes on BlueGene) */
 	uint32_t min_nodes;	/* per job */
+	uint32_t min_nodes_orig;/* unscaled value (c-nodes on BlueGene) */
 	uint32_t total_nodes;	/* total number of nodes in the partition */
 	uint32_t total_cpus;	/* total number of cpus in the partition */
 	uint32_t min_offset;	/* select plugin min offset */
 	uint32_t max_offset;	/* select plugin max offset */
 	uint16_t root_only;	/* 1 if allocate/submit RPC can only be 
 				   issued by user root */
-	uint16_t shared;	/* See part_shared in slurm.h */
+	uint16_t max_share;	/* number of jobs to gang schedule */
+	uint16_t priority;	/* scheduling priority for jobs */
 	uint16_t state_up;	/* 1 if state is up, 0 if down */
 	char *nodes;		/* comma delimited list names of nodes */
 	char *allow_groups;	/* comma delimited list of groups, 
@@ -257,7 +269,7 @@ struct part_record {
 extern List part_list;			/* list of part_record entries */
 extern time_t last_part_update;		/* time of last part_list update */
 extern struct part_record default_part;	/* default configuration values */
-extern char default_part_name[MAX_SLURM_NAME];	/* name of default partition */
+extern char *default_part_name;		/* name of default partition */
 extern struct part_record *default_part_loc;	/* default partition ptr */
 
 /*****************************************************************************\
@@ -265,11 +277,29 @@ extern struct part_record *default_part_loc;	/* default partition ptr */
 \*****************************************************************************/
 extern time_t last_job_update;	/* time of last update to part records */
 
+/* Used for Moab
+ * These QOS values only apply to LLNL's configuration
+ * Other values may apply at other sites,
+ * These may be mapped to partition priorities in the future */
+#define QOS_EXPEDITE	300
+#define QOS_NORMAL 	200
+#define	QOS_STANDBY	100
+
 #define DETAILS_MAGIC 0xdea84e7
 #define JOB_MAGIC 0xf0b7392c
 #define STEP_MAGIC 0xce593bc1
 #define KILL_ON_STEP_DONE	1
 
+#define FEATURE_OP_OR  0
+#define FEATURE_OP_AND 1
+#define FEATURE_OP_XOR 2
+#define FEATURE_OP_END 3		/* last entry lacks separator */
+struct feature_record {
+	char *name;			/* name of feature */
+	uint16_t count;			/* count of nodes with this feature */
+	uint8_t op_code;		/* separator, see FEATURE_OP_ above */
+};
+
 /* job_details - specification of a job's constraints, 
  * can be purged after initiation */
 struct job_details {
@@ -282,28 +312,29 @@ struct job_details {
 	uint16_t *req_node_layout;	/* task layout for required nodes */
 	bitstr_t *exc_node_bitmap;	/* bitmap of excluded nodes */
 	char *features;			/* required features */
+	List feature_list;		/* required features with node counts */
 	uint16_t shared;		/* 1 if job can share nodes,
-					   0 if job cannot share nodes,
-					   any other value accepts the default
-					   sharing policy. */
+					 * 0 if job cannot share nodes,
+					 * any other value accepts the default
+					 * sharing policy. */
 	uint16_t contiguous;		/* set if requires contiguous nodes */
-	uint16_t task_dist;		/* task layout for this job. Only useful
-                                         * when Consumable Resources is enabled */
+	uint16_t task_dist;		/* task layout for this job. Only
+					 * useful when Consumable Resources
+                                         * is enabled */
 	uint32_t num_tasks;		/* number of tasks to start */
-	uint16_t overcommit;		/* processors being over subscribed */
+	uint8_t open_mode;		/* stdout/err append or trunctate */
+	uint8_t overcommit;		/* processors being over subscribed */
+	uint16_t acctg_freq;		/* accounting polling interval */
 	uint16_t cpus_per_task;		/* number of processors required for 
 					 * each task */
 	uint16_t ntasks_per_node;	/* number of tasks on each node */
 	/* job constraints: */
 	uint32_t job_min_procs;		/* minimum processors per node */
 	uint32_t job_min_memory;	/* minimum memory per node, MB */
-	uint32_t job_max_memory;	/* maximum memory per node, MB */
 	uint32_t job_min_tmp_disk;	/* minimum tempdisk per node, MB */
 	char *err;			/* pathname of job's stderr file */
 	char *in;			/* pathname of job's stdin file */
 	char *out;			/* pathname of job's stdout file */
-	uint32_t total_procs;		/* number of allocated processors, 
-					   for accounting */
 	time_t submit_time;		/* time of submission */
 	time_t begin_time;		/* start at this time (srun --being), 
 					 * resets to time first eligible
@@ -313,89 +344,116 @@ struct job_details {
 	char *work_dir;			/* pathname of working directory */
 	char **argv;			/* arguments for a batch job script */
 	uint16_t argc;			/* count of argv elements */
-	uint16_t no_requeue;		/* don't requeue job if set */
+	uint16_t requeue;		/* controls ability requeue job */
 	multi_core_data_t *mc_ptr;	/* multi-core specific data */
+	char *dependency;		/* wait for other jobs */
+	List depend_list;		/* list of job_ptr:state pairs */
 };
 
 struct job_record {
-	uint32_t job_id;		/* job ID */
-	uint32_t magic;			/* magic cookie for data integrity */
-	char name[MAX_JOBNAME_LEN];	/* name of the job */
-	char partition[MAX_SLURM_NAME];	/* name of the partition */
-	struct part_record *part_ptr;	/* pointer to the partition record */
+	char    *account;		/* account number to charge */
+	char    *alloc_node;		/* local node making resource alloc */
+	uint16_t alloc_resp_port;	/* RESPONSE_RESOURCE_ALLOCATION port */
+	uint32_t alloc_sid;		/* local sid making resource alloc */
+	uint32_t assoc_id;              /* used for accounting plugins */
+	void    *assoc_ptr;		/* job's association record ptr, it is
+					 * void* because of interdependencies
+					 * in the header files, confirm the 
+					 * value before use */
 	uint16_t batch_flag;		/* 1 or 2 if batch job (with script),
 					 * 2 indicates retry mode (one retry) */
-	uint32_t user_id;		/* user the job runs as */
+	char *comment;			/* arbitrary comment */
+        uint16_t cr_enabled;            /* specify if if Consumable Resources
+                                         * is enabled. Needed since CR deals
+                                         * with a finer granularity in its
+                                         * node/cpu scheduling (available cpus
+                                         * instead of available nodes) than the
+                                         * bluegene and the linear plugins 
+                                         * 0 if cr is NOT enabled, 
+                                         * 1 if cr is enabled */
+	uint32_t db_index;              /* used only for database
+					 * plugins */
+	struct job_details *details;	/* job details */
+	time_t end_time;		/* time of termination, 
+					 * actual or expected */
+	uint32_t exit_code;		/* exit code for job (status from 
+					 * wait call) */
 	uint32_t group_id;		/* group submitted under */
+	uint32_t job_id;		/* job ID */
+	struct job_record *job_next;	/* next entry with same hash index */
 	enum job_states job_state;	/* state of the job */
 	uint16_t kill_on_node_fail;	/* 1 if job should be killed on 
 					 * node failure */
 	uint16_t kill_on_step_done;	/* 1 if job should be killed when 
 					 * the job step completes, 2 if kill
 					 * in progress */
-	select_jobinfo_t select_jobinfo;	/* opaque data */
+	char *licenses;			/* licenses required by the job */
+	List license_list;		/* structure with license info */
+	uint16_t mail_type;		/* see MAIL_JOB_* in slurm.h */
+	char *mail_user;		/* user to get e-mail notification */
+	uint32_t magic;			/* magic cookie for data integrity */
+	char *name;			/* name of the job */
+	char *network;			/* network/switch requirement spec */
+	uint16_t next_step_id;		/* next step id to be used */
 	char *nodes;			/* list of nodes allocated to job */
+	slurm_addr *node_addr;		/* addresses of the nodes allocated to 
+					 * job */
 	bitstr_t *node_bitmap;		/* bitmap of nodes allocated to job */
+	uint32_t node_cnt;		/* count of nodes currently 
+					 * allocated to job */
 	char *nodes_completing;		/* nodes still in completing state
 					 * for this job, used to insure
 					 * epilog is not re-run for job */
 	uint32_t num_procs;		/* count of required processors */
-	uint32_t time_limit;		/* time_limit minutes or INFINITE,
-					 * NO_VAL implies partition max_time */
+	uint16_t other_port;		/* port for client communications */
+	char *partition;		/* name of the partition */
+	struct part_record *part_ptr;	/* pointer to the partition record */
+	time_t pre_sus_time;		/* time job ran prior to last suspend */
+	uint32_t priority;		/* relative priority of the job,
+					 * zero == held (don't initiate) */
+	uint16_t qos;			/* quality of service, used only by Moab */
+	uint32_t requid;            	/* requester user ID */
+	char *resp_host;		/* host for srun communications */
+	select_jobinfo_t select_jobinfo;/* opaque data */
 	time_t start_time;		/* time execution begins, 
 					 * actual or expected */
-	time_t end_time;		/* time of termination, 
-					 * actual or expected */
+	uint16_t state_reason;		/* reason job still pending or failed
+					 * see slurm.h:enum job_wait_reason */
+	List step_list;			/* list of job's steps */
 	time_t suspend_time;		/* time job last suspended or resumed */
-	time_t pre_sus_time;		/* time job ran prior to last suspend */
 	time_t time_last_active;	/* time of last job activity */
-	uint32_t priority;		/* relative priority of the job,
-					 * zero == held (don't initiate) */
-	struct job_details *details;	/* job details */
+	uint32_t time_limit;		/* time_limit minutes or INFINITE,
+					 * NO_VAL implies partition max_time */
+	time_t tot_sus_time;		/* total time in suspend state */
+	uint32_t total_procs;		/* number of allocated processors, 
+					 * for accounting */
+	uint32_t user_id;		/* user the job runs as */
+
+	/* Per node allocation details */
 	uint16_t num_cpu_groups;	/* record count in cpus_per_node and 
 					 * cpu_count_reps */
 	uint32_t *cpus_per_node;	/* array of cpus per node allocated */
 	uint32_t *cpu_count_reps;	/* array of consecutive nodes with 
 					 * same cpu count */
-	uint32_t alloc_sid;		/* local sid making resource alloc */
-	char    *alloc_node;		/* local node making resource alloc */
-	uint16_t next_step_id;		/* next step id to be used */
-	uint32_t node_cnt;		/* count of nodes allocated to job */
-	slurm_addr *node_addr;		/* addresses of the nodes allocated to 
-					 * job */
-	List step_list;			/* list of job's steps */
-	uint16_t alloc_resp_port;	/* RESPONSE_RESOURCE_ALLOCATION port */
-	char *alloc_resp_host;		/* RESPONSE_RESOURCE_ALLOCATION host */
-	uint16_t other_port;		/* port for client communications */
-	char *other_host;		/* host for client communications */
-	char *account;			/* account number to charge */
-	char *comment;			/* arbitrary comment */
-	uint32_t dependency;		/* defer until this job completes */
-	char *network;			/* network/switch requirement spec */
-	struct job_record *job_next;	/* next entry with same hash index */
-        uint16_t cr_enabled;            /* specify if if Consumable
-                                         * Resources is
-                                         * enabled. Needed since CR
-                                         * deals with a finer
-                                         * granularity in its node/cpu
-                                         * scheduling (available cpus
-                                         * instead of available nodes)
-                                         * than the bluegene and the
-                                         * linear plugins 
-                                         * 0 if cr is NOT enabled, 
-                                         * 1 if cr is enabled */
+
         uint32_t alloc_lps_cnt;		/* number of hosts in alloc_lps
 					 * or 0 if alloc_lps is not needed
 					 * for the credentials */
         uint32_t *alloc_lps;		/* number of logical processors
 					 * allocated for this job */
-	uint16_t mail_type;		/* see MAIL_JOB_* in slurm.h */
-	char *mail_user;		/* user to get e-mail notification */
-	uint32_t requid;            	/* requester user ID */
-	uint32_t exit_code;		/* exit code for job (status from 
-					 * wait call) */
-	uint16_t state_reason;		/* reason job still pending or failed
-					 * see slurm.h:enum job_wait_reason */
+	uint32_t *used_lps;		/* number of logical processors
+					 * already allocated to job steps */
+};
+
+/* Job dependency specification, used in "depend_list" within job_record */
+#define SLURM_DEPEND_AFTER		1
+#define SLURM_DEPEND_AFTER_ANY		2
+#define SLURM_DEPEND_AFTER_NOT_OK	3
+#define SLURM_DEPEND_AFTER_OK		4
+struct	depend_spec {
+	uint16_t	depend_type;	/* SLURM_DEPEND_* type */
+	uint32_t	job_id;		/* SLURM job_id */
+	struct job_record *job_ptr;	/* pointer to this job */
 };
 
 struct 	step_record {
@@ -408,11 +466,17 @@ struct 	step_record {
 					 * implicitly the same as suspend_time
 					 * in the job record */
 	time_t pre_sus_time;		/* time step ran prior to last suspend */
+	time_t tot_sus_time;		/* total time in suspended state */
 	bitstr_t *step_node_bitmap;	/* bitmap of nodes allocated to job 
 					   step */
 	uint16_t port;			/* port for srun communications */
 	char *host;			/* host for srun communications */
 	uint16_t batch_step;		/* 1 if batch job step, 0 otherwise */
+	uint16_t mem_per_task;		/* MB memory per task, 0=no limit */
+	uint16_t ckpt_interval;		/* checkpoint interval in minutes */
+	char *ckpt_path;	        /* path to store checkpoint image files */
+	uint16_t exclusive;		/* dedicated resources for the step */
+	time_t ckpt_time;		/* time of last checkpoint */
 	switch_jobinfo_t switch_job;	/* switch context, opaque */
 	check_jobinfo_t check_job;	/* checkpoint context, opaque */
 	char *name;			/* name of job step */
@@ -439,11 +503,9 @@ extern List job_list;			/* list of job_record entries */
 */
 enum select_data_info {
 	SELECT_CR_PLUGIN,    /* data-> uint32 1 if CR plugin */
-	SELECT_CPU_COUNT,    /* data-> uint16 count_cpus (CR support) */   
 	SELECT_BITMAP,       /* data-> partially_idle_bitmap (CR support) */
 	SELECT_ALLOC_CPUS,   /* data-> uint16 alloc cpus (CR support) */
 	SELECT_ALLOC_LPS,    /* data-> uint32 alloc lps  (CR support) */
-	SELECT_ALLOC_MEMORY, /* data-> uint32 alloc mem  (CR support) */
 	SELECT_AVAIL_CPUS,   /* data-> uint16 avail cpus (CR support) */ 
 	SELECT_AVAIL_MEMORY  /* data-> uint32 avail mem  (CR support) */ 
 } ;
@@ -627,7 +689,7 @@ extern struct part_record *find_part_record (char *name);
  * OUT env_size - number of elements to read
  * RET point to array of string pointers containing environment variables
  */
-extern char **get_job_env (struct job_record *job_ptr, uint16_t *env_size);
+extern char **get_job_env (struct job_record *job_ptr, uint32_t *env_size);
 
 /* 
  * get_job_script - return the script for a given job
@@ -713,6 +775,7 @@ extern bool is_node_resp (char *name);
  * IN immediate - if set then either initiate the job immediately or fail
  * IN will_run - don't initiate the job if set, just test if it could run 
  *	now or later
+ * OUT resp - will run response (includes start location, time, etc.)
  * IN allocate - resource allocation request if set, not a full job
  * IN submit_uid -uid of user issuing the request
  * OUT job_pptr - set to pointer to job record
@@ -727,7 +790,8 @@ extern bool is_node_resp (char *name);
  *	default_part_loc - pointer to default partition
  * NOTE: lock_slurmctld on entry: Read config Write job, Write node, Read part
  */
-extern int job_allocate(job_desc_msg_t * job_specs, int immediate, int will_run, 
+extern int job_allocate(job_desc_msg_t * job_specs, int immediate, 
+		int will_run, will_run_response_msg_t **resp, 
 		int allocate, uid_t submit_uid, struct job_record **job_pptr);
 
 /* log the completion of the specified job */
@@ -756,14 +820,6 @@ extern int job_end_time(job_alloc_info_msg_t *time_req_msg,
 /* job_fini - free all memory associated with job records */
 extern void job_fini (void);
 
-/*
- * job_is_completing - Determine if jobs are in the process of completing.
- * RET - True of any job is in the process of completing
- * NOTE: This function can reduce resource fragmentation, which is a 
- * critical issue on Elan interconnect based systems.
- */
-extern bool job_is_completing(void);
-
 /*
  * job_fail - terminate a job due to initiation failure
  * IN job_id - id of the job to be killed
@@ -822,6 +878,15 @@ extern int job_step_checkpoint(checkpoint_msg_t *ckpt_ptr,
  */
 extern int job_step_checkpoint_comp(checkpoint_comp_msg_t *ckpt_ptr,
 		uid_t uid, slurm_fd conn_fd);
+/*
+ * job_step_checkpoint_task_comp - note task checkpoint completion
+ * IN ckpt_ptr - checkpoint task complete status message
+ * IN uid - user id of the user issuing the RPC
+ * IN conn_fd - file descriptor on which to send reply
+ * RET 0 on success, otherwise ESLURM error code
+ */
+extern int job_step_checkpoint_task_comp(checkpoint_task_comp_msg_t *ckpt_ptr,
+                uid_t uid, slurm_fd conn_fd);
 
 /*
  * job_step_suspend - perform some suspend/resume operation
@@ -855,6 +920,17 @@ extern int job_complete (uint32_t job_id, uid_t uid, bool requeue,
  */
 extern bool job_independent(struct job_record *job_ptr);
 
+/*
+ * job_req_node_filter - job reqeust node filter.
+ * clear from a bitmap the nodes which can not be used for a job
+ * test memory size, required features, processor count, etc.
+ * IN job_ptr - pointer to node to be scheduled
+ * IN/OUT bitmap - set of nodes being considered for use
+ * RET SLURM_SUCCESS or EINVAL if can't filter (exclusive OR of features)
+ */
+extern int job_req_node_filter(struct job_record *job_ptr, 
+			       bitstr_t *avail_bitmap);
+
 /*
  * job_requeue - Requeue a running or pending batch job
  * IN uid - user id of user issuing the RPC
@@ -981,14 +1057,6 @@ extern int load_all_part_state ( void );
  */
 extern int load_step_state(struct job_record *job_ptr, Buf buffer);
 
-/* 
- * make_batch_job_cred - add a job credential to the batch_job_launch_msg
- * IN/OUT launch_msg_ptr - batch_job_launch_msg in which job_id, step_id,
- *                         uid and nodes have already been set
- * RET 0 or error code
- */
-extern int make_batch_job_cred(batch_job_launch_msg_t *launch_msg_ptr);
-
 /* make_node_alloc - flag specified node as allocated to a job
  * IN node_ptr - pointer to node being allocated
  * IN job_ptr  - pointer to job that is starting
@@ -1188,6 +1256,9 @@ extern void reset_job_priority(void);
  */
 extern void restore_node_features(void);
 
+/* Update time stamps for job step resume */
+extern void resume_job_step(struct job_record *job_ptr);
+
 /* run_backup - this is the backup controller, it should run in standby 
  *	mode, assuming control when the primary controller stops responding */
 extern void run_backup(void);
@@ -1195,26 +1266,6 @@ extern void run_backup(void);
 /* save_all_state - save entire slurmctld state for later recovery */
 extern void save_all_state(void);
 
-/* 
- * schedule - attempt to schedule all pending jobs
- *	pending jobs for each partition will be scheduled in priority  
- *	order until a request fails
- * RET count of jobs scheduled
- * global: job_list - global list of job records
- *	last_job_update - time of last update to job table
- * Note: We re-build the queue every time. Jobs can not only be added 
- *	or removed from the queue, but have their priority or partition 
- *	changed with the update_job RPC. In general nodes will be in priority 
- *	order (by submit time), so the sorting should be pretty fast.
- */
-extern int schedule (void);
-
-/*
- * set_job_elig_time - set the eligible time for pending jobs once their 
- *	dependencies are lifted (in job->details->begin_time)
- */
-extern void set_job_elig_time(void);
-
 /*
  * set_node_down - make the specified node's state DOWN if possible
  *	(not in a DRAIN state), kill jobs as needed 
@@ -1239,12 +1290,22 @@ extern void set_slurmd_addr (void);
  */
 extern void signal_step_tasks(struct step_record *step_ptr, uint16_t signal);
 
+/* Read configuration file.
+ * Same name as API function for use in accounting_storage plugin */
+extern int slurm_reconfigure(void);
+
 /*
  * slurmctld_shutdown - wake up slurm_rpc_mgr thread via signal
  * RET 0 or error code
  */
 extern int slurmctld_shutdown(void);
 
+/* Perform periodic job step checkpoints (per user request) */
+extern void step_checkpoint(void);
+
+/* Update a job's record of allocated CPUs when a job step gets scheduled */
+extern void step_alloc_lps(struct step_record *step_ptr);
+
 /*
  * step_create - creates a step_record in step_specs->job_id, sets up the
  *	according to the step_specs.
@@ -1367,52 +1428,36 @@ extern int validate_group (struct part_record *part_ptr, uid_t run_uid);
  *	are actually running, if not clean up the job records and/or node 
  *	records, call this function after validate_node_specs() sets the node 
  *	state properly 
- * IN node_name - node which should have jobs running
- * IN/OUT job_count - number of jobs which should be running on specified node
- * IN job_id_ptr - pointer to array of job_ids that should be on this node
- * IN step_id_ptr - pointer to array of job step ids that should be on node
+ * IN reg_msg - node registration message
  */
-extern void validate_jobs_on_node ( char *node_name, uint32_t *job_count, 
-			uint32_t *job_id_ptr, uint16_t *step_id_ptr);
+extern void validate_jobs_on_node(slurm_node_registration_status_msg_t *reg_msg);
 
 /*
  * validate_node_specs - validate the node's specifications as valid, 
- *   if not set state to down, in any case update last_response
- * IN node_name - name of the node
- * IN cpus - number of cpus measured
- * IN sockets - number of sockets per cpu measured
- * IN cores - number of cores per socket measured
- * IN threads - number of threads per core measured
- * IN real_memory - mega_bytes of real_memory measured
- * IN tmp_disk - mega_bytes of tmp_disk measured
- * IN job_count - number of jobs allocated to this node
- * IN status - node status code
+ *	if not set state to down, in any case update last_response
+ * IN reg_msg - node registration message
  * RET 0 if no error, ENOENT if no such node, EINVAL if values too low
- * global: node_record_table_ptr - pointer to global node table
+ * NOTE: READ lock_slurmctld config before entry
  */
-extern int validate_node_specs (char *node_name,
-				uint16_t cpus,
-				uint16_t sockets,
-				uint16_t cores,
-				uint16_t threads,
-				uint32_t real_memory,
-				uint32_t tmp_disk, uint32_t job_count,
-				uint32_t status);
+extern int validate_node_specs(slurm_node_registration_status_msg_t *reg_msg);
 
 /*
  * validate_nodes_via_front_end - validate all nodes on a cluster as having
  *	a valid configuration as soon as the front-end registers. Individual
  *	nodes will not register with this configuration
- * IN job_count - number of jobs which should be running on cluster
- * IN job_id_ptr - pointer to array of job_ids that should be on cluster
- * IN step_id_ptr - pointer to array of job step ids that should be on cluster
- * IN status - cluster status code
+ * IN reg_msg - node registration message
  * RET 0 if no error, SLURM error code otherwise
- * global: node_record_table_ptr - pointer to global node table
  * NOTE: READ lock_slurmctld config before entry
  */
-extern int validate_nodes_via_front_end(uint32_t job_count, 
-			uint32_t *job_id_ptr, uint16_t *step_id_ptr,
-			uint32_t status);
+extern int validate_nodes_via_front_end(
+		slurm_node_registration_status_msg_t *reg_msg);
+
+/*
+ * validate_super_user - validate that the uid is authorized to see 
+ *      privileged data (either user root or SlurmUser)
+ * IN uid - user to validate
+ * RET true if permitted to run, false otherwise
+ */
+extern bool validate_super_user (uid_t uid);
 
 #endif /* !_HAVE_SLURMCTLD_H */
diff --git a/src/slurmctld/srun_comm.c b/src/slurmctld/srun_comm.c
index 0ecedad7bc7784a98746e3e134a90e1f849b3c72..322c6dbb9e48aae7a0c703459d509e5884c84920 100644
--- a/src/slurmctld/srun_comm.c
+++ b/src/slurmctld/srun_comm.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -78,14 +78,14 @@ extern void srun_allocate (uint32_t job_id)
 	struct job_record *job_ptr = find_job_record (job_id);
 
 	xassert(job_ptr);
-	if (job_ptr && job_ptr->alloc_resp_port
-	    && job_ptr->alloc_resp_host && job_ptr->alloc_resp_host[0]) {
+	if (job_ptr && job_ptr->alloc_resp_port && job_ptr->alloc_node
+	&&  job_ptr->resp_host) {
 		slurm_addr * addr;
 		resource_allocation_response_msg_t *msg_arg;
 
 		addr = xmalloc(sizeof(struct sockaddr_in));
-		slurm_set_addr(addr, job_ptr->alloc_resp_port,
-			       job_ptr->alloc_resp_host);
+		slurm_set_addr(addr, job_ptr->alloc_resp_port, 
+			job_ptr->resp_host);
 		msg_arg = xmalloc(sizeof(resource_allocation_response_msg_t));
 		msg_arg->job_id 	= job_ptr->job_id;
 		msg_arg->node_list	= xstrdup(job_ptr->nodes);
@@ -102,7 +102,7 @@ extern void srun_allocate (uint32_t job_id)
 		msg_arg->select_jobinfo = select_g_copy_jobinfo(
 				job_ptr->select_jobinfo);
 		msg_arg->error_code	= SLURM_SUCCESS;
-		_srun_agent_launch(addr, job_ptr->alloc_resp_host, 
+		_srun_agent_launch(addr, job_ptr->alloc_node, 
 				   RESPONSE_RESOURCE_ALLOCATION, msg_arg);
 	}
 }
@@ -126,23 +126,11 @@ extern void srun_node_fail (uint32_t job_id, char *node_name)
 	xassert(node_name);
 	if (!job_ptr || job_ptr->job_state != JOB_RUNNING)
 		return;
+
 	if (!node_name || (node_ptr = find_node_record(node_name)) == NULL)
 		return;
 	bit_position = node_ptr - node_record_table_ptr;
 
-	if (job_ptr->other_port
-	    && job_ptr->other_host && job_ptr->other_host[0]) {
-		addr = xmalloc(sizeof(struct sockaddr_in));
-		slurm_set_addr(addr, job_ptr->other_port, job_ptr->other_host);
-		msg_arg = xmalloc(sizeof(srun_node_fail_msg_t));
-		msg_arg->job_id   = job_id;
-		msg_arg->step_id  = NO_VAL;
-		msg_arg->nodelist = xstrdup(node_name);
-		_srun_agent_launch(addr, job_ptr->other_host, SRUN_NODE_FAIL,
-				   msg_arg);
-	}
-
-
 	step_iterator = list_iterator_create(job_ptr->step_list);
 	while ((step_ptr = (struct step_record *) list_next(step_iterator))) {
 		if (!bit_test(step_ptr->step_node_bitmap, bit_position))
@@ -162,6 +150,17 @@ extern void srun_node_fail (uint32_t job_id, char *node_name)
 				   msg_arg);
 	}	
 	list_iterator_destroy(step_iterator);
+
+	if (job_ptr->other_port && job_ptr->alloc_node && job_ptr->resp_host) {
+		addr = xmalloc(sizeof(struct sockaddr_in));
+		slurm_set_addr(addr, job_ptr->other_port, job_ptr->resp_host);
+		msg_arg = xmalloc(sizeof(srun_node_fail_msg_t));
+		msg_arg->job_id   = job_id;
+		msg_arg->step_id  = NO_VAL;
+		msg_arg->nodelist = xstrdup(node_name);
+		_srun_agent_launch(addr, job_ptr->alloc_node, SRUN_NODE_FAIL,
+				   msg_arg);
+	}
 }
 
 /* srun_ping - ping all srun commands that have not been heard from recently */
@@ -183,16 +182,16 @@ extern void srun_ping (void)
 		
 		if (job_ptr->job_state != JOB_RUNNING)
 			continue;
-		if ( (job_ptr->time_last_active <= old)
-		     && job_ptr->other_port
-		     && job_ptr->other_host && job_ptr->other_host[0] ) {
+		
+		if ((job_ptr->time_last_active <= old) && job_ptr->other_port
+		    &&  job_ptr->alloc_node && job_ptr->resp_host) {
 			addr = xmalloc(sizeof(struct sockaddr_in));
 			slurm_set_addr(addr, job_ptr->other_port,
-				       job_ptr->other_host);
+				job_ptr->resp_host);
 			msg_arg = xmalloc(sizeof(srun_ping_msg_t));
 			msg_arg->job_id  = job_ptr->job_id;
 			msg_arg->step_id = NO_VAL;
-			_srun_agent_launch(addr, job_ptr->other_host,
+			_srun_agent_launch(addr, job_ptr->alloc_node,
 					   SRUN_PING, msg_arg);
 		}
 	}
@@ -210,20 +209,19 @@ extern void srun_timeout (struct job_record *job_ptr)
 	srun_timeout_msg_t *msg_arg;
 	ListIterator step_iterator;
 	struct step_record *step_ptr;
-
+	
 	xassert(job_ptr);
 	if (job_ptr->job_state != JOB_RUNNING)
 		return;
-
-	if (job_ptr->other_port
-	    && job_ptr->other_host && job_ptr->other_host[0]) {
+	
+	if (job_ptr->other_port && job_ptr->alloc_node && job_ptr->resp_host) {
 		addr = xmalloc(sizeof(struct sockaddr_in));
-		slurm_set_addr(addr, job_ptr->other_port, job_ptr->other_host);
+		slurm_set_addr(addr, job_ptr->other_port, job_ptr->resp_host);
 		msg_arg = xmalloc(sizeof(srun_timeout_msg_t));
 		msg_arg->job_id   = job_ptr->job_id;
 		msg_arg->step_id  = NO_VAL;
 		msg_arg->timeout  = job_ptr->end_time;
-		_srun_agent_launch(addr, job_ptr->other_host, SRUN_TIMEOUT,
+		_srun_agent_launch(addr, job_ptr->alloc_node, SRUN_TIMEOUT,
 				   msg_arg);
 	}
 
@@ -242,7 +240,7 @@ extern void srun_timeout (struct job_record *job_ptr)
 		msg_arg->step_id  = step_ptr->step_id;
 		msg_arg->timeout  = job_ptr->end_time;
 		_srun_agent_launch(addr, step_ptr->host, SRUN_TIMEOUT, 
-				msg_arg);
+				   msg_arg);
 	}	
 	list_iterator_destroy(step_iterator);
 }
@@ -262,13 +260,13 @@ extern void srun_user_message(struct job_record *job_ptr, char *msg)
 		return;
 
 	if (job_ptr->other_port
-	&&  job_ptr->other_host && job_ptr->other_host[0]) {
+	&&  job_ptr->resp_host && job_ptr->resp_host[0]) {
 		addr = xmalloc(sizeof(struct sockaddr_in));
-		slurm_set_addr(addr, job_ptr->other_port, job_ptr->other_host);
+		slurm_set_addr(addr, job_ptr->other_port, job_ptr->resp_host);
 		msg_arg = xmalloc(sizeof(srun_user_msg_t));
 		msg_arg->job_id = job_ptr->job_id;
 		msg_arg->msg    = xstrdup(msg);
-		_srun_agent_launch(addr, job_ptr->other_host, SRUN_USER_MSG,
+		_srun_agent_launch(addr, job_ptr->resp_host, SRUN_USER_MSG,
 				   msg_arg);
 	}
 }
@@ -285,19 +283,17 @@ extern void srun_job_complete (struct job_record *job_ptr)
 	struct step_record *step_ptr;
 
 	xassert(job_ptr);
-	if (job_ptr->other_port
-	    && job_ptr->other_host && job_ptr->other_host[0]) {
+	
+	if (job_ptr->other_port && job_ptr->alloc_node && job_ptr->resp_host) {
 		addr = xmalloc(sizeof(struct sockaddr_in));
-		slurm_set_addr(addr, job_ptr->other_port, job_ptr->other_host);
-		msg_arg = xmalloc(sizeof(srun_timeout_msg_t));
+		slurm_set_addr(addr, job_ptr->other_port, job_ptr->resp_host);
+		msg_arg = xmalloc(sizeof(srun_job_complete_msg_t));
 		msg_arg->job_id   = job_ptr->job_id;
 		msg_arg->step_id  = NO_VAL;
-		_srun_agent_launch(addr, job_ptr->other_host, 
-				   SRUN_JOB_COMPLETE,
-				   msg_arg);
+		_srun_agent_launch(addr, job_ptr->alloc_node, 
+				   SRUN_JOB_COMPLETE, msg_arg);
 	}
 
-
 	step_iterator = list_iterator_create(job_ptr->step_list);
 	while ((step_ptr = (struct step_record *) list_next(step_iterator))) {
 		if (step_ptr->batch_step)	/* batch script itself */
diff --git a/src/slurmctld/srun_comm.h b/src/slurmctld/srun_comm.h
index f74cdec7ae2ba44c104bdb475c70e6d2c95cdad6..6e796100beaef65880d401b17d008daed19f9939 100644
--- a/src/slurmctld/srun_comm.h
+++ b/src/slurmctld/srun_comm.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmctld/state_save.c b/src/slurmctld/state_save.c
index f46d23dc84f7ea3a9cd19934eaf6ba4962342399..105b624bfd8a9f485b4b295293d0e4c02315143a 100644
--- a/src/slurmctld/state_save.c
+++ b/src/slurmctld/state_save.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmctld/state_save.h b/src/slurmctld/state_save.h
index 270566604ecd01b6a2914c9571eb9c9f770f434d..d800752ad1650fae6f8ce911d4f55bfb227f2cd1 100644
--- a/src/slurmctld/state_save.h
+++ b/src/slurmctld/state_save.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c
index 5b39ef9b8bcfd0a7bc53b063114ae367c614b033..cef57533058c511793dfa88d8698192de4a09b94 100644
--- a/src/slurmctld/step_mgr.c
+++ b/src/slurmctld/step_mgr.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  step_mgr.c - manage the job step information of slurm
- *  $Id: step_mgr.c 13857 2008-04-11 19:14:36Z jette $
+ *  $Id: step_mgr.c 13858 2008-04-11 19:29:30Z jette $
  *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -59,7 +59,8 @@
 #include "src/common/switch.h"
 #include "src/common/xstring.h"
 #include "src/common/forward.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurm_jobacct_gather.h"
 
 #include "src/slurmctld/agent.h"
 #include "src/slurmctld/locks.h"
@@ -67,15 +68,20 @@
 #include "src/slurmctld/slurmctld.h"
 #include "src/slurmctld/srun_comm.h"
 
+#define STEP_DEBUG 0
 #define MAX_RETRIES 10
 
+static int  _count_cpus(bitstr_t *bitmap);
 static void _pack_ctld_job_step_info(struct step_record *step, Buf buffer);
 static bitstr_t * _pick_step_nodes (struct job_record  *job_ptr, 
-				    job_step_create_request_msg_t *step_spec );
+				    job_step_create_request_msg_t *step_spec,
+				    bool batch_step, int *return_code);
 static hostlist_t _step_range_to_hostlist(struct step_record *step_ptr,
 				uint32_t range_first, uint32_t range_last);
 static int _step_hostname_to_inx(struct step_record *step_ptr,
 				char *node_name);
+static void _step_dealloc_lps(struct step_record *step_ptr);
+
 
 /* 
  * create_step_record - create an empty step_record for the specified job.
@@ -94,8 +100,9 @@ create_step_record (struct job_record *job_ptr)
 	last_job_update = time(NULL);
 	step_ptr->job_ptr = job_ptr; 
 	step_ptr->step_id = (job_ptr->next_step_id)++;
-	step_ptr->start_time = time ( NULL ) ;
-	step_ptr->jobacct = jobacct_g_alloc(NULL);
+	step_ptr->start_time = time(NULL) ;
+	step_ptr->jobacct = jobacct_gather_g_create(NULL);
+	step_ptr->ckpt_path = NULL;
 	if (list_append (job_ptr->step_list, step_ptr) == NULL)
 		fatal ("create_step_record: unable to allocate memory");
 
@@ -135,11 +142,12 @@ delete_step_records (struct job_record *job_ptr, int filter)
 		xfree(step_ptr->host);
 		xfree(step_ptr->name);
 		slurm_step_layout_destroy(step_ptr->step_layout);
-		jobacct_g_free(step_ptr->jobacct);
+		jobacct_gather_g_destroy(step_ptr->jobacct);
 		FREE_NULL_BITMAP(step_ptr->step_node_bitmap);
 		FREE_NULL_BITMAP(step_ptr->exit_node_bitmap);
 		if (step_ptr->network)
 			xfree(step_ptr->network);
+		xfree(step_ptr->ckpt_path);
 		xfree(step_ptr);
 	}		
 
@@ -179,14 +187,19 @@ delete_step_record (struct job_record *job_ptr, uint32_t step_id)
 				switch_free_jobinfo (step_ptr->switch_job);
 			}
 			checkpoint_free_jobinfo (step_ptr->check_job);
+
+			if (step_ptr->mem_per_task)
+				select_g_step_fini(step_ptr);
+
 			xfree(step_ptr->host);
 			xfree(step_ptr->name);
 			slurm_step_layout_destroy(step_ptr->step_layout);
-			jobacct_g_free(step_ptr->jobacct);
+			jobacct_gather_g_destroy(step_ptr->jobacct);
 			FREE_NULL_BITMAP(step_ptr->step_node_bitmap);
 			FREE_NULL_BITMAP(step_ptr->exit_node_bitmap);
 			if (step_ptr->network)
 				xfree(step_ptr->network);
+			xfree(step_ptr->ckpt_path);
 			xfree(step_ptr);
 			error_code = 0;
 			break;
@@ -214,9 +227,12 @@ dump_step_desc(job_step_create_request_msg_t *step_spec)
 	debug3("   num_tasks=%u relative=%u task_dist=%u node_list=%s", 
 		step_spec->num_tasks, step_spec->relative, 
 		step_spec->task_dist, step_spec->node_list);
-	debug3("   host=%s port=%u name=%s network=%s", 
+	debug3("   host=%s port=%u name=%s network=%s checkpoint=%u", 
 		step_spec->host, step_spec->port, step_spec->name,
-		step_spec->network);
+		step_spec->network, step_spec->ckpt_interval);
+	debug3("   checkpoint-path=%s exclusive=%u immediate=%u mem_per_task=%u",
+	        step_spec->ckpt_path, step_spec->exclusive, 
+		step_spec->immediate, step_spec->mem_per_task);
 }
 
 
@@ -374,23 +390,24 @@ int job_step_complete(uint32_t job_id, uint32_t step_id, uid_t uid,
 		info("job_step_complete: invalid job id %u", job_id);
 		return ESLURM_INVALID_JOB_ID;
 	}
-	
+
+	if ((job_ptr->user_id != uid) && (uid != 0) && (uid != getuid())) {
+		error("Security violation, JOB_COMPLETE RPC from uid %d",
+		      uid);
+		return ESLURM_USER_ID_MISSING;
+	}
+
 	step_ptr = find_step_record(job_ptr, step_id);
 	if (step_ptr == NULL) 
 		return ESLURM_INVALID_JOB_ID;
-	else 
-		jobacct_g_step_complete_slurmctld(step_ptr);
-	
+
+	jobacct_storage_g_step_complete(acct_db_conn, step_ptr);
+	_step_dealloc_lps(step_ptr);
+
 	if ((job_ptr->kill_on_step_done)
 	    &&  (list_count(job_ptr->step_list) <= 1)
 	    &&  (!IS_JOB_FINISHED(job_ptr))) 
 		return job_complete(job_id, uid, requeue, job_return_code);
-	
-	if ((job_ptr->user_id != uid) && (uid != 0) && (uid != getuid())) {
-		error("Security violation, JOB_COMPLETE RPC from uid %d",
-		      uid);
-		return ESLURM_USER_ID_MISSING;
-	}
 
 	last_job_update = time(NULL);
 	error_code = delete_step_record(job_ptr, step_id);
@@ -407,36 +424,75 @@ int job_step_complete(uint32_t job_id, uint32_t step_id, uid_t uid,
  *	we satisfy the super-set of constraints.
  * IN job_ptr - pointer to job to have new step started
  * IN step_spec - job step specification
+ * IN batch_step - if set then step is a batch script
+ * OUT return_code - exit code or SLURM_SUCCESS
  * global: node_record_table_ptr - pointer to global node table
  * NOTE: returns all of a job's nodes if step_spec->node_count == INFINITE
  * NOTE: returned bitmap must be freed by the caller using bit_free()
  */
 static bitstr_t *
 _pick_step_nodes (struct job_record  *job_ptr, 
-		  job_step_create_request_msg_t *step_spec)
+		  job_step_create_request_msg_t *step_spec,
+		  bool batch_step, int *return_code)
 {
 
 	bitstr_t *nodes_avail = NULL, *nodes_idle = NULL;
 	bitstr_t *nodes_picked = NULL, *node_tmp = NULL;
-	int error_code, nodes_picked_cnt = 0, cpus_picked_cnt, i;
-/* 	char *temp; */
+	int error_code, nodes_picked_cnt=0, cpus_picked_cnt = 0, i;
 	ListIterator step_iterator;
 	struct step_record *step_p;
+#if STEP_DEBUG
+	char *temp;
+#endif
 
-	if (job_ptr->node_bitmap == NULL)
+	*return_code = SLURM_SUCCESS;
+	if (job_ptr->node_bitmap == NULL) {
+		*return_code = ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
 		return NULL;
+	}
 	
 	nodes_avail = bit_copy (job_ptr->node_bitmap);
 	if (nodes_avail == NULL)
 		fatal("bit_copy malloc failure");
 	bit_and (nodes_avail, up_node_bitmap);
 
+	/* In exclusive mode, just satisfy the processor count.
+	 * Do not use nodes that have no unused CPUs */
+	if (step_spec->exclusive) {
+		int i, j=0, avail, tot_cpus = 0;
+		for (i=bit_ffs(job_ptr->node_bitmap); i<node_record_count; 
+		     i++) {
+			if (!bit_test(job_ptr->node_bitmap, i))
+				continue;
+			avail = job_ptr->alloc_lps[j] - job_ptr->used_lps[j];
+			tot_cpus += job_ptr->alloc_lps[j];
+			if ((avail <= 0) ||
+			    (cpus_picked_cnt >= step_spec->cpu_count))
+				bit_clear(nodes_avail, i);
+			else
+				cpus_picked_cnt += avail;
+			if (++j >= job_ptr->node_cnt)
+				break;
+		}
+		if (cpus_picked_cnt >= step_spec->cpu_count)
+			return nodes_avail;
+
+		FREE_NULL_BITMAP(nodes_avail);
+		if (tot_cpus >= step_spec->cpu_count)
+			*return_code = ESLURM_NODES_BUSY;
+		else
+			*return_code = ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
+		return NULL;
+	}
+
 	if ( step_spec->node_count == INFINITE)	/* use all nodes */
 		return nodes_avail;
 
 	if (step_spec->node_list) {
 		bitstr_t *selected_nodes = NULL;
-/* 		info("selected nodelist is %s", step_spec->node_list); */
+#if STEP_DEBUG
+		info("selected nodelist is %s", step_spec->node_list);
+#endif
 		error_code = node_name2bitmap(step_spec->node_list, false, 
 					      &selected_nodes);
 		
@@ -532,26 +588,30 @@ _pick_step_nodes (struct job_record  *job_ptr,
 		while ((step_p = (struct step_record *)
 			list_next(step_iterator))) {
 			bit_or(nodes_idle, step_p->step_node_bitmap);
-			/* temp = bitmap2node_name(step_p->step_node_bitmap); */
-/* 			info("step %d has nodes %s", step_p->step_id, temp); */
-/* 			xfree(temp); */
+#if STEP_DEBUG
+			temp = bitmap2node_name(step_p->step_node_bitmap);
+			info("step %d has nodes %s", step_p->step_id, temp);
+			xfree(temp);
+#endif
 		} 
 		list_iterator_destroy (step_iterator);
 		bit_not(nodes_idle);
 		bit_and(nodes_idle, nodes_avail);
 	}
-/* 	temp = bitmap2node_name(nodes_avail); */
-/* 	info("can pick from %s %d", temp, step_spec->node_count); */
-/* 	xfree(temp); */
-/* 	temp = bitmap2node_name(nodes_idle); */
-/* 	info("can pick from %s", temp); */
-/* 	xfree(temp); */
-	
+#if STEP_DEBUG
+	temp = bitmap2node_name(nodes_avail);
+	info("can pick from %s %d", temp, step_spec->node_count);
+	xfree(temp);
+	temp = bitmap2node_name(nodes_idle);
+	info("can pick from %s", temp);
+	xfree(temp);
+#endif
+
 	/* if user specifies step needs a specific processor count and 
 	 * all nodes have the same processor count, just translate this to
 	 * a node count */
-	if (step_spec->cpu_count && (job_ptr->num_cpu_groups == 1)
-	&&  job_ptr->cpus_per_node[0]) {
+	if (step_spec->cpu_count && (job_ptr->num_cpu_groups == 1) && 
+	    job_ptr->cpus_per_node[0]) {
 		i = (step_spec->cpu_count + (job_ptr->cpus_per_node[0] - 1) ) 
 				/ job_ptr->cpus_per_node[0];
 		step_spec->node_count = (i > step_spec->node_count) ? 
@@ -561,7 +621,9 @@ _pick_step_nodes (struct job_record  *job_ptr,
 
 	if (step_spec->node_count) {
 		nodes_picked_cnt = bit_set_count(nodes_picked);
-/* 		info("got %d %d", step_spec->node_count, nodes_picked_cnt); */
+#if STEP_DEBUG
+		info("got %u %d", step_spec->node_count, nodes_picked_cnt);
+#endif
 		if (nodes_idle 
 		    && (bit_set_count(nodes_idle) >= step_spec->node_count)
 		    && (step_spec->node_count > nodes_picked_cnt)) {
@@ -594,9 +656,10 @@ _pick_step_nodes (struct job_record  *job_ptr,
 	}
 	
 	if (step_spec->cpu_count) {
-		cpus_picked_cnt = count_cpus(nodes_picked);
-		/* person is requesting more cpus than we got from the
-		   picked nodes we should return with an error */
+		/* make sure the selected nodes have enough cpus */
+		cpus_picked_cnt = _count_cpus(nodes_picked);
+		/* user is requesting more cpus than we got from the
+		 * picked nodes we should return with an error */
 		if(step_spec->cpu_count > cpus_picked_cnt) {
 			debug2("Have %d nodes with %d cpus which is less "
 			       "than what the user is asking for (%d cpus) "
@@ -605,60 +668,6 @@ _pick_step_nodes (struct job_record  *job_ptr,
 			       step_spec->cpu_count);
 			goto cleanup;
 		}
-		/* Not sure why the rest of this 'if' is here 
-		   since this will only
-		   change the number of requested nodes by added nodes
-		   to the picked bitmap which isn't what we want to do
-		   if the user requests a node count.  If the user
-		   doesn't specify one then the entire allocation is
-		   already set so we should return an error in either
-		   case */
-		
-/* 		if (nodes_idle */
-/* 		    &&  (step_spec->cpu_count > cpus_picked_cnt)) { */
-/* 			int first_bit, last_bit; */
-/* 			first_bit = bit_ffs(nodes_idle); */
-/* 			if(first_bit == -1) */
-/* 				goto no_idle_bits; */
-/* 			last_bit  = bit_fls(nodes_idle); */
-/* 			if(last_bit == -1) */
-/* 				goto no_idle_bits; */
-			
-/* 			for (i = first_bit; i <= last_bit; i++) { */
-/* 				if (bit_test (nodes_idle, i) != 1) */
-/* 					continue; */
-/* 				bit_set (nodes_picked, i); */
-/* 				bit_clear (nodes_avail, i); */
-/* 				/\* bit_clear (nodes_idle, i);	unused *\/ */
-/* 				cpus_picked_cnt += */
-/* 					node_record_table_ptr[i].cpus; */
-/* 				if (cpus_picked_cnt >= step_spec->cpu_count) */
-/* 					break; */
-/* 			} */
-/* 			if (step_spec->cpu_count > cpus_picked_cnt) */
-/* 				goto cleanup; */
-/* 		} */
-/* 	no_idle_bits: */
-/* 		if (step_spec->cpu_count > cpus_picked_cnt) { */
-/* 			int first_bit, last_bit; */
-/* 			first_bit = bit_ffs(nodes_avail); */
-/* 			if(first_bit == -1) */
-/* 				goto cleanup; */
-/* 			last_bit  = bit_fls(nodes_avail); */
-/*  			if(last_bit == -1) */
-/* 				goto cleanup; */
-/* 			for (i = first_bit; i <= last_bit; i++) { */
-/* 				if (bit_test (nodes_avail, i) != 1) */
-/* 					continue; */
-/* 				bit_set (nodes_picked, i); */
-/* 				cpus_picked_cnt +=  */
-/* 					node_record_table_ptr[i].cpus; */
-/* 				if (cpus_picked_cnt >= step_spec->cpu_count) */
-/* 					break; */
-/* 			} */
-/* 			if (step_spec->cpu_count > cpus_picked_cnt) */
-/* 				goto cleanup; */
-/* 		} */
 	}
 	
 	FREE_NULL_BITMAP(nodes_avail);
@@ -669,9 +678,105 @@ cleanup:
 	FREE_NULL_BITMAP(nodes_avail);
 	FREE_NULL_BITMAP(nodes_idle);
 	FREE_NULL_BITMAP(nodes_picked);
+	*return_code = ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE;
 	return NULL;
 }
 
+/*
+ * _count_cpus - report how many cpus are associated with the identified nodes 
+ * IN bitmap - map of nodes to tally
+ * RET cpu count
+ * globals: node_record_count - number of nodes configured
+ *	node_record_table_ptr - pointer to global node table
+ */
+static int _count_cpus(bitstr_t *bitmap)
+{
+	int i, sum;
+
+	sum = 0;
+	for (i = 0; i < node_record_count; i++) {
+		if (bit_test(bitmap, i) != 1)
+			continue;
+		if (slurmctld_conf.fast_schedule)
+			sum += node_record_table_ptr[i].config_ptr->cpus;
+		else
+			sum += node_record_table_ptr[i].cpus;
+	}
+	return sum;
+}
+
+/* Update a job's record of allocated CPUs when a job step gets scheduled */
+extern void step_alloc_lps(struct step_record *step_ptr)
+{
+	struct job_record  *job_ptr = step_ptr->job_ptr;
+	int i_node, i_first, i_last;
+	int job_node_inx = -1, step_node_inx = -1;
+
+	i_first = bit_ffs(job_ptr->node_bitmap);
+	i_last  = bit_fls(job_ptr->node_bitmap);
+	if (i_first == -1)	/* empty bitmap */
+		return;
+	for (i_node = i_first; i_node <= i_last; i_node++) {
+		if (!bit_test(job_ptr->node_bitmap, i_node))
+			continue;
+		job_node_inx++;
+		if (!bit_test(step_ptr->step_node_bitmap, i_node))
+			continue;
+		step_node_inx++;
+		job_ptr->used_lps[job_node_inx] += 
+			step_ptr->step_layout->tasks[step_node_inx];
+#if 0
+		info("step alloc of %s procs: %u of %u", 
+			node_record_table_ptr[i_node].name,
+			job_ptr->used_lps[job_node_inx],
+			job_ptr->alloc_lps[job_node_inx]);
+#endif
+		if (step_node_inx == (step_ptr->step_layout->node_cnt - 1))
+			break;
+	}
+	
+}
+
+static void _step_dealloc_lps(struct step_record *step_ptr)
+{
+	struct job_record  *job_ptr = step_ptr->job_ptr;
+	int i_node, i_first, i_last;
+	int job_node_inx = -1, step_node_inx = -1;
+
+	if (step_ptr->step_layout == NULL)	/* batch step */
+		return;
+
+	i_first = bit_ffs(job_ptr->node_bitmap);
+	i_last  = bit_fls(job_ptr->node_bitmap);
+	if (i_first == -1)	/* empty bitmap */
+		return;
+	for (i_node = i_first; i_node <= i_last; i_node++) {
+		if (!bit_test(job_ptr->node_bitmap, i_node))
+			continue;
+		job_node_inx++;
+		if (!bit_test(step_ptr->step_node_bitmap, i_node))
+			continue;
+		step_node_inx++;
+		if (job_ptr->used_lps[job_node_inx] >=
+		    step_ptr->step_layout->tasks[step_node_inx]) {
+			job_ptr->used_lps[job_node_inx] -= 
+				step_ptr->step_layout->tasks[step_node_inx];
+		} else {
+			error("_step_dealloc_lps: underflow for %u.%u",
+				job_ptr->job_id, step_ptr->step_id);
+			job_ptr->used_lps[job_node_inx] = 0;
+		}
+#if 0
+		info("step dealloc of %s procs: %u of %u", 
+			node_record_table_ptr[i_node].name,
+			job_ptr->used_lps[job_node_inx],
+			job_ptr->alloc_lps[job_node_inx]);
+#endif
+		if (step_node_inx == (step_ptr->step_layout->node_cnt - 1))
+			break;
+	}
+	
+}
 
 /*
  * step_create - creates a step_record in step_specs->job_id, sets up the
@@ -692,7 +797,7 @@ step_create(job_step_create_request_msg_t *step_specs,
 	struct step_record *step_ptr;
 	struct job_record  *job_ptr;
 	bitstr_t *nodeset;
-	int node_count;
+	int node_count, ret_code;
 	time_t now = time(NULL);
 	char *step_node_list = NULL;
 
@@ -701,8 +806,10 @@ step_create(job_step_create_request_msg_t *step_specs,
 	if (job_ptr == NULL)
 		return ESLURM_INVALID_JOB_ID ;
 
-	if (job_ptr->job_state == JOB_SUSPENDED)
+	if ((job_ptr->details == NULL) || 
+	    (job_ptr->job_state == JOB_SUSPENDED))
 		return ESLURM_DISABLED;
+
 	if (IS_JOB_PENDING(job_ptr)) {
 		/* NOTE: LSF creates a job allocation for batch jobs.
 		 * After the allocation has been made, LSF submits a
@@ -728,6 +835,16 @@ step_create(job_step_create_request_msg_t *step_specs,
 	    (job_ptr->end_time <= time(NULL)))
 		return ESLURM_ALREADY_DONE;
 
+	if (job_ptr->details->job_min_memory) {
+		/* use memory reserved by job, no limit on steps */
+		step_specs->mem_per_task = 0;
+	} else if (step_specs->mem_per_task) {
+		if (slurmctld_conf.max_mem_per_task &&
+		    (step_specs->mem_per_task > slurmctld_conf.max_mem_per_task))
+			return ESLURM_INVALID_TASK_MEMORY;
+	} else
+		step_specs->mem_per_task = slurmctld_conf.def_mem_per_task;
+
 	if ((step_specs->task_dist != SLURM_DIST_CYCLIC) &&
 	    (step_specs->task_dist != SLURM_DIST_BLOCK) &&
 	    (step_specs->task_dist != SLURM_DIST_CYCLIC_CYCLIC) &&
@@ -742,7 +859,14 @@ step_create(job_step_create_request_msg_t *step_specs,
 	    && (!strcmp(slurmctld_conf.switch_type, "switch/elan"))) {
 		return ESLURM_TASKDIST_ARBITRARY_UNSUPPORTED;
 	}
-	
+
+	if ((step_specs->host      && (strlen(step_specs->host)      > MAX_STR_LEN)) ||
+	    (step_specs->node_list && (strlen(step_specs->node_list) > MAX_STR_LEN)) ||
+	    (step_specs->network   && (strlen(step_specs->network)   > MAX_STR_LEN)) ||
+	    (step_specs->name      && (strlen(step_specs->name)      > MAX_STR_LEN)) ||
+	    (step_specs->ckpt_path && (strlen(step_specs->ckpt_path) > MAX_STR_LEN)))
+		return ESLURM_PATHNAME_TOO_LONG;
+
 	/* if the overcommit flag is checked we 0 out the cpu_count
 	 * which makes it so we don't check to see the available cpus
 	 */	 
@@ -755,9 +879,9 @@ step_create(job_step_create_request_msg_t *step_specs,
 	job_ptr->kill_on_step_done = kill_job_when_step_done;
 
 	job_ptr->time_last_active = now;
-	nodeset = _pick_step_nodes(job_ptr, step_specs);
+	nodeset = _pick_step_nodes(job_ptr, step_specs, batch_step, &ret_code);
 	if (nodeset == NULL)
-		return ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE ;
+		return ret_code;
 	node_count = bit_set_count(nodeset);
 
 	if (step_specs->num_tasks == NO_VAL) {
@@ -792,8 +916,10 @@ step_create(job_step_create_request_msg_t *step_specs,
 		xfree(step_specs->node_list);
 		step_specs->node_list = xstrdup(step_node_list);
 	}
-/* 	info("got %s and %s looking for %d nodes", step_node_list, */
-/* 	     step_specs->node_list, step_specs->node_count); */
+#if STEP_DEBUG
+	info("got %s and %s looking for %d nodes", step_node_list,
+	     step_specs->node_list, step_specs->node_count);
+#endif
 	step_ptr->step_node_bitmap = nodeset;
 	
 	switch(step_specs->task_dist) {
@@ -810,7 +936,12 @@ step_create(job_step_create_request_msg_t *step_specs,
 	step_ptr->port = step_specs->port;
 	step_ptr->host = xstrdup(step_specs->host);
 	step_ptr->batch_step = batch_step;
+	step_ptr->mem_per_task = step_specs->mem_per_task;
+	step_ptr->ckpt_interval = step_specs->ckpt_interval;
+	step_ptr->ckpt_time = now;
 	step_ptr->exit_code = NO_VAL;
+	step_ptr->exclusive = step_specs->exclusive;
+	step_ptr->ckpt_path = xstrdup(step_specs->ckpt_path);
 
 	/* step's name and network default to job's values if not 
 	 * specified in the step specification */
@@ -822,7 +953,7 @@ step_create(job_step_create_request_msg_t *step_specs,
 		step_ptr->network = xstrdup(step_specs->network);
 	else
 		step_ptr->network = xstrdup(job_ptr->network);
-
+	
 	/* a batch script does not need switch info */
 	if (!batch_step) {
 		step_ptr->step_layout = 
@@ -846,12 +977,20 @@ step_create(job_step_create_request_msg_t *step_specs,
 			delete_step_record (job_ptr, step_ptr->step_id);
 			return ESLURM_INTERCONNECT_FAILURE;
 		}
+		step_alloc_lps(step_ptr);
 	}
 	if (checkpoint_alloc_jobinfo (&step_ptr->check_job) < 0)
 		fatal ("step_create: checkpoint_alloc_jobinfo error");
 	xfree(step_node_list);
+	if (step_ptr->mem_per_task &&
+	    (select_g_step_begin(step_ptr) != SLURM_SUCCESS)) {
+		error("No memory to allocate step for job %u", job_ptr->job_id);
+		step_ptr->mem_per_task = 0;	/* no memory to be freed */
+		delete_step_record (job_ptr, step_ptr->step_id);
+		return ESLURM_INVALID_TASK_MEMORY;
+	}
 	*new_step_record = step_ptr;
-	jobacct_g_step_start_slurmctld(step_ptr);
+	jobacct_storage_g_step_start(acct_db_conn, step_ptr);
 	return SLURM_SUCCESS;
 }
 
@@ -866,14 +1005,10 @@ extern slurm_step_layout_t *step_layout_create(struct step_record *step_ptr,
 	uint32_t cpu_count_reps[node_count];
 	int cpu_inx = -1;
 	int usable_cpus = 0, i;
-	int set_nodes = 0;
-	int inx = 0;
+	int set_nodes = 0, set_cpus = 0;
 	int pos = -1;
 	struct job_record *job_ptr = step_ptr->job_ptr;
 
-	/* node_pos is the position in the node in the job */
-	uint32_t node_pos = job_ptr->cpu_count_reps[inx];
-			
 	/* build the cpus-per-node arrays for the subset of nodes
 	   used by this job step */
 	for (i = 0; i < node_record_count; i++) {
@@ -882,15 +1017,19 @@ extern slurm_step_layout_t *step_layout_create(struct step_record *step_ptr,
 			pos = bit_get_pos_num(job_ptr->node_bitmap, i);
 			if (pos == -1)
 				return NULL;
-			/* need to get the correct num of cpus on the
-			   node */
-			while(pos >= node_pos) {
-				node_pos += 
-					job_ptr->cpu_count_reps[++inx];
-			}
-			debug2("%d got inx of %d cpus = %d pos = %d", 
-			       i, inx, job_ptr->cpus_per_node[inx], pos);
-			usable_cpus = job_ptr->cpus_per_node[inx];
+			if (step_ptr->exclusive) {
+				usable_cpus = job_ptr->alloc_lps[pos] -
+					      job_ptr->used_lps[pos];
+				if (usable_cpus < 0) {
+					error("step_layout_create exclusive");
+					return NULL;
+				}
+				usable_cpus = MAX(usable_cpus, 
+						  (num_tasks - set_cpus));
+			} else
+				usable_cpus = job_ptr->alloc_lps[pos];
+			debug2("step_layout cpus = %d pos = %d", 
+			       usable_cpus, pos);
 			
 			if ((cpu_inx == -1) ||
 			    (cpus_per_node[cpu_inx] != usable_cpus)) {
@@ -901,10 +1040,12 @@ extern slurm_step_layout_t *step_layout_create(struct step_record *step_ptr,
 			} else
 				cpu_count_reps[cpu_inx]++;
 			set_nodes++;
-			if(set_nodes == node_count)
+			set_cpus += usable_cpus;
+			if (set_nodes == node_count)
 				break;
 		}
 	}
+
 	/* layout the tasks on the nodes */
 	return slurm_step_layout_create(step_node_list,
 					cpus_per_node, cpu_count_reps, 
@@ -931,6 +1072,7 @@ static void _pack_ctld_job_step_info(struct step_record *step_ptr, Buf buffer)
 	}
 	pack32(step_ptr->job_ptr->job_id, buffer);
 	pack16(step_ptr->step_id, buffer);
+	pack16(step_ptr->ckpt_interval, buffer);
 	pack32(step_ptr->job_ptr->user_id, buffer);
 	pack32(task_cnt, buffer);
 
@@ -949,6 +1091,7 @@ static void _pack_ctld_job_step_info(struct step_record *step_ptr, Buf buffer)
 	packstr(step_ptr->name, buffer);
 	packstr(step_ptr->network, buffer);
 	pack_bit_fmt(step_ptr->step_node_bitmap, buffer);
+	packstr(step_ptr->ckpt_path, buffer);
 	
 }
 
@@ -988,6 +1131,12 @@ extern int pack_ctld_job_step_info_response_msg(uint32_t job_id,
 			    (job_ptr->part_ptr) && 
 			    (job_ptr->part_ptr->hidden))
 				continue;
+
+			if (slurmctld_conf.private_data
+			&&  (job_ptr->user_id != uid) 
+			&&  !validate_super_user(uid))
+				continue;
+
 			step_iterator =
 			    list_iterator_create(job_ptr->step_list);
 			while ((step_ptr =
@@ -1007,6 +1156,10 @@ extern int pack_ctld_job_step_info_response_msg(uint32_t job_id,
 		    (job_ptr->part_ptr) && 
 		    (job_ptr->part_ptr->hidden))
 			job_ptr = NULL;
+		else if (slurmctld_conf.private_data
+		&&  (job_ptr->user_id != uid) && !validate_super_user(uid))
+			job_ptr = NULL;
+
 		if (job_ptr) {
 			step_iterator = 
 				list_iterator_create(job_ptr->step_list);
@@ -1027,6 +1180,10 @@ extern int pack_ctld_job_step_info_response_msg(uint32_t job_id,
 		&&  (job_ptr->part_ptr) 
 		&&  (job_ptr->part_ptr->hidden))
 			job_ptr = NULL;
+		else if (slurmctld_conf.private_data
+		&&  (job_ptr->user_id != uid) && !validate_super_user(uid))
+			job_ptr = NULL;
+
 		step_ptr = find_step_record(job_ptr, step_id);
 		if (step_ptr == NULL)
 			error_code = ESLURM_INVALID_JOB_ID;
@@ -1225,6 +1382,62 @@ extern int job_step_checkpoint_comp(checkpoint_comp_msg_t *ckpt_ptr,
 	return rc;
 }
 
+/*
+ * job_step_checkpoint_task_comp - note task checkpoint completion
+ * IN ckpt_ptr - checkpoint task complete status message
+ * IN uid - user id of the user issuing the RPC
+ * IN conn_fd - file descriptor on which to send reply
+ * RET 0 on success, otherwise ESLURM error code
+ */
+extern int job_step_checkpoint_task_comp(checkpoint_task_comp_msg_t *ckpt_ptr,
+		uid_t uid, slurm_fd conn_fd)
+{
+	int rc = SLURM_SUCCESS;
+	struct job_record *job_ptr;
+	struct step_record *step_ptr;
+	slurm_msg_t resp_msg;
+	return_code_msg_t rc_msg;
+	
+	slurm_msg_t_init(&resp_msg);
+		
+	/* find the job */
+	job_ptr = find_job_record (ckpt_ptr->job_id);
+	if (job_ptr == NULL) {
+		rc = ESLURM_INVALID_JOB_ID;
+		goto reply;
+	}
+	if ((uid != job_ptr->user_id) && (uid != 0)) {
+		rc = ESLURM_ACCESS_DENIED;
+		goto reply;
+	}
+	if (job_ptr->job_state == JOB_PENDING) {
+		rc = ESLURM_JOB_PENDING;
+		goto reply;
+	} else if ((job_ptr->job_state != JOB_RUNNING)
+	&&         (job_ptr->job_state != JOB_SUSPENDED)) {
+		rc = ESLURM_ALREADY_DONE;
+		goto reply;
+	}
+ 
+	step_ptr = find_step_record(job_ptr, ckpt_ptr->step_id);
+	if (step_ptr == NULL) {
+		rc = ESLURM_INVALID_JOB_ID;
+		goto reply;
+	} else {
+		rc = checkpoint_task_comp((void *)step_ptr, 
+			ckpt_ptr->task_id, ckpt_ptr->begin_time, 
+			ckpt_ptr->error_code, ckpt_ptr->error_msg);
+		last_job_update = time(NULL);
+	}
+
+    reply:
+	rc_msg.return_code = rc;
+	resp_msg.msg_type  = RESPONSE_SLURM_RC;
+	resp_msg.data      = &rc_msg;
+	(void) slurm_send_node_msg(conn_fd, &resp_msg);
+	return rc;
+}
+
 /*
  * step_partial_comp - Note the completion of a job step on at least
  *	some of its nodes
@@ -1255,7 +1468,7 @@ extern int step_partial_comp(step_complete_msg_t *req, int *rem,
 		step_ptr->exit_code = req->step_rc;
 		if (max_rc)
 			*max_rc = step_ptr->exit_code;
-		jobacct_g_aggregate(step_ptr->jobacct, req->jobacct);
+		jobacct_gather_g_aggregate(step_ptr->jobacct, req->jobacct);
 		/* we don't want to delete the step record here since
 		   right after we delete this step again if we delete
 		   it here we won't find it when we try the second
@@ -1269,7 +1482,7 @@ extern int step_partial_comp(step_complete_msg_t *req, int *rem,
 		return EINVAL;
 	}
 
-	jobacct_g_aggregate(step_ptr->jobacct, req->jobacct);
+	jobacct_gather_g_aggregate(step_ptr->jobacct, req->jobacct);
 
 	if (step_ptr->exit_code == NO_VAL) {
 		/* initialize the node bitmap for exited nodes */
@@ -1435,12 +1648,10 @@ _suspend_job_step(struct job_record *job_ptr,
 	if ((job_ptr->suspend_time)
 	&&  (job_ptr->suspend_time > step_ptr->start_time)) {
 		step_ptr->pre_sus_time +=
-			difftime(now,
-			job_ptr->suspend_time);
+			difftime(now, job_ptr->suspend_time);
 	} else {
 		step_ptr->pre_sus_time +=
-			difftime(now,
-			step_ptr->start_time);
+			difftime(now, step_ptr->start_time);
 	}
 
 }
@@ -1460,6 +1671,34 @@ suspend_job_step(struct job_record *job_ptr)
 	list_iterator_destroy (step_iterator);
 }
 
+static void 
+_resume_job_step(struct job_record *job_ptr, 
+		struct step_record *step_ptr, time_t now)
+{
+	if ((job_ptr->suspend_time) &&
+	    (job_ptr->suspend_time < step_ptr->start_time)) {
+		step_ptr->tot_sus_time +=
+			difftime(now, step_ptr->start_time);
+	} else {
+		step_ptr->tot_sus_time +=
+			difftime(now, job_ptr->suspend_time);
+	}
+}
+
+/* Update time stamps for job step resume */
+extern void
+resume_job_step(struct job_record *job_ptr)
+{
+	time_t now = time(NULL);
+	ListIterator step_iterator;
+	struct step_record *step_ptr;
+
+	step_iterator = list_iterator_create (job_ptr->step_list);
+	while ((step_ptr = (struct step_record *) list_next (step_iterator))) {
+		_resume_job_step(job_ptr, step_ptr, now);
+	}
+	list_iterator_destroy (step_iterator);
+}
 
 
 /*
@@ -1473,6 +1712,9 @@ extern void dump_job_step_state(struct step_record *step_ptr, Buf buffer)
 	pack16(step_ptr->step_id, buffer);
 	pack16(step_ptr->cyclic_alloc, buffer);
 	pack16(step_ptr->port, buffer);
+	pack16(step_ptr->ckpt_interval, buffer);
+	pack16(step_ptr->mem_per_task, buffer);
+
 	pack32(step_ptr->exit_code, buffer);
 	if (step_ptr->exit_code != NO_VAL) {
 		pack_bit_fmt(step_ptr->exit_node_bitmap, buffer);
@@ -1482,9 +1724,13 @@ extern void dump_job_step_state(struct step_record *step_ptr, Buf buffer)
 
 	pack_time(step_ptr->start_time, buffer);
 	pack_time(step_ptr->pre_sus_time, buffer);
+	pack_time(step_ptr->tot_sus_time, buffer);
+	pack_time(step_ptr->ckpt_time, buffer);
+
 	packstr(step_ptr->host,  buffer);
 	packstr(step_ptr->name, buffer);
 	packstr(step_ptr->network, buffer);
+	packstr(step_ptr->ckpt_path, buffer);
 	pack16(step_ptr->batch_step, buffer);
 	if (!step_ptr->batch_step) {
 		pack_slurm_step_layout(step_ptr->step_layout, buffer);
@@ -1501,10 +1747,11 @@ extern void dump_job_step_state(struct step_record *step_ptr, Buf buffer)
 extern int load_step_state(struct job_record *job_ptr, Buf buffer)
 {
 	struct step_record *step_ptr = NULL;
-	uint16_t step_id, cyclic_alloc, name_len, port, batch_step, bit_cnt;
-	uint32_t exit_code;
-	time_t start_time, pre_sus_time;
-	char *host = NULL;
+	uint16_t step_id, cyclic_alloc, port, batch_step, bit_cnt;
+	uint16_t ckpt_interval, mem_per_task;
+	uint32_t exit_code, name_len;
+	time_t start_time, pre_sus_time, tot_sus_time, ckpt_time;
+	char *host = NULL, *ckpt_path = NULL;
 	char *name = NULL, *network = NULL, *bit_fmt = NULL;
 	switch_jobinfo_t switch_tmp = NULL;
 	check_jobinfo_t check_tmp = NULL;
@@ -1513,6 +1760,9 @@ extern int load_step_state(struct job_record *job_ptr, Buf buffer)
 	safe_unpack16(&step_id, buffer);
 	safe_unpack16(&cyclic_alloc, buffer);
 	safe_unpack16(&port, buffer);
+	safe_unpack16(&ckpt_interval, buffer);
+	safe_unpack16(&mem_per_task, buffer);
+
 	safe_unpack32(&exit_code, buffer);
 	if (exit_code != NO_VAL) {
 		safe_unpackstr_xmalloc(&bit_fmt, &name_len, buffer);
@@ -1521,9 +1771,13 @@ extern int load_step_state(struct job_record *job_ptr, Buf buffer)
 	
 	safe_unpack_time(&start_time, buffer);
 	safe_unpack_time(&pre_sus_time, buffer);
+	safe_unpack_time(&tot_sus_time, buffer);
+	safe_unpack_time(&ckpt_time, buffer);
+
 	safe_unpackstr_xmalloc(&host, &name_len, buffer);
 	safe_unpackstr_xmalloc(&name, &name_len, buffer);
 	safe_unpackstr_xmalloc(&network, &name_len, buffer);
+	safe_unpackstr_xmalloc(&ckpt_path, &name_len, buffer);
 	safe_unpack16(&batch_step, buffer);
 	if (!batch_step) {
 		if (unpack_slurm_step_layout(&step_layout, buffer))
@@ -1554,15 +1808,20 @@ extern int load_step_state(struct job_record *job_ptr, Buf buffer)
 	step_ptr->cyclic_alloc = cyclic_alloc;
 	step_ptr->name         = name;
 	step_ptr->network      = network;
+	step_ptr->ckpt_path    = ckpt_path;
 	step_ptr->port         = port;
+	step_ptr->ckpt_interval= ckpt_interval;
+	step_ptr->mem_per_task = mem_per_task;
 	step_ptr->host         = host;
 	step_ptr->batch_step   = batch_step;
 	host                   = NULL;  /* re-used, nothing left to free */
 	step_ptr->start_time   = start_time;
 	step_ptr->pre_sus_time = pre_sus_time;
+	step_ptr->tot_sus_time = tot_sus_time;
+	step_ptr->ckpt_time    = ckpt_time;
 
 	slurm_step_layout_destroy(step_ptr->step_layout);
-	step_ptr->step_layout = step_layout;
+	step_ptr->step_layout  = step_layout;
 	
 	step_ptr->switch_job   = switch_tmp;
 	step_ptr->check_job    = check_tmp;
@@ -1595,9 +1854,59 @@ extern int load_step_state(struct job_record *job_ptr, Buf buffer)
 	xfree(host);
 	xfree(name);
 	xfree(network);
+	xfree(ckpt_path);
 	xfree(bit_fmt);
 	if (switch_tmp)
 		switch_free_jobinfo(switch_tmp);
 	slurm_step_layout_destroy(step_layout);
 	return SLURM_FAILURE;
 }
+
+/* Perform periodic job step checkpoints (per user request) */
+extern void step_checkpoint(void)
+{
+	static int ckpt_run = -1;
+	time_t now = time(NULL), ckpt_due;
+	ListIterator job_iterator;
+	struct job_record *job_ptr;
+	ListIterator step_iterator;
+	struct step_record *step_ptr;
+	time_t event_time;
+	uint32_t error_code;
+	char *error_msg;
+
+	/* Exit if "checkpoint/none" is configured */
+	if (ckpt_run == -1) {
+		char *ckpt_type = slurm_get_checkpoint_type();
+		if (strcasecmp(ckpt_type, "checkpoint/none"))
+			ckpt_run = 1;
+		else
+			ckpt_run = 0;
+		xfree(ckpt_type);
+	}
+	if (ckpt_run == 0)
+		return;
+
+	job_iterator = list_iterator_create(job_list);
+	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
+		if (job_ptr->job_state != JOB_RUNNING)
+			continue;
+		step_iterator = list_iterator_create (job_ptr->step_list);
+		while ((step_ptr = (struct step_record *) 
+				list_next (step_iterator))) {
+			if (step_ptr->ckpt_interval == 0)
+				continue;
+			ckpt_due = step_ptr->ckpt_time +
+				(step_ptr->ckpt_interval * 60);
+			if (ckpt_due > now) 
+				continue;
+			step_ptr->ckpt_time = now;
+			last_job_update = now;
+			(void) checkpoint_op(CHECK_CREATE, 0, 
+				(void *)step_ptr, &event_time, 
+				&error_code, &error_msg);
+		}
+		list_iterator_destroy (step_iterator);
+	}
+	list_iterator_destroy(job_iterator);
+}
diff --git a/src/slurmctld/trigger_mgr.c b/src/slurmctld/trigger_mgr.c
index 6b4871e491e0358ff00273d71f8882eb6d2d0098..c1686129ac554e9f165bcb51aebef514a132d834 100644
--- a/src/slurmctld/trigger_mgr.c
+++ b/src/slurmctld/trigger_mgr.c
@@ -2,9 +2,10 @@
  *  trigger_mgr.c - Event trigger management
  *****************************************************************************
  *  Copyright (C) 2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -64,7 +65,7 @@
 #define MAX_PROG_TIME 300	/* maximum run time for program */
 
 /* Change TRIGGER_STATE_VERSION value when changing the state save format */
-#define TRIGGER_STATE_VERSION      "VER001"
+#define TRIGGER_STATE_VERSION      "VER002"
 
 /* TRIG_IS_JOB_FINI differs from IS_JOB_FINISHED by considering 
  * completing jobs as not really finished */
@@ -75,13 +76,15 @@ List trigger_list;
 uint32_t next_trigger_id = 1;
 static pthread_mutex_t trigger_mutex = PTHREAD_MUTEX_INITIALIZER;
 bitstr_t *trigger_down_nodes_bitmap = NULL;
+bitstr_t *trigger_drained_nodes_bitmap = NULL;
+bitstr_t *trigger_fail_nodes_bitmap = NULL;
 bitstr_t *trigger_up_nodes_bitmap   = NULL;
 static bool trigger_block_err = false;
 static bool trigger_node_reconfig = false;
 
 typedef struct trig_mgr_info {
 	uint32_t trig_id;	/* trigger ID */
-	uint8_t  res_type;	/* TRIGGER_RES_TYPE_* */
+	uint16_t res_type;	/* TRIGGER_RES_TYPE_* */
 	char *   res_id;	/* node name or job_id (string) */
 	bitstr_t *nodes_bitmap;	/* bitmap of requested nodes (if applicable) */
 	uint32_t job_id;	/* job ID (if applicable) */
@@ -103,8 +106,7 @@ void _trig_del(void *x) {
 	xfree(tmp);
 }
 
-#if _DEBUG
-static char *_res_type(uint8_t res_type)
+static char *_res_type(uint16_t res_type)
 {
 	if      (res_type == TRIGGER_RES_TYPE_JOB)
 		return "job";
@@ -120,6 +122,10 @@ static char *_trig_type(uint16_t trig_type)
 		return "up";
 	else if (trig_type == TRIGGER_TYPE_DOWN)
 		return "down";
+	else if (trig_type == TRIGGER_TYPE_DRAINED)
+		return "drained";
+	else if (trig_type == TRIGGER_TYPE_FAIL)
+		return "fail";
 	else if (trig_type == TRIGGER_TYPE_IDLE)
 		return "idle";
 	else if (trig_type == TRIGGER_TYPE_TIME)
@@ -134,6 +140,7 @@ static char *_trig_type(uint16_t trig_type)
 		return "unknown";
 }
 
+#if _DEBUG
 static int _trig_offset(uint16_t offset)
 {
 	static int rc;
@@ -170,6 +177,33 @@ static void _dump_trigger_msg(char *header, trigger_info_msg_t *msg)
 }
 #endif
 
+/* Validate trigger program */
+static bool _validate_trigger(trig_mgr_info_t *trig_in)
+{
+	struct stat buf;
+	int modes;
+
+	if (stat(trig_in->program, &buf) != 0) {
+		info("trigger program %s not found", trig_in->program);
+		return false;
+	}
+	if (!S_ISREG(buf.st_mode)) {
+		info("trigger program %s not a regular file", trig_in->program);
+		return false;
+	}
+	if (buf.st_uid == trig_in->user_id)
+		modes =  (buf.st_mode >> 6) & 07;
+	else if (buf.st_gid == trig_in->group_id)
+		modes =  (buf.st_mode >> 3) & 07;
+	else
+		modes = buf.st_mode  & 07;
+	if (modes & 01)
+		return true;
+
+	info("trigger program %s not executable", trig_in->program);
+	return false;
+}
+
 extern int trigger_clear(uid_t uid, trigger_info_msg_t *msg)
 {
 	int rc = ESRCH;
@@ -215,7 +249,7 @@ extern int trigger_clear(uid_t uid, trigger_info_msg_t *msg)
 			continue;
 		if (trig_test->state == 2)	/* wait for proc termination */
 			continue;
-		list_delete(trig_iter);
+		list_delete_item(trig_iter);
 		rc = SLURM_SUCCESS;
 	}
 	list_iterator_destroy(trig_iter);
@@ -288,8 +322,8 @@ extern int trigger_set(uid_t uid, gid_t gid, trigger_info_msg_t *msg)
 		 * launched. To prevent the launched program for an arbitrary 
 		 * user being executed as user SlurmUser, disable all other
 		 * users from setting triggers. */
-		info("Attemt to set trigger by uid %u", uid);
-		rc = EPERM;
+		info("Attempt to set trigger by uid %u != SlurmUser", uid);
+		rc = ESLURM_ACCESS_DENIED;
 		goto fini;
 	}
 
@@ -345,6 +379,13 @@ extern int trigger_set(uid_t uid, gid_t gid, trigger_info_msg_t *msg)
 		/* move don't copy "program" */
 		trig_add->program = msg->trigger_array[i].program;
 		msg->trigger_array[i].program = NULL;
+		if (!_validate_trigger(trig_add)) {
+			rc = ESLURM_ACCESS_DENIED;
+			xfree(trig_add->program);
+			xfree(trig_add->res_id);
+			xfree(trig_add);
+			continue;
+		}
 		list_append(trigger_list, trig_add);
 		schedule_trigger_save();
 	}
@@ -365,6 +406,28 @@ extern void trigger_node_down(struct node_record *node_ptr)
 	slurm_mutex_unlock(&trigger_mutex);
 }
 
+extern void trigger_node_drained(struct node_record *node_ptr)
+{
+        int inx = node_ptr - node_record_table_ptr;
+
+	slurm_mutex_lock(&trigger_mutex);
+	if (trigger_drained_nodes_bitmap == NULL)
+		trigger_drained_nodes_bitmap = bit_alloc(node_record_count);
+	bit_set(trigger_drained_nodes_bitmap, inx);
+	slurm_mutex_unlock(&trigger_mutex);
+}
+
+extern void trigger_node_failing(struct node_record *node_ptr)
+{
+	int inx = node_ptr - node_record_table_ptr;
+
+	slurm_mutex_lock(&trigger_mutex);
+	if (trigger_fail_nodes_bitmap == NULL)
+		trigger_fail_nodes_bitmap = bit_alloc(node_record_count);
+	bit_set(trigger_fail_nodes_bitmap, inx);
+	slurm_mutex_unlock(&trigger_mutex);
+}
+
 
 extern void trigger_node_up(struct node_record *node_ptr)
 {
@@ -394,7 +457,7 @@ extern void trigger_block_error(void)
 static void _dump_trigger_state(trig_mgr_info_t *trig_ptr, Buf buffer)
 {
 	pack32   (trig_ptr->trig_id,   buffer);
-	pack8    (trig_ptr->res_type,  buffer);
+	pack16   (trig_ptr->res_type,  buffer);
 	packstr  (trig_ptr->res_id,    buffer);
 	/* rebuild nodes_bitmap as needed from res_id */
 	/* rebuild job_id as needed from res_id */
@@ -410,11 +473,11 @@ static void _dump_trigger_state(trig_mgr_info_t *trig_ptr, Buf buffer)
 static int _load_trigger_state(Buf buffer)
 {
 	trig_mgr_info_t *trig_ptr;
-	uint16_t str_len;
+	uint32_t str_len;
 
 	trig_ptr = xmalloc(sizeof(trig_mgr_info_t));
 	safe_unpack32   (&trig_ptr->trig_id,   buffer);
-	safe_unpack8    (&trig_ptr->res_type,  buffer);
+	safe_unpack16   (&trig_ptr->res_type,  buffer);
 	safe_unpackstr_xmalloc(&trig_ptr->res_id, &str_len, buffer);
 	/* rebuild nodes_bitmap as needed from res_id */
 	/* rebuild job_id as needed from res_id */
@@ -550,7 +613,7 @@ extern int trigger_state_restore(void)
 	Buf buffer;
 	time_t buf_time;
 	char *ver_str = NULL;
-	uint16_t ver_str_len;
+	uint32_t ver_str_len;
 
 	/* read the file */
 	state_file = xstrdup(slurmctld_conf.state_save_location);
@@ -586,17 +649,8 @@ extern int trigger_state_restore(void)
 	unlock_state_files();
 
 	buffer = create_buf(data, data_size);
-	if (size_buf(buffer) >= sizeof(uint16_t) + 
-			strlen(TRIGGER_STATE_VERSION)) {
-	        char *ptr = get_buf_data(buffer);
-
-	        if (!memcmp(&ptr[sizeof(uint16_t)], TRIGGER_STATE_VERSION, 3)) {
-		        safe_unpackstr_xmalloc(&ver_str, &ver_str_len, buffer);
-		        debug3("Version string in trigger_state header is %s",
-			       ver_str);
-		}
-	}
-	if (ver_str && (strcmp(ver_str, TRIGGER_STATE_VERSION) != 0)) {
+	safe_unpackstr_xmalloc(&ver_str, &ver_str_len, buffer);
+	if (strcmp(ver_str, TRIGGER_STATE_VERSION) != 0) {
 		error("Can't recover trigger state, data version incompatable");
 		xfree(ver_str);
 		free_buf(buffer);
@@ -678,6 +732,21 @@ static void _trigger_job_event(trig_mgr_info_t *trig_in, time_t now)
 		}
 	}
 
+	if (trig_in->trig_type & TRIGGER_TYPE_FAIL) {
+		if (trigger_fail_nodes_bitmap
+		&&  bit_overlap(trig_in->job_ptr->node_bitmap, 
+				trigger_fail_nodes_bitmap)) {
+#if _DEBUG
+			info("trigger[%u] for job %u node fail",
+				trig_in->trig_id, trig_in->job_id);
+#endif
+			trig_in->state = 1;
+			trig_in->trig_time = now + 
+					(trig_in->trig_time - 0x8000);
+			return;
+		}
+	}
+
 	if (trig_in->trig_type & TRIGGER_TYPE_UP) {
 		if (trigger_up_nodes_bitmap
 		&&  bit_overlap(trig_in->job_ptr->node_bitmap, 
@@ -734,6 +803,62 @@ static void _trigger_node_event(trig_mgr_info_t *trig_in, time_t now)
 		}
 	}
 
+	if ((trig_in->trig_type & TRIGGER_TYPE_DRAINED)
+	&&   trigger_drained_nodes_bitmap
+	&&   (bit_ffs(trigger_drained_nodes_bitmap) != -1)) {
+		if (trig_in->nodes_bitmap == NULL) {	/* all nodes */
+			xfree(trig_in->res_id);
+			trig_in->res_id = bitmap2node_name(
+					trigger_drained_nodes_bitmap);
+			trig_in->state = 1;
+		} else if (bit_overlap(trig_in->nodes_bitmap, 
+					trigger_drained_nodes_bitmap)) {
+			bit_and(trig_in->nodes_bitmap, 
+					trigger_drained_nodes_bitmap);
+			xfree(trig_in->res_id);
+			trig_in->res_id = bitmap2node_name(
+					trig_in->nodes_bitmap);
+			trig_in->state = 1;
+		}
+		if (trig_in->state == 1) {
+			trig_in->trig_time = now + 
+					(trig_in->trig_time - 0x8000);
+#if _DEBUG
+			info("trigger[%u] for node %s drained",
+				trig_in->trig_id, trig_in->res_id);
+#endif
+			return;
+		}
+	}
+
+	if ((trig_in->trig_type & TRIGGER_TYPE_FAIL)
+	&&   trigger_fail_nodes_bitmap
+	&&   (bit_ffs(trigger_fail_nodes_bitmap) != -1)) {
+		if (trig_in->nodes_bitmap == NULL) {	/* all nodes */
+			xfree(trig_in->res_id);
+			trig_in->res_id = bitmap2node_name(
+					trigger_fail_nodes_bitmap);
+			trig_in->state = 1;
+		} else if (bit_overlap(trig_in->nodes_bitmap, 
+					trigger_fail_nodes_bitmap)) {
+			bit_and(trig_in->nodes_bitmap, 
+					trigger_fail_nodes_bitmap);
+			xfree(trig_in->res_id);
+			trig_in->res_id = bitmap2node_name(
+					trig_in->nodes_bitmap);
+			trig_in->state = 1;
+		}
+		if (trig_in->state == 1) {
+			trig_in->trig_time = now + 
+					(trig_in->trig_time - 0x8000);
+#if _DEBUG
+			info("trigger[%u] for node %s fail",
+				trig_in->trig_id, trig_in->res_id);
+#endif
+			return;
+		}
+	}
+
 	if (trig_in->trig_type & TRIGGER_TYPE_IDLE) {
 		/* We need to determine which (if any) of these 
 		 * nodes have been idle for at least the offset time */
@@ -830,6 +955,8 @@ static void _trigger_run_program(trig_mgr_info_t *trig_in)
 	gid_t gid;
 	pid_t child;
 
+	if (!_validate_trigger(trig_in))
+		return;
 	strncpy(program, trig_in->program, sizeof(program));
 	pname = strrchr(program, '/');
 	if (pname == NULL)
@@ -849,7 +976,11 @@ static void _trigger_run_program(trig_mgr_info_t *trig_in)
 		int i;
 		for (i=0; i<128; i++)
 			close(i);
+#ifdef SETPGRP_TWO_ARGS
+		setpgrp(0, 0);
+#else
 		setpgrp();
+#endif
 		setsid();
 		setuid(uid);
 		setgid(gid);
@@ -864,6 +995,8 @@ static void _clear_event_triggers(void)
 {
 	if (trigger_down_nodes_bitmap)
 		bit_nclear(trigger_down_nodes_bitmap, 0, (node_record_count-1));
+	if (trigger_drained_nodes_bitmap)
+		bit_nclear(trigger_drained_nodes_bitmap, 0, (node_record_count-1));
 	if (trigger_up_nodes_bitmap)
 		bit_nclear(trigger_up_nodes_bitmap,   0, (node_record_count-1));
 	trigger_node_reconfig = false;
@@ -878,6 +1011,8 @@ extern void trigger_process(void)
 	slurmctld_lock_t job_node_read_lock =
 		{ NO_LOCK, READ_LOCK, READ_LOCK, NO_LOCK };
 	bool state_change = false;
+	pid_t rc;
+	int prog_stat;
 
 	lock_slurmctld(job_node_read_lock);
 	slurm_mutex_lock(&trigger_mutex);
@@ -908,32 +1043,45 @@ extern void trigger_process(void)
 		} else if ((trig_in->state == 2) && 
 			   (difftime(now, trig_in->trig_time) > 
 					MAX_PROG_TIME)) {
-			bool purge;
-
 			if (trig_in->group_id != 0) {
-				pid_t rc;
-
 				killpg(trig_in->group_id, SIGKILL);
-				rc = waitpid(trig_in->group_id, NULL, WNOHANG);
-				if ((rc == trig_in->group_id)
-				||  ((rc == -1) && (errno == ECHILD)))
-					purge = true;
-				else
-					purge = false;
-			} else	/* No PID to wait for */
-				purge = true;
-
-			if (purge) {
+				rc = waitpid(trig_in->group_id, &prog_stat, 
+					     WNOHANG);
+				if ((rc > 0) && prog_stat) {
+					info("trigger uid=%u type=%s:%s "
+					     "exit=%u:%u",
+					     trig_in->user_id,
+					     _res_type(trig_in->res_type),
+					     _trig_type(trig_in->trig_type),
+					     WIFEXITED(prog_stat), 
+					     WTERMSIG(prog_stat));
+				}
+				if ((rc == trig_in->group_id) ||
+				    ((rc == -1) && (errno == ECHILD)))
+					trig_in->group_id = 0;
+			}
+
+			if (trig_in->group_id == 0) {
 #if _DEBUG
 				info("purging trigger[%u]", trig_in->trig_id);
 #endif
-				list_delete(trig_iter);
+				list_delete_item(trig_iter);
 				state_change = true;
 			}
 		} else if (trig_in->state == 2) {
 			/* Elimiate zombie processes right away.
 			 * Purge trigger entry above MAX_PROG_TIME later */
-			waitpid(trig_in->group_id, NULL, WNOHANG);
+			rc = waitpid(trig_in->group_id, &prog_stat, WNOHANG);
+			if ((rc > 0) && prog_stat) {
+				info("trigger uid=%u type=%s:%s exit=%u:%u",
+				     trig_in->user_id,
+				     _res_type(trig_in->res_type),
+				     _trig_type(trig_in->trig_type),
+				     WIFEXITED(prog_stat), WTERMSIG(prog_stat));
+			}
+			if ((rc == trig_in->group_id) ||
+			    ((rc == -1) && (errno == ECHILD)))
+				trig_in->group_id = 0;
 		}
 	}
 	list_iterator_destroy(trig_iter);
@@ -952,5 +1100,7 @@ extern void trigger_fini(void)
 		trigger_list = NULL;
 	}
 	FREE_NULL_BITMAP(trigger_down_nodes_bitmap);
+	FREE_NULL_BITMAP(trigger_drained_nodes_bitmap);
+	FREE_NULL_BITMAP(trigger_fail_nodes_bitmap);
 	FREE_NULL_BITMAP(trigger_up_nodes_bitmap);
 }
diff --git a/src/slurmctld/trigger_mgr.h b/src/slurmctld/trigger_mgr.h
index 80d922bdead0f016dfc1c07f55c6b7613f3d5841..69986d14346879ff788e655b88f4217014f6f5ba 100644
--- a/src/slurmctld/trigger_mgr.h
+++ b/src/slurmctld/trigger_mgr.h
@@ -2,9 +2,10 @@
  *  trigger_mgr.h - header to manager event triggers
  *****************************************************************************
  *  Copyright (C) 2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -51,6 +52,8 @@ extern int trigger_set(uid_t uid, gid_t gid, trigger_info_msg_t *msg);
 /* Note the some event has occured and flag triggers as needed */
 extern void trigger_block_error(void);
 extern void trigger_node_down(struct node_record *node_ptr);
+extern void trigger_node_drained(struct node_record *node_ptr);
+extern void trigger_node_failing(struct node_record *node_ptr);
 extern void trigger_node_up(struct node_record *node_ptr);
 extern void trigger_reconfig(void);
 
diff --git a/src/slurmd/Makefile.in b/src/slurmd/Makefile.in
index 4a9b859e7e742465617215ad104b04d307e0af63..408c46fd0f351a9d7520c852db7e909abf18bd02 100644
--- a/src/slurmd/Makefile.in
+++ b/src/slurmd/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -99,6 +101,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -112,10 +115,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -135,7 +141,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -146,6 +155,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -161,6 +172,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -176,6 +188,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -347,8 +360,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -373,8 +386,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -384,13 +397,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/slurmd/common/proctrack.c b/src/slurmd/common/proctrack.c
index 43b317a421b28fb68599e9e629a393bfff1dec2b..651af3b859f3a16eb8cecc41285ee14fe3515431 100644
--- a/src/slurmd/common/proctrack.c
+++ b/src/slurmd/common/proctrack.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/common/proctrack.h b/src/slurmd/common/proctrack.h
index 604b4e1c4d8fb33d92f904aa5aedab8646a0a387..35325770e7bc9b1e3854e9bdea40299e6c2faded 100644
--- a/src/slurmd/common/proctrack.h
+++ b/src/slurmd/common/proctrack.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/common/reverse_tree.h b/src/slurmd/common/reverse_tree.h
index 5020cd14a6e768daa6cef882dcd27f5d60e2a5c3..a406db9a3b532277351f1934dbd982a139c64b89 100644
--- a/src/slurmd/common/reverse_tree.h
+++ b/src/slurmd/common/reverse_tree.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/common/run_script.c b/src/slurmd/common/run_script.c
index e03e1d3db2d048cc1ed5ca8b8d70ac31964f1a75..278d6964e84eda531b26a7c1920b63a576b4a298 100644
--- a/src/slurmd/common/run_script.c
+++ b/src/slurmd/common/run_script.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -72,7 +72,11 @@ run_script(const char *name, const char *path, uint32_t jobid,
 	if (path == NULL || path[0] == '\0')
 		return 0;
 
-	debug("[job %u] attempting to run %s [%s]", jobid, name, path);
+	if (jobid) {
+		debug("[job %u] attempting to run %s [%s]", 
+			jobid, name, path);
+	} else
+		debug("attempting to run %s [%s]", name, path);
 
 	if (access(path, R_OK | X_OK) < 0) {
 		debug("Not running %s [%s]: %m", name, path);
diff --git a/src/slurmd/common/run_script.h b/src/slurmd/common/run_script.h
index a83b40898dc6d0b6080b29370ae663c1de657133..837d4dce6200f859c666cc736144645418ab3a33 100644
--- a/src/slurmd/common/run_script.h
+++ b/src/slurmd/common/run_script.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/common/setproctitle.c b/src/slurmd/common/setproctitle.c
index b10e2bd67da7b917ff1a006954c40053a9c74ebb..646e9e5586018ccba1ccdceb1c18016f8d66f371 100644
--- a/src/slurmd/common/setproctitle.c
+++ b/src/slurmd/common/setproctitle.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/common/setproctitle.c - argv manipulation 
- * $Id: setproctitle.c 10574 2006-12-15 23:38:29Z jette $
+ * $Id: setproctitle.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/common/setproctitle.h b/src/slurmd/common/setproctitle.h
index 625ecc6a9ee01137850e9af673349c87037596ed..30caef88696d148288f7f4353be91e0d1f3d8ea4 100644
--- a/src/slurmd/common/setproctitle.h
+++ b/src/slurmd/common/setproctitle.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/common/setproctitle.h - Emulation of BSD setproctitle()
- * $Id: setproctitle.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: setproctitle.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/common/slurmstepd_init.c b/src/slurmd/common/slurmstepd_init.c
index 903520a8d34f337bca198e1a27ef359b5a92dab8..81cfd21beac02fbd8ccfd34cbebec3b2427fcd03 100644
--- a/src/slurmd/common/slurmstepd_init.c
+++ b/src/slurmd/common/slurmstepd_init.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -49,7 +49,7 @@ extern void pack_slurmd_conf_lite(slurmd_conf_t *conf, Buf buffer)
 	packstr(conf->logfile, buffer);
 	packstr(conf->task_prolog, buffer);
 	packstr(conf->task_epilog, buffer);
-	pack16(conf->job_acct_freq, buffer);
+	pack16(conf->job_acct_gather_freq, buffer);
 	pack16(conf->propagate_prio, buffer);
 	pack32(conf->debug_level, buffer);
 	pack32(conf->daemonize, buffer);
@@ -60,18 +60,18 @@ extern void pack_slurmd_conf_lite(slurmd_conf_t *conf, Buf buffer)
 
 extern int unpack_slurmd_conf_lite_no_alloc(slurmd_conf_t *conf, Buf buffer)
 {
-	uint16_t uint16_tmp;
 	uint32_t uint32_tmp;
-	safe_unpackstr_xmalloc(&conf->hostname, &uint16_tmp, buffer);
+
+	safe_unpackstr_xmalloc(&conf->hostname, &uint32_tmp, buffer);
 	safe_unpack16(&conf->sockets, buffer);
 	safe_unpack16(&conf->cores, buffer);
 	safe_unpack16(&conf->threads, buffer);
-	safe_unpackstr_xmalloc(&conf->spooldir, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&conf->node_name, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&conf->logfile, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&conf->task_prolog, &uint16_tmp, buffer);
-	safe_unpackstr_xmalloc(&conf->task_epilog, &uint16_tmp, buffer);
-	safe_unpack16(&conf->job_acct_freq, buffer);
+	safe_unpackstr_xmalloc(&conf->spooldir,    &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&conf->node_name,   &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&conf->logfile,     &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&conf->task_prolog, &uint32_tmp, buffer);
+	safe_unpackstr_xmalloc(&conf->task_epilog, &uint32_tmp, buffer);
+	safe_unpack16(&conf->job_acct_gather_freq, buffer);
 	safe_unpack16(&conf->propagate_prio, buffer);
 	safe_unpack32(&uint32_tmp, buffer);
 	conf->debug_level = uint32_tmp;
diff --git a/src/slurmd/common/slurmstepd_init.h b/src/slurmd/common/slurmstepd_init.h
index 47914187c15f5fb0b37d4f267220d0cb2e138ba8..0499d17a0f26ebe47ac98456e010503ba4456818 100644
--- a/src/slurmd/common/slurmstepd_init.h
+++ b/src/slurmd/common/slurmstepd_init.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/common/task_plugin.c b/src/slurmd/common/task_plugin.c
index e148fdfc4fb11d0c0b6ca00175809ee91da0147a..1882a9b0555a1044a77eff929214fbcdb7330bc2 100644
--- a/src/slurmd/common/task_plugin.c
+++ b/src/slurmd/common/task_plugin.c
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  task_plugin.h - task launch plugin stub.
  *****************************************************************************
- *  Copyright (C) 2005 The Regents of the University of California.
+ *  Copyright (C) 2005-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -46,13 +47,19 @@
 #include "src/slurmd/slurmstepd/slurmstepd_job.h"
 
 typedef struct slurmd_task_ops {
-	int		(*slurmd_launch_request)	( uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id);
-	int		(*slurmd_reserve_resources)	( uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id );
-	int		(*slurmd_release_resources)	( uint32_t job_id);
-
-	int		(*pre_setuid)		( slurmd_job_t *job );
-	int		(*pre_launch)		( slurmd_job_t *job );
-	int		(*post_term)		( slurmd_job_t *job );
+	int	(*slurmd_launch_request)	(uint32_t job_id, 
+						 launch_tasks_request_msg_t *req,
+						 uint32_t node_id);
+	int	(*slurmd_reserve_resources)	(uint32_t job_id, 
+						 launch_tasks_request_msg_t *req, 
+						 uint32_t node_id);
+	int	(*slurmd_suspend_job)		(uint32_t job_id);
+	int	(*slurmd_resume_job)		(uint32_t job_id);
+	int	(*slurmd_release_resources)	(uint32_t job_id);
+
+	int	(*pre_setuid)			(slurmd_job_t *job);
+	int	(*pre_launch)			(slurmd_job_t *job);
+	int	(*post_term)			(slurmd_job_t *job);
 } slurmd_task_ops_t;
 
 
@@ -68,7 +75,7 @@ static pthread_mutex_t		g_task_context_lock = PTHREAD_MUTEX_INITIALIZER;
 
 
 static slurmd_task_ops_t *
-_slurmd_task_get_ops( slurmd_task_context_t *c )
+_slurmd_task_get_ops(slurmd_task_context_t *c)
 {
 	/*
 	 * Must be synchronized with slurmd_task_ops_t above.
@@ -76,6 +83,8 @@ _slurmd_task_get_ops( slurmd_task_context_t *c )
 	static const char *syms[] = {
 		"task_slurmd_launch_request",
 		"task_slurmd_reserve_resources",
+		"task_slurmd_suspend_job",
+		"task_slurmd_resume_job",
 		"task_slurmd_release_resources",
 		"task_pre_setuid",
 		"task_pre_launch",
@@ -118,7 +127,7 @@ _slurmd_task_get_ops( slurmd_task_context_t *c )
 
 
 static slurmd_task_context_t *
-_slurmd_task_context_create( const char *task_plugin_type )
+_slurmd_task_context_create(const char *task_plugin_type)
 {
 	slurmd_task_context_t *c;
 
@@ -137,7 +146,7 @@ _slurmd_task_context_create( const char *task_plugin_type )
 
 
 static int
-_slurmd_task_context_destroy( slurmd_task_context_t *c )
+_slurmd_task_context_destroy(slurmd_task_context_t *c)
 {
 	/*
 	 * Must check return code here because plugins might still
@@ -161,7 +170,7 @@ _slurmd_task_context_destroy( slurmd_task_context_t *c )
  *
  * RET - slurm error code
  */
-extern int slurmd_task_init( void )
+extern int slurmd_task_init(void)
 {
 	int retval = SLURM_SUCCESS;
 	char *task_plugin_type = NULL;
@@ -198,7 +207,7 @@ extern int slurmd_task_init( void )
  *
  * RET - slurm error code
  */
-extern int slurmd_task_fini( void )
+extern int slurmd_task_fini(void)
 {
 	int rc;
 
@@ -215,9 +224,11 @@ extern int slurmd_task_fini( void )
  *
  * RET - slurm error code
  */
-extern int slurmd_launch_request( uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id)
+extern int slurmd_launch_request(uint32_t job_id, 
+				 launch_tasks_request_msg_t *req, 
+				 uint32_t node_id)
 {
-	if ( slurmd_task_init() )
+	if (slurmd_task_init())
 		return SLURM_ERROR;
 
 	return (*(g_task_context->ops.slurmd_launch_request))(job_id, req, node_id);
@@ -228,22 +239,50 @@ extern int slurmd_launch_request( uint32_t job_id, launch_tasks_request_msg_t *r
  *
  * RET - slurm error code
  */
-extern int slurmd_reserve_resources(  uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id )
+extern int slurmd_reserve_resources(uint32_t job_id, 
+				    launch_tasks_request_msg_t *req, 
+				    uint32_t node_id )
 {
-	if ( slurmd_task_init() )
+	if (slurmd_task_init())
 		return SLURM_ERROR;
 
 	return (*(g_task_context->ops.slurmd_reserve_resources))(job_id, req, node_id);
 }
 
+/*
+ * Slurmd is suspending a job.
+ *
+ * RET - slurm error code
+ */
+extern int slurmd_suspend_job(uint32_t job_id)
+{
+	if (slurmd_task_init())
+		return SLURM_ERROR;
+
+	return (*(g_task_context->ops.slurmd_suspend_job))(job_id);
+}
+
+/*
+ * Slurmd is resuming a previously suspended job.
+ *
+ * RET - slurm error code
+ */
+extern int slurmd_resume_job(uint32_t job_id)
+{
+	if (slurmd_task_init())
+		return SLURM_ERROR;
+
+	return (*(g_task_context->ops.slurmd_resume_job))(job_id);
+}
+
 /*
  * Slurmd is releasing resources for the task.
  *
  * RET - slurm error code
  */
-extern int slurmd_release_resources( uint32_t job_id )
+extern int slurmd_release_resources(uint32_t job_id)
 {
-	if ( slurmd_task_init() )
+	if (slurmd_task_init())
 		return SLURM_ERROR;
 
 	return (*(g_task_context->ops.slurmd_release_resources))(job_id);
@@ -255,9 +294,9 @@ extern int slurmd_release_resources( uint32_t job_id )
  *
  * RET - slurm error code
  */
-extern int pre_setuid( slurmd_job_t *job )
+extern int pre_setuid(slurmd_job_t *job)
 {
-	if ( slurmd_task_init() )
+	if (slurmd_task_init())
 		return SLURM_ERROR;
 
 	return (*(g_task_context->ops.pre_setuid))(job);
@@ -268,9 +307,9 @@ extern int pre_setuid( slurmd_job_t *job )
  *
  * RET - slurm error code
  */
-extern int pre_launch( slurmd_job_t *job )
+extern int pre_launch(slurmd_job_t *job)
 {
-	if ( slurmd_task_init() )
+	if (slurmd_task_init())
 		return SLURM_ERROR;
 
 	return (*(g_task_context->ops.pre_launch))(job);
@@ -281,9 +320,9 @@ extern int pre_launch( slurmd_job_t *job )
  *
  * RET - slurm error code
  */
-extern int post_term( slurmd_job_t *job )
+extern int post_term(slurmd_job_t *job)
 {
-	if ( slurmd_task_init() )
+	if (slurmd_task_init())
 		return SLURM_ERROR;
 
 	return (*(g_task_context->ops.post_term))(job);
diff --git a/src/slurmd/common/task_plugin.h b/src/slurmd/common/task_plugin.h
index 6e566a1c2141dba04c7b404410af525262ea8e9e..121876569de2e577f7b4507ec9fd0ce4b82e6529 100644
--- a/src/slurmd/common/task_plugin.h
+++ b/src/slurmd/common/task_plugin.h
@@ -1,10 +1,11 @@
 /*****************************************************************************\
  *  task_plugin.h - Define plugin functions for task pre_launch and post_term.
  *****************************************************************************
- *  Copyright (C) 2005 The Regents of the University of California.
+ *  Copyright (C) 2005-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -65,21 +66,39 @@ extern int slurmd_task_fini(void);
  *
  * RET - slurm error code
  */
-extern int slurmd_launch_request( uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id );
+extern int slurmd_launch_request(uint32_t job_id, 
+				 launch_tasks_request_msg_t *req, 
+				 uint32_t node_id );
 
 /*
  * Slurmd is reserving resources for the task.
  *
  * RET - slurm error code
  */
-extern int slurmd_reserve_resources( uint32_t job_id, launch_tasks_request_msg_t *req, uint32_t node_id );
+extern int slurmd_reserve_resources(uint32_t job_id, 
+				    launch_tasks_request_msg_t *req, 
+				    uint32_t node_id );
+
+/*
+ * Slurmd is suspending a job.
+ *
+ * RET - slurm error code
+ */
+extern int slurmd_suspend_job(uint32_t job_id);
+
+/*
+ * Slurmd is resuming a previously suspended job.
+ *
+ * RET - slurm error code
+ */
+extern int slurmd_resume_job(uint32_t job_id);
 
 /*
  * Slurmd is releasing resources for the task.
  *
  * RET - slurm error code
  */
-extern int slurmd_release_resources( uint32_t job_id );
+extern int slurmd_release_resources(uint32_t job_id);
 
 /*
  * Note that a task launch is about to occur.
diff --git a/src/slurmd/slurmd/Makefile.am b/src/slurmd/slurmd/Makefile.am
index 6b0e7ba4d09246c47bc49b6b7e810641af01a53a..ec4cebd4684813a85c4c13c89c9a6f1d46b6653a 100644
--- a/src/slurmd/slurmd/Makefile.am
+++ b/src/slurmd/slurmd/Makefile.am
@@ -7,13 +7,13 @@ sbin_PROGRAMS = slurmd
 noinst_PROGRAMS = slurmd.test
 
 CPPFLAGS =  -DLIBSLURM_SO=\"$(libdir)/libslurm.so\"
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS) 
+INCLUDES = -I$(top_srcdir)
 
 slurmd_LDADD = 					   \
-        $(top_builddir)/src/common/libcommon.la    \
 	$(top_builddir)/src/common/libdaemonize.la \
 	$(top_builddir)/src/common/libeio.la       \
-	$(PLPA_LIBS) $(SSL_LIBS) 
+	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(PLPA_LIBS) 
 
 slurmd_test_LDADD = $(slurmd_LDADD)
 
@@ -47,9 +47,9 @@ slurmd_test_SOURCES = \
 if HAVE_AIX
 # We need to set maxdata back to 0 because this effects the "max memory size"
 # ulimit, and the ulimit is inherited by child processes.
-slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS) -Wl,-bmaxdata:0x0
+slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) -Wl,-bmaxdata:0x0 
 else
-slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 endif
 
 slurmd_test_LDFLAGS = $(slurmd_LDFLAGS)
diff --git a/src/slurmd/slurmd/Makefile.in b/src/slurmd/slurmd/Makefile.in
index 034679356c5b110b2734011ddddf48eb1fed1f6e..d92d8a3944f93bb27f00b91abdb055302541c6b9 100644
--- a/src/slurmd/slurmd/Makefile.in
+++ b/src/slurmd/slurmd/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -47,6 +47,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -78,24 +80,22 @@ am__objects_1 = slurmd.$(OBJEXT) req.$(OBJEXT) get_mach_stat.$(OBJEXT) \
 am_slurmd_OBJECTS = $(am__objects_1) config.$(OBJEXT)
 slurmd_OBJECTS = $(am_slurmd_OBJECTS)
 am__DEPENDENCIES_1 =
-slurmd_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
-	$(top_builddir)/src/common/libdaemonize.la \
-	$(top_builddir)/src/common/libeio.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+slurmd_DEPENDENCIES = $(top_builddir)/src/common/libdaemonize.la \
+	$(top_builddir)/src/common/libeio.la \
+	$(top_builddir)/src/common/libcommon.o $(am__DEPENDENCIES_1)
 slurmd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(slurmd_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_slurmd_test_OBJECTS = $(am__objects_1) testconfig.$(OBJEXT)
 slurmd_test_OBJECTS = $(am_slurmd_test_OBJECTS)
-am__DEPENDENCIES_2 = $(top_builddir)/src/common/libcommon.la \
-	$(top_builddir)/src/common/libdaemonize.la \
-	$(top_builddir)/src/common/libeio.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+am__DEPENDENCIES_2 = $(top_builddir)/src/common/libdaemonize.la \
+	$(top_builddir)/src/common/libeio.la \
+	$(top_builddir)/src/common/libcommon.o $(am__DEPENDENCIES_1)
 slurmd_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
 slurmd_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(slurmd_test_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -135,6 +135,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -148,10 +149,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -171,7 +175,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -182,6 +189,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -197,6 +206,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -212,6 +222,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -269,12 +280,12 @@ target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS) 
+INCLUDES = -I$(top_srcdir)
 slurmd_LDADD = \
-        $(top_builddir)/src/common/libcommon.la    \
 	$(top_builddir)/src/common/libdaemonize.la \
 	$(top_builddir)/src/common/libeio.la       \
-	$(PLPA_LIBS) $(SSL_LIBS) 
+	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(PLPA_LIBS) 
 
 slurmd_test_LDADD = $(slurmd_LDADD)
 SLURMD_SOURCES = \
@@ -304,11 +315,11 @@ slurmd_test_SOURCES = \
     $(SLURMD_SOURCES) \
 	testconfig.c
 
-@HAVE_AIX_FALSE@slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+@HAVE_AIX_FALSE@slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 
 # We need to set maxdata back to 0 because this effects the "max memory size"
 # ulimit, and the ulimit is inherited by child processes.
-@HAVE_AIX_TRUE@slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS) -Wl,-bmaxdata:0x0
+@HAVE_AIX_TRUE@slurmd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) -Wl,-bmaxdata:0x0 
 slurmd_test_LDFLAGS = $(slurmd_LDFLAGS)
 all: all-am
 
@@ -359,8 +370,8 @@ install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -507,8 +518,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -520,8 +531,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -531,13 +542,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/slurmd/slurmd/get_mach_stat.c b/src/slurmd/slurmd/get_mach_stat.c
index 526b02400d7e2da5920abfa039d5d2ea807c4b13..a082be7a2ed2c0dc029856ef264a0b94833a91b1 100644
--- a/src/slurmd/slurmd/get_mach_stat.c
+++ b/src/slurmd/slurmd/get_mach_stat.c
@@ -10,7 +10,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmd/get_mach_stat.h b/src/slurmd/slurmd/get_mach_stat.h
index 46482e34559cd47ec7f1f1b03e833b21d9992f17..586c7e5345a4a3e9dec80385395cf452de596764 100644
--- a/src/slurmd/slurmd/get_mach_stat.h
+++ b/src/slurmd/slurmd/get_mach_stat.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmd/read_proc.c b/src/slurmd/slurmd/read_proc.c
index 5ed4ca0a16a11ad9e4c5062691b13421b2a65461..a0169fef59c633a6bb1bf94642064f88479aa20d 100644
--- a/src/slurmd/slurmd/read_proc.c
+++ b/src/slurmd/slurmd/read_proc.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -77,7 +77,7 @@ struct sess_record *session_ptr;
 int dump_proc(int uid, int sid);
 void init_proc(void);
 int parse_proc_stat(char* proc_stat, int *session, 
-		long unsigned *time, long *resident_set_size);
+		    unsigned long *time, long *resident_set_size);
 int read_proc();
 
 #if DEBUG_MODULE
@@ -178,7 +178,7 @@ init_proc (void)
  * RET - zero or errno code
  */
 int 
-parse_proc_stat(char* proc_stat, int *session, long unsigned *time, 
+parse_proc_stat(char* proc_stat, int *session, unsigned long *time, 
 		long *resident_set_size) {
 	int pid, ppid, pgrp, tty, tpgid;
 	char cmd[16], state[1];
@@ -239,7 +239,7 @@ read_proc()
 	struct stat buffer;
 	int uid, session;
 	long resident_set_size;
-	long unsigned time;
+	unsigned long time;
 	struct sess_record *s_ptr, *sess_free;
 
 	/* Initialization */
diff --git a/src/slurmd/slurmd/req.c b/src/slurmd/slurmd/req.c
index 84242acf6716529e93f51741fe18ae71ac8b5cd7..bab35a4a6df7f9454b4694f9e739260ebb9d58b5 100644
--- a/src/slurmd/slurmd/req.c
+++ b/src/slurmd/slurmd/req.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/slurmd/slurmd/req.c - slurmd request handling
- *  $Id: req.c 13326 2008-02-21 20:37:56Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,12 +56,13 @@
 #include <grp.h>
 
 #include "src/common/hostlist.h"
+#include "src/common/jobacct_common.h"
 #include "src/common/log.h"
 #include "src/common/macros.h"
 #include "src/common/node_select.h"
 #include "src/common/slurm_auth.h"
 #include "src/common/slurm_cred.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobacct_gather.h"
 #include "src/common/slurm_protocol_defs.h"
 #include "src/common/slurm_protocol_api.h"
 #include "src/common/slurm_protocol_interface.h"
@@ -93,18 +94,26 @@ typedef struct {
 	gid_t *gids;
 } gids_t;
 
+typedef struct {
+	uint32_t job_id;
+	uint32_t job_mem;
+} job_mem_limits_t;
+
 static int  _abort_job(uint32_t job_id);
 static int  _abort_step(uint32_t job_id, uint32_t step_id);
 static char ** _build_env(uint32_t jobid, uid_t uid, char *bg_part_id);
 static void _delay_rpc(int host_inx, int host_cnt, int usec_per_rpc);
 static void _destroy_env(char **env);
 static bool _slurm_authorized_user(uid_t uid);
+static void _job_limits_free(void *x);
+static int  _job_limits_match(void *x, void *key);
 static bool _job_still_running(uint32_t job_id);
 static int  _kill_all_active_steps(uint32_t jobid, int sig, bool batch);
 static int  _terminate_all_steps(uint32_t jobid, bool batch);
 static void _rpc_launch_tasks(slurm_msg_t *);
 static void _rpc_batch_job(slurm_msg_t *);
 static void _rpc_signal_tasks(slurm_msg_t *);
+static void _rpc_checkpoint_tasks(slurm_msg_t *);
 static void _rpc_terminate_tasks(slurm_msg_t *);
 static void _rpc_timelimit(slurm_msg_t *);
 static void _rpc_reattach_tasks(slurm_msg_t *);
@@ -117,6 +126,7 @@ static void _rpc_reconfig(slurm_msg_t *msg);
 static void _rpc_pid2jid(slurm_msg_t *msg);
 static int  _rpc_file_bcast(slurm_msg_t *msg);
 static int  _rpc_ping(slurm_msg_t *);
+static int  _rpc_health_check(slurm_msg_t *);
 static int  _rpc_step_complete(slurm_msg_t *msg);
 static int  _rpc_stat_jobacct(slurm_msg_t *msg);
 static int  _rpc_daemon_status(slurm_msg_t *msg);
@@ -144,6 +154,18 @@ static pthread_mutex_t launch_mutex = PTHREAD_MUTEX_INITIALIZER;
 static time_t booted = 0;
 static time_t last_slurmctld_msg = 0;
 
+static pthread_mutex_t job_limits_mutex = PTHREAD_MUTEX_INITIALIZER;
+static List job_limits_list = NULL;
+static bool job_limits_loaded = false;
+
+/* NUM_PARALLEL_SUSPEND controls the number of jobs suspended/resumed
+ * at one time as well as the number of jobsteps per job that can be
+ * suspended at one time */
+#define NUM_PARALLEL_SUSPEND 8
+static pthread_mutex_t suspend_mutex = PTHREAD_MUTEX_INITIALIZER;
+static uint32_t job_suspend_array[NUM_PARALLEL_SUSPEND];
+static int job_suspend_size = 0;
+
 void
 slurmd_req(slurm_msg_t *msg)
 {
@@ -156,6 +178,13 @@ slurmd_req(slurm_msg_t *msg)
 			list_destroy(waiters);
 			waiters = NULL;
 		}
+		slurm_mutex_lock(&job_limits_mutex);
+		if (job_limits_list) {
+			list_destroy(job_limits_list);
+			job_limits_list = NULL;
+			job_limits_loaded = false;
+		}
+		slurm_mutex_unlock(&job_limits_mutex);
 		return;
 	}
 
@@ -180,6 +209,11 @@ slurmd_req(slurm_msg_t *msg)
 		_rpc_signal_tasks(msg);
 		slurm_free_kill_tasks_msg(msg->data);
 		break;
+	case REQUEST_CHECKPOINT_TASKS:
+		debug2("Processing RPC: REQUEST_CHECKPOINT_TASKS");
+		_rpc_checkpoint_tasks(msg);
+		slurm_free_checkpoint_tasks_msg(msg->data);
+		break;
 	case REQUEST_TERMINATE_TASKS:
 		debug2("Processing RPC: REQUEST_TERMINATE_TASKS");
 		_rpc_terminate_tasks(msg);
@@ -240,6 +274,11 @@ slurmd_req(slurm_msg_t *msg)
 		last_slurmctld_msg = time(NULL);
 		/* No body to free */
 		break;
+	case REQUEST_HEALTH_CHECK:
+		_rpc_health_check(msg);
+		last_slurmctld_msg = time(NULL);
+		/* No body to free */
+		break;
 	case REQUEST_JOB_ID:
 		_rpc_pid2jid(msg);
 		slurm_free_job_id_request_msg(msg->data);
@@ -561,22 +600,21 @@ _forkexec_slurmstepd(slurmd_step_type_t type, void *req,
 /*
  * The job(step) credential is the only place to get a definitive
  * list of the nodes allocated to a job step.  We need to return
- * a hostset_t of the nodes.
- *
- * FIXME - Rewrite this to only take a slurm_cred_t and only return a
- *         slurm_cred_arg_t.  The other parameters, jobid, stepid, etc.
- *         should be checked one caller layer higher.
+ * a hostset_t of the nodes. Validate the incoming RPC, updating 
+ * job_mem and task_mem as needed.
  */
 static int
-_check_job_credential(slurm_cred_t cred, uint32_t jobid, 
-		      uint32_t stepid, uid_t uid, int tasks_to_launch,
-		      hostset_t *step_hset)
+_check_job_credential(launch_tasks_request_msg_t *req, uid_t uid,
+		      int tasks_to_launch, hostset_t *step_hset)
 {
 	slurm_cred_arg_t arg;
 	hostset_t        hset    = NULL;
 	bool             user_ok = _slurm_authorized_user(uid); 
 	int              host_index = -1;
 	int              rc;
+	slurm_cred_t     cred = req->cred;
+	uint32_t         jobid = req->job_id;
+	uint32_t         stepid = req->job_step_id;
 
 	/*
 	 * First call slurm_cred_verify() so that all valid
@@ -591,6 +629,11 @@ _check_job_credential(slurm_cred_t cred, uint32_t jobid,
 		}
 	}
 
+	/* Overwrite any memory limits in the RPC with 
+	 * contents of the credential */
+	req->job_mem  = arg.job_mem;
+	req->task_mem = arg.task_mem;
+
 	/*
 	 * If uid is the slurm user id or root, do not bother
 	 * performing validity check of the credential
@@ -689,20 +732,19 @@ _rpc_launch_tasks(slurm_msg_t *msg)
 	char     host[MAXHOSTNAMELEN];
 	uid_t    req_uid;
 	launch_tasks_request_msg_t *req = msg->data;
-	uint32_t jobid  = req->job_id;
-	uint32_t stepid = req->job_step_id;
 	bool     super_user = false;
 	bool     first_job_run;
 	slurm_addr self;
 	slurm_addr *cli = &msg->orig_addr;
 	socklen_t adlen;
 	hostset_t step_hset = NULL;
+	job_mem_limits_t *job_limits_ptr;
 	int nodeid = nodelist_find(req->complete_nodelist, conf->node_name);
 
-	req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	memcpy(&req->orig_addr, &msg->orig_addr, sizeof(slurm_addr));
 
-	slurmd_launch_request(jobid, req, nodeid);
+	slurmd_launch_request(req->job_id, req, nodeid);
 
 	super_user = _slurm_authorized_user(req_uid);
 
@@ -718,24 +760,52 @@ _rpc_launch_tasks(slurm_msg_t *msg)
 	     req->job_step_id, req->uid, req->gid, host, port);
 
 	first_job_run = !slurm_cred_jobid_cached(conf->vctx, req->job_id);
-	if (_check_job_credential(req->cred, jobid, stepid, req_uid,
-				  req->tasks_to_launch[nodeid],
+	if (_check_job_credential(req, req_uid, req->tasks_to_launch[nodeid],
 				  &step_hset) < 0) {
 		errnum = errno;
 		error("Invalid job credential from %ld@%s: %m", 
 		      (long) req_uid, host);
 		goto done;
 	}
-
+	
 #ifndef HAVE_FRONT_END
 	if (first_job_run) {
-		if (_run_prolog(req->job_id, req->uid, NULL) != 0) {
-			error("[job %u] prolog failed", req->job_id);
+		int rc;
+		rc =  _run_prolog(req->job_id, req->uid, NULL);
+		if (rc) {
+			int term_sig, exit_status;
+			if (WIFSIGNALED(rc)) {
+				exit_status = 0;
+				term_sig    = WTERMSIG(rc);
+			} else {
+				exit_status = WEXITSTATUS(rc);
+				term_sig    = 0;
+			}
+			error("[job %u] prolog failed status=%d:%d", 
+			      req->job_id, exit_status, term_sig);
 			errnum = ESLURMD_PROLOG_FAILED;
 			goto done;
 		}
 	}
 #endif
+
+	if (req->job_mem) {
+		slurm_mutex_lock(&job_limits_mutex);
+		if (!job_limits_list)
+			job_limits_list = list_create(_job_limits_free);
+		job_limits_ptr = list_find_first (job_limits_list, 
+						  _job_limits_match, 
+						  &req->job_id);
+		if (!job_limits_ptr) {
+			//info("AddLim job:%u mem:%u",req->job_id,req->job_mem);
+			job_limits_ptr = xmalloc(sizeof(job_mem_limits_t));
+			job_limits_ptr->job_id = req->job_id;
+			list_append(job_limits_list, job_limits_ptr);
+		}
+		job_limits_ptr->job_mem = req->job_mem;	/* reset limit */
+		slurm_mutex_unlock(&job_limits_mutex);
+	}
+
 	adlen = sizeof(self);
 	_slurm_getsockname(msg->conn_fd, (struct sockaddr *)&self, &adlen);
 
@@ -750,7 +820,7 @@ _rpc_launch_tasks(slurm_msg_t *msg)
 
 	if (slurm_send_rc_msg(msg, errnum) < 0) {
 
-		error("launch_tasks: unable to send return code: %m");
+		error("_rpc_launch_tasks: unable to send return code: %m");
 
 		/*
 		 * Rewind credential so that srun may perform retry
@@ -806,7 +876,7 @@ _rpc_batch_job(slurm_msg_t *msg)
 	batch_job_launch_msg_t *req = (batch_job_launch_msg_t *)msg->data;
 	bool     first_job_run = true;
 	int      rc = SLURM_SUCCESS;
-	uid_t    req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t    req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	char    *bg_part_id = NULL;
 	bool	replied = false;
 	slurm_addr *cli = &msg->orig_addr;
@@ -851,8 +921,17 @@ _rpc_batch_job(slurm_msg_t *msg)
 
 		rc = _run_prolog(req->job_id, req->uid, bg_part_id);
 		xfree(bg_part_id);
-		if (rc != 0) {
-			error("[job %u] prolog failed", req->job_id);
+		if (rc) {
+			int term_sig, exit_status;
+			if (WIFSIGNALED(rc)) {
+				exit_status = 0;
+				term_sig    = WTERMSIG(rc);
+			} else {
+				exit_status = WEXITSTATUS(rc);
+				term_sig    = 0;
+			}
+			error("[job %u] prolog failed status=%d:%d", 
+			      req->job_id, exit_status, term_sig);
 			_prolog_error(req, rc);
 			rc = ESLURMD_PROLOG_FAILED;
 			goto done;
@@ -934,7 +1013,7 @@ _abort_step(uint32_t job_id, uint32_t step_id)
 	resp.range_first  = 0;
 	resp.range_last   = 0;
 	resp.step_rc      = 1;
-	resp.jobacct      = jobacct_g_alloc(NULL);
+	resp.jobacct      = jobacct_gather_g_create(NULL);
 	resp_msg.msg_type = REQUEST_STEP_COMPLETE;
 	resp_msg.data     = &resp;
 	return slurm_send_recv_controller_rc_msg(&resp_msg, &rc);
@@ -943,7 +1022,7 @@ _abort_step(uint32_t job_id, uint32_t step_id)
 static void
 _rpc_reconfig(slurm_msg_t *msg)
 {
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	if (!_slurm_authorized_user(req_uid))
 		error("Security violation, reconfig RPC from uid %u",
@@ -957,7 +1036,7 @@ _rpc_reconfig(slurm_msg_t *msg)
 static void
 _rpc_shutdown(slurm_msg_t *msg)
 {
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	
 	forward_wait(msg);
 	if (!_slurm_authorized_user(req_uid))
@@ -971,11 +1050,183 @@ _rpc_shutdown(slurm_msg_t *msg)
 	/* Never return a message, slurmctld does not expect one */
 }
 
+static void _job_limits_free(void *x)
+{
+	xfree(x);
+}
+
+
+static int _job_limits_match(void *x, void *key)
+{
+	job_mem_limits_t *job_limits_ptr = (job_mem_limits_t *) x;
+	uint32_t *job_id = (uint32_t *) key;
+	if (job_limits_ptr->job_id == *job_id)
+		return 1;
+	return 0;
+}
+
+/* Call only with job_limits_mutex locked */
+static void
+_load_job_limits(void)
+{
+	List steps;
+	ListIterator step_iter;
+	step_loc_t *stepd;
+	int fd;
+	job_mem_limits_t *job_limits_ptr;
+	slurmstepd_info_t *stepd_info_ptr;
+
+	if (!job_limits_list)
+		job_limits_list = list_create(_job_limits_free);
+	job_limits_loaded = true;
+
+	steps = stepd_available(conf->spooldir, conf->node_name);
+	step_iter = list_iterator_create(steps);
+	while ((stepd = list_next(step_iter))) {
+		job_limits_ptr = list_find_first(job_limits_list,
+						 _job_limits_match,
+						 &stepd->jobid);
+		if (job_limits_ptr)	/* already processed */
+			continue;
+		fd = stepd_connect(stepd->directory, stepd->nodename,
+				   stepd->jobid, stepd->stepid);
+		if (fd == -1)
+			continue;	/* step completed */
+		stepd_info_ptr = stepd_get_info(fd);
+		if (stepd_info_ptr && stepd_info_ptr->job_mem_limit) {
+			/* create entry for this job */
+			job_limits_ptr = xmalloc(sizeof(job_mem_limits_t));
+			job_limits_ptr->job_id  = stepd->jobid;
+			job_limits_ptr->job_mem = stepd_info_ptr->job_mem_limit;
+			debug("RecLim job:%u mem:%u", 
+			      stepd->jobid, stepd_info_ptr->job_mem_limit);
+			list_append(job_limits_list, job_limits_ptr);
+		}
+		xfree(stepd_info_ptr);
+		close(fd);
+	}
+	list_iterator_destroy(step_iter);
+	list_destroy(steps);
+}
+
+static void
+_enforce_job_mem_limit(void)
+{
+	List steps;
+	ListIterator step_iter, job_limits_iter;
+	job_mem_limits_t *job_limits_ptr;
+	step_loc_t *stepd;
+	int fd, i, job_inx, job_cnt = 0;
+	uint32_t step_rss;
+	stat_jobacct_msg_t acct_req;
+	stat_jobacct_msg_t *resp = NULL;
+	struct job_mem_info {
+		uint32_t job_id;
+		uint32_t mem_limit;	/* MB */
+		uint32_t mem_used;	/* KB */
+	};
+	struct job_mem_info *job_mem_info_ptr = NULL;
+	slurm_msg_t msg;
+	job_notify_msg_t notify_req;
+	job_step_kill_msg_t kill_req;
+
+	slurm_mutex_lock(&job_limits_mutex);
+	if (!job_limits_loaded)
+		_load_job_limits();
+	if (list_count(job_limits_list) == 0) {
+		slurm_mutex_unlock(&job_limits_mutex);
+		return;
+	}
+
+	job_mem_info_ptr = xmalloc((list_count(job_limits_list) + 1) * 
+			   sizeof(struct job_mem_info));
+	job_cnt = 0;
+	job_limits_iter = list_iterator_create(job_limits_list);
+	while ((job_limits_ptr = list_next(job_limits_iter))) {
+		job_mem_info_ptr[job_cnt].job_id    = job_limits_ptr->job_id; 
+		job_mem_info_ptr[job_cnt].mem_limit = job_limits_ptr->job_mem;
+		job_cnt++;
+	}
+	list_iterator_destroy(job_limits_iter);
+	slurm_mutex_unlock(&job_limits_mutex);
+
+	steps = stepd_available(conf->spooldir, conf->node_name);
+	step_iter = list_iterator_create(steps);
+	while ((stepd = list_next(step_iter))) {
+		for (job_inx=0; job_inx<job_cnt; job_inx++) {
+			if (job_mem_info_ptr[job_inx].job_id == stepd->jobid)
+				break;
+		}
+		if (job_inx >= job_cnt)
+			continue;	/* job not being tracked */
+
+		fd = stepd_connect(stepd->directory, stepd->nodename,
+				   stepd->jobid, stepd->stepid);
+		if (fd == -1)
+			continue;	/* step completed */
+		acct_req.job_id  = stepd->jobid;
+		acct_req.step_id = stepd->stepid;
+		resp = xmalloc(sizeof(stat_jobacct_msg_t));
+		if ((!stepd_stat_jobacct(fd, &acct_req, resp)) &&
+		    (resp->jobacct)) {
+			/* resp->jobacct is NULL if account is disabled */
+			jobacct_common_getinfo((struct jobacctinfo *)
+					       resp->jobacct,
+					       JOBACCT_DATA_TOT_RSS,
+					       &step_rss);
+			//info("job %u.%u rss:%u",stepd->jobid, stepd->stepid, step_rss);
+			step_rss = MAX(step_rss, 1);
+			job_mem_info_ptr[job_inx].mem_used += step_rss;
+		}
+		slurm_free_stat_jobacct_msg(resp);
+		close(fd);
+	}
+	list_iterator_destroy(step_iter);
+	list_destroy(steps);
+
+	for (i=0; i<job_cnt; i++) {
+		if ((job_mem_info_ptr[i].mem_limit == 0) ||
+		    (job_mem_info_ptr[i].mem_used == 0)) {
+			/* no memory limit or no steps found, purge record */
+			slurm_mutex_lock(&job_limits_mutex);
+			list_delete_all(job_limits_list, _job_limits_match, 
+					&job_mem_info_ptr[i].job_id);
+			slurm_mutex_unlock(&job_limits_mutex);
+			break;
+		}
+		job_mem_info_ptr[i].mem_used /= 1024;	/* KB to MB */
+		if (job_mem_info_ptr[i].mem_used <=
+		    job_mem_info_ptr[i].mem_limit)
+			continue;
+
+		info("Job %u exceeded memory limit (%u>%u), cancelling it",
+		    job_mem_info_ptr[i].job_id, job_mem_info_ptr[i].mem_used,
+		    job_mem_info_ptr[i].mem_limit);
+		/* NOTE: Batch jobs may have no srun to get this message */
+		slurm_msg_t_init(&msg);
+		notify_req.job_id      = job_mem_info_ptr[i].job_id;
+		notify_req.job_step_id = NO_VAL;
+		notify_req.message     = "Exceeded job memory limit";
+		msg.msg_type    = REQUEST_JOB_NOTIFY;
+		msg.data        = &notify_req;
+		slurm_send_only_controller_msg(&msg);
+
+		kill_req.job_id      = job_mem_info_ptr[i].job_id;
+		kill_req.job_step_id = NO_VAL;
+		kill_req.signal      = SIGKILL;
+		kill_req.batch_flag  = (uint16_t) 0;
+		msg.msg_type    = REQUEST_CANCEL_JOB_STEP;
+		msg.data        = &kill_req;
+		slurm_send_only_controller_msg(&msg);
+	}
+	xfree(job_mem_info_ptr);
+}
+
 static int
 _rpc_ping(slurm_msg_t *msg)
 {
 	int        rc = SLURM_SUCCESS;
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	if (!_slurm_authorized_user(req_uid)) {
 		error("Security violation, ping RPC from uid %u",
@@ -994,6 +1245,44 @@ _rpc_ping(slurm_msg_t *msg)
 		error("Error responding to ping: %m");
 		send_registration_msg(SLURM_SUCCESS, false);
 	}
+
+	/* Take this opportunity to enforce any job memory limits */
+	_enforce_job_mem_limit();
+	return rc;
+}
+
+static int
+_rpc_health_check(slurm_msg_t *msg)
+{
+	int        rc = SLURM_SUCCESS;
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+
+	if (!_slurm_authorized_user(req_uid)) {
+		error("Security violation, ping RPC from uid %u",
+		      (unsigned int) req_uid);
+		rc = ESLURM_USER_ID_MISSING;	/* or bad in this case */
+	}
+
+	/* Return result. If the reply can't be sent this indicates that
+	 * 1. The network is broken OR
+	 * 2. slurmctld has died    OR
+	 * 3. slurmd was paged out due to full memory
+	 * If the reply request fails, we send an registration message to 
+	 * slurmctld in hopes of avoiding having the node set DOWN due to
+	 * slurmd paging and not being able to respond in a timely fashion. */
+	if (slurm_send_rc_msg(msg, rc) < 0) {
+		error("Error responding to ping: %m");
+		send_registration_msg(SLURM_SUCCESS, false);
+	}
+
+	if ((rc == SLURM_SUCCESS) && (conf->health_check_program)) {
+		char *env[1] = { NULL };
+		rc = run_script("health_check", conf->health_check_program, 
+				0, 60, env);
+	}
+
+	/* Take this opportunity to enforce any job memory limits */
+	_enforce_job_mem_limit();
 	return rc;
 }
 
@@ -1002,7 +1291,7 @@ _rpc_signal_tasks(slurm_msg_t *msg)
 {
 	int               fd;
 	int               rc = SLURM_SUCCESS;
-	uid_t             req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t             req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	kill_tasks_msg_t *req = (kill_tasks_msg_t *) msg->data;
 	slurmstepd_info_t *step;
 
@@ -1063,6 +1352,50 @@ done:
 	slurm_send_rc_msg(msg, rc);
 }
 
+static void
+_rpc_checkpoint_tasks(slurm_msg_t *msg)
+{
+	int               fd;
+	int               rc = SLURM_SUCCESS;
+	uid_t             req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+	checkpoint_tasks_msg_t *req = (checkpoint_tasks_msg_t *) msg->data;
+	slurmstepd_info_t *step;
+
+	fd = stepd_connect(conf->spooldir, conf->node_name,
+			   req->job_id, req->job_step_id);
+	if (fd == -1) {
+		debug("checkpoint for nonexistant %u.%u stepd_connect failed: %m",
+		      req->job_id, req->job_step_id);
+		rc = ESLURM_INVALID_JOB_ID;
+		goto done;
+	}
+	if ((step = stepd_get_info(fd)) == NULL) {
+		debug("checkpoint for nonexistent job %u.%u requested",
+		      req->job_id, req->job_step_id);
+		rc = ESLURM_INVALID_JOB_ID;
+		goto done2;
+	}
+
+	if ((req_uid != step->uid) && (!_slurm_authorized_user(req_uid))) {
+		debug("checkpoint req from uid %ld for job %u.%u owned by uid %ld",
+		      (long) req_uid, req->job_id, req->job_step_id,
+		      (long) step->uid);
+		rc = ESLURM_USER_ID_MISSING;     /* or bad in this case */
+		goto done3;
+	}
+
+	rc = stepd_checkpoint(fd, req->signal, req->timestamp);
+	if (rc == -1)
+		rc = ESLURMD_JOB_NOTRUNNING;
+
+ done3:
+	xfree(step);
+ done2:
+	close(fd);
+ done:
+	slurm_send_rc_msg(msg, rc);
+}
+
 static void
 _rpc_terminate_tasks(slurm_msg_t *msg)
 {
@@ -1088,7 +1421,7 @@ _rpc_terminate_tasks(slurm_msg_t *msg)
 		goto done2;
 	} 
 
-	req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	if ((req_uid != step->uid) && (!_slurm_authorized_user(req_uid))) {
 		debug("kill req from uid %ld for job %u.%u owned by uid %ld",
 		      (long) req_uid, req->job_id, req->job_step_id, 
@@ -1127,9 +1460,9 @@ _rpc_step_complete(slurm_msg_t *msg)
 		goto done;
 	}
 
-	/* step completionmessages are only allowed from other slurmstepd,
+	/* step completion messages are only allowed from other slurmstepd,
 	   so only root or SlurmUser is allowed here */
-	req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	if (!_slurm_authorized_user(req_uid)) {
 		debug("step completion from uid %ld for job %u.%u",
 		      (long) req_uid, req->job_id, req->job_step_id);
@@ -1238,7 +1571,7 @@ _rpc_stat_jobacct(slurm_msg_t *msg)
 	debug3("Entering _rpc_stat_jobacct");
 	/* step completion messages are only allowed from other slurmstepd,
 	   so only root or SlurmUser is allowed here */
-	req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	
 	job_uid = _get_job_uid(req->job_id);
 	if (job_uid < 0) {
@@ -1279,7 +1612,7 @@ _rpc_stat_jobacct(slurm_msg_t *msg)
 		
 	}
 	if (stepd_stat_jobacct(fd, req, resp) == SLURM_ERROR) {
-		debug("kill for nonexistent job %u.%u requested",
+		debug("accounting for nonexistent job %u.%u requested",
 		      req->job_id, req->step_id);
 	} 
 	close(fd);
@@ -1296,12 +1629,11 @@ _rpc_stat_jobacct(slurm_msg_t *msg)
 /* 
  *  For the specified job_id: reply to slurmctld, 
  *   sleep(configured kill_wait), then send SIGKILL 
- *  FIXME! - Perhaps we should send SIGXCPU first?
  */
 static void
 _rpc_timelimit(slurm_msg_t *msg)
 {
-	uid_t           uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t           uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	kill_job_msg_t *req = msg->data;
 	int             nsteps;
 
@@ -1323,6 +1655,7 @@ _rpc_timelimit(slurm_msg_t *msg)
 		_kill_all_active_steps(req->job_id, SIGTERM, false);
 	verbose( "Job %u: timeout: sent SIGTERM to %d active steps", 
 	         req->job_id, nsteps );
+	_kill_all_active_steps(req->job_id, SIGXCPU, true);
 
 	/* Revoke credential, send SIGKILL, run epilog, etc. */
 	_rpc_terminate_job(msg); 
@@ -1378,9 +1711,9 @@ static int
 _rpc_file_bcast(slurm_msg_t *msg)
 {
 	file_bcast_msg_t *req = msg->data;
-	int i, fd, flags, offset, inx, rc;
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
-	uid_t req_gid = g_slurm_auth_get_gid(msg->auth_cred);
+	int fd, flags, offset, inx, rc;
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
+	uid_t req_gid = g_slurm_auth_get_gid(msg->auth_cred, NULL);
 	pid_t child;
 
 #if 0
@@ -1433,21 +1766,18 @@ _rpc_file_bcast(slurm_msg_t *msg)
 		exit(errno);
 	}
 
-	for (i=0; i<FILE_BLOCKS; i++) {
-		offset = 0;
-		while (req->block_len[i] - offset) {
-			inx = write(fd, &req->block[i][offset], 
-				(req->block_len[i] - offset));
-			if (inx == -1) {
-				if ((errno == EINTR) || (errno == EAGAIN))
-					continue;
-				error("sbcast: uid:%u can't write `%s`: %s",
-					req_uid, req->fname, strerror(errno));
-				close(fd);
-				exit(errno);
-			}
-			offset += inx;
+	offset = 0;
+	while (req->block_len - offset) {
+		inx = write(fd, &req->block[offset], (req->block_len - offset));
+		if (inx == -1) {
+			if ((errno == EINTR) || (errno == EAGAIN))
+				continue;
+			error("sbcast: uid:%u can't write `%s`: %s",
+				req_uid, req->fname, strerror(errno));
+			close(fd);
+			exit(errno);
 		}
+		offset += inx;
 	}
 	if (req->last_block && fchmod(fd, (req->modes & 0777))) {
 		error("sbcast: uid:%u can't chmod `%s`: %s",
@@ -1508,7 +1838,7 @@ _rpc_reattach_tasks(slurm_msg_t *msg)
 	nodeid = step->nodeid;
 	debug2("_rpc_reattach_tasks: nodeid %d in the job step", nodeid);
 
-	req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	if ((req_uid != step->uid) && (!_slurm_authorized_user(req_uid))) {
 		error("uid %ld attempt to attach to job %u.%u owned by %ld",
 		      (long) req_uid, req->job_id, req->job_step_id,
@@ -1852,7 +2182,7 @@ static void
 _rpc_signal_job(slurm_msg_t *msg)
 {
 	signal_job_msg_t *req = msg->data;
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	long job_uid;
 	List steps;
 	ListIterator i;
@@ -1951,6 +2281,51 @@ _rpc_signal_job(slurm_msg_t *msg)
 	}
 }
 
+/* if a lock is granted to the job then return 1; else return 0 if
+ * the lock for the job is already taken or there's no more locks */
+static int
+_get_suspend_job_lock(uint32_t jobid)
+{
+	int i, spot = -1;
+	pthread_mutex_lock(&suspend_mutex);
+
+	for (i = 0; i < job_suspend_size; i++) {
+		if (job_suspend_array[i] == -1) {
+			spot = i;
+			continue;
+		}
+		if (job_suspend_array[i] == jobid) {
+			/* another thread already has the lock */
+			pthread_mutex_unlock(&suspend_mutex);
+			return 0;
+		}
+	}
+	i = 0;
+	if (spot != -1) {
+		/* nobody has the lock and here's an available used lock */
+		job_suspend_array[spot] = jobid;
+		i = 1;
+	} else if (job_suspend_size < NUM_PARALLEL_SUSPEND) {
+		/* a new lock is available */
+		job_suspend_array[job_suspend_size++] = jobid;
+		i = 1;
+	}
+	pthread_mutex_unlock(&suspend_mutex);
+	return i;
+}
+
+static void
+_unlock_suspend_job(uint32_t jobid)
+{
+	int i;
+	pthread_mutex_lock(&suspend_mutex);
+	for (i = 0; i < job_suspend_size; i++) {
+		if (job_suspend_array[i] == jobid)
+			job_suspend_array[i] = -1;
+	}
+	pthread_mutex_unlock(&suspend_mutex);
+}
+
 /*
  * Send a job suspend/resume request through the appropriate slurmstepds for 
  * each job step belonging to a given job allocation.
@@ -1959,90 +2334,134 @@ static void
 _rpc_suspend_job(slurm_msg_t *msg)
 {
 	suspend_msg_t *req = msg->data;
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
-	long job_uid;
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	List steps;
 	ListIterator i;
 	step_loc_t *stepd;
 	int step_cnt  = 0;  
-	int fd, rc = SLURM_SUCCESS;
+	int first_time, rc = SLURM_SUCCESS;
 
 	if (req->op != SUSPEND_JOB && req->op != RESUME_JOB) {
 		error("REQUEST_SUSPEND: bad op code %u", req->op);
 		rc = ESLURM_NOT_SUPPORTED;
-		goto fini;
 	}
-	debug("_rpc_suspend_job jobid=%u uid=%d", 
-		req->job_id, req_uid);
-	job_uid = _get_job_uid(req->job_id);
-	if (job_uid < 0)
-		goto no_job;
+
 	/* 
 	 * check that requesting user ID is the SLURM UID or root
 	 */
 	if (!_slurm_authorized_user(req_uid)) {
-		error("Security violation: signal_job(%u) from uid %ld",
+		error("Security violation: suspend_job(%u) from uid %ld",
 		      req->job_id, (long) req_uid);
 		rc =  ESLURM_USER_ID_MISSING;
-		goto fini;
-	} 
+	}
+	
+	/* send a response now, which will include any errors
+	 * detected with the request */
+	if (msg->conn_fd >= 0) {
+		slurm_send_rc_msg(msg, rc);
+		if (slurm_close_accepted_conn(msg->conn_fd) < 0)
+			error ("_rpc_suspend_job: close(%d): %m", msg->conn_fd);
+		msg->conn_fd = -1;
+	}
+	if (rc != SLURM_SUCCESS)
+		return;
+
+	/* now we can focus on performing the requested action,
+	 * which could take a few seconds to complete */
+	debug("_rpc_suspend_job jobid=%u uid=%d action=%s", req->job_id,
+		req_uid, req->op == SUSPEND_JOB ? "suspend" : "resume");
+
+	/* Try to get a thread lock for this job. If the lock
+	 * is not available then sleep and try again */
+	 first_time = 1;
+	 while (!_get_suspend_job_lock(req->job_id)) {
+	 	first_time = 0;
+		debug3("suspend lock sleep for %u", req->job_id);
+		sleep(1);
+	 }
+
+	/* If suspending and you got the lock on the first try then
+	 * sleep for 1 second to give any launch requests a chance
+	 * to get started and avoid a race condition that would
+	 * effectively cause the suspend request to get ignored
+	 * because "there's no job to suspend" */
+	if (first_time && req->op == SUSPEND_JOB) {
+		debug3("suspend first sleep for %u", req->job_id);
+		sleep(1);
+	}
+
+	/* Release or reclaim resources bound to these tasks (task affinity) */
+	if (req->op == SUSPEND_JOB)
+		(void) slurmd_suspend_job(req->job_id);
+	else
+		(void) slurmd_resume_job(req->job_id);
 
 	/*
 	 * Loop through all job steps and call stepd_suspend or stepd_resume
-	 * as appropriate.
+	 * as appropriate. Since the "suspend" action contains a 'sleep 1',
+	 * suspend multiple jobsteps in parallel.
 	 */
 	steps = stepd_available(conf->spooldir, conf->node_name);
 	i = list_iterator_create(steps);
-	while ((stepd = list_next(i))) {
-		if (stepd->jobid != req->job_id) {
-			/* multiple jobs expected on shared nodes */
-			debug3("Step from other job: jobid=%u (this jobid=%u)",
-			      stepd->jobid, req->job_id);
-			continue;
-		}
-		step_cnt++;
 
-		fd = stepd_connect(stepd->directory, stepd->nodename,
-				   stepd->jobid, stepd->stepid);
-		if (fd == -1) {
-			debug3("Unable to connect to step %u.%u",
-			       stepd->jobid, stepd->stepid);
-			continue;
+	while (1) {
+		int x, fdi, fd[NUM_PARALLEL_SUSPEND];
+		fdi = 0;
+		while ((stepd = list_next(i))) {
+			if (stepd->jobid != req->job_id) {
+				/* multiple jobs expected on shared nodes */
+				debug3("Step from other job: jobid=%u (this jobid=%u)",
+				      stepd->jobid, req->job_id);
+				continue;
+			}
+			step_cnt++;
+
+			fd[fdi] = stepd_connect(stepd->directory,
+						stepd->nodename, stepd->jobid,
+						stepd->stepid);
+			if (fd[fdi] == -1) {
+				debug3("Unable to connect to step %u.%u",
+			       		stepd->jobid, stepd->stepid);
+				continue;
+			}
+			
+
+			fdi++;
+			if (fdi >= NUM_PARALLEL_SUSPEND)
+				break;
 		}
+		/* check for open connections */
+		if (fdi == 0)
+			break;
 
 		if (req->op == SUSPEND_JOB) {
-			debug2("Suspending job step %u.%u",
-			       stepd->jobid, stepd->stepid);
-			if (stepd_suspend(fd) < 0)
-				debug("  suspend failed: %m", stepd->jobid);
+			stepd_suspend(fd, fdi, req->job_id);
 		} else {
-			debug2("Resuming job step %u.%u",
-			       stepd->jobid, stepd->stepid);
-			if (stepd_resume(fd) < 0)
-				debug("  resume failed: %m", stepd->jobid);
+			/* "resume" remains a serial action (for now) */
+			for (x = 0; x < fdi; x++) {
+				debug2("Resuming job %u (cached step count %d)",
+					req->job_id, x);
+				if (stepd_resume(fd[x]) < 0)
+					debug("  resume failed: %m");
+			}
 		}
+		for (x = 0; x < fdi; x++)
+			/* fd may have been closed by stepd_suspend */
+			if (fd[x] != -1)
+				close(fd[x]);
 
-		close(fd);
+		/* check for no more jobs */
+		if (fdi < NUM_PARALLEL_SUSPEND)
+			break;
 	}
 	list_iterator_destroy(i);
 	list_destroy(steps);
+	_unlock_suspend_job(req->job_id);
 
- no_job:
 	if (step_cnt == 0) {
 		debug2("No steps in jobid %u to suspend/resume", 
 			req->job_id);
 	}
-
-	/*
-	 *  At this point, if connection still open, we send controller
-	 *  a reply.
-	 */
- fini:	if (msg->conn_fd >= 0) {
-		slurm_send_rc_msg(msg, rc);
-		if (slurm_close_accepted_conn(msg->conn_fd) < 0)
-			error ("_rpc_signal_job: close(%d): %m", msg->conn_fd);
-		msg->conn_fd = -1;
-	}
 }
 
 static void 
@@ -2050,10 +2469,11 @@ _rpc_terminate_job(slurm_msg_t *msg)
 {
 	int             rc     = SLURM_SUCCESS;
 	kill_job_msg_t *req    = msg->data;
-	uid_t           uid    = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t           uid    = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 	int             nsteps = 0;
 	int		delay;
 	char           *bg_part_id = NULL;
+	uint16_t	base_job_state = req->job_state & (~JOB_COMPLETING);
 	slurm_ctl_conf_t *cf;
 
 	debug("_rpc_terminate_job, uid = %d", uid);
@@ -2095,6 +2515,12 @@ _rpc_terminate_job(slurm_msg_t *msg)
 		debug("credential for job %u revoked", req->job_id);
 	}
 
+	if ((base_job_state == JOB_NODE_FAIL) || 
+	    (base_job_state == JOB_PENDING))		/* requeued */
+		_kill_all_active_steps(req->job_id, SIG_NODE_FAIL, true);
+	else if (base_job_state == JOB_FAILED)
+		_kill_all_active_steps(req->job_id, SIG_FAILURE, true);
+
 	/*
 	 * Tasks might be stopped (possibly by a debugger)
 	 * so send SIGCONT first.
@@ -2178,8 +2604,17 @@ _rpc_terminate_job(slurm_msg_t *msg)
 	rc = _run_epilog(req->job_id, req->job_uid, bg_part_id);
 	xfree(bg_part_id);
 	
-	if (rc != 0) {
-		error ("[job %u] epilog failed", req->job_id);
+	if (rc) {
+		int term_sig, exit_status;
+		if (WIFSIGNALED(rc)) {
+			exit_status = 0;
+			term_sig    = WTERMSIG(rc);
+		} else {
+			exit_status = WEXITSTATUS(rc);
+			term_sig    = 0;
+		}
+		error("[job %u] epilog failed status=%d:%d", 
+		      req->job_id, exit_status, term_sig);
 		rc = ESLURMD_EPILOG_FAILED;
 	} else
 		debug("completed epilog for jobid %u", req->job_id);
@@ -2201,10 +2636,11 @@ static void _sync_messages_kill(kill_job_msg_t *req)
 	int host_cnt, host_inx;
 	char *host;
 	hostset_t hosts;
+	int epilog_msg_time;
 
 	hosts = hostset_create(req->nodes);
 	host_cnt = hostset_count(hosts);
-	if (host_cnt <= 32)
+	if (host_cnt <= 64)
 		goto fini;
 	if (conf->hostname == NULL)
 		goto fini;	/* should never happen */
@@ -2219,7 +2655,8 @@ static void _sync_messages_kill(kill_job_msg_t *req)
 		}
 		free(host);
 	}
-	_delay_rpc(host_inx, host_cnt, 10000);
+	epilog_msg_time = slurm_get_epilog_msg_time();
+	_delay_rpc(host_inx, host_cnt, epilog_msg_time);
 
  fini:	hostset_destroy(hosts);
 }
@@ -2354,7 +2791,7 @@ static void
 _rpc_update_time(slurm_msg_t *msg)
 {
 	int   rc      = SLURM_SUCCESS;
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
+	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, NULL);
 
 	if ((req_uid != conf->slurm_user_id) && (req_uid != 0)) {
 		rc = ESLURM_USER_ID_MISSING;
diff --git a/src/slurmd/slurmd/req.h b/src/slurmd/slurmd/req.h
index 7d13065c15d1b55da217088af17f171cf54c85ca..211c90ac7978eca41d5307b54e4be0bc84b1c1f1 100644
--- a/src/slurmd/slurmd/req.h
+++ b/src/slurmd/slurmd/req.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmd/req.h - slurmd request handling
- * $Id: req.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: req.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmd/reverse_tree_math.c b/src/slurmd/slurmd/reverse_tree_math.c
index 134d2a8d03dd43ad519bcc93f43bf8e68a2e5287..9cb03b9f6d1c88df53e751c4d9fdbf24e77d980e 100644
--- a/src/slurmd/slurmd/reverse_tree_math.c
+++ b/src/slurmd/slurmd/reverse_tree_math.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmd/reverse_tree_math.h b/src/slurmd/slurmd/reverse_tree_math.h
index d40d75887f12e1338e1e75e1c0fdd33e838039b8..6896db8ace8228cab860934c464f5599a53c61a8 100644
--- a/src/slurmd/slurmd/reverse_tree_math.h
+++ b/src/slurmd/slurmd/reverse_tree_math.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmd/slurmd.c b/src/slurmd/slurmd/slurmd.c
index d523cd2f147e0e84e4a8faa73ef33e06cd7b1461..d46d3fc08af6bfb6fc25446b8c96272907108728 100644
--- a/src/slurmd/slurmd/slurmd.c
+++ b/src/slurmd/slurmd/slurmd.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/slurmd/slurmd/slurmd.c - main slurm node server daemon
- *  $Id: slurmd.c 13688 2008-03-21 17:27:38Z jette $
+ *  $Id: slurmd.c 13690 2008-03-21 18:17:38Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -49,6 +49,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/resource.h>
+#include <sys/utsname.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/mman.h>
@@ -258,6 +259,8 @@ main (int argc, char *argv[])
 
 	_slurmd_fini();
 	_destroy_conf();
+	slurm_crypto_fini();	/* must be after _destroy_conf() */
+
 	info("Slurmd shutdown completing");
 	log_fini();
        	return 0;
@@ -447,20 +450,31 @@ _fill_registration_msg(slurm_node_registration_status_msg_t *msg)
 	List steps;
 	ListIterator i;
 	step_loc_t *stepd;
-	int          n;
-
-	msg->node_name = xstrdup (conf->node_name);
-	msg->cpus	= conf->cpus;
-	msg->sockets	= conf->sockets;
-	msg->cores	= conf->cores;
-	msg->threads	= conf->threads;
-
-	msg->real_memory_size     = conf->real_memory_size;
-	msg->temporary_disk_space = conf->tmp_disk_space;
+	int  n;
+	char *arch, *os;
+	struct utsname buf;
+
+	msg->node_name  = xstrdup (conf->node_name);
+	msg->cpus	 = conf->cpus;
+	msg->sockets	 = conf->sockets;
+	msg->cores	 = conf->cores;
+	msg->threads	 = conf->threads;
+	msg->real_memory = conf->real_memory_size;
+	msg->tmp_disk    = conf->tmp_disk_space;
 
 	debug3("Procs=%u Sockets=%u Cores=%u Threads=%u Memory=%u TmpDisk=%u",
 	       msg->cpus, msg->sockets, msg->cores, msg->threads,
-	       msg->real_memory_size, msg->temporary_disk_space);
+	       msg->real_memory, msg->tmp_disk);
+
+	uname(&buf);
+	if ((arch = getenv("SLURM_ARCH")))
+		msg->arch = xstrdup(arch);
+	else
+		msg->arch = xstrdup(buf.machine);
+	if ((os = getenv("SLURM_OS")))
+		msg->os   = xstrdup(os);
+	else
+		msg->os = xstrdup(buf.sysname);
 
 	if (msg->startup) {
 		if (switch_g_alloc_node_info(&msg->switch_nodeinfo))
@@ -607,6 +621,8 @@ _read_config()
 	_free_and_set(&conf->epilog,   xstrdup(cf->epilog));
 	_free_and_set(&conf->prolog,   xstrdup(cf->prolog));
 	_free_and_set(&conf->tmpfs,    xstrdup(cf->tmp_fs));
+	_free_and_set(&conf->health_check_program, 
+		      xstrdup(cf->health_check_program));
 	_free_and_set(&conf->spooldir, xstrdup(cf->slurmd_spooldir));
 	_massage_pathname(&conf->spooldir);
 	_free_and_set(&conf->pidfile,  xstrdup(cf->slurmd_pidfile));
@@ -616,7 +632,7 @@ _read_config()
 	_free_and_set(&conf->pubkey,   path_pubkey);
 	
 	conf->propagate_prio = cf->propagate_prio_process;
-	conf->job_acct_freq = cf->job_acct_freq;
+	conf->job_acct_gather_freq = cf->job_acct_gather_freq;
 
 	if ( (conf->node_name == NULL) ||
 	     (conf->node_name[0] == '\0') )
@@ -712,6 +728,7 @@ _print_conf()
 	debug3("TmpDisk     = %u",       conf->tmp_disk_space);
 	debug3("Epilog      = `%s'",     conf->epilog);
 	debug3("Logfile     = `%s'",     cf->slurmd_logfile);
+	debug3("HealthCheck = `%s'",     conf->health_check_program);
 	debug3("NodeName    = %s",       conf->node_name);
 	debug3("Port        = %u",       conf->port);
 	debug3("Prolog      = `%s'",     conf->prolog);
@@ -747,6 +764,7 @@ _init_conf()
 	conf->block_map_inv = NULL;
 	conf->conffile    = NULL;
 	conf->epilog      = NULL;
+	conf->health_check_program = NULL;
 	conf->logfile     = NULL;
 	conf->pubkey      = NULL;
 	conf->prolog      = NULL;
@@ -775,6 +793,7 @@ _destroy_conf()
 	if(conf) {
 		xfree(conf->block_map);
 		xfree(conf->block_map_inv);
+		xfree(conf->health_check_program);
 		xfree(conf->hostname);
 		xfree(conf->node_name);
 		xfree(conf->conffile);
@@ -892,7 +911,7 @@ _slurmd_init()
 		return SLURM_FAILURE;
 	if (slurmd_task_init() != SLURM_SUCCESS)
 		return SLURM_FAILURE;
-	if (slurm_auth_init() != SLURM_SUCCESS)
+	if (slurm_auth_init(NULL) != SLURM_SUCCESS)
 		return SLURM_FAILURE;
 
 	if (getrlimit(RLIMIT_NOFILE,&rlim) == 0) {
diff --git a/src/slurmd/slurmd/slurmd.h b/src/slurmd/slurmd/slurmd.h
index 191bf951e981f0884ff839c78f458a2706b9fc21..1723f9d4da722bbb0f52141ccedea6364c9b52a0 100644
--- a/src/slurmd/slurmd/slurmd.h
+++ b/src/slurmd/slurmd/slurmd.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmd/slurmd.h - header for slurmd
- * $Id: slurmd.h 13688 2008-03-21 17:27:38Z jette $
+ * $Id: slurmd.h 13690 2008-03-21 18:17:38Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -99,7 +99,7 @@ typedef struct slurmd_config {
 	char         *logfile;		/* slurmd logfile, if any          */
 	char         *spooldir;		/* SlurmdSpoolDir	           */
 	char         *pidfile;		/* PidFile location		   */
-
+	char         *health_check_program;	/* run on RPC request      */
 	char         *tmpfs;		/* directory of tmp FS             */
 	char         *pubkey;		/* location of job cred public key */
 	char         *epilog;		/* Path to Epilog script	   */
@@ -119,7 +119,7 @@ typedef struct slurmd_config {
 
 	uid_t           slurm_user_id;	/* UID that slurmctld runs as      */
 	pthread_mutex_t config_mutex;	/* lock for slurmd_config access   */
-	uint16_t        job_acct_freq;
+	uint16_t        job_acct_gather_freq;
 	uint16_t	use_pam;
 	uint16_t	use_cpusets;	/* Use cpusets, if available       */
 	uint16_t	propagate_prio;	/* PropagatePrioProcess flag       */
diff --git a/src/slurmd/slurmd/xcpu.c b/src/slurmd/slurmd/xcpu.c
index 576c49af138b579d42be9af8b758accc2a8fb285..6bc5d330e2192cc5b201eb525d57b4c6243b64f2 100644
--- a/src/slurmd/slurmd/xcpu.c
+++ b/src/slurmd/slurmd/xcpu.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmd/xcpu.h b/src/slurmd/slurmd/xcpu.h
index e1d2b055227a546959a2c1ac6fda01a87de4029c..b98ba58d7049c1314bd4e8cc1835aabbd480fac1 100644
--- a/src/slurmd/slurmd/xcpu.h
+++ b/src/slurmd/slurmd/xcpu.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/Makefile.am b/src/slurmd/slurmstepd/Makefile.am
index c4a1f0ec24c5d41c0acf91af217789f18cd6b29b..4e344a18894d1abedda646c9065cd43f59646fcf 100644
--- a/src/slurmd/slurmstepd/Makefile.am
+++ b/src/slurmd/slurmstepd/Makefile.am
@@ -5,14 +5,14 @@ AUTOMAKE_OPTIONS = foreign
 
 sbin_PROGRAMS = slurmstepd
 
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS)
+INCLUDES = -I$(top_srcdir)
 
 slurmstepd_LDADD = 				   \
-        $(top_builddir)/src/common/libcommon.la    \
 	$(top_builddir)/src/common/libdaemonize.la \
 	$(top_builddir)/src/common/libeio.la       \
 	$(top_builddir)/src/common/libspank.la     \
-	$(PLPA_LIBS) $(SSL_LIBS) $(PAM_LIBS) 
+	$(top_builddir)/src/common/libcommon.o -ldl\
+	$(PLPA_LIBS) $(PAM_LIBS) $(UTIL_LIBS) 
 
 slurmstepd_SOURCES = 	        	\
 	slurmstepd.c slurmstepd.h	\
@@ -42,9 +42,9 @@ slurmstepd_SOURCES = 	        	\
 if HAVE_AIX
 # We need to set maxdata back to 0 because this effects the "max memory size"
 # ulimit, and the ulimit is inherited by child processes.
-slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS) -Wl,-bmaxdata:0x0
+slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) -Wl,-bmaxdata:0x0
 else
-slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 endif
 
 force:
diff --git a/src/slurmd/slurmstepd/Makefile.in b/src/slurmd/slurmstepd/Makefile.in
index 35e2e263bb4b8fde192395ba461e2c6ccdd85328..5bc200c7e0c67d0ed4789f7e7d244e1338141ba8 100644
--- a/src/slurmd/slurmstepd/Makefile.in
+++ b/src/slurmd/slurmstepd/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -78,15 +80,15 @@ am_slurmstepd_OBJECTS = slurmstepd.$(OBJEXT) mgr.$(OBJEXT) \
 	run_script.$(OBJEXT) task_plugin.$(OBJEXT)
 slurmstepd_OBJECTS = $(am_slurmstepd_OBJECTS)
 am__DEPENDENCIES_1 =
-slurmstepd_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
-	$(top_builddir)/src/common/libdaemonize.la \
+slurmstepd_DEPENDENCIES = $(top_builddir)/src/common/libdaemonize.la \
 	$(top_builddir)/src/common/libeio.la \
-	$(top_builddir)/src/common/libspank.la $(am__DEPENDENCIES_1) \
+	$(top_builddir)/src/common/libspank.la \
+	$(top_builddir)/src/common/libcommon.o $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 slurmstepd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(slurmstepd_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -126,6 +128,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -139,10 +142,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -162,7 +168,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -173,6 +182,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -188,6 +199,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -203,6 +215,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -260,13 +273,13 @@ target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS)
+INCLUDES = -I$(top_srcdir)
 slurmstepd_LDADD = \
-        $(top_builddir)/src/common/libcommon.la    \
 	$(top_builddir)/src/common/libdaemonize.la \
 	$(top_builddir)/src/common/libeio.la       \
 	$(top_builddir)/src/common/libspank.la     \
-	$(PLPA_LIBS) $(SSL_LIBS) $(PAM_LIBS) 
+	$(top_builddir)/src/common/libcommon.o -ldl\
+	$(PLPA_LIBS) $(PAM_LIBS) $(UTIL_LIBS) 
 
 slurmstepd_SOURCES = \
 	slurmstepd.c slurmstepd.h	\
@@ -293,11 +306,11 @@ slurmstepd_SOURCES = \
 	$(top_builddir)/src/slurmd/common/task_plugin.h \
 	$(top_builddir)/src/slurmd/common/reverse_tree.h
 
-@HAVE_AIX_FALSE@slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+@HAVE_AIX_FALSE@slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 
 # We need to set maxdata back to 0 because this effects the "max memory size"
 # ulimit, and the ulimit is inherited by child processes.
-@HAVE_AIX_TRUE@slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS) -Wl,-bmaxdata:0x0
+@HAVE_AIX_TRUE@slurmstepd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) -Wl,-bmaxdata:0x0
 all: all-am
 
 .SUFFIXES:
@@ -340,8 +353,8 @@ install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -489,8 +502,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -502,8 +515,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -513,13 +526,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/slurmd/slurmstepd/fname.c b/src/slurmd/slurmstepd/fname.c
index ce82957001d7174f51ce76efbe2a70604a9bc971..6c639a9701b191e4b2fca0fc2ef777949e695db4 100644
--- a/src/slurmd/slurmstepd/fname.c
+++ b/src/slurmd/slurmstepd/fname.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -140,45 +140,6 @@ fname_create(slurmd_job_t *job, const char *format, int taskid)
 	return name;
 }
 
-static int
-find_fname(void *obj, void *key)
-{
-	char *str  = obj;
-	char *name = key;
-
-	if (strcmp(str, name) == 0) 
-		return 1;
-	return 0;
-}
-
-static int
-_trunc_file(char *path)
-{
-	int flags = O_CREAT|O_TRUNC|O_WRONLY;
-	int fd;
-       
-	do {
-		fd = open(path, flags, 0644);
-	} while ((fd < 0) && (errno == EINTR));
-
-	if (fd < 0) {
-		error("Unable to open `%s': %m", path);
-		return -1;
-	} else
-		debug3("opened and truncated `%s'", path);
-
-	if (close(fd) < 0)
-		error("Unable to close `%s': %m", path);
-
-	return 0;
-}
-
-static void
-fname_free(void *name)
-{
-	xfree(name);
-}
-
 /*
  * Return >= 0 if fmt specifies "single task only" IO
  *  i.e. if it specifies a single integer only
@@ -195,30 +156,3 @@ int fname_single_task_io (const char *fmt)
 
 	return -1;
 }
-
-int 
-fname_trunc_all(slurmd_job_t *job, const char *fmt)
-{
-	int i, rc = SLURM_SUCCESS;
-	char *fname;
-	ListIterator filei;
-	List files = NULL;
-
-	if (fname_single_task_io (fmt) >= 0)
-		return (0);
-
-	files = list_create((ListDelF)fname_free);
-	for (i = 0; i < job->ntasks; i++) {
-		fname = fname_create(job, fmt, job->task[i]->gtid);
-		if (!list_find_first(files, (ListFindF) find_fname, fname))
-			list_append(files, (void *)fname);
-	}	
-
-	filei = list_iterator_create(files);
-	while ((fname = list_next(filei))) {
-		if ((rc = _trunc_file(fname)) < 0)
-			break;
-	}
-	list_destroy(files);
-	return rc;
-}
diff --git a/src/slurmd/slurmstepd/fname.h b/src/slurmd/slurmstepd/fname.h
index 124549dbf55918a39628f85ab94717d73e00d07f..156423b5750eb14adac2ccb777d52cb110fa0a5a 100644
--- a/src/slurmd/slurmstepd/fname.h
+++ b/src/slurmd/slurmstepd/fname.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/io.c b/src/slurmd/slurmstepd/io.c
index 3e7120ab3570041c6423cf0fd98d55cc0a9e6f43..bc01281306cdb801b6e2ab7f5382f56d751ac9a3 100644
--- a/src/slurmd/slurmstepd/io.c
+++ b/src/slurmd/slurmstepd/io.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmstepd/io.c - Standard I/O handling routines for slurmstepd
- * $Id: io.c 11873 2007-07-25 21:08:46Z jette $
+ * $Id: io.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -52,6 +52,15 @@
 #  include <stdlib.h>
 #endif
 
+#ifdef HAVE_PTY_H
+#  include <pty.h>
+#endif
+
+#ifdef HAVE_UTMP_H
+#  include <utmp.h>
+#endif
+
+#include <sys/poll.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
@@ -69,6 +78,7 @@
 #include "src/common/read_config.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xsignal.h"
+#include "src/common/xstring.h"
 
 #include "src/slurmd/slurmd/slurmd.h"
 #include "src/slurmd/slurmstepd/io.h"
@@ -160,6 +170,19 @@ struct task_read_info {
 	bool		 eof_msg_sent;
 };
 
+/**********************************************************************
+ * Pseudo terminal declarations
+ **********************************************************************/
+struct window_info {
+	slurmd_task_info_t *task;
+	slurmd_job_t *job;
+	slurm_fd pty_fd;
+};
+#ifdef HAVE_PTY_H
+static void  _spawn_window_manager(slurmd_task_info_t *task, slurmd_job_t *job);
+static void *_window_manager(void *arg);
+#endif
+
 /**********************************************************************
  * General declarations
  **********************************************************************/
@@ -301,7 +324,8 @@ _client_read(eio_obj_t *obj, List objs)
 	if (client->header.length == 0) { /* zero length is an eof message */
 		debug5("  got stdin eof message!");
 	} else {
-		buf = client->in_msg->data + (client->in_msg->length - client->in_remaining);
+		buf = client->in_msg->data + 
+			(client->in_msg->length - client->in_remaining);
 	again:
 		if ((n = read(obj->fd, buf, client->in_remaining)) < 0) {
 			if (errno == EINTR)
@@ -392,7 +416,8 @@ _client_write(eio_obj_t *obj, List objs)
 			debug5("_client_write: nothing in the queue");
 			return SLURM_SUCCESS;
 		}
-		debug5("  dequeue successful, client->out_msg->length = %d", client->out_msg->length);
+		debug5("  dequeue successful, client->out_msg->length = %d", 
+			client->out_msg->length);
 		client->out_remaining = client->out_msg->length;
 	}
 
@@ -401,7 +426,8 @@ _client_write(eio_obj_t *obj, List objs)
 	/*
 	 * Write message to socket.
 	 */
-	buf = client->out_msg->data + (client->out_msg->length - client->out_remaining);
+	buf = client->out_msg->data + 
+		(client->out_msg->length - client->out_remaining);
 again:
 	if ((n = write(obj->fd, buf, client->out_remaining)) < 0) {
 		if (errno == EINTR) {
@@ -647,6 +673,119 @@ again:
 	return SLURM_SUCCESS;
 }
 
+/**********************************************************************
+ * Pseudo terminal functions
+ **********************************************************************/
+#ifdef HAVE_PTY_H
+static void *_window_manager(void *arg)
+{
+	struct window_info *win_info = (struct window_info *) arg;
+	pty_winsz_t winsz;
+	ssize_t len;
+	struct winsize ws;
+	struct pollfd ufds;
+	char buf[4];
+
+	info("in _window_manager");
+	ufds.fd = win_info->pty_fd;
+	ufds.events = POLLIN;
+
+	while (1) {
+		if (poll(&ufds, 1, -1) <= 0) {
+			if (errno == EINTR)
+				continue;
+			error("poll(pty): %m");
+			break;
+		}
+		if (!(ufds.revents & POLLIN)) {
+			/* ((ufds.revents & POLLHUP) ||
+			 *  (ufds.revents & POLLERR)) */
+			break;
+		}
+		len = slurm_read_stream(win_info->pty_fd, buf, 4);
+		if ((len == -1) && ((errno == EINTR) || (errno == EAGAIN)))
+			continue;
+		if (len < 4) {
+			error("read window size error: %m");
+			return NULL;
+		}
+		memcpy(&winsz.cols, buf, 2);
+		memcpy(&winsz.rows, buf+2, 2);
+		ws.ws_col = ntohs(winsz.cols);
+		ws.ws_row = ntohs(winsz.rows);
+		debug("new pty size %u:%u", ws.ws_row, ws.ws_col);
+		if (ioctl(win_info->task->to_stdin, TIOCSWINSZ, &ws))
+			error("ioctl(TIOCSWINSZ): %s");
+		if (kill(win_info->task->pid, SIGWINCH)) {
+			if (errno == ESRCH)
+				break;
+			error("kill(%d, SIGWINCH): %m", 
+				(int)win_info->task->pid);
+		}
+	}
+	return NULL;
+}
+
+static void
+_spawn_window_manager(slurmd_task_info_t *task, slurmd_job_t *job)
+{
+	char *host, *port, *rows, *cols;
+	slurm_fd pty_fd;
+	slurm_addr pty_addr;
+	uint16_t port_u;
+	struct window_info *win_info;
+	pthread_attr_t attr;
+	pthread_t win_id;
+
+#if 0
+	/* NOTE: SLURM_LAUNCH_NODE_IPADDR is not available at this point */
+	if (!(ip_addr = getenvp(job->env, "SLURM_LAUNCH_NODE_IPADDR"))) {
+		error("SLURM_LAUNCH_NODE_IPADDR env var not set");
+		return;
+	}
+#endif
+	if (!(host = getenvp(job->env, "SLURM_SRUN_COMM_HOST"))) {
+		error("SLURM_SRUN_COMM_HOST env var not set");
+		return;
+	}
+	if (!(port = getenvp(job->env, "SLURM_PTY_PORT"))) {
+		error("SLURM_PTY_PORT env var not set");
+		return;
+	}
+	if (!(cols = getenvp(job->env, "SLURM_PTY_WIN_COL")))
+		error("SLURM_PTY_WIN_COL env var not set");
+	if (!(rows = getenvp(job->env, "SLURM_PTY_WIN_ROW")))
+		error("SLURM_PTY_WIN_ROW env var not set");
+
+	if (rows && cols) {
+		struct winsize ws;
+		ws.ws_col = atoi(cols);
+		ws.ws_row = atoi(rows);
+		debug("init pty size %u:%u", ws.ws_row, ws.ws_col);
+		if (ioctl(task->to_stdin, TIOCSWINSZ, &ws))
+			error("ioctl(TIOCSWINSZ): %s");
+	}
+
+	port_u = atoi(port);
+	slurm_set_addr(&pty_addr, port_u, host);
+	pty_fd = slurm_open_msg_conn(&pty_addr);
+	if (pty_fd < 0) {
+		error("slurm_open_msg_conn(pty_conn) %s,%u: %m",
+			host, port_u);
+		return;
+	}
+
+	win_info = xmalloc(sizeof(struct window_info));
+	win_info->task   = task;
+	win_info->job    = job;
+	win_info->pty_fd = pty_fd;
+	slurm_attr_init(&attr);
+	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	if (pthread_create(&win_id, &attr, &_window_manager, (void *) win_info))
+		error("pthread_create(pty_conn): %m");
+}
+#endif
+
 /**********************************************************************
  * General fuctions
  **********************************************************************/
@@ -663,17 +802,56 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job)
 	int file_flags;
 
 	/* set files for opening stdout/err */
-	conf = slurm_conf_lock();
-	if (conf->job_file_append)
+	if (job->open_mode == OPEN_MODE_APPEND)
 		file_flags = O_CREAT|O_WRONLY|O_APPEND;
-	else
+	else if (job->open_mode == OPEN_MODE_TRUNCATE)
 		file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC;
-	slurm_conf_unlock();
+	else {
+		conf = slurm_conf_lock();
+		if (conf->job_file_append)
+			file_flags = O_CREAT|O_WRONLY|O_APPEND;
+		else
+			file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC;
+		slurm_conf_unlock();
+	}
 
 	/*
 	 *  Initialize stdin
 	 */
+#ifdef HAVE_PTY_H
+	if (job->pty) {
+		/* All of the stdin fails unless EVERY
+		 * task gets an eio object for stdin.
+		 * Its not clear why that is. */
+		if (task->gtid == 0) {
+			int amaster, aslave;
+			debug("  stdin uses a pty object");
+			if (openpty(&amaster, &aslave, NULL, NULL, NULL) < 0) {
+				error("stdin openpty: %m");
+				return SLURM_ERROR;
+			}
+			task->stdin_fd = aslave;
+			fd_set_close_on_exec(task->stdin_fd);
+			task->to_stdin = amaster;
+			fd_set_close_on_exec(task->to_stdin);
+			fd_set_nonblocking(task->to_stdin);
+			_spawn_window_manager(task, job);
+			task->in = _create_task_in_eio(task->to_stdin, job);
+			eio_new_initial_obj(job->eio, (void *)task->in);
+		} else {
+			xfree(task->ifname);
+			task->ifname = xstrdup("/dev/null");
+			task->stdin_fd = open("/dev/null", O_RDWR);
+			fd_set_close_on_exec(task->stdin_fd);
+			task->to_stdin = dup(task->stdin_fd);
+			fd_set_nonblocking(task->to_stdin);
+			task->in = _create_task_in_eio(task->to_stdin, job);
+			eio_new_initial_obj(job->eio, (void *)task->in);
+		}
+	} else if (task->ifname != NULL) {
+#else
 	if (task->ifname != NULL) {
+#endif
 		/* open file on task's stdin */
 		debug5("  stdin file name = %s", task->ifname);
 		if ((task->stdin_fd = open(task->ifname, O_RDONLY)) == -1) {
@@ -702,7 +880,29 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job)
 	/*
 	 *  Initialize stdout
 	 */
+#ifdef HAVE_PTY_H
+	if (job->pty) {
+		if (task->gtid == 0) {
+			task->stdout_fd = dup(task->stdin_fd);
+			fd_set_close_on_exec(task->stdout_fd);
+			task->from_stdout = dup(task->to_stdin);
+			fd_set_close_on_exec(task->from_stdout);
+			fd_set_nonblocking(task->from_stdout);
+			task->out = _create_task_out_eio(task->from_stdout,
+						 SLURM_IO_STDOUT, job, task);
+			list_append(job->stdout_eio_objs, (void *)task->out);
+			eio_new_initial_obj(job->eio, (void *)task->out);
+		} else {
+			xfree(task->ofname);
+			task->ofname = xstrdup("/dev/null");
+			task->stdout_fd = open("/dev/null", O_RDWR);
+			fd_set_close_on_exec(task->stdout_fd);
+			task->from_stdout = -1;  /* not used */
+		}
+	} else if (task->ofname != NULL) {
+#else
 	if (task->ofname != NULL) {
+#endif
 		/* open file on task's stdout */
 		debug5("  stdout file name = %s", task->ofname);
 		task->stdout_fd = open(task->ofname, file_flags, 0666);
@@ -710,8 +910,7 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job)
 			error("Could not open stdout file: %m");
 			xfree(task->ofname);
 			task->ofname = fname_create(job, "slurm-%J.out", 0);
-			task->stdout_fd = open(task->ofname, 
-				O_CREAT|O_WRONLY|O_TRUNC|O_APPEND, 0666);
+			task->stdout_fd = open(task->ofname, file_flags, 0666);
 			if (task->stdout_fd == -1)
 				return SLURM_ERROR;
 		}
@@ -739,7 +938,29 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job)
 	/*
 	 *  Initialize stderr
 	 */
+#ifdef HAVE_PTY_H
+	if (job->pty) {
+		if (task->gtid == 0) {
+			task->stderr_fd = dup(task->stdin_fd);
+			fd_set_close_on_exec(task->stderr_fd);
+			task->from_stderr = dup(task->to_stdin);
+			fd_set_close_on_exec(task->from_stderr);
+			fd_set_nonblocking(task->from_stderr);
+			task->err = _create_task_out_eio(task->from_stderr,
+						 SLURM_IO_STDERR, job, task);
+			list_append(job->stderr_eio_objs, (void *)task->err);
+			eio_new_initial_obj(job->eio, (void *)task->err);
+		} else {
+			xfree(task->efname);
+			task->efname = xstrdup("/dev/null");
+			task->stderr_fd = open("/dev/null", O_RDWR);
+			fd_set_close_on_exec(task->stderr_fd);
+			task->from_stderr = -1;  /* not used */
+		}
+	} else if (task->efname != NULL) {
+#else
 	if (task->efname != NULL) {
+#endif
 		/* open file on task's stdout */
 		debug5("  stderr file name = %s", task->efname);
 		task->stderr_fd = open(task->efname, file_flags, 0666);
@@ -747,8 +968,7 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job)
 			error("Could not open stderr file: %m");
 			xfree(task->efname);
 			task->efname = fname_create(job, "slurm-%J.err", 0);
-			task->stderr_fd = open(task->efname,
-				O_CREAT|O_WRONLY|O_TRUNC|O_APPEND, 0666);
+			task->stderr_fd = open(task->efname, file_flags, 0666);
 			if (task->stderr_fd == -1)
 				return SLURM_ERROR;
 		}
diff --git a/src/slurmd/slurmstepd/io.h b/src/slurmd/slurmstepd/io.h
index 72d4e5a5729f227a23b38b87ee0dfefc129978f4..e1adb77f0dfd91b5526940214eccc2aa0d31dc6b 100644
--- a/src/slurmd/slurmstepd/io.h
+++ b/src/slurmd/slurmstepd/io.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmstepd/io.h - slurmstepd standard IO routines
- * $Id: io.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: io.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c
index 494dc360bb67690a843ff16b25f1d606a2972762..c468c7bf54982251b998707f5df987440b46a6c6 100644
--- a/src/slurmd/slurmstepd/mgr.c
+++ b/src/slurmd/slurmstepd/mgr.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/slurmd/slurmstepd/mgr.c - job manager functions for slurmstepd
- *  $Id: mgr.c 13414 2008-02-28 23:22:33Z da $
+ *  $Id: mgr.c 13971 2008-05-02 20:23:00Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -82,7 +82,7 @@
 #include "src/common/node_select.h"
 #include "src/common/fd.h"
 #include "src/common/safeopen.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobacct_gather.h"
 #include "src/common/switch.h"
 #include "src/common/xsignal.h"
 #include "src/common/xstring.h"
@@ -158,6 +158,7 @@ typedef struct kill_thread {
 /* 
  * Job manager related prototypes
  */
+static int  _access(const char *path, int modes, uid_t uid, gid_t gid);
 static void _send_launch_failure(launch_tasks_request_msg_t *, 
                                  slurm_addr *, int);
 static int  _fork_all_tasks(slurmd_job_t *job);
@@ -342,7 +343,7 @@ _setup_normal_io(slurmd_job_t *job)
 
 	/*
 	 * Temporarily drop permissions, initialize task stdio file
-	 * decriptors (which may be connected to files), then
+	 * descriptors (which may be connected to files), then
 	 * reclaim privileges.
 	 */
 	if (_drop_privileges(job, true, &sprivs) < 0)
@@ -511,11 +512,11 @@ _one_step_complete_msg(slurmd_job_t *job, int first, int last)
 	msg.range_first = first;
 	msg.range_last = last;
 	msg.step_rc = step_complete.step_rc;
-	msg.jobacct = jobacct_g_alloc(NULL);
+	msg.jobacct = jobacct_gather_g_create(NULL);
 	/************* acct stuff ********************/
 	if(!acct_sent) {
-		jobacct_g_aggregate(step_complete.jobacct, job->jobacct);
-		jobacct_g_getinfo(step_complete.jobacct, JOBACCT_DATA_TOTAL, 
+		jobacct_gather_g_aggregate(step_complete.jobacct, job->jobacct);
+		jobacct_gather_g_getinfo(step_complete.jobacct, JOBACCT_DATA_TOTAL, 
 				  msg.jobacct);
 		acct_sent = true;
 	}
@@ -560,7 +561,7 @@ _one_step_complete_msg(slurmd_job_t *job, int first, int last)
 		error("Rank %d failed sending step completion message"
 		      " directly to slurmctld", step_complete.rank);
 finished:
-	jobacct_g_free(msg.jobacct);
+	jobacct_gather_g_destroy(msg.jobacct);
 }
 
 /* Given a starting bit in the step_complete.bits bitstring, "start",
@@ -670,7 +671,7 @@ job_manager(slurmd_job_t *job)
 	    || slurmd_task_init() != SLURM_SUCCESS
 	    || mpi_hook_slurmstepd_init(&job->env) != SLURM_SUCCESS
 	    || slurm_proctrack_init() != SLURM_SUCCESS
-	    || jobacct_init() != SLURM_SUCCESS) {
+	    || slurm_jobacct_gather_init() != SLURM_SUCCESS) {
 		rc = SLURM_FAILURE;
 		goto fail1;
 	}
@@ -733,7 +734,7 @@ job_manager(slurmd_job_t *job)
 	_send_launch_resp(job, 0);
 
 	_wait_for_all_tasks(job);
-	jobacct_g_endpoll();
+	jobacct_gather_g_endpoll();
 		
 	job->state = SLURMSTEPD_STEP_ENDING;
 
@@ -913,7 +914,7 @@ _fork_all_tasks(slurmd_job_t *job)
 				if (j > i)
 					close(readfds[j]);
 			}
-			/* jobacct_g_endpoll();	
+			/* jobacct_gather_g_endpoll();	
 			 * closing jobacct files here causes deadlock */
 
 			if (conf->propagate_prio == 1)
@@ -966,19 +967,26 @@ _fork_all_tasks(slurmd_job_t *job)
 
 	for (i = 0; i < job->ntasks; i++) {
 		/*
-                 * Put this task in the step process group
-                 */
-                if (setpgid (job->task[i]->pid, job->pgid) < 0)
-                        error ("Unable to put task %d (pid %ld) into pgrp %ld",
-                               i, job->task[i]->pid, job->pgid);
-
-                if (slurm_container_add(job, job->task[i]->pid) == SLURM_ERROR) {
-                        error("slurm_container_create: %m");
+		 * Put this task in the step process group
+		 * login_tty() must put task zero in its own
+		 * session, causing setpgid() to fail, setsid()
+		 * has already set its process group as desired
+		 */
+		if ((job->pty == 0)
+		&&  (setpgid (job->task[i]->pid, job->pgid) < 0)) {
+			error("Unable to put task %d (pid %ld) into "
+				"pgrp %ld: %m",
+				i, job->task[i]->pid, job->pgid);
+		}
+
+                if (slurm_container_add(job, job->task[i]->pid)
+		    == SLURM_ERROR) {
+                        error("slurm_container_add: %m");
 			goto fail1;
                 }
 		jobacct_id.nodeid = job->nodeid;
 		jobacct_id.taskid = job->task[i]->gtid;
-		jobacct_g_add_task(job->task[i]->pid, 
+		jobacct_gather_g_add_task(job->task[i]->pid, 
 				   &jobacct_id);
 
 		if (spank_task_post_fork (job, i) < 0) {
@@ -986,8 +994,8 @@ _fork_all_tasks(slurmd_job_t *job)
 			return SLURM_ERROR;
 		}
 	}
-	jobacct_g_set_proctrack_container_id(job->cont_id);
-
+	jobacct_gather_g_set_proctrack_container_id(job->cont_id);
+	
 	/*
 	 * Now it's ok to unblock the tasks, so they may call exec.
 	 */
@@ -1108,12 +1116,12 @@ _wait_for_any_task(slurmd_job_t *job, bool waitflag)
 		}
 
 		/************* acct stuff ********************/
-		jobacct = jobacct_g_remove_task(pid);
+		jobacct = jobacct_gather_g_remove_task(pid);
 		if(jobacct) {
-			jobacct_g_setinfo(jobacct, 
-					  JOBACCT_DATA_RUSAGE, &rusage);
-			jobacct_g_aggregate(job->jobacct, jobacct);
-			jobacct_g_free(jobacct);
+			jobacct_gather_g_setinfo(jobacct, 
+						 JOBACCT_DATA_RUSAGE, &rusage);
+			jobacct_gather_g_aggregate(job->jobacct, jobacct);
+			jobacct_gather_g_destroy(jobacct);
 		} 		
 		/*********************************************/	
 	
@@ -1141,7 +1149,7 @@ _wait_for_any_task(slurmd_job_t *job, bool waitflag)
 			if (job->task_epilog) {
 				_run_script_as_user("user task_epilog",
 						    job->task_epilog,
-						    job, 2, job->env);
+						    job, 5, job->env);
 			}
 			if (conf->task_epilog) {
 				char *my_epilog;
@@ -1671,6 +1679,34 @@ _initgroups(slurmd_job_t *job)
 	return 0;
 }
 
+/*
+ * Check this user's access rights to a file
+ * path IN: pathname of file to test
+ * modes IN: desired access
+ * uid IN: user ID to access the file
+ * gid IN: group ID to access the file
+ * RET 0 on success, -1 on failure
+ */
+static int _access(const char *path, int modes, uid_t uid, gid_t gid)
+{
+	struct stat buf;
+	int f_mode;
+
+	if (stat(path, &buf) != 0)
+		return -1;
+
+	if (buf.st_uid == uid)
+		f_mode = (buf.st_mode >> 6) & 07;
+	else if (buf.st_gid == gid)
+		f_mode = (buf.st_mode >> 3) & 07;
+	else
+		f_mode = buf.st_mode & 07;
+
+	if ((f_mode & modes) == modes)
+		return 0;
+	return -1;
+}
+
 /*
  * Run a script as a specific user, with the specified uid, gid, and 
  * extended groups.
@@ -1697,8 +1733,8 @@ _run_script_as_user(const char *name, const char *path, slurmd_job_t *job,
 
 	debug("[job %u] attempting to run %s [%s]", job->jobid, name, path);
 
-	if (access(path, R_OK | X_OK) < 0) {
-		error("Could not run %s [%s]: %m", name, path);
+	if (_access(path, 5, job->pwd->pw_uid, job->pwd->pw_gid) < 0) {
+		error("Could not run %s [%s]: access denied", name, path);
 		return -1;
 	}
 
@@ -1729,7 +1765,11 @@ _run_script_as_user(const char *name, const char *path, slurmd_job_t *job,
 		}
 
 		chdir(job->cwd);
+#ifdef SETPGRP_TWO_ARGS
+		setpgrp(0, 0);
+#else
 		setpgrp();
+#endif
 		execve(path, argv, env);
 		error("execve(): %m");
 		exit(127);
diff --git a/src/slurmd/slurmstepd/mgr.h b/src/slurmd/slurmstepd/mgr.h
index 38d183bb1415dc5e8505908016531b9538c0ed99..2efa3be73d639e8503d7ebb837a239e874644b3e 100644
--- a/src/slurmd/slurmstepd/mgr.h
+++ b/src/slurmd/slurmstepd/mgr.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/multi_prog.c b/src/slurmd/slurmstepd/multi_prog.c
index 6a1c2e8fd2efcb9e264582b133a05fef160947b3..3dfd090f8e0ef138c1efba267f1d21b895ea4d94 100644
--- a/src/slurmd/slurmstepd/multi_prog.c
+++ b/src/slurmd/slurmstepd/multi_prog.c
@@ -11,7 +11,7 @@
  *  and
  *  Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>,
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -142,11 +142,11 @@ extern int
 multi_prog_get_argv(char *file_contents, char **prog_env, int task_rank,
 		    int *argc, char ***argv)
 {
-	char *line;
+	char *line = NULL;
 	int line_num = 0;
 	int task_offset;
-	char *p, *s, *ptrptr;
-	char *rank_spec, *args_spec;
+	char *p = NULL, *s = NULL, *ptrptr = NULL;
+	char *rank_spec = NULL, *args_spec = NULL;
 	int prog_argc = 0;
 	char **prog_argv = NULL;
 	char *local_data = NULL;
diff --git a/src/slurmd/slurmstepd/multi_prog.h b/src/slurmd/slurmstepd/multi_prog.h
index e262add27274c8acaed4ac15b088c167f3b4bd5d..a36256b6f20463aaf87ccad3b456c1f229a60f9c 100644
--- a/src/slurmd/slurmstepd/multi_prog.h
+++ b/src/slurmd/slurmstepd/multi_prog.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/pam_ses.c b/src/slurmd/slurmstepd/pam_ses.c
index 2e25621cf7457567345f4917e4ed7f8ba0e6a755..c754492fe069ec2ae0b97b33287fba4e5d453bea 100644
--- a/src/slurmd/slurmstepd/pam_ses.c
+++ b/src/slurmd/slurmstepd/pam_ses.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Donna Mecozzi <dmecozzi@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/pam_ses.h b/src/slurmd/slurmstepd/pam_ses.h
index 2c0092a58aaf731b4bcef0fea5d54473e6a7cdef..f933cc27744ec4a4e2cca6eef29799e92a859c63 100644
--- a/src/slurmd/slurmstepd/pam_ses.h
+++ b/src/slurmd/slurmstepd/pam_ses.h
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Donna Mecozzi <dmecozzi@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/pdebug.c b/src/slurmd/slurmstepd/pdebug.c
index 4917d689e0efeb1b5e71b55a9622c40b4794041a..59a26f87d1e5443d80dd7a71fb7dab8084b3c844 100644
--- a/src/slurmd/slurmstepd/pdebug.c
+++ b/src/slurmd/slurmstepd/pdebug.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/pdebug.h b/src/slurmd/slurmstepd/pdebug.h
index c6ae9a02715e5c9ead4e67e684ac42e1377b59a2..228dcfb0293585b03fb02c7abe0dec6f6f9c7465 100644
--- a/src/slurmd/slurmstepd/pdebug.h
+++ b/src/slurmd/slurmstepd/pdebug.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/req.c b/src/slurmd/slurmstepd/req.c
index fc744d250dbb854795880be70a804b7562535a7a..110083f7ea3e5712bc43e2c7cbcc832998ee2acb 100644
--- a/src/slurmd/slurmstepd/req.c
+++ b/src/slurmd/slurmstepd/req.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/slurmd/slurmstepd/req.c - slurmstepd domain socket request handling
- *  $Id: req.c 13322 2008-02-21 19:06:27Z da $
+ *  $Id: req.c 13959 2008-04-30 21:00:47Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -53,7 +53,7 @@
 #include "src/common/fd.h"
 #include "src/common/eio.h"
 #include "src/common/slurm_auth.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobacct_gather.h"
 #include "src/common/stepd_api.h"
 
 #include "src/slurmd/slurmd/slurmd.h"
@@ -72,6 +72,7 @@ static int _handle_info(int fd, slurmd_job_t *job);
 static int _handle_signal_process_group(int fd, slurmd_job_t *job, uid_t uid);
 static int _handle_signal_task_local(int fd, slurmd_job_t *job, uid_t uid);
 static int _handle_signal_container(int fd, slurmd_job_t *job, uid_t uid);
+static int _handle_checkpoint_tasks(int fd, slurmd_job_t *job, uid_t uid);
 static int _handle_attach(int fd, slurmd_job_t *job, uid_t uid);
 static int _handle_pid_in_container(int fd, slurmd_job_t *job);
 static int _handle_daemon_pid(int fd, slurmd_job_t *job);
@@ -384,7 +385,7 @@ _handle_accept(void *arg)
 		free_buf(buffer);
 		goto fail;
 	}
-	rc = g_slurm_auth_verify(auth_cred, NULL, 2);
+	rc = g_slurm_auth_verify(auth_cred, NULL, 2, NULL);
 	if (rc != SLURM_SUCCESS) {
 		error("Verifying authentication credential: %s",
 		      g_slurm_auth_errstr(g_slurm_auth_errno(auth_cred)));
@@ -394,8 +395,8 @@ _handle_accept(void *arg)
 	}
 
 	/* Get the uid & gid from the credential, then destroy it. */
-	uid = g_slurm_auth_get_uid(auth_cred);
-	gid = g_slurm_auth_get_gid(auth_cred);
+	uid = g_slurm_auth_get_uid(auth_cred, NULL);
+	gid = g_slurm_auth_get_gid(auth_cred, NULL);
 	debug3("  Identity: uid=%d, gid=%d", uid, gid);
 	g_slurm_auth_destroy(auth_cred);
 	free_buf(buffer);
@@ -464,6 +465,10 @@ _handle_request(int fd, slurmd_job_t *job, uid_t uid, gid_t gid)
 		debug("Handling REQUEST_SIGNAL_CONTAINER");
 		rc = _handle_signal_container(fd, job, uid);
 		break;
+	case REQUEST_CHECKPOINT_TASKS:
+		debug("Handling REQUEST_CHECKPOINT_TASKS");
+		rc = _handle_checkpoint_tasks(fd, job, uid);
+		break;
 	case REQUEST_STATE:
 		debug("Handling REQUEST_STATE");
 		rc = _handle_state(fd, job);
@@ -540,6 +545,7 @@ _handle_info(int fd, slurmd_job_t *job)
 	safe_write(fd, &job->jobid, sizeof(uint32_t));
 	safe_write(fd, &job->stepid, sizeof(uint32_t));
 	safe_write(fd, &job->nodeid, sizeof(uint32_t));
+	safe_write(fd, &job->job_mem, sizeof(uint32_t));
 
 	return SLURM_SUCCESS;
 rwfail:
@@ -714,6 +720,29 @@ _handle_signal_container(int fd, slurmd_job_t *job, uid_t uid)
 	/*
 	 * Signal the container
 	 */
+	if (job->nodeid == 0) {
+		static int msg_sent = 0;
+		/* Not really errors, 
+		 * but we want messages displayed by default */
+		if (msg_sent)
+			;
+		else if (sig == SIGXCPU) {
+			error("*** JOB CANCELLED DUE TO TIME LIMIT ***");
+			msg_sent = 1;
+		} else if (sig == SIG_NODE_FAIL) {
+			error("*** JOB CANCELLED DUE TO NODE FAILURE ***");
+			msg_sent = 1;
+		} else if (sig == SIG_FAILURE) {
+			error("*** JOB CANCELLED DUE TO SYSTEM FAILURE ***");
+			msg_sent = 1;
+		} else if ((sig == SIGTERM) || (sig == SIGKILL)) {
+			error("*** JOB CANCELLED ***");
+			msg_sent = 1;
+		}
+	}
+	if ((sig == SIG_NODE_FAIL) || (sig == SIG_FAILURE))
+		goto done;
+
 	pthread_mutex_lock(&suspend_mutex);
 	if (suspended) {
 		rc = -1;
@@ -742,6 +771,76 @@ rwfail:
 	return SLURM_FAILURE;
 }
 
+static int
+_handle_checkpoint_tasks(int fd, slurmd_job_t *job, uid_t uid)
+{
+	static time_t last_timestamp = 0;
+	int rc = SLURM_SUCCESS;
+	int signal;
+	time_t timestamp;
+
+	debug3("_handle_checkpoint_tasks for job %u.%u",
+	       job->jobid, job->stepid);
+
+	safe_read(fd, &signal, sizeof(int));
+	safe_read(fd, &timestamp, sizeof(time_t));
+
+	debug3("  uid = %d", uid);
+	if (uid != job->uid && !_slurm_authorized_user(uid)) {
+		debug("checkpoint req from uid %ld for job %u.%u owned by uid %ld",
+		      (long)uid, job->jobid, job->stepid, (long)job->uid);
+		rc = EPERM;
+		goto done;
+	}
+
+	if (timestamp == last_timestamp) {
+		debug("duplicate checkpoint req for job %u.%u, timestamp %ld. discarded.",
+		      job->jobid, job->stepid, (long)timestamp);
+		rc = ESLURM_ALREADY_DONE; /* EINPROGRESS? */
+		goto done;
+	}
+
+       /*
+        * Sanity checks
+        */
+       if (job->pgid <= (pid_t)1) {
+               debug ("step %u.%u invalid [jmgr_pid:%d pgid:%u]",
+                       job->jobid, job->stepid, job->jmgr_pid, job->pgid);
+               rc = ESLURMD_JOB_NOTRUNNING;
+               goto done;
+       }
+
+       /*
+        * Signal the process group
+        */
+       pthread_mutex_lock(&suspend_mutex);
+       if (suspended) {
+               rc = ESLURMD_STEP_SUSPENDED;
+               pthread_mutex_unlock(&suspend_mutex);
+               goto done;
+       }
+
+       /* TODO: send timestamp with signal */
+       if (killpg(job->pgid, signal) == -1) {
+               rc = -1;        /* Most probable ESRCH, resulting in ESLURMD_JOB_NOTRUNNING */
+               verbose("Error sending signal %d to %u.%u, pgid %d, errno: %d: %s",
+                       signal, job->jobid, job->stepid, job->pgid,
+                       errno, slurm_strerror(rc));
+       } else {
+               last_timestamp = timestamp;
+               verbose("Sent signal %d to %u.%u, pgid %d",
+                       signal, job->jobid, job->stepid, job->pgid);
+       }
+       pthread_mutex_unlock(&suspend_mutex);
+
+done:
+       /* Send the return code */
+       safe_write(fd, &rc, sizeof(int));
+       return SLURM_SUCCESS;
+rwfail:
+       return SLURM_FAILURE;
+}
+
 static int
 _handle_terminate(int fd, slurmd_job_t *job, uid_t uid)
 {
@@ -933,7 +1032,15 @@ _handle_suspend(int fd, slurmd_job_t *job, uid_t uid)
 		goto done;
 	}
 
-	jobacct_g_suspend_poll();
+	if (cont_id == 0) {
+		debug ("step %u.%u invalid container [cont_id:%u]",
+			job->jobid, job->stepid, job->cont_id);
+		rc = -1;
+		errnum = ESLURMD_JOB_NOTRUNNING;
+		goto done;
+	}
+
+	jobacct_gather_g_suspend_poll();
 
 	/*
 	 * Signal the container
@@ -990,7 +1097,15 @@ _handle_resume(int fd, slurmd_job_t *job, uid_t uid)
 		goto done;
 	}
 
-	jobacct_g_resume_poll();
+	if (job->cont_id == 0) {
+		debug ("step %u.%u invalid container [cont_id:%u]",
+			job->jobid, job->stepid, job->cont_id);
+		rc = -1;
+		errnum = ESLURMD_JOB_NOTRUNNING;
+		goto done;
+	}
+
+	jobacct_gather_g_resume_poll();
 	/*
 	 * Signal the container
 	 */
@@ -1049,8 +1164,8 @@ _handle_completion(int fd, slurmd_job_t *job, uid_t uid)
 	safe_read(fd, &first, sizeof(int));
 	safe_read(fd, &last, sizeof(int));
 	safe_read(fd, &step_rc, sizeof(int));
-	jobacct = jobacct_g_alloc(NULL);
-	jobacct_g_getinfo(jobacct, JOBACCT_DATA_PIPE, &fd);	
+	jobacct = jobacct_gather_g_create(NULL);
+	jobacct_gather_g_getinfo(jobacct, JOBACCT_DATA_PIPE, &fd);	
 	
 	/*
 	 * Record the completed nodes
@@ -1075,9 +1190,9 @@ _handle_completion(int fd, slurmd_job_t *job, uid_t uid)
 	step_complete.step_rc = MAX(step_complete.step_rc, step_rc);
 	
 	/************* acct stuff ********************/
-	jobacct_g_aggregate(step_complete.jobacct, jobacct);
+	jobacct_gather_g_aggregate(step_complete.jobacct, jobacct);
 timeout:
-	jobacct_g_free(jobacct);
+	jobacct_gather_g_destroy(jobacct);
 	/*********************************************/
 	
 	/* Send the return code and errno, we do this within the locked
@@ -1109,24 +1224,24 @@ _handle_stat_jobacct(int fd, slurmd_job_t *job, uid_t uid)
 		      "owned by uid %ld",
 		      (long)uid, job->jobid, job->stepid, (long)job->uid);
 		/* Send NULL */
-		jobacct_g_setinfo(jobacct, JOBACCT_DATA_PIPE, &fd);	
+		jobacct_gather_g_setinfo(jobacct, JOBACCT_DATA_PIPE, &fd);
 		return SLURM_ERROR;
 	}
 	
-	jobacct = jobacct_g_alloc(NULL);
+	jobacct = jobacct_gather_g_create(NULL);
 	debug3("num tasks = %d", job->ntasks);
 	
 	for (i = 0; i < job->ntasks; i++) {
-		temp_jobacct = jobacct_g_stat_task(job->task[i]->pid);
+		temp_jobacct = jobacct_gather_g_stat_task(job->task[i]->pid);
 		if(temp_jobacct) {
-			jobacct_g_aggregate(jobacct, temp_jobacct);
-			jobacct_g_free(temp_jobacct);
+			jobacct_gather_g_aggregate(jobacct, temp_jobacct);
+			jobacct_gather_g_destroy(temp_jobacct);
 			num_tasks++;
 		}
 	}
-	jobacct_g_setinfo(jobacct, JOBACCT_DATA_PIPE, &fd);
+	jobacct_gather_g_setinfo(jobacct, JOBACCT_DATA_PIPE, &fd);
 	safe_write(fd, &num_tasks, sizeof(int));
-	jobacct_g_free(jobacct);
+	jobacct_gather_g_destroy(jobacct);
 	return SLURM_SUCCESS;
 rwfail:
 	return SLURM_ERROR;
diff --git a/src/slurmd/slurmstepd/req.h b/src/slurmd/slurmstepd/req.h
index 5a041309bed1dbdf6bc30c41155685a2a7a69d3b..cc63c6fdbad9bcb3462049a10e2e260f8e457832 100644
--- a/src/slurmd/slurmstepd/req.h
+++ b/src/slurmd/slurmstepd/req.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/slurmd/slurmstepd/req.h - slurmstepd request handling
- *  $Id: req.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: req.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/slurmstepd.c b/src/slurmd/slurmstepd/slurmstepd.c
index 0a293d339c57f2b7657c6f6c0eefa4acc8b2e1e6..40d126f71dae9aa32945ac5aba1c01343b0bf004 100644
--- a/src/slurmd/slurmstepd/slurmstepd.c
+++ b/src/slurmd/slurmstepd/slurmstepd.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  src/slurmd/slurmstepd/slurmstepd.c - SLURM job-step manager.
- *  $Id: slurmstepd.c 11602 2007-06-01 01:01:25Z morrone $
+ *  $Id: slurmstepd.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov> 
  *  and Christopher Morrone <morrone2@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -47,7 +47,7 @@
 
 #include "src/common/xmalloc.h"
 #include "src/common/xsignal.h"
-#include "src/common/slurm_jobacct.h"
+#include "src/common/slurm_jobacct_gather.h"
 #include "src/common/switch.h"
 #include "src/common/stepd_api.h"
 
@@ -182,6 +182,8 @@ _init_from_slurmd(int sock, char **argv,
 	slurm_msg_t *msg = NULL;
 	int ngids = 0;
 	gid_t *gids = NULL;
+	uint16_t port;
+	char buf[16];
 
 	/* receive job type from slurmd */
 	safe_read(sock, &step_type, sizeof(int));
@@ -196,7 +198,7 @@ _init_from_slurmd(int sock, char **argv,
 	safe_read(sock, &step_complete.max_depth, sizeof(int));
 	safe_read(sock, &step_complete.parent_addr, sizeof(slurm_addr));
 	step_complete.bits = bit_alloc(step_complete.children);
-	step_complete.jobacct = jobacct_g_alloc(NULL);
+	step_complete.jobacct = jobacct_gather_g_create(NULL);
 	pthread_mutex_unlock(&step_complete.lock);
 
 	/* receive conf from slurmd */
@@ -230,17 +232,13 @@ _init_from_slurmd(int sock, char **argv,
 
 	log_init(argv[0], conf->log_opts, LOG_DAEMON, conf->logfile);
 	/* acct info */
-	jobacct_g_startpoll(conf->job_acct_freq);
+	jobacct_gather_g_startpoll(conf->job_acct_gather_freq);
 	
 	switch_g_slurmd_step_init();
 
-	{
-		uint16_t port;
-		char buf[16];
-		slurm_get_ip_str(&step_complete.parent_addr, &port, buf, 16);
-		debug3("slurmstepd rank %d, parent address = %s, port = %u",
-		       step_complete.rank, buf, port);
-	}
+	slurm_get_ip_str(&step_complete.parent_addr, &port, buf, 16);
+	debug3("slurmstepd rank %d, parent address = %s, port = %u",
+	       step_complete.rank, buf, port);
 
 	/* receive cli from slurmd */
 	safe_read(sock, &len, sizeof(int));
@@ -342,7 +340,7 @@ _step_setup(slurm_addr *cli, slurm_addr *self, slurm_msg_t *msg)
 		fatal("_step_setup: no job returned");
 	}
 	job->jmgr_pid = getpid();
-	job->jobacct = jobacct_g_alloc(NULL);
+	job->jobacct = jobacct_gather_g_create(NULL);
 	
 	return job;
 }
@@ -350,7 +348,7 @@ _step_setup(slurm_addr *cli, slurm_addr *self, slurm_msg_t *msg)
 static void
 _step_cleanup(slurmd_job_t *job, slurm_msg_t *msg, int rc)
 {
-	jobacct_g_free(job->jobacct);
+	jobacct_gather_g_destroy(job->jobacct);
 	if (!job->batch)
 		job_destroy(job);
 	/* 
@@ -369,7 +367,7 @@ _step_cleanup(slurmd_job_t *job, slurm_msg_t *msg, int rc)
 		fatal("handle_launch_message: Unrecognized launch RPC");
 		break;
 	}
-	jobacct_g_free(step_complete.jobacct);
+	jobacct_gather_g_destroy(step_complete.jobacct);
 	
 	xfree(msg);
 }
diff --git a/src/slurmd/slurmstepd/slurmstepd.h b/src/slurmd/slurmstepd/slurmstepd.h
index 2ef0cc40f5659ec31919fd66e1e9e6687ee525f7..d053aeb3c1815c9fe8345be64710c390fbb0443c 100644
--- a/src/slurmd/slurmstepd/slurmstepd.h
+++ b/src/slurmd/slurmstepd/slurmstepd.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmstepd/slurmstepd.h - slurmstepd general header file
- * $Id: slurmstepd.h 13322 2008-02-21 19:06:27Z da $
+ * $Id: slurmstepd.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/slurmstepd_job.c b/src/slurmd/slurmstepd/slurmstepd_job.c
index 122ac1549422edd90de8751045f21fc5f5be450f..e00850f62d931a769b991778393920e2aeaed062 100644
--- a/src/slurmd/slurmstepd/slurmstepd_job.c
+++ b/src/slurmd/slurmstepd/slurmstepd_job.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmstepd/slurmstepd_job.c - slurmd_job_t routines
- * $Id: slurmstepd_job.c 12580 2007-10-29 20:17:09Z jette $
+ * $Id: slurmstepd_job.c 13755 2008-04-01 19:12:53Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -54,6 +54,7 @@
 #include "src/common/fd.h"
 #include "src/common/log.h"
 #include "src/common/eio.h"
+#include "src/common/slurm_jobacct_gather.h"
 #include "src/common/slurm_protocol_api.h"
 
 #include "src/slurmd/slurmd/slurmd.h"
@@ -155,7 +156,7 @@ job_create(launch_tasks_request_msg_t *msg)
 	srun_info_t   *srun = NULL;
 	slurm_addr     resp_addr;
 	slurm_addr     io_addr;
-	int           nodeid = NO_VAL;
+	int            nodeid = NO_VAL;
 	
 	xassert(msg != NULL);
 	xassert(msg->complete_nodelist != NULL);
@@ -185,23 +186,33 @@ job_create(launch_tasks_request_msg_t *msg)
 		return NULL;
 	}
 	
-	job->state   = SLURMSTEPD_STEP_STARTING;
-	job->pwd     = pwd;
-	job->ntasks  = msg->tasks_to_launch[nodeid];
-	job->nprocs  = msg->nprocs;
-	job->jobid   = msg->job_id;
-	job->stepid  = msg->job_step_id;
+	job->state	= SLURMSTEPD_STEP_STARTING;
+	job->pwd	= pwd;
+	job->ntasks	= msg->tasks_to_launch[nodeid];
+	job->nprocs	= msg->nprocs;
+	job->jobid	= msg->job_id;
+	job->stepid	= msg->job_step_id;
+
+	job->job_mem	= msg->job_mem;
+	job->task_mem	= msg->task_mem;
+	if (job->job_mem)
+		jobacct_common_set_mem_limit(job->jobid, job->job_mem);
+	else if (job->task_mem && job->ntasks) {
+		jobacct_common_set_mem_limit(job->jobid, 
+					     (job->task_mem * job->ntasks));
+	}
 	
-	job->uid     = (uid_t) msg->uid;
-	job->gid     = (gid_t) msg->gid;
-	job->cwd     = xstrdup(msg->cwd);
-	job->task_dist  = msg->task_dist;
-	job->plane_size = msg->plane_size;
+	job->uid	= (uid_t) msg->uid;
+	job->gid	= (gid_t) msg->gid;
+	job->cwd	= xstrdup(msg->cwd);
+	job->task_dist	= msg->task_dist;
+	job->plane_size	= msg->plane_size;
 	
 	job->cpu_bind_type = msg->cpu_bind_type;
 	job->cpu_bind = xstrdup(msg->cpu_bind);
 	job->mem_bind_type = msg->mem_bind_type;
 	job->mem_bind = xstrdup(msg->mem_bind);
+	job->ckpt_path = xstrdup(msg->ckpt_path);
 
 	job->env     = _array_copy(msg->envc, msg->env);
 	job->eio     = eio_handle_create();
@@ -229,6 +240,7 @@ job_create(launch_tasks_request_msg_t *msg)
 	job->envtp->cpu_bind = NULL;
 	job->envtp->mem_bind_type = 0;
 	job->envtp->mem_bind = NULL;
+	job->envtp->ckpt_path = NULL;
 	
 	memcpy(&resp_addr, &msg->orig_addr, sizeof(slurm_addr));
 	slurm_set_addr(&resp_addr,
@@ -256,12 +268,15 @@ job_create(launch_tasks_request_msg_t *msg)
 	job->nodeid  = nodeid;
 	job->debug   = msg->slurmd_debug;
 	job->cpus    = msg->cpus_allocated[nodeid];
+	if (msg->acctg_freq != (uint16_t) NO_VAL)
+		jobacct_gather_g_change_poll(msg->acctg_freq);
 	job->multi_prog  = msg->multi_prog;
 	job->timelimit   = (time_t) -1;
 	job->task_flags  = msg->task_flags;
-	job->switch_job = msg->switch_job;
-
-	job->options =    msg->options;
+	job->switch_job  = msg->switch_job;
+	job->pty         = msg->pty;
+	job->open_mode   = msg->open_mode;
+	job->options     = msg->options;
 	
 	list_append(job->sruns, (void *) srun);
 
@@ -314,10 +329,18 @@ job_batch_job_create(batch_job_launch_msg_t *msg)
 	job->nprocs  = msg->nprocs;
 	job->jobid   = msg->job_id;
 	job->stepid  = msg->step_id;
+
+	job->job_mem = msg->job_mem;
+	if (job->job_mem)
+		jobacct_common_set_mem_limit(job->jobid, job->job_mem);
+
 	job->batch   = true;
+	if (msg->acctg_freq != (uint16_t) NO_VAL)
+		jobacct_gather_g_change_poll(msg->acctg_freq);
 	job->multi_prog = 0;
+	job->open_mode  = msg->open_mode;
 	job->overcommit = (bool) msg->overcommit;
-	job->node_name = xstrdup(conf->node_name);
+	job->node_name  = xstrdup(conf->node_name);
 
 	job->uid     = (uid_t) msg->uid;
 	job->gid     = (gid_t) msg->gid;
@@ -340,6 +363,7 @@ job_batch_job_create(batch_job_launch_msg_t *msg)
 	job->envtp->cpu_bind = NULL;
 	job->envtp->mem_bind_type = 0;
 	job->envtp->mem_bind = NULL;
+	job->envtp->ckpt_path = NULL;
 	
 	srun = srun_info_create(NULL, NULL, NULL);
 
diff --git a/src/slurmd/slurmstepd/slurmstepd_job.h b/src/slurmd/slurmstepd/slurmstepd_job.h
index 1da6d9678be956234894a0377178581b528595fa..5b0a653efb9911c483403ec13d1c52a3ef2dde08 100644
--- a/src/slurmd/slurmstepd/slurmstepd_job.h
+++ b/src/slurmd/slurmstepd/slurmstepd_job.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  src/slurmd/slurmstepd/slurmstepd_job.h  slurmd_job_t definition
- *  $Id: slurmstepd_job.h 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: slurmstepd_job.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -117,6 +117,8 @@ typedef struct slurmd_job {
 	uint32_t       nodeid; /* relative position of this node in job     */
 	uint32_t       ntasks; /* number of tasks on *this* node            */
 	uint32_t       debug;  /* debug level for job slurmd                */
+	uint32_t       job_mem;  /* MB of memory reserved for the job       */
+	uint32_t       task_mem; /* MB of memory reserved for each task     */ 
 	uint16_t       cpus;   /* number of cpus to use for this job        */
 	uint16_t       argc;   /* number of commandline arguments           */
 	char         **env;    /* job environment                           */
@@ -188,8 +190,10 @@ typedef struct slurmd_job {
 
 	char          *batchdir;
 	jobacctinfo_t *jobacct;
-
+	uint8_t        open_mode;	/* stdout/err append or truncate */
+	uint8_t        pty;		/* set if creating pseudo tty       */
 	job_options_t  options;
+	char          *ckpt_path;
 } slurmd_job_t;
 
 
diff --git a/src/slurmd/slurmstepd/step_terminate_monitor.c b/src/slurmd/slurmstepd/step_terminate_monitor.c
index 9b01edd913f9ea2034eb50d0870f464f297bd53b..3438374f82389da12397cf924de2317c7ab71dd6 100644
--- a/src/slurmd/slurmstepd/step_terminate_monitor.c
+++ b/src/slurmd/slurmstepd/step_terminate_monitor.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,6 +56,7 @@ static int call_external_program(void);
 void step_terminate_monitor_start(uint32_t jobid, uint32_t stepid)
 {
 	slurm_ctl_conf_t *conf;
+	pthread_attr_t attr;
 
 	pthread_mutex_lock(&lock);
 
@@ -75,7 +76,9 @@ void step_terminate_monitor_start(uint32_t jobid, uint32_t stepid)
 	program_name = xstrdup(conf->unkillable_program);
 	slurm_conf_unlock();
 
-	pthread_create(&tid, NULL, monitor, NULL);
+	slurm_attr_init(&attr);
+	pthread_create(&tid, &attr, monitor, NULL);
+	slurm_attr_destroy(&attr);
 	running_flag = 1;
 	recorded_jobid = jobid;
 	recorded_stepid = stepid;
diff --git a/src/slurmd/slurmstepd/step_terminate_monitor.h b/src/slurmd/slurmstepd/step_terminate_monitor.h
index d2c8ce56d4e1db712d328249787d86da355d0449..ee2caf4be952cf6576f65dfddd5b5c07efabb7d5 100644
--- a/src/slurmd/slurmstepd/step_terminate_monitor.h
+++ b/src/slurmd/slurmstepd/step_terminate_monitor.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Christopher J. Morrone <morrone2@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/task.c b/src/slurmd/slurmstepd/task.c
index f8909617a270c2e634a4a50ed7170f742004958d..c38df2e2c470494953e7ce69faa9a1fdd8f638d0 100644
--- a/src/slurmd/slurmstepd/task.c
+++ b/src/slurmd/slurmstepd/task.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  slurmd/slurmstepd/task.c - task launching functions for slurmstepd
- *  $Id: task.c 12573 2007-10-26 15:57:01Z jette $
+ *  $Id: task.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark A. Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,6 +62,14 @@
 #  include <sys/checkpnt.h>
 #endif
 
+#ifdef HAVE_PTY_H
+#  include <pty.h>
+#endif
+
+#ifdef HAVE_UTMP_H
+#  include <utmp.h>
+#endif
+
 #include <sys/resource.h>
 
 #include <slurm/slurm_errno.h>
@@ -69,7 +77,6 @@
 #include "src/common/env.h"
 #include "src/common/fd.h"
 #include "src/common/log.h"
-#include "src/common/slurm_jobacct.h"
 #include "src/common/switch.h"
 #include "src/common/xsignal.h"
 #include "src/common/xstring.h"
@@ -291,6 +298,16 @@ exec_task(slurmd_job_t *job, int i, int waitfd)
 	int rc;
 	slurmd_task_info_t *task = job->task[i];
 
+#ifdef HAVE_PTY_H
+	/* Execute login_tty() before setpgid() calls */
+	if (job->pty && (task->gtid == 0)) {
+		if (login_tty(task->stdin_fd))
+			error("login_tty: %m");
+		else
+			debug3("login_tty good");
+	}
+#endif
+
 	if (set_user_limits(job) < 0) {
 		debug("Unable to set user limits");
 		log_fini();
@@ -331,6 +348,7 @@ exec_task(slurmd_job_t *job, int i, int waitfd)
 	job->envtp->mem_bind = xstrdup(job->mem_bind);
 	job->envtp->mem_bind_type = job->mem_bind_type;
 	job->envtp->distribution = -1;
+	job->envtp->ckpt_path = xstrdup(job->ckpt_path);
 	setup_env(job->envtp);
 	setenvf(&job->envtp->env, "SLURMD_NODENAME", "%s", conf->node_name);
 	job->env = job->envtp->env;
@@ -361,12 +379,19 @@ exec_task(slurmd_job_t *job, int i, int waitfd)
 		pdebug_stop_current(job);
 	}
 
-	io_dup_stdio(task);
+#ifdef HAVE_PTY_H
+	if (job->pty && (task->gtid == 0)) {
+		/* Need to perform the login_tty() before all tasks
+		 * register and the process groups are reset, otherwise
+		 * login_tty() gets disabled */
+	} else
+#endif
+		io_dup_stdio(task);
 
 	/* task-specific pre-launch activities */
 
 	if (spank_user_task (job, i) < 0) {
-		error ("Failed to invoke task plugin stack\n");
+		error ("Failed to invoke task plugin stack");
 		exit (1);
 	}
 
diff --git a/src/slurmd/slurmstepd/task.h b/src/slurmd/slurmstepd/task.h
index b2aeade2d529beba084aa1dac28159b773e77386..9daa80dfac1c14b020c087973aa83323f7a37648 100644
--- a/src/slurmd/slurmstepd/task.h
+++ b/src/slurmd/slurmstepd/task.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmstepd/task.h - task launching functions for slurmstepd
- * $Id: task.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: task.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmd/slurmstepd/ulimits.c b/src/slurmd/slurmstepd/ulimits.c
index 9d52bafbaa97257c709c5d2f4615fb8c83dafa53..08eda040d52778cb6fcd53e30da8ab51001281eb 100644
--- a/src/slurmd/slurmstepd/ulimits.c
+++ b/src/slurmd/slurmstepd/ulimits.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/slurmd/slurmstepd/ulimits.c - set user limits for job
- * $Id: ulimits.c 11693 2007-06-13 16:22:30Z jette $
+ * $Id: ulimits.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -76,10 +76,46 @@ static int _set_limit(char **env, slurm_rlimits_info_t *rli);
 int set_user_limits(slurmd_job_t *job)
 {
 	slurm_rlimits_info_t *rli;
+	struct rlimit r;
+	rlim_t task_mem_bytes;
 
 	for (rli = get_slurm_rlimits_info(); rli->name; rli++)
 		_set_limit( job->env, rli );
 
+	/* Set soft and hard memory and data size limit for this process, 
+	 * try to handle job and task limit (all spawned processes) in slurmd */
+	task_mem_bytes  = job->task_mem;	/* MB */
+	task_mem_bytes *= (1024 * 1024);
+#ifdef RLIMIT_AS
+	if ((task_mem_bytes) && (getrlimit(RLIMIT_AS, &r) == 0) &&
+	    (r.rlim_max > task_mem_bytes)) {
+		r.rlim_max =  r.rlim_cur = task_mem_bytes;
+		if (setrlimit(RLIMIT_AS, &r)) {
+			/* Indicates that limit has already been exceeded */
+			fatal("setrlimit(RLIMIT_AS, %u MB): %m", job->task_mem);
+		} else
+			info("Set task_mem(%u MB)", job->task_mem);
+#if 0
+		getrlimit(RLIMIT_AS, &r);
+		info("task memory limits: %u %u", r.rlim_cur, r.rlim_max);
+#endif
+	}
+#endif
+#ifdef RLIMIT_DATA
+	if ((task_mem_bytes) && (getrlimit(RLIMIT_DATA, &r) == 0) &&
+	    (r.rlim_max > task_mem_bytes)) {
+		r.rlim_max =  r.rlim_cur = task_mem_bytes;
+		if (setrlimit(RLIMIT_DATA, &r)) {
+			/* Indicates that limit has already been exceeded */
+			fatal("setrlimit(RLIMIT_DATA, %u MB): %m", job->task_mem);
+		} else
+			info("Set task_data(%u MB)", job->task_mem);
+#if 0
+		getrlimit(RLIMIT_DATA, &r);
+		info("task DATA limits: %u %u", r.rlim_cur, r.rlim_max);
+#endif
+	}
+#endif
 	return SLURM_SUCCESS;
 }
 
diff --git a/src/slurmd/slurmstepd/ulimits.h b/src/slurmd/slurmstepd/ulimits.h
index b51314e80848f724fc8d27117795b4e1ab5201bd..6a1656b605294d909a91915f24814d82012cd019 100644
--- a/src/slurmd/slurmstepd/ulimits.h
+++ b/src/slurmd/slurmstepd/ulimits.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/slurmdbd/Makefile.am b/src/slurmdbd/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..c8c9e1613671989107f1dbf3caa6645b2aecff62
--- /dev/null
+++ b/src/slurmdbd/Makefile.am
@@ -0,0 +1,32 @@
+#
+# Makefile for slurmdbd
+
+AUTOMAKE_OPTIONS = foreign
+CLEANFILES = core.*
+
+INCLUDES = -I$(top_srcdir)
+
+sbin_PROGRAMS = slurmdbd
+
+slurmdbd_LDADD = 					\
+	$(top_builddir)/src/common/libdaemonize.la \
+	 $(top_builddir)/src/common/libcommon.o -ldl
+
+
+slurmdbd_SOURCES = 		\
+	agent.c			\
+	agent.h			\
+	proc_req.c		\
+	proc_req.h		\
+	read_config.c		\
+	read_config.h		\
+	rpc_mgr.c		\
+	rpc_mgr.h		\
+	slurmdbd.c  		\
+	slurmdbd.h
+
+slurmdbd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) 	
+
+force:
+$(slurmdbd_LDADD) : force
+	@cd `dirname $@` && $(MAKE) `basename $@`
diff --git a/src/slurmdbd/Makefile.in b/src/slurmdbd/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..450be380c18e81e7dfe079721567815f6940f044
--- /dev/null
+++ b/src/slurmdbd/Makefile.in
@@ -0,0 +1,576 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+#
+# Makefile for slurmdbd
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+sbin_PROGRAMS = slurmdbd$(EXEEXT)
+subdir = src/slurmdbd
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(sbindir)"
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(sbin_PROGRAMS)
+am_slurmdbd_OBJECTS = agent.$(OBJEXT) proc_req.$(OBJEXT) \
+	read_config.$(OBJEXT) rpc_mgr.$(OBJEXT) slurmdbd.$(OBJEXT)
+slurmdbd_OBJECTS = $(am_slurmdbd_OBJECTS)
+slurmdbd_DEPENDENCIES = $(top_builddir)/src/common/libdaemonize.la \
+	$(top_builddir)/src/common/libcommon.o
+slurmdbd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(slurmdbd_LDFLAGS) \
+	$(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(slurmdbd_SOURCES)
+DIST_SOURCES = $(slurmdbd_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+CLEANFILES = core.*
+INCLUDES = -I$(top_srcdir)
+slurmdbd_LDADD = \
+	$(top_builddir)/src/common/libdaemonize.la \
+	 $(top_builddir)/src/common/libcommon.o -ldl
+
+slurmdbd_SOURCES = \
+	agent.c			\
+	agent.h			\
+	proc_req.c		\
+	proc_req.h		\
+	read_config.c		\
+	read_config.h		\
+	rpc_mgr.c		\
+	rpc_mgr.h		\
+	slurmdbd.c  		\
+	slurmdbd.h
+
+slurmdbd_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) 	
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/slurmdbd/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/slurmdbd/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	     || test -f $$p1 \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-sbinPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f '$(DESTDIR)$(sbindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(sbindir)/$$f"; \
+	done
+
+clean-sbinPROGRAMS:
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+slurmdbd$(EXEEXT): $(slurmdbd_OBJECTS) $(slurmdbd_DEPENDENCIES) 
+	@rm -f slurmdbd$(EXEEXT)
+	$(slurmdbd_LINK) $(slurmdbd_OBJECTS) $(slurmdbd_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agent.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc_req.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_config.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc_mgr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurmdbd.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+	for dir in "$(DESTDIR)$(sbindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-sbinPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-sbinPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-sbinPROGRAMS ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-sbinPROGRAMS install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-sbinPROGRAMS
+
+
+force:
+$(slurmdbd_LDADD) : force
+	@cd `dirname $@` && $(MAKE) `basename $@`
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/slurmdbd/agent.c b/src/slurmdbd/agent.c
new file mode 100644
index 0000000000000000000000000000000000000000..006160d498d64e52782fac824bd0179223397b64
--- /dev/null
+++ b/src/slurmdbd/agent.c
@@ -0,0 +1,37 @@
+/*****************************************************************************\
+ *  agent.c - functions for queued requests
+ *****************************************************************************
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
diff --git a/src/srun/reattach.h b/src/slurmdbd/agent.h
similarity index 82%
rename from src/srun/reattach.h
rename to src/slurmdbd/agent.h
index 04882a3c0f1a2b27f663e533611f41b85aa3d5d2..70c133abf33262b10826567d5d7cb1c623fcd15d 100644
--- a/src/srun/reattach.h
+++ b/src/slurmdbd/agent.h
@@ -1,10 +1,10 @@
 /*****************************************************************************\
- * src/srun/reattach.h support for re/attach to running jobs in slurm
+ *  agent.h - data structures and function definitions for queued requests
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Morris Jette <jette@llnl.gov>
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -35,12 +35,8 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#ifndef _REATTACH_H
-#define _REATTACH_H
+#ifndef _AGENT_H
+#define _AGENT_H
 
-/* reattach to running job, if possible. 
- * jobid/stepid to attach to are held in srun options "opt"
- */
-int reattach(void);
 
-#endif /* !_REATTACH_H */
+#endif /* !_AGENT_H */
diff --git a/src/slurmdbd/proc_req.c b/src/slurmdbd/proc_req.c
new file mode 100644
index 0000000000000000000000000000000000000000..a3065e982a1ee0c46fbb3eee92c2cc7c07de28d8
--- /dev/null
+++ b/src/slurmdbd/proc_req.c
@@ -0,0 +1,1800 @@
+/*****************************************************************************\
+ *  proc_req.c - functions for processing incoming RPCs.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/common/macros.h"
+#include "src/common/pack.h"
+#include "src/common/slurmdbd_defs.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/jobacct_common.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_protocol_defs.h"
+#include "src/slurmdbd/read_config.h"
+#include "src/slurmdbd/rpc_mgr.h"
+#include "src/slurmctld/slurmctld.h"
+
+/* Local functions */
+static int   _add_accounts(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _add_account_coords(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _add_assocs(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _add_clusters(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _add_users(void *db_conn,
+			Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _cluster_procs(void *db_conn,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _get_accounts(void *db_conn, Buf in_buffer, Buf *out_buffer);
+static int   _get_assocs(void *db_conn, Buf in_buffer, Buf *out_buffer);
+static int   _get_clusters(void *db_conn, Buf in_buffer, Buf *out_buffer);
+static int   _get_jobs(void *db_conn, Buf in_buffer, Buf *out_buffer);
+static int   _get_usage(uint16_t type, void *db_conn,
+			Buf in_buffer, Buf *out_buffer);
+static int   _get_users(void *db_conn, Buf in_buffer, Buf *out_buffer);
+static int   _flush_jobs(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static void *_init_conn(Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _fini_conn(void **db_conn, Buf in_buffer, Buf *out_buffer);
+static int   _job_complete(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _job_start(void *db_conn,
+			Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _job_suspend(void *db_conn,
+			  Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _modify_accounts(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _modify_assocs(void *db_conn,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _modify_clusters(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _modify_users(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _node_state(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static char *_node_state_string(uint16_t node_state);
+static int   _register_ctld(void *db_conn, slurm_fd orig_fd,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _remove_accounts(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _remove_account_coords(void *db_conn,
+				    Buf in_buffer, Buf *out_buffer,
+				    uint32_t *uid);
+static int   _remove_assocs(void *db_conn,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _remove_clusters(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _remove_users(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _roll_usage(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _step_complete(void *db_conn,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _step_start(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+static int   _update_shares_used(void *db_conn,
+				 Buf in_buffer, Buf *out_buffer, uint32_t *uid);
+
+/* Process an incoming RPC
+ * orig_fd IN - originating file descriptor of the RPC
+ * msg IN - incoming message
+ * msg_size IN - size of msg in bytes
+ * first IN - set if first message received on the socket
+ * buffer OUT - outgoing response, must be freed by caller
+ * uid IN/OUT - user ID who initiated the RPC
+ * RET SLURM_SUCCESS or error code */
+extern int 
+proc_req(void **db_conn, slurm_fd orig_fd, 
+	 char *msg, uint32_t msg_size,
+	 bool first, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	uint16_t msg_type;
+	Buf in_buffer;
+	char *comment = NULL;
+
+	in_buffer = create_buf(msg, msg_size); /* puts msg into buffer struct */
+	safe_unpack16(&msg_type, in_buffer);
+
+	if (first && (msg_type != DBD_INIT)) {
+		comment = "Initial RPC not DBD_INIT";
+		error("%s type (%d)", comment, msg_type);
+		rc = EINVAL;
+		*out_buffer = make_dbd_rc_msg(rc, comment, DBD_INIT);
+	} else {
+		switch (msg_type) {
+		case DBD_ADD_ACCOUNTS:
+			rc = _add_accounts(*db_conn,
+					   in_buffer, out_buffer, uid);
+			break;
+		case DBD_ADD_ACCOUNT_COORDS:
+			rc = _add_account_coords(*db_conn,
+						 in_buffer, out_buffer, uid);
+			break;
+		case DBD_ADD_ASSOCS:
+			rc = _add_assocs(*db_conn, in_buffer, out_buffer, uid);
+			break;
+		case DBD_ADD_CLUSTERS:
+			rc = _add_clusters(*db_conn,
+					   in_buffer, out_buffer, uid);
+			break;
+		case DBD_ADD_USERS:
+			rc = _add_users(*db_conn, in_buffer, out_buffer, uid);
+			break;
+		case DBD_CLUSTER_PROCS:
+			rc = _cluster_procs(*db_conn,
+					    in_buffer, out_buffer, uid);
+			break;
+		case DBD_GET_ACCOUNTS:
+			rc = _get_accounts(*db_conn, in_buffer, out_buffer);
+			break;
+		case DBD_GET_ASSOCS:
+			rc = _get_assocs(*db_conn, in_buffer, out_buffer);
+			break;
+		case DBD_GET_ASSOC_USAGE:
+		case DBD_GET_CLUSTER_USAGE:
+			rc = _get_usage(msg_type, *db_conn,
+					in_buffer, out_buffer);
+			break;
+		case DBD_GET_CLUSTERS:
+			rc = _get_clusters(*db_conn, in_buffer, out_buffer);
+			break;
+		case DBD_GET_JOBS:
+			rc = _get_jobs(*db_conn, in_buffer, out_buffer);
+			break;
+		case DBD_GET_USERS:
+			rc = _get_users(*db_conn, in_buffer, out_buffer);
+			break;
+		case DBD_FLUSH_JOBS:
+			rc = _flush_jobs(*db_conn, in_buffer, out_buffer, uid);
+			break;
+		case DBD_INIT:
+			if (first)
+				(*db_conn) = _init_conn(
+					in_buffer, out_buffer, uid);
+			else {
+				comment = "DBD_INIT sent after connection established";
+				error("%s", comment);
+				rc = EINVAL;
+				*out_buffer = make_dbd_rc_msg(rc, comment,
+							      DBD_INIT);
+			}
+			break;
+		case DBD_FINI:
+			rc = _fini_conn(db_conn, in_buffer, out_buffer);
+			break;
+		case DBD_JOB_COMPLETE:
+			rc = _job_complete(*db_conn,
+					   in_buffer, out_buffer, uid);
+			break;
+		case DBD_JOB_START:
+			rc = _job_start(*db_conn,
+					in_buffer, out_buffer, uid);
+			break;
+		case DBD_JOB_SUSPEND:
+			rc = _job_suspend(*db_conn,
+					  in_buffer, out_buffer, uid);
+			break;
+		case DBD_MODIFY_ACCOUNTS:
+			rc = _modify_accounts(*db_conn,
+					      in_buffer, out_buffer, uid);
+			break;
+		case DBD_MODIFY_ASSOCS:
+			rc = _modify_assocs(*db_conn,
+					    in_buffer, out_buffer, uid);
+			break;
+		case DBD_MODIFY_CLUSTERS:
+			rc = _modify_clusters(*db_conn,
+					      in_buffer, out_buffer, uid);
+			break;
+		case DBD_MODIFY_USERS:
+			rc = _modify_users(*db_conn,
+					   in_buffer, out_buffer, uid);
+			break;
+		case DBD_NODE_STATE:
+			rc = _node_state(*db_conn,
+					 in_buffer, out_buffer, uid);
+			break;
+		case DBD_REGISTER_CTLD:
+			rc = _register_ctld(*db_conn, orig_fd, in_buffer, 
+					    out_buffer, uid);
+			break;
+		case DBD_REMOVE_ACCOUNTS:
+			rc = _remove_accounts(*db_conn,
+					      in_buffer, out_buffer, uid);
+			break;
+		case DBD_REMOVE_ACCOUNT_COORDS:
+			rc = _remove_account_coords(*db_conn,
+						 in_buffer, out_buffer, uid);
+			break;
+		case DBD_REMOVE_ASSOCS:
+			rc = _remove_assocs(*db_conn,
+					    in_buffer, out_buffer, uid);
+			break;
+		case DBD_REMOVE_CLUSTERS:
+			rc = _remove_clusters(*db_conn,
+					      in_buffer, out_buffer, uid);
+			break;
+		case DBD_REMOVE_USERS:
+			rc = _remove_users(*db_conn,
+					   in_buffer, out_buffer, uid);
+			break;
+		case DBD_ROLL_USAGE:
+			rc = _roll_usage(*db_conn, in_buffer, out_buffer, uid);
+			break;
+		case DBD_STEP_COMPLETE:
+			rc = _step_complete(*db_conn,
+					    in_buffer, out_buffer, uid);
+			break;
+		case DBD_STEP_START:
+			rc = _step_start(*db_conn,
+					 in_buffer, out_buffer, uid);
+			break;
+		case DBD_UPDATE_SHARES_USED:
+			rc = _update_shares_used(*db_conn,
+						 in_buffer, out_buffer, uid);
+			break;
+		default:
+			comment = "Invalid RPC";
+			error("%s msg_type=%d", comment, msg_type);
+			rc = EINVAL;
+			*out_buffer = make_dbd_rc_msg(rc, comment, 0);
+			break;
+		}
+	}
+
+	xfer_buf_data(in_buffer);	/* delete in_buffer struct without 
+					 * xfree of msg */
+	return rc;
+
+unpack_error:
+	free_buf(in_buffer);
+	return SLURM_ERROR;
+}
+
+static int _add_accounts(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_list_msg_t *get_msg = NULL;
+	char *comment = NULL;
+
+	debug2("DBD_ADD_ACCOUNTS: called");
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		acct_user_rec_t user;
+
+		memset(&user, 0, sizeof(acct_user_rec_t));
+		user.uid = *uid;
+		if(!assoc_mgr_fill_in_user(db_conn, &user, 1)) {
+			comment = "Your user has not been added to the accounting system yet.";
+			error("%s", comment);
+			rc = SLURM_ERROR;
+			goto end_it;
+		}
+		if(!list_count(user.coord_accts)) {
+			comment = "Your user doesn't have privilege to preform this action";
+			error("%s", comment);
+			rc = ESLURM_ACCESS_DENIED;
+			goto end_it;			
+		}
+		/* If the user is a coord of any acct they can add
+		 * accounts they are only able to make associations to
+		 * these accounts if they are coordinators of the
+		 * parent they are trying to add to
+		 */		
+	}
+
+	if (slurmdbd_unpack_list_msg(DBD_ADD_ACCOUNTS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_ADD_ACCOUNTS message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	
+	rc = acct_storage_g_add_accounts(db_conn, *uid, get_msg->my_list);
+end_it:
+	slurmdbd_free_list_msg(get_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_ADD_ACCOUNTS);
+	return rc;
+}
+static int _add_account_coords(void *db_conn,
+			       Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_acct_coord_msg_t *get_msg = NULL;
+	char *comment = NULL;
+	
+	if (slurmdbd_unpack_acct_coord_msg(&get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_ADD_ACCOUNT_COORDS message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	
+	debug2("DBD_ADD_ACCOUNT_COORDS: called");
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		ListIterator itr = NULL;
+		acct_user_rec_t user;
+		acct_coord_rec_t *coord = NULL;
+		
+		memset(&user, 0, sizeof(acct_user_rec_t));
+		user.uid = *uid;
+		if(!assoc_mgr_fill_in_user(db_conn, &user, 1)) {
+			comment = "Your user has not been added to the accounting system yet.";
+			error("%s", comment);
+			rc = SLURM_ERROR;
+			goto end_it;
+		}
+		if(!list_count(user.coord_accts)) {
+			comment = "Your user doesn't have privilege to preform this action";
+			error("%s", comment);
+			rc = ESLURM_ACCESS_DENIED;
+			goto end_it;
+		}
+		itr = list_iterator_create(user.coord_accts);
+		while((coord = list_next(itr))) {
+			if(!strcasecmp(coord->acct_name, get_msg->acct))
+				break;
+		}
+		list_iterator_destroy(itr);
+		
+		if(!coord)  {
+			comment = "Your user doesn't have privilege to preform this action";
+			error("%s", comment);
+			rc = ESLURM_ACCESS_DENIED;
+			goto end_it;
+		}
+	}
+
+	rc = acct_storage_g_add_coord(db_conn, *uid, get_msg->acct,
+				      get_msg->cond);
+end_it:
+	slurmdbd_free_acct_coord_msg(get_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_ADD_ACCOUNT_COORDS);
+	return rc;
+}
+
+static int _add_assocs(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_list_msg_t *get_msg = NULL;
+	char *comment = NULL;
+
+	debug2("DBD_ADD_ASSOCS: called");
+
+	if (slurmdbd_unpack_list_msg(DBD_ADD_ASSOCS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_ADD_ASSOCS message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		ListIterator itr = NULL;
+		ListIterator itr2 = NULL;
+		acct_user_rec_t user;
+		acct_coord_rec_t *coord = NULL;
+		acct_association_rec_t *object = NULL;
+
+		memset(&user, 0, sizeof(acct_user_rec_t));
+		user.uid = *uid;
+		if(!assoc_mgr_fill_in_user(db_conn, &user, 1)) {
+			comment = "Your user has not been added to the accounting system yet.";
+			error("%s", comment);
+			rc = SLURM_ERROR;
+			goto end_it;
+		}
+		if(!user.coord_accts || !list_count(user.coord_accts)) {
+			comment = "Your user doesn't have privilege to preform this action";
+			error("%s", comment);
+			rc = ESLURM_ACCESS_DENIED;
+			goto end_it;
+		}
+		itr = list_iterator_create(get_msg->my_list);
+		itr2 = list_iterator_create(user.coord_accts);
+		while((object = list_next(itr))) {
+			char *account = "root";
+			if(object->user)
+				account = object->acct;
+			else if(object->parent_acct)
+				account = object->parent_acct;
+			list_iterator_reset(itr2);
+			while((coord = list_next(itr2))) {
+				if(!strcasecmp(coord->acct_name, account))
+					break;
+			}
+			if(!coord) 
+				break;
+		}
+		list_iterator_destroy(itr2);
+		list_iterator_destroy(itr);
+		if(!coord)  {
+			comment = "Your user doesn't have privilege to preform this action";
+			error("%s", comment);
+			rc = ESLURM_ACCESS_DENIED;
+			goto end_it;
+		}
+	}
+
+	rc = acct_storage_g_add_associations(db_conn, *uid, get_msg->my_list);
+end_it:
+	slurmdbd_free_list_msg(get_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_ADD_ASSOCS);
+	return rc;
+}
+
+static int _add_clusters(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_list_msg_t *get_msg = NULL;
+	char *comment = NULL;
+
+	debug2("DBD_ADD_CLUSTERS: called");
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_SUPER_USER) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+
+	if (slurmdbd_unpack_list_msg(DBD_ADD_CLUSTERS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_ADD_CLUSTERS message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	
+	rc = acct_storage_g_add_clusters(db_conn, *uid, get_msg->my_list);
+	if(rc != SLURM_SUCCESS) 
+		comment = "Failed to add cluster.";
+
+end_it:
+	slurmdbd_free_list_msg(get_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_ADD_CLUSTERS);
+	return rc;
+}
+static int _add_users(void *db_conn,
+		      Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_list_msg_t *get_msg = NULL;
+	char *comment = NULL;
+	debug2("DBD_ADD_USERS: called");
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		acct_user_rec_t user;
+
+		memset(&user, 0, sizeof(acct_user_rec_t));
+		user.uid = *uid;
+		if(!assoc_mgr_fill_in_user(db_conn, &user, 1)) {
+			comment = "Your user has not been added to the accounting system yet.";
+			error("%s", comment);
+			rc = SLURM_ERROR;
+			goto end_it;
+		}
+		if(!list_count(user.coord_accts)) {
+			comment = "Your user doesn't have privilege to preform this action";
+			error("%s", comment);
+			rc = ESLURM_ACCESS_DENIED;
+			goto end_it;			
+		}
+		/* If the user is a coord of any acct they can add
+		 * users they are only able to make associations to
+		 * these users if they are coordinators of the
+		 * account they are trying to add to
+		 */		
+	}
+
+	if (slurmdbd_unpack_list_msg(DBD_ADD_USERS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_ADD_USERS message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	
+	rc = acct_storage_g_add_users(db_conn, *uid, get_msg->my_list);
+
+end_it:
+	slurmdbd_free_list_msg(get_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_ADD_USERS);
+	return rc;
+}
+
+static int _cluster_procs(void *db_conn,
+			  Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_cluster_procs_msg_t *cluster_procs_msg = NULL;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_CLUSTER_PROCS message from invalid uid";
+		error("DBD_CLUSTER_PROCS message from invalid uid %u", *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_cluster_procs_msg(&cluster_procs_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_CLUSTER_PROCS message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	debug2("DBD_CLUSTER_PROCS: called for %s(%u)",
+	       cluster_procs_msg->cluster_name,
+	       cluster_procs_msg->proc_count);
+
+	rc = clusteracct_storage_g_cluster_procs(
+		db_conn,
+		cluster_procs_msg->cluster_name,
+		cluster_procs_msg->proc_count,
+		cluster_procs_msg->event_time);
+end_it:
+	slurmdbd_free_cluster_procs_msg(cluster_procs_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_CLUSTER_PROCS);
+	return rc;
+}
+
+static int _get_accounts(void *db_conn, Buf in_buffer, Buf *out_buffer)
+{
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_GET_ACCOUNTS: called");
+	if (slurmdbd_unpack_cond_msg(DBD_GET_ACCOUNTS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_GET_ACCOUNTS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment,
+					      DBD_GET_ACCOUNTS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_get_accounts(db_conn, get_msg->cond);
+	slurmdbd_free_cond_msg(DBD_GET_ACCOUNTS, get_msg);
+
+
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_ACCOUNTS, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_ACCOUNTS, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return SLURM_SUCCESS;
+}
+
+static int _get_assocs(void *db_conn, Buf in_buffer, Buf *out_buffer)
+{
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_GET_ASSOCS: called");
+	if (slurmdbd_unpack_cond_msg(DBD_GET_ASSOCS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_GET_ASSOCS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment,
+					      DBD_GET_ASSOCS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_get_associations(
+		db_conn, get_msg->cond);
+	slurmdbd_free_cond_msg(DBD_GET_ASSOCS, get_msg);
+
+
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_ASSOCS, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_ASSOCS, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+	
+	return SLURM_SUCCESS;
+}
+
+static int _get_clusters(void *db_conn, Buf in_buffer, Buf *out_buffer)
+{
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_GET_CLUSTERS: called");
+	if (slurmdbd_unpack_cond_msg(DBD_GET_CLUSTERS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_GET_CLUSTERS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment,
+					      DBD_GET_CLUSTERS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_get_clusters(
+		db_conn, get_msg->cond);
+	slurmdbd_free_cond_msg(DBD_GET_CLUSTERS, get_msg);
+
+
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_CLUSTERS, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_CLUSTERS, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+	
+	return SLURM_SUCCESS;
+}
+
+static int _get_jobs(void *db_conn, Buf in_buffer, Buf *out_buffer)
+{
+	dbd_get_jobs_msg_t *get_jobs_msg = NULL;
+	dbd_list_msg_t list_msg;
+	sacct_parameters_t sacct_params;
+	char *comment = NULL;
+
+	debug2("DBD_GET_JOBS: called");
+	if (slurmdbd_unpack_get_jobs_msg(&get_jobs_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_GET_JOBS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment, 
+					      DBD_GET_JOBS);
+		return SLURM_ERROR;
+	}
+	
+	memset(&sacct_params, 0, sizeof(sacct_parameters_t));
+	sacct_params.opt_cluster = get_jobs_msg->cluster_name;
+
+	list_msg.my_list = jobacct_storage_g_get_jobs(
+		db_conn,
+		get_jobs_msg->selected_steps, get_jobs_msg->selected_parts,
+		&sacct_params);
+	slurmdbd_free_get_jobs_msg(get_jobs_msg);
+
+
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_JOBS, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_JOBS, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+	
+	return SLURM_SUCCESS;
+}
+
+static int _get_usage(uint16_t type, void *db_conn,
+		      Buf in_buffer, Buf *out_buffer)
+{
+	dbd_usage_msg_t *get_msg = NULL;
+	dbd_usage_msg_t got_msg;
+	uint16_t ret_type = 0;
+	int (*my_function) (void *db_conn, void *object,
+			    time_t start, time_t end);
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	info("DBD_GET_USAGE: called");
+
+	if (slurmdbd_unpack_usage_msg(type, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_GET_USAGE message"; 
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment, type);
+		return SLURM_ERROR;
+	}
+	switch(type) {
+	case DBD_GET_ASSOC_USAGE:
+		ret_type = DBD_GOT_ASSOC_USAGE;
+		my_function = acct_storage_g_get_usage;
+		break;
+	case DBD_GET_CLUSTER_USAGE:
+		ret_type = DBD_GOT_CLUSTER_USAGE;
+		my_function = clusteracct_storage_g_get_usage;
+		break;
+	default:
+		comment = "Unknown type of usage to get";
+		error("%s %u", comment, type);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment, type);
+		return SLURM_ERROR;
+	}		
+
+	rc = (*(my_function))(db_conn, get_msg->rec,
+			      get_msg->start, get_msg->end);
+	slurmdbd_free_usage_msg(type, get_msg);
+
+	if(rc != SLURM_SUCCESS) {
+		comment = "Problem getting usage info";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment, type);
+		return SLURM_ERROR;
+		
+	}
+	memset(&got_msg, 0, sizeof(dbd_usage_msg_t));
+	got_msg.rec = get_msg->rec;
+	get_msg->rec = NULL;
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) ret_type, *out_buffer);
+	slurmdbd_pack_usage_msg(ret_type, &got_msg, *out_buffer);
+	
+	return SLURM_SUCCESS;
+}
+
+static int _get_users(void *db_conn, Buf in_buffer, Buf *out_buffer)
+{
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_GET_USERS: called");
+
+	if (slurmdbd_unpack_cond_msg(DBD_GET_USERS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_GET_USERS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment,
+					      DBD_GET_USERS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_get_users(db_conn, get_msg->cond);
+	slurmdbd_free_cond_msg(DBD_GET_USERS, get_msg);
+
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_USERS, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_USERS, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+	
+	return SLURM_SUCCESS;
+}
+
+static int _flush_jobs(void *db_conn,
+			  Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_cluster_procs_msg_t *cluster_procs_msg = NULL;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_FLUSH_JOBS message from invalid uid";
+		error("DBD_FLUSH_JOBS message from invalid uid %u", *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_cluster_procs_msg(&cluster_procs_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_FLUSH_JOBS message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	debug2("DBD_FLUSH_JOBS: called for %s",
+	       cluster_procs_msg->cluster_name);
+
+	rc = acct_storage_g_flush_jobs_on_cluster(
+		db_conn,
+		cluster_procs_msg->cluster_name,
+		cluster_procs_msg->event_time);
+end_it:
+	slurmdbd_free_cluster_procs_msg(cluster_procs_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_FLUSH_JOBS);
+	return rc;
+}
+
+static void *_init_conn(Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_init_msg_t *init_msg = NULL;
+	char *comment = NULL;
+	int rc = SLURM_SUCCESS;
+	void *new_conn = NULL;
+
+	if (slurmdbd_unpack_init_msg(&init_msg, in_buffer, 
+				     slurmdbd_conf->auth_info)
+	    != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_INIT message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	if (init_msg->version != SLURMDBD_VERSION) {
+		comment = "Incompatable RPC version";
+		error("Incompatable RPC version (%d != %d)",
+		      init_msg->version, SLURMDBD_VERSION);
+		goto end_it;
+	}
+	*uid = init_msg->uid;
+	
+	debug("DBD_INIT: VERSION:%u UID:%u", init_msg->version, init_msg->uid);
+	new_conn = acct_storage_g_get_connection(false, init_msg->rollback);
+	
+end_it:
+	slurmdbd_free_init_msg(init_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_INIT);
+
+	return new_conn;
+}
+
+static int   _fini_conn(void **db_conn, Buf in_buffer, Buf *out_buffer)
+{
+	dbd_fini_msg_t *fini_msg = NULL;
+	char *comment = NULL;
+	int rc = SLURM_SUCCESS;
+
+	if (slurmdbd_unpack_fini_msg(&fini_msg, in_buffer) != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_FINI message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	
+	debug2("DBD_FINI: CLOSE:%u COMMIT:%u",
+	       fini_msg->close_conn, fini_msg->commit);
+	if(fini_msg->close_conn == 1)
+		rc = acct_storage_g_close_connection(db_conn);
+	else
+		rc = acct_storage_g_commit((*db_conn), fini_msg->commit);
+end_it:
+	slurmdbd_free_fini_msg(fini_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_FINI);
+
+	return rc;
+
+}
+
+static int  _job_complete(void *db_conn,
+			  Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_job_comp_msg_t *job_comp_msg = NULL;
+	struct job_record job;
+	struct job_details details;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_JOB_COMPLETE message from invalid uid";
+		error("%s %u", comment, *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_job_complete_msg(&job_comp_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_JOB_COMPLETE message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+
+	debug2("DBD_JOB_COMPLETE: ID:%u ", job_comp_msg->job_id);
+
+	memset(&job, 0, sizeof(struct job_record));
+	memset(&details, 0, sizeof(struct job_details));
+
+	job.assoc_id = job_comp_msg->assoc_id;
+	job.db_index = job_comp_msg->db_index;
+	job.end_time = job_comp_msg->end_time;
+	job.exit_code = job_comp_msg->exit_code;
+	job.job_id = job_comp_msg->job_id;
+	job.job_state = job_comp_msg->job_state;
+	job.nodes = job_comp_msg->nodes;
+	job.start_time = job_comp_msg->start_time;
+	details.submit_time = job_comp_msg->submit_time;
+
+	job.details = &details;
+	rc = jobacct_storage_g_job_complete(db_conn, &job);
+
+	if(rc && errno == 740) /* meaning data is already there */
+		rc = SLURM_SUCCESS;
+end_it:
+	slurmdbd_free_job_complete_msg(job_comp_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_JOB_COMPLETE);
+	return SLURM_SUCCESS;
+}
+
+static int  _job_start(void *db_conn,
+		       Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_job_start_msg_t *job_start_msg = NULL;
+	dbd_job_start_rc_msg_t job_start_rc_msg;
+	struct job_record job;
+	struct job_details details;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_JOB_START message from invalid uid";
+		error("%s %u", comment, *uid);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED, comment,
+					      DBD_JOB_START);
+		return SLURM_ERROR;
+	}
+	if (slurmdbd_unpack_job_start_msg(&job_start_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_JOB_START message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR, comment,
+					      DBD_JOB_START);
+		return SLURM_ERROR;
+	}
+	memset(&job, 0, sizeof(struct job_record));
+	memset(&details, 0, sizeof(struct job_details));
+	memset(&job_start_rc_msg, 0, sizeof(dbd_job_start_rc_msg_t));
+
+	job.total_procs = job_start_msg->alloc_cpus;
+	job.account = job_start_msg->account;
+	job.assoc_id = job_start_msg->assoc_id;
+	job.comment = job_start_msg->block_id;
+	job.db_index = job_start_msg->db_index;
+	details.begin_time = job_start_msg->eligible_time;
+	job.user_id = job_start_msg->uid;
+	job.group_id = job_start_msg->gid;
+	job.job_id = job_start_msg->job_id;
+	job.job_state = job_start_msg->job_state;
+	job.name = job_start_msg->name;
+	job.nodes = job_start_msg->nodes;
+	job.partition = job_start_msg->partition;
+	job.num_procs = job_start_msg->req_cpus;
+	job.priority = job_start_msg->priority;
+	job.start_time = job_start_msg->start_time;
+	details.submit_time = job_start_msg->submit_time;
+
+	job.details = &details;
+
+	if(job.db_index) {
+		debug2("DBD_JOB_START: START CALL ID:%u NAME:%s INX:%u", 
+		       job_start_msg->job_id, job_start_msg->name, 
+		       job.db_index);	
+	} else {
+		debug2("DBD_JOB_START: ELIGIBLE CALL ID:%u NAME:%s", 
+		       job_start_msg->job_id, job_start_msg->name);
+	}
+	job_start_rc_msg.return_code = jobacct_storage_g_job_start(db_conn,
+								   &job);
+	job_start_rc_msg.db_index = job.db_index;
+
+	slurmdbd_free_job_start_msg(job_start_msg);
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_JOB_START_RC, *out_buffer);
+	slurmdbd_pack_job_start_rc_msg(&job_start_rc_msg, *out_buffer);
+	return SLURM_SUCCESS;
+}
+
+static int  _job_suspend(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_job_suspend_msg_t *job_suspend_msg = NULL;
+	struct job_record job;
+	struct job_details details;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_JOB_SUSPEND message from invalid uid";
+		error("%s %u", comment, *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_job_suspend_msg(&job_suspend_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_JOB_SUSPEND message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+
+	debug2("DBD_JOB_SUSPEND: ID:%u STATE:%s", 
+	       job_suspend_msg->job_id, 
+	       job_state_string((enum job_states) job_suspend_msg->job_state));
+
+	memset(&job, 0, sizeof(struct job_record));
+	memset(&details, 0, sizeof(struct job_details));
+
+	job.assoc_id = job_suspend_msg->assoc_id;
+	job.db_index = job_suspend_msg->db_index;
+	job.job_id = job_suspend_msg->job_id;
+	job.job_state = job_suspend_msg->job_state;
+	details.submit_time = job_suspend_msg->submit_time;
+	job.suspend_time = job_suspend_msg->suspend_time;
+
+	job.details = &details;
+	rc = jobacct_storage_g_job_suspend(db_conn, &job);
+
+	if(rc && errno == 740) /* meaning data is already there */
+		rc = SLURM_SUCCESS;
+end_it:
+	slurmdbd_free_job_suspend_msg(job_suspend_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_JOB_SUSPEND);
+	return SLURM_SUCCESS;
+}
+
+static int   _modify_accounts(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_modify_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_MODIFY_ACCOUNTS: called");
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_MODIFY_ACCOUNTS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_modify_msg(DBD_MODIFY_ACCOUNTS, &get_msg,
+				       in_buffer) != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_MODIFY_ACCOUNTS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_MODIFY_ACCOUNTS);
+		return SLURM_ERROR;
+	}
+	
+
+	list_msg.my_list = acct_storage_g_modify_accounts(
+		db_conn, *uid, get_msg->cond, get_msg->rec);
+	slurmdbd_free_modify_msg(DBD_MODIFY_ACCOUNTS, get_msg);
+
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_MODIFY_ACCOUNTS);
+	return rc;
+}
+
+static int   _modify_assocs(void *db_conn,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_modify_msg_t *get_msg = NULL;
+	char *comment = NULL;
+	dbd_list_msg_t list_msg;
+
+	debug2("DBD_MODIFY_ASSOCS: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_MODIFY_ASSOCS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_modify_msg(DBD_MODIFY_ASSOCS, &get_msg, 
+				       in_buffer) != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_MODIFY_ASSOCS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_MODIFY_ASSOCS);
+		return SLURM_ERROR;
+	}
+	
+
+	list_msg.my_list = acct_storage_g_modify_associations(db_conn, *uid,
+						get_msg->cond, get_msg->rec);
+
+	slurmdbd_free_modify_msg(DBD_MODIFY_ASSOCS, get_msg);
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+}
+
+static int   _modify_clusters(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_list_msg_t list_msg;
+	int rc = SLURM_SUCCESS;
+	dbd_modify_msg_t *get_msg = NULL;
+	char *comment = NULL;
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid)
+	   < ACCT_ADMIN_SUPER_USER) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_MODIFY_CLUSTERS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_modify_msg(DBD_MODIFY_CLUSTERS, &get_msg,
+				       in_buffer) != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_MODIFY_CLUSTERS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_MODIFY_CLUSTERS);
+		return SLURM_ERROR;
+	}
+	
+	debug2("DBD_MODIFY_CLUSTERS: called");
+
+	list_msg.my_list = acct_storage_g_modify_clusters(db_conn, *uid,
+					    get_msg->cond, get_msg->rec);
+
+	slurmdbd_free_modify_msg(DBD_MODIFY_CLUSTERS, get_msg);
+	*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+}
+
+static int   _modify_users(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_list_msg_t list_msg;
+	int rc = SLURM_SUCCESS;
+	dbd_modify_msg_t *get_msg = NULL;
+	char *comment = NULL;
+
+	debug2("DBD_MODIFY_USERS: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_MODIFY_USERS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_modify_msg(DBD_MODIFY_USERS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_MODIFY_USERS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_MODIFY_USERS);
+		return SLURM_ERROR;
+	}
+
+	if(((acct_user_rec_t *)get_msg->rec)->admin_level != ACCT_ADMIN_NOTSET 
+	   && *uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) 
+	   < ((acct_user_rec_t *)get_msg->rec)->admin_level) {
+		comment = "You have to be the same or higher admin level to change another persons";
+		((acct_user_rec_t *)get_msg->rec)->admin_level =
+			ACCT_ADMIN_NOTSET;
+	}
+
+	list_msg.my_list = acct_storage_g_modify_users(
+		db_conn, *uid, get_msg->cond, get_msg->rec);
+
+	slurmdbd_free_modify_msg(DBD_MODIFY_USERS, get_msg);
+		*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+}
+
+static int _node_state(void *db_conn,
+		       Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_node_state_msg_t *node_state_msg = NULL;
+	struct node_record node_ptr;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	memset(&node_ptr, 0, sizeof(struct node_record));
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_NODE_STATE message from invalid uid";
+		error("%s %u", comment, *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_node_state_msg(&node_state_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_NODE_STATE message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+
+	debug2("DBD_NODE_STATE: NODE:%s STATE:%s REASON:%s TIME:%u", 
+	       node_state_msg->hostlist,
+	       _node_state_string(node_state_msg->new_state),
+	       node_state_msg->reason, 
+	       node_state_msg->event_time);
+	node_ptr.name = node_state_msg->hostlist;
+	node_ptr.cpus = node_state_msg->cpu_count;
+
+	slurmctld_conf.fast_schedule = 0;
+
+	if(node_state_msg->new_state == DBD_NODE_STATE_DOWN)
+		rc = clusteracct_storage_g_node_down(
+			db_conn,
+			node_state_msg->cluster_name,
+			&node_ptr,
+			node_state_msg->event_time,
+			node_state_msg->reason);
+	else
+		rc = clusteracct_storage_g_node_up(db_conn,
+						   node_state_msg->cluster_name,
+						   &node_ptr,
+						   node_state_msg->event_time);
+	
+	if(rc && errno == 740) /* meaning data is already there */
+		rc = SLURM_SUCCESS;
+
+end_it:
+	slurmdbd_free_node_state_msg(node_state_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_NODE_STATE);
+	return SLURM_SUCCESS;
+}
+
+static char *_node_state_string(uint16_t node_state)
+{
+	switch(node_state) {
+		case DBD_NODE_STATE_DOWN:
+			return "DOWN";
+		case DBD_NODE_STATE_UP:
+			return "UP";
+	}
+	return "UNKNOWN";
+}
+
+static int   _register_ctld(void *db_conn, slurm_fd orig_fd,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_register_ctld_msg_t *register_ctld_msg = NULL;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL, ip[32];
+	slurm_addr ctld_address;
+	uint16_t orig_port;
+	acct_cluster_cond_t cluster_q;
+	acct_cluster_rec_t cluster;
+	dbd_list_msg_t list_msg;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_REGISTER_CTLD message from invalid uid";
+		error("%s %u", comment, *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_register_ctld_msg(&register_ctld_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_REGISTER_CTLD message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+	debug2("DBD_REGISTER_CTLD: called for %s(%u)",
+	       register_ctld_msg->cluster_name, register_ctld_msg->port);
+	slurm_get_peer_addr(orig_fd, &ctld_address);
+	slurm_get_ip_str(&ctld_address, &orig_port, ip, sizeof(ip));
+	debug2("slurmctld at ip:%s, port:%d", ip, register_ctld_msg->port);
+
+	memset(&cluster_q, 0, sizeof(acct_cluster_cond_t));
+	memset(&cluster, 0, sizeof(acct_cluster_rec_t));
+	cluster_q.cluster_list = list_create(NULL);
+	list_append(cluster_q.cluster_list, register_ctld_msg->cluster_name);
+	cluster.control_host = ip;
+	cluster.control_port = register_ctld_msg->port;
+	list_msg.my_list = acct_storage_g_modify_clusters(
+		db_conn, *uid, &cluster_q, &cluster);
+
+	if(!list_msg.my_list || !list_count(list_msg.my_list)) {
+		comment = "This cluster hasn't been added to accounting yet";
+		rc = SLURM_ERROR;
+	} 
+	
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+	
+
+	list_destroy(cluster_q.cluster_list);
+	/*
+	 * Outgoing message header must have flag set:
+	 * out_msg.flags = SLURM_GLOBAL_AUTH_KEY;
+	 */
+#if 0
+{
+	/* Code to validate communications back to slurmctld */
+	slurm_fd fd;
+	slurm_set_addr_char(&ctld_address, register_ctld_msg->port, ip);
+	fd =  slurm_open_msg_conn(&ctld_address);
+	if (fd < 0) {
+		error("can not open socket back to slurmctld");
+	} else {
+		slurm_msg_t out_msg;
+		slurm_msg_t_init(&out_msg);
+		out_msg.msg_type = REQUEST_PING;
+		out_msg.flags = SLURM_GLOBAL_AUTH_KEY;
+		slurm_send_node_msg(fd, &out_msg);
+		/* We probably need to add matching recv_msg function
+		 * for an arbitray fd or should these be fire and forget? */
+		slurm_close_stream(fd);
+	}
+}
+#endif
+
+end_it:
+	slurmdbd_free_register_ctld_msg(register_ctld_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_REGISTER_CTLD);
+	return rc;
+}
+
+static int   _remove_accounts(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_REMOVE_ACCOUNTS: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_REMOVE_ACCOUNTS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_cond_msg(DBD_REMOVE_ACCOUNTS, &get_msg, 
+				     in_buffer) != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_REMOVE_ACCOUNTS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_REMOVE_ACCOUNTS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_remove_accounts(
+		db_conn, *uid, get_msg->cond);
+/* this should be done inside the plugin */
+/* 	if(rc == SLURM_SUCCESS) { */
+/* 		memset(&assoc_q, 0, sizeof(acct_association_cond_t)); */
+/* 		assoc_q.acct_list = */
+/* 			((acct_account_cond_t *)get_msg->cond)->acct_list; */
+/* 		list_msg.my_list = acct_storage_g_remove_associations(db_conn, *uid, &assoc_q); */
+/* 	} */
+
+	slurmdbd_free_cond_msg(DBD_REMOVE_ACCOUNTS, get_msg);
+		*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+}
+
+static int   _remove_account_coords(void *db_conn,
+				    Buf in_buffer, Buf *out_buffer,
+				    uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_acct_coord_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_REMOVE_ACCOUNT_COORDS: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(
+			ESLURM_ACCESS_DENIED, comment,
+			DBD_REMOVE_ACCOUNT_COORDS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_acct_coord_msg(&get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_REMOVE_ACCOUNT_COORDS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(
+			SLURM_ERROR, comment, DBD_REMOVE_ACCOUNT_COORDS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_remove_coord(
+		db_conn, *uid, get_msg->acct, get_msg->cond);
+
+	slurmdbd_free_acct_coord_msg(get_msg);
+		*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+}
+
+static int   _remove_assocs(void *db_conn,
+			    Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_REMOVE_ASSOCS: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_REMOVE_ASSOCS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_cond_msg(DBD_REMOVE_ASSOCS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_REMOVE_ASSOCS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_REMOVE_ASSOCS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_remove_associations(
+		db_conn, *uid, get_msg->cond);
+
+	slurmdbd_free_cond_msg(DBD_REMOVE_ASSOCS, get_msg);
+		*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+
+}
+
+static int   _remove_clusters(void *db_conn,
+			      Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_REMOVE_CLUSTERS: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) 
+	   < ACCT_ADMIN_SUPER_USER) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_REMOVE_CLUSTERS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_cond_msg(DBD_REMOVE_CLUSTERS, &get_msg, 
+				     in_buffer) != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_REMOVE_CLUSTERS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_REMOVE_CLUSTERS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_remove_clusters(
+		db_conn, *uid, get_msg->cond);
+/* this should be done inside the plugin */
+/* 	if(rc == SLURM_SUCCESS) { */
+/* 		memset(&assoc_q, 0, sizeof(acct_association_cond_t)); */
+/* 		assoc_q.cluster_list = */
+/* 			((acct_cluster_cond_t *)get_msg->cond)->cluster_list; */
+/* 		list_msg.my_list = acct_storage_g_remove_associations(db_conn, *uid, &assoc_q); */
+/* 	} */
+
+	slurmdbd_free_cond_msg(DBD_REMOVE_CLUSTERS, get_msg);
+		*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+}
+
+static int   _remove_users(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_cond_msg_t *get_msg = NULL;
+	dbd_list_msg_t list_msg;
+	char *comment = NULL;
+
+	debug2("DBD_REMOVE_USERS: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(ESLURM_ACCESS_DENIED,
+					      comment, DBD_REMOVE_USERS);
+
+		return ESLURM_ACCESS_DENIED;
+	}
+
+	if (slurmdbd_unpack_cond_msg(DBD_REMOVE_USERS, &get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_REMOVE_USERS message";
+		error("%s", comment);
+		*out_buffer = make_dbd_rc_msg(SLURM_ERROR,
+					      comment, DBD_REMOVE_USERS);
+		return SLURM_ERROR;
+	}
+	
+	list_msg.my_list = acct_storage_g_remove_users(
+		db_conn, *uid, get_msg->cond);
+/* this should be done inside the plugin */
+	/* if(rc == SLURM_SUCCESS) { */
+/* 		memset(&assoc_q, 0, sizeof(acct_association_cond_t)); */
+/* 		assoc_q.user_list = */
+/* 			((acct_user_cond_t *)get_msg->cond)->user_list; */
+/* 		list_msg.my_list = acct_storage_g_remove_associations(db_conn, *uid, &assoc_q); */
+/* 	} */
+
+	slurmdbd_free_cond_msg(DBD_REMOVE_USERS, get_msg);
+		*out_buffer = init_buf(1024);
+	pack16((uint16_t) DBD_GOT_LIST, *out_buffer);
+	slurmdbd_pack_list_msg(DBD_GOT_LIST, &list_msg, *out_buffer);
+	if(list_msg.my_list)
+		list_destroy(list_msg.my_list);
+
+	return rc;
+}
+
+static int   _roll_usage(void *db_conn,
+			 Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_roll_usage_msg_t *get_msg = NULL;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	info("DBD_ROLL_USAGE: called");
+
+	if(*uid != slurmdbd_conf->slurm_user_id
+	   && assoc_mgr_get_admin_level(db_conn, *uid) < ACCT_ADMIN_OPERATOR) {
+		comment = "Your user doesn't have privilege to preform this action";
+		error("%s", comment);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+
+	if (slurmdbd_unpack_roll_usage_msg(&get_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_ROLL_USAGE message"; 
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+
+	rc = acct_storage_g_roll_usage(db_conn, get_msg->start);
+
+end_it:
+	slurmdbd_free_roll_usage_msg(get_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_ROLL_USAGE);
+	return rc;
+}
+
+static int  _step_complete(void *db_conn,
+			   Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_step_comp_msg_t *step_comp_msg = NULL;
+	struct step_record step;
+	struct job_record job;
+	struct job_details details;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_STEP_COMPLETE message from invalid uid";
+		error("%s %u", comment, *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_step_complete_msg(&step_comp_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_STEP_COMPLETE message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+
+	debug2("DBD_STEP_COMPLETE: ID:%u.%u SUBMIT:%u", 
+	       step_comp_msg->job_id, step_comp_msg->step_id,
+	       step_comp_msg->job_submit_time);
+
+	memset(&step, 0, sizeof(struct step_record));
+	memset(&job, 0, sizeof(struct job_record));
+	memset(&details, 0, sizeof(struct job_details));
+
+	job.assoc_id = step_comp_msg->assoc_id;
+	job.db_index = step_comp_msg->db_index;
+	job.end_time = step_comp_msg->end_time;
+	step.jobacct = step_comp_msg->jobacct;
+	job.job_id = step_comp_msg->job_id;
+	job.requid = step_comp_msg->req_uid;
+	job.start_time = step_comp_msg->start_time;
+	details.submit_time = step_comp_msg->job_submit_time;
+	step.step_id = step_comp_msg->step_id;
+	job.total_procs = step_comp_msg->total_procs;
+
+	job.details = &details;
+	step.job_ptr = &job;
+
+	rc = jobacct_storage_g_step_complete(db_conn, &step);
+
+	if(rc && errno == 740) /* meaning data is already there */
+		rc = SLURM_SUCCESS;
+
+end_it:
+	slurmdbd_free_step_complete_msg(step_comp_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_STEP_COMPLETE);
+	return rc;
+}
+
+static int  _step_start(void *db_conn,
+			Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	dbd_step_start_msg_t *step_start_msg = NULL;
+	struct step_record step;
+	struct job_record job;
+	struct job_details details;
+	int rc = SLURM_SUCCESS;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_STEP_START message from invalid uid";
+		error("%s %u", comment, *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	if (slurmdbd_unpack_step_start_msg(&step_start_msg, in_buffer) !=
+	    SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_STEP_START message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	}
+
+	debug2("DBD_STEP_START: ID:%u.%u NAME:%s SUBMIT:%d", 
+	     step_start_msg->job_id, step_start_msg->step_id,
+	       step_start_msg->name, step_start_msg->job_submit_time);
+
+	memset(&step, 0, sizeof(struct step_record));
+	memset(&job, 0, sizeof(struct job_record));
+	memset(&details, 0, sizeof(struct job_details));
+
+	job.assoc_id = step_start_msg->assoc_id;
+	job.db_index = step_start_msg->db_index;
+	job.job_id = step_start_msg->job_id;
+	step.name = step_start_msg->name;
+	job.nodes = step_start_msg->nodes;
+	step.start_time = step_start_msg->start_time;
+	details.submit_time = step_start_msg->job_submit_time;
+	step.step_id = step_start_msg->step_id;
+	job.total_procs = step_start_msg->total_procs;
+
+	job.details = &details;
+	step.job_ptr = &job;
+
+	rc = jobacct_storage_g_step_start(db_conn, &step);
+
+	if(rc && errno == 740) /* meaning data is already there */
+		rc = SLURM_SUCCESS;
+end_it:
+	slurmdbd_free_step_start_msg(step_start_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_STEP_START);
+	return rc;
+}
+
+static int  _update_shares_used(void *db_conn,
+				Buf in_buffer, Buf *out_buffer, uint32_t *uid)
+{
+	int rc = SLURM_SUCCESS;
+	dbd_list_msg_t *used_shares_msg = NULL;
+	char *comment = NULL;
+
+	if (*uid != slurmdbd_conf->slurm_user_id) {
+		comment = "DBD_UPDATE_SHARES_USED message from invalid uid";
+		error("%s %u", comment, *uid);
+		rc = ESLURM_ACCESS_DENIED;
+		goto end_it;
+	}
+	debug2("DBD_UPDATE_SHARES_USED");
+	if (slurmdbd_unpack_list_msg(DBD_UPDATE_SHARES_USED, &used_shares_msg, 
+				     in_buffer) != SLURM_SUCCESS) {
+		comment = "Failed to unpack DBD_UPDATE_SHARES_USED message";
+		error("%s", comment);
+		rc = SLURM_ERROR;
+		goto end_it;
+	} else {
+#if 0
+		/* This was only added to verify the logic. 
+		 * It is not useful for production use */
+		ListIterator itr = NULL;
+		shares_used_object_t *usage;
+		itr = list_iterator_create(used_shares_msg->my_list);
+		while((usage = list_next(itr))) {
+			debug2("assoc_id:%u shares_used:%u", 
+			       usage->assoc_id, usage->shares_used);
+		}
+		list_iterator_destroy(itr);
+#endif
+	}
+
+	rc = acct_storage_g_update_shares_used(db_conn, 
+					       used_shares_msg->my_list);
+
+end_it:
+	slurmdbd_free_list_msg(used_shares_msg);
+	*out_buffer = make_dbd_rc_msg(rc, comment, DBD_UPDATE_SHARES_USED);
+	return rc;
+}
diff --git a/src/sacct/sacct_stat.h b/src/slurmdbd/proc_req.h
similarity index 68%
rename from src/sacct/sacct_stat.h
rename to src/slurmdbd/proc_req.h
index af3d6794fef13d9cedd9ecc235b6c1d31b0abf8b..6ed7cc19165ff54778ab49b0c7ef5080c91d97ac 100644
--- a/src/sacct/sacct_stat.h
+++ b/src/slurmdbd/proc_req.h
@@ -1,12 +1,10 @@
 /*****************************************************************************\
- *  sacct_stat.h - header file for sacct
- *
- *  $Id: sacct.h 7541 2006-03-18 01:44:58Z da $
+ *  proc_req.h - functions and definitions for processing incoming RPCs.
  *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Danny Auble <da@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -17,7 +15,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -36,31 +34,24 @@
  *  with SLURM; if not, write to the Free Software Foundation, Inc.,
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
-#ifndef _SACCT_STAT_H
-#define _SACCT_STAT_H
-
-#include "src/common/slurm_protocol_api.h"
 
-typedef struct {
-	uint16_t taskid; /* contains which task number it was on */
-	uint32_t nodeid; /* contains which node number it was on */	
-} jobacct_id_t;
+#ifndef _PROC_REQ_H
+#define _PROC_REQ_H
 
-typedef struct sacct_struct {
-	uint32_t max_vsize; 
-	jobacct_id_t max_vsize_id;
-	float ave_vsize;
-	uint32_t max_rss;
-	jobacct_id_t max_rss_id;
-	float ave_rss;
-	uint32_t max_pages;
-	jobacct_id_t max_pages_id;
-	float ave_pages;
-	float min_cpu;
-	jobacct_id_t min_cpu_id;
-	float ave_cpu;	
-} sacct_t;
+#include "src/common/macros.h"
+#include "src/common/pack.h"
+#include "src/common/slurm_protocol_defs.h"
 
-extern int sacct_stat(uint32_t jobid, uint32_t stepid);
+/* Process an incoming RPC
+ * orig_fd IN - originating file descriptor of the RPC
+ * msg IN - incoming message
+ * msg_size IN - size of msg in bytes
+ * first IN - set if first message received on the socket
+ * buffer OUT - outgoing response, must be freed by caller
+ * uid IN/OUT - user ID who initiated the RPC
+ * RET SLURM_SUCCESS or error code */
+extern int proc_req(void **db_conn, slurm_fd orig_fd, char *msg, 
+		    uint32_t msg_size, bool first, Buf *out_buffer, 
+		    uint32_t *uid);
 
-#endif
+#endif /* !_PROC_REQ */
diff --git a/src/slurmdbd/read_config.c b/src/slurmdbd/read_config.c
new file mode 100644
index 0000000000000000000000000000000000000000..73bf525190b38374d8e854aee72e8c7512a86747
--- /dev/null
+++ b/src/slurmdbd/read_config.c
@@ -0,0 +1,283 @@
+/*****************************************************************************\
+ *  read_config.c - functions for reading slurmdbd.conf
+ *****************************************************************************
+ *  Copyright (C) 2003-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include <pwd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <slurm/slurm_errno.h>
+
+#include "src/common/macros.h"
+#include "src/common/log.h"
+#include "src/common/parse_config.h"
+#include "src/common/read_config.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+#include "src/slurmdbd/read_config.h"
+
+/* Global variables */
+pthread_mutex_t conf_mutex = PTHREAD_MUTEX_INITIALIZER;
+//slurm_dbd_conf_t *slurmdbd_conf = NULL;
+
+/* Local functions */
+static void _clear_slurmdbd_conf(void);
+static char * _get_conf_path(void);
+
+/*
+ * free_slurmdbd_conf - free storage associated with the global variable 
+ *	slurmdbd_conf
+ */
+extern void free_slurmdbd_conf(void)
+{
+	slurm_mutex_lock(&conf_mutex);
+	_clear_slurmdbd_conf();
+	xfree(slurmdbd_conf);
+	slurm_mutex_unlock(&conf_mutex);
+}
+
+static void _clear_slurmdbd_conf(void)
+{
+	if (slurmdbd_conf) {
+		xfree(slurmdbd_conf->auth_info);
+		xfree(slurmdbd_conf->auth_type);
+		xfree(slurmdbd_conf->dbd_addr);
+		xfree(slurmdbd_conf->dbd_host);
+		slurmdbd_conf->dbd_port = 0;
+		xfree(slurmdbd_conf->log_file);
+		xfree(slurmdbd_conf->pid_file);
+		xfree(slurmdbd_conf->plugindir);
+		xfree(slurmdbd_conf->slurm_user_name);
+		xfree(slurmdbd_conf->storage_host);
+		xfree(slurmdbd_conf->storage_loc);
+		xfree(slurmdbd_conf->storage_pass);
+		slurmdbd_conf->storage_port = 0;
+		xfree(slurmdbd_conf->storage_type);
+		xfree(slurmdbd_conf->storage_user);
+	}
+}
+
+/*
+ * read_slurmdbd_conf - load the SlurmDBD configuration from the slurmdbd.conf  
+ *	file. Store result into global variable slurmdbd_conf. 
+ *	This function can be called more than once.
+ * RET SLURM_SUCCESS if no error, otherwise an error code
+ */
+extern int read_slurmdbd_conf(void)
+{
+	s_p_options_t options[] = {
+		{"AuthInfo", S_P_STRING},
+		{"AuthType", S_P_STRING},
+		{"DbdAddr", S_P_STRING},
+		{"DbdHost", S_P_STRING},
+		{"DbdPort", S_P_UINT16},
+		{"DebugLevel", S_P_UINT16},
+		{"LogFile", S_P_STRING},
+		{"MessageTimeout", S_P_UINT16},
+		{"PidFile", S_P_STRING},
+		{"PluginDir", S_P_STRING},
+		{"SlurmUser", S_P_STRING},
+		{"StorageHost", S_P_STRING},
+		{"StorageLoc", S_P_STRING},
+		{"StoragePass", S_P_STRING},
+		{"StoragePort", S_P_UINT16},
+		{"StorageType", S_P_STRING},
+		{"StorageUser", S_P_STRING},
+		{NULL} };
+	s_p_hashtbl_t *tbl;
+	char *conf_path;
+	struct stat buf;
+
+	/* Set initial values */
+	slurm_mutex_lock(&conf_mutex);
+	if (slurmdbd_conf == NULL)
+		slurmdbd_conf = xmalloc(sizeof(slurm_dbd_conf_t));
+	slurmdbd_conf->debug_level = LOG_LEVEL_INFO;
+	_clear_slurmdbd_conf();
+
+	/* Get the slurmdbd.conf path and validate the file */
+	conf_path = _get_conf_path();
+	if ((conf_path == NULL) || (stat(conf_path, &buf) == -1)) {
+		info("No slurmdbd.conf file (%s)", conf_path);
+	} else {
+		debug("Reading slurmdbd.conf file %s", conf_path);
+
+		tbl = s_p_hashtbl_create(options);
+		if (s_p_parse_file(tbl, conf_path) == SLURM_ERROR) {
+			fatal("Could not open/read/parse slurmdbd.conf file %s",
+		 	     conf_path);
+		}
+
+		s_p_get_string(&slurmdbd_conf->auth_info, "AuthInfo", tbl);
+		s_p_get_string(&slurmdbd_conf->auth_type, "AuthType", tbl);
+		s_p_get_string(&slurmdbd_conf->dbd_host, "DbdHost", tbl);
+		s_p_get_string(&slurmdbd_conf->dbd_addr, "DbdAddr", tbl);
+		s_p_get_uint16(&slurmdbd_conf->dbd_port, "DbdPort", tbl);
+		s_p_get_uint16(&slurmdbd_conf->debug_level, "DebugLevel", tbl);
+		s_p_get_string(&slurmdbd_conf->log_file, "LogFile", tbl);
+		if (!s_p_get_uint16(&slurmdbd_conf->msg_timeout,
+				    "MessageTimeout", tbl))
+			slurmdbd_conf->msg_timeout = DEFAULT_MSG_TIMEOUT;
+		else if (slurmdbd_conf->msg_timeout > 100) {
+			info("WARNING: MessageTimeout is too high for "
+			     "effective fault-tolerance");
+		}
+		s_p_get_string(&slurmdbd_conf->pid_file, "PidFile", tbl);
+		s_p_get_string(&slurmdbd_conf->plugindir, "PluginDir", tbl);
+		s_p_get_string(&slurmdbd_conf->slurm_user_name, "SlurmUser",
+			       tbl);
+		s_p_get_string(&slurmdbd_conf->storage_host,
+				"StorageHost", tbl);
+		s_p_get_string(&slurmdbd_conf->storage_loc,
+				"StorageLoc", tbl);
+		s_p_get_string(&slurmdbd_conf->storage_pass,
+				"StoragePass", tbl);
+		s_p_get_uint16(&slurmdbd_conf->storage_port,
+			       "StoragePort", tbl);
+		s_p_get_string(&slurmdbd_conf->storage_type,
+			       "StorageType", tbl);
+		s_p_get_string(&slurmdbd_conf->storage_user,
+				"StorageUser", tbl);
+
+		s_p_hashtbl_destroy(tbl);
+	}
+
+	xfree(conf_path);
+	if (slurmdbd_conf->auth_type == NULL)
+		slurmdbd_conf->auth_type = xstrdup(DEFAULT_SLURMDBD_AUTHTYPE);
+	if (slurmdbd_conf->dbd_host == NULL) {
+		error("slurmdbd.conf lacks DbdHost parameter, using 'localhost'");
+		slurmdbd_conf->dbd_host = xstrdup("localhost");
+	}
+	if (slurmdbd_conf->dbd_addr == NULL)
+		slurmdbd_conf->dbd_addr = xstrdup(slurmdbd_conf->dbd_host);
+	if (slurmdbd_conf->pid_file == NULL)
+		slurmdbd_conf->pid_file = xstrdup(DEFAULT_SLURMDBD_PIDFILE);
+	if (slurmdbd_conf->dbd_port == 0)
+		slurmdbd_conf->dbd_port = SLURMDBD_PORT;
+	if(slurmdbd_conf->plugindir == NULL)
+		slurmdbd_conf->plugindir = xstrdup(default_plugin_path);
+	if (slurmdbd_conf->slurm_user_name) {
+		struct passwd *slurm_passwd;
+		slurm_passwd = getpwnam(slurmdbd_conf->slurm_user_name);
+		if (slurm_passwd == NULL) {
+			fatal("Invalid user for SlurmUser %s, ignored",
+			      slurmdbd_conf->slurm_user_name);
+		} else
+			slurmdbd_conf->slurm_user_id = slurm_passwd->pw_uid;
+	} else {
+		slurmdbd_conf->slurm_user_name = xstrdup("root");
+		slurmdbd_conf->slurm_user_id = 0;
+	}
+	if (slurmdbd_conf->storage_type == NULL)
+		fatal("StorageType must be specified");
+				
+	slurm_mutex_unlock(&conf_mutex);
+	return SLURM_SUCCESS;
+}
+
+/* Log the current configuration using verbose() */
+extern void log_config(void)
+{
+	debug2("AuthInfo          = %s", slurmdbd_conf->auth_info);
+	debug2("AuthType          = %s", slurmdbd_conf->auth_type);
+	debug2("DbdAddr           = %s", slurmdbd_conf->dbd_addr);
+	debug2("DbdHost           = %s", slurmdbd_conf->dbd_host);
+	debug2("DbdPort           = %u", slurmdbd_conf->dbd_port);
+	debug2("DebugLevel        = %u", slurmdbd_conf->debug_level);
+	debug2("LogFile           = %s", slurmdbd_conf->log_file);
+	debug2("MessageTimeout    = %u", slurmdbd_conf->msg_timeout);
+	debug2("PidFile           = %s", slurmdbd_conf->pid_file);
+	debug2("PluginDir         = %s", slurmdbd_conf->plugindir);
+	debug2("SlurmUser         = %s(%u)", 
+		slurmdbd_conf->slurm_user_name, slurmdbd_conf->slurm_user_id); 
+	debug2("StorageHost       = %s", slurmdbd_conf->storage_host);
+	debug2("StorageLoc        = %s", slurmdbd_conf->storage_loc);
+	debug2("StoragePass       = %s", slurmdbd_conf->storage_pass);
+	debug2("StoragePort       = %u", slurmdbd_conf->storage_port);
+	debug2("StorageType       = %s", slurmdbd_conf->storage_type);
+	debug2("StorageUser       = %s", slurmdbd_conf->storage_user);
+}
+
+/* Return the DbdPort value */
+extern uint16_t get_dbd_port(void)
+{
+	uint16_t port;
+
+	slurm_mutex_lock(&conf_mutex);
+	port = slurmdbd_conf->dbd_port;
+	slurm_mutex_unlock(&conf_mutex);
+	return port;
+}
+
+extern void slurmdbd_conf_lock(void)
+{
+	slurm_mutex_lock(&conf_mutex);
+}
+
+extern void slurmdbd_conf_unlock(void)
+{
+	slurm_mutex_unlock(&conf_mutex);
+}
+
+
+/* Return the pathname of the slurmdbd.conf file.
+ * xfree() the value returned */
+static char * _get_conf_path(void)
+{
+	char *val = getenv("SLURM_CONF");
+	char *path = NULL;
+	int i;
+
+	if (!val)
+		val = default_slurm_config_file;
+
+	/* Replace file name on end of path */
+	i = strlen(val) + 15;
+	path = xmalloc(i);
+	strcpy(path, val);
+	val = strrchr(path, (int)'/');
+	if (val)	/* absolute path */
+		val++;
+	else		/* not absolute path */
+		val = path;
+	strcpy(val, "slurmdbd.conf");
+
+	return path;
+}
diff --git a/src/slurmdbd/read_config.h b/src/slurmdbd/read_config.h
new file mode 100644
index 0000000000000000000000000000000000000000..79d09c5141db385e4e57ea806ee13f6c439cef75
--- /dev/null
+++ b/src/slurmdbd/read_config.h
@@ -0,0 +1,110 @@
+/*****************************************************************************\
+ *  read_config.h - functions and declarations for reading slurmdbd.conf
+ *****************************************************************************
+ *  Copyright (C) 2003-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef _DBD_READ_CONFIG_H
+#define _DBD_READ_CONFIG_H
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#else  /* !HAVE_INTTYPES_H */
+#  if HAVE_STDINT_H
+#    include <stdint.h>
+#  endif
+#endif  /* HAVE_INTTYPES_H */
+#else   /* !HAVE_CONFIG_H */
+#include <stdint.h>
+#endif  /* HAVE_CONFIG_H */
+
+#include <time.h>
+
+#define DEFAULT_SLURMDBD_AUTHTYPE	"auth/none"
+#define DEFAULT_SLURMDBD_PIDFILE	"/var/run/slurmdbd.pid"
+
+/* SlurmDBD configuration parameters */
+typedef struct slurm_dbd_conf {
+	time_t		last_update;	/* time slurmdbd.conf read	*/
+	char *		auth_info;	/* authentication info		*/
+	char *		auth_type;	/* authentication mechanism	*/
+	char *		dbd_addr;	/* network address of Slurm DBD	*/
+	char *		dbd_host;	/* hostname of Slurm DBD	*/
+	uint16_t	dbd_port;	/* port number for RPCs to DBD	*/
+	uint16_t	debug_level;	/* Debug level, default=3	*/
+	char *		log_file;	/* Log file			*/
+	uint16_t        msg_timeout;    /* message timeout */   
+	char *		pid_file;	/* where to store current PID	*/
+	char *		plugindir;	/* dir to look for plugins	*/
+	uint32_t	slurm_user_id;	/* uid of slurm_user_name	*/
+	char *		slurm_user_name;/* user that slurmcdtld runs as	*/
+	char *		storage_host;	/* host where DB is running	*/
+	char *		storage_loc;	/* database name */
+	char *		storage_pass;   /* password for DB write	*/
+	uint16_t	storage_port;	/* port DB is listening to	*/
+	char *		storage_type;	/* DB to be used for storage	*/
+	char *		storage_user;	/* user authorized to write DB	*/
+} slurm_dbd_conf_t;
+
+extern pthread_mutex_t conf_mutex;
+extern slurm_dbd_conf_t *slurmdbd_conf;
+
+
+/*
+ * free_slurmdbd_conf - free storage associated with the global variable 
+ *	slurmdbd_conf
+ */
+extern void free_slurmdbd_conf(void);
+
+/* Return the DbdPort value */
+extern uint16_t get_dbd_port(void);
+
+/* lock and unlock the dbd_conf */
+extern void slurmdbd_conf_lock(void);
+extern void slurmdbd_conf_unlock(void);
+
+/* Log the current configuration using verbose() */
+extern void log_config(void);
+
+/*
+ * read_slurmdbd_conf - load the SlurmDBD configuration from the slurmdbd.conf  
+ *	file. This function can be called more than once if so desired.
+ * RET SLURM_SUCCESS if no error, otherwise an error code
+ */
+extern int read_slurmdbd_conf(void);
+
+#endif /* !_DBD_READ_CONFIG_H */
diff --git a/src/slurmdbd/rpc_mgr.c b/src/slurmdbd/rpc_mgr.c
new file mode 100644
index 0000000000000000000000000000000000000000..e58f503cc4a8bed20eec2f2b75a86ff9ffb75123
--- /dev/null
+++ b/src/slurmdbd/rpc_mgr.c
@@ -0,0 +1,523 @@
+/*****************************************************************************\
+ *  rpc_mgr.h - functions for processing RPCs.
+ *****************************************************************************
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+#include <arpa/inet.h>
+#include <pthread.h>
+#include <signal.h>
+#include <sys/poll.h>
+#include <sys/time.h>
+
+#include "src/common/fd.h"
+#include "src/common/log.h"
+#include "src/common/macros.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurmdbd_defs.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xsignal.h"
+#include "src/slurmdbd/proc_req.h"
+#include "src/slurmdbd/read_config.h"
+#include "src/slurmdbd/rpc_mgr.h"
+#include "src/slurmdbd/slurmdbd.h"
+
+#define MAX_THREAD_COUNT 50
+
+/* Local functions */
+static bool   _fd_readable(slurm_fd fd);
+static bool   _fd_writeable(slurm_fd fd);
+static void   _free_server_thread(pthread_t my_tid);
+static int    _send_resp(slurm_fd fd, Buf buffer);
+static void * _service_connection(void *arg);
+static void   _sig_handler(int signal);
+static int    _tot_wait (struct timeval *start_time);
+static int    _wait_for_server_thread(void);
+static void   _wait_for_thread_fini(void);
+
+/* Local variables */
+static pthread_t       master_thread_id = 0, slave_thread_id[MAX_THREAD_COUNT];
+static int             thread_count = 0;
+static pthread_mutex_t thread_count_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t  thread_count_cond = PTHREAD_COND_INITIALIZER;
+
+typedef struct connection_arg {
+	slurm_fd newsockfd;
+} connection_arg_t;
+
+
+/* Process incoming RPCs. Meant to execute as a pthread */
+extern void *rpc_mgr(void *no_data)
+{
+	pthread_attr_t thread_attr_rpc_req;
+	slurm_fd sockfd, newsockfd;
+	int i, retry_cnt, sigarray[] = {SIGUSR1, 0};
+	slurm_addr cli_addr;
+	connection_arg_t *conn_arg = NULL;
+
+	slurm_mutex_lock(&thread_count_lock);
+	master_thread_id = pthread_self();
+	slurm_mutex_unlock(&thread_count_lock);
+
+	(void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+	(void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+	/* threads to process individual RPC's are detached */
+	slurm_attr_init(&thread_attr_rpc_req);
+	if (pthread_attr_setdetachstate
+	    (&thread_attr_rpc_req, PTHREAD_CREATE_DETACHED))
+		fatal("pthread_attr_setdetachstate %m");
+
+	/* initialize port for RPCs */
+	if ((sockfd = slurm_init_msg_engine_port(get_dbd_port()))
+	    == SLURM_SOCKET_ERROR)
+		fatal("slurm_init_msg_engine_port error %m");
+
+	/* Prepare to catch SIGUSR1 to interrupt accept().
+	 * This signal is generated by the slurmdbd signal
+	 * handler thread upon receipt of SIGABRT, SIGINT, 
+	 * or SIGTERM. That thread does all processing of  
+	 * all signals. */
+	xsignal(SIGUSR1, _sig_handler);
+	xsignal_unblock(sigarray);
+
+	/*
+	 * Process incoming RPCs until told to shutdown
+	 */
+	while ((i = _wait_for_server_thread()) >= 0) {
+		/*
+		 * accept needed for stream implementation is a no-op in 
+		 * message implementation that just passes sockfd to newsockfd
+		 */
+		if ((newsockfd = slurm_accept_msg_conn(sockfd,
+						       &cli_addr)) ==
+		    SLURM_SOCKET_ERROR) {
+			_free_server_thread((pthread_t) 0);
+			if (errno != EINTR)
+				error("slurm_accept_msg_conn: %m");
+			continue;
+		}
+		fd_set_nonblocking(newsockfd);
+		conn_arg = xmalloc(sizeof(connection_arg_t));
+		conn_arg->newsockfd = newsockfd;
+		retry_cnt = 0;
+		while (pthread_create(&slave_thread_id[i],
+				      &thread_attr_rpc_req,
+				      _service_connection,
+				      (void *) conn_arg)) {
+			if (retry_cnt > 0) {
+				error("pthread_create failure, "
+				      "aborting RPC: %m");
+				close(newsockfd);
+				break;
+			}
+			error("pthread_create failure: %m");
+			retry_cnt++;
+			usleep(1000);	/* retry in 1 msec */
+		}
+	}
+
+	debug3("rpc_mgr shutting down");
+	slurm_attr_destroy(&thread_attr_rpc_req);
+	(void) slurm_shutdown_msg_engine(sockfd);
+	_wait_for_thread_fini();
+	pthread_exit((void *) 0);
+	return NULL;
+}
+
+/* Wake up the RPC manager and all spawned threads so they can exit */
+extern void rpc_mgr_wake(void)
+{
+	int i;
+
+	slurm_mutex_lock(&thread_count_lock);
+	if (master_thread_id)
+		pthread_kill(master_thread_id, SIGUSR1);
+	for (i=0; i<MAX_THREAD_COUNT; i++) {
+		if (slave_thread_id[i])
+			pthread_kill(slave_thread_id[i], SIGUSR1);
+	}
+	slurm_mutex_unlock(&thread_count_lock);
+}
+
+static void * _service_connection(void *arg)
+{
+	connection_arg_t *conn = (connection_arg_t *) arg;
+	uint32_t nw_size, msg_size, uid;
+	char *msg = NULL;
+	ssize_t msg_read, offset;
+	bool fini = false, first = true;
+	Buf buffer = NULL;
+	int rc;
+	void *db_conn = NULL;
+			 
+	debug2("Opened connection %d", conn->newsockfd);
+	while (!fini) {
+		if (!_fd_readable(conn->newsockfd))
+			break;		/* problem with this socket */
+		msg_read = read(conn->newsockfd, &nw_size, sizeof(nw_size));
+		if (msg_read == 0)	/* EOF */
+			break;
+		if (msg_read != sizeof(nw_size)) {
+			error("Could not read msg_size from connection %d",
+			      conn->newsockfd);
+			break;
+		}
+		msg_size = ntohl(nw_size);
+		if ((msg_size < 2) || (msg_size > 1000000)) {
+			error("Invalid msg_size (%u) from connection %d",
+			      conn->newsockfd);
+			break;
+		}
+
+		msg = xmalloc(msg_size);
+		offset = 0;
+		while (msg_size > offset) {
+			if (!_fd_readable(conn->newsockfd))
+				break;		/* problem with this socket */
+			msg_read = read(conn->newsockfd, (msg + offset), 
+					(msg_size - offset));
+			if (msg_read <= 0) {
+				error("read(%d): %m", conn->newsockfd);
+				break;
+			}
+			offset += msg_read;
+		}
+		if (msg_size == offset) {
+			rc = proc_req(&db_conn, conn->newsockfd,
+				      msg, msg_size, first, &buffer, &uid);
+			first = false;
+			if (rc != SLURM_SUCCESS) {
+				error("Processing message from connection %d",
+				      conn->newsockfd);
+				//fini = true;
+			}
+		} else {
+			buffer = make_dbd_rc_msg(SLURM_ERROR, "Bad offset", 0);
+			fini = true;
+		}
+
+		rc = _send_resp(conn->newsockfd, buffer);
+		xfree(msg);
+	}
+
+	acct_storage_g_close_connection(&db_conn);
+	if (slurm_close_accepted_conn(conn->newsockfd) < 0)
+		error("close(%d): %m",  conn->newsockfd);
+	else
+		debug2("Closed connection %d uid(%d)", conn->newsockfd, uid);
+	xfree(arg);
+	_free_server_thread(pthread_self());
+	return NULL;
+}
+
+/* Return a buffer containing a DBD_RC (return code) message
+ * caller must free returned buffer */
+extern Buf make_dbd_rc_msg(int rc, char *comment, uint16_t sent_type)
+{
+	Buf buffer;
+
+	dbd_rc_msg_t msg;
+	buffer = init_buf(1024);
+	pack16((uint16_t) DBD_RC, buffer);
+	msg.return_code  = rc;
+	msg.comment  = comment;
+	msg.sent_type  = sent_type;
+	slurmdbd_pack_rc_msg(&msg, buffer);
+	return buffer;
+}
+
+static int _send_resp(slurm_fd fd, Buf buffer)
+{
+	uint32_t msg_size, nw_size;
+	ssize_t msg_wrote;
+	char *out_buf;
+
+	if ((fd < 0) || (!_fd_writeable(fd)))
+		goto io_err;
+
+	msg_size = get_buf_offset(buffer);
+	nw_size = htonl(msg_size);
+	if (!_fd_writeable(fd))
+		goto io_err;
+	msg_wrote = write(fd, &nw_size, sizeof(nw_size));
+	if (msg_wrote != sizeof(nw_size))
+		goto io_err;
+
+	out_buf = get_buf_data(buffer);
+	while (msg_size > 0) {
+		if (!_fd_writeable(fd))
+			goto io_err;
+		msg_wrote = write(fd, out_buf, msg_size);
+		if (msg_wrote <= 0)
+			goto io_err;
+		out_buf  += msg_wrote;
+		msg_size -= msg_wrote;
+	}
+	free_buf(buffer);
+	return SLURM_SUCCESS;
+
+io_err:
+	free_buf(buffer);
+	return SLURM_ERROR;
+}
+
+/* Return time in msec since "start time" */
+static int _tot_wait (struct timeval *start_time)
+{
+	struct timeval end_time;
+	int msec_delay;
+
+	gettimeofday(&end_time, NULL);
+	msec_delay =   (end_time.tv_sec  - start_time->tv_sec ) * 1000;
+	msec_delay += ((end_time.tv_usec - start_time->tv_usec + 500) / 1000);
+	return msec_delay;
+}
+
+/* Wait until a file is readable, return false if can not be read */
+static bool _fd_readable(slurm_fd fd)
+{
+	struct pollfd ufds;
+	int rc;
+
+	ufds.fd     = fd;
+	ufds.events = POLLIN;
+	while (1) {
+		rc = poll(&ufds, 1, -1);
+		if (shutdown_time)
+			return false;
+		if (rc == -1) {
+			if ((errno == EINTR) || (errno == EAGAIN))
+				continue;
+			error("poll: %m");
+			return false;
+		}
+		if (ufds.revents & POLLHUP) {
+			debug3("Read connection %d closed", fd);
+			return false;
+		}
+		if (ufds.revents & POLLNVAL) {
+			error("Connection %d is invalid", fd);
+			return false;
+		}
+		if (ufds.revents & POLLERR) {
+			error("Connection %d experienced an error", fd);
+			return false;
+		}
+		if ((ufds.revents & POLLIN) == 0) {
+			error("Connection %d events %d", fd, ufds.revents);
+			return false;
+		}
+		break;
+	}
+	return true;
+}
+
+/* Wait until a file is writeable, 
+ * RET false if can not be written to within 5 seconds */
+static bool _fd_writeable(slurm_fd fd)
+{
+	struct pollfd ufds;
+	int msg_timeout = 5000;
+	int rc, time_left;
+	struct timeval tstart;
+
+	ufds.fd     = fd;
+	ufds.events = POLLOUT;
+	gettimeofday(&tstart, NULL);
+	while (1) {
+		time_left = msg_timeout - _tot_wait(&tstart);
+		rc = poll(&ufds, 1, time_left);
+		if (shutdown_time)
+			return false;
+		if (rc == -1) {
+			if ((errno == EINTR) || (errno == EAGAIN))
+				continue;
+			error("poll: %m");
+			return false;
+		}
+		if (rc == 0) {
+			error("write timeout");
+			return false;
+		}
+		if (ufds.revents & POLLHUP) {
+			debug3("Write connection %d closed", fd);
+			return false;
+		}
+		if (ufds.revents & POLLNVAL) {
+			error("Connection %d is invalid", fd);
+			return false;
+		}
+		if (ufds.revents & POLLERR) {
+			error("Connection %d experienced an error", fd);
+			return false;
+		}
+		if ((ufds.revents & POLLOUT) == 0) {
+			error("Connection %d events %d", fd, ufds.revents);
+			return false;
+		}
+		break;
+	}
+	return true;
+}
+
+/* Increment thread_count and don't return until its value is no larger 
+ *	than MAX_THREAD_COUNT,
+ * RET index of free index in slave_pthread_id or -1 to exit */
+static int _wait_for_server_thread(void)
+{
+	bool print_it = true;
+	int i, rc = -1;
+
+	slurm_mutex_lock(&thread_count_lock);
+	while (1) {
+		if (shutdown_time)
+			break;
+
+		if (thread_count < MAX_THREAD_COUNT) {
+			thread_count++;
+			for (i=0; i<MAX_THREAD_COUNT; i++) {
+				if (slave_thread_id[i])
+					continue;
+				rc = i;
+				break;
+			}
+			if (rc == -1) {
+				/* thread_count and slave_thread_id 
+				 * out of sync */
+				fatal("No free slave_thread_id");
+			}
+			break;
+		} else {
+			/* wait for state change and retry, 
+			 * just a delay and not an error.
+			 * This can happen when the epilog completes
+			 * on a bunch of nodes at the same time, which
+			 * can easily happen for highly parallel jobs. */
+			if (print_it) {
+				static time_t last_print_time = 0;
+				time_t now = time(NULL);
+				if (difftime(now, last_print_time) > 2) {
+					verbose("thread_count over "
+						"limit (%d), waiting", 
+						thread_count);
+					last_print_time = now;
+				}
+				print_it = false;
+			}
+			pthread_cond_wait(&thread_count_cond, 
+			                  &thread_count_lock);
+		}
+	}
+	slurm_mutex_unlock(&thread_count_lock);
+	return rc;
+}
+
+/* my_tid IN - Thread ID of spawned thread, 0 if no thread spawned */
+static void _free_server_thread(pthread_t my_tid)
+{
+	int i;
+
+	slurm_mutex_lock(&thread_count_lock);
+	if (thread_count > 0)
+		thread_count--;
+	else
+		error("thread_count underflow");
+
+	if (my_tid) {
+		for (i=0; i<MAX_THREAD_COUNT; i++) {
+			if (slave_thread_id[i] != my_tid)
+				continue;
+			slave_thread_id[i] = (pthread_t) 0;
+			break;
+		}
+		if (i >= MAX_THREAD_COUNT)
+			error("Could not find slave_thread_id");
+	}
+
+	slurm_mutex_unlock(&thread_count_lock);
+	pthread_cond_broadcast(&thread_count_cond);
+}
+
+/* Wait for all RPC handler threads to exit.
+ * After one second, start sending SIGKILL to the threads. */
+static void _wait_for_thread_fini(void)
+{
+	int i, j;
+
+	if (thread_count == 0)
+		return;
+	usleep(500000);	/* Give the threads 500 msec to clean up */
+
+	/* Interupt any hung I/O */
+	slurm_mutex_lock(&thread_count_lock);
+	for (j=0; j<MAX_THREAD_COUNT; j++) {
+		if (slave_thread_id[j] == 0)
+			continue;
+		pthread_kill(slave_thread_id[j], SIGUSR1);
+	}
+	slurm_mutex_unlock(&thread_count_lock);
+	usleep(100000);	/* Give the threads 100 msec to clean up */
+
+	for (i=0; ; i++) {
+		if (thread_count == 0)
+			return;
+
+		slurm_mutex_lock(&thread_count_lock);
+		for (j=0; j<MAX_THREAD_COUNT; j++) {
+			if (slave_thread_id[j] == 0)
+				continue;
+			info("rpc_mgr sending SIGKILL to thread %u", 
+			     slave_thread_id[j]);
+			if (pthread_kill(slave_thread_id[j], SIGKILL)) {
+				slave_thread_id[j] = 0;
+				if (thread_count > 0)
+					thread_count--;
+				else
+					error("thread_count underflow");
+			}
+		}
+		slurm_mutex_unlock(&thread_count_lock);
+		sleep(1);
+	}
+}
+
+static void _sig_handler(int signal)
+{
+}
diff --git a/src/srun/msg.h b/src/slurmdbd/rpc_mgr.h
similarity index 73%
rename from src/srun/msg.h
rename to src/slurmdbd/rpc_mgr.h
index 0bd2078c8b9f10e3e3e7d4346e955850b816eb03..2f5c881cb70a06afe4ba12cec605c51e7a2f6512 100644
--- a/src/srun/msg.h
+++ b/src/slurmdbd/rpc_mgr.h
@@ -1,11 +1,10 @@
 /*****************************************************************************\
- * src/srun/msg.h - message traffic between srun and slurmd routines
- * $Id: msg.h 10574 2006-12-15 23:38:29Z jette $
+ *  rpc_mgr.h - functions and definitions for processing RPCs.
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -16,7 +15,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -36,21 +35,20 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#include "src/srun/srun_job.h"
+#ifndef _RPC_MGR_H
+#define _RPC_MGR_H
 
-#ifndef _HAVE_MSG_H
-#define _HAVE_MSG_H
+#include "src/common/pack.h"
+#include "src/common/assoc_mgr.h"
 
-void     *msg_thr(void *arg);
-int       msg_thr_create(srun_job_t *job);
-slurm_fd  slurmctld_msg_init(void);
-void      timeout_handler(time_t timeout);
+/* Return a buffer containing a DBD_RC (return code) message
+ * caller must free returned buffer */
+extern Buf make_dbd_rc_msg(int rc, char *comment, uint16_t sent_type);
 
-typedef struct slurmctld_communication_addr {
-	char *hostname;
-	uint16_t port;
-} slurmctld_comm_addr_t;
+/* Process incoming RPCs. Meant to execute as a pthread */
+extern void *rpc_mgr(void *no_data);
 
-slurmctld_comm_addr_t slurmctld_comm_addr;
+/* Wake up the RPC manager so that it can exit */
+extern void rpc_mgr_wake(void);
 
-#endif /* !_HAVE_MSG_H */
+#endif /* !_RPC_MGR_H */
diff --git a/src/slurmdbd/slurmdbd.c b/src/slurmdbd/slurmdbd.c
new file mode 100644
index 0000000000000000000000000000000000000000..6738308ef6a7a451d26c202f3c95b5caf12446c2
--- /dev/null
+++ b/src/slurmdbd/slurmdbd.c
@@ -0,0 +1,465 @@
+/*****************************************************************************\
+ *  slurmdbd.c - functions for SlurmDBD
+ *****************************************************************************
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under 
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "src/common/daemonize.h"
+#include "src/common/fd.h"
+#include "src/common/log.h"
+#include "src/common/read_config.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurm_auth.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xsignal.h"
+#include "src/common/xstring.h"
+#include "src/slurmdbd/read_config.h"
+#include "src/slurmdbd/rpc_mgr.h"
+
+/* Global variables */
+time_t shutdown_time = 0;		/* when shutdown request arrived */
+
+/* Local variables */
+static int    dbd_sigarray[] = {	/* blocked signals for this process */
+			SIGINT,  SIGTERM, SIGCHLD, SIGUSR1,
+			SIGUSR2, SIGTSTP, SIGXCPU, SIGQUIT,
+			SIGPIPE, SIGALRM, SIGABRT, SIGHUP, 0 };
+static int    debug_level = 0;		/* incremented for -v on command line */
+static int    foreground = 0;		/* run process as a daemon */
+static log_options_t log_opts = 	/* Log to stderr & syslog */
+			LOG_OPTS_INITIALIZER;
+static pthread_t rpc_handler_thread;	/* thread ID for RPC hander */
+static pthread_t signal_handler_thread;	/* thread ID for signal hander */
+static pthread_t rollup_handler_thread;	/* thread ID for rollup hander */
+static pthread_mutex_t rollup_lock = PTHREAD_MUTEX_INITIALIZER;
+static bool running_rollup = 0;
+
+/* Local functions */
+static void  _daemonize(void);
+static void  _default_sigaction(int sig);
+static void  _init_config(void);
+static void  _init_pidfile(void);
+static void  _kill_old_slurmdbd(void);
+static void  _parse_commandline(int argc, char *argv[]);
+static void _rollup_handler_cancel();
+static void *_rollup_handler(void *no_data);
+static void *_signal_handler(void *no_data);
+static void  _update_logging(void);
+static void  _usage(char *prog_name);
+
+/* main - slurmctld main function, start various threads and process RPCs */
+int main(int argc, char *argv[])
+{
+	pthread_attr_t thread_attr;
+	char node_name[128];
+	void *db_conn = NULL;
+
+	_init_config();
+	log_init(argv[0], log_opts, LOG_DAEMON, NULL);
+	if (read_slurmdbd_conf())
+		exit(1);
+	_parse_commandline(argc, argv);
+	_update_logging();
+
+	if (gethostname_short(node_name, sizeof(node_name)))
+		fatal("getnodename: %m");
+	if (slurmdbd_conf->dbd_host &&
+	    strcmp(slurmdbd_conf->dbd_host, node_name) &&
+	    strcmp(slurmdbd_conf->dbd_host, "localhost")) {
+		fatal("This host not configured to run SlurmDBD (%s != %s)",
+		      node_name, slurmdbd_conf->dbd_host);
+	}
+	if (slurm_auth_init(NULL) != SLURM_SUCCESS) {
+		fatal("Unable to initialize %s authentication plugin",
+			slurmdbd_conf->auth_type);
+	}
+	if (slurm_acct_storage_init(NULL) != SLURM_SUCCESS) {
+		fatal("Unable to initialize %s accounting storage plugin",
+			slurmdbd_conf->storage_type);
+	}
+	_kill_old_slurmdbd();
+	if (foreground == 0)
+		_daemonize();
+	_init_pidfile();
+	log_config();
+	info("slurmdbd version %s started", SLURM_VERSION);
+	if (xsignal_block(dbd_sigarray) < 0)
+		error("Unable to block signals");
+
+	/* Create attached thread for signal handling */
+	slurm_attr_init(&thread_attr);
+	if (pthread_create(&signal_handler_thread, &thread_attr,
+			   _signal_handler, NULL))
+		fatal("pthread_create %m");
+	slurm_attr_destroy(&thread_attr);
+
+	db_conn = acct_storage_g_get_connection(false, false);
+	
+	if(assoc_mgr_init(db_conn, 0) == SLURM_ERROR) {
+		error("Problem getting cache of data");
+		acct_storage_g_close_connection(&db_conn);
+		goto end_it;
+	}
+
+	/* Create attached thread to process incoming RPCs */
+	slurm_attr_init(&thread_attr);
+	if (pthread_create(&rpc_handler_thread, &thread_attr, rpc_mgr, NULL))
+		fatal("pthread_create error %m");
+	slurm_attr_destroy(&thread_attr);
+
+	/* Create attached thread to do usage rollup */
+	slurm_attr_init(&thread_attr);
+	if (pthread_create(&rollup_handler_thread, &thread_attr,
+			   _rollup_handler, db_conn))
+		fatal("pthread_create error %m");
+	slurm_attr_destroy(&thread_attr);
+
+	/* Daemon is fully operational here */
+
+	/* Daemon termination handled here */
+	pthread_join(rollup_handler_thread, NULL);
+
+	pthread_join(rpc_handler_thread, NULL);
+
+	pthread_join(signal_handler_thread, NULL);
+
+end_it:
+	acct_storage_g_close_connection(&db_conn);
+
+	if (slurmdbd_conf->pid_file &&
+	    (unlink(slurmdbd_conf->pid_file) < 0)) {
+		verbose("Unable to remove pidfile '%s': %m",
+			slurmdbd_conf->pid_file);
+	}
+
+	assoc_mgr_fini();
+	slurm_acct_storage_fini();
+	slurm_auth_fini();
+	log_fini();
+	free_slurmdbd_conf();
+	exit(0);
+}
+
+/* Reset some of the processes resource limits to the hard limits */
+static void  _init_config(void)
+{
+	struct rlimit rlim;
+
+	if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) {
+		rlim.rlim_cur = rlim.rlim_max;
+		(void) setrlimit(RLIMIT_NOFILE, &rlim);
+	}
+	if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
+		rlim.rlim_cur = rlim.rlim_max;
+		(void) setrlimit(RLIMIT_CORE, &rlim);
+	}
+	if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
+		/* slurmctld can spawn lots of pthreads. 
+		 * Set the (per thread) stack size to a 
+		 * more "reasonable" value to avoid running 
+		 * out of virtual memory and dying */
+		rlim.rlim_cur = rlim.rlim_max;
+		(void) setrlimit(RLIMIT_STACK, &rlim);
+	}
+	if (getrlimit(RLIMIT_DATA, &rlim) == 0) {
+		rlim.rlim_cur = rlim.rlim_max;
+		(void) setrlimit(RLIMIT_DATA, &rlim);
+	}
+}
+
+/*
+ * _parse_commandline - parse and process any command line arguments
+ * IN argc - number of command line arguments
+ * IN argv - the command line arguments
+ * IN/OUT conf_ptr - pointer to current configuration, update as needed
+ */
+static void _parse_commandline(int argc, char *argv[])
+{
+	int c = 0;
+
+	opterr = 0;
+	while ((c = getopt(argc, argv, "DhvV")) != -1)
+		switch (c) {
+		case 'D':
+			foreground = 1;
+			break;
+		case 'h':
+			_usage(argv[0]);
+			exit(0);
+			break;
+		case 'v':
+			debug_level++;
+			break;
+		case 'V':
+			printf("%s %s\n", PACKAGE, SLURM_VERSION);
+			exit(0);
+			break;
+		default:
+			_usage(argv[0]);
+			exit(1);
+		}
+}
+
+/* _usage - print a message describing the command line arguments of 
+ *	slurmctld */
+static void _usage(char *prog_name)
+{
+	fprintf(stderr, "Usage: %s [OPTIONS]\n", prog_name);
+	fprintf(stderr, "  -D         \t"
+			"Run daemon in foreground.\n");
+	fprintf(stderr, "  -h         \t"
+			"Print this help message.\n");
+	fprintf(stderr, "  -v         \t"
+			"Verbose mode. Multiple -v's increase verbosity.\n");
+	fprintf(stderr, "  -V         \t"
+			"Print version information and exit.\n");
+}
+
+/* Reset slurmctld logging based upon configuration parameters */
+static void _update_logging(void) 
+{
+	/* Preserve execute line arguments (if any) */
+	if (debug_level) {
+		slurmdbd_conf->debug_level = MIN(
+			(LOG_LEVEL_INFO + debug_level), 
+			(LOG_LEVEL_END - 1));
+	}
+
+	log_opts.stderr_level  = slurmdbd_conf->debug_level;
+	log_opts.logfile_level = slurmdbd_conf->debug_level;
+	log_opts.syslog_level  = slurmdbd_conf->debug_level;
+
+	if (foreground)
+		log_opts.syslog_level = LOG_LEVEL_QUIET;
+	else {
+		log_opts.stderr_level = LOG_LEVEL_QUIET;
+		if (slurmdbd_conf->log_file)
+			log_opts.syslog_level = LOG_LEVEL_QUIET;
+	}
+
+	log_alter(log_opts, SYSLOG_FACILITY_DAEMON, slurmdbd_conf->log_file);
+}
+
+/* Kill the currently running slurmdbd */
+static void _kill_old_slurmdbd(void)
+{
+	int fd;
+	pid_t oldpid;
+
+	if (slurmdbd_conf->pid_file == NULL) {
+		error("No PidFile configured");
+		return;
+	}
+
+	oldpid = read_pidfile(slurmdbd_conf->pid_file, &fd);
+	if (oldpid != (pid_t) 0) {
+		info("Killing old slurmdbd[%ld]", (long) oldpid);
+		kill(oldpid, SIGTERM);
+
+		/* 
+		 * Wait for previous daemon to terminate
+		 */
+		if (fd_get_readw_lock(fd) < 0) 
+			fatal("Unable to wait for readw lock: %m");
+		(void) close(fd); /* Ignore errors */ 
+	}
+}
+
+/* Create the PidFile if one is configured */
+static void _init_pidfile(void)
+{
+	int   fd;
+
+	if (slurmdbd_conf->pid_file == NULL) {
+		error("No PidFile configured");
+		return;
+	}
+
+	if ((fd = create_pidfile(slurmdbd_conf->pid_file)) < 0)
+		return;
+}
+
+/* Become a daemon (child of init) and 
+ * "cd" to the LogFile directory (if one is configured) */
+static void _daemonize(void)
+{
+	if (daemon(1, 1))
+		error("daemon(): %m");
+	log_alter(log_opts, LOG_DAEMON, slurmdbd_conf->log_file);
+		
+	if (slurmdbd_conf->log_file &&
+	    (slurmdbd_conf->log_file[0] == '/')) {
+		char *slash_ptr, *work_dir;
+		work_dir = xstrdup(slurmdbd_conf->log_file);
+		slash_ptr = strrchr(work_dir, '/');
+		if (slash_ptr == work_dir)
+			work_dir[1] = '\0';
+		else
+			slash_ptr[0] = '\0';
+		if (chdir(work_dir) < 0)
+			fatal("chdir(%s): %m", work_dir);
+		xfree(work_dir);
+	}
+}
+
+static void _rollup_handler_cancel()
+{
+	if(running_rollup)
+		debug("Waiting for rollup thread to finish.");
+	slurm_mutex_lock(&rollup_lock);
+	pthread_cancel(rollup_handler_thread);
+	slurm_mutex_unlock(&rollup_lock);	
+}
+
+/* _rollup_handler - Process rollup duties */
+static void *_rollup_handler(void *db_conn)
+{
+	time_t start_time = time(NULL);
+	time_t next_time;
+/* 	int sigarray[] = {SIGUSR1, 0}; */
+	struct tm tm;
+
+	(void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+	(void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+	if(!localtime_r(&start_time, &tm)) {
+		fatal("Couldn't get localtime for rollup handler %d",
+		      start_time);
+		return NULL;
+	}
+
+	while (1) {
+		if(!db_conn)
+			break;
+		/* run the roll up */
+		slurm_mutex_lock(&rollup_lock);
+		running_rollup = 1;
+		debug2("running rollup at %s", ctime(&start_time));
+		acct_storage_g_roll_usage(db_conn, 0);
+		running_rollup = 0;
+		slurm_mutex_unlock(&rollup_lock);	
+
+		/* sleep for an hour */
+		tm.tm_sec = 0;
+		tm.tm_min = 0;
+		tm.tm_hour++;
+		tm.tm_isdst = -1;
+		next_time = mktime(&tm);
+		sleep((next_time-start_time));
+		start_time = next_time;
+		/* repeat ;) */
+	}
+
+	return NULL;
+}
+
+/* _signal_handler - Process daemon-wide signals */
+static void *_signal_handler(void *no_data)
+{
+	int rc, sig;
+	int sig_array[] = {SIGINT, SIGTERM, SIGHUP, SIGABRT, 0};
+	sigset_t set;
+
+	(void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+	(void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+	/* Make sure no required signals are ignored (possibly inherited) */
+	_default_sigaction(SIGINT);
+	_default_sigaction(SIGTERM);
+	_default_sigaction(SIGHUP);
+	_default_sigaction(SIGABRT);
+
+	while (1) {
+		xsignal_sigset_create(sig_array, &set);
+		rc = sigwait(&set, &sig);
+		if (rc == EINTR)
+			continue;
+		switch (sig) {
+		case SIGHUP:	/* kill -1 */
+			info("Reconfigure signal (SIGHUP) received");
+			read_slurmdbd_conf();
+			_update_logging();
+			break;
+		case SIGINT:	/* kill -2  or <CTRL-C> */
+		case SIGTERM:	/* kill -15 */
+			info("Terminate signal (SIGINT or SIGTERM) received");
+			shutdown_time = time(NULL);
+			rpc_mgr_wake();
+			_rollup_handler_cancel();
+
+			return NULL;	/* Normal termination */
+		case SIGABRT:	/* abort */
+			info("SIGABRT received");
+			abort();	/* Should terminate here */
+			shutdown_time = time(NULL);
+			rpc_mgr_wake();
+			_rollup_handler_cancel();
+			return NULL;
+		default:
+			error("Invalid signal (%d) received", sig);
+		}
+	}
+
+}
+
+/* Reset some signals to their default state to clear any 
+ * inherited signal states */
+static void _default_sigaction(int sig)
+{
+	struct sigaction act;
+
+	if (sigaction(sig, NULL, &act)) {
+		error("sigaction(%d): %m", sig);
+		return;
+	}
+	if (act.sa_handler != SIG_IGN)
+		return;
+
+	act.sa_handler = SIG_DFL;
+	if (sigaction(sig, &act, NULL))
+		error("sigaction(%d): %m", sig);
+}
diff --git a/src/srun/sigstr.h b/src/slurmdbd/slurmdbd.h
similarity index 80%
rename from src/srun/sigstr.h
rename to src/slurmdbd/slurmdbd.h
index d69a6d577bfc1592955af9d1263d059a789f2a12..a5fb94502960cb30173c28379182d5e127b739ba 100644
--- a/src/srun/sigstr.h
+++ b/src/slurmdbd/slurmdbd.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
- * src/srun/sigstr.h - 
- * $Id: sigstr.h 10574 2006-12-15 23:38:29Z jette $
+ *  slurmdbd.h - data structures and function definitions for SlurmDBD
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Morris Jette <jette@llnl.gov>
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -36,15 +36,9 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#ifndef _SIGSTR_H
-#define _SIGSTR_H
+#ifndef _SLURM_DBD_H
+#define _SLURM_DBD_H
 
-/*
- * Returns a descriptive string regarding the signal given in the
- * exit status 'status.' 
- *
- * WIFSIGNALED(status) must be true in order to call this function!
- */
-char *sigstr(int status);
+extern time_t shutdown_time;		/* when shutdown request arrived */
 
-#endif /* !_SIGSTR_H */
+#endif /* !_SLURM_DBD_H */
diff --git a/src/smap/Makefile.am b/src/smap/Makefile.am
index 32f7aff2b19a50375bc5e083e5750cfcf2efd9b5..2ec5094dc8aeaba7eded53b829e67d8ededa4349 100644
--- a/src/smap/Makefile.am
+++ b/src/smap/Makefile.am
@@ -14,7 +14,8 @@ if HAVE_SOME_CURSES
 bin_PROGRAMS = smap
 
 smap_LDADD = \
-	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+	$(top_builddir)/src/api/libslurmhelper.la
 
 noinst_HEADERS = smap.h 
 smap_SOURCES = smap.c \
diff --git a/src/smap/Makefile.in b/src/smap/Makefile.in
index a4bcfd7d4ae7533ef07da6678f9e0aefba8ab929..06f6ec162b72ffa78e71b41610aa42109a8e26e1 100644
--- a/src/smap/Makefile.in
+++ b/src/smap/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -51,6 +51,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -85,11 +87,12 @@ am__EXTRA_smap_SOURCES_DIST = smap.h smap.c job_functions.c \
 	partition_functions.c configure_functions.c grid_functions.c \
 	opts.c
 smap_OBJECTS = $(am_smap_OBJECTS)
-@HAVE_SOME_CURSES_TRUE@smap_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la
+@HAVE_SOME_CURSES_TRUE@smap_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/api/libslurmhelper.la
 smap_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(smap_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -131,6 +134,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -144,10 +148,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -167,7 +174,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -178,6 +188,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -193,6 +205,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -208,6 +221,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -267,7 +281,8 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir) $(BG_INCLUDES) 
 @HAVE_SOME_CURSES_TRUE@smap_LDADD = \
-@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+@HAVE_SOME_CURSES_TRUE@	$(top_builddir)/src/api/libslurmhelper.la
 
 @HAVE_SOME_CURSES_TRUE@noinst_HEADERS = smap.h 
 @HAVE_SOME_CURSES_TRUE@smap_SOURCES = smap.c \
@@ -321,8 +336,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -389,8 +404,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -402,8 +417,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -413,13 +428,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/smap/configure_functions.c b/src/smap/configure_functions.c
index aa5294f7138600b687b946b93ff77f240bd1e128..0f15f36287f2571cd2559eef18eb08fa444917e8 100644
--- a/src/smap/configure_functions.c
+++ b/src/smap/configure_functions.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  configure_functions.c - Functions related to configure mode of smap.
- *  $Id: configure_functions.c 13270 2008-02-14 19:40:44Z da $
+ *  $Id: configure_functions.c 13783 2008-04-03 00:07:07Z da $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -585,11 +585,14 @@ static int _change_state_bps(char *com, int state)
 #ifdef HAVE_BG
 	if ((com[i+3] == 'x')
 	    || (com[i+3] == '-')) {
-		for(j=0; j<3; j++) 
-			if((i+j)>len 
-			   || (com[i+j] < '0' || com[i+j] > 'Z'
-			       || (com[i+j] > '9' && com[i+j] < 'A'))) 
-				goto error_message2;
+		for(j=0; j<3; j++) {
+			if (((i+j) <= len) &&
+			    (((com[i+j] >= '0') && (com[i+j] <= '9')) ||
+			     ((com[i+j] >= 'A') && (com[i+j] <= 'Z'))))
+				continue;
+			goto error_message2; 
+
+		}
 		number = xstrntol(com + i, NULL,
 				  BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE);
 		start[X] = number / (HOSTLIST_BASE * HOSTLIST_BASE);
@@ -598,11 +601,13 @@ static int _change_state_bps(char *com, int state)
 		start[Z] = (number % HOSTLIST_BASE);
 		
 		i += 4;
-		for(j=0; j<3; j++) 
-			if((i+j)>len 
-			   || (com[i+j] < '0' || com[i+j] > 'Z'
-			       || (com[i+j] > '9' && com[i+j] < 'A'))) 
-				goto error_message2;
+		for(j=0; j<3; j++) {
+			if (((i+j) <= len) &&
+			    (((com[i+j] >= '0') && (com[i+j] <= '9')) ||
+			     ((com[i+j] >= 'A') && (com[i+j] <= 'Z'))))
+				continue; 
+			goto error_message2;
+		}
 		number = xstrntol(com + i, NULL,
 				  BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE);
 		end[X] = number / (HOSTLIST_BASE * HOSTLIST_BASE);
@@ -610,11 +615,13 @@ static int _change_state_bps(char *com, int state)
 			/ HOSTLIST_BASE;
 		end[Z] = (number % HOSTLIST_BASE);			
 	} else {
-		for(j=0; j<3; j++) 
-			if((i+j)>len 
-			   || (com[i+j] < '0' || com[i+j] > 'Z'
-			       || (com[i+j] > '9' && com[i+j] < 'A')))
-				goto error_message2;
+		for(j=0; j<3; j++) {
+			if (((i+j) <= len) &&
+			    (((com[i+j] >= '0') && (com[i+j] <= '9')) ||
+			     ((com[i+j] >= 'A') && (com[i+j] <= 'Z'))))
+				continue;
+			goto error_message2;
+		}
 		number = xstrntol(com + i, NULL,
 				  BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE);
 		start[X] = end[X] = number / (HOSTLIST_BASE * HOSTLIST_BASE);
@@ -649,7 +656,7 @@ static int _change_state_bps(char *com, int state)
 	if ((com[i+3] == 'x')
 	    || (com[i+3] == '-')) {
 		start[X] =  xstrntol(com + i, NULL,
-				    BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE);;
+				    BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE);
 		i += 4;
 		end[X] =  xstrntol(com + i, NULL, 
 				   BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE);
diff --git a/src/smap/grid_functions.c b/src/smap/grid_functions.c
index b97c73be62f1f4a120d26a2dee2eac45d680c0d3..86cc099576a0ff9e9f4d1e93d675ee9d252c0ec3 100644
--- a/src/smap/grid_functions.c
+++ b/src/smap/grid_functions.c
@@ -5,7 +5,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/smap/job_functions.c b/src/smap/job_functions.c
index 21eedfc16d9ddb797df147b1db7b014b3a33b572..9a49b3729f0c149ca57a2e2e13b442477e5d8aaa 100644
--- a/src/smap/job_functions.c
+++ b/src/smap/job_functions.c
@@ -5,7 +5,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/smap/opts.c b/src/smap/opts.c
index 2abc184edd9126ce6a51fc4847027343b3a8940d..40a73dbc5b7b0a37f931bfdea81fb2d837fa35dd 100644
--- a/src/smap/opts.c
+++ b/src/smap/opts.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c
index 9e8c6743b9a86961221d96d6070903ae83ac0614..89e24e1b6922e73a4ef2d55f40802a8904722bbd 100644
--- a/src/smap/partition_functions.c
+++ b/src/smap/partition_functions.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  * 
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/smap/smap.c b/src/smap/smap.c
index 9e704f32fed1cd960a289ce76206c8015816a5ec..f6aa3f8f975b58b76fa3272e56aefe6882e2b316 100644
--- a/src/smap/smap.c
+++ b/src/smap/smap.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  smap.c - Report overall state the system
- *  $Id: smap.c 13794 2008-04-04 15:56:01Z da $
+ *  $Id: smap.c 13795 2008-04-04 15:59:14Z da $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/smap/smap.h b/src/smap/smap.h
index b6f3413f662a4dbe60ab511e6a3a49f3bae352e4..28e17a6dd66c86ec80eb4b867316043bbc3aff9d 100644
--- a/src/smap/smap.h
+++ b/src/smap/smap.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/squeue/Makefile.in b/src/squeue/Makefile.in
index 7c71dab52a43bb138a65c89b3538a35f18b11554..1f178ae7dba09fdf9e72760d2712989cb040fc69 100644
--- a/src/squeue/Makefile.in
+++ b/src/squeue/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -48,6 +48,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -78,7 +80,7 @@ squeue_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 squeue_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(squeue_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -300,8 +313,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -366,8 +379,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -379,8 +392,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -390,13 +403,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/squeue/opts.c b/src/squeue/opts.c
index 488a3b947cb1d86cca20ed487f2905846330e2fb..d295de2d7224011a7dc477e9b2ac906556a90d45 100644
--- a/src/squeue/opts.c
+++ b/src/squeue/opts.c
@@ -1,12 +1,12 @@
 /****************************************************************************\
  *  opts.c - srun command line option parsing
  *
- *  $Id: opts.c 12590 2007-10-31 16:08:11Z jette $
+ *  $Id: opts.c 14150 2008-05-29 00:14:29Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>, Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -558,6 +558,11 @@ extern int parse_format( char* format )
 				                        field_size, 
 				                        right_justify, 
 				                        suffix );
+			else if (field[0] == 'Q')
+				 job_format_add_priority_long( params.format_list,
+							field_size,
+							right_justify,
+							suffix );
 			else if (field[0] == 'r')
 				job_format_add_reason( params.format_list,
 							field_size,
diff --git a/src/squeue/print.c b/src/squeue/print.c
index 7aba3a523a5db6f4815a38a9a6178a8144d80507..0225f2ca31608812a36f2d6ee9b416c0cfd829ca 100644
--- a/src/squeue/print.c
+++ b/src/squeue/print.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
  *  print.c - squeue print job functions
- *  $Id: print.c 12951 2008-01-04 00:29:45Z jette $
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>, 
  *             Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *    
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -525,6 +525,20 @@ int _print_job_priority(job_info_t * job, int width, bool right, char* suffix)
 	return SLURM_SUCCESS;
 }
 
+int _print_job_priority_long(job_info_t * job, int width, bool right, char* suffix)
+{
+	char temp[FORMAT_STRING_SIZE];
+	if (job == NULL)	/* Print the Header instead */
+		_print_str("PRIORITY", width, right, true);
+	else {
+		sprintf(temp, "%u", job->priority);
+		_print_str(temp, width, right, true);
+	}
+	if (suffix)
+		printf("%s", suffix);
+	return SLURM_SUCCESS;
+}
+
 int _print_job_nodes(job_info_t * job, int width, bool right, char* suffix)
 {
 	if (job == NULL) {       /* Print the Header instead */
@@ -870,19 +884,12 @@ int _print_job_min_memory(job_info_t * job, int width, bool right_justify,
 			  char* suffix)
 {
 	char min_mem[10];
-	char max_mem[10];
 	char tmp_char[21];
 	
 	if (job == NULL)	/* Print the Header instead */
 		_print_str("MIN_MEMORY", width, right_justify, true);
 	else {
 	    	tmp_char[0] = '\0';
-		if (job->job_max_memory < job->job_min_memory) {
-			convert_num_unit((float)job->job_max_memory, max_mem, 
-					 sizeof(max_mem), UNIT_NONE);
-			strcat(tmp_char, max_mem);
-			strcat(tmp_char, "-");
-		 }
 		convert_num_unit((float)job->job_min_memory, min_mem, 
 				 sizeof(min_mem), UNIT_NONE);
 		strcat(tmp_char, min_mem);
@@ -1024,11 +1031,10 @@ int _print_job_dependency(job_info_t * job, int width, bool right_justify,
 {
 	if (job == NULL)	/* Print the Header instead */
 		_print_str("DEPENDENCY", width, right_justify, true);
-	else {
-		char id[FORMAT_STRING_SIZE];
-		snprintf(id, FORMAT_STRING_SIZE, "%u", job->dependency);
-		_print_str(id, width, right_justify, true);
-	}
+	else if (job->dependency)
+		_print_str(job->dependency, width, right_justify, true);
+	else
+		_print_str("", width, right_justify, true);
 	if (suffix)
 		printf("%s", suffix); 
 	return SLURM_SUCCESS;
diff --git a/src/squeue/print.h b/src/squeue/print.h
index f596f0a14f73a69d728e2cdc97283c83e9bc4daf..a8181aae615bccb7f309c948dfa77809735eebb3 100644
--- a/src/squeue/print.h
+++ b/src/squeue/print.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -115,6 +115,8 @@ int job_format_add_function(List list, int width, bool right_justify,
 	job_format_add_function(list,wid,right,suffix,_print_job_time_end)
 #define job_format_add_priority(list,wid,right,suffix) \
 	job_format_add_function(list,wid,right,suffix,_print_job_priority)
+#define job_format_add_priority_long(list,wid,right,suffix) \
+	job_format_add_function(list,wid,right,suffix,_print_job_priority_long)
 #define job_format_add_nodes(list,wid,right,suffix) \
 	job_format_add_function(list,wid,right,suffix,_print_job_nodes)
 #define job_format_add_node_inx(list,wid,right,suffix) \
@@ -203,6 +205,8 @@ int _print_job_time_end(job_info_t * job, int width, bool right_justify,
 			char* suffix);
 int _print_job_priority(job_info_t * job, int width, bool right_justify, 
 			char* suffix);
+int _print_job_priority_long(job_info_t * job, int width, bool right_justify,
+			char* suffix);
 int _print_job_nodes(job_info_t * job, int width, bool right_justify, 
 			char* suffix);
 int _print_job_node_inx(job_info_t * job, int width, bool right_justify, 
diff --git a/src/squeue/sort.c b/src/squeue/sort.c
index 3783871f9bb9f3106a381525c3b11d1a4510e064..05c42f4f7e3b4eea4a1239a84348997e0d7cc7a0 100644
--- a/src/squeue/sort.c
+++ b/src/squeue/sort.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/squeue/squeue.c b/src/squeue/squeue.c
index 488d9e1e7d9a1d3f03395a1170bd29217385ccfc..7a0a5f3a72b8699284bae99d9822a502d639cc14 100644
--- a/src/squeue/squeue.c
+++ b/src/squeue/squeue.c
@@ -1,13 +1,13 @@
 /*****************************************************************************\
  *  squeue.c - Report jobs in the slurm system
  *
- *  $Id: squeue.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: squeue.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>, 
  *             Morris Jette <jette1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/squeue/squeue.h b/src/squeue/squeue.h
index c5ff3e0975c7b5ae1888ebd8fb55c0cdfb6483c1..0227512ac4652c71f024648b6d068ec29b6b3ee4 100644
--- a/src/squeue/squeue.h
+++ b/src/squeue/squeue.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Joey Ekstrom <ekstrom1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sreport/Makefile.am b/src/sreport/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..a4bf7fccb98431dd184120e564b1488a31b00ba5
--- /dev/null
+++ b/src/sreport/Makefile.am
@@ -0,0 +1,21 @@
+# Makefile for sreport
+
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = -I$(top_srcdir)
+
+bin_PROGRAMS = sreport
+
+sreport_SOURCES =	\
+	sreport.c sreport.h	
+
+sreport_LDADD =  \
+	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la \
+	$(READLINE_LIBS)
+
+sreport_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+
+force:
+$(convenience_libs) : force
+	@cd `dirname $@` && $(MAKE) `basename $@`
diff --git a/src/slaunch/Makefile.in b/src/sreport/Makefile.in
similarity index 80%
rename from src/slaunch/Makefile.in
rename to src/sreport/Makefile.in
index 6e537e164ec1177b0c861c35045e18ddb3bc56b6..e15b13e502bae9d78558c4073f0395a214b7f964 100644
--- a/src/slaunch/Makefile.in
+++ b/src/sreport/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-#
+# Makefile for sreport
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -35,8 +35,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-bin_PROGRAMS = slaunch$(EXEEXT)
-subdir = src/slaunch
+bin_PROGRAMS = sreport$(EXEEXT)
+subdir = src/sreport
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -68,15 +70,16 @@ CONFIG_CLEAN_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_slaunch_OBJECTS = slaunch.$(OBJEXT) opt.$(OBJEXT) attach.$(OBJEXT) \
-	fname.$(OBJEXT) sigstr.$(OBJEXT) core-format.$(OBJEXT) \
-	multi_prog.$(OBJEXT) slaunch.wrapper.$(OBJEXT)
-slaunch_OBJECTS = $(am_slaunch_OBJECTS)
-slaunch_DEPENDENCIES = $(convenience_libs)
-slaunch_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(slaunch_LDFLAGS) \
+am_sreport_OBJECTS = sreport.$(OBJEXT)
+sreport_OBJECTS = $(am_sreport_OBJECTS)
+am__DEPENDENCIES_1 =
+sreport_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
+	$(top_builddir)/src/api/libslurmhelper.la \
+	$(am__DEPENDENCIES_1)
+sreport_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sreport_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -88,8 +91,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(slaunch_SOURCES)
-DIST_SOURCES = $(slaunch_SOURCES)
+SOURCES = $(sreport_SOURCES)
+DIST_SOURCES = $(sreport_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -116,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -129,10 +133,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -152,7 +159,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -163,6 +173,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -178,6 +190,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -193,6 +206,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -250,26 +264,16 @@ target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
-INCLUDES = -I$(top_srcdir) 
-slaunch_SOURCES = \
-	slaunch.c slaunch.h \
-	opt.c opt.h \
-	attach.h    \
-	attach.c    \
-	fname.c     \
-	fname.h     \
-	sigstr.c    \
-	sigstr.h    \
-	core-format.c \
-	core-format.h \
-	multi_prog.c multi_prog.h \
-	slaunch.wrapper.c
-
-convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
-slaunch_LDADD = \
-	$(convenience_libs) 
-
-slaunch_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+INCLUDES = -I$(top_srcdir)
+sreport_SOURCES = \
+	sreport.c sreport.h	
+
+sreport_LDADD = \
+	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la \
+	$(READLINE_LIBS)
+
+sreport_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -283,9 +287,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/slaunch/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/sreport/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/slaunch/Makefile
+	  $(AUTOMAKE) --foreign  src/sreport/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -312,8 +316,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -331,9 +335,9 @@ clean-binPROGRAMS:
 	  echo " rm -f $$p $$f"; \
 	  rm -f $$p $$f ; \
 	done
-slaunch$(EXEEXT): $(slaunch_OBJECTS) $(slaunch_DEPENDENCIES) 
-	@rm -f slaunch$(EXEEXT)
-	$(slaunch_LINK) $(slaunch_OBJECTS) $(slaunch_LDADD) $(LIBS)
+sreport$(EXEEXT): $(sreport_OBJECTS) $(sreport_DEPENDENCIES) 
+	@rm -f sreport$(EXEEXT)
+	$(sreport_LINK) $(sreport_OBJECTS) $(sreport_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -341,14 +345,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attach.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/core-format.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fname.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_prog.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigstr.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slaunch.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slaunch.wrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sreport.Po@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -382,8 +379,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -395,8 +392,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -406,13 +403,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
@@ -506,7 +502,7 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
-install-exec-am: install-binPROGRAMS install-exec-local
+install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
@@ -547,34 +543,19 @@ uninstall-am: uninstall-binPROGRAMS
 	distclean-generic distclean-libtool distclean-tags distdir dvi \
 	dvi-am html html-am info info-am install install-am \
 	install-binPROGRAMS install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-exec-local \
-	install-html install-html-am install-info install-info-am \
-	install-man install-pdf install-pdf-am install-ps \
-	install-ps-am install-strip installcheck installcheck-am \
-	installdirs maintainer-clean maintainer-clean-generic \
-	mostlyclean mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
-	uninstall-am uninstall-binPROGRAMS
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am \
+	uninstall-binPROGRAMS
 
 
 force:
 $(convenience_libs) : force
 	@cd `dirname $@` && $(MAKE) `basename $@`
-
-# debugging information is required for symbols in the attach
-# module so that a debugger can attach to spawned tasks
-attach.o : attach.c
-	$(COMPILE) -c -g -o attach.o $(srcdir)/attach.c 
-
-install-exec-local:
-	umask 022; \
-	if [ -x /usr/lib/rpm/debugedit ]; then \
-	  srcdir=`cd $(top_srcdir) && pwd`; \
-	  /usr/lib/rpm/debugedit -b $$srcdir -d $(pkglibdir) \
-	                         $(DESTDIR)$(bindir)/slaunch; fi; \
-	mkdir -p -m 755 $(DESTDIR)$(pkglibdir)/src/slaunch
-	$(INSTALL) -m 644 $(top_srcdir)/src/slaunch/slaunch.wrapper.c \
-		$(DESTDIR)$(pkglibdir)/src/slaunch/slaunch.wrapper.c
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/src/sreport/sreport.c b/src/sreport/sreport.c
new file mode 100644
index 0000000000000000000000000000000000000000..c3dfb8223eaf579769e4c88352147e9bd382ddf9
--- /dev/null
+++ b/src/sreport/sreport.c
@@ -0,0 +1,379 @@
+/*****************************************************************************\
+ *  sreport.c - report generating tool for slurm accounting.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/sreport/sreport.h"
+#include "src/common/xsignal.h"
+
+#define OPT_LONG_HIDE   0x102
+#define BUFFER_SIZE 4096
+
+char *command_name;
+int exit_code;		/* sreport's exit code, =1 on any error at any time */
+int exit_flag;		/* program to terminate if =1 */
+int input_words;	/* number of words of input permitted */
+int one_liner;		/* one record per line if =1 */
+int quiet_flag;		/* quiet=1, verbose=-1, normal=0 */
+int rollback_flag;       /* immediate execute=1, else = 0 */
+int with_assoc_flag = 0;
+void *db_conn = NULL;
+uint32_t my_uid = 0;
+
+static int	_get_command (int *argc, char *argv[]);
+static void     _print_version( void );
+static int	_process_command (int argc, char *argv[]);
+static void	_usage ();
+
+int 
+main (int argc, char *argv[]) 
+{
+	int error_code = SLURM_SUCCESS, i, opt_char, input_field_count;
+	char **input_fields;
+	log_options_t opts = LOG_OPTS_STDERR_ONLY ;
+
+	int option_index;
+	static struct option long_options[] = {
+		{"help",     0, 0, 'h'},
+		{"immediate",0, 0, 'i'},
+		{"oneliner", 0, 0, 'o'},
+		{"no_header", 0, 0, 'n'},
+		{"parsable", 0, 0, 'p'},
+		{"quiet",    0, 0, 'q'},
+		{"usage",    0, 0, 'h'},
+		{"verbose",  0, 0, 'v'},
+		{"version",  0, 0, 'V'},
+		{NULL,       0, 0, 0}
+	};
+
+	command_name      = argv[0];
+	rollback_flag     = 1;
+	exit_code         = 0;
+	exit_flag         = 0;
+	input_field_count = 0;
+	quiet_flag        = 0;
+	log_init("sacctmgr", opts, SYSLOG_FACILITY_DAEMON, NULL);
+
+	while((opt_char = getopt_long(argc, argv, "hionpqsvV",
+			long_options, &option_index)) != -1) {
+		switch (opt_char) {
+		case (int)'?':
+			fprintf(stderr, "Try \"sacctmgr --help\" "
+				"for more information\n");
+			exit(1);
+			break;
+		case (int)'h':
+			_usage ();
+			exit(exit_code);
+			break;
+		case (int)'i':
+			rollback_flag = 0;
+			break;
+		case (int)'o':
+			one_liner = 1;
+			break;
+/* 		case (int)'n': */
+/* 			have_header = 0; */
+/* 			break; */
+/* 		case (int)'p': */
+/* 			parsable_print = 1; */
+/* 			break; */
+		case (int)'q':
+			quiet_flag = 1;
+			break;
+		case (int)'s':
+			with_assoc_flag = 1;
+			break;
+		case (int)'v':
+			quiet_flag = -1;
+			break;
+		case (int)'V':
+			_print_version();
+			exit(exit_code);
+			break;
+		default:
+			exit_code = 1;
+			fprintf(stderr, "getopt error, returned %c\n", 
+				opt_char);
+			exit(exit_code);
+		}
+	}
+
+	if (argc > MAX_INPUT_FIELDS)	/* bogus input, but continue anyway */
+		input_words = argc;
+	else
+		input_words = 128;
+	input_fields = (char **) xmalloc (sizeof (char *) * input_words);
+	if (optind < argc) {
+		for (i = optind; i < argc; i++) {
+			input_fields[input_field_count++] = argv[i];
+		}	
+	}
+
+	db_conn = acct_storage_g_get_connection(false, rollback_flag);
+	my_uid = getuid();
+
+	if (input_field_count)
+		exit_flag = 1;
+	else
+		error_code = _get_command (&input_field_count, input_fields);
+	while (error_code == SLURM_SUCCESS) {
+		error_code = _process_command (input_field_count, 
+					       input_fields);
+		if (error_code || exit_flag)
+			break;
+		error_code = _get_command (&input_field_count, input_fields);
+	}
+
+	acct_storage_g_close_connection(&db_conn);
+	slurm_acct_storage_fini();
+	printf("\n");
+	exit(exit_code);
+}
+
+#if !HAVE_READLINE
+/*
+ * Alternative to readline if readline is not available
+ */
+static char *
+getline(const char *prompt)
+{
+	char buf[4096];
+	char *line;
+	int len;
+	printf("%s", prompt);
+
+	fgets(buf, 4096, stdin);
+	len = strlen(buf);
+	if ((len > 0) && (buf[len-1] == '\n'))
+		buf[len-1] = '\0';
+	else
+		len++;
+	line = malloc (len * sizeof(char));
+	return strncpy(line, buf, len);
+}
+#endif
+
+/*
+ * _get_command - get a command from the user
+ * OUT argc - location to store count of arguments
+ * OUT argv - location to store the argument list
+ */
+static int 
+_get_command (int *argc, char **argv) 
+{
+	char *in_line;
+	static char *last_in_line = NULL;
+	int i, in_line_size;
+	static int last_in_line_size = 0;
+
+	*argc = 0;
+
+#if HAVE_READLINE
+	in_line = readline ("sreport: ");
+#else
+	in_line = getline("sreport: ");
+#endif
+	if (in_line == NULL)
+		return 0;
+	else if (strcmp (in_line, "!!") == 0) {
+		free (in_line);
+		in_line = last_in_line;
+		in_line_size = last_in_line_size;
+	} else {
+		if (last_in_line)
+			free (last_in_line);
+		last_in_line = in_line;
+		last_in_line_size = in_line_size = strlen (in_line);
+	}
+
+#if HAVE_READLINE
+	add_history(in_line);
+#endif
+
+	/* break in_line into tokens */
+	for (i = 0; i < in_line_size; i++) {
+		bool double_quote = false, single_quote = false;
+		if (in_line[i] == '\0')
+			break;
+		if (isspace ((int) in_line[i]))
+			continue;
+		if (((*argc) + 1) > MAX_INPUT_FIELDS) {	/* bogus input line */
+			exit_code = 1;
+			fprintf (stderr, 
+				 "%s: can not process over %d words\n",
+				 command_name, input_words);
+			return E2BIG;
+		}		
+		argv[(*argc)++] = &in_line[i];
+		for (i++; i < in_line_size; i++) {
+			if (in_line[i] == '\042') {
+				double_quote = !double_quote;
+				continue;
+			}
+			if (in_line[i] == '\047') {
+				single_quote = !single_quote;
+				continue;
+			}
+			if (in_line[i] == '\0')
+				break;
+			if (double_quote || single_quote)
+				continue;
+			if (isspace ((int) in_line[i])) {
+				in_line[i] = '\0';
+				break;
+			}
+		}		
+	}
+	return 0;		
+}
+
+
+static void _print_version(void)
+{
+	printf("%s %s\n", PACKAGE, SLURM_VERSION);
+	if (quiet_flag == -1) {
+		long version = slurm_api_version();
+		printf("slurm_api_version: %ld, %ld.%ld.%ld\n", version,
+			SLURM_VERSION_MAJOR(version), 
+			SLURM_VERSION_MINOR(version),
+			SLURM_VERSION_MICRO(version));
+	}
+}
+
+/*
+ * _process_command - process the user's command
+ * IN argc - count of arguments
+ * IN argv - the arguments
+ * RET 0 or errno (only for errors fatal to sreport)
+ */
+static int
+_process_command (int argc, char *argv[]) 
+{
+	if (argc < 1) {
+		exit_code = 1;
+		if (quiet_flag == -1)
+			fprintf(stderr, "no input");
+	} else if (strncasecmp (argv[0], "help", 2) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, 
+				 "too many arguments for keyword:%s\n",
+				 argv[0]);
+		}
+		_usage ();
+	} else if (strncasecmp (argv[0], "oneliner", 1) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, 
+				 "too many arguments for keyword:%s\n",
+				 argv[0]);
+		}
+		one_liner = 1;
+	} else if (strncasecmp (argv[0], "quiet", 4) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, "too many arguments for keyword:%s\n",
+				 argv[0]);
+		}
+		quiet_flag = 1;
+	} else if ((strncasecmp (argv[0], "exit", 4) == 0) ||
+		   (strncasecmp (argv[0], "quit", 4) == 0)) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr, 
+				 "too many arguments for keyword:%s\n", 
+				 argv[0]);
+		}
+		exit_flag = 1;
+	} else if (strncasecmp (argv[0], "verbose", 4) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr,
+				 "too many arguments for %s keyword\n",
+				 argv[0]);
+		}		
+		quiet_flag = -1;
+	} else if (strncasecmp (argv[0], "version", 4) == 0) {
+		if (argc > 1) {
+			exit_code = 1;
+			fprintf (stderr,
+				 "too many arguments for %s keyword\n",
+				 argv[0]);
+		}		
+		_print_version();
+	} else {
+		exit_code = 1;
+		fprintf (stderr, "invalid keyword: %s\n", argv[0]);
+	}
+		
+	return 0;
+}
+
+/* _usage - show the valid sreport commands */
+void _usage () {
+	printf ("\
+sreport [<OPTION>] [<COMMAND>]                                             \n\
+    Valid <OPTION> values are:                                             \n\
+     -h or --help: equivalent to \"help\" command                          \n\
+     -o or --oneliner: equivalent to \"oneliner\" command                  \n\
+     -q or --quiet: equivalent to \"quiet\" command                        \n\
+     -s or --associations: equivalent to \"associations\" command          \n\
+     -v or --verbose: equivalent to \"verbose\" command                    \n\
+     -V or --version: equivalent to \"version\" command                    \n\
+                                                                           \n\
+  <keyword> may be omitted from the execute line and sreport will execute  \n\
+  in interactive mode. It will process commands as entered until explicitly\n\
+  terminated.                                                              \n\
+                                                                           \n\
+    Valid <COMMAND> values are:                                            \n\
+     exit                     terminate sreport                            \n\
+     help                     print this description of use.               \n\
+     no_header                no header will be added to the beginning of  \n\
+                              output.                                      \n\
+     oneliner                 report output one record per line.           \n\
+     quiet                    print no messages other than error messages. \n\
+     quit                     terminate this command.                      \n\
+     parsable                 output will be | delimited                   \n\
+     verbose                  enable detailed logging.                     \n\
+     version                  display tool version number.                 \n\
+     !!                       Repeat the last command entered.             \n\
+                                                                           \n\
+                                                                           \n\
+  All commands entitys, and options are case-insensitive.               \n\n");
+	
+}
+
diff --git a/src/sreport/sreport.h b/src/sreport/sreport.h
new file mode 100644
index 0000000000000000000000000000000000000000..034f03e5cd37c11cf96bf3ee69cecb355b862824
--- /dev/null
+++ b/src/sreport/sreport.h
@@ -0,0 +1,88 @@
+/*****************************************************************************\
+ *  sreport.h - report generating tool for slurm accounting header file.
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifndef __SREPORT_H__
+#define __SREPORT_H__
+
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_GETOPT_H
+#  include <getopt.h>
+#else
+#  include "src/common/getopt.h"
+#endif
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#  include <strings.h>
+#endif
+#include <time.h>
+#include <unistd.h>
+
+#if HAVE_READLINE
+#  include <readline/readline.h>
+#  include <readline/history.h>
+#endif
+
+#if HAVE_INTTYPES_H
+#  include <inttypes.h>
+#else  /* !HAVE_INTTYPES_H */
+#  if HAVE_STDINT_H
+#    include <stdint.h>
+#  endif
+#endif  /* HAVE_INTTYPES_H */
+
+#include <slurm/slurm.h>
+
+#include "src/common/jobacct_common.h"
+#include "src/common/parse_time.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/xstring.h"
+
+#define CKPT_WAIT	10
+#define	MAX_INPUT_FIELDS 128
+
+#endif /* HAVE_SREPORT_H */
diff --git a/src/srun/Makefile.am b/src/srun/Makefile.am
index 38612377873b936a1179ed9502b0557ae7ce4ee5..80a846909da642901012de95128b9d9dfdffee55 100644
--- a/src/srun/Makefile.am
+++ b/src/srun/Makefile.am
@@ -10,18 +10,11 @@ srun_SOURCES = \
 	srun.c srun.h \
 	opt.c opt.h \
 	srun_job.c srun_job.h \
-	msg.c msg.h \
-	signals.c signals.h \
-	launch.c    \
-	launch.h    \
-	attach.h    \
-	attach.c    \
-	reattach.c  \
-	reattach.h  \
+	srun_pty.c srun_pty.h \
+	debugger.h    \
+	debugger.c    \
 	fname.c     \
 	fname.h     \
-	sigstr.c    \
-	sigstr.h    \
 	allocate.c  \
 	allocate.h  \
 	core-format.c \
@@ -34,7 +27,7 @@ convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
 srun_LDADD = \
 	$(convenience_libs) 
 
-srun_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+srun_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 
 force:
 $(convenience_libs) : force
diff --git a/src/srun/Makefile.in b/src/srun/Makefile.in
index 98aa2874ab5208a4ebacedcc34ad500345bc3fef..4485b7d17062a5582aee3cfdd870bd36d23e761c 100644
--- a/src/srun/Makefile.in
+++ b/src/srun/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -69,16 +71,15 @@ am__installdirs = "$(DESTDIR)$(bindir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
 am_srun_OBJECTS = srun.$(OBJEXT) opt.$(OBJEXT) srun_job.$(OBJEXT) \
-	msg.$(OBJEXT) signals.$(OBJEXT) launch.$(OBJEXT) \
-	attach.$(OBJEXT) reattach.$(OBJEXT) fname.$(OBJEXT) \
-	sigstr.$(OBJEXT) allocate.$(OBJEXT) core-format.$(OBJEXT) \
-	multi_prog.$(OBJEXT) srun.wrapper.$(OBJEXT)
+	srun_pty.$(OBJEXT) debugger.$(OBJEXT) fname.$(OBJEXT) \
+	allocate.$(OBJEXT) core-format.$(OBJEXT) multi_prog.$(OBJEXT) \
+	srun.wrapper.$(OBJEXT)
 srun_OBJECTS = $(am_srun_OBJECTS)
 srun_DEPENDENCIES = $(convenience_libs)
 srun_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(srun_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -118,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -131,10 +133,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -154,7 +159,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -165,6 +173,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -180,6 +190,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -195,6 +206,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -257,18 +269,11 @@ srun_SOURCES = \
 	srun.c srun.h \
 	opt.c opt.h \
 	srun_job.c srun_job.h \
-	msg.c msg.h \
-	signals.c signals.h \
-	launch.c    \
-	launch.h    \
-	attach.h    \
-	attach.c    \
-	reattach.c  \
-	reattach.h  \
+	srun_pty.c srun_pty.h \
+	debugger.h    \
+	debugger.c    \
 	fname.c     \
 	fname.h     \
-	sigstr.c    \
-	sigstr.h    \
 	allocate.c  \
 	allocate.h  \
 	core-format.c \
@@ -280,7 +285,7 @@ convenience_libs = $(top_builddir)/src/api/libslurmhelper.la
 srun_LDADD = \
 	$(convenience_libs) 
 
-srun_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(FEDERATION_LDFLAGS)
+srun_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -323,8 +328,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -353,19 +358,15 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocate.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attach.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/core-format.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debugger.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fname.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launch.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_prog.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reattach.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signals.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigstr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srun.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srun.wrapper.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srun_job.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srun_pty.Po@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -399,8 +400,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -412,8 +413,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -423,13 +424,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/srun/allocate.c b/src/srun/allocate.c
index b1abd672acf29f57b0179aaf9610c21a59464eab..0ae0183341103208bcef576ba444fa7495de11b7 100644
--- a/src/srun/allocate.c
+++ b/src/srun/allocate.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/srun/allocate.c - srun functions for managing node allocations
- * $Id: allocate.c 13231 2008-02-08 17:16:47Z jette $
+ * $Id: allocate.c 13771 2008-04-02 20:03:47Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -55,41 +55,141 @@
 #include "src/common/xstring.h"
 #include "src/common/forward.h"
 #include "src/common/env.h"
+#include "src/common/fd.h"
 
 #include "src/srun/allocate.h"
-#include "src/srun/msg.h"
 #include "src/srun/opt.h"
-#include "src/srun/attach.h"
+#include "src/srun/debugger.h"
 
 #define MAX_ALLOC_WAIT 60	/* seconds */
 #define MIN_ALLOC_WAIT  5	/* seconds */
 #define MAX_RETRIES    10
 
+pthread_mutex_t msg_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t msg_cond = PTHREAD_COND_INITIALIZER;
+allocation_msg_thread_t *msg_thr = NULL;
+resource_allocation_response_msg_t *global_resp = NULL;
+struct pollfd global_fds[1];
+
 extern char **environ;
 
+static bool exit_flag = false;
+static uint32_t pending_job_id = 0;
+
 /*
  * Static Prototypes
  */
-static int   _accept_msg_connection(slurm_fd slurmctld_fd,
-		resource_allocation_response_msg_t **resp);
-static int   _handle_msg(slurm_msg_t *msg, \
-		resource_allocation_response_msg_t **resp);
-static int   _wait_for_alloc_rpc(int sleep_time,
-		resource_allocation_response_msg_t **resp);
-static void  _wait_for_resources(resource_allocation_response_msg_t **resp);
-static bool  _retry();
+static void _set_pending_job_id(uint32_t job_id);
+static void _ignore_signal(int signo);
+static void _exit_on_signal(int signo);
+static void _signal_while_allocating(int signo);
 static void  _intr_handler(int signo);
 
-static job_step_create_request_msg_t * _step_req_create(srun_job_t *j);
-
 static sig_atomic_t destroy_job = 0;
-static srun_job_t *allocate_job = NULL;
+
+static void _set_pending_job_id(uint32_t job_id)
+{
+	info("Pending job allocation %u", job_id);
+	pending_job_id = job_id;
+}
+
+static void _signal_while_allocating(int signo)
+{
+	destroy_job = 1;
+	if (pending_job_id != 0) {
+		slurm_complete_job(pending_job_id, 0);
+	}
+}
+
+static void _ignore_signal(int signo)
+{
+	/* do nothing */
+}
+
+static void _exit_on_signal(int signo)
+{
+	exit_flag = true;
+}
+
+/* This typically signifies the job was cancelled by scancel */
+static void _job_complete_handler(srun_job_complete_msg_t *msg)
+{
+	info("Force Terminated job");
+}
+
+/*
+ * Job has been notified of it's approaching time limit. 
+ * Job will be killed shortly after timeout.
+ * This RPC can arrive multiple times with the same or updated timeouts.
+ * FIXME: We may want to signal the job or perform other action for this.
+ * FIXME: How much lead time do we want for this message? Some jobs may 
+ *	require tens of minutes to gracefully terminate.
+ */
+static void _timeout_handler(srun_timeout_msg_t *msg)
+{
+	static time_t last_timeout = 0;
+
+	if (msg->timeout != last_timeout) {
+		last_timeout = msg->timeout;
+		verbose("job time limit to be reached at %s", 
+			ctime(&msg->timeout));
+	}
+}
+
+static void _user_msg_handler(srun_user_msg_t *msg)
+{
+	info("%s", msg->msg);
+}
+
+static void _ping_handler(srun_ping_msg_t *msg) 
+{
+	/* the api will respond so there really isn't anything to do
+	   here */
+}
+
+static void _node_fail_handler(srun_node_fail_msg_t *msg)
+{
+	error("Node failure on %s", msg->nodelist);
+}
+
+
+
+static bool _retry()
+{
+	static int  retries = 0;
+	static char *msg = "Slurm controller not responding, "
+		           "sleeping and retrying.";
+
+	if (errno == ESLURM_ERROR_ON_DESC_TO_RECORD_COPY) {
+		if (retries == 0)
+			error (msg);
+		else if (retries < MAX_RETRIES)
+			debug (msg);
+		else
+			return false;
+		sleep (++retries);
+	} else {
+		error("Unable to allocate resources: %m");
+		return false;
+	}
+
+	return true;
+}
+
+/*
+ * SIGINT handler while waiting for resources to become available.
+ */
+static void
+_intr_handler(int signo)
+{
+	destroy_job = 1;
+}
 
 int
 allocate_test(void)
 {
 	int rc;
-	job_desc_msg_t *j = job_desc_msg_create_from_opts (NULL);
+	job_desc_msg_t *j = job_desc_msg_create_from_opts();
 	if(!j)
 		return SLURM_ERROR;
 	
@@ -101,23 +201,13 @@ allocate_test(void)
 resource_allocation_response_msg_t *
 allocate_nodes(void)
 {
-	int rc = 0;
-	static int sigarray[] = { SIGQUIT, SIGINT, SIGTERM, 0 };
-	SigFunc *oquitf, *ointf, *otermf;
-	sigset_t oset;
 	resource_allocation_response_msg_t *resp = NULL;
-	job_desc_msg_t *j = job_desc_msg_create_from_opts (NULL);
+	job_desc_msg_t *j = job_desc_msg_create_from_opts();
+	slurm_allocation_callbacks_t callbacks;
 
 	if(!j)
 		return NULL;
 	
-	oquitf = xsignal(SIGQUIT, _intr_handler);
-	ointf  = xsignal(SIGINT,  _intr_handler);
-	otermf = xsignal(SIGTERM, _intr_handler);
-
-	xsignal_save_mask(&oset);
-	xsignal_unblock(sigarray);
-
 	/* Do not re-use existing job id when submitting new job
 	 * from within a running job */
 	if ((j->job_id != NO_VAL) && !opt.jobid_set) {
@@ -127,33 +217,54 @@ allocate_nodes(void)
 		if (!opt.jobid_set)	/* Let slurmctld set jobid */
 			j->job_id = NO_VAL;
 	}
-	
-	while ((rc = slurm_allocate_resources(j, &resp) < 0) && _retry()) {
-		if (destroy_job)
-			goto done;
-	} 
-
-	if(!resp)
-		goto done;
-	
-	if ((rc == 0) && (resp->node_list == NULL)) {
-		if (resp->error_code)
-			verbose("Warning: %s",
-				slurm_strerror(resp->error_code));
-		_wait_for_resources(&resp);
+	callbacks.ping = _ping_handler;
+	callbacks.timeout = _timeout_handler;
+	callbacks.job_complete = _job_complete_handler;
+	callbacks.user_msg = _user_msg_handler;
+	callbacks.node_fail = _node_fail_handler;
+
+	/* create message thread to handle pings and such from slurmctld */
+	msg_thr = slurm_allocation_msg_thr_create(&j->other_port, &callbacks);
+
+	xsignal(SIGHUP, _signal_while_allocating);
+	xsignal(SIGINT, _signal_while_allocating);
+	xsignal(SIGQUIT, _signal_while_allocating);
+	xsignal(SIGPIPE, _signal_while_allocating);
+	xsignal(SIGTERM, _signal_while_allocating);
+	xsignal(SIGUSR1, _signal_while_allocating);
+	xsignal(SIGUSR2, _signal_while_allocating);
+
+	while (!resp) {
+		resp = slurm_allocate_resources_blocking(j, opt.max_wait,
+							 _set_pending_job_id);
+		if (destroy_job) {
+			/* cancelled by signal */
+			break;
+		} else if(!resp && !_retry()) {
+			break;		
+		}
 	}
-
-    done:
-	xsignal_set_mask(&oset);
-	xsignal(SIGINT,  ointf);
-	xsignal(SIGTERM, otermf);
-	xsignal(SIGQUIT, oquitf);
+	
+	xsignal(SIGHUP, _exit_on_signal);
+	xsignal(SIGINT, _ignore_signal);
+	xsignal(SIGQUIT, _ignore_signal);
+	xsignal(SIGPIPE, _ignore_signal);
+	xsignal(SIGTERM, _ignore_signal);
+	xsignal(SIGUSR1, _ignore_signal);
+	xsignal(SIGUSR2, _ignore_signal);
 
 	job_desc_msg_destroy(j);
 
 	return resp;
 }
 
+int 
+cleanup_allocation()
+{
+	slurm_allocation_msg_thr_destroy(msg_thr);
+	return SLURM_SUCCESS;
+}
+
 resource_allocation_response_msg_t *
 existing_allocation(void)
 {
@@ -181,222 +292,44 @@ existing_allocation(void)
         return resp;
 }
 
-static void
-_wait_for_resources(resource_allocation_response_msg_t **resp)
-{
-	resource_allocation_response_msg_t *r = *resp;
-	int sleep_time = MIN_ALLOC_WAIT;
-	int job_id = r->job_id;
-
-	if (!opt.quiet)
-		info ("job %u queued and waiting for resources", r->job_id);
-
-	slurm_free_resource_allocation_response_msg(r);
-
-	/* Keep polling until the job is allocated resources */
-	while (_wait_for_alloc_rpc(sleep_time, resp) <= 0) {
-
-		if (slurm_allocation_lookup_lite(job_id, resp) >= 0)
-			break;
-
-		if (slurm_get_errno() == ESLURM_JOB_PENDING) 
-			debug3 ("Still waiting for allocation");
-		else 
-			fatal ("Unable to confirm allocation for job %u: %m", 
-			       job_id);
-
-		if (destroy_job) {
-			verbose("cancelling job %u", job_id);
-			slurm_complete_job(job_id, 0);
-			debugger_launch_failure(allocate_job);
-			exit(0);
-		}
-
-		if (sleep_time < MAX_ALLOC_WAIT)
-			sleep_time++;
-	}
-	if (!opt.quiet)
-		info ("job %u has been allocated resources", (*resp)->job_id);
-}
-
-/* Wait up to sleep_time for RPC from slurmctld indicating resource allocation
- * has occured.
- * IN sleep_time: delay in seconds
- * OUT resp: resource allocation response message
- * RET 1 if resp is filled in, 0 otherwise */
-static int
-_wait_for_alloc_rpc(int sleep_time, resource_allocation_response_msg_t **resp)
-{
-	struct pollfd fds[1];
-	slurm_fd slurmctld_fd;
-
-	if ((slurmctld_fd = slurmctld_msg_init()) < 0) {
-		sleep (sleep_time);
-		return (0);
-	}
-
-	fds[0].fd = slurmctld_fd;
-	fds[0].events = POLLIN;
-
-	while (poll (fds, 1, (sleep_time * 1000)) < 0) {
-		switch (errno) {
-			case EAGAIN:
-			case EINTR:
-				return (-1);
-			case ENOMEM:
-			case EINVAL:
-			case EFAULT:
-				fatal("poll: %m");
-			default:
-				error("poll: %m. Continuing...");
-		}
-	}
-
-	if (fds[0].revents & POLLIN)
-		return (_accept_msg_connection(slurmctld_fd, resp));
-
-	return (0);
-}
-
-/* Accept RPC from slurmctld and process it.
- * IN slurmctld_fd: file descriptor for slurmctld communications
- * OUT resp: resource allocation response message
- * RET 1 if resp is filled in, 0 otherwise */
-static int 
-_accept_msg_connection(slurm_fd slurmctld_fd, 
-		resource_allocation_response_msg_t **resp)
-{
-	slurm_fd     fd;
-	slurm_msg_t *msg = NULL;
-	slurm_addr   cli_addr;
-	char         host[256];
-	uint16_t     port;
-	int          rc = 0;
-
-	fd = slurm_accept_msg_conn(slurmctld_fd, &cli_addr);
-	if (fd < 0) {
-		error("Unable to accept connection: %m");
-		return rc;
-	}
-
-	slurm_get_addr(&cli_addr, &port, host, sizeof(host));
-	debug2("got message connection from %s:%hu", host, port);
-
-	msg = xmalloc(sizeof(slurm_msg_t));
-	slurm_msg_t_init(msg);
-	
-  again:
-	if(slurm_receive_msg(fd, msg, 0) != 0) {
-		if (errno == EINTR) {
-			goto again;
-		}			
-		error("_accept_msg_connection[%s]: %m", host);
-		rc = SLURM_ERROR;
-		goto cleanup;
-		
-	}
-		
-	rc = _handle_msg(msg, resp); /* handle_msg frees msg->data */
-cleanup:
-	slurm_free_msg(msg);
-		
-	slurm_close_accepted_conn(fd);
-	return rc;
-}
-
-/* process RPC from slurmctld
- * IN msg: message recieved
- * OUT resp: resource allocation response message
- * RET 1 if resp is filled in, 0 otherwise */
-static int
-_handle_msg(slurm_msg_t *msg, resource_allocation_response_msg_t **resp)
+/* Set up port to handle messages from slurmctld */
+slurm_fd
+slurmctld_msg_init(void)
 {
-	uid_t req_uid   = g_slurm_auth_get_uid(msg->auth_cred);
-	uid_t uid       = getuid();
-	uid_t slurm_uid = (uid_t) slurm_get_slurm_user_id();
-	int rc = 0;
-	srun_timeout_msg_t *to;
-	srun_user_msg_t *um;
-
-	if ((req_uid != slurm_uid) && (req_uid != 0) && (req_uid != uid)) {
-		error ("Security violation, slurm message from uid %u",
-			(unsigned int) req_uid);
-		return 0;
-	}
-
-	switch (msg->msg_type) {
-		case SRUN_PING:
-			debug3("slurmctld ping received");
-			slurm_send_rc_msg(msg, SLURM_SUCCESS);
-			slurm_free_srun_ping_msg(msg->data);
-			break;
-		case SRUN_JOB_COMPLETE:
-			debug3("job complete received");
-			/* FIXME: do something here */
-			slurm_free_srun_job_complete_msg(msg->data);	
-			break;
-		case RESPONSE_RESOURCE_ALLOCATION:
-			debug2("resource allocation response received");
-			slurm_send_rc_msg(msg, SLURM_SUCCESS);
-			*resp = msg->data;
-			rc = 1;
-			break;
-		case SRUN_TIMEOUT:
-			debug2("timeout received");
-			to = msg->data;
-			timeout_handler(to->timeout);
-			slurm_free_srun_timeout_msg(msg->data);
-			break;
-		case SRUN_USER_MSG:
-			um = msg->data;
-			info("%s", um->msg);
-			slurm_free_srun_user_msg(msg->data);
-			break;
-		default:
-			error("received spurious message type: %d\n",
-				 msg->msg_type);
-	}
-	return rc;
-}
-
-static bool
-_retry()
-{
-	static int  retries = 0;
-	static char *msg = "Slurm job queue full, sleeping and retrying.";
-
-	if (errno == ESLURM_ERROR_ON_DESC_TO_RECORD_COPY) {
-		if (retries == 0)
-			error (msg);
-		else if (retries < MAX_RETRIES)
-			debug (msg);
-		else
-			return false;
-		sleep (++retries);
-	} else {
-		error("Unable to allocate resources: %m");
-		return false;
-	}
-
-	return true;
+	slurm_addr slurm_address;
+	uint16_t port;
+	static slurm_fd slurmctld_fd   = (slurm_fd) NULL;
+
+	if (slurmctld_fd)	/* May set early for queued job allocation */
+		return slurmctld_fd;
+
+	slurmctld_fd = -1;
+	slurmctld_comm_addr.hostname = NULL;
+	slurmctld_comm_addr.port = 0;
+
+	if ((slurmctld_fd = slurm_init_msg_engine_port(0)) < 0)
+		fatal("slurm_init_msg_engine_port error %m");
+	if (slurm_get_stream_addr(slurmctld_fd, &slurm_address) < 0)
+		fatal("slurm_get_stream_addr error %m");
+	fd_set_nonblocking(slurmctld_fd);
+	/* hostname is not set,  so slurm_get_addr fails
+	   slurm_get_addr(&slurm_address, &port, hostname, sizeof(hostname)); */
+	port = ntohs(slurm_address.sin_port);
+	slurmctld_comm_addr.hostname = xstrdup(opt.ctrl_comm_ifhn);
+	slurmctld_comm_addr.port     = port;
+	debug2("slurmctld messages to host=%s,port=%u", 
+	       slurmctld_comm_addr.hostname, 
+	       slurmctld_comm_addr.port);
+
+	return slurmctld_fd;
 }
 
-/*
- * SIGINT handler while waiting for resources to become available.
- */
-static void
-_intr_handler(int signo)
-{
-	destroy_job = 1;
-}
-
-
 /*
  * Create job description structure based off srun options
  * (see opt.h)
  */
 job_desc_msg_t *
-job_desc_msg_create_from_opts (char *script)
+job_desc_msg_create_from_opts ()
 {
 	job_desc_msg_t *j = xmalloc(sizeof(*j));
 	char buf[8192];
@@ -461,6 +394,8 @@ job_desc_msg_create_from_opts (char *script)
 		j->mail_user = xstrdup(opt.mail_user);
 	if (opt.begin)
 		j->begin_time = opt.begin;
+	if (opt.licenses)
+		j->licenses = xstrdup(opt.licenses);
 	if (opt.network)
 		j->network = xstrdup(opt.network);
 	if (opt.account)
@@ -516,8 +451,6 @@ job_desc_msg_create_from_opts (char *script)
 		j->job_min_threads  = opt.job_min_threads;
 	if (opt.job_min_memory != NO_VAL)
 		j->job_min_memory   = opt.job_min_memory;
-	if (opt.job_max_memory != NO_VAL)
-		j->job_max_memory   = opt.job_max_memory;
 	if (opt.job_min_tmp_disk != NO_VAL)
 		j->job_min_tmp_disk = opt.job_min_tmp_disk;
 	if (opt.overcommit) {
@@ -541,45 +474,6 @@ job_desc_msg_create_from_opts (char *script)
 	 * message as all other messages */
 	j->alloc_resp_port = slurmctld_comm_addr.port;
 	j->other_port = slurmctld_comm_addr.port;
-	if (slurmctld_comm_addr.hostname) {
-		j->alloc_resp_hostname = xstrdup(slurmctld_comm_addr.hostname);
-		j->other_hostname = xstrdup(slurmctld_comm_addr.hostname);
-	} else {
-		j->alloc_resp_hostname = NULL;
-		j->other_hostname = NULL;
-	}
-
-	if (script) {
-		/*
-		 * If script is set then we are building a request for
-		 *  a batch job
-		 */
-		xassert (opt.batch);
-
-		j->environment = NULL;
-		if (opt.get_user_env_time >= 0) {
-			struct passwd *pw = NULL;
-			pw = getpwuid(opt.uid);
-			if (pw != NULL) {
-				j->environment = env_array_user_default(
-							pw->pw_name,
-							opt.get_user_env_time,
-							opt.get_user_env_mode);
-				if (j->environment == NULL)
-					exit(1);    /* error already logged */
-			}
-		}
-		env_array_merge(&j->environment, (const char **)environ);
-		j->env_size = envcount (j->environment);
-		j->script = script;
-		j->argv = remote_argv;
-		j->argc = remote_argc;
-		j->err  = opt.efname;
-		j->in   = opt.ifname;
-		j->out  = opt.ofname;
-		j->work_dir = opt.cwd;
-		j->no_requeue = opt.no_requeue;
-	}
 
 	return (j);
 }
@@ -590,136 +484,126 @@ job_desc_msg_destroy(job_desc_msg_t *j)
 	if (j) {
 		xfree(j->account);
 		xfree(j->comment);
-		xfree(j->alloc_resp_hostname);
-		xfree(j->other_hostname);
 		xfree(j);
 	}
 }
 
-static job_step_create_request_msg_t *
-_step_req_create(srun_job_t *j)
+int
+create_job_step(srun_job_t *job)
 {
-	job_step_create_request_msg_t *r = xmalloc(sizeof(*r));
-	r->job_id     = j->jobid;
-	r->user_id    = opt.uid;
-
-	r->node_count = j->nhosts;
-	/* info("send %d or %d? sending %d", opt.max_nodes, */
-/* 		     j->nhosts, r->node_count); */
-	if(r->node_count > j->nhosts) {
-		error("Asking for more nodes that allocated");
-		return NULL;
-	}
-	r->cpu_count  = opt.overcommit ? r->node_count
-		                       : (opt.nprocs*opt.cpus_per_task);
-	r->num_tasks  = opt.nprocs;
-	r->node_list  = xstrdup(opt.nodelist);
-	r->network    = xstrdup(opt.network);
-	r->name       = xstrdup(opt.job_name);
-	r->relative   = (uint16_t)opt.relative;
-	r->overcommit = opt.overcommit ? 1 : 0;
-	debug("requesting job %d, user %d, nodes %d including (%s)", 
-	      r->job_id, r->user_id, r->node_count, r->node_list);
-	debug("cpus %d, tasks %d, name %s, relative %d", 
-	      r->cpu_count, r->num_tasks, r->name, r->relative);
+	int i, rc;
+	SigFunc *oquitf = NULL, *ointf = NULL, *otermf = NULL;
+
+	slurm_step_ctx_params_t_init(&job->ctx_params);
+	job->ctx_params.job_id = job->jobid;
+	job->ctx_params.uid = opt.uid;
+
+	/* set the jobid for totalview */
+	totalview_jobid = NULL;
+	xstrfmtcat(totalview_jobid, "%u", job->ctx_params.job_id);
+
+	job->ctx_params.node_count = job->nhosts;
+	job->ctx_params.task_count = opt.nprocs;
 	
+	job->ctx_params.cpu_count = opt.overcommit ? job->ctx_params.node_count
+		: (opt.nprocs*opt.cpus_per_task);
+	
+	job->ctx_params.relative = (uint16_t)opt.relative;
+	if (opt.task_mem != NO_VAL)
+		job->ctx_params.mem_per_task = (uint16_t)opt.task_mem;
+	job->ctx_params.ckpt_interval = (uint16_t)opt.ckpt_interval;
+	job->ctx_params.ckpt_path = opt.ckpt_path;
+	job->ctx_params.exclusive = (uint16_t)opt.exclusive;
+	job->ctx_params.immediate = (uint16_t)opt.immediate;
+	job->ctx_params.verbose_level = (uint16_t)_verbose;
 	switch (opt.distribution) {
 	case SLURM_DIST_BLOCK:
-		r->task_dist = SLURM_DIST_BLOCK;
-		break;
 	case SLURM_DIST_ARBITRARY:
-		r->task_dist = SLURM_DIST_ARBITRARY;
-		break;
 	case SLURM_DIST_CYCLIC:
-		r->task_dist = SLURM_DIST_CYCLIC;
-		break;
 	case SLURM_DIST_CYCLIC_CYCLIC:
-		r->task_dist = SLURM_DIST_CYCLIC_CYCLIC;
-		break;
 	case SLURM_DIST_CYCLIC_BLOCK:
-		r->task_dist = SLURM_DIST_CYCLIC_BLOCK;
-		break;
 	case SLURM_DIST_BLOCK_CYCLIC:
-		r->task_dist = SLURM_DIST_BLOCK_CYCLIC;
-		break;
 	case SLURM_DIST_BLOCK_BLOCK:
-		r->task_dist = SLURM_DIST_BLOCK_BLOCK;
+		job->ctx_params.task_dist = opt.distribution;
 		break;
 	case SLURM_DIST_PLANE:
-		r->task_dist = SLURM_DIST_PLANE;
-		r->plane_size = opt.plane_size;
+		job->ctx_params.task_dist = SLURM_DIST_PLANE;
+		job->ctx_params.plane_size = opt.plane_size;
 		break;
 	default:
-		r->task_dist = (r->num_tasks <= r->node_count) 
+		job->ctx_params.task_dist = (job->ctx_params.task_count <= 
+			job->ctx_params.node_count) 
 			? SLURM_DIST_CYCLIC : SLURM_DIST_BLOCK;
 		break;
 
 	}
-	opt.distribution = r->task_dist;
-	
-	if (slurmctld_comm_addr.port) {
-		r->host = xstrdup(slurmctld_comm_addr.hostname);
-		r->port = slurmctld_comm_addr.port;
-	}
+	job->ctx_params.overcommit = opt.overcommit ? 1 : 0;
 
-	return(r);
-}
-
-int
-create_job_step(srun_job_t *job)
-{
-	job_step_create_request_msg_t  *req  = NULL;
-	job_step_create_response_msg_t *resp = NULL;
-	int i;
+	job->ctx_params.node_list = opt.nodelist;
 	
-	if (!(req = _step_req_create(job))) {
-		error ("Unable to allocate step request message");
-		return -1;
-	}
-
-	for (i=0; ;i++) {
-		if ((slurm_job_step_create(req, &resp) == SLURM_SUCCESS)
-		&&  (resp != NULL))
+	job->ctx_params.network = opt.network;
+	job->ctx_params.name = opt.job_name;
+	
+	debug("requesting job %d, user %d, nodes %d including (%s)", 
+	      job->ctx_params.job_id, job->ctx_params.uid,
+	      job->ctx_params.node_count, job->ctx_params.node_list);
+	debug("cpus %d, tasks %d, name %s, relative %d", 
+	      job->ctx_params.cpu_count, job->ctx_params.task_count,
+	      job->ctx_params.name, job->ctx_params.relative);
+
+	for (i=0; (!destroy_job); i++) {
+		if(opt.no_alloc) {
+			job->step_ctx = slurm_step_ctx_create_no_alloc(
+				&job->ctx_params, job->stepid);
+		} else
+			job->step_ctx = slurm_step_ctx_create(
+				&job->ctx_params);
+		if (job->step_ctx != NULL) {
+			if (i > 0)
+				info("Job step created");
+			
 			break;
-		if (slurm_get_errno() != ESLURM_DISABLED) {
+		}
+		rc = slurm_get_errno();
+
+		if (opt.immediate ||
+		    ((rc != ESLURM_NODES_BUSY) && (rc != ESLURM_DISABLED))) {
 			error ("Unable to create job step: %m");
 			return -1;
 		}
-		if (i == 0)
-			info("Job step creation temporarily disabled, retrying");
+		
+		if (i == 0) {
+			info("Job step creation temporarily disabled, retrying");	
+			ointf  = xsignal(SIGINT,  _intr_handler);
+			otermf  = xsignal(SIGTERM, _intr_handler);
+			oquitf  = xsignal(SIGQUIT, _intr_handler);
+		} else
+			info("Job step creation still disabled, retrying");
 		sleep(MIN((i*10), 60));
 	}
-	
-	job->stepid  = resp->job_step_id;
-	job->step_layout = resp->step_layout;
-	job->cred    = resp->cred;
-	job->switch_job = resp->switch_job;
-		
+	if (i > 0) {
+		xsignal(SIGINT,  ointf);
+		xsignal(SIGQUIT, oquitf);
+		xsignal(SIGTERM, otermf);
+		if (destroy_job) {
+			info("Cancelled pending job step");
+			return -1;
+		}
+	}
 
+	slurm_step_ctx_get(job->step_ctx, SLURM_STEP_CTX_STEPID, &job->stepid);
 	/*  Number of hosts in job may not have been initialized yet if 
 	 *    --jobid was used or only SLURM_JOBID was set in user env.
 	 *    Reset the value here just in case.
 	 */
-	job->nhosts = job->step_layout->node_cnt;
-
-	if(!job->step_layout) {
-		error("step_layout not returned");
-		return -1;
-	}
+	slurm_step_ctx_get(job->step_ctx, SLURM_STEP_CTX_NUM_HOSTS,
+			   &job->nhosts);
 	
 	/*
 	 * Recreate filenames which may depend upon step id
 	 */
 	job_update_io_fnames(job);
 
-	slurm_free_job_step_create_request_msg(req);
-	
 	return 0;
 }
 
-void 
-set_allocate_job(srun_job_t *job) 
-{
-	allocate_job = job;
-	return;
-}
diff --git a/src/srun/allocate.h b/src/srun/allocate.h
index 0be8ff65e80be9c081c2de0c4c0c7bc7c4832f07..91474c653ae69492f005fe4f02b069d5a9c12bff 100644
--- a/src/srun/allocate.h
+++ b/src/srun/allocate.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/srun/allocate.h - node allocation functions for srun
- * $Id: allocate.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: allocate.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -43,6 +43,13 @@
 
 #include "src/srun/srun_job.h"
 
+typedef struct slurmctld_communication_addr {
+	char *hostname;
+	uint16_t port;
+} slurmctld_comm_addr_t;
+
+slurmctld_comm_addr_t slurmctld_comm_addr;
+
 /* 
  * Allocate nodes from the slurm controller -- retrying the attempt
  * if the controller appears to be down, and optionally waiting for
@@ -53,18 +60,24 @@
  */
 resource_allocation_response_msg_t * allocate_nodes(void);
 
+/* clean up the msg thread polling for information from the controller */
+int cleanup_allocation();
+
 /*
  * Test if an allocation would occur now given the job request.
  * Do not actually allocate resources
  */
 int allocate_test(void);
 
+/* Set up port to handle messages from slurmctld */
+slurm_fd slurmctld_msg_init(void);
+
 /*
  * Create a job_desc_msg_t object, filled in from the current srun options
- * (see opt.h), if script != NULL then this is a batch job.
+ * (see opt.h)
  * The resulting memory must be freed with  job_desc_msg_destroy()
  */
-job_desc_msg_t * job_desc_msg_create_from_opts (char *script);
+job_desc_msg_t * job_desc_msg_create_from_opts ();
 
 /* 
  * Destroy (free memory from) a job_desc_msg_t object allocated with
diff --git a/src/srun/attach.h b/src/srun/attach.h
deleted file mode 100644
index 4aacc0b4859f7be532d15c86da91f9cac48a67b0..0000000000000000000000000000000000000000
--- a/src/srun/attach.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************\
- *  attach.h - definitions needed for TotalView interactions
- *****************************************************************************
- *  This file was supplied by James Cownie <jcownie@etnus.com> and provides 
- *  information required to interface Slurm to the TotalView debugger from 
- *  the Etnus Corporation. For more information about TotalView, see
- *  http://www.etnus.com/
-\*****************************************************************************/
-
-/*  $Id: attach.h 5227 2005-08-08 18:12:07Z da $
- */
-
-/* This file contains support for bringing processes up stopped, so that
- * a debugger can attach to them     (done for TotalView)
- */
-
-/* Update log
- *
- * Nov 27 1996 jcownie@dolphinics.com: Added the executable_name to MPIR_PROCDESC
- */
-
-#ifndef _ATTACH_INCLUDE
-#define _ATTACH_INCLUDE
-
-#ifndef VOLATILE
-#if defined(__STDC__) || defined(__cplusplus)
-#define VOLATILE volatile
-#else
-#define VOLATILE
-#endif
-#endif
-#include "src/srun/srun_job.h"
-/*****************************************************************************
-*                                DEBUGGING SUPPORT                           *
-*****************************************************************************/
-
-
-/* A little struct to hold the target processor name and pid for
- * each process which forms part of the MPI program.
- * We may need to think more about this once we have dynamic processes...
- *
- * DO NOT change the name of this structure or its fields. The debugger knows
- * them, and will be confused if you change them.
- */
-typedef struct {
-  char * host_name;           /* Something we can pass to inet_addr */
-  char * executable_name;     /* The name of the image */
-  int    pid;		      /* The pid of the process */
-} MPIR_PROCDESC;
-
-/* Array of procdescs for debugging purposes */
-extern MPIR_PROCDESC *MPIR_proctable;
-extern int MPIR_proctable_size;
-
-/* Various global variables which a debugger can use for 
- * 1) finding out what the state of the program is at
- *    the time the magic breakpoint is hit.
- * 2) inform the process that it has been attached to and is
- *    now free to run.
- */
-extern VOLATILE int MPIR_debug_state;
-extern VOLATILE int MPIR_debug_gate;
-extern int          MPIR_being_debugged; /* Cause extra info on internal state
-					  * to be maintained
-					  */
- 
-/* Values for the debug_state, this seems to be all we need at the moment
- * but that may change... 
- */
-#define MPIR_DEBUG_SPAWNED   1
-#define MPIR_DEBUG_ABORTING  2
-
-/* SLURM specific declarations */
-extern int MPIR_i_am_starter;
-extern int MPIR_acquired_pre_main;
-
-extern void MPIR_Breakpoint(void);
-extern void debugger_launch_failure(srun_job_t *job);
-
-/* Value for totalview %J expansion in bulk launch string
- */
-extern char *totalview_jobid; 
-
-#endif
diff --git a/src/srun/core-format.c b/src/srun/core-format.c
index 0efa68112a86cbc49f576569503bca0095b461d7..1edf3fe6a31067d9496bc36ad1412b61956d4bec 100644
--- a/src/srun/core-format.c
+++ b/src/srun/core-format.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/srun/core-format.c - Change corefile characteristics for job
- * $Id: core-format.c 10574 2006-12-15 23:38:29Z jette $
+ * $Id: core-format.c 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/srun/core-format.h b/src/srun/core-format.h
index 3255ae3e778fad09bc77b7b853e87e2b701320a2..696e522f39bd4fbbac17735bdfb753243f66e044 100644
--- a/src/srun/core-format.h
+++ b/src/srun/core-format.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  * src/srun/core-format.h - Change corefile characteristics for job
- * $Id: core-format.h 10574 2006-12-15 23:38:29Z jette $
+ * $Id: core-format.h 13672 2008-03-19 23:10:58Z jette $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/srun/attach.c b/src/srun/debugger.c
similarity index 91%
rename from src/srun/attach.c
rename to src/srun/debugger.c
index 7934007a35d1bf3e02f0380468057a178e36d101..e27b37e3c11b3d3e0d0ead0fb84efc7a3c89d480 100644
--- a/src/srun/attach.c
+++ b/src/srun/debugger.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
- *  attach.c - Definitions needed for parallel debugger
- *  $Id: attach.c 10574 2006-12-15 23:38:29Z jette $
+ *  debugger.c - Definitions needed for parallel debugger
+ *  $Id: debugger.c 11149 2007-03-14 20:53:19Z morrone $
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -16,7 +16,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -42,10 +42,10 @@
 
 #include "src/common/log.h"
 
-#include "src/srun/attach.h"
+#include "src/srun/debugger.h"
 
 /*
- *  Instantiate extern variables from attach.h
+ *  Instantiate extern variables from debugger.h
  */
 MPIR_PROCDESC *MPIR_proctable;
 int MPIR_proctable_size;
diff --git a/src/slaunch/attach.h b/src/srun/debugger.h
similarity index 92%
rename from src/slaunch/attach.h
rename to src/srun/debugger.h
index c066ca40e2ed6c83af3f83e68ff444f44e1361c4..6c34800df32dba673cfa9c17e034e332bd06fa6a 100644
--- a/src/slaunch/attach.h
+++ b/src/srun/debugger.h
@@ -1,5 +1,5 @@
 /****************************************************************************\
- *  attach.h - definitions needed for TotalView interactions
+ *  debugger.h - definitions needed for TotalView interactions
  *****************************************************************************
  *  This file was supplied by James Cownie <jcownie@etnus.com> and provides 
  *  information required to interface Slurm to the TotalView debugger from 
@@ -7,7 +7,7 @@
  *  http://www.etnus.com/
 \*****************************************************************************/
 
-/*  $Id: attach.h 8570 2006-07-13 21:12:58Z morrone $
+/*  $Id: debugger.h 11149 2007-03-14 20:53:19Z morrone $
  */
 
 /* This file contains support for bringing processes up stopped, so that
@@ -19,8 +19,8 @@
  * Nov 27 1996 jcownie@dolphinics.com: Added the executable_name to MPIR_PROCDESC
  */
 
-#ifndef _SLAUNCH_ATTACH_INCLUDE
-#define _SLAUNCH_ATTACH_INCLUDE
+#ifndef _DEBUGGER_INCLUDE
+#define _DEBUGGER_INCLUDE
 
 #ifndef VOLATILE
 #if defined(__STDC__) || defined(__cplusplus)
@@ -29,7 +29,7 @@
 #define VOLATILE
 #endif
 #endif
-
+#include "src/srun/srun_job.h"
 /*****************************************************************************
 *                                DEBUGGING SUPPORT                           *
 *****************************************************************************/
diff --git a/src/srun/fname.c b/src/srun/fname.c
index 25f7a3357d04f0a2ad25d6faa8930c43e68e76a3..2b4093234fe0cd9da268a732abf719873e5a5e02 100644
--- a/src/srun/fname.c
+++ b/src/srun/fname.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -64,12 +64,12 @@
  * Fill in as much of filename as possible from srun, update
  * filename type to one of the io types ALL, NONE, PER_TASK, ONE
  */
-io_filename_t *
+fname_t *
 fname_create(srun_job_t *job, char *format)
 {
 	unsigned long int wid     = 0;
 	unsigned long int taskid  = 0;
-	io_filename_t *fname = NULL;
+	fname_t *fname = NULL;
 	char *p, *q, *name;
 
 	fname = xmalloc(sizeof(*fname));
@@ -166,7 +166,7 @@ fname_create(srun_job_t *job, char *format)
 }
 
 void 
-fname_destroy(io_filename_t *f)
+fname_destroy(fname_t *f)
 {
 	if (f->name)
 		xfree(f->name);
@@ -174,7 +174,7 @@ fname_destroy(io_filename_t *f)
 }
 
 char * 
-fname_remote_string (io_filename_t *f)
+fname_remote_string (fname_t *f)
 {
 	if ((f->type == IO_PER_TASK) || (f->type == IO_ONE))
 		return (xstrdup (f->name));
diff --git a/src/srun/fname.h b/src/srun/fname.h
index 09576a1ed989b6b94e6fc757135223932c94942e..ff51145536480fe640e9d9897f199a4dca3e2e7d 100644
--- a/src/srun/fname.h
+++ b/src/srun/fname.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -44,34 +44,17 @@
 
 #include "src/srun/srun_job.h"
 
-enum io_t {
-	IO_ALL          = 0, /* multiplex output from all/bcast stdin to all */
-	IO_ONE          = 1, /* output from only one task/stdin to one task  */
-	IO_PER_TASK     = 2, /* separate output/input file per task          */
-	IO_NONE         = 3, /* close output/close stdin                     */
-};
-
-#define format_io_t(t) (t == IO_ONE) ? "one" : (t == IO_ALL) ? \
-                                                     "all" : "per task"
-
-struct io_filename {
-	char      *name;
-	enum io_t  type;
-	int        taskid;  /* taskid for IO if IO_ONE */
-};
-
 /*
  * Create an filename from a (probably user supplied) filename format.
  * fname_create() will expand the format as much as possible for srun,
  * leaving node or task specific format specifiers for the remote 
  * slurmd to handle.
  */
-typedef struct srun_job fname_job_t;
 
-io_filename_t *fname_create(fname_job_t *job, char *format);
-void fname_destroy(io_filename_t *fname);
+fname_t *fname_create(srun_job_t *job, char *format);
+void fname_destroy(fname_t *fname);
 
-char * fname_remote_string (io_filename_t *fname);
+char * fname_remote_string (fname_t *fname);
 
 #endif /* !_FNAME_H */
 
diff --git a/src/srun/launch.c b/src/srun/launch.c
deleted file mode 100644
index c072aafe70604963c86b07cded1952d214977aba..0000000000000000000000000000000000000000
--- a/src/srun/launch.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/****************************************************************************\
- *  launch.c - initiate the user job's tasks.
- *  $Id: launch.c 11920 2007-08-01 22:13:12Z jette $
- *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <grondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/param.h>
-
-#include "src/common/log.h"
-#include "src/common/macros.h"
-#include "src/common/hostlist.h"
-#include "src/common/plugstack.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/slurm_protocol_interface.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/common/xsignal.h"
-#include "src/common/forward.h"
-#include "src/common/mpi.h"
-#include "src/api/step_io.h"
-
-#include "src/srun/srun_job.h"
-#include "src/srun/launch.h"
-#include "src/srun/opt.h"
-
-#define MAX_RETRIES 3
-
-extern char **environ;
-
-/* number of active threads */
-static int             fail_launch_cnt = 0;
-
-static void   _print_launch_msg(launch_tasks_request_msg_t *msg, 
-		                char * hostname);
-static void   _update_failed_node(srun_job_t *j, int id);
-static void   _update_contacted_node(srun_job_t *j, int id);
-
-int 
-launch_thr_create(srun_job_t *job)
-{
-	int e, retries = 0;
-	pthread_attr_t attr;
-
-	slurm_attr_init(&attr);
-	while ((e = pthread_create(&job->lid, &attr, &launch, (void *) job))) {
-		if (++retries > MAX_RETRIES) {
-			error ("pthread_create error %m");
-			slurm_attr_destroy(&attr);
-			slurm_seterrno_ret(e);
-		}
-		sleep(1);	/* sleep and try again */
-	}
-	slurm_attr_destroy(&attr);
-
-	debug("Started launch thread (%lu)", (unsigned long) job->lid);
-
-	return SLURM_SUCCESS;
-}
-
-void *
-launch(void *arg)
-{
-	launch_tasks_request_msg_t r;
-	srun_job_t *job = (srun_job_t *) arg;
-	int i, my_envc;
-	slurm_msg_t msg;
-	ret_data_info_t *ret_data = NULL;
-	List ret_list = NULL;
-	ListIterator ret_itr;
-	int rc = SLURM_SUCCESS;
-	int nodeid = NO_VAL;
-
-	update_job_state(job, SRUN_JOB_LAUNCHING);
-	
-	debug("going to launch %d tasks on %d hosts", 
-	      opt.nprocs, job->step_layout->node_cnt);
-
-	my_envc = envcount(environ);
-	/* convert timeout from sec to milliseconds */
-	opt.msg_timeout *= 1000;
-	memset(&r, 0, sizeof(r));
-
-	/* Common message contents */
-	r.job_id          = job->jobid;
-	r.uid             = opt.uid;
-	r.gid             = opt.gid;
-	r.argc            = remote_argc;
-	r.argv            = remote_argv;
-	r.cred            = job->cred;
-	r.job_step_id     = job->stepid;
-	r.envc            = my_envc;
-	r.env             = environ;
-	r.cwd             = opt.cwd;
-	r.nnodes          = job->step_layout->node_cnt;
-	r.nprocs          = opt.nprocs;
-	r.slurmd_debug    = opt.slurmd_debug;
-	r.switch_job      = job->switch_job;
-	r.task_prolog     = opt.task_prolog;
-	r.task_epilog     = opt.task_epilog;
-	r.task_dist       = opt.distribution;
-	r.plane_size      = opt.plane_size;
-	r.cpu_bind_type   = opt.cpu_bind_type;
-	r.cpu_bind        = opt.cpu_bind;
-	r.mem_bind_type   = opt.mem_bind_type;
-	r.mem_bind        = opt.mem_bind;
-	r.multi_prog      = opt.multi_prog;
-	r.options         = job_options_create();
-	r.complete_nodelist = xstrdup(job->step_layout->node_list);
-	spank_set_remote_options (r.options);
-
-	r.ofname  = fname_remote_string (job->ofname);
-	r.efname  = fname_remote_string (job->efname);
-	r.ifname  = fname_remote_string (job->ifname);
-	r.buffered_stdio = !opt.unbuffered;
-	
-	r.task_flags = 0;
-	if (opt.parallel_debug)
-		r.task_flags |= TASK_PARALLEL_DEBUG;
-	
-	/* Node specific message contents */
-	if (mpi_hook_client_single_task_per_node ()) {
-		for (i = 0; i < job->step_layout->node_cnt; i++)
-			job->step_layout->tasks[i] = 1;
-	} 
-	r.tasks_to_launch = job->step_layout->tasks;
-
-	r.global_task_ids = job->step_layout->tids;
-	r.cpus_allocated  = job->step_layout->tasks;
-	r.max_sockets     = opt.max_sockets_per_node;
-	r.max_cores       = opt.max_cores_per_socket;
-	r.max_threads     = opt.max_threads_per_core;
-	r.cpus_per_task   = opt.cpus_per_task;
-
-	r.ntasks_per_node   = opt.ntasks_per_node;
-	r.ntasks_per_socket = opt.ntasks_per_socket;
-	r.ntasks_per_core   = opt.ntasks_per_core;
-	
-	r.num_resp_port = job->njfds;
-	r.resp_port = xmalloc(sizeof(uint16_t) * r.num_resp_port);
-	for (i = 0; i < r.num_resp_port; i++) {
-		r.resp_port[i] = ntohs(job->jaddr[i].sin_port);
-	}
-
-	r.num_io_port = job->client_io->num_listen;
-	r.io_port = xmalloc(sizeof(uint16_t) * r.num_io_port);
-	for (i = 0; i < r.num_io_port; i++) {
-		r.io_port[i] = job->client_io->listenport[i];
-	}
-
-	
-	
-	//hostlist = hostlist_create(job->nodelist);
-	debug("sending to list %s", job->step_layout->node_list);
-	
-	slurm_msg_t_init(&msg);
-	msg.msg_type        = REQUEST_LAUNCH_TASKS;
-	msg.data            = &r;
-	
-	if (_verbose) {
-		for(i=0; i<job->step_layout->node_cnt; i++) {
-			char *name = nodelist_nth_host(
-				job->step_layout->node_list, i);
-			_print_launch_msg(&r, name);
-			free(name);
-		}
-	}
-	if(!(ret_list = slurm_send_recv_msgs(
-		     job->step_layout->node_list,
-		     &msg, opt.msg_timeout))) {
-		error("slurm_send_recv_msgs failed miserably: %m");
-		return NULL;
-	}
-
-	ret_itr = list_iterator_create(ret_list);
-	while ((ret_data = list_next(ret_itr))) {
-		rc = slurm_get_return_code(ret_data->type, 
-					   ret_data->data);
-		debug("launch returned msg_rc=%d err=%d type=%d",
-		      rc, ret_data->err, ret_data->type);
-		nodeid = nodelist_find(job->step_layout->node_list,
-				       ret_data->node_name);
-		
-		if(nodeid >= job->step_layout->node_cnt) {
-			/* Make sure we aren't trying to mark
-			 * something we haven't requested but was
-			 * included in the nodelist.  This should never
-			 * happen */
-			error("Job step allocation has more nodes than "
-			      "expected, ignoring node %s(%d): %s",
-			      ret_data->node_name, nodeid, 
-			      slurm_strerror(rc));
-		} else if (rc != SLURM_SUCCESS) {
-			slurm_seterrno(rc);
-			error("Task launch failed on node %s(%d): %s",
-			      ret_data->node_name, nodeid, 
-			      slurm_strerror(rc));
-			_update_failed_node(job, nodeid);
-			fail_launch_cnt++;
-		} else {
-#if 0 /* only for debugging, might want to make this a callback */
-			slurm_seterrno(rc);
-			info("Launch success on node %s(%d)",
-			     ret_data->node_name, nodeid);
-#endif
-			_update_contacted_node(job, nodeid);
-		}
-	}
-	list_iterator_destroy(ret_itr);
-	list_destroy(ret_list);
-	
-	if (fail_launch_cnt) {
-		srun_job_state_t jstate;
-
-		slurm_mutex_lock(&job->state_mutex);
-		jstate = job->state;
-		slurm_mutex_unlock(&job->state_mutex);
-
-		if (jstate < SRUN_JOB_TERMINATED) {
-			error("%d launch request%s failed", 
-			      fail_launch_cnt, fail_launch_cnt > 1 ? "s" : "");
-			job->rc = 124;
-			srun_job_kill(job);
-		}
-
-	} else {
-		debug("All task launch requests sent");
-		update_job_state(job, SRUN_JOB_STARTING);
-	}
-	xfree(r.io_port);
-	xfree(r.resp_port);
-	xfree(r.complete_nodelist);
-		
-	return(void *)(0);
-}
-
-static void
-_update_failed_node(srun_job_t *j, int id)
-{
-	int i;
-	pipe_enum_t pipe_enum = PIPE_HOST_STATE;
-	
-	pthread_mutex_lock(&j->task_mutex);
-	if (j->host_state[id] == SRUN_HOST_INIT) {
-		j->host_state[id] = SRUN_HOST_UNREACHABLE;
-
-		if(message_thread) {
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-			      &pipe_enum,sizeof(int));
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-			      &id,sizeof(int));
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-			      &j->host_state[id],sizeof(int));
-		}
-	}
-
-	pipe_enum = PIPE_TASK_STATE;
-	for (i = 0; i < j->step_layout->tasks[id]; i++) {
-		j->task_state[j->step_layout->tids[id][i]] = SRUN_TASK_FAILED;
-
-		if(message_thread) {
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-				   &pipe_enum, sizeof(int));
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-				   &j->step_layout->tids[id][i], sizeof(int));
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-				   &j->task_state[j->step_layout->tids[id][i]],
-				   sizeof(int));
-		}
-	}
-	pthread_mutex_unlock(&j->task_mutex);
-
-	/* update_failed_tasks(j, id); */
-	return;
-rwfail:
-	pthread_mutex_unlock(&j->task_mutex);
-	error("_update_failed_node: "
-	      "write from srun message-handler process failed");
-}
-
-static void
-_update_contacted_node(srun_job_t *j, int id)
-{
-	pipe_enum_t pipe_enum = PIPE_HOST_STATE;
-	pthread_mutex_lock(&j->task_mutex);
-	if (j->host_state[id] == SRUN_HOST_INIT) {
-		j->host_state[id] = SRUN_HOST_CONTACTED;
-		if(message_thread) {
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-				   &pipe_enum, sizeof(int));
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-				   &id, sizeof(int));
-			safe_write(j->forked_msg->par_msg->msg_pipe[1],
-				   &j->host_state[id], sizeof(int));
-		}
-	}
-	pthread_mutex_unlock(&j->task_mutex);
-	return;
-rwfail:
-	pthread_mutex_unlock(&j->task_mutex);
-	error("_update_contacted_node: "
-	      "write from srun message-handler process failed");
-}
-
-static void 
-_print_launch_msg(launch_tasks_request_msg_t *msg, char * hostname)
-{
-	int i;
-	char tmp_str[10], task_list[4096];
-	int nodeid = nodelist_find(msg->complete_nodelist, hostname);
-	
-	if (opt.distribution == SLURM_DIST_BLOCK) {
-		sprintf(task_list, "%u-%u", 
-		        msg->global_task_ids[nodeid][0],
-			msg->global_task_ids[nodeid]
-			[(msg->tasks_to_launch[nodeid]-1)]);
-	} else {
-		for (i=0; i<msg->tasks_to_launch[nodeid]; i++) {
-			sprintf(tmp_str, ",%u", 
-				msg->global_task_ids[nodeid][i]);
-			if (i == 0)
-				strcpy(task_list, &tmp_str[1]);
-			else if ((strlen(tmp_str) + strlen(task_list)) < 
-			         sizeof(task_list))
-				strcat(task_list, tmp_str);
-			else
-				break;
-		}
-	}
-
-	info("launching %u.%u on host %s, %u tasks: %s", 
-	     msg->job_id, msg->job_step_id, hostname, 
-	     msg->tasks_to_launch[nodeid], task_list);
-
-	debug3("uid:%ld gid:%ld cwd:%s %d", (long) msg->uid,
-		(long) msg->gid, msg->cwd, nodeid);
-}
diff --git a/src/srun/msg.c b/src/srun/msg.c
deleted file mode 100644
index 21e2d12a1574c4c2645e69a499ef875c6f4a9f68..0000000000000000000000000000000000000000
--- a/src/srun/msg.c
+++ /dev/null
@@ -1,1565 +0,0 @@
-/****************************************************************************\
- *  msg.c - process message traffic between srun and slurm daemons
- *  $Id: msg.c 12809 2007-12-11 18:41:21Z jette $
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#if HAVE_PTHREAD_H
-#  include <pthread.h>
-#endif
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-#include <sys/poll.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <time.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <slurm/slurm_errno.h>
-
-#include "src/common/fd.h"
-#include "src/common/hostlist.h"
-#include "src/common/log.h"
-#include "src/common/macros.h"
-#include "src/common/read_config.h"
-#include "src/common/slurm_auth.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/slurm_protocol_defs.h"
-#include "src/common/xassert.h"
-#include "src/common/xmalloc.h"
-#include "src/common/mpi.h"
-#include "src/common/forward.h"
-#include "src/api/pmi_server.h"
-
-#include "src/srun/srun_job.h"
-#include "src/srun/opt.h"
-#include "src/srun/msg.h"
-#include "src/srun/sigstr.h"
-#include "src/srun/attach.h"
-#include "src/srun/allocate.h"
-#include "src/srun/multi_prog.h"
-#include "src/srun/signals.h"
-#include "src/srun/srun.h"
-
-#include "src/common/xstring.h"
-
-#define LAUNCH_WAIT_SEC	 60	/* max wait to confirm launches, sec */
-#define MAX_RETRIES 3		/* pthread_create retries */
-
-static int    tasks_exited     = 0;
-static uid_t  slurm_uid;
-static slurm_fd slurmctld_fd   = (slurm_fd) NULL;
-
-/*
- *  Static prototypes
- */
-static void	_accept_msg_connection(srun_job_t *job, int fdnum);
-static void	_confirm_launch_complete(srun_job_t *job);
-static void	_dump_proctable(srun_job_t *job);
-static void	_exec_prog(slurm_msg_t *msg);
-static void 	_exit_handler(srun_job_t *job, slurm_msg_t *exit_msg);
-static void	_handle_msg(srun_job_t *job, slurm_msg_t *msg);
-static inline bool _job_msg_done(srun_job_t *job);
-static void	_launch_handler(srun_job_t *job, slurm_msg_t *resp);
-static void	_job_step_complete(srun_job_t *job, slurm_msg_t *msg);
-static void     _do_poll_timeout(srun_job_t *job);
-static int      _get_next_timeout(srun_job_t *job);
-static void 	_msg_thr_poll(srun_job_t *job);
-static void	_set_jfds_nonblocking(srun_job_t *job);
-static void     _print_pid_list(const char *host, int ntasks, 
-				uint32_t *pid, char *executable_name);
-static void	_node_fail_handler(int fd, srun_job_t *job);
-static void	_node_fail_forwarder(char *nodelist, srun_job_t *job);
-
-#define _poll_set_rd(_pfd, _fd) do {    \
-	(_pfd).fd = _fd;                \
-	(_pfd).events = POLLIN;         \
-	} while (0)
-
-#define _poll_set_wr(_pfd, _fd) do {    \
-	(_pfd).fd = _fd;                \
-	(_pfd).events = POLLOUT;        \
-	} while (0)
-
-#define _poll_rd_isset(pfd) ((pfd).revents & POLLIN )
-#define _poll_wr_isset(pfd) ((pfd).revents & POLLOUT)
-#define _poll_err(pfd)      ((pfd).revents & POLLERR)
-
-/* fd is job->forked_msg->par_msg->msg_pipe[1] */
-static void _update_mpir_proctable(int fd, srun_job_t *job,
-				   int nodeid, int ntasks, uint32_t *pid,
-				   char *executable)
-{
-	int msg_type = PIPE_UPDATE_MPIR_PROCTABLE;
-	int dummy = 0xdeadbeef;
-	int len;
-	int i;
-
-	xassert(message_thread);
-	safe_write(fd, &msg_type, sizeof(int)); /* read by par_thr() */
-	safe_write(fd, &dummy, sizeof(int));    /* read by par_thr() */
-
-	/* the rest are read by _handle_update_mpir_proctable() */
-	safe_write(fd, &nodeid, sizeof(int));
-	safe_write(fd, &ntasks, sizeof(int));
-	len = strlen(executable) + 1;
-	safe_write(fd, &len, sizeof(int));
-	if (len > 0) {
-		safe_write(fd, executable, len);
-	}
-	for (i = 0; i < ntasks; i++) {
-		int taskid = job->step_layout->tids[nodeid][i];
-		safe_write(fd, &taskid, sizeof(int));
-		safe_write(fd, &pid[i], sizeof(int));
-	}
-
-	return;
-
-rwfail:
-	error("_update_mpir_proctable: write to srun main process failed");
-}
-
-static void _handle_update_mpir_proctable(int fd, srun_job_t *job)
-{
-	static int tasks_recorded = 0;
-	int nodeid;
-	int ntasks;
-	int len;
-	char *executable = NULL;
-	int i;
-	char *name = NULL;
-	
-	/* some initialization */
-	if (MPIR_proctable_size == 0) {
-		MPIR_proctable_size = job->step_layout->task_cnt;
-		MPIR_proctable = xmalloc(sizeof(MPIR_PROCDESC)
-					 * MPIR_proctable_size);
-		totalview_jobid = NULL;
-		xstrfmtcat(totalview_jobid, "%u", job->jobid);
-	}
-
-	safe_read(fd, &nodeid, sizeof(int));
-	safe_read(fd, &ntasks, sizeof(int));
-	safe_read(fd, &len, sizeof(int));
-	if (len > 0) {
-		executable = xmalloc(len);
-		safe_read(fd, executable, len);
-
-		/* remote_argv global will be NULL during an srun --attach */
-		if (remote_argv == NULL) {
-			remote_argc = 1;
-			xrealloc(remote_argv, 2 * sizeof(char *));
-			remote_argv[0] = executable;
-			remote_argv[1] = NULL;
-		}
-	}
-	name = nodelist_nth_host(job->step_layout->node_list, nodeid);
-	for (i = 0; i < ntasks; i++) {
-		MPIR_PROCDESC *tv;
-		int taskid, pid;
-
-		safe_read(fd, &taskid, sizeof(int));
-		safe_read(fd, &pid, sizeof(int));
-
-		tv = &MPIR_proctable[taskid];
-		tv->host_name = xstrdup(name);
-		tv->pid = pid;
-		tv->executable_name = executable;
-		tasks_recorded++;
-	}
-	free(name);
-	/* if all tasks are now accounted for, set the debug state and
-	   call the Breakpoint */
-	if (tasks_recorded == job->step_layout->task_cnt) {
-		if (opt.multi_prog)
-			set_multi_name(tasks_recorded);
-		MPIR_debug_state = MPIR_DEBUG_SPAWNED;
-		MPIR_Breakpoint();
-		if (opt.debugger_test)
-			_dump_proctable(job);
-	}
-	
-	return;
-
-rwfail:
-	error("_handle_update_mpir_proctable: "
-	      "read from srun message-handler process failed");
-}
-
-static void _update_step_layout(int fd, slurm_step_layout_t *layout, 
-				int nodeid)
-{
-	int msg_type = PIPE_UPDATE_STEP_LAYOUT;
-	int dummy = 0xdeadbeef;
-	
-	safe_write(fd, &msg_type, sizeof(int)); /* read by par_thr() */
-	safe_write(fd, &dummy, sizeof(int));    /* read by par_thr() */
-
-	/* the rest are read by _handle_update_step_layout() */
-	safe_write(fd, &nodeid, sizeof(int));
-	safe_write(fd, &layout->node_cnt, sizeof(uint32_t));
-	safe_write(fd, &layout->task_cnt, sizeof(uint32_t));
-	safe_write(fd, &layout->tasks[nodeid], sizeof(uint16_t));
-	safe_write(fd, layout->tids[nodeid],
-		   layout->tasks[nodeid]*sizeof(uint32_t));
-
-	return;
-
-rwfail:
-	error("_update_step_layout: write to srun main process failed");
-}
-
-static void _handle_update_step_layout(int fd, slurm_step_layout_t *layout)
-{
-	int nodeid;
-	
-	safe_read(fd, &nodeid, sizeof(int));
-	safe_read(fd, &layout->node_cnt, sizeof(uint32_t));
-	safe_read(fd, &layout->task_cnt, sizeof(uint32_t));
-	xassert(nodeid >= 0 && nodeid <= layout->task_cnt);
-
-	/* If this is the first call to this function, then we probably need
-	   to intialize some of the arrays */
-	if (layout->tasks == NULL)
-		layout->tasks = xmalloc(layout->node_cnt * sizeof(uint16_t *));
-	if (layout->tids == NULL)
-		layout->tids = xmalloc(layout->node_cnt * sizeof(uint32_t *));
-
-	safe_read(fd, &layout->tasks[nodeid], sizeof(uint16_t));
-	xassert(layout->tids[nodeid] == NULL);
-	layout->tids[nodeid] = xmalloc(layout->tasks[nodeid]*sizeof(uint32_t));
-	safe_read(fd, layout->tids[nodeid],
-		  layout->tasks[nodeid]*sizeof(uint32_t));
-	return;
-
-rwfail:
-	error("_handle_update_step_layout: "
-	      "read from srun message-handler process failed");
-}
-
-static void _dump_proctable(srun_job_t *job)
-{
-	int node_inx, task_inx, taskid;
-	int task_cnt;
-	MPIR_PROCDESC *tv;
-
-	for (node_inx=0; node_inx<job->nhosts; node_inx++) {
-		task_cnt = job->step_layout->tasks[node_inx];
-		for (task_inx = 0; task_inx < task_cnt; task_inx++) {
-			taskid = job->step_layout->tids[node_inx][task_inx];
-			tv = &MPIR_proctable[taskid];
-			if (!tv)
-				break;
-			info("task:%d, host:%s, pid:%d, executable:%s",
-			     taskid, tv->host_name, tv->pid,
-			     tv->executable_name);
-		}
-	} 
-}
-	
-void debugger_launch_failure(srun_job_t *job)
-{
-	int i;
-	pipe_enum_t pipe_enum = PIPE_MPIR_DEBUG_STATE;
-	
-	if (opt.parallel_debug) {
-		if(message_thread && job) {
-			i = MPIR_DEBUG_ABORTING;
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &pipe_enum, sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &i, sizeof(int));
-		}
-	}
-	return;
-rwfail:
-	error("debugger_launch_failure: "
-	      "write from srun message-handler process failed");
-
-}
-
-/*
- * Job has been notified of it's approaching time limit. 
- * Job will be killed shortly after timeout.
- * This RPC can arrive multiple times with the same or updated timeouts.
- * FIXME: We may want to signal the job or perform other action for this.
- * FIXME: How much lead time do we want for this message? Some jobs may 
- *	require tens of minutes to gracefully terminate.
- */
-void timeout_handler(time_t timeout)
-{
-	static time_t last_timeout = 0;
-
-	if (timeout != last_timeout) {
-		last_timeout = timeout;
-		verbose("job time limit to be reached at %s", 
-			ctime(&timeout));
-	}
-}
-
-/*
- * Job has been notified of a node's failure (at least the node's slurmd 
- * has stopped responding to slurmctld). It is possible that the user's 
- * job is continuing to execute on the specified nodes, but quite possibly 
- * not. The job will continue to execute given the --no-kill option. 
- * Otherwise all of the job's tasks and the job itself are killed..
- */
-static void _node_fail_handler(int fd, srun_job_t *job)
-{
-	char *nodelist = NULL;
-	int len = 0;
-	hostset_t fail_nodes, all_nodes;
-	hostlist_iterator_t fail_itr;
-	char *node;
-	int num_node_ids;
-	int *node_ids;
-	int i, j;
-	int node_id, num_tasks;
-
-	/* get the hostlist string of failed nodes from the message thread */
-	safe_read(fd, &len, sizeof(int));
-	nodelist = (char *)xmalloc(len+1);
-	safe_read(fd, nodelist, len);
-	nodelist[len] = '\0';
-
-	/* now process the down nodes and tell the IO client about them */
-	fail_nodes = hostset_create(nodelist);
-	fail_itr = hostset_iterator_create(fail_nodes);
-	num_node_ids = hostset_count(fail_nodes);
-	node_ids = xmalloc(sizeof(int) * num_node_ids);
-
-	all_nodes = hostset_create(job->step_layout->node_list);
-	/* find the index number of each down node */
-	slurm_mutex_lock(&job->task_mutex);
-	for (i = 0; i < num_node_ids; i++) {
-		node = hostlist_next(fail_itr);
-		node_id = node_ids[i] = hostset_find(all_nodes, node);
-		if (job->host_state[node_id] != SRUN_HOST_UNREACHABLE) {
-			error("Node failure: %s.", node);
-			job->host_state[node_id] = SRUN_HOST_UNREACHABLE;
-		}
-		free(node);
-
-		/* find all of the tasks that should run on this failed node
-		 * and mark them as having failed.
-		 */
-		num_tasks = job->step_layout->tasks[node_id];
-		for (j = 0; j < num_tasks; j++) {
-			int gtaskid;
-			debug2("marking task %d done on failed node %d",
-			       job->step_layout->tids[node_id][j], node_id);
-			gtaskid = job->step_layout->tids[node_id][j];
-			job->task_state[gtaskid] = SRUN_TASK_FAILED;
-		}
-	}
-	slurm_mutex_unlock(&job->task_mutex);
-
-	if (!opt.allocate) {
-		client_io_handler_downnodes(job->client_io, node_ids,
-					    num_node_ids);
-	}
-
-	if (!opt.no_kill) {
-		update_job_state(job, SRUN_JOB_FORCETERM);
-		info("sending SIGINT to remaining tasks");
-		fwd_signal(job, SIGINT, opt.max_threads);
-	}
-
-	xfree(nodelist);
-	return;
-rwfail:
-	error("Failure reading node failure message from message process: %m");
-	if (nodelist != NULL)
-		xfree(nodelist);
-	return;
-}
-
-/*
- * Forward the node failure message to the main srun process.
- *
- * NOTE: this is called from the forked message handling process
- */
-static void _node_fail_forwarder(char *nodelist, srun_job_t *job)
-{
-	pipe_enum_t pipe_enum = PIPE_NODE_FAIL;
-	int dummy = 0xdeadbeef;
-	int pipe_fd = job->forked_msg->par_msg->msg_pipe[1];
-	int len;
-
-	len = strlen(nodelist);
-	if (message_thread) {
-		safe_write(pipe_fd, &pipe_enum, sizeof(int));
-		safe_write(pipe_fd, &dummy, sizeof(int));
-
-		/* the following writes are handled by _node_fail_handler */
-		safe_write(pipe_fd, &len, sizeof(int));
-		safe_write(pipe_fd, nodelist, len);
-	}
-	return;
-rwfail:
-	error("Failure sending node failure message to main process: %m");
-	return;
-}
-
-static bool _job_msg_done(srun_job_t *job)
-{
-	return (job->state >= SRUN_JOB_TERMINATED);
-}
-
-static void
-_process_launch_resp(srun_job_t *job, launch_tasks_response_msg_t *msg)
-{
-	pipe_enum_t pipe_enum = PIPE_HOST_STATE;
-	int nodeid = nodelist_find(job->step_layout->node_list,
-				   msg->node_name);
-
-	if ((nodeid < 0) || (nodeid >= job->nhosts)) {
-		error ("Bad launch response from %s", msg->node_name);
-		return;
-	}
-	pthread_mutex_lock(&job->task_mutex);
-	job->host_state[nodeid] = SRUN_HOST_REPLIED;
-	pthread_mutex_unlock(&job->task_mutex);
-
-	if(message_thread) {
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &pipe_enum, sizeof(int));
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &nodeid, sizeof(int));
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &job->host_state[nodeid], sizeof(int));
-		
-	}
-	_update_mpir_proctable(job->forked_msg->par_msg->msg_pipe[1], job,
-			       nodeid, msg->count_of_pids,
-			       msg->local_pids, remote_argv[0]);
-	_print_pid_list( msg->node_name, msg->count_of_pids, 
-			 msg->local_pids, remote_argv[0]     );
-	return;
-rwfail:
-	error("_process_launch_resp: "
-	      "write from srun message-handler process failed");
-	
-}
-
-/* This is used to initiate an OpenMPI checkpoint program, 
- * but is written to be general purpose */
-static void
-_exec_prog(slurm_msg_t *msg)
-{
-	pid_t child;
-	int pfd[2], status, exit_code = 0, i;
-	ssize_t len;
-	char *argv[4], buf[256] = "";
-	time_t now = time(NULL);
-	bool checkpoint = false;
-	srun_exec_msg_t *exec_msg = msg->data;
-
-	if (exec_msg->argc > 2) {
-		verbose("Exec '%s %s' for %u.%u", 
-			exec_msg->argv[0], exec_msg->argv[1],
-			exec_msg->job_id, exec_msg->step_id);
-	} else {
-		verbose("Exec '%s' for %u.%u", 
-			exec_msg->argv[0], 
-			exec_msg->job_id, exec_msg->step_id);
-	}
-
-	if (strcmp(exec_msg->argv[0], "ompi-checkpoint") == 0)
-		checkpoint = true;
-	if (checkpoint) {
-		/* OpenMPI specific checkpoint support */
-		info("Checkpoint started at %s", ctime(&now));
-		for (i=0; (exec_msg->argv[i] && (i<2)); i++) {
-			argv[i] = exec_msg->argv[i];
-		}
-		snprintf(buf, sizeof(buf), "%ld", (long) srun_ppid);
-		argv[i] = buf;
-		argv[i+1] = NULL;
-	}
-
-	if (pipe(pfd) == -1) {
-		snprintf(buf, sizeof(buf), "pipe: %s", strerror(errno));
-		error("%s", buf);
-		exit_code = errno;
-		goto fini;
-	}
-
-	child = fork();
-	if (child == 0) {
-		int fd = open("/dev/null", O_RDONLY);
-		dup2(fd, 0);		/* stdin from /dev/null */
-		dup2(pfd[1], 1);	/* stdout to pipe */
-		dup2(pfd[1], 2);	/* stderr to pipe */
-		close(pfd[0]);
-		close(pfd[1]);
-		if (checkpoint)
-			execvp(exec_msg->argv[0], argv);
-		else
-			execvp(exec_msg->argv[0], exec_msg->argv);
-		error("execvp(%s): %m", exec_msg->argv[0]);
-	} else if (child < 0) {
-		snprintf(buf, sizeof(buf), "fork: %s", strerror(errno));
-		error("%s", buf);
-		exit_code = errno;
-		goto fini;
-	} else {
-		close(pfd[1]);
-		len = read(pfd[0], buf, sizeof(buf));
-		close(pfd[0]);
-		waitpid(child, &status, 0);
-		exit_code = WEXITSTATUS(status);
-	}
-
-fini:	if (checkpoint) {
-		now = time(NULL);
-		if (exit_code) {
-			info("Checkpoint completion code %d at %s", 
-				exit_code, ctime(&now));
-		} else {
-			info("Checkpoint completed successfully at %s",
-				ctime(&now));
-		}
-		if (buf[0])
-			info("Checkpoint location: %s", buf);
-		slurm_checkpoint_complete(exec_msg->job_id, exec_msg->step_id,
-			time(NULL), (uint32_t) exit_code, buf);
-	}
-}
-
-/* This typically signifies the job was cancelled by scancel */
-static void
-_job_step_complete(srun_job_t *job, slurm_msg_t *msg)
-{
-	srun_job_complete_msg_t *step_msg = msg->data;
-
-	if (step_msg->step_id == NO_VAL) {
-		verbose("Complete job %u received",
-			step_msg->job_id);
-	} else {
-		verbose("Complete job step %u.%u received",
-			step_msg->job_id, step_msg->step_id);
-	}
-	update_job_state(job, SRUN_JOB_FORCETERM);
-	job->removed = true;
-}
-
-static void
-update_tasks_state(srun_job_t *job, uint32_t nodeid)
-{
-	int i;
-	pipe_enum_t pipe_enum = PIPE_TASK_STATE;
-	slurm_mutex_lock(&job->task_mutex);
-	debug2("updating %u tasks state for node %u", 
-	       job->step_layout->tasks[nodeid], nodeid);
-	for (i = 0; i < job->step_layout->tasks[nodeid]; i++) {
-		uint32_t tid = job->step_layout->tids[nodeid][i];
-
-		if(message_thread) {
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &pipe_enum,sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &tid,sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &job->task_state[tid],sizeof(int));
-		}
-	}
-	slurm_mutex_unlock(&job->task_mutex);
-	return;
-rwfail:
-	slurm_mutex_unlock(&job->task_mutex);
-	error("update_tasks_state: "
-	      "write from srun message-handler process failed");
-
-}
-
-static void
-update_running_tasks(srun_job_t *job, uint32_t nodeid)
-{
-	int i;
-	pipe_enum_t pipe_enum = PIPE_TASK_STATE;
-	debug2("updating %u running tasks for node %u", 
-	       job->step_layout->tasks[nodeid], nodeid);
-	slurm_mutex_lock(&job->task_mutex);
-	for (i = 0; i < job->step_layout->tasks[nodeid]; i++) {
-		uint32_t tid = job->step_layout->tids[nodeid][i];
-		job->task_state[tid] = SRUN_TASK_RUNNING;
-
-		if(message_thread) {
-			safe_write(job->forked_msg->
-				   par_msg->msg_pipe[1],
-				   &pipe_enum,sizeof(int));
-			safe_write(job->forked_msg->
-				   par_msg->msg_pipe[1],&tid, sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &job->task_state[tid], sizeof(int));
-		}
-	}
-	slurm_mutex_unlock(&job->task_mutex);
-	return;
-rwfail:
-	slurm_mutex_unlock(&job->task_mutex);
-	error("update_running_tasks: "
-	      "write from srun message-handler process failed");
-}
-
-static void
-update_failed_tasks(srun_job_t *job, uint32_t nodeid)
-{
-	int i;
-	pipe_enum_t pipe_enum = PIPE_TASK_STATE;
-	
-	slurm_mutex_lock(&job->task_mutex);
-	for (i = 0; i < job->step_layout->tasks[nodeid]; i++) {
-		uint32_t tid = job->step_layout->tids[nodeid][i];
-		job->task_state[tid] = SRUN_TASK_FAILED;
-
-		if(message_thread) {
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &pipe_enum, sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1], 
-				   &tid, sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &job->task_state[tid], sizeof(int));
-		}
-		tasks_exited++;
-	}
-	slurm_mutex_unlock(&job->task_mutex);
-
-	if (tasks_exited == opt.nprocs) {
-		debug2("all tasks exited");
-		update_job_state(job, SRUN_JOB_TERMINATED);
-	}
-rwfail:
-	slurm_mutex_unlock(&job->task_mutex);
-	error("update_failed_tasks: "
-	      "write from srun message-handler process failed");
-
-}
-
-static void
-_launch_handler(srun_job_t *job, slurm_msg_t *resp)
-{
-	launch_tasks_response_msg_t *msg = resp->data;
-	pipe_enum_t pipe_enum = PIPE_HOST_STATE;
-	int nodeid = nodelist_find(job->step_layout->node_list, 
-				   msg->node_name);
-		
-	debug3("received launch resp from %s nodeid=%d", 
-	       msg->node_name,
-	       nodeid);
-	
-	if (msg->return_code != 0)  {
-
-		error("%s: launch failed: %s", 
-		      msg->node_name, slurm_strerror(msg->return_code));
-
-		slurm_mutex_lock(&job->task_mutex);
-		job->host_state[nodeid] = SRUN_HOST_REPLIED;
-		slurm_mutex_unlock(&job->task_mutex);
-		
-		if(message_thread) {
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &pipe_enum, sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &nodeid, sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &job->host_state[nodeid],
-				   sizeof(int));
-		}
-		update_failed_tasks(job, nodeid);
-
-		/*
-		  if (!opt.no_kill) {
-		  job->rc = 124;
-		  update_job_state(job, SRUN_JOB_WAITING_ON_IO);
-		  } else 
-		  update_failed_tasks(job, nodeid);
-		*/
-		debugger_launch_failure(job);
-		return;
-	} else {
-		_process_launch_resp(job, msg);
-		update_running_tasks(job, nodeid);
-	}
-	return;
-rwfail:
-	error("_launch_handler: "
-	      "write from srun message-handler process failed");
-
-}
-
-/* _confirm_launch_complete
- * confirm that all tasks registers a sucessful launch
- * pthread_exit with job kill on failure */
-static void	
-_confirm_launch_complete(srun_job_t *job)
-{
-	int i;
-	char *name = NULL;
-
-	printf("job->nhosts %d\n",job->nhosts);
-		
-	for (i=0; i<job->nhosts; i++) {
-		printf("job->nhosts %d\n",job->nhosts);
-		if (job->host_state[i] != SRUN_HOST_REPLIED) {
-			name = nodelist_nth_host(job->step_layout->node_list,
-						 i);
-			error ("Node %s not responding, terminating job step",
-			       name);
-			free(name);
-			info("sending Ctrl-C to remaining tasks");
-			fwd_signal(job, SIGINT, opt.max_threads);
-			job->rc = 124;
-			update_job_state(job, SRUN_JOB_FAILED);
-			pthread_exit(0);
-		}
-	}
-
-	/*
-	 *  Reset launch timeout so timer will no longer go off
-	 */
-	job->ltimeout = 0;
-}
-
-static void
-_reattach_handler(srun_job_t *job, slurm_msg_t *msg)
-{
-	int i;
-	reattach_tasks_response_msg_t *resp = msg->data;
-	int nodeid = nodelist_find(job->step_layout->node_list, 
-				   resp->node_name);
-		
-	if ((nodeid < 0) || (nodeid >= job->nhosts)) {
-		error ("Invalid reattach response received");
-		return;
-	}
-
-	slurm_mutex_lock(&job->task_mutex);
-	job->host_state[nodeid] = SRUN_HOST_REPLIED;
-	slurm_mutex_unlock(&job->task_mutex);
-
-	if(message_thread) {
-		pipe_enum_t pipe_enum = PIPE_HOST_STATE;
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &pipe_enum, sizeof(int));
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &nodeid, sizeof(int));
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &job->host_state[nodeid], sizeof(int));
-	}
-
-	if (resp->return_code != 0) {
-		if (job->stepid == NO_VAL) { 
-			error ("Unable to attach to job %d: %s", 
-			       job->jobid, slurm_strerror(resp->return_code));
-		} else {
-			error ("Unable to attach to step %d.%d on node %d: %s",
-			       job->jobid, job->stepid, nodeid,
-			       slurm_strerror(resp->return_code));
-		}
-		job->rc = 1;
-
-		update_job_state(job, SRUN_JOB_FAILED);
-		return;
-	}
-
-	/* 
-	 * store global task id information as returned from slurmd
-	 */
-	job->step_layout->tids[nodeid]  = 
-		xmalloc( resp->ntasks * sizeof(uint32_t) );
-
-	job->step_layout->tasks[nodeid] = resp->ntasks;
-
-	info ("ntasks = %d\n");
-
-	for (i = 0; i < resp->ntasks; i++) {
-		job->step_layout->tids[nodeid][i] = resp->gtids[i];
-		info ("setting task%d on hostid %d\n", 
-		      resp->gtids[i], nodeid);
-	}
-	_update_step_layout(job->forked_msg->par_msg->msg_pipe[1],
-			    job->step_layout, nodeid);
-
-	/* Build process table for any parallel debugger
-         */
-	if ((remote_argc == 0) && (resp->executable_names)) {
-		remote_argc = 1;
-		xrealloc(remote_argv, 2 * sizeof(char *));
-		remote_argv[0] = resp->executable_names[0];
-		resp->executable_names = NULL; /* nothing left to free */
-		remote_argv[1] = NULL;
-	}
-	_update_mpir_proctable(job->forked_msg->par_msg->msg_pipe[1], job,
-			       nodeid, resp->ntasks,
-			       resp->local_pids, remote_argv[0]);
-
-	_print_pid_list(resp->node_name, resp->ntasks, resp->local_pids, 
-			remote_argv[0]);
-
-	update_running_tasks(job, nodeid);
-	return;
-rwfail:
-	error("_reattach_handler: "
-	      "write from srun message-handler process failed");
-}
-
-
-static void 
-_print_exit_status(srun_job_t *job, hostlist_t hl, char *host, int status)
-{
-	char buf[MAXHOSTRANGELEN];
-	char *corestr = "";
-	bool signaled  = false;
-	void (*print) (const char *, ...) = (void *) &error; 
-		
-	xassert(hl != NULL);
-
-	slurm_mutex_lock(&job->state_mutex);
-	signaled = job->signaled;
-	slurm_mutex_unlock(&job->state_mutex);
-	
-	/*
-	 *  Print message that task was signaled as verbose message
-	 *    not error message if the user generated the signal.
-	 */
-	if (signaled) 
-		print = &verbose;
-
-	hostlist_ranged_string(hl, sizeof(buf), buf);
-
-	if (status == 0) {
-		verbose("%s: %s: Done", host, buf);
-		return;
-	}
-
-#ifdef WCOREDUMP
-	if (WCOREDUMP(status))
-		corestr = " (core dumped)";
-#endif
-
-	if (WIFSIGNALED(status)) {
-		(*print) ("%s: task%s: %s%s", host, buf, 
-			  sigstr(status), corestr); 
-	} else {
-		error ("%s: task%s: Exited with exit code %d", 
-		       host, buf, WEXITSTATUS(status));
-	}
-
-	return;
-}
-
-static void
-_die_if_signaled(srun_job_t *job, int status)
-{
-	bool signaled  = false;
-
-	slurm_mutex_lock(&job->state_mutex);
-	signaled = job->signaled;
-	slurm_mutex_unlock(&job->state_mutex);
-
-	if (WIFSIGNALED(status) && !signaled) {
-		job->rc = 128 + WTERMSIG(status);
-		update_job_state(job, SRUN_JOB_FAILED);
-	}
-}
-
-static void
-_update_task_exitcode(srun_job_t *job, int taskid)
-{
-	pipe_enum_t pipe_enum = PIPE_TASK_EXITCODE;
-
-	if(message_thread) {
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &pipe_enum, sizeof(int));
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &taskid, sizeof(int));
-		safe_write(job->forked_msg->par_msg->msg_pipe[1],
-			   &job->tstatus[taskid], sizeof(int));
-	}
-	return;
-rwfail:
-	error("_update_task_exitcode: "
-	      "write from srun message-handler process failed");
-}
-
-static void 
-_exit_handler(srun_job_t *job, slurm_msg_t *exit_msg)
-{
-	task_exit_msg_t *msg       = (task_exit_msg_t *) exit_msg->data;
-	hostlist_t       hl        = hostlist_create(NULL);
-	int              task0     = msg->task_id_list[0];
-	char            *host      = NULL;
-	int              status    = msg->return_code;
-	int              i;
-	char             buf[1024];
-	
-	if (!(host = slurm_step_layout_host_name(job->step_layout, task0)))
-		host = "Unknown host";
-	debug2("exited host %s", host);
-	if (!job->etimeout && !tasks_exited) 
-		job->etimeout = time(NULL) + opt.max_exit_timeout;
-
-	for (i = 0; i < msg->num_tasks; i++) {
-		uint32_t taskid = msg->task_id_list[i];
-
-		if ((taskid < 0) || (taskid >= opt.nprocs)) {
-			error("task exit resp has bad task id %d", taskid);
-			continue;
-		}
-
-		snprintf(buf, sizeof(buf), "%d", taskid);
-		hostlist_push(hl, buf);
-
-		slurm_mutex_lock(&job->task_mutex);
-		job->tstatus[taskid] = status;
-		_update_task_exitcode(job, taskid);
-		if (status) 
-			job->task_state[taskid] = SRUN_TASK_ABNORMAL_EXIT;
-		else {
-			job->task_state[taskid] = SRUN_TASK_EXITED;
-		}
-
-		slurm_mutex_unlock(&job->task_mutex);
-
-		tasks_exited++;
-		debug2("looking for %d got %d", opt.nprocs, tasks_exited);
-		if ((tasks_exited == opt.nprocs) 
-		    || (mpi_hook_client_single_task_per_node () 
-			&& (tasks_exited == job->nhosts))) {
-			debug2("All tasks exited");
-			update_job_state(job, SRUN_JOB_TERMINATED);
-		}
-	}
-	
-	update_tasks_state(job, slurm_step_layout_host_id(job->step_layout, 
-							  task0));
-		
-	_print_exit_status(job, hl, host, status);
-
-	hostlist_destroy(hl);
-
-	_die_if_signaled(job, status);
-
-	/*
-	 * When a task terminates with a non-zero exit code and the
-	 * "--kill-on-bad-exit" option is set, terminate the entire job.
-	 */
-	if (status != 0 && opt.kill_bad_exit)
-	{
-		static int first_time = 1;
-
-		/* Only kill the job once. */
-		if (first_time)
-		{
-			debug("Terminating job due to a non-zero exit code");
-
-			first_time = 0;
-
-			srun_job_kill(job);
-		}
-	}
-}
-
-static void
-_handle_msg(srun_job_t *job, slurm_msg_t *msg)
-{
-	uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred);
-	uid_t uid     = getuid();
-	int rc;
-	srun_timeout_msg_t *to;
-	srun_node_fail_msg_t *nf;
-	srun_user_msg_t *um;
-	
-	if ((req_uid != slurm_uid) && (req_uid != 0) && (req_uid != uid)) {
-		error ("Security violation, slurm message from uid %u", 
-		       (unsigned int) req_uid);
-		return;
-	}
-
-	switch (msg->msg_type)
-	{
-	case RESPONSE_LAUNCH_TASKS:
-		debug("received task launch response");
-		_launch_handler(job, msg);
-		slurm_free_launch_tasks_response_msg(msg->data);
-		break;
-	case MESSAGE_TASK_EXIT:
-		debug2("task_exit received");
-		_exit_handler(job, msg);
-		slurm_free_task_exit_msg(msg->data);
-		break;
-	case RESPONSE_REATTACH_TASKS:
-		debug2("received reattach response");
-		_reattach_handler(job, msg);
-		slurm_free_reattach_tasks_response_msg(msg->data);
-		break;
-	case SRUN_PING:
-		debug3("slurmctld ping received");
-		slurm_send_rc_msg(msg, SLURM_SUCCESS);
-		slurm_free_srun_ping_msg(msg->data);
-		break;
-	case SRUN_EXEC:
-		_exec_prog(msg);
-		slurm_free_srun_exec_msg(msg->data);
-		break;
-	case SRUN_JOB_COMPLETE:
-		_job_step_complete(job, msg);
-		slurm_free_srun_job_complete_msg(msg->data);
-		break;
-	case SRUN_TIMEOUT:
-		verbose("timeout received");
-		to = msg->data;
-		timeout_handler(to->timeout);
-		slurm_free_srun_timeout_msg(msg->data);
-		break;
-	case SRUN_USER_MSG:
-		um = msg->data;
-		info("%s", um->msg);
-		slurm_free_srun_user_msg(msg->data);
-		break;
-	case SRUN_NODE_FAIL:
-		verbose("node_fail received");
-		nf = msg->data;
-		_node_fail_forwarder(nf->nodelist, job);
-		slurm_free_srun_node_fail_msg(msg->data);
-		break;
-	case RESPONSE_RESOURCE_ALLOCATION:
-		debug3("resource allocation response received");
-		slurm_send_rc_msg(msg, SLURM_SUCCESS);
-		slurm_free_resource_allocation_response_msg(msg->data);
-		break;
-	case PMI_KVS_PUT_REQ:
-		debug3("PMI_KVS_PUT_REQ received");
-		rc = pmi_kvs_put((struct kvs_comm_set *) msg->data);
-		slurm_send_rc_msg(msg, rc);
-		break;
-	case PMI_KVS_GET_REQ:
-		debug3("PMI_KVS_GET_REQ received");
-		rc = pmi_kvs_get((kvs_get_msg_t *) msg->data);
-		slurm_send_rc_msg(msg, rc);
-		slurm_free_get_kvs_msg((kvs_get_msg_t *) msg->data);
-		break;
-	default:
-		error("received spurious message type: %d\n",
-		      msg->msg_type);
-		break;
-	}
-	return;
-}
-
-/* NOTE: One extra FD for incoming slurmctld messages */
-static void
-_accept_msg_connection(srun_job_t *job, int fdnum)
-{
-	slurm_fd     fd = (slurm_fd) NULL;
-	slurm_msg_t *msg = NULL;
-	slurm_addr   cli_addr;
-	unsigned char *uc;
-	short        port;
-	int          timeout = 0;	/* slurm default value */
-
-	if (fdnum < job->njfds)
-		fd = slurm_accept_msg_conn(job->jfd[fdnum], &cli_addr);
-	else
-		fd = slurm_accept_msg_conn(slurmctld_fd, &cli_addr);
-
-	if (fd < 0) {
-		error("Unable to accept connection: %m");
-		return;
-	}
-
-	/* Should not call slurm_get_addr() because the IP may not be
-	   in /etc/hosts. */
-	uc = (unsigned char *)&cli_addr.sin_addr.s_addr;
-	port = cli_addr.sin_port;
-	debug2("got message connection from %u.%u.%u.%u:%hu",
-	       uc[0], uc[1], uc[2], uc[3], ntohs(port));
-
-	msg = xmalloc(sizeof(slurm_msg_t));
-	slurm_msg_t_init(msg);
-		
-	/* multiple jobs (easily induced via no_alloc) and highly
-	 * parallel jobs using PMI sometimes result in slow message 
-	 * responses and timeouts. Raise the default timeout for srun. */
-	timeout = slurm_get_msg_timeout() * 8000;
-again:
-	if(slurm_receive_msg(fd, msg, timeout) != 0) {
-		if (errno == EINTR) {
-			goto again;
-		}
-		error("slurm_receive_msg[%u.%u.%u.%u]: %m",
-		      uc[0],uc[1],uc[2],uc[3]);
-		goto cleanup;
-	}
-		
-	_handle_msg(job, msg); /* handle_msg frees msg->data */
-cleanup:
-	if ((msg->conn_fd >= 0) && slurm_close_accepted_conn(msg->conn_fd) < 0)
-		error ("close(%d): %m", msg->conn_fd);
-	slurm_free_msg(msg);
-	
-
-	return;
-}
-
-
-static void
-_set_jfds_nonblocking(srun_job_t *job)
-{
-	int i;
-	for (i = 0; i < job->njfds; i++) 
-		fd_set_nonblocking(job->jfd[i]);
-}
-
-/*
- *  Call poll() with a timeout. (timeout argument is in seconds)
- * NOTE: One extra FD for incoming slurmctld messages
- */
-static int
-_do_poll(srun_job_t *job, struct pollfd *fds, int timeout)
-{
-	nfds_t nfds = (job->njfds + 1);
-	int rc, to;
-
-	if (timeout > 0)
-		to = timeout * 1000;
-	else
-		to = timeout;
-
-	while ((rc = poll(fds, nfds, to)) < 0) {
-		switch (errno) {
-		case EAGAIN:
-		case EINTR:  continue;
-		case ENOMEM:
-		case EINVAL:
-		case EFAULT: fatal("poll: %m");
-		default:     error("poll: %m. Continuing...");
-			continue;
-		}
-	}
-
-	return rc;
-}
-
-
-/*
- *  Get the next timeout in seconds from now.
- */
-static int 
-_get_next_timeout(srun_job_t *job)
-{
-	int timeout = -1;
-
-	if (!job->ltimeout && !job->etimeout)
-		return -1;
-
-	if (!job->ltimeout)
-		timeout = job->etimeout - time(NULL);
-	else if (!job->etimeout)
-		timeout = job->ltimeout - time(NULL);
-	else 
-		timeout = job->ltimeout < job->etimeout ? 
-			job->ltimeout - time(NULL) : 
-			job->etimeout - time(NULL);
-
-	return timeout;
-}
-
-/*
- *  Handle the two poll timeout cases:
- *    1. Job launch timed out
- *    2. Exit timeout has expired (either print a message or kill job)
- */
-static void
-_do_poll_timeout(srun_job_t *job)
-{
-	time_t now = time(NULL);
-
-	if ((job->ltimeout > 0) && (job->ltimeout <= now)) 
-		_confirm_launch_complete(job);
-
-	if ((job->etimeout > 0) && (job->etimeout <= now)) {
-		if (!opt.max_wait)
-			info("Warning: first task terminated %ds ago", 
-			     opt.max_exit_timeout);
-		else {
-			error("First task exited %ds ago", opt.max_wait);
-			report_task_status(job);
-			update_job_state(job, SRUN_JOB_FAILED);
-		}
-		job->etimeout = 0;
-	}
-}
-
-/* NOTE: One extra FD for incoming slurmctld messages */
-static void 
-_msg_thr_poll(srun_job_t *job)
-{
-	struct pollfd *fds;
-	int i;
-	
-	fds = xmalloc((job->njfds + 1) * sizeof(*fds));
-
-	_set_jfds_nonblocking(job);
-		
-	for (i = 0; i < job->njfds; i++)
-		_poll_set_rd(fds[i], job->jfd[i]);
-	_poll_set_rd(fds[i], slurmctld_fd);
-	
-	while (!_job_msg_done(job)) {
-		if (_do_poll(job, fds, _get_next_timeout(job)) == 0) {
-			_do_poll_timeout(job);
-			continue;
-		}
-		
-		for (i = 0; i < (job->njfds + 1) ; i++) {
-			unsigned short revents = fds[i].revents;
-			if ((revents & POLLERR) || 
-			    (revents & POLLHUP) ||
-			    (revents & POLLNVAL))
-				error("poll error on jfd %d: %m", fds[i].fd);
-			else if (revents & POLLIN) 
-				_accept_msg_connection(job, i);
-		}
-		
-	}
-	
-	xfree(fds);	/* if we were to break out of while loop */
-}
-
-void *
-msg_thr(void *arg)
-{
-	srun_job_t *job = (srun_job_t *) arg;
-	forked_msg_pipe_t *par_msg = job->forked_msg->par_msg;
-	debug3("msg thread pid = %lu", (unsigned long) getpid());
-
-	slurm_uid = (uid_t) slurm_get_slurm_user_id();
-
-	_msg_thr_poll(job);
-
-	close(par_msg->msg_pipe[1]); // close excess fildes
-	debug3("msg thread done");	
-	return (void *)1;
-}
-
-
-/*
- *  This function runs in a pthread of the parent srun process and
- *  handles messages from the srun message-handler process.
- */
-void *
-par_thr(void *arg)
-{
-	srun_job_t *job = (srun_job_t *) arg;
-	forked_msg_pipe_t *par_msg = job->forked_msg->par_msg;
-	forked_msg_pipe_t *msg_par = job->forked_msg->msg_par;
-	int c;
-	pipe_enum_t type=0;
-	int tid=-1;
-	int status;
-	debug3("par thread pid = %lu", (unsigned long) getpid());
-
-	//slurm_uid = (uid_t) slurm_get_slurm_user_id();
-	close(msg_par->msg_pipe[0]); // close read end of pipe
-	close(par_msg->msg_pipe[1]); // close write end of pipe 
-	/* Note: On some message types, we read a task ID as the 
-	 * first number then read status or exit code as the second */
-	while(read(par_msg->msg_pipe[0], &c, sizeof(int)) 
-	      == sizeof(int)) {
-		// getting info from msg thread
-		if(type == PIPE_NONE) {
-			debug2("got type %d\n",c);
-			type = c;
-			continue;
-		} 
-
-		switch(type) {
-		case PIPE_JOB_STATE:
-			debug("PIPE_JOB_STATE, c = %d", c);
-			update_job_state(job, c);
-			break;
-		case PIPE_TASK_STATE:
-			if(tid == -1) {
-				tid = c;
-				continue;
-			}
-			debug("PIPE_TASK_STATE tid=%d, state=%d", tid, c);
-			slurm_mutex_lock(&job->task_mutex);
-			job->task_state[tid] = c;
-			if(c == SRUN_TASK_FAILED)
-				tasks_exited++;
-			slurm_mutex_unlock(&job->task_mutex);
-			if (tasks_exited == opt.nprocs) {
-				debug2("all tasks exited");
-				update_job_state(job, SRUN_JOB_TERMINATED);
-			}
-			tid = -1;
-			break;
-		case PIPE_TASK_EXITCODE:
-			if(tid == -1) {
-				tid = c;
-				continue;
-			}
-			debug("PIPE_TASK_EXITCODE tid=%d code=%d", tid, c);
-			slurm_mutex_lock(&job->task_mutex);
-			job->tstatus[tid] = c;
-			slurm_mutex_unlock(&job->task_mutex);
-			tid = -1;
-			break;
-		case PIPE_HOST_STATE:
-			if(tid == -1) {
-				tid = c;
-				continue;
-			}
-			slurm_mutex_lock(&job->task_mutex);
-			job->host_state[tid] = c;
-			slurm_mutex_unlock(&job->task_mutex);
-			tid = -1;
-			break;
-		case PIPE_SIGNALED:
-			slurm_mutex_lock(&job->state_mutex);
-			job->signaled = c;
-			slurm_mutex_unlock(&job->state_mutex);
-			break;
-		case PIPE_MPIR_DEBUG_STATE:
-			MPIR_debug_state = c;
-			MPIR_Breakpoint();
-			if (opt.debugger_test)
-				_dump_proctable(job);
-			break;
-		case PIPE_UPDATE_MPIR_PROCTABLE:
-			_handle_update_mpir_proctable(par_msg->msg_pipe[0],
-						      job);
-			break;
-		case PIPE_UPDATE_STEP_LAYOUT:
-			_handle_update_step_layout(par_msg->msg_pipe[0],
-						   job->step_layout);
-			break;
-		case PIPE_NODE_FAIL:
-			_node_fail_handler(par_msg->msg_pipe[0], job);
-			break;
-		default:
-			error("Unrecognized message from message thread %d",
-			      type);
-		}
-		type = PIPE_NONE;
-	}
-	close(par_msg->msg_pipe[0]); // close excess fildes    
-	close(msg_par->msg_pipe[1]); // close excess fildes
-	if(waitpid(par_msg->pid,&status,0)<0) // wait for pid to finish
-		return NULL;// there was an error
-	debug3("par thread done");
-	return (void *)1;
-}
-
-/*
- * Forks the srun process that handles messages even if the main srun
- * process is stopped (for instance, by totalview).  Also creates
- * the various pthreads used in the original and monitor process.
- *
- * NOTE: call this before creating any pthreads to avoid having forked process 
- * hang on localtime_t() mutex locked in parent processes pthread.
- */
-extern int 
-msg_thr_create(srun_job_t *job)
-{
-	int i, retries = 0;
-	pthread_attr_t attr;
-	int c;
-	
-	job->forked_msg = xmalloc(sizeof(forked_msg_t));
-	job->forked_msg->par_msg = xmalloc(sizeof(forked_msg_pipe_t));
-	job->forked_msg->msg_par = xmalloc(sizeof(forked_msg_pipe_t));
-	
-	set_allocate_job(job);
-
-	for (i = 0; i < job->njfds; i++) {
-		if ((job->jfd[i] = slurm_init_msg_engine_port(0)) < 0)
-			fatal("init_msg_engine_port: %m");
-		if (slurm_get_stream_addr(job->jfd[i], 
-					  &job->jaddr[i]) 
-		    < 0)
-			fatal("slurm_get_stream_addr: %m");
-		debug("initialized job control port %d\n",
-		      ntohs(((struct sockaddr_in)
-			     job->jaddr[i]).sin_port));
-	}
-
-	if (pipe(job->forked_msg->par_msg->msg_pipe) == -1) {
-		error("pipe():  %m"); 
-		return SLURM_ERROR;
-	}
-	if (pipe(job->forked_msg->msg_par->msg_pipe) == -1) {
-		error("pipe():  %m"); 
-		return SLURM_ERROR;
-	}
-	debug2("created the pipes for communication");
-
-	/* retry fork for super-heavily loaded systems */
-	for (i = 0; ; i++) {
-		if((job->forked_msg->par_msg->pid = fork()) != -1)
-			break;
-		if (i < 3)
-			usleep(1000);
-		else {
-			error("fork(): %m");
-			return SLURM_ERROR;
-		}
-	}
-
-	if (job->forked_msg->par_msg->pid == 0) {
-		/* child */
-		setsid();  
-		message_thread = 1;
-		close(job->forked_msg->
-		      par_msg->msg_pipe[0]); // close read end of pipe
-		close(job->forked_msg->
-		      msg_par->msg_pipe[1]); // close write end of pipe
-		slurm_attr_init(&attr);
-		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-		while ((errno = pthread_create(&job->jtid, &attr, &msg_thr,
-					       (void *)job))) {
-			if (++retries > MAX_RETRIES)
-				fatal("Can't create pthread");
-			sleep(1);
-		}
-		slurm_attr_destroy(&attr);
-		debug("Started msg to parent server thread (%lu)", 
-		      (unsigned long) job->jtid);
-		
-		/*
-		 * Wait for the main srun process to exit.  When it
-		 * does, the other end of the msg_par->msg_pipe will
-		 * close.
-		 */
-		while(read(job->forked_msg->msg_par->msg_pipe[0],
-			   &c, sizeof(int)) > 0)
-			; /* do nothing */
-		
-		close(job->forked_msg->msg_par->msg_pipe[0]);
-		/*
-		 * These xfree aren't really necessary if we are just going
-		 * to exit, and they can cause the message thread to
-		 * segfault.
-		 */
-		/* xfree(job->forked_msg->par_msg); */
-		/* xfree(job->forked_msg->msg_par); */
-		/* xfree(job->forked_msg); */
-		_exit(0);
-	} else {
-		/* parent */
-
-		slurm_attr_init(&attr);
-		while ((errno = pthread_create(&job->jtid, &attr, &par_thr, 
-					       (void *)job))) {
-			if (++retries > MAX_RETRIES)
-				fatal("Can't create pthread");
-			sleep(1);	/* sleep and try again */
-		}
-		slurm_attr_destroy(&attr);
-
-		debug("Started parent to msg server thread (%lu)", 
-		      (unsigned long) job->jtid);
-	}
-
-	
-	return SLURM_SUCCESS;
-}
-
-static void
-_print_pid_list(const char *host, int ntasks, uint32_t *pid, 
-		char *executable_name)
-{
-	if (_verbose) {
-		int i;
-		hostlist_t pids = hostlist_create(NULL);
-		char buf[MAXHOSTRANGELEN];
-		
-		for (i = 0; i < ntasks; i++) {
-			snprintf(buf, sizeof(buf), "pids:%d", pid[i]);
-			hostlist_push(pids, buf);
-		}
-		
-		hostlist_ranged_string(pids, sizeof(buf), buf);
-		verbose("%s: %s %s", host, executable_name, buf);
-	}
-}
-
-/* Set up port to handle messages from slurmctld */
-extern slurm_fd slurmctld_msg_init(void)
-{
-	slurm_addr slurm_address;
-	uint16_t port;
-
-	if (slurmctld_fd)	/* May set early for queued job allocation */
-		return slurmctld_fd;
-
-	if (opt.allocate && opt.noshell)
-		return -1;
-
-	slurmctld_fd = -1;
-	slurmctld_comm_addr.hostname = NULL;
-	slurmctld_comm_addr.port = 0;
-
-	if ((slurmctld_fd = slurm_init_msg_engine_port(0)) < 0)
-		fatal("slurm_init_msg_engine_port error %m");
-	if (slurm_get_stream_addr(slurmctld_fd, &slurm_address) < 0)
-		fatal("slurm_get_stream_addr error %m");
-	fd_set_nonblocking(slurmctld_fd);
-	/* hostname is not set,  so slurm_get_addr fails
-	   slurm_get_addr(&slurm_address, &port, hostname, sizeof(hostname)); */
-	port = ntohs(slurm_address.sin_port);
-	slurmctld_comm_addr.hostname = xstrdup(opt.ctrl_comm_ifhn);
-	slurmctld_comm_addr.port     = port;
-	debug2("slurmctld messages to host=%s,port=%u", 
-	       slurmctld_comm_addr.hostname, 
-	       slurmctld_comm_addr.port);
-
-	return slurmctld_fd;
-}
-
-
diff --git a/src/srun/multi_prog.c b/src/srun/multi_prog.c
index f2d49dcbd6ef7eee7f0469fd3202c7531e1cf3e2..91d09ce0ec0ac8eaf31a8b54e80029b1e2a3fbc5 100644
--- a/src/srun/multi_prog.c
+++ b/src/srun/multi_prog.c
@@ -11,7 +11,7 @@
  *  and
  *  Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -22,7 +22,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -59,7 +59,7 @@
 #include "src/common/xassert.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
-#include "src/srun/attach.h"
+#include "src/srun/debugger.h"
 
 /* Given a program name, translate it to a fully qualified pathname
  * as needed based upon the PATH environment variable */
@@ -170,18 +170,16 @@ _set_exec_names(char *ranks, char *exec_name, int ntasks)
 }
 
 extern int
-set_multi_name(int ntasks)
+mpir_set_multi_name(int ntasks, const char *config_fname)
 {
 	FILE *config_fd;
 	char line[256];
-	char *config_fname = NULL, *ranks, *exec_name, *p, *ptrptr;
+	char *ranks, *exec_name, *p, *ptrptr;
 	int line_num = 0, i;
 
 	for (i=0; i<ntasks; i++) {
 		MPIR_PROCDESC *tv;
 		tv = &MPIR_proctable[i];
-		if (i == 0)
-			config_fname = tv->executable_name;
 		tv->executable_name = NULL;
 	}
 
@@ -222,6 +220,55 @@ set_multi_name(int ntasks)
 	return 0;
 }
 
+extern void
+mpir_init(int num_tasks)
+{
+	MPIR_proctable_size = num_tasks;
+	MPIR_proctable = xmalloc(sizeof(MPIR_PROCDESC) * num_tasks);
+	if (MPIR_proctable == NULL)
+		fatal("Unable to initialize MPIR_proctable: %m");
+}
+
+extern void
+mpir_cleanup()
+{
+	int i;
+
+	for (i = 0; i < MPIR_proctable_size; i++) {
+		xfree(MPIR_proctable[i].host_name);
+		xfree(MPIR_proctable[i].executable_name);
+	}
+	xfree(MPIR_proctable);
+}
+
+extern void
+mpir_set_executable_names(const char *executable_name)
+{
+	int i;
+
+	for (i = 0; i < MPIR_proctable_size; i++) {
+		MPIR_proctable[i].executable_name = xstrdup(executable_name);
+		if (MPIR_proctable[i].executable_name == NULL)
+			fatal("Unable to set MPI_proctable executable_name:"
+			      " %m");
+	}
+}
+
+extern void
+mpir_dump_proctable()
+{
+	MPIR_PROCDESC *tv;
+	int i;
+
+	for (i = 0; i < MPIR_proctable_size; i++) {
+		tv = &MPIR_proctable[i];
+		if (!tv)
+			break;
+		info("task:%d, host:%s, pid:%d, executable:%s",
+		     i, tv->host_name, tv->pid, tv->executable_name);
+	}
+}
+
 static int
 _update_task_mask(int low_num, int high_num, int ntasks, bitstr_t *task_mask)
 {
diff --git a/src/srun/multi_prog.h b/src/srun/multi_prog.h
index 28c2cc37cc9787c32994d4609beed4a76e8a2d12..e32d98efbd345ff0556cf517ede1e05317d30e7a 100644
--- a/src/srun/multi_prog.h
+++ b/src/srun/multi_prog.h
@@ -7,7 +7,7 @@
  *  and
  *  Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -18,7 +18,7 @@
  *  any later version.
  *
  *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
+ *  to link the code of portions of this program with the OpenSSL library under
  *  certain conditions as described in each individual source file, and 
  *  distribute linked combinations including the two. You must obey the GNU 
  *  General Public License in all respects for all of the code used other than 
@@ -42,7 +42,11 @@
 
 /* set global MPIR_PROCDESC executable names based upon multi-program 
  * configuration file */
-extern int set_multi_name(int ntasks);
+extern int mpir_set_multi_name(int ntasks, const char *config_fname);
+extern void mpir_init(int num_tasks);
+extern void mpir_cleanup(void);
+extern void mpir_set_executable_names(const char *executable_name);
+extern void mpir_dump_proctable(void);
 
 /*
  * Verify that we have a valid executable program specified for each task
diff --git a/src/srun/opt.c b/src/srun/opt.c
index 06afe966a99c728af38d60498adc476e22bb5d47..59d46290e06bdbbd2fa477fc5de71555a139614a 100644
--- a/src/srun/opt.c
+++ b/src/srun/opt.c
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  opt.c - options processing for srun
- *  $Id: opt.c 13727 2008-03-27 23:49:35Z jette $
+ *  $Id: opt.c 14110 2008-05-22 16:34:50Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -72,6 +72,7 @@
 #include "src/common/list.h"
 #include "src/common/log.h"
 #include "src/common/parse_time.h"
+#include "src/common/proc_args.h"
 #include "src/common/slurm_protocol_api.h"
 #include "src/common/slurm_protocol_interface.h"
 #include "src/common/uid.h"
@@ -82,9 +83,9 @@
 #include "src/common/optz.h"
 #include "src/api/pmi_server.h"
 
-#include "src/srun/attach.h"
 #include "src/srun/multi_prog.h"
 #include "src/srun/opt.h"
+#include "src/srun/debugger.h"
 #include "src/common/mpi.h"
 
 /* generic OPT_ definitions -- mainly for use with env vars  */
@@ -106,6 +107,8 @@
 #define OPT_NCORES      0x11
 #define OPT_NTHREADS    0x12
 #define OPT_EXCLUSIVE   0x13
+#define OPT_OPEN_MODE   0x14
+#define OPT_ACCTG_FREQ  0x15
 
 /* generic getopt_long flags, integers and *not* valid characters */
 #define LONG_OPT_HELP        0x100
@@ -122,7 +125,6 @@
 #define LONG_OPT_GID         0x10b
 #define LONG_OPT_MPI         0x10c
 #define LONG_OPT_CORE	     0x10e
-#define LONG_OPT_NOSHELL     0x10f
 #define LONG_OPT_DEBUG_TS    0x110
 #define LONG_OPT_CONNTYPE    0x111
 #define LONG_OPT_TEST_ONLY   0x113
@@ -141,9 +143,7 @@
 #define LONG_OPT_MEM_BIND    0x120
 #define LONG_OPT_CTRL_COMM_IFHN 0x121
 #define LONG_OPT_MULTI       0x122
-#define LONG_OPT_NO_REQUEUE  0x123
 #define LONG_OPT_COMMENT     0x124
-#define LONG_OPT_REQUEUE     0x125
 #define LONG_OPT_SOCKETSPERNODE  0x130
 #define LONG_OPT_CORESPERSOCKET	 0x131
 #define LONG_OPT_THREADSPERCORE  0x132
@@ -153,7 +153,7 @@
 #define LONG_OPT_NTASKSPERNODE	 0x136
 #define LONG_OPT_NTASKSPERSOCKET 0x137
 #define LONG_OPT_NTASKSPERCORE	 0x138
-#define LONG_OPT_JOBMEM	         0x13a
+#define LONG_OPT_TASK_MEM        0x13a
 #define LONG_OPT_HINT	         0x13b
 #define LONG_OPT_BLRTS_IMAGE     0x140
 #define LONG_OPT_LINUX_IMAGE     0x141
@@ -161,27 +161,23 @@
 #define LONG_OPT_RAMDISK_IMAGE   0x143
 #define LONG_OPT_REBOOT          0x144
 #define LONG_OPT_GET_USER_ENV    0x145
+#define LONG_OPT_PTY             0x146
+#define LONG_OPT_CHECKPOINT      0x147
+#define LONG_OPT_CHECKPOINT_PATH 0x148
+#define LONG_OPT_OPEN_MODE       0x149
+#define LONG_OPT_ACCTG_FREQ      0x14a
 
 /*---- global variables, defined in opt.h ----*/
-char **remote_argv;
-int remote_argc;
 int _verbose;
-enum modes mode;
 opt_t opt;
 
 /*---- forward declarations of static functions  ----*/
 
 typedef struct env_vars env_vars_t;
 
-/* return command name from its full path name */
-static char * _base_name(char* command);
-
-static List  _create_path_list(void);
 
 /* Get a decimal integer from arg */
 static int  _get_int(const char *arg, const char *what, bool positive);
-static bool _get_resource_range(const char *arg, const char *what, 
-                                int *min, int *max, bool isFatal);
 
 static void  _help(void);
 
@@ -193,8 +189,8 @@ static void _opt_default(void);
 
 /* set options based upon env vars  */
 static void _opt_env(void);
+
 static void _opt_args(int argc, char **argv);
-static void _proc_get_user_env(char *optarg);
 
 /* list known options and their settings  */
 static void  _opt_list(void);
@@ -202,39 +198,16 @@ static void  _opt_list(void);
 /* verify options sanity  */
 static bool _opt_verify(void);
 
-static void  _print_version(void);
-
 static void _process_env_var(env_vars_t *e, const char *val);
 
-static uint16_t _parse_mail_type(const char *arg);
-static char *_print_mail_type(const uint16_t type);
-
-/* search PATH for command returns full path */
-static char *_search_path(char *, bool, int);
-
-static long  _to_bytes(const char *arg);
-
 static bool  _under_parallel_debugger(void);
 
 static void  _usage(void);
 static bool  _valid_node_list(char **node_list_pptr);
-static task_dist_states_t _verify_dist_type(const char *arg, uint32_t *psize);
-static bool  _verify_socket_core_thread_count(const char *arg,
-					   int *min_sockets, int *max_sockets,
-					   int *min_cores, int *max_cores,
-					   int *min_threads, int  *max_threads,
-					   cpu_bind_type_t *cpu_bind_type);
-static bool  _verify_hint(const char *arg,
-					   int *min_sockets, int *max_sockets,
-					   int *min_cores, int *max_cores,
-					   int *min_threads, int  *max_threads,
-					   cpu_bind_type_t *cpu_bind_type);
 static int   _verify_cpu_bind(const char *arg, char **cpu_bind,
-			      cpu_bind_type_t *cpu_bind_type);
-static int   _verify_geometry(const char *arg, uint16_t *geometry);
+			      cpu_bind_type_t *flags);
 static int   _verify_mem_bind(const char *arg, char **mem_bind,
-			      mem_bind_type_t *mem_bind_type);
-static int   _verify_conn_type(const char *arg);
+			      mem_bind_type_t *flags);
 
 /*---[ end forward declarations of static functions ]---------------------*/
 
@@ -249,6 +222,9 @@ int initialize_and_process_args(int argc, char *argv[])
 	/* initialize options with argv */
 	_opt_args(argc, argv);
 
+	if (!_opt_verify())
+		exit(1);
+
 	if (_verbose > 3)
 		_opt_list();
 
@@ -256,11 +232,6 @@ int initialize_and_process_args(int argc, char *argv[])
 
 }
 
-static void _print_version(void)
-{
-	printf("%s %s\n", PACKAGE, SLURM_VERSION);
-}
-
 /*
  * If the node list supplied is a file name, translate that into 
  *	a list of nodes, we orphan the data pointed to
@@ -298,117 +269,6 @@ static bool _valid_node_list(char **node_list_pptr)
 	return true;
 }
 
-/* 
- * verify that a distribution type in arg is of a known form
- * returns the task_dist_states, or -1 if state is unknown
- */
-static task_dist_states_t _verify_dist_type(const char *arg, 
-					    uint32_t *plane_size)
-{
-	int len = strlen(arg);
-	char *dist_str = NULL;
-	task_dist_states_t result = SLURM_DIST_UNKNOWN;
-	bool lllp_dist = false, plane_dist = false;
-
-	dist_str = strchr(arg,':');
-	if (dist_str != NULL) {
-		/* -m cyclic|block:cyclic|block */
-		lllp_dist = true;
-	} else {
-		/* -m plane=<plane_size> */
-		dist_str = strchr(arg,'=');
-		if(dist_str != NULL) {
-			*plane_size=atoi(dist_str+1);
-			len = dist_str-arg;
-			plane_dist = true;
-		}
-	}
-
-	if (lllp_dist) {
-		if (strcasecmp(arg, "cyclic:cyclic") == 0) {
-			result = SLURM_DIST_CYCLIC_CYCLIC;
-		} else if (strcasecmp(arg, "cyclic:block") == 0) {
-			result = SLURM_DIST_CYCLIC_BLOCK;
-		} else if (strcasecmp(arg, "block:block") == 0) {
-			result = SLURM_DIST_BLOCK_BLOCK;
-		} else if (strcasecmp(arg, "block:cyclic") == 0) {
-			result = SLURM_DIST_BLOCK_CYCLIC;
-		}
-	} else if (plane_dist) {
-		if (strncasecmp(arg, "plane", len) == 0) {
-			result = SLURM_DIST_PLANE;
-		}
-	} else {
-		if (strncasecmp(arg, "cyclic", len) == 0) {
-			result = SLURM_DIST_CYCLIC;
-		} else if (strncasecmp(arg, "block", len) == 0) {
-			result = SLURM_DIST_BLOCK;
-		} else if ((strncasecmp(arg, "arbitrary", len) == 0) ||
-		           (strncasecmp(arg, "hostfile", len) == 0)) {
-			result = SLURM_DIST_ARBITRARY;
-		}
-	}
-
-	return result;
-}
-
-/*
- * verify that a connection type in arg is of known form
- * returns the connection_type or -1 if not recognized
- */
-static int _verify_conn_type(const char *arg)
-{
-	int len = strlen(arg);
-
-	if (!strncasecmp(arg, "MESH", len))
-		return SELECT_MESH;
-	else if (!strncasecmp(arg, "TORUS", len))
-		return SELECT_TORUS;
-	else if (!strncasecmp(arg, "NAV", len))
-		return SELECT_NAV;
-
-	error("invalid --conn-type argument %s ignored.", arg);
-	return -1;
-}
-
-/*
- * verify geometry arguments, must have proper count
- * returns -1 on error, 0 otherwise
- */
-static int _verify_geometry(const char *arg, uint16_t *geometry)
-{
-	char* token, *delimiter = ",x", *next_ptr;
-	int i, rc = 0;
-	char* geometry_tmp = xstrdup(arg);
-	char* original_ptr = geometry_tmp;
-
-	token = strtok_r(geometry_tmp, delimiter, &next_ptr);
-	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-		if (token == NULL) {
-			error("insufficient dimensions in --geometry");
-			rc = -1;
-			break;
-		}
-		geometry[i] = (uint16_t)atoi(token);
-		if (geometry[i] == 0 || geometry[i] == (uint16_t)NO_VAL) {
-			error("invalid --geometry argument");
-			rc = -1;
-			break;
-		}
-		geometry_tmp = next_ptr;
-		token = strtok_r(geometry_tmp, delimiter, &next_ptr);
-	}
-	if (token != NULL) {
-		error("too many dimensions in --geometry");
-		rc = -1;
-	}
-
-	if (original_ptr)
-		xfree(original_ptr);
-
-	return rc;
-}
-
 /*
  * _isvalue
  * returns 1 is the argument appears to be a value, 0 otherwise
@@ -428,27 +288,64 @@ static int _isvalue(char *arg) {
 	return 0;	/* not a value */
 }
 
+/*
+ * First clear all of the bits in "*data" which are set in "clear_mask".
+ * Then set all of the bits in "*data" that are set in "set_mask".
+ */
+static void clear_then_set(int *data, int clear_mask, int set_mask)
+{
+	*data &= ~clear_mask;
+	*data |= set_mask;
+}
+
+static void _print_cpu_bind_help()
+{
+	printf(
+"CPU bind options:\n"
+"    --cpu_bind=         Bind tasks to CPUs\n"
+"        q[uiet]         quietly bind before task runs (default)\n"
+"        v[erbose]       verbosely report binding before task runs\n"
+"        no[ne]          don't bind tasks to CPUs (default)\n"
+"        rank            bind by task rank\n"
+"        map_cpu:<list>  specify a CPU ID binding for each task\n"
+"                        where <list> is <cpuid1>,<cpuid2>,...<cpuidN>\n"
+"        mask_cpu:<list> specify a CPU ID binding mask for each task\n"
+"                        where <list> is <mask1>,<mask2>,...<maskN>\n"
+"        sockets         auto-generated masks bind to sockets\n"
+"        cores           auto-generated masks bind to cores\n"
+"        threads         auto-generated masks bind to threads\n"
+"        help            show this help message\n");
+}
+
 /*
  * verify cpu_bind arguments
+ *
+ * we support different launch policy names
+ * we also allow a verbose setting to be specified
+ *     --cpu_bind=threads
+ *     --cpu_bind=cores
+ *     --cpu_bind=sockets
+ *     --cpu_bind=v
+ *     --cpu_bind=rank,v
+ *     --cpu_bind=rank
+ *     --cpu_bind={MAP_CPU|MASK_CPU}:0,1,2,3,4
+ *
+ *
  * returns -1 on error, 0 otherwise
  */
 static int _verify_cpu_bind(const char *arg, char **cpu_bind, 
-			    cpu_bind_type_t *cpu_bind_type)
+			    cpu_bind_type_t *flags)
 {
 	char *buf, *p, *tok;
-	if (!arg) {
+	int bind_bits =
+		CPU_BIND_NONE|CPU_BIND_RANK|CPU_BIND_MAP|CPU_BIND_MASK;
+	int bind_to_bits =
+		CPU_BIND_TO_SOCKETS|CPU_BIND_TO_CORES|CPU_BIND_TO_THREADS;
+
+	if (arg == NULL) {
 	    	return 0;
 	}
-	/* we support different launch policy names
-	 * we also allow a verbose setting to be specified
-	 *     --cpu_bind=threads
-	 *     --cpu_bind=cores
-	 *     --cpu_bind=sockets
-	 *     --cpu_bind=v
-	 *     --cpu_bind=rank,v
-	 *     --cpu_bind=rank
-	 *     --cpu_bind={MAP_CPU|MASK_CPU}:0,1,2,3,4
-	 */
+
     	buf = xstrdup(arg);
     	p = buf;
 	/* change all ',' delimiters not followed by a digit to ';'  */
@@ -462,50 +359,27 @@ static int _verify_cpu_bind(const char *arg, char **cpu_bind,
 	p = buf;
 	while ((tok = strsep(&p, ";"))) {
 		if (strcasecmp(tok, "help") == 0) {
-			printf(
-"CPU bind options:\n"
-"    --cpu_bind=         Bind tasks to CPUs\n"
-"        q[uiet]         quietly bind before task runs (default)\n"
-"        v[erbose]       verbosely report binding before task runs\n"
-"        no[ne]          don't bind tasks to CPUs (default)\n"
-"        rank            bind by task rank\n"
-"        map_cpu:<list>  specify a CPU ID binding for each task\n"
-"                        where <list> is <cpuid1>,<cpuid2>,...<cpuidN>\n"
-"        mask_cpu:<list> specify a CPU ID binding mask for each task\n"
-"                        where <list> is <mask1>,<mask2>,...<maskN>\n"
-"        sockets         auto-generated masks bind to sockets\n"
-"        cores           auto-generated masks bind to cores\n"
-"        threads         auto-generated masks bind to threads\n"
-"        help            show this help message\n");
+			_print_cpu_bind_help();
 			return 1;
 		} else if ((strcasecmp(tok, "q") == 0) ||
 			   (strcasecmp(tok, "quiet") == 0)) {
-		        *cpu_bind_type &= ~CPU_BIND_VERBOSE;
+		        *flags &= ~CPU_BIND_VERBOSE;
 		} else if ((strcasecmp(tok, "v") == 0) ||
 			   (strcasecmp(tok, "verbose") == 0)) {
-		        *cpu_bind_type |= CPU_BIND_VERBOSE;
+		        *flags |= CPU_BIND_VERBOSE;
 		} else if ((strcasecmp(tok, "no") == 0) ||
 			   (strcasecmp(tok, "none") == 0)) {
-			*cpu_bind_type |=  CPU_BIND_NONE;
-			*cpu_bind_type &= ~CPU_BIND_RANK;
-			*cpu_bind_type &= ~CPU_BIND_MAP;
-			*cpu_bind_type &= ~CPU_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, CPU_BIND_NONE);
 			xfree(*cpu_bind);
 		} else if (strcasecmp(tok, "rank") == 0) {
-			*cpu_bind_type &= ~CPU_BIND_NONE;
-			*cpu_bind_type |=  CPU_BIND_RANK;
-			*cpu_bind_type &= ~CPU_BIND_MAP;
-			*cpu_bind_type &= ~CPU_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, CPU_BIND_RANK);
 			xfree(*cpu_bind);
 		} else if ((strncasecmp(tok, "map_cpu", 7) == 0) ||
 		           (strncasecmp(tok, "mapcpu", 6) == 0)) {
 			char *list;
 			list = strsep(&tok, ":=");
 			list = strsep(&tok, ":=");
-			*cpu_bind_type &= ~CPU_BIND_NONE;
-			*cpu_bind_type &= ~CPU_BIND_RANK;
-			*cpu_bind_type |=  CPU_BIND_MAP;
-			*cpu_bind_type &= ~CPU_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, CPU_BIND_MAP);
 			xfree(*cpu_bind);
 			if (list && *list) {
 				*cpu_bind = xstrdup(list);
@@ -519,10 +393,7 @@ static int _verify_cpu_bind(const char *arg, char **cpu_bind,
 			char *list;
 			list = strsep(&tok, ":=");
 			list = strsep(&tok, ":=");
-			*cpu_bind_type &= ~CPU_BIND_NONE;
-			*cpu_bind_type &= ~CPU_BIND_RANK;
-			*cpu_bind_type &= ~CPU_BIND_MAP;
-			*cpu_bind_type |=  CPU_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, CPU_BIND_MASK);
 			xfree(*cpu_bind);
 			if (list && *list) {
 				*cpu_bind = xstrdup(list);
@@ -533,19 +404,16 @@ static int _verify_cpu_bind(const char *arg, char **cpu_bind,
 			}
 		} else if ((strcasecmp(tok, "socket") == 0) ||
 		           (strcasecmp(tok, "sockets") == 0)) {
-			*cpu_bind_type |=  CPU_BIND_TO_SOCKETS;
-			*cpu_bind_type &= ~CPU_BIND_TO_CORES;
-			*cpu_bind_type &= ~CPU_BIND_TO_THREADS;
+			clear_then_set((int *)flags, bind_to_bits,
+				       CPU_BIND_TO_SOCKETS);
 		} else if ((strcasecmp(tok, "core") == 0) ||
 		           (strcasecmp(tok, "cores") == 0)) {
-			*cpu_bind_type &= ~CPU_BIND_TO_SOCKETS;
-			*cpu_bind_type |=  CPU_BIND_TO_CORES;
-			*cpu_bind_type &= ~CPU_BIND_TO_THREADS;
+			clear_then_set((int *)flags, bind_to_bits,
+				       CPU_BIND_TO_CORES);
 		} else if ((strcasecmp(tok, "thread") == 0) ||
 		           (strcasecmp(tok, "threads") == 0)) {
-			*cpu_bind_type &= ~CPU_BIND_TO_SOCKETS;
-			*cpu_bind_type &= ~CPU_BIND_TO_CORES;
-			*cpu_bind_type |=  CPU_BIND_TO_THREADS;
+			clear_then_set((int *)flags, bind_to_bits,
+				       CPU_BIND_TO_THREADS);
 		} else {
 			error("unrecognized --cpu_bind argument \"%s\"", tok);
 			xfree(buf);
@@ -557,24 +425,46 @@ static int _verify_cpu_bind(const char *arg, char **cpu_bind,
 	return 0;
 }
 
+static void _print_mem_bind_help()
+{
+			printf(
+"Memory bind options:\n"
+"    --mem_bind=         Bind memory to locality domains (ldom)\n"
+"        q[uiet]         quietly bind before task runs (default)\n"
+"        v[erbose]       verbosely report binding before task runs\n"
+"        no[ne]          don't bind tasks to memory (default)\n"
+"        rank            bind by task rank\n"
+"        local           bind to memory local to processor\n"
+"        map_mem:<list>  specify a memory binding for each task\n"
+"                        where <list> is <cpuid1>,<cpuid2>,...<cpuidN>\n"
+"        mask_mem:<list> specify a memory binding mask for each tasks\n"
+"                        where <list> is <mask1>,<mask2>,...<maskN>\n"
+"        help            show this help message\n");
+}
+
 /*
  * verify mem_bind arguments
+ *
+ * we support different memory binding names
+ * we also allow a verbose setting to be specified
+ *     --mem_bind=v
+ *     --mem_bind=rank,v
+ *     --mem_bind=rank
+ *     --mem_bind={MAP_MEM|MASK_MEM}:0,1,2,3,4
+ *
  * returns -1 on error, 0 otherwise
  */
 static int _verify_mem_bind(const char *arg, char **mem_bind, 
-			    mem_bind_type_t *mem_bind_type)
+			    mem_bind_type_t *flags)
 {
 	char *buf, *p, *tok;
-	if (!arg) {
+	int bind_bits = MEM_BIND_NONE|MEM_BIND_RANK|MEM_BIND_LOCAL|
+		MEM_BIND_MAP|MEM_BIND_MASK;
+
+	if (arg == NULL) {
 	    	return 0;
 	}
-	/* we support different memory binding names
-	 * we also allow a verbose setting to be specified
-	 *     --mem_bind=v
-	 *     --mem_bind=rank,v
-	 *     --mem_bind=rank
-	 *     --mem_bind={MAP_MEM|MASK_MEM}:0,1,2,3,4
-	 */
+
     	buf = xstrdup(arg);
     	p = buf;
 	/* change all ',' delimiters not followed by a digit to ';'  */
@@ -588,59 +478,31 @@ static int _verify_mem_bind(const char *arg, char **mem_bind,
 	p = buf;
 	while ((tok = strsep(&p, ";"))) {
 		if (strcasecmp(tok, "help") == 0) {
-			printf(
-"Memory bind options:\n"
-"    --mem_bind=         Bind memory to locality domains (ldom)\n"
-"        q[uiet]         quietly bind before task runs (default)\n"
-"        v[erbose]       verbosely report binding before task runs\n"
-"        no[ne]          don't bind tasks to memory (default)\n"
-"        rank            bind by task rank\n"
-"        local           bind to memory local to processor\n"
-"        map_mem:<list>  specify a memory binding for each task\n"
-"                        where <list> is <cpuid1>,<cpuid2>,...<cpuidN>\n"
-"        mask_mem:<list> specify a memory binding mask for each tasks\n"
-"                        where <list> is <mask1>,<mask2>,...<maskN>\n"
-"        help            show this help message\n");
+			_print_mem_bind_help();
 			return 1;
 			
 		} else if ((strcasecmp(tok, "q") == 0) ||
 			   (strcasecmp(tok, "quiet") == 0)) {
-		        *mem_bind_type &= ~MEM_BIND_VERBOSE;
+		        *flags &= ~MEM_BIND_VERBOSE;
 		} else if ((strcasecmp(tok, "v") == 0) ||
 			   (strcasecmp(tok, "verbose") == 0)) {
-		        *mem_bind_type |= MEM_BIND_VERBOSE;
+		        *flags |= MEM_BIND_VERBOSE;
 		} else if ((strcasecmp(tok, "no") == 0) ||
 			   (strcasecmp(tok, "none") == 0)) {
-			*mem_bind_type |=  MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, MEM_BIND_NONE);
 			xfree(*mem_bind);
 		} else if (strcasecmp(tok, "rank") == 0) {
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type |=  MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, MEM_BIND_RANK);
 			xfree(*mem_bind);
 		} else if (strcasecmp(tok, "local") == 0) {
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type |=  MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, MEM_BIND_LOCAL);
 			xfree(*mem_bind);
 		} else if ((strncasecmp(tok, "map_mem", 7) == 0) ||
 		           (strncasecmp(tok, "mapmem", 6) == 0)) {
 			char *list;
 			list = strsep(&tok, ":=");
 			list = strsep(&tok, ":=");
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type |=  MEM_BIND_MAP;
-			*mem_bind_type &= ~MEM_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, MEM_BIND_MAP);
 			xfree(*mem_bind);
 			if (list && *list) {
 				*mem_bind = xstrdup(list);
@@ -654,11 +516,7 @@ static int _verify_mem_bind(const char *arg, char **mem_bind,
 			char *list;
 			list = strsep(&tok, ":=");
 			list = strsep(&tok, ":=");
-			*mem_bind_type &= ~MEM_BIND_NONE;
-			*mem_bind_type &= ~MEM_BIND_RANK;
-			*mem_bind_type &= ~MEM_BIND_LOCAL;
-			*mem_bind_type &= ~MEM_BIND_MAP;
-			*mem_bind_type |=  MEM_BIND_MASK;
+			clear_then_set((int *)flags, bind_bits, MEM_BIND_MASK);
 			xfree(*mem_bind);
 			if (list && *list) {
 				*mem_bind = xstrdup(list);
@@ -678,203 +536,6 @@ static int _verify_mem_bind(const char *arg, char **mem_bind,
 	return 0;
 }
 
-/* 
- * verify that a resource counts in arg are of a known form X, X:X, X:X:X, or 
- * X:X:X:X, where X is defined as either (count, min-max, or '*')
- * RET true if valid
- */
-static bool
-_verify_socket_core_thread_count(const char *arg, 
-			      int *min_sockets, int *max_sockets,
-			      int *min_cores, int *max_cores,
-			      int *min_threads, int  *max_threads,
-			      cpu_bind_type_t *cpu_bind_type)
-{
-	bool tmp_val,ret_val;
-	int i,j;
-	const char *cur_ptr = arg;
-	char buf[3][48]; /* each can hold INT64_MAX - INT64_MAX */
-	buf[0][0] = '\0';
-	buf[1][0] = '\0';
-	buf[2][0] = '\0';
-
- 	for (j=0;j<3;j++) {	
-		for (i=0;i<47;i++) {
-			if (*cur_ptr == '\0' || *cur_ptr ==':') break;
-			buf[j][i] = *cur_ptr++;
-		}
-		if (*cur_ptr == '\0') break;
-		xassert(*cur_ptr == ':');
-		buf[j][i] = '\0';
-		cur_ptr++;
-	}
-	/* if cpu_bind_type doesn't already have a auto preference, choose
-	 * the level based on the level of the -E specification
-	 */
-	if (!(*cpu_bind_type & (CPU_BIND_TO_SOCKETS |
-				CPU_BIND_TO_CORES |
-				CPU_BIND_TO_THREADS))) {
-		if (j == 0) {
-			*cpu_bind_type |= CPU_BIND_TO_SOCKETS;
-		} else if (j == 1) {
-			*cpu_bind_type |= CPU_BIND_TO_CORES;
-		} else if (j == 2) {
-			*cpu_bind_type |= CPU_BIND_TO_THREADS;
-		}
-        }
-	buf[j][i] = '\0';
-
-	ret_val = true;
-	tmp_val = _get_resource_range(&buf[0][0], "first arg of -B", 
-				      min_sockets, max_sockets, true);
-	ret_val = ret_val && tmp_val;
-	tmp_val = _get_resource_range(&buf[1][0], "second arg of -B", 
-				      min_cores, max_cores, true);
-	ret_val = ret_val && tmp_val;
-	tmp_val = _get_resource_range(&buf[2][0], "third arg of -B", 
-				      min_threads, max_threads, true);
-	ret_val = ret_val && tmp_val;
-
-	return ret_val;
-}
-
-/* 
- * verify that a hint is valid and convert it into the implied settings
- * RET true if valid
- */
-static bool
-_verify_hint(const char *arg, 
-			      int *min_sockets, int *max_sockets,
-			      int *min_cores, int *max_cores,
-			      int *min_threads, int  *max_threads,
-			      cpu_bind_type_t *cpu_bind_type)
-{
-	char *buf, *p, *tok;
-	if (!arg) {
-		return true;
-	}
-
-	buf = xstrdup(arg);
-	p = buf;
-	/* change all ',' delimiters not followed by a digit to ';'  */
-	/* simplifies parsing tokens while keeping map/mask together */
-	while (p[0] != '\0') {
-		if ((p[0] == ',') && (!isdigit(p[1])))
-			p[0] = ';';
-		p++;
-	}
-
-	p = buf;
-	while ((tok = strsep(&p, ";"))) {
-		if (strcasecmp(tok, "help") == 0) {
-			printf(
-"Application hint options:\n"
-"    --hint=             Bind tasks according to application hints\n"
-"        compute_bound   use all cores in each physical CPU\n"
-"        memory_bound    use only one core in each physical CPU\n"
-"        [no]multithread [don't] use extra threads with in-core multi-threading\n"
-"        help            show this help message\n");
-			return 1;
-		} else if (strcasecmp(tok, "compute_bound") == 0) {
-		        *min_sockets = 1;
-		        *max_sockets = INT_MAX;
-		        *min_cores   = 1;
-		        *max_cores   = INT_MAX;
-			*cpu_bind_type |= CPU_BIND_TO_CORES;
-		} else if (strcasecmp(tok, "memory_bound") == 0) {
-		        *min_cores = 1;
-		        *max_cores = 1;
-			*cpu_bind_type |= CPU_BIND_TO_CORES;
-		} else if (strcasecmp(tok, "multithread") == 0) {
-		        *min_threads = 1;
-		        *max_threads = INT_MAX;
-			*cpu_bind_type |= CPU_BIND_TO_THREADS;
-		} else if (strcasecmp(tok, "nomultithread") == 0) {
-		        *min_threads = 1;
-		        *max_threads = 1;
-			*cpu_bind_type |= CPU_BIND_TO_THREADS;
-		} else {
-			error("unrecognized --hint argument \"%s\", see --hint=help", tok);
-			xfree(buf);
-			return 1;
-		}
-	}
-
-	xfree(buf);
-	return 0;
-}
-
-/* return command name from its full path name */
-static char * _base_name(char* command)
-{
-	char *char_ptr, *name;
-	int i;
-
-	if (command == NULL)
-		return NULL;
-
-	char_ptr = strrchr(command, (int)'/');
-	if (char_ptr == NULL)
-		char_ptr = command;
-	else
-		char_ptr++;
-
-	i = strlen(char_ptr);
-	name = xmalloc(i+1);
-	strcpy(name, char_ptr);
-	return name;
-}
-
-/*
- * _to_bytes(): verify that arg is numeric with optional "G" or "M" at end
- * if "G" or "M" is there, multiply by proper power of 2 and return
- * number in bytes
- */
-static long _to_bytes(const char *arg)
-{
-	char *buf;
-	char *endptr;
-	int end;
-	int multiplier = 1;
-	long result;
-
-	buf = xstrdup(arg);
-
-	end = strlen(buf) - 1;
-
-	if (isdigit(buf[end])) {
-		result = strtol(buf, &endptr, 10);
-
-		if (*endptr != '\0')
-			result = -result;
-
-	} else {
-
-		switch (toupper(buf[end])) {
-
-		case 'G':
-			multiplier = 1024;
-			break;
-
-		case 'M':
-			/* do nothing */
-			break;
-
-		default:
-			multiplier = -1;
-		}
-
-		buf[end] = '\0';
-
-		result = multiplier * strtol(buf, &endptr, 10);
-
-		if (*endptr != '\0')
-			result = -result;
-	}
-
-	return result;
-}
-
 /*
  * print error message to stderr with opt.progname prepended
  */
@@ -943,6 +604,9 @@ static void _opt_default()
 	opt.mem_bind = NULL;
 	opt.time_limit = NO_VAL;
 	opt.time_limit_str = NULL;
+	opt.ckpt_interval = 0;
+	opt.ckpt_interval_str = NULL;
+	opt.ckpt_path = NULL;
 	opt.partition = NULL;
 	opt.max_threads = MAX_THREADS;
 	pmi_server_max_threads(opt.max_threads);
@@ -953,7 +617,7 @@ static void _opt_default()
 	opt.job_name_set = false;
 	opt.jobid    = NO_VAL;
 	opt.jobid_set = false;
-	opt.dependency = NO_VAL;
+	opt.dependency = NULL;
 	opt.account  = NULL;
 	opt.comment  = NULL;
 
@@ -969,17 +633,13 @@ static void _opt_default()
 	opt.labelio = false;
 	opt.unbuffered = false;
 	opt.overcommit = false;
-	opt.batch = false;
 	opt.shared = (uint16_t)NO_VAL;
+	opt.exclusive = false;
 	opt.no_kill = false;
 	opt.kill_bad_exit = false;
 
 	opt.immediate	= false;
-	opt.no_requeue	= false;
 
-	opt.allocate	= false;
-	opt.noshell	= false;
-	opt.attach	= NULL;
 	opt.join	= false;
 	opt.max_wait	= slurm_get_wait_time();
 
@@ -996,7 +656,7 @@ static void _opt_default()
 	opt.job_min_cores   = NO_VAL;
 	opt.job_min_threads = NO_VAL;
 	opt.job_min_memory  = NO_VAL;
-	opt.job_max_memory  = NO_VAL;
+	opt.task_mem        = NO_VAL;
 	opt.job_min_tmp_disk= NO_VAL;
 
 	opt.hold	    = false;
@@ -1030,8 +690,6 @@ static void _opt_default()
 	opt.task_prolog     = NULL;
 	opt.task_epilog     = NULL;
 
-	mode	= MODE_NORMAL;
-
 	gethostname_short(hostname, sizeof(hostname));
 	opt.ctrl_comm_ifhn  = xstrdup(hostname);
 
@@ -1045,8 +703,9 @@ static void _opt_default()
 		opt.msg_timeout     = 15;
 	}
 	
-	opt.get_user_env_time = -1;
-	opt.get_user_env_mode = -1;
+	opt.pty = false;
+	opt.open_mode = 0;
+	opt.acctg_freq = -1;
 }
 
 /*---[ env var processing ]-----------------------------------------------*/
@@ -1076,7 +735,7 @@ env_vars_t env_vars[] = {
 {"SLURM_CORE_FORMAT",   OPT_CORE,       NULL,               NULL             },
 {"SLURM_CPU_BIND",      OPT_CPU_BIND,   NULL,               NULL             },
 {"SLURM_MEM_BIND",      OPT_MEM_BIND,   NULL,               NULL             },
-{"SLURM_DEPENDENCY",    OPT_INT,        &opt.dependency,    NULL             },
+{"SLURM_DEPENDENCY",    OPT_STRING,     &opt.dependency,    NULL             },
 {"SLURM_DISTRIBUTION",  OPT_DISTRIB,    NULL,               NULL             },
 {"SLURM_GEOMETRY",      OPT_GEOMETRY,   NULL,               NULL             },
 {"SLURM_IMMEDIATE",     OPT_INT,        &opt.immediate,     NULL             },
@@ -1090,7 +749,6 @@ env_vars_t env_vars[] = {
 {"SLURM_NSOCKETS_PER_NODE",OPT_NSOCKETS,NULL,               NULL             },
 {"SLURM_NCORES_PER_SOCKET",OPT_NCORES,  NULL,               NULL             },
 {"SLURM_NTHREADS_PER_CORE",OPT_NTHREADS,NULL,               NULL             },
-{"SLURM_NO_REQUEUE",    OPT_INT,        &opt.no_requeue,    NULL             },
 {"SLURM_NO_ROTATE",     OPT_NO_ROTATE,  NULL,               NULL             },
 {"SLURM_NPROCS",        OPT_INT,        &opt.nprocs,        &opt.nprocs_set  },
 {"SLURM_OVERCOMMIT",    OPT_OVERCOMMIT, NULL,               NULL             },
@@ -1102,6 +760,8 @@ env_vars_t env_vars[] = {
 {"SLURM_STDOUTMODE",    OPT_STRING,     &opt.ofname,        NULL             },
 {"SLURM_THREADS",       OPT_INT,        &opt.max_threads,   NULL             },
 {"SLURM_TIMELIMIT",     OPT_STRING,     &opt.time_limit_str,NULL             },
+{"SLURM_CHECKPOINT",    OPT_STRING,     &opt.ckpt_interval_str, NULL         },
+{"SLURM_CHECKPOINT_PATH",OPT_STRING,    &opt.ckpt_path,     NULL             },
 {"SLURM_WAIT",          OPT_INT,        &opt.max_wait,      NULL             },
 {"SLURM_DISABLE_STATUS",OPT_INT,        &opt.disable_status,NULL             },
 {"SLURM_MPI_TYPE",      OPT_MPI,        NULL,               NULL             },
@@ -1115,6 +775,9 @@ env_vars_t env_vars[] = {
 {"SLURM_TASK_EPILOG",   OPT_STRING,     &opt.task_epilog,   NULL             },
 {"SLURM_WORKING_DIR",   OPT_STRING,     &opt.cwd,           &opt.cwd_set     },
 {"SLURM_EXCLUSIVE",     OPT_EXCLUSIVE,  NULL,               NULL             },
+{"SLURM_OPEN_MODE",     OPT_OPEN_MODE,  NULL,               NULL             },
+{"SLURM_ACCTG_FREQ",    OPT_INT,        &opt.acctg_freq,    NULL             },
+{"SLURM_TASK_MEM",      OPT_INT,        &opt.task_mem,      NULL             },
 {NULL, 0, NULL, NULL}
 };
 
@@ -1164,7 +827,7 @@ _process_env_var(env_vars_t *e, const char *val)
 	case OPT_DISTRIB:
 		if (strcmp(val, "unknown") == 0)
 			break;	/* ignore it, passed from salloc */
-		dt = _verify_dist_type(val, &opt.plane_size);
+		dt = verify_dist_type(val, &opt.plane_size);
 		if (dt == SLURM_DIST_UNKNOWN) {
 			error("\"%s=%s\" -- invalid distribution type. " 
 			      "ignoring...", e->var, val);
@@ -1185,9 +848,9 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_NODES:
-		opt.nodes_set = _get_resource_range( val ,"OPT_NODES", 
-						     &opt.min_nodes, 
-						     &opt.max_nodes, false);
+		opt.nodes_set = get_resource_arg_range( val ,"OPT_NODES", 
+							&opt.min_nodes, 
+							&opt.max_nodes, false);
 		if (opt.nodes_set == false) {
 			error("\"%s=%s\" -- invalid node count. ignoring...",
 			      e->var, val);
@@ -1199,15 +862,25 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_EXCLUSIVE:
+		opt.exclusive = true;
 		opt.shared = 0;
 		break;
 
+	case OPT_OPEN_MODE:
+		if ((val[0] == 'a') || (val[0] == 'A'))
+			opt.open_mode = OPEN_MODE_APPEND;
+		else if ((val[0] == 't') || (val[0] == 'T'))
+			opt.open_mode = OPEN_MODE_TRUNCATE;
+		else
+			error("Invalid SLURM_OPEN_MODE: %s. Ignored", val);
+		break;
+
 	case OPT_CORE:
 		opt.core_type = core_format_type (val);
 		break;
 	    
 	case OPT_CONN_TYPE:
-		opt.conn_type = _verify_conn_type(val);
+		opt.conn_type = verify_conn_type(val);
 		break;
 
 	case OPT_NO_ROTATE:
@@ -1215,7 +888,7 @@ _process_env_var(env_vars_t *e, const char *val)
 		break;
 
 	case OPT_GEOMETRY:
-		if (_verify_geometry(val, opt.geometry)) {
+		if (verify_geometry(val, opt.geometry)) {
 			error("\"%s=%s\" -- invalid geometry, ignoring...",
 			      e->var, val);
 		}
@@ -1260,76 +933,12 @@ _get_int(const char *arg, const char *what, bool positive)
 	return (int) result;
 }
 
-/* 
- * get either 1 or 2 integers for a resource count in the form of either
- * (count, min-max, or '*')
- * A partial error message is passed in via the 'what' param.
- * RET true if valid
- */
-static bool
-_get_resource_range(const char *arg, const char *what, int* min, int *max, 
-              	    bool isFatal)
-{
-	char *p;
-	long int result;
-
-	if (*arg == '\0') return true;
-
-	/* wildcard meaning every possible value in range */
-	if (*arg == '*' ) {
-		*min = 1;
-		*max = INT_MAX;
-		return true;
-	}
-
-	result = strtol(arg, &p, 10);
-        if (*p == 'k' || *p == 'K') {
-		result *= 1024;
-		p++;
-	}
-
-	if (((*p != '\0')&&(*p != '-')) || (result <= 0L)) {
-		error ("Invalid numeric value \"%s\" for %s.", arg, what);
-		if (isFatal) exit(1);
-		return false;
-	} else if (result > INT_MAX) {
-		error ("Numeric argument (%ld) to big for %s.", result, what);
-		if (isFatal) exit(1);
-		return false;
-	}
-
-	*min = (int) result;
-
-	if (*p == '\0') return true;
-	if (*p == '-') p++;
-
-	result = strtol(p, &p, 10);
-        if (*p == 'k' || *p == 'K') {
-		result *= 1024;
-		p++;
-	}
-	
-	if (((*p != '\0')&&(*p != '-')) || (result <= 0L)) {
-		error ("Invalid numeric value \"%s\" for %s.", arg, what);
-		if (isFatal) exit(1);
-		return false;
-	} else if (result > INT_MAX) {
-		error ("Numeric argument (%ld) to big for %s.", result, what);
-		if (isFatal) exit(1);
-		return false;
-	}
-
-	*max = (int) result;
-
-	return true;
-}
-
-void set_options(const int argc, char **argv, int first)
+static void set_options(const int argc, char **argv)
 {
 	int opt_char, option_index = 0;
 	struct utsname name;
 	static struct option long_options[] = {
-		{"attach",        required_argument, 0, 'a'},
+		{"attach",        no_argument,       0, 'a'},
 		{"allocate",      no_argument,       0, 'A'},
 		{"batch",         no_argument,       0, 'b'},
 		{"extra-node-info", required_argument, 0, 'B'},
@@ -1347,6 +956,7 @@ void set_options(const int argc, char **argv, int first)
 		{"no-kill",       no_argument,       0, 'k'},
 		{"kill-on-bad-exit", no_argument,    0, 'K'},
 		{"label",         no_argument,       0, 'l'},
+		{"licenses",      required_argument, 0, 'L'},
 		{"distribution",  required_argument, 0, 'm'},
 		{"ntasks",        required_argument, 0, 'n'},
 		{"nodes",         required_argument, 0, 'N'},
@@ -1380,10 +990,10 @@ void set_options(const int argc, char **argv, int first)
 		{"mincores",         required_argument, 0, LONG_OPT_MINCORES},
 		{"minthreads",       required_argument, 0, LONG_OPT_MINTHREADS},
 		{"mem",              required_argument, 0, LONG_OPT_MEM},
-		{"job-mem",          required_argument, 0, LONG_OPT_JOBMEM},
+		{"job-mem",          required_argument, 0, LONG_OPT_TASK_MEM},
+		{"task-mem",         required_argument, 0, LONG_OPT_TASK_MEM},
 		{"hint",             required_argument, 0, LONG_OPT_HINT},
 		{"mpi",              required_argument, 0, LONG_OPT_MPI},
-		{"no-shell",         no_argument,       0, LONG_OPT_NOSHELL},
 		{"tmp",              required_argument, 0, LONG_OPT_TMP},
 		{"jobid",            required_argument, 0, LONG_OPT_JOBID},
 		{"msg-timeout",      required_argument, 0, LONG_OPT_TIMEO},
@@ -1408,8 +1018,6 @@ void set_options(const int argc, char **argv, int first)
 		{"nice",             optional_argument, 0, LONG_OPT_NICE},
 		{"ctrl-comm-ifhn",   required_argument, 0, LONG_OPT_CTRL_COMM_IFHN},
 		{"multi-prog",       no_argument,       0, LONG_OPT_MULTI},
-		{"no-requeue",       no_argument,       0, LONG_OPT_NO_REQUEUE},
-		{"requeue",          no_argument,       0, LONG_OPT_REQUEUE},
 		{"comment",          required_argument, 0, LONG_OPT_COMMENT},
 		{"sockets-per-node", required_argument, 0, LONG_OPT_SOCKETSPERNODE},
 		{"cores-per-socket", required_argument, 0, LONG_OPT_CORESPERSOCKET},
@@ -1417,15 +1025,21 @@ void set_options(const int argc, char **argv, int first)
 		{"ntasks-per-node",  required_argument, 0, LONG_OPT_NTASKSPERNODE},
 		{"ntasks-per-socket",required_argument, 0, LONG_OPT_NTASKSPERSOCKET},
 		{"ntasks-per-core",  required_argument, 0, LONG_OPT_NTASKSPERCORE},
+		{"tasks-per-node",   required_argument, 0, LONG_OPT_NTASKSPERNODE},
 		{"blrts-image",      required_argument, 0, LONG_OPT_BLRTS_IMAGE},
 		{"linux-image",      required_argument, 0, LONG_OPT_LINUX_IMAGE},
 		{"mloader-image",    required_argument, 0, LONG_OPT_MLOADER_IMAGE},
 		{"ramdisk-image",    required_argument, 0, LONG_OPT_RAMDISK_IMAGE},
 		{"reboot",           no_argument,       0, LONG_OPT_REBOOT},            
 		{"get-user-env",     optional_argument, 0, LONG_OPT_GET_USER_ENV},
+		{"pty",              no_argument,       0, LONG_OPT_PTY},
+		{"checkpoint",       required_argument, 0, LONG_OPT_CHECKPOINT},
+		{"checkpoint-path",  required_argument, 0, LONG_OPT_CHECKPOINT_PATH},
+		{"open-mode",        required_argument, 0, LONG_OPT_OPEN_MODE},
+		{"acctg-freq",       required_argument, 0, LONG_OPT_ACCTG_FREQ},
 		{NULL,               0,                 0, 0}
 	};
-	char *opt_string = "+a:AbB:c:C:d:D:e:g:Hi:IjJ:kKlm:n:N:"
+	char *opt_string = "+aAbB:c:C:d:D:e:g:Hi:IjJ:kKlL:m:n:N:"
 		"o:Op:P:qQr:R:st:T:uU:vVw:W:x:XZ";
 
 	struct option *optz = spank_option_table_create (long_options);
@@ -1437,69 +1051,32 @@ void set_options(const int argc, char **argv, int first)
 
 	if(opt.progname == NULL)
 		opt.progname = xbasename(argv[0]);
-	else if(!first)
-		argv[0] = opt.progname;
 	else
-		error("opt.progname is set but it is the first time through.");
+		error("opt.progname is already set.");
 	optind = 0;		
 	while((opt_char = getopt_long(argc, argv, opt_string,
 				      optz, &option_index)) != -1) {
 		switch (opt_char) {
 
 		case (int)'?':
-			if(first) {
-				fprintf(stderr, "Try \"srun --help\" for more "
-					"information\n");
-				exit(1);
-			} 
+			fprintf(stderr,
+				"Try \"srun --help\" for more information\n");
+			exit(1);
 			break;
 		case (int)'a':
-			if(first) {
-				if (opt.allocate || opt.batch) {
-					error("can only specify one mode: "
-					      "allocate, attach or batch.");
-					exit(1);
-				}
-				mode = MODE_ATTACH;
-				opt.attach = strdup(optarg);
-			} else {
-				error("Option '%c' can only be set "
-				      "from srun commandline.", opt_char);
-			}
-			break;
+			error("Please use the \"sattach\" command instead of "
+			      "\"srun -a/--attach\".");
+			exit(1);
 		case (int)'A':
-			if(first) {
-				if (opt.attach || opt.batch) {
-					error("can only specify one mode: "
-					      "allocate, attach or batch.");
-					exit(1);
-				}
-				mode = MODE_ALLOCATE;
-				opt.allocate = true;
-			} else {
-				error("Option '%c' can only be set "
-				      "from srun commandline.", opt_char);
-			}
-			break;
+			error("Please use the \"salloc\" command instead of "
+			      "\"srun -A/--allocate\".");
+			exit(1);
 		case (int)'b':
-			if(first) {
-				if (opt.allocate || opt.attach) {
-					error("can only specify one mode: "
-					      "allocate, attach or batch.");
-					exit(1);
-				}
-				mode = MODE_BATCH;
-				opt.batch = true;
-			} else {
-				error("Option '%c' can only be set "
-				      "from srun commandline.", opt_char);
-			}
-			break;
+			error("Please use the \"sbatch\" command instead of "
+			      "\"srun -b/--batch\".");
+			exit(1);
 		case (int)'B':
-			if(!first && opt.extra_set)
-				break;
-
-			opt.extra_set = _verify_socket_core_thread_count(
+			opt.extra_set = verify_socket_core_thread_count(
 				optarg,
 				&opt.min_sockets_per_node,
 				&opt.max_sockets_per_node,
@@ -1517,37 +1094,26 @@ void set_options(const int argc, char **argv, int first)
 			}
 			break;
 		case (int)'c':
-			if(!first && opt.cpus_set)
-				break;
 			opt.cpus_set = true;
 			opt.cpus_per_task = 
 				_get_int(optarg, "cpus-per-task", true);
 			break;
 		case (int)'C':
-			if(!first && opt.constraints)
-				break;
 			xfree(opt.constraints);
 			opt.constraints = xstrdup(optarg);
 			break;
 		case (int)'d':
-			if(!first && opt.slurmd_debug)
-				break;
-			
 			opt.slurmd_debug = 
 				_get_int(optarg, "slurmd-debug", false);
 			break;
 		case (int)'D':
-			if(!first && opt.cwd_set)
-				break;
-
 			opt.cwd_set = true;
 			xfree(opt.cwd);
 			opt.cwd = xstrdup(optarg);
 			break;
 		case (int)'e':
-			if(!first && opt.efname)
-				break;
-			
+			if (opt.pty)
+				fatal("--error incompatable with --pty option");
 			xfree(opt.efname);
 			if (strncasecmp(optarg, "none", (size_t) 4) == 0)
 				opt.efname = xstrdup("/dev/null");
@@ -1555,18 +1121,15 @@ void set_options(const int argc, char **argv, int first)
 				opt.efname = xstrdup(optarg);
 			break;
 		case (int)'g':
-			if(!first && opt.geometry)
-				break;
-			if (_verify_geometry(optarg, opt.geometry))
+			if (verify_geometry(optarg, opt.geometry))
 				exit(1);
 			break;
 		case (int)'H':
 			opt.hold = true;
 			break;
 		case (int)'i':
-			if(!first && opt.ifname)
-				break;
-			
+			if (opt.pty)
+				fatal("--input incompatable with --pty option");
 			xfree(opt.ifname);
 			if (strncasecmp(optarg, "none", (size_t) 4) == 0)
 				opt.ifname = xstrdup("/dev/null");
@@ -1580,9 +1143,6 @@ void set_options(const int argc, char **argv, int first)
 			opt.join = true;
 			break;
 		case (int)'J':
-			if(!first && opt.job_name_set)
-				break;
-
 			opt.job_name_set = true;
 			xfree(opt.job_name);
 			opt.job_name = xstrdup(optarg);
@@ -1596,10 +1156,12 @@ void set_options(const int argc, char **argv, int first)
 		case (int)'l':
 			opt.labelio = true;
 			break;
+		case 'L':
+			xfree(opt.licenses);
+			opt.licenses = xstrdup(optarg);
+			break;
 		case (int)'m':
-			if(!first && opt.distribution)
-				break;
-			opt.distribution = _verify_dist_type(optarg, 
+			opt.distribution = verify_dist_type(optarg, 
 							     &opt.plane_size);
 			if (opt.distribution == SLURM_DIST_UNKNOWN) {
 				error("distribution type `%s' " 
@@ -1608,22 +1170,16 @@ void set_options(const int argc, char **argv, int first)
 			}
 			break;
 		case (int)'n':
-			if(!first && opt.nprocs_set)
-				break;
-						
 			opt.nprocs_set = true;
 			opt.nprocs = 
 				_get_int(optarg, "number of tasks", true);
 			break;
 		case (int)'N':
-			if(!first && opt.nodes_set)
-				break;
-						
 			opt.nodes_set = 
-				_get_resource_range(optarg, 
-						    "requested node count",
-						    &opt.min_nodes,
-						    &opt.max_nodes, true);
+				get_resource_arg_range( optarg, 
+							"requested node count",
+							&opt.min_nodes,
+							&opt.max_nodes, true );
 			
 			if (opt.nodes_set == false) {
 				error("invalid resource allocation -N `%s'", 
@@ -1632,9 +1188,8 @@ void set_options(const int argc, char **argv, int first)
 			}
 			break;
 		case (int)'o':
-			if(!first && opt.ofname)
-				break;			
-			
+			if (opt.pty)
+				fatal("--output incompatable with --pty option");
 			xfree(opt.ofname);
 			if (strncasecmp(optarg, "none", (size_t) 4) == 0)
 				opt.ofname = xstrdup("/dev/null");
@@ -1645,32 +1200,20 @@ void set_options(const int argc, char **argv, int first)
 			opt.overcommit = true;
 			break;
 		case (int)'p':
-			if(!first && opt.partition)
-				break;
-						
 			xfree(opt.partition);
 			opt.partition = xstrdup(optarg);
 			break;
 		case (int)'P':
-			if(!first && opt.dependency)
-				break;
-						
-			opt.dependency = _get_int(optarg, "dependency", true);
+			xfree(opt.dependency);
+			opt.dependency = xstrdup(optarg);
 			break;
 		case (int)'q':
 			opt.quit_on_intr = true;
 			break;
 		case (int) 'Q':
-			if(!first && opt.quiet)
-				break;
-			
 			opt.quiet++;
 			break;
 		case (int)'r':
-			if(!first && opt.relative)
-				break;
-			
-			//xfree(opt.relative);
 			opt.relative = _get_int(optarg, "relative", false);
 			opt.relative_set = true;
 			break;
@@ -1681,16 +1224,10 @@ void set_options(const int argc, char **argv, int first)
 			opt.shared = 1;
 			break;
 		case (int)'t':
-			if(!first && opt.time_limit_str)
-				break;
-
 			xfree(opt.time_limit_str);
 			opt.time_limit_str = xstrdup(optarg);
 			break;
 		case (int)'T':
-			if(!first && opt.max_threads)
-				break;
-			
 			opt.max_threads = 
 				_get_int(optarg, "max_threads", true);
 			pmi_server_max_threads(opt.max_threads);
@@ -1699,36 +1236,19 @@ void set_options(const int argc, char **argv, int first)
 			opt.unbuffered = true;
 			break;
 		case (int)'U':
-			if(!first && opt.account)
-				break;
 			xfree(opt.account);
 			opt.account = xstrdup(optarg);
 			break;
 		case (int)'v':
-			if(!first && _verbose)
-				break;
-			
 			_verbose++;
 			break;
 		case (int)'V':
-			_print_version();
+			print_slurm_version();
 			exit(0);
 			break;
 		case (int)'w':
-			if(!first && opt.nodelist)
-				break;
-			
 			xfree(opt.nodelist);
 			opt.nodelist = xstrdup(optarg);
-#ifdef HAVE_BG
-			info("\tThe nodelist option should only be used if\n"
-			     "\tthe block you are asking for can be created.\n"
-			     "\tIt should also include all the midplanes you\n"
-			     "\twant to use, partial lists may not\n"
-			     "\twork correctly.\n"
-			     "\tPlease consult smap before using this option\n"
-			     "\tor your job may be stuck with no way to run.");
-#endif
 			break;
 		case (int)'W':
 			opt.max_wait = _get_int(optarg, "wait", false);
@@ -1752,6 +1272,7 @@ void set_options(const int argc, char **argv, int first)
 			opt.contiguous = true;
 			break;
                 case LONG_OPT_EXCLUSIVE:
+			opt.exclusive = true;
                         opt.shared = 0;
                         break;
                 case LONG_OPT_CPU_BIND:
@@ -1785,16 +1306,16 @@ void set_options(const int argc, char **argv, int first)
 				true);
 			break;
 		case LONG_OPT_MEM:
-			opt.job_min_memory = (int) _to_bytes(optarg);
+			opt.job_min_memory = (int) str_to_bytes(optarg);
 			if (opt.job_min_memory < 0) {
 				error("invalid memory constraint %s", 
 				      optarg);
 				exit(1);
 			}
 			break;
-		case LONG_OPT_JOBMEM:
-			opt.job_max_memory = (int) _to_bytes(optarg);
-			if (opt.job_max_memory < 0) {
+		case LONG_OPT_TASK_MEM:
+			opt.task_mem = (int) str_to_bytes(optarg);
+			if (opt.task_mem < 0) {
 				error("invalid memory constraint %s", 
 				      optarg);
 				exit(1);
@@ -1808,11 +1329,8 @@ void set_options(const int argc, char **argv, int first)
 				      optarg);
 			}
 			break;
-		case LONG_OPT_NOSHELL:
-			opt.noshell = true;
-			break;
 		case LONG_OPT_TMP:
-			opt.job_min_tmp_disk = _to_bytes(optarg);
+			opt.job_min_tmp_disk = str_to_bytes(optarg);
 			if (opt.job_min_tmp_disk < 0) {
 				error("invalid tmp value %s", optarg);
 				exit(1);
@@ -1862,7 +1380,7 @@ void set_options(const int argc, char **argv, int first)
 			_usage();
 			exit(0);
 		case LONG_OPT_CONNTYPE:
-			opt.conn_type = _verify_conn_type(optarg);
+			opt.conn_type = verify_conn_type(optarg);
 			break;
 		case LONG_OPT_TEST_ONLY:
 			opt.test_only = true;
@@ -1897,7 +1415,7 @@ void set_options(const int argc, char **argv, int first)
 			}
 			break;
 		case LONG_OPT_MAIL_TYPE:
-			opt.mail_type |= _parse_mail_type(optarg);
+			opt.mail_type |= parse_mail_type(optarg);
 			if (opt.mail_type == 0)
 				fatal("--mail-type=%s invalid", optarg);
 			break;
@@ -1940,35 +1458,30 @@ void set_options(const int argc, char **argv, int first)
 		case LONG_OPT_MULTI:
 			opt.multi_prog = true;
 			break;
-		case LONG_OPT_NO_REQUEUE:
-			opt.no_requeue = true;
-			break;
-		case LONG_OPT_REQUEUE:
-			opt.no_requeue = false;	/* the default */
-			break;
 		case LONG_OPT_COMMENT:
-			if(!first && opt.comment)
-				break;
 			xfree(opt.comment);
 			opt.comment = xstrdup(optarg);
 			break;
 		case LONG_OPT_SOCKETSPERNODE:
-			_get_resource_range( optarg, "sockets-per-node",
-				             &opt.min_sockets_per_node,
-				             &opt.max_sockets_per_node, true );
+			get_resource_arg_range( optarg, "sockets-per-node",
+						&opt.min_sockets_per_node,
+						&opt.max_sockets_per_node,
+						true );
 			break;
 		case LONG_OPT_CORESPERSOCKET:
-			_get_resource_range( optarg, "cores-per-socket",
-				             &opt.min_cores_per_socket,
-				             &opt.max_cores_per_socket, true);
+			get_resource_arg_range( optarg, "cores-per-socket",
+						&opt.min_cores_per_socket,
+						&opt.max_cores_per_socket,
+						true);
 			break;
 		case LONG_OPT_THREADSPERCORE:
-			_get_resource_range( optarg, "threads-per-core",
-				             &opt.min_threads_per_core,
-				             &opt.max_threads_per_core, true );
+			get_resource_arg_range( optarg, "threads-per-core",
+						&opt.min_threads_per_core,
+						&opt.max_threads_per_core,
+						true );
 			break;
 		case LONG_OPT_HINT:
-			if (_verify_hint(optarg,
+			if (verify_hint(optarg,
 				&opt.min_sockets_per_node,
 				&opt.max_sockets_per_node,
 				&opt.min_cores_per_socket,
@@ -1992,26 +1505,18 @@ void set_options(const int argc, char **argv, int first)
 				true);
 			break;
 		case LONG_OPT_BLRTS_IMAGE:
-			if(!first && opt.blrtsimage)
-				break;			
 			xfree(opt.blrtsimage);
 			opt.blrtsimage = xstrdup(optarg);
 			break;
 		case LONG_OPT_LINUX_IMAGE:
-			if(!first && opt.linuximage)
-				break;			
 			xfree(opt.linuximage);
 			opt.linuximage = xstrdup(optarg);
 			break;
 		case LONG_OPT_MLOADER_IMAGE:
-			if(!first && opt.mloaderimage)
-				break;			
 			xfree(opt.mloaderimage);
 			opt.mloaderimage = xstrdup(optarg);
 			break;
 		case LONG_OPT_RAMDISK_IMAGE:
-			if(!first && opt.ramdiskimage)
-				break;			
 			xfree(opt.ramdiskimage);
 			opt.ramdiskimage = xstrdup(optarg);
 			break;
@@ -2019,10 +1524,43 @@ void set_options(const int argc, char **argv, int first)
 			opt.reboot = true;
 			break;
 		case LONG_OPT_GET_USER_ENV:
-			if (optarg)
-				_proc_get_user_env(optarg);
-			else
-				opt.get_user_env_time = 0;
+			error("--get-user-env is no longer supported in srun, use sbatch");
+			break;
+		case LONG_OPT_PTY:
+#ifdef HAVE_PTY_H
+			opt.pty = true;
+			opt.unbuffered = true;	/* implicit */
+			if (opt.ifname)
+				fatal("--input incompatable with --pty option");
+			if (opt.ofname)
+				fatal("--output incompatable with --pty option");
+			if (opt.efname)
+				fatal("--error incompatable with --pty option");
+#else
+			error("--pty not currently supported on this system type");
+#endif
+			break;
+		case LONG_OPT_CHECKPOINT:
+			xfree(opt.ckpt_interval_str);
+			opt.ckpt_interval_str = xstrdup(optarg);
+			break;
+		case LONG_OPT_OPEN_MODE:
+			if ((optarg[0] == 'a') || (optarg[0] == 'A'))
+				opt.open_mode = OPEN_MODE_APPEND;
+			else if ((optarg[0] == 't') || (optarg[0] == 'T'))
+				opt.open_mode = OPEN_MODE_TRUNCATE;
+			else {
+				error("Invalid --open-mode argument: %s. Ignored", 
+				      optarg);
+			}
+			break;
+		case LONG_OPT_ACCTG_FREQ:
+			opt.acctg_freq = _get_int(optarg, "acctg-freq",
+                                false);
+			break;
+		case LONG_OPT_CHECKPOINT_PATH:
+			xfree(opt.ckpt_path);
+			opt.ckpt_path = xstrdup(optarg);
 			break;
 		default:
 			if (spank_process_option (opt_char, optarg) < 0) {
@@ -2031,35 +1569,9 @@ void set_options(const int argc, char **argv, int first)
 		}
 	}
 
-	if (!first) {
-		if (!_opt_verify())
-			exit(1);
-		if (_verbose > 3)
-			_opt_list();
-	}
-
 	spank_option_table_destroy (optz);
 }
 
-static void _proc_get_user_env(char *optarg)
-{
-	char *end_ptr;
-
-	if ((optarg[0] >= '0') && (optarg[0] <= '9'))
-		opt.get_user_env_time = strtol(optarg, &end_ptr, 10);
-	else {
-		opt.get_user_env_time = 0;
-		end_ptr = optarg;
-	}
- 
-	if ((end_ptr == NULL) || (end_ptr[0] == '\0'))
-		return;
-	if      ((end_ptr[0] == 's') || (end_ptr[0] == 'S'))
-		opt.get_user_env_mode = 1;
-	else if ((end_ptr[0] == 'l') || (end_ptr[0] == 'L'))
-		opt.get_user_env_mode = 2;
-}
-
 /* Load the multi_prog config file into argv, pass the  entire file contents 
  * in order to avoid having to read the file on every node. We could parse
  * the infomration here too for loading the MPIR records for TotalView */
@@ -2109,16 +1621,17 @@ static void _opt_args(int argc, char **argv)
 	int i;
 	char **rest = NULL;
 
-	set_options(argc, argv, 1);	
+	set_options(argc, argv);
 
         /* When CR with memory as a CR is enabled we need to assign
-	   adequate value or check the value to opt.mem */
-	if ((opt.job_min_memory >= -1) && (opt.job_max_memory > 0)) {
+	 * adequate value or check the value to opt.mem */
+	if ((opt.job_min_memory >= -1) && (opt.task_mem > 0)) {
 		if (opt.job_min_memory == -1) {
-			opt.job_min_memory = opt.job_max_memory;
-		} else if (opt.job_min_memory < opt.job_max_memory) {
-			info("mem < job-mem - resizing mem to be equal to job-mem");
-			opt.job_min_memory = opt.job_max_memory;
+			opt.job_min_memory = opt.task_mem;
+		} else if (opt.job_min_memory < opt.task_mem) {
+			info("mem < task-mem - resizing mem to be equal "
+			     "to task-mem");
+			opt.job_min_memory = opt.task_mem;
 		}
 	}
 
@@ -2154,39 +1667,45 @@ static void _opt_args(int argc, char **argv)
 	}
 #endif
 
-	remote_argc = 0;
+	if (opt.nodelist && (!opt.test_only)) {
+#ifdef HAVE_BG
+		info("\tThe nodelist option should only be used if\n"
+		     "\tthe block you are asking for can be created.\n"
+		     "\tIt should also include all the midplanes you\n"
+		     "\twant to use, partial lists will not work correctly.\n"
+		     "\tPlease consult smap before using this option\n"
+		     "\tor your job may be stuck with no way to run.");
+#endif
+	}
+
+	opt.argc = 0;
 	if (optind < argc) {
 		rest = argv + optind;
-		while (rest[remote_argc] != NULL)
-			remote_argc++;
+		while (rest[opt.argc] != NULL)
+			opt.argc++;
 	}
-	remote_argv = (char **) xmalloc((remote_argc + 1) * sizeof(char *));
-	for (i = 0; i < remote_argc; i++)
-		remote_argv[i] = xstrdup(rest[i]);
-	remote_argv[i] = NULL;	/* End of argv's (for possible execv) */
+	opt.argv = (char **) xmalloc((opt.argc + 1) * sizeof(char *));
+	for (i = 0; i < opt.argc; i++)
+		opt.argv[i] = xstrdup(rest[i]);
+	opt.argv[i] = NULL;	/* End of argv's (for possible execv) */
 
 	if (opt.multi_prog) {
-		if (remote_argc < 1) {
+		if (opt.argc < 1) {
 			error("configuration file not specified");
 			exit(1);
 		}
-		_load_multi(&remote_argc, remote_argv);
+		_load_multi(&opt.argc, opt.argv);
 	}
-	else if (remote_argc > 0) {
+	else if (opt.argc > 0) {
 		char *fullpath;
-		char *cmd       = remote_argv[0];
-		bool search_cwd = (opt.batch || opt.allocate);
-		int  mode       = (search_cwd) ? R_OK : X_OK;
 
-		if ((fullpath = _search_path(cmd, search_cwd, mode))) {
-			xfree(remote_argv[0]);
-			remote_argv[0] = fullpath;
+		if ((fullpath = search_path(opt.cwd, opt.argv[0], false, X_OK))) {
+			xfree(opt.argv[0]);
+			opt.argv[0] = fullpath;
 		} 
 	}
-	if (!_opt_verify())
-		exit(1);
 
-	if (opt.multi_prog && verify_multi_name(remote_argv[0], opt.nprocs))
+	if (opt.multi_prog && verify_multi_name(opt.argv[0], opt.nprocs))
 		exit(1);
 }
 
@@ -2239,8 +1758,8 @@ static bool _opt_verify(void)
 	if (opt.job_min_cpus < opt.cpus_per_task)
 		opt.job_min_cpus = opt.cpus_per_task;
 
-	if ((opt.job_name == NULL) && (remote_argc > 0))
-		opt.job_name = _base_name(remote_argv[0]);
+	if ((opt.job_name == NULL) && (opt.argc > 0))
+		opt.job_name = base_name(opt.argv[0]);
 
 	if(!opt.nodelist) {
 		if((opt.nodelist = xstrdup(getenv("SLURM_HOSTFILE")))) {
@@ -2263,9 +1782,10 @@ static bool _opt_verify(void)
 				      opt.nodelist);
 			}
 		}
-	} else
+	} else {
 		if (!_valid_node_list(&opt.nodelist))
 			exit(1);
+	}
 	
 	/* now if max is set make sure we have <= max_nodes in the
 	 * nodelist but only if it isn't arbitrary since the user has
@@ -2295,72 +1815,89 @@ static bool _opt_verify(void)
 	} 
 
 
-	if (mode == MODE_ATTACH) {	/* attach to a running job */
-		if (opt.nodes_set || opt.cpus_set || opt.nprocs_set) {
-			error("do not specific a node allocation "
-			      "with --attach (-a)");
-			verified = false;
-		}
-
-		/* if (constraints_given()) {
-		 *	error("do not specify any constraints with "
-		 *	      "--attach (-a)");
-		 *	verified = false;
-		 *}
-		 */
+	if ((opt.argc == 0) && (opt.test_only == false)) {
+		error("must supply remote command");
+		verified = false;
+	}
 
-	} else { /* mode != MODE_ATTACH */
+	/* check for realistic arguments */
+	if (opt.nprocs <= 0) {
+		error("%s: invalid number of processes (-n %d)",
+		      opt.progname, opt.nprocs);
+		verified = false;
+	}
 
-		if ((remote_argc == 0) && (mode != MODE_ALLOCATE)) {
-			error("must supply remote command");
-			verified = false;
-		}
+	if (opt.cpus_per_task <= 0) {
+		error("%s: invalid number of cpus per task (-c %d)\n",
+		      opt.progname, opt.cpus_per_task);
+		verified = false;
+	}
 
+	if ((opt.min_nodes <= 0) || (opt.max_nodes < 0) || 
+	    (opt.max_nodes && (opt.min_nodes > opt.max_nodes))) {
+		error("%s: invalid number of nodes (-N %d-%d)\n",
+		      opt.progname, opt.min_nodes, opt.max_nodes);
+		verified = false;
+	}
 
-		/* check for realistic arguments */
-		if (opt.nprocs <= 0) {
-			error("%s: invalid number of processes (-n %d)",
-			      opt.progname, opt.nprocs);
-			verified = false;
+	/* bound max_threads/cores from ntasks_cores/sockets */ 
+	if ((opt.max_threads_per_core <= 0) &&
+	    (opt.ntasks_per_core > 0)) {
+		opt.max_threads_per_core = opt.ntasks_per_core;
+		/* if cpu_bind_type doesn't already have a auto pref,
+		 * choose the level based on the level of ntasks
+		 */
+		if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
+					   CPU_BIND_TO_CORES |
+					   CPU_BIND_TO_THREADS))) {
+			opt.cpu_bind_type |= CPU_BIND_TO_CORES;
 		}
-
-		if (opt.cpus_per_task <= 0) {
-			error("%s: invalid number of cpus per task (-c %d)\n",
-			      opt.progname, opt.cpus_per_task);
-			verified = false;
+	}
+	if ((opt.max_cores_per_socket <= 0) &&
+	    (opt.ntasks_per_socket > 0)) {
+		opt.max_cores_per_socket = opt.ntasks_per_socket;
+		/* if cpu_bind_type doesn't already have a auto pref,
+		 * choose the level based on the level of ntasks
+		 */
+		if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
+					   CPU_BIND_TO_CORES |
+					   CPU_BIND_TO_THREADS))) {
+			opt.cpu_bind_type |= CPU_BIND_TO_SOCKETS;
 		}
+	}
 
-		if ((opt.min_nodes <= 0) || (opt.max_nodes < 0) || 
-		    (opt.max_nodes && (opt.min_nodes > opt.max_nodes))) {
-			error("%s: invalid number of nodes (-N %d-%d)\n",
-			      opt.progname, opt.min_nodes, opt.max_nodes);
-			verified = false;
+	core_format_enable (opt.core_type);
+
+	/* massage the numbers */
+	if (opt.nodelist) {
+		hl = hostlist_create(opt.nodelist);
+		if (!hl)
+			fatal("memory allocation failure");
+		hostlist_uniq(hl);
+		hl_cnt = hostlist_count(hl);
+		if (opt.nodes_set)
+			opt.min_nodes = MAX(hl_cnt, opt.min_nodes);
+		else {
+			opt.min_nodes = hl_cnt;
+			opt.nodes_set = true;
 		}
+	}
+	if ((opt.nodes_set || opt.extra_set) && !opt.nprocs_set) {
+		/* 1 proc / node default */
+		opt.nprocs = opt.min_nodes;
 
-		/* bound max_threads/cores from ntasks_cores/sockets */ 
-		if ((opt.max_threads_per_core <= 0) &&
-		    (opt.ntasks_per_core > 0)) {
-			opt.max_threads_per_core = opt.ntasks_per_core;
-			/* if cpu_bind_type doesn't already have a auto pref,
-			 * choose the level based on the level of ntasks
-			 */
-			if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
-						CPU_BIND_TO_CORES |
-						CPU_BIND_TO_THREADS))) {
-				opt.cpu_bind_type |= CPU_BIND_TO_CORES;
-			}
+		/* 1 proc / min_[socket * core * thread] default */
+		if (opt.min_sockets_per_node > 0) {
+			opt.nprocs *= opt.min_sockets_per_node;
+			opt.nprocs_set = true;
 		}
-		if ((opt.max_cores_per_socket <= 0) &&
-		    (opt.ntasks_per_socket > 0)) {
-			opt.max_cores_per_socket = opt.ntasks_per_socket;
-			/* if cpu_bind_type doesn't already have a auto pref,
-			 * choose the level based on the level of ntasks
-			 */
-			if (!(opt.cpu_bind_type & (CPU_BIND_TO_SOCKETS |
-						CPU_BIND_TO_CORES |
-						CPU_BIND_TO_THREADS))) {
-				opt.cpu_bind_type |= CPU_BIND_TO_SOCKETS;
-			}
+		if (opt.min_cores_per_socket > 0) {
+			opt.nprocs *= opt.min_cores_per_socket;
+			opt.nprocs_set = true;
+		}
+		if (opt.min_threads_per_core > 0) {
+			opt.nprocs *= opt.min_threads_per_core;
+			opt.nprocs_set = true;
 		}
 
 		core_format_enable (opt.core_type);
@@ -2386,61 +1923,44 @@ static bool _opt_verify(void)
 			   used later
 			*/
 		}
+	} else if (opt.nodes_set && opt.nprocs_set) {
 
-		if ((opt.nodes_set || opt.extra_set) && !opt.nprocs_set) {
-			/* 1 proc / node default */
-			opt.nprocs = opt.min_nodes;
-
-			/* 1 proc / min_[socket * core * thread] default */
-			if (opt.min_sockets_per_node > 0) {
-				opt.nprocs *= opt.min_sockets_per_node;
-				opt.nprocs_set = true;
-			}
-			if (opt.min_cores_per_socket > 0) {
-				opt.nprocs *= opt.min_cores_per_socket;
-				opt.nprocs_set = true;
-			}
-			if (opt.min_threads_per_core > 0) {
-				opt.nprocs *= opt.min_threads_per_core;
-				opt.nprocs_set = true;
-			}
-		} else if (opt.nodes_set && opt.nprocs_set) {
-
-			/*
-			 * Make sure in a non allocate situation that
-			 * the number of max_nodes is <= number of tasks
-			 */
-			if (!opt.allocate && opt.nprocs < opt.max_nodes) 
-				opt.max_nodes = opt.nprocs;
-
-			/* 
-			 *  make sure # of procs >= min_nodes || max_nodes 
-			 */
-			if (opt.nprocs < opt.min_nodes) {
-
-				info ("Warning: can't run %d processes on %d " 
-				      "nodes, setting nnodes to %d", 
-				      opt.nprocs, opt.min_nodes, opt.nprocs);
-
-				opt.min_nodes = opt.nprocs;
-				if (opt.max_nodes 
-				&&  (opt.min_nodes > opt.max_nodes) )
-					opt.max_nodes = opt.min_nodes;
-				if (hl_cnt > opt.min_nodes) {
-					int del_cnt, i;
-					char *host;
-					del_cnt = hl_cnt - opt.min_nodes;
-					for (i=0; i<del_cnt; i++) {
-						host = hostlist_pop(hl);
-						free(host);
-					}
-					hostlist_ranged_string(hl, strlen(opt.nodelist)+1, 
-							       opt.nodelist);
+		/*
+		 * Make sure that the number of 
+		 * max_nodes is <= number of tasks
+		 */
+		if (opt.nprocs < opt.max_nodes) 
+			opt.max_nodes = opt.nprocs;
+		
+		/* 
+		 *  make sure # of procs >= min_nodes 
+		 */
+		if (opt.nprocs < opt.min_nodes) {
+
+			info ("Warning: can't run %d processes on %d " 
+			      "nodes, setting nnodes to %d", 
+			      opt.nprocs, opt.min_nodes, opt.nprocs);
+
+			opt.min_nodes = opt.nprocs;
+			if (opt.max_nodes 
+			    &&  (opt.min_nodes > opt.max_nodes) )
+				opt.max_nodes = opt.min_nodes;
+			if (hl_cnt > opt.min_nodes) {
+				int del_cnt, i;
+				char *host;
+				del_cnt = hl_cnt - opt.min_nodes;
+				for (i=0; i<del_cnt; i++) {
+					host = hostlist_pop(hl);
+					free(host);
 				}
+				hostlist_ranged_string(hl, 
+						       strlen(opt.nodelist)+1, 
+						       opt.nodelist);
 			}
+		}
+
+	} /* else if (opt.nprocs_set && !opt.nodes_set) */
 
-		} /* else if (opt.nprocs_set && !opt.nodes_set) */
-	}
 	if (hl)
 		hostlist_destroy(hl);
 
@@ -2467,7 +1987,7 @@ static bool _opt_verify(void)
 
 	if (opt.time_limit_str) {
 		opt.time_limit = time_str2mins(opt.time_limit_str);
-		if (opt.time_limit < 0) {
+		if ((opt.time_limit < 0) && (opt.time_limit != INFINITE)) {
 			error("Invalid time limit specification");
 			exit(1);
 		}
@@ -2475,6 +1995,17 @@ static bool _opt_verify(void)
 			opt.time_limit = INFINITE;
 	}
 
+	if (opt.ckpt_interval_str) {
+		opt.ckpt_interval = time_str2mins(opt.ckpt_interval_str);
+		if ((opt.ckpt_interval < 0) && (opt.ckpt_interval != INFINITE)) {
+			error("Invalid checkpoint interval specification");
+			exit(1);
+		}
+	}
+
+	if (! opt.ckpt_path)
+		opt.ckpt_path = xstrdup(opt.cwd);
+
 	if ((opt.euid != (uid_t) -1) && (opt.euid != opt.uid)) 
 		opt.uid = opt.euid;
 
@@ -2484,11 +2015,6 @@ static bool _opt_verify(void)
         if ((opt.egid != (gid_t) -1) && (opt.egid != opt.gid))
 	        opt.gid = opt.egid;
 
-	if (opt.noshell && !opt.allocate) {
-		error ("--no-shell only valid with -A (--allocate)");
-		verified = false;
-	}
-
 	if (opt.propagate && parse_rlimits( opt.propagate, PROPAGATE_RLIMITS)) {
 		error( "--propagate=%s is not valid.", opt.propagate );
 		verified = false;
@@ -2504,123 +2030,22 @@ static bool _opt_verify(void)
 		xfree(sched_name);
 	}
 
-	return verified;
-}
-
-static uint16_t _parse_mail_type(const char *arg)
-{
-	uint16_t rc;
-
-	if (strcasecmp(arg, "BEGIN") == 0)
-		rc = MAIL_JOB_BEGIN;
-	else if  (strcasecmp(arg, "END") == 0)
-		rc = MAIL_JOB_END;
-	else if (strcasecmp(arg, "FAIL") == 0)
-		rc = MAIL_JOB_FAIL;
-	else if (strcasecmp(arg, "ALL") == 0)
-		rc = MAIL_JOB_BEGIN |  MAIL_JOB_END |  MAIL_JOB_FAIL;
-	else
-		rc = 0;		/* failure */
-
-	return rc;
-}
-
-static char *_print_mail_type(const uint16_t type)
-{
-	if (type == 0)
-		return "NONE";
-
-	if (type == MAIL_JOB_BEGIN)
-		return "BEGIN";
-	if (type == MAIL_JOB_END)
-		return "END";
-	if (type == MAIL_JOB_FAIL)
-		return "FAIL";
-	if (type == (MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL))
-		return "ALL";
-
-	return "MULTIPLE";
-}
-
-static void
-_freeF(void *data)
-{
-	xfree(data);
-}
-
-static List
-_create_path_list(void)
-{
-	List l = list_create(_freeF);
-	char *path, *c, *lc;
-
-	c = getenv("PATH");
-	if (!c) {
-		verbose("No PATH environment variable");
-		return l;
-	}
-
-	path = xstrdup(c);
-	c = lc = path;
-
-	while (*c != '\0') {
-		if (*c == ':') {
-			/* nullify and push token onto list */
-			*c = '\0';
-			if (lc != NULL && strlen(lc) > 0)
-				list_append(l, xstrdup(lc));
-			lc = ++c;
-		} else
-			c++;
-	}
-
-	if (strlen(lc) > 0)
-		list_append(l, xstrdup(lc));
-
-	xfree(path);
-
-	return l;
-}
-
-static char *
-_search_path(char *cmd, bool check_current_dir, int access_mode)
-{
-	List         l        = NULL;
-	ListIterator i        = NULL;
-	char *path, *fullpath = NULL;
-
-	if (  (cmd[0] == '.' || cmd[0] == '/') 
-	      && (access(cmd, access_mode) == 0 ) ) {
-		if (cmd[0] == '.')
-			xstrfmtcat(fullpath, "%s/", opt.cwd);
-		xstrcat(fullpath, cmd);
-		goto done;
+	if (opt.task_mem > 0) {
+		uint32_t max_mem = slurm_get_max_mem_per_task();
+		if (max_mem && (opt.task_mem > max_mem)) {
+			info("WARNING: Reducing --task-mem to system maximum "
+			     "of %u MB", max_mem);
+			opt.task_mem = max_mem;
+		}	
+	} else {
+		uint32_t max_mem = slurm_get_def_mem_per_task();
+		if (max_mem)
+			opt.task_mem = max_mem;
 	}
 
-	l = _create_path_list();
-	if (l == NULL)
-		return NULL;
-
-	if (check_current_dir) 
-		list_prepend(l, xstrdup(opt.cwd));
-
-	i = list_iterator_create(l);
-	while ((path = list_next(i))) {
-		xstrfmtcat(fullpath, "%s/%s", path, cmd);
-
-		if (access(fullpath, access_mode) == 0)
-			goto done;
-
-		xfree(fullpath);
-		fullpath = NULL;
-	}
-done:
-	if (l)
-		list_destroy(l);
-	return fullpath;
+	return verified;
 }
 
-
 /* helper function for printing options
  * 
  * warning: returns pointer to memory allocated on the stack.
@@ -2644,8 +2069,8 @@ static char *print_constraints()
 	if (opt.job_min_memory > 0)
 		xstrfmtcat(buf, "mem=%dM ", opt.job_min_memory);
 
-	if (opt.job_max_memory > 0)
-		xstrfmtcat(buf, "job-mem=%dM ", opt.job_max_memory);
+	if (opt.task_mem > 0)
+		xstrfmtcat(buf, "task-mem=%dM ", opt.task_mem);
 
 	if (opt.job_min_tmp_disk > 0)
 		xstrfmtcat(buf, "tmp=%ld ", opt.job_min_tmp_disk);
@@ -2665,39 +2090,6 @@ static char *print_constraints()
 	return buf;
 }
 
-static char * 
-print_commandline()
-{
-	int i;
-	char buf[256];
-
-	buf[0] = '\0';
-	for (i = 0; i < remote_argc; i++)
-		snprintf(buf, 256,  "%s", remote_argv[i]);
-	return xstrdup(buf);
-}
-
-static char *
-print_geometry()
-{
-	int i;
-	char buf[32], *rc = NULL;
-
-	if ((SYSTEM_DIMENSIONS == 0)
-	    ||  (opt.geometry[0] == (uint16_t)NO_VAL))
-		return NULL;
-
-	for (i=0; i<SYSTEM_DIMENSIONS; i++) {
-		if (i > 0)
-			snprintf(buf, sizeof(buf), "x%u", opt.geometry[i]);
-		else
-			snprintf(buf, sizeof(buf), "%u", opt.geometry[i]);
-		xstrcat(rc, buf);
-	}
-
-	return rc;
-}
-
 #define tf_(b) (b == true) ? "true" : "false"
 
 static void _opt_list()
@@ -2737,27 +2129,25 @@ static void _opt_list()
 	info("verbose        : %d", _verbose);
 	info("slurmd_debug   : %d", opt.slurmd_debug);
 	info("immediate      : %s", tf_(opt.immediate));
-	info("no-requeue     : %s", tf_(opt.no_requeue));
 	info("label output   : %s", tf_(opt.labelio));
 	info("unbuffered IO  : %s", tf_(opt.unbuffered));
-	info("allocate       : %s", tf_(opt.allocate));
-	info("attach         : `%s'", opt.attach);
 	info("overcommit     : %s", tf_(opt.overcommit));
-	info("batch          : %s", tf_(opt.batch));
 	info("threads        : %d", opt.max_threads);
 	if (opt.time_limit == INFINITE)
 		info("time_limit     : INFINITE");
 	else if (opt.time_limit != NO_VAL)
 		info("time_limit     : %d", opt.time_limit);
+	if (opt.ckpt_interval)
+		info("checkpoint     : %d secs", opt.ckpt_interval);
+	info("checkpoint_path: %s", opt.ckpt_path);
 	info("wait           : %d", opt.max_wait);
 	if (opt.nice)
 		info("nice           : %d", opt.nice);
 	info("account        : %s", opt.account);
 	info("comment        : %s", opt.comment);
-	if (opt.dependency == NO_VAL)
-		info("dependency     : none");
-	else
-		info("dependency     : %u", opt.dependency);
+
+	info("dependency     : %s", opt.dependency);
+	info("exclusive      : %s", tf_(opt.exclusive));
 	if (opt.shared != (uint16_t) NO_VAL)
 		info("shared         : %u", opt.shared);
 	str = print_constraints();
@@ -2765,7 +2155,7 @@ static void _opt_list()
 	xfree(str);
 	if (opt.conn_type != (uint16_t) NO_VAL)
 		info("conn_type      : %u", opt.conn_type);
-	str = print_geometry();
+	str = print_geometry(opt.geometry);
 	info("geometry       : %s", str);
 	xfree(str);
 	info("reboot         : %s", opt.reboot ? "no" : "yes");
@@ -2790,17 +2180,23 @@ static void _opt_list()
 	}
 	info("prolog         : %s", opt.prolog);
 	info("epilog         : %s", opt.epilog);
-	info("mail_type      : %s", _print_mail_type(opt.mail_type));
+	info("mail_type      : %s", print_mail_type(opt.mail_type));
 	info("mail_user      : %s", opt.mail_user);
 	info("task_prolog    : %s", opt.task_prolog);
 	info("task_epilog    : %s", opt.task_epilog);
 	info("ctrl_comm_ifhn : %s", opt.ctrl_comm_ifhn);
 	info("multi_prog     : %s", opt.multi_prog ? "yes" : "no");
+	info("sockets-per-node  : %d - %d", opt.min_sockets_per_node,
+					    opt.max_sockets_per_node);
+	info("cores-per-socket  : %d - %d", opt.min_cores_per_socket,
+					    opt.max_cores_per_socket);
+	info("threads-per-core  : %d - %d", opt.min_threads_per_core,
+					    opt.max_threads_per_core);
 	info("ntasks-per-node   : %d", opt.ntasks_per_node);
 	info("ntasks-per-socket : %d", opt.ntasks_per_socket);
 	info("ntasks-per-core   : %d", opt.ntasks_per_core);
 	info("plane_size        : %u", opt.plane_size);
-	str = print_commandline();
+	str = print_commandline(opt.argc, opt.argv);
 	info("remote command    : `%s'", str);
 	xfree(str);
 
@@ -2819,10 +2215,11 @@ static void _usage(void)
 "            [-c ncpus] [-r n] [-p partition] [--hold] [-t minutes]\n"
 "            [-D path] [--immediate] [--overcommit] [--no-kill]\n"
 "            [--share] [--label] [--unbuffered] [-m dist] [-J jobname]\n"
-"            [--jobid=id] [--batch] [--verbose] [--slurmd_debug=#]\n"
-"            [--core=type] [-T threads] [-W sec] [--attach] [--join] \n"
+"            [--jobid=id] [--verbose] [--slurmd_debug=#]\n"
+"            [--core=type] [-T threads] [-W sec] [--checkpoint=time]\n"
+"            [--checkpoint-path=dir]  [--licenses=names]\n"
 "            [--contiguous] [--mincpus=n] [--mem=MB] [--tmp=MB] [-C list]\n"
-"            [--mpi=type] [--account=name] [--dependency=jobid]\n"
+"            [--mpi=type] [--account=name] [--dependency=type:jobid]\n"
 "            [--kill-on-bad-exit] [--propagate[=rlimits] [--comment=name]\n"
 "            [--cpu_bind=...] [--mem_bind=...]\n"
 "            [--ntasks-per-node=n] [--ntasks-per-socket=n]\n"
@@ -2835,7 +2232,7 @@ static void _usage(void)
 		"            [--mail-type=type] [--mail-user=user] [--nice[=value]]\n"
 		"            [--prolog=fname] [--epilog=fname]\n"
 		"            [--task-prolog=fname] [--task-epilog=fname]\n"
-		"            [--ctrl-comm-ifhn=addr] [--multi-prog] [--no-requeue]\n"
+		"            [--ctrl-comm-ifhn=addr] [--multi-prog]\n"
 		"            [-w hosts...] [-x hosts...] executable [args...]\n");
 }
 
@@ -2883,7 +2280,7 @@ static void _help(void)
 "  -d, --slurmd-debug=level    slurmd debug level\n"
 "      --core=type             change default corefile format type\n"
 "                              (type=\"list\" to list of valid formats)\n"
-"  -P, --dependency=jobid      defer job until specified jobid completes\n"
+"  -P, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "      --nice[=value]          decrease secheduling priority by value\n"
 "  -U, --account=name          charge job to specified account\n"
 "      --comment=name          arbitrary comment\n"
@@ -2900,16 +2297,12 @@ static void _help(void)
 "      --multi-prog            if set the program name specified is the\n"
 "                              configuration specification for multiple programs\n"
 "      --get-user-env          used by Moab.  See srun man page.\n"
-"      --no-requeue            if set, do not permit the job to be requeued\n"
-"\n"
-"Allocate only:\n"
-"  -A, --allocate              allocate resources and spawn a shell\n"
-"      --no-shell              don't spawn shell in allocate mode\n"
-"\n"
-"Attach to running job:\n"
-"  -a, --attach=jobid          attach to running job with specified id\n"
-"  -j, --join                  when used with --attach, allow forwarding of\n"
-"                              signals and stdin.\n"
+"  -L, --licenses=names        required license, comma separated\n"
+"      --checkpoint=time       job step checkpoint interval\n"
+"      --checkpoint-path=dir   path to store job step checkpoint image files\n"
+#ifdef HAVE_PTY_H
+"      --pty                   run task zero in pseudo terminal\n"
+#endif
 "\n"
 "Constraint options:\n"
 "      --mincpus=n             minimum number of cpus per node\n"
@@ -2927,7 +2320,8 @@ static void _help(void)
 "Consumable resources related options:\n" 
 "      --exclusive             allocate nodes in exclusive mode when\n" 
 "                              cpu consumable resource is enabled\n"
-"      --job-mem=MB            maximum amount of real memory per node\n"
+"                              or don't share CPUs for job steps\n"
+"      --task-mem=MB           maximum amount of real memory per task\n"
 "                              required by the job.\n" 
 "                              --mem >= --job-mem if --mem is specified.\n" 
 "\n"
diff --git a/src/srun/opt.h b/src/srun/opt.h
index 8104cb48c9d2d477326ca4be558e1d38418abed7..54cdac36c154b29e9e091c1074de43355bb319fa 100644
--- a/src/srun/opt.h
+++ b/src/srun/opt.h
@@ -1,11 +1,11 @@
 /*****************************************************************************\
  *  opt.h - definitions for srun option processing
- *  $Id: opt.h 13407 2008-02-28 20:13:43Z jette $
+ *  $Id: opt.h 13771 2008-04-02 20:03:47Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona1@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -58,20 +58,8 @@
 #define INT_UNASSIGNED ((int)-1)
 
 /* global variables relating to user options */
-extern char **remote_argv;
-extern int remote_argc;
 extern int _verbose;
 
-/* mutually exclusive modes for srun */
-enum modes {
-	MODE_UNKNOWN	= 0,
-	MODE_NORMAL	= 1,
-	MODE_IMMEDIATE	= 2,
-	MODE_ATTACH	= 3,
-	MODE_ALLOCATE	= 4,
-	MODE_BATCH	= 5
-};
-
 extern enum modes mode;
 
 #define format_task_dist_states(t) (t == SLURM_DIST_BLOCK) ? "block" :   \
@@ -121,6 +109,10 @@ typedef struct srun_options {
 	bool extra_set;		/* true if extra node info explicitly set */
 	int  time_limit;	/* --time,   -t	(int minutes)	*/
 	char *time_limit_str;	/* --time,   -t (string)	*/
+	int  ckpt_interval;	/* --checkpoint (int minutes)	*/
+	char *ckpt_interval_str;/* --checkpoint (string)	*/
+	char *ckpt_path;	/* --checkpoint-path (string)   */
+	bool exclusive;		/* --exclusive			*/
 	char *partition;	/* --partition=n,   -p n   	*/
 	enum task_dist_states
 	        distribution;	/* --distribution=, -m dist	*/
@@ -132,7 +124,7 @@ typedef struct srun_options {
 	unsigned int jobid;     /* --jobid=jobid                */
 	bool jobid_set;		/* true if jobid explicitly set */
 	char *mpi_type;		/* --mpi=type			*/
-	unsigned int dependency;/* --dependency, -P jobid	*/
+	char *dependency;	/* --dependency, -P type:jobid	*/
 	int nice;		/* --nice			*/
 	char *account;		/* --account, -U acct_name	*/
 	char *comment;		/* --comment			*/
@@ -143,7 +135,6 @@ typedef struct srun_options {
 
 	int  slurmd_debug;	/* --slurmd-debug, -D           */
 	core_format_t core_type;/* --core= 	        	*/
-	char *attach;		/* --attach=id	    -a id	*/ 
 	bool join;		/* --join, 	    -j		*/
 
 	/* no longer need these, they are set globally : 	*/
@@ -158,10 +149,8 @@ typedef struct srun_options {
 	bool allocate;		/* --allocate, 	   -A		*/
 	bool noshell;		/* --no-shell                   */
 	bool overcommit;	/* --overcommit,   -O		*/
-	bool batch;		/* --batch,   -b		*/
 	bool no_kill;		/* --no-kill, -k		*/
 	bool kill_bad_exit;	/* --kill-on-bad-exit, -K	*/
-	bool no_requeue;	/* --no-requeue			*/
 	uint16_t shared;	/* --share,   -s		*/
 	int  max_wait;		/* --wait,    -W		*/
 	bool quit_on_intr;      /* --quit-on-interrupt, -q      */
@@ -173,6 +162,7 @@ typedef struct srun_options {
 	char *propagate;	/* --propagate[=RLIMIT_CORE,...]*/
 	char *task_epilog;	/* --task-epilog=		*/
 	char *task_prolog;	/* --task-prolog=		*/
+	char *licenses;		/* --licenses, -L		*/
 
 	/* constraint options */
 	int32_t job_min_cpus;	/* --mincpus=n			*/
@@ -180,7 +170,7 @@ typedef struct srun_options {
 	int32_t job_min_cores;	/* --mincores=n			*/
 	int32_t job_min_threads;/* --minthreads=n		*/
 	int32_t job_min_memory;	/* --mem=n			*/
-	int32_t job_max_memory;	/* --job-mem=n			*/
+	int32_t task_mem;	/* --task-mem=n			*/
 	long job_min_tmp_disk;	/* --tmp=n			*/
 	char *constraints;	/* --constraints=, -C constraint*/
 	bool contiguous;	/* --contiguous			*/
@@ -212,8 +202,11 @@ typedef struct srun_options {
 	uint16_t mail_type;	/* --mail-type			*/
 	char *mail_user;	/* --mail-user			*/
 	char *ctrl_comm_ifhn;	/* --ctrl-comm-ifhn		*/
-	int get_user_env_time;	/* --get-user-env[=secs]	*/
-	int get_user_env_mode;	/* --get-user-env=[S|L]		*/
+	uint8_t open_mode;	/* --open-mode=append|truncate	*/
+	int acctg_freq;		/* --acctg-freq=secs		*/
+	bool pty;		/* --pty			*/
+	int argc;		/* length of argv array		*/
+	char **argv;		/* left over on command line	*/
 } opt_t;
 
 extern opt_t opt;
@@ -239,8 +232,4 @@ extern opt_t opt;
  */
 int initialize_and_process_args(int argc, char *argv[]);
 
-/* set options based upon commandline args */
-void set_options(const int argc, char **argv, int first);
-
-
 #endif	/* _HAVE_OPT_H */
diff --git a/src/srun/reattach.c b/src/srun/reattach.c
deleted file mode 100644
index a24d20bdb451a104b0be5f8c743fb2eaaef7537d..0000000000000000000000000000000000000000
--- a/src/srun/reattach.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/****************************************************************************\
- * src/srun/reattach.c - reattach to a running job
- * $Id: reattach.c 10574 2006-12-15 23:38:29Z jette $
- *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <grondona@llnl.gov>.
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under 
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/param.h>
-
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/common/xsignal.h"
-#include "src/common/log.h"
-#include "src/common/list.h"
-#include "src/common/macros.h"
-#include "src/common/hostlist.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/read_config.h"
-#include "src/common/forward.h"
-
-#include "src/srun/srun_job.h"
-#include "src/srun/launch.h"
-#include "src/srun/opt.h"
-#include "src/srun/msg.h"
-#include "src/srun/srun.h"
-#include "src/srun/signals.h"
-
-
-/* number of active threads */
-static pthread_mutex_t active_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  active_cond  = PTHREAD_COND_INITIALIZER;
-static int             active = 0;
-
-static bool            invalid_user = false;
-
-typedef enum {THD_NEW, THD_ACTIVE, THD_DONE, THD_FAILED} state_t;
-
-typedef struct thd {
-        pthread_t	thread;			/* thread ID */
-        pthread_attr_t	attr;			/* thread attributes */
-        state_t		state;      		/* thread state */
-	slurm_msg_t    *msg;
-	srun_job_t     *job;
-	uint32_t        nodeid;
-} thd_t;
-
-static void		 _p_reattach(slurm_msg_t *req, srun_job_t *job);
-static void 		*_p_reattach_task(void *args);
-
-typedef struct _srun_step {
-	uint32_t  jobid;
-	uint32_t  stepid;
-	uint32_t  ntasks;
-	char     *nodes;
-	char     *name;
-	bool      complete_job;
-} srun_step_t;
-
-static void
-_srun_step_destroy(srun_step_t *s)
-{
-	if (s->name)
-		xfree(s->name);
-	if (s->nodes)
-		xfree(s->nodes);
-	xfree(s);
-}
-
-static srun_step_t *
-_srun_step_create(uint32_t jobid, uint32_t stepid, char *name)
-{
-	srun_step_t *s = xmalloc(sizeof(*s));
-	s->jobid  = jobid;
-	s->stepid = stepid;
-	s->ntasks = 0;
-	s->nodes  = NULL;
-	s->name   = NULL;
-
-	s->complete_job = false;
-
-	if (name == NULL) 
-		return s;
-	s->name = xstrdup(name);
-	return s;
-}
-
-static char *
-_next_tok(char *sep, char **str)
-{
-	char *tok;
-
-	/* push str past any leading separators */
-	while ((**str != '\0') && (strchr(sep, **str) != '\0'))
-		(*str)++;
-
-	if (**str == '\0')
-		return NULL;
-
-	/* assign token ptr */
-	tok = *str;
-
-	/* push str past token and leave pointing to first separator */
-	while ((**str != '\0') && (strchr(sep, **str) == '\0'))
-		(*str)++;
-
-	/* nullify consecutive separators and push str beyond them */
-	while ((**str != '\0') && (strchr(sep, **str) != '\0'))
-		*(*str)++ = '\0';
-
-	return tok;
-}
-
-
-static List
-_step_list_create(char *steplist)
-{
-	List     l    = NULL;
-	char    *str  = NULL;
-	char    *orig = NULL;
-	char    *tok  = NULL;
-	uint32_t jobid, stepid;
-       
-	if (steplist == NULL)
-		return NULL;
-
-	orig = str = xstrdup(steplist);
-
-	l = list_create((ListDelF)_srun_step_destroy);
-
-	while ((tok = _next_tok(",", &str))) {
-		char *cur = tok;
-		char *p   = strchr(tok, '.');
-		char *q   = NULL;
-
-		if (p) *(p++) = '\0';
-
-		jobid  = strtoul(tok, &q, 10);
-
-		if (q == tok) {
-			error("Invalid jobid: `%s'", cur);
-			goto error;
-		}
-
-		stepid = (p && *p) ? strtoul(p, &q, 10) : NO_VAL;
-
-		if ((q == p) || (*q != '\0')) {
-			error("Invalid job step id: `%s'", cur);
-			goto error;
-		}
-		
-		list_append(l, _srun_step_create(jobid, stepid, cur));
-	}
-
-	xfree(orig);
-	return l;
-
-    error:
-	xfree(orig);
-	list_destroy(l);
-	return NULL;
-
-}
-
-static int
-_get_job_info(srun_step_t *s)
-{
-	int             i, rc = -1;
-	job_info_msg_t *resp = NULL;
-	job_info_t     *job  = NULL;
-	hostlist_t      hl;
-
-	s->nodes = NULL;
-
-	if (slurm_load_jobs((time_t) 0, &resp, 1) < 0) {
-		error("Unable to load jobs: %m");
-		goto done;
-	}
-
-	for (i = 0; i < resp->record_count; i++) {
-		job = &resp->job_array[i];
-		if (job->job_id == s->jobid)
-			break;
-		job = NULL;
-	}
-
-	if (job == NULL) {
-		error ("Unable to find job %u", s->jobid);
-		goto done;
-	}
-
-	if ((job->job_state != JOB_RUNNING)
-	&&  (job->job_state != JOB_SUSPENDED)) {
-		error ("Cannot attach to job %d in state %s",
-		       job->job_id, job_state_string(job->job_state));
-		goto done;
-	}
-
-	if (!job->batch_flag) {
-		rc = 0;
-		goto done;
-	}
-
-	if (!(hl = hostlist_create(job->nodes))) {
-		error ("Unable to create hostlist from `%s'", job->nodes);
-		goto done;
-	}
-	s->nodes  = hostlist_shift(hl);
-	hostlist_destroy(hl);
-
-	s->ntasks = 1;
-	rc = 0;
-
-  done:
-	if (resp)
-		slurm_free_job_info_msg(resp);
-	return rc;
-}
-
-static void
-_get_step_info(srun_step_t *s)
-{
-	uid_t my_uid;
-	job_step_info_response_msg_t *resp = NULL;
-
-	xassert(s->stepid != NO_VAL);
-
-	if (slurm_get_job_steps((time_t) 0, s->jobid, s->stepid, &resp, 1) 
-	    < 0) {
-		error("Unable to get step information for %u.%u: %m", 
-		      s->jobid, s->stepid);
-		goto done;
-	}
-	if (resp->job_step_count == 0) {
-		error("No nodes in %u.%u", s->jobid, s->stepid);
-		s->ntasks = 0;
-		goto done;
-	}
-
-	invalid_user = false;
-	if ((my_uid = getuid()) != 0) {	/* not user root */
-		if (my_uid != resp->job_steps->user_id) {
-			error("Invalid user id");
-			invalid_user = true;
-			/* We let the request continue and log the 
-			 * event in SlurmdLog for security purposes */
-		}
-	}
-	s->nodes  = xstrdup(resp->job_steps->nodes);
-	s->ntasks = resp->job_steps->num_tasks;
-
-    done:
-	if (resp)
-		slurm_free_job_step_info_response_msg(resp);
-	return;
-}
-
-static void
-_get_attach_info(srun_step_t *s)
-{
-	if (s->stepid == NO_VAL) {
-		if (_get_job_info(s) < 0)
-			return;
-
-		/* If job was not a batch job, try step 0
-		 */
-		if (s->nodes == NULL) {
-			s->stepid = 0;
-			_get_step_info(s);
-		}
-
-	} else {
-		_get_step_info(s);
-	}
-}
-
-static int
-_attach_to_job(srun_job_t *job)
-{
-	int i;
-	reattach_tasks_request_msg_t *req = NULL;
-	slurm_msg_t *msg = NULL;
-	hostlist_t hl = NULL;
-	char *name = NULL;
-	
-	req = xmalloc(job->nhosts * sizeof(reattach_tasks_request_msg_t));
-	msg = xmalloc(job->nhosts * sizeof(slurm_msg_t));
-
-	debug("Going to attach to job %u.%u", job->jobid, job->stepid);
-
-	hl = hostlist_create(job->step_layout->node_list);
-	for (i = 0; i < job->nhosts; i++) {
-		reattach_tasks_request_msg_t *r = &req[i];
-		slurm_msg_t                  *m = &msg[i];
-
-		r->job_id          = job->jobid;
-		r->job_step_id     = job->stepid;
-		r->num_io_port     = 1;
-		r->io_port         = (uint16_t *)xmalloc(sizeof(uint16_t));
-		r->io_port[0]      = job->client_io->listenport[
-					   i%job->client_io->num_listen];
-		r->num_resp_port   = 1;
-		r->resp_port	   = (uint16_t *)xmalloc(sizeof(uint16_t));
-		r->resp_port[0]    = ntohs(job->jaddr[i%job->njfds].sin_port);
-		r->cred            = job->cred;
-		slurm_msg_t_init(m);
-		m->data            = r;
-		m->msg_type        = REQUEST_REATTACH_TASKS;
-		name = hostlist_shift(hl);
-		if(!name) {
-			error("hostlist incomplete for this job request");
-			hostlist_destroy(hl);
-			return SLURM_ERROR;
-		}
-		if(slurm_conf_get_addr(name, &m->address)
-		   == SLURM_ERROR) {
-			error("_init_task_layout: can't get addr for "
-			      "host %s", name);
-			free(name);
-			hostlist_destroy(hl);
-			return SLURM_ERROR;
-		}
-		free(name);
-		/* memcpy(&m->address, &job->step_layout->node_addr[i],  */
-/* 		       sizeof(slurm_addr)); */
-	}
-	hostlist_destroy(hl);
-	_p_reattach(msg, job);
-	
-	return SLURM_SUCCESS;
-}
-
-static void
-_p_reattach(slurm_msg_t *msg, srun_job_t *job)
-{
-	int i;
-	thd_t *thd = xmalloc(job->nhosts * sizeof(thd_t));
-
-	for (i = 0; i < job->nhosts; i++) {
-
-		slurm_mutex_lock(&active_mutex);
-		while (active >= opt.max_threads) {
-			pthread_cond_wait(&active_cond, &active_mutex);
-		}
-		active++;
-		slurm_mutex_unlock(&active_mutex);
-
-		thd[i].msg = &msg[i];
-		thd[i].job = job;
-		thd[i].nodeid = i;
-
-		slurm_attr_init(&thd[i].attr);
-		if (pthread_attr_setdetachstate(&thd[i].attr,
-				PTHREAD_CREATE_DETACHED ) < 0)
-			fatal("pthread_attr_setdetachstate: %m");
-
-		if (pthread_create( &thd[i].thread, &thd[i].attr,
-				    _p_reattach_task, (void *) &thd[i])) {
-			error("pthread_create: %m");
-			_p_reattach_task((void *) &thd[i]);
-		}
-		slurm_attr_destroy(&thd[i].attr);
-
-	}
-
-	slurm_mutex_lock(&active_mutex);
-	while (active > 0)
-		pthread_cond_wait(&active_cond, &active_mutex);
-	slurm_mutex_unlock(&active_mutex);
-
-	xfree(thd);
-}
-
-static void *
-_p_reattach_task(void *arg)
-{
-	thd_t *t   = (thd_t *) arg;
-	int rc     = 0;
-	char *host = nodelist_nth_host(t->job->step_layout->node_list,
-				       t->nodeid);
-	
-	t->state = THD_ACTIVE;
-	debug3("sending reattach request to %s", host);
-
-	rc = slurm_send_only_node_msg(t->msg);
-	if (rc < 0) {
-		error("reattach: %s: %m", host);
-		t->state = THD_FAILED;
-		t->job->host_state[t->nodeid] = SRUN_HOST_REPLIED;
-	} else {
-		t->state = THD_DONE;
-		t->job->host_state[t->nodeid] = SRUN_HOST_UNREACHABLE;
-	}
-	free(host);
-	slurm_mutex_lock(&active_mutex);
-	active--;
-	pthread_cond_signal(&active_cond);
-	slurm_mutex_unlock(&active_mutex);
-
-	return NULL;
-}
-
-
-int reattach()
-{
-	List          steplist = _step_list_create(opt.attach);
-	srun_step_t  *s        = NULL;
-	srun_job_t        *job      = NULL;
-	slurm_step_io_fds_t fds = SLURM_STEP_IO_FDS_INITIALIZER;
-
-	if ((steplist == NULL) || (list_count(steplist) == 0)) {
-		info("No job/steps in attach");
-		exit(1);
-	}
-
-	if (list_count(steplist) > 1)
-		info("Warning: attach to multiple jobs/steps not supported");
-	s = list_peek(steplist);
-
-	_get_attach_info(s);
-
-	if (!opt.join)
-		opt.ifname = "none";
-
-	if ((opt.nodelist = s->nodes) == NULL) 
-		exit(1);
-
-	if ((opt.nprocs = s->ntasks) == 0) 
-		exit(1);
-
-	/*
-	 * Indicate that nprocs has been manually set
-	 */
-	opt.nprocs_set = true;
-
-	if (!(job = job_create_noalloc()))
-		exit(1);
-
-	job->jobid  = s->jobid;
-	job->stepid = s->stepid;
-	
-	if (job->stepid == NO_VAL) {
-		char *new_argv0 = NULL;
-		xstrfmtcat(new_argv0, "attach[%d]", job->jobid);
-		log_set_argv0(new_argv0);
-	}
-
-	/*
-	 * mask and handle certain signals iff we are "joining" with
-	 * the job in question. If opt.join is off, attached srun is in
-	 * "read-only" mode and cannot forward stdin/signals.
-	 */
-	if (opt.join)
-		sig_setup_sigmask();
-
-	if (msg_thr_create(job) < 0) {
-		error("Unable to create msg thread: %m");
-		exit(1);
-	}
-
-	srun_set_stdio_fds(job, &fds);
-	job->client_io = client_io_handler_create(fds,
-						  job->step_layout->task_cnt,
-						  job->step_layout->node_cnt,
-						  job->cred,
-						  opt.labelio);
-	if (!job->client_io
-	    || (client_io_handler_start(job->client_io) != SLURM_SUCCESS))
-		job_fatal(job, "failed to start IO handler");
-
-	if (opt.join && sig_thr_create(job) < 0) {
-		error("Unable to create signals thread: %m");
-	}
-
-	_attach_to_job(job);
-
-	if (invalid_user)
-		exit(1);
-
-	slurm_mutex_lock(&job->state_mutex);
-	while (job->state < SRUN_JOB_TERMINATED) {
-		pthread_cond_wait(&job->state_cond, &job->state_mutex);
-	}
-	slurm_mutex_unlock(&job->state_mutex);
-
-	if (job->state == SRUN_JOB_FAILED)
-		info("Job terminated abnormally.");
-
-	/*
-	 *  Signal the IO thread to shutdown, which will stop
-	 *  the listening socket and file read (stdin) event
-	 *  IO objects, but allow file write (stdout) objects to
-	 *  complete any writing that remains.
-	 */
-	debug("Waiting for IO thread");
-	if (client_io_handler_finish(job->client_io) != SLURM_SUCCESS)
-		error ("IO handler did not finish correctly (reattach): %m");
-	client_io_handler_destroy(job->client_io);
-
-	/* kill msg server thread */
-	pthread_kill(job->jtid, SIGHUP);
-
-	/* _complete_job(job); */
-	
-	exit(0);
-}
diff --git a/src/srun/signals.c b/src/srun/signals.c
deleted file mode 100644
index 3a40abbf77cc70b37c21f5d8b198756e337c6db0..0000000000000000000000000000000000000000
--- a/src/srun/signals.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*****************************************************************************\
- *  src/srun/signals.c - signal handling for srun
- *****************************************************************************
- *  Copyright (C) 2002-2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona@llnl.gov>, and
- *             Morris Jette  <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  In addition, as a special exception, the copyright holders give permission 
- *  to link the code of portions of this program with the OpenSSL library under
- *  certain conditions as described in each individual source file, and 
- *  distribute linked combinations including the two. You must obey the GNU 
- *  General Public License in all respects for all of the code used other than 
- *  OpenSSL. If you modify file(s) with this exception, you may extend this 
- *  exception to your version of the file(s), but you are not obligated to do 
- *  so. If you do not wish to do so, delete this exception statement from your
- *  version.  If you delete this exception statement from all source files in 
- *  the program, then also delete it here.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#if HAVE_PTHREAD
-#include <pthread.h>
-#endif
-
-#include <signal.h>
-#include <string.h>
-
-#include <slurm/slurm_errno.h>
-
-#include "src/common/log.h"
-#include "src/common/macros.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/slurm_protocol_defs.h"
-#include "src/common/xmalloc.h"
-#include "src/common/xstring.h"
-#include "src/common/xsignal.h"
-
-#include "src/srun/opt.h"
-#include "src/srun/srun_job.h"
-#include "src/srun/signals.h"
-
-#define MAX_RETRIES 3
-
-/*
- *  Static list of signals to block in srun:
- */
-static int srun_sigarray[] = {
-	SIGINT,  SIGQUIT, /*SIGTSTP,*/ SIGCONT, SIGTERM,
-	SIGALRM, SIGUSR1, SIGUSR2, SIGPIPE, 0
-};
-
-/* 
- * Static prototypes
- */
-static void   _sigterm_handler(int);
-static void   _handle_intr(srun_job_t *, time_t *, time_t *); 
-static void * _sig_thr(void *);
-
-static inline bool 
-_sig_thr_done(srun_job_t *job)
-{
-	bool retval;
-	slurm_mutex_lock(&job->state_mutex);
-	retval = (job->state >= SRUN_JOB_DONE);
-	slurm_mutex_unlock(&job->state_mutex);
-	return retval;
-}
-
-int
-sig_setup_sigmask(void)
-{
-	if (xsignal_block(srun_sigarray) < 0)
-		return SLURM_ERROR;
-
-	xsignal(SIGHUP,  &_sigterm_handler);
-
-	return SLURM_SUCCESS;
-}
-
-int 
-sig_unblock_signals(void)
-{
-	return xsignal_unblock(srun_sigarray);
-}
-
-int 
-sig_thr_create(srun_job_t *job)
-{
-	int e, retries = 0;
-	pthread_attr_t attr;
-
-	slurm_attr_init(&attr);
-
-	while ((e = pthread_create(&job->sigid, &attr, &_sig_thr, job))) {
-		if (++retries > MAX_RETRIES) {
-			slurm_attr_destroy(&attr);
-			slurm_seterrno_ret(e);
-		}
-		sleep(1);	/* sleep and try again */
-	}
-	slurm_attr_destroy(&attr);
-
-	debug("Started signals thread (%lu)", (unsigned long) job->sigid);
-
-	return SLURM_SUCCESS;
-}
-
-
-static void
-_sigterm_handler(int signum)
-{
-}
-
-static void
-_handle_intr(srun_job_t *job, time_t *last_intr, time_t *last_intr_sent)
-{
-	if (opt.quit_on_intr) {
-		job_force_termination(job);
-		pthread_exit (0);
-	}
-
-	if (((time(NULL) - *last_intr) > 1) && !opt.disable_status) {
-		info("interrupt (one more within 1 sec to abort)");
-		if (mode != MODE_ATTACH)
-			report_task_status(job);
-		*last_intr = time(NULL);
-	} else  { /* second Ctrl-C in half as many seconds */
-		update_job_state(job, SRUN_JOB_CANCELLED);
-		/* terminate job */
-		if (job->state < SRUN_JOB_FORCETERM) {
-			if ((time(NULL) - *last_intr_sent) < 1) {
-				job_force_termination(job);
-				pthread_exit(0);
-			}
-
-			info("sending Ctrl-C to job");
-			*last_intr_sent = time(NULL);
-			fwd_signal(job, SIGINT, opt.max_threads);
-
-		} else {
-			job_force_termination(job);
-		}
-	}
-}
-
-/* simple signal handling thread */
-static void *
-_sig_thr(void *arg)
-{
-	srun_job_t *job = (srun_job_t *)arg;
-	sigset_t set;
-	time_t last_intr      = 0;
-	time_t last_intr_sent = 0;
-	int signo, err;
-
-	while (!_sig_thr_done(job)) {
-
-		xsignal_sigset_create(srun_sigarray, &set);
-
-		if ((err = sigwait(&set, &signo)) != 0) {
-			if (err != EINTR) 
-				error ("sigwait: %s", slurm_strerror (err));
-			continue;
-		}
-
-		debug2("recvd signal %d", signo);
-		switch (signo) {
-		  case SIGINT:
-			  _handle_intr(job, &last_intr, &last_intr_sent);
-			  break;
-		  /* case SIGTSTP: */
-/* 			debug3("got SIGTSTP"); */
-/* 			break; */
-		  case SIGCONT:
-			debug3("got SIGCONT");
-			break;
-		  case SIGQUIT:
-			info("Quit");
-			job_force_termination(job);
-			break;
-		  default:
-			fwd_signal(job, signo, opt.max_threads);
-			break;
-		}
-	}
-
-	pthread_exit(0);
-	return NULL;
-}
-
-
-
diff --git a/src/srun/srun.c b/src/srun/srun.c
index 82b01cd39ad14b1d60739fed76384b7f491f70d9..3a67fc6f70011dd5af13e07b2df5acb9b62786ed 100644
--- a/src/srun/srun.c
+++ b/src/srun/srun.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -65,10 +65,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
+#include <termios.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <grp.h>
 
+
 #include "src/common/fd.h"
 #include "src/common/log.h"
 #include "src/common/slurm_protocol_api.h"
@@ -80,17 +82,17 @@
 #include "src/common/mpi.h"
 #include "src/common/slurm_rlimits_info.h"
 #include "src/common/plugstack.h"
+#include "src/common/read_config.h"
 
 #include "src/srun/allocate.h"
 #include "src/srun/srun_job.h"
-#include "src/srun/launch.h"
-#include "src/srun/msg.h"
 #include "src/srun/opt.h"
-#include "src/srun/sigstr.h"
-#include "src/srun/reattach.h"
-#include "src/srun/attach.h"
+#include "src/srun/debugger.h"
 #include "src/srun/srun.h"
-#include "src/srun/signals.h"
+#include "src/srun/srun_pty.h"
+#include "src/srun/multi_prog.h"
+#include "src/api/pmi_server.h"
+#include "src/api/step_launch.h"
 
 #define MAX_RETRIES 20
 #define MAX_ENTRIES 50
@@ -100,57 +102,70 @@
 #define	TYPE_SCRIPT	2
 
 mpi_plugin_client_info_t mpi_job_info[1];
-pid_t srun_ppid = 0;
+static struct termios termdefaults;
+int global_rc;
+srun_job_t *job = NULL;
+
+struct {
+	bitstr_t *start_success;
+	bitstr_t *start_failure;
+	bitstr_t *finish_normal;
+	bitstr_t *finish_abnormal;
+} task_state;
 
 /*
  * forward declaration of static funcs
  */
 static void  _print_job_information(resource_allocation_response_msg_t *resp);
-static char *_build_script (const char *argv0, char *pathname, int file_type);
-static char *_get_shell (void);
-static void  _send_options(const int argc, char **argv);
-static void  _get_options (const char *buffer);
-static char *_get_token(char *buf_ptr);
-static int   _is_file_text (char *, char**);
-static int   _run_batch_job (const char *argv0);
-static int   _run_job_script(srun_job_t *job, env_t *env);
 static void  _set_prio_process_env(void);
 static int   _set_rlimit_env(void);
 static int   _set_umask_env(void);
 static char *_uint16_array_to_str(int count, const uint16_t *array);
-static void  _switch_standalone(srun_job_t *job);
 static int   _become_user (void);
-static int   _print_script_exit_status(const char *argv0, int status);
 static void  _run_srun_prolog (srun_job_t *job);
 static void  _run_srun_epilog (srun_job_t *job);
 static int   _run_srun_script (srun_job_t *job, char *script);
-static int   _change_rlimit_rss(void);
 static int   _slurm_debug_env_val (void);
 static int   _call_spank_local_user (srun_job_t *job);
+static void  _set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds);
 static void  _define_symbols(void);
+static void  _pty_restore(void);
+static void  _step_opt_exclusive(void);
+static void _task_start(launch_tasks_response_msg_t *msg);
+static void _task_finish(task_exit_msg_t *msg);
+static void _task_state_struct_init(int num_tasks);
+static void _task_state_struct_print(void);
+static void _task_state_struct_free(void);
+static void _handle_intr();
+static void _handle_signal(int signo);
+static int _setup_signals();
 
 int srun(int ac, char **av)
 {
 	resource_allocation_response_msg_t *resp;
-	srun_job_t *job = NULL;
-	int exitcode = 0;
 	env_t *env = xmalloc(sizeof(env_t));
 	uint32_t job_id = 0;
 	log_options_t logopt = LOG_OPTS_STDERR_ONLY;
-	slurm_step_io_fds_t fds = SLURM_STEP_IO_FDS_INITIALIZER;
-	char **mpi_env = NULL;
-	mpi_plugin_client_state_t *mpi_state;
-	
+	slurm_step_launch_params_t launch_params;
+	slurm_step_launch_callbacks_t callbacks;
+	int got_alloc = 0;
+
 	env->stepid = -1;
 	env->procid = -1;
 	env->localid = -1;
 	env->nodeid = -1;
 	env->cli = NULL;
 	env->env = NULL;
+	env->ckpt_path = NULL;
 
 	logopt.stderr_level += _slurm_debug_env_val();
 	log_init(xbasename(av[0]), logopt, 0, NULL);
 
+/* 	xsignal(SIGQUIT, _ignore_signal); */
+/* 	xsignal(SIGPIPE, _ignore_signal); */
+/* 	xsignal(SIGUSR1, _ignore_signal); */
+/* 	xsignal(SIGUSR2, _ignore_signal); */
+
 	/* Initialize plugin stack, read options from plugins, etc.
 	 */
 	if (spank_init(NULL) < 0) {
@@ -170,7 +185,7 @@ int srun(int ac, char **av)
 		error ("srun initialization failed");
 		exit (1);
 	}
-	srun_ppid = getppid();
+	record_ppid();
 	
 	/* reinit log with new verbosity (if changed by command line)
 	 */
@@ -185,14 +200,13 @@ int srun(int ac, char **av)
 		log_alter(logopt, 0, NULL);
 	}
 
-	if (!opt.allocate) {
-		(void) _set_rlimit_env();
-		_set_prio_process_env();
-		(void) _set_umask_env();
-	}
+	(void) _set_rlimit_env();
+	_set_prio_process_env();
+	(void) _set_umask_env();
+	
 	/* Set up slurmctld message handler */
 	slurmctld_msg_init();
-	
+
 	/* now global "opt" should be filled in and available,
 	 * create a job from opt
 	 */
@@ -202,96 +216,28 @@ int srun(int ac, char **av)
 			slurm_perror("allocation failure");
 			exit (1);
 		}
-		info("allocation success");
-		exit (0);
-
-	} else if (opt.batch) {
-	    	/* allow binding with batch submissions */
-		env->distribution = opt.distribution;
-		env->cpu_bind_type = opt.cpu_bind_type;
-		env->cpu_bind = opt.cpu_bind;
-		env->mem_bind_type = opt.mem_bind_type;
-		env->mem_bind = opt.mem_bind;
-		setup_env(env);
-
-		if (_run_batch_job(av[0]) < 0)
-			exit (1);
 		exit (0);
 
 	} else if (opt.no_alloc) {
 		info("do not allocate resources");
-		sig_setup_sigmask();
 		job = job_create_noalloc(); 
-		_switch_standalone(job);
-
-	} else if (opt.allocate) {
-		sig_setup_sigmask();
-		if ( !(resp = allocate_nodes()) ) 
+		if (create_job_step(job) < 0) {
 			exit(1);
-		if (opt.noshell) {
-			fprintf (stdout, "SLURM_JOBID=%u\n", resp->job_id);
-			exit (0);
 		}
-		if (_become_user () < 0)
-			info ("Warning: unable to assume uid=%lu\n", opt.uid);
-		_print_job_information(resp);
-		
-		job = job_create_allocation(resp);
-		if(!job)
-			exit(1);
-		
-		job->step_layout = 
-			fake_slurm_step_layout_create(resp->node_list,
-						      resp->cpus_per_node,
-						      resp->cpu_count_reps,
-						      resp->node_cnt, 0);
-		if(!job->step_layout)
-			exit(1);
-		if (msg_thr_create(job) < 0)
-			job_fatal(job, "Unable to create msg thread");
-		exitcode = _run_job_script(job, env);
-
-		/* close up the msg thread cleanly */
-		close(job->forked_msg->msg_par->msg_pipe[1]);
-		debug2("Waiting for message thread");
-		if (pthread_join(job->jtid, NULL) < 0)
-			error ("Waiting on message thread: %m");
-		debug2("done");
-
-		srun_job_destroy(job,exitcode);
-
-		debug ("Spawned srun shell terminated");
-		xfree(env->task_count);
-		xfree(env);
-		exit (exitcode);
-
 	} else if ((resp = existing_allocation())) {
 		job_id = resp->job_id;
 		if (opt.alloc_nodelist == NULL)
                        opt.alloc_nodelist = xstrdup(resp->node_list);
-
-		if (opt.allocate) {
-			error("job %u already has an allocation",
-			      job_id);
-			slurm_free_resource_allocation_response_msg(resp);
-			exit(1);
-		}
+		if (opt.exclusive)
+			_step_opt_exclusive();
 
 		job = job_step_create_allocation(resp);
 		slurm_free_resource_allocation_response_msg(resp);
 
-		if(!job)
-			exit(1);
-		
-		job->old_job = true;
-		sig_setup_sigmask();
-			
-		if (create_job_step(job) < 0)
+		if (!job || create_job_step(job) < 0)
 			exit(1);
-	} else if (mode == MODE_ATTACH) {
-		reattach();
-		exit (0);
 	} else {
+		got_alloc = 1;
 		/* Combined job allocation and job step launch */
 #ifdef HAVE_FRONT_END
 		uid_t my_uid = getuid();
@@ -301,18 +247,14 @@ int srun(int ac, char **av)
 			exit(1);
 		}
 #endif
-		if (opt.job_max_memory > 0) {		
-			(void) _change_rlimit_rss();
-		}
-		sig_setup_sigmask();
+	
 		if ( !(resp = allocate_nodes()) ) 
 			exit(1);
 		_print_job_information(resp);
 		job = job_create_allocation(resp);
-		if(!job)
-			exit(1);
-		if (create_job_step(job) < 0) {
-			srun_job_destroy(job, 0);
+		opt.exclusive = false;	/* not applicable for this step */
+		if (!job || create_job_step(job) < 0) {
+			slurm_complete_job(job->jobid, 1);
 			exit(1);
 		}
 		
@@ -325,11 +267,6 @@ int srun(int ac, char **av)
 	if (_become_user () < 0)
 		info ("Warning: Unable to assume uid=%lu\n", opt.uid);
 
-	/* job structure should now be filled in */
-
-	if (_call_spank_local_user (job) < 0)
-		job_fatal(job, "Failure in local plugin stack");
-
 	/*
 	 *  Enhance environment for job
 	 */
@@ -353,144 +290,152 @@ int srun(int ac, char **av)
 	env->labelio = opt.labelio;
 	env->comm_port = slurmctld_comm_addr.port;
 	env->comm_hostname = slurmctld_comm_addr.hostname;
-	if(job) {
+	if (job) {
+		uint16_t *tasks = NULL;
+		slurm_step_ctx_get(job->step_ctx, SLURM_STEP_CTX_TASKS, 
+				   &tasks);
+
 		env->select_jobinfo = job->select_jobinfo;
 		env->nhosts = job->nhosts;
 		env->nodelist = job->nodelist;
 		env->task_count = _uint16_array_to_str(
-			job->nhosts, job->step_layout->tasks);
+			job->nhosts, tasks);
 		env->jobid = job->jobid;
 		env->stepid = job->stepid;
 	}
+	if (opt.pty) {
+		struct termios term;
+		int fd = STDIN_FILENO;
+
+		/* Save terminal settings for restore */
+		tcgetattr(fd, &termdefaults); 
+		tcgetattr(fd, &term);
+		/* Set raw mode on local tty */
+		cfmakeraw(&term);
+		tcsetattr(fd, TCSANOW, &term);
+		atexit(&_pty_restore);
+
+		set_winsize(job);
+		block_sigwinch();
+		pty_thread_create(job);
+		env->pty_port = job->pty_port;
+		env->ws_col   = job->ws_col;
+		env->ws_row   = job->ws_row;
+	}
 	setup_env(env);
 	xfree(env->task_count);
 	xfree(env);
 	
-	_run_srun_prolog(job);
+	_task_state_struct_init(opt.nprocs);
+	slurm_step_launch_params_t_init(&launch_params);
+	launch_params.gid = opt.gid;
+	launch_params.argc = opt.argc;
+	launch_params.argv = opt.argv;
+	launch_params.multi_prog = opt.multi_prog ? true : false;
+	launch_params.cwd = opt.cwd;
+	launch_params.slurmd_debug = opt.slurmd_debug;
+	launch_params.buffered_stdio = !opt.unbuffered;
+	launch_params.labelio = opt.labelio ? true : false;
+	launch_params.remote_output_filename =fname_remote_string(job->ofname);
+	launch_params.remote_input_filename = fname_remote_string(job->ifname);
+	launch_params.remote_error_filename = fname_remote_string(job->efname);
+	launch_params.task_prolog = opt.task_prolog;
+	launch_params.task_epilog = opt.task_epilog;
+	launch_params.cpu_bind = opt.cpu_bind;
+	launch_params.cpu_bind_type = opt.cpu_bind_type;
+	launch_params.mem_bind = opt.mem_bind;
+	launch_params.mem_bind_type = opt.mem_bind_type;	
+	launch_params.open_mode = opt.open_mode;
+	if (opt.acctg_freq >= 0)
+		launch_params.acctg_freq = opt.acctg_freq;
+	launch_params.pty = opt.pty;
+	launch_params.max_sockets     = opt.max_sockets_per_node;
+	launch_params.max_cores       = opt.max_cores_per_socket;
+	launch_params.max_threads     = opt.max_threads_per_core;
+	launch_params.cpus_per_task = opt.cpus_per_task;
+	launch_params.ntasks_per_node   = opt.ntasks_per_node;
+	launch_params.ntasks_per_socket = opt.ntasks_per_socket;
+	launch_params.ntasks_per_core   = opt.ntasks_per_core;
+	launch_params.ckpt_path = xstrdup(opt.ckpt_path);
 
-	if (msg_thr_create(job) < 0)
-		job_fatal(job, "Unable to create msg thread");
-
-	mpi_job_info->jobid = job->jobid;
-	mpi_job_info->stepid = job->stepid;
-	mpi_job_info->step_layout = job->step_layout;
-	if (!(mpi_state = mpi_hook_client_prelaunch(mpi_job_info, &mpi_env)))
-		job_fatal (job, "Failed to initialize MPI");
-	env_array_set_environment(mpi_env);
-	env_array_free(mpi_env);
-
-	srun_set_stdio_fds(job, &fds);
-	job->client_io = client_io_handler_create(fds,
-						  job->step_layout->task_cnt,
-						  job->step_layout->node_cnt,
-						  job->cred,
-						  opt.labelio);
-	if (!job->client_io
-	    || (client_io_handler_start(job->client_io)	!= SLURM_SUCCESS))
-		job_fatal(job, "failed to start IO handler");
-
-	if (sig_thr_create(job) < 0)
-		job_fatal(job, "Unable to create signals thread: %m");
-	
-	if (launch_thr_create(job) < 0)
- 		job_fatal(job, "Unable to create launch thread: %m");
-	
-	/* wait for job to terminate 
-	 */
-	slurm_mutex_lock(&job->state_mutex);
-	while (job->state < SRUN_JOB_TERMINATED) {
-		pthread_cond_wait(&job->state_cond, &job->state_mutex);
+	/* job structure should now be filled in */
+	_setup_signals();
+
+	_set_stdio_fds(job, &launch_params.local_fds);
+
+	if (MPIR_being_debugged) {
+		launch_params.parallel_debug = true;
+		pmi_server_max_threads(1);
+	} else {
+		launch_params.parallel_debug = false;
 	}
-	slurm_mutex_unlock(&job->state_mutex);
-	
-	/* job is now overdone, clean up  
-	 *
-	 * If job is "forcefully terminated" exit immediately.
-	 *
-	 */
-	if (job->state == SRUN_JOB_FORCETERM) {
-		info("Force Terminated job");
-		srun_job_destroy(job, 0);
-		exit(1);
-	} else if (job->state == SRUN_JOB_CANCELLED) {
-		info("Cancelling job");
-		srun_job_destroy(job, NO_VAL);
-		exit(1);
-	} else if (job->state == SRUN_JOB_FAILED) {
-		/* This check here is to check if the job failed
-		   because we (srun or slurmd or slurmstepd wasn't
-		   able to fork or make a thread or something we still
-		   need the job failed check below incase the job
-		   failed on it's own.
-		*/
-		info("Job Failed");
-		srun_job_destroy(job, NO_VAL);
+	callbacks.task_start = _task_start;
+	callbacks.task_finish = _task_finish;
+
+	_run_srun_prolog(job);
+
+	mpir_init(job->ctx_params.task_count);
+
+	if (_call_spank_local_user (job) < 0) {
+		error("Failure in local plugin stack");
+		slurm_step_launch_abort(job->step_ctx);
 		exit(1);
 	}
 
-	/*
-	 *  We want to make sure we get the correct state of the job
-	 *  and not finish before all the messages have been sent.
-	 */
-	if (job->state == SRUN_JOB_FAILED)
-		close(job->forked_msg->msg_par->msg_pipe[1]);
-	debug("Waiting for message thread");
-	if (pthread_join(job->jtid, NULL) < 0)
-		error ("Waiting on message thread: %m");
-	debug("done");
-	
-	/* have to check if job was cancelled here just to make sure 
-	   state didn't change when we were waiting for the message thread */
-	exitcode = set_job_rc(job);
-	if (job->state == SRUN_JOB_CANCELLED) {
-		info("Cancelling job");
-		srun_job_destroy(job, NO_VAL);
-	} else if (job->state == SRUN_JOB_FAILED) {
-		info("Terminating job");
-		srun_job_destroy(job, job->rc);
-	} else 
-		srun_job_destroy(job, job->rc);
-		
-	/* wait for launch thread */
-	if (pthread_join(job->lid, NULL) < 0)
-		error ("Waiting on launch thread: %m");
+	update_job_state(job, SRUN_JOB_LAUNCHING);
+	if (slurm_step_launch(job->step_ctx, slurmctld_comm_addr.hostname, 
+	    &launch_params, &callbacks) != SLURM_SUCCESS) {
+		error("Application launch failed: %m");
+		goto cleanup;
+	}
 
-	/*
-	 *  Signal the IO thread to shutdown, which will stop
-	 *  the listening socket and file read (stdin) event
-	 *  IO objects, but allow file write (stdout) objects to
-	 *  complete any writing that remains.
-	 */
-	debug("Waiting for IO thread");
-	if (client_io_handler_finish(job->client_io) != SLURM_SUCCESS)
-		error ("IO handler did not finish correctly: %m");
-	client_io_handler_destroy(job->client_io);
-	debug("done");
-	
-	
-	if (mpi_hook_client_fini (mpi_state) < 0)
-		; /* eh, ignore errors here */
+	update_job_state(job, SRUN_JOB_STARTING);
+	if (slurm_step_launch_wait_start(job->step_ctx) == SLURM_SUCCESS) {
+		update_job_state(job, SRUN_JOB_RUNNING);
+		/* Only set up MPIR structures if the step launched
+		   correctly. */
+		if (opt.multi_prog)
+			mpir_set_multi_name(job->ctx_params.task_count,
+					    launch_params.argv[0]);
+		else
+			mpir_set_executable_names(launch_params.argv[0]);
+		MPIR_debug_state = MPIR_DEBUG_SPAWNED;
+		MPIR_Breakpoint();
+		if (opt.debugger_test)
+			mpir_dump_proctable();
+	} else {
+		info("Job step aborted before step completely launched.");
+	}
 
-	_run_srun_epilog(job);
+	slurm_step_launch_wait_finish(job->step_ctx);
 
-	/* 
-	 *  Let exit() clean up remaining threads.
-	 */
+cleanup:
+	if(got_alloc) {
+		cleanup_allocation();
+		slurm_complete_job(job->jobid, global_rc);
+	}
+	_run_srun_epilog(job);
+	slurm_step_ctx_destroy(job->step_ctx);
+	mpir_cleanup();
+	_task_state_struct_free();
 	log_fini();
-	exit(exitcode);
+
+	return global_rc;
 }
 
 static int _call_spank_local_user (srun_job_t *job)
 {
 	struct spank_launcher_job_info info[1];
+	job_step_create_response_msg_t *step_resp;
 
 	info->uid = opt.uid;
 	info->gid = opt.gid;
 	info->jobid = job->jobid;
 	info->stepid = job->stepid;
-	info->step_layout = job->step_layout;	
-	info->argc = remote_argc;
-	info->argv = remote_argv;
+	slurm_step_ctx_get(job->step_ctx, SLURM_STEP_CTX_RESP, &step_resp);
+	info->step_layout = step_resp->step_layout;
+	info->argc = opt.argc;
+	info->argv = opt.argv;
 
 	return spank_local_user(info);
 }
@@ -554,21 +499,6 @@ static char *_uint16_array_to_str(int array_len, const uint16_t *array)
 	return str;
 }
 
-static void
-_switch_standalone(srun_job_t *job)
-{
-	int cyclic = (opt.distribution == SLURM_DIST_CYCLIC);
-
-	if (switch_alloc_jobinfo(&job->switch_job) < 0)
-		fatal("switch_alloc_jobinfo: %m");
-	if (switch_build_jobinfo(job->switch_job, 
-				 job->nodelist, 
-				 job->step_layout->tasks, 
-				 cyclic, opt.network) < 0)
-		fatal("switch_build_jobinfo: %m");
-}
-
-
 static void 
 _print_job_information(resource_allocation_response_msg_t *resp)
 {
@@ -592,301 +522,6 @@ _print_job_information(resource_allocation_response_msg_t *resp)
 	verbose("%s",job_details);
 }
 
-
-/* submit a batch job and return error code */
-static int
-_run_batch_job(const char *argv0)
-{
-	int file_type, retries = 0;
-	int rc = SLURM_SUCCESS;
-	job_desc_msg_t *req;
-	submit_response_msg_t *resp;
-	char *script;
-	static char *msg = "Slurm job queue full, sleeping and retrying.";
-
-	if ((remote_argc == 0) || (remote_argv[0] == NULL))
-		return SLURM_ERROR;
-
-	file_type = _is_file_text (remote_argv[0], NULL);
-
-	/* if (file_type == TYPE_NOT_TEXT) {
-         *	error ("file %s is not script", remote_argv[0]);
-	 *	return SLURM_ERROR;
-	 * }
-	 */
-
-	if ((script = _build_script (argv0, remote_argv[0], file_type))
-	    == NULL) {
-		error ("unable to build script from file %s", remote_argv[0]);
-		return SLURM_ERROR;
-	}
-
-	if (!(req = job_desc_msg_create_from_opts (script)))
-		fatal ("Unable to create job request");
-
-	/* Do not re-use existing job id from environment variable
-	 * when submitting new job from within a running job */
-	if (!opt.jobid_set)
-		req->job_id = NO_VAL;
-
-	while ((rc = slurm_submit_batch_job(req, &resp)) < 0) {
-		if ((errno != ESLURM_ERROR_ON_DESC_TO_RECORD_COPY) ||
-		    (retries >= MAX_RETRIES))
-			return (error("Unable to submit batch job: %m"));
-		
-		if (retries == 0)
-			error(msg);
-		else
-			debug(msg);
-		sleep (++retries);
-	}
-
-	
-	if (rc == SLURM_SUCCESS) {
-		if (resp->step_id == NO_VAL)
-			info ("jobid %u submitted",resp->job_id);
-		else
-			info ("jobid %u.%u submitted",resp->job_id,
-							resp->step_id);
-		if (resp->error_code) {
-			if (opt.immediate) {
-				error("Job failed: %s", 
-					slurm_strerror(resp->error_code));
-				rc = resp->error_code;
-			} else {
-				info("Warning: %s", 
-					slurm_strerror(resp->error_code));
-			}
-		}
-		slurm_free_submit_response_response_msg (resp);
-	}
-
-	job_desc_msg_destroy (req);
-	xfree (script);
-
-	return (rc);
-}
-
-static void _send_options(const int argc, char **argv)
-{
-	int i;
-	
-	set_options(argc, argv, 0);
-	for(i=1; i<argc; i++) {
-		debug3("argv[%d] = %s.",i,argv[i]);
-		xfree(argv[i]);
-	}
-}
-
-/* _get_shell - return a string containing the default shell for this user
- * NOTE: This function is NOT reentrant (see getpwuid_r if needed) */
-static char *
-_get_shell (void)
-{
-	struct passwd *pw_ent_ptr;
-
-	pw_ent_ptr = getpwuid (opt.uid);
-	if ( ! pw_ent_ptr ) {
-		pw_ent_ptr = getpwnam( "nobody" );
-		info( "warning - no user information for user %d", opt.uid );
-	}
-	return pw_ent_ptr->pw_shell;
-}
-
-static char *_get_token(char *buf_ptr)
-{
-	int i, token_size = 0;
-	char *token;
-
-	for (i=1; (buf_ptr[i] != '\n') && (buf_ptr[i] != '\0');
-			i++) {
-		if (isspace(buf_ptr[i]))
-			break;
-	}
-	token_size = i;
-
-	token = xmalloc(token_size + 1);
-	strncpy(token, buf_ptr, token_size);
-	return token;
-}
-
-/* _get_opts - gather options put in user script.  Used for batch scripts. */
-static void
-_get_options (const char *buffer)
-{
-	int argc = 1;
-	char *argv[MAX_ENTRIES];
-	char *buf_loc = (char *) buffer;
-
-	while ((buf_loc = strstr(buf_loc, "#SLURM"))) {
-		buf_loc += 6;
-		/* find the tokens and move them to argv */
-		for ( ; ((buf_loc[0] != '\n') && (buf_loc[0] != '\0')); 
-				buf_loc++) {
-			if (isspace(buf_loc[0]))
-				continue;
-			argv[argc] = _get_token(buf_loc);
-			buf_loc += (strlen(argv[argc]) - 1);
-			argc++;
-		}
-	}
-	if(argc > 1)
-		_send_options(argc, argv);
-	return;
-}
-
-#define F 0	/* char never appears in text */
-#define T 1	/* character appears in plain ASCII text */
-#define I 2	/* character appears in ISO-8859 text */
-#define X 3     /* character appears in non-ISO extended ASCII */
-static char text_chars[256] = {
-	/*                  BEL BS HT LF    FF CR    */
-	F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F,  /* 0x0X */
-	/*                              ESC          */
-	F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F,  /* 0x1X */
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x2X */
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x3X */
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x4X */
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x5X */
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x6X */
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F,  /* 0x7X */
-	/*            NEL                            */
-	X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X,  /* 0x8X */
-	X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,  /* 0x9X */
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xaX */
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xbX */
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xcX */
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xdX */
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xeX */
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I   /* 0xfX */
-};
-
-
-/* _is_file_text - determine if specified file is a script
- * shell_ptr - if not NULL, set to pointer to pathname of specified shell 
- *		(if any, ie. return code of 2)
- *	return 0 if the specified file can not be read or does not contain text
- *	returns 2 if file contains text starting with "#!", otherwise
- *	returns 1 if file contains text, but lacks "#!" header 
- */
-static int
-_is_file_text (char *fname, char **shell_ptr)
-{
-	int buf_size, fd, i;
-	int rc = 1;	/* initially assume the file contains text */
-	unsigned char buffer[8192];
-
-	if (fname[0] != '/') {
-		info("warning: %s not found in local path", fname);
-		return 0;
-	}
-
-	fd = open(fname, O_RDONLY);
-	if (fd < 0) {
-		error ("Unable to open file %s: %m", fname);
-		return 0;
-	}
-
-	buf_size = read (fd, buffer, sizeof (buffer));
-	if (buf_size < 0) {
-		error ("Unable to read file %s: %m", fname);
-		rc = 0;
-	}
-	(void) close (fd);
-
-	for (i=0; i<buf_size; i++) {
-		if (((int) text_chars[buffer[i]] != T) 
-		&&  ((int) text_chars[buffer[i]] != I)) {
-			rc = 0;
-			break;
-		}
-	}
-
-	if ((rc == 1) && (buf_size > 2)) {
-		if ((buffer[0] == '#') && (buffer[1] == '!'))
-			rc = 2;
-	}
-
-	if ((rc == 2) && shell_ptr) {
-		shell_ptr[0] = xmalloc (sizeof (buffer));
-		for (i=2; i<sizeof(buffer); i++) {
-			if (iscntrl (buffer[i])) {
-				shell_ptr[0][i-2] = '\0';
-				break;
-			} else
-				shell_ptr[0][i-2] = buffer[i];
-		}
-		if (i == sizeof(buffer)) {
-			error ("shell specified in script too long, not used");
-			xfree (shell_ptr[0]);
-			shell_ptr[0] = NULL;
-		}
-	}
-
-	return rc;
-}
-
-/* allocate and build a string containing a script for a batch job */
-static char *
-_build_script (const char *argv0, char *fname, int file_type)
-{
-	cbuf_t cb = cbuf_create(512, 1048576);
-	int   fd     = -1;
-	int   i      =  0;
-	char *buffer = NULL;
-
-	if (file_type != 0) {
-		if ((fd = open(fname, O_RDONLY)) < 0) {
-			error ("Unable to open file %s: %m", fname);
-			return NULL;
-		}
-	}
-
-	if (file_type != TYPE_SCRIPT) {
-		xstrfmtcat(buffer, "#!%s\n", _get_shell());
-		if (file_type == 0) {
-			xstrfmtcat(buffer, "%s ", argv0); /* path to srun */
-			for (i = 0; i < remote_argc; i++)
-				xstrfmtcat(buffer, "%s ", remote_argv[i]);
-			xstrcatchar(buffer, '\n');
-		}
-	} 
-	
-	if (file_type != 0) {
-		int len = buffer ? strlen(buffer) : 0;
-		int size;
-
-		while ((size = cbuf_write_from_fd(cb, fd, -1, NULL)) > 0) 
-			;
-		
-		if (size < 0) {
-			error ("unable to read %s: %m", fname);
-			cbuf_destroy(cb);
-			return NULL;
-		}
-
-		cbuf_write(cb, "\0", 1, NULL);
-
-		xrealloc(buffer, cbuf_used(cb) + len +1);
-
-		cbuf_read(cb, buffer+len, cbuf_used(cb));
-
-		if (close(fd) < 0)
-			error("close: %m");
-	}
-	
-	cbuf_destroy(cb);
-
-	_get_options(buffer);
-
-	if (strlen(buffer) >= 0xffff) {
-		error("Job script exceeds size supported by slurm");
-		xfree(buffer);
-	}
-
-	return buffer;
-}
-
 /* Set SLURM_UMASK environment variable with current state */
 static int _set_umask_env(void)
 {
@@ -937,34 +572,6 @@ static void  _set_prio_process_env(void)
 	debug ("propagating SLURM_PRIO_PROCESS=%d", retval);
 }
 
-/* 
- *  Change SLURM_RLIMIT_RSS to the user specified value --job-mem 
- *  or opt.job_max_memory 
- */
-static int _change_rlimit_rss(void)
-{
-	struct rlimit        rlim[1];
-	long                 new_cur;
-	int                  rc = SLURM_SUCCESS;
-	
-	if (getrlimit (RLIMIT_RSS, rlim) < 0)
-		return (error ("getrlimit (RLIMIT_RSS): %m"));
-
-	new_cur = opt.job_max_memory*1024; 
-	if((new_cur > rlim->rlim_max) || (new_cur < 0))
-		rlim->rlim_cur = rlim->rlim_max;
-	else
-		rlim->rlim_cur = new_cur;
-
-	if (setenvf (NULL, "SLURM_RLIMIT_RSS", "%lu", rlim->rlim_cur) < 0)
-		error ("unable to set %s in environment", "RSS");
-
-	if (setrlimit (RLIMIT_RSS, rlim) < 0) 
-		return (error ("Unable to change memoryuse: %m"));
-
-	return rc;
-}
-
 /* Set SLURM_RLIMIT_* environment variables with current resource 
  * limit values, reset RLIMIT_NOFILE to maximum possible value */
 static int _set_rlimit_env(void)
@@ -1017,111 +624,6 @@ static int _set_rlimit_env(void)
 	return rc;
 }
 
-static int
-_print_script_exit_status(const char *argv0, int status)
-{
-	char *corestr = "";
-	int exitcode = 0;
-
-	if (status == 0) {
-		verbose("%s: Done", argv0);
-		return exitcode;
-	}
-
-#ifdef WCOREDUMP
-	if (WCOREDUMP(status))
-		corestr = " (core dumped)";
-#endif
-
-	if (WIFSIGNALED(status)) {
-		error("%s: %s%s", argv0, sigstr(status), corestr);
-		return WTERMSIG(status) + 128;
-	}
-	if (WEXITSTATUS(status))
-		error("%s: Exit %d", argv0, WEXITSTATUS(status));
-	return WEXITSTATUS(status);
-}
-
-/* allocation option specified, spawn a script and wait for it to exit */
-static int _run_job_script (srun_job_t *job, env_t *env)
-{
-	int   status, exitcode;
-	pid_t cpid;
-	char **argv = (remote_argv[0] ? remote_argv : NULL);
-
-	if (opt.nprocs_set)
-		env->nprocs = opt.nprocs;
-	if (opt.cpus_set)
-		env->cpus_per_task = opt.cpus_per_task;
-	if (opt.ntasks_per_node != NO_VAL)
-		env->ntasks_per_node = opt.ntasks_per_node;
-	if (opt.ntasks_per_socket != NO_VAL)
-		env->ntasks_per_socket = opt.ntasks_per_socket;
-	if (opt.ntasks_per_core != NO_VAL)
-		env->ntasks_per_core = opt.ntasks_per_core;
-	env->distribution = opt.distribution;
-	env->overcommit = opt.overcommit;
-	env->slurmd_debug = opt.slurmd_debug;
-	env->labelio = opt.labelio;
-	env->comm_port = slurmctld_comm_addr.port;
-	env->comm_hostname = slurmctld_comm_addr.hostname;
-	if(job) {
-		env->select_jobinfo = job->select_jobinfo;
-		env->jobid = job->jobid;
-		env->nhosts = job->nhosts;
-		env->nodelist = job->nodelist;
-		env->task_count = _uint16_array_to_str(
-			job->nhosts, job->step_layout->tasks);
-	}
-	
-	if (setup_env(env) != SLURM_SUCCESS) 
-		return SLURM_ERROR;
-
-	if (!argv) {
-		/*
-		 *  If no arguments were supplied, spawn a shell
-		 *    for the user.
-		 */
-		argv = xmalloc(2 * sizeof(char *));
-		argv[0] = _get_shell();
-		argv[1] = NULL;
-	}
-
-	if ((cpid = fork()) < 0) {
-		error("fork: %m");
-		exit(1);
-	} 
-
-	if (cpid == 0) { 
-		/*
-		 *  Child.
-		 */
-#ifdef HAVE_AIX
-		(void) mkcrid(0);
-#endif
-		log_fini();
-		sig_unblock_signals();
-		execvp(argv[0], argv);
-		exit(1);
-	}
-
-	/* 
-	 *  Parent continues.
-	 */
-
-    again:
-	if (waitpid(cpid, &status, 0) < (pid_t) 0) {
-		if (errno == EINTR)
-			goto again;
-		error("waitpid: %m");
-	}
-
-	exitcode = _print_script_exit_status(xbasename(argv[0]), status); 
-
-	(void) unsetenv("SLURM_JOBID");	/* no return code on some systems */
-	return exitcode;
-}
-
 static int _become_user (void)
 {
 	struct passwd *pwd = getpwuid (opt.uid);
@@ -1186,8 +688,8 @@ static int _run_srun_script (srun_job_t *job, char *script)
 		 */
 		args = xmalloc(sizeof(char *) * 1024);
 		args[0] = script;
-		for (i = 0; i < remote_argc; i++) {
-			args[i+1] = remote_argv[i];
+		for (i = 0; i < opt.argc; i++) {
+			args[i+1] = opt.argv[i];
 		}
 		args[i+1] = NULL;
 		execv(script, args);
@@ -1209,7 +711,7 @@ static int _run_srun_script (srun_job_t *job, char *script)
 }
 
 static int
-_is_local_file (io_filename_t *fname)
+_is_local_file (fname_t *fname)
 {
 	if (fname->name == NULL)
 		return 1;
@@ -1220,10 +722,25 @@ _is_local_file (io_filename_t *fname)
 	return ((fname->type != IO_PER_TASK) && (fname->type != IO_ONE));
 }
 
-void
-srun_set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds)
+static void
+_set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds)
 {
 	bool err_shares_out = false;
+	int file_flags;
+
+	if (opt.open_mode == OPEN_MODE_APPEND)
+		file_flags = O_CREAT|O_WRONLY|O_APPEND;
+	else if (opt.open_mode == OPEN_MODE_TRUNCATE)
+		file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC;
+	else {
+		slurm_ctl_conf_t *conf;
+		conf = slurm_conf_lock();
+		if (conf->job_file_append)
+			file_flags = O_CREAT|O_WRONLY|O_APPEND;
+		else
+			file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC;
+		slurm_conf_unlock();
+	}
 
 	/*
 	 * create stdin file descriptor
@@ -1237,9 +754,14 @@ srun_set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds)
 				fatal("Could not open stdin file: %m");
 		}
 		if (job->ifname->type == IO_ONE) {
+			job_step_create_response_msg_t *step_resp = NULL;
+			
+			slurm_step_ctx_get(job->step_ctx, SLURM_STEP_CTX_RESP,
+					   &step_resp);
+		
 			cio_fds->in.taskid = job->ifname->taskid;
 			cio_fds->in.nodeid = slurm_step_layout_host_id(
-				job->step_layout, job->ifname->taskid);
+				step_resp->step_layout, job->ifname->taskid);
 		}
 	}
 
@@ -1251,7 +773,7 @@ srun_set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds)
 			cio_fds->out.fd = STDOUT_FILENO;
 		} else {
 			cio_fds->out.fd = open(job->ofname->name,
-					       O_CREAT|O_WRONLY|O_TRUNC, 0644);
+					       file_flags, 0644);
 			if (cio_fds->out.fd == -1)
 				fatal("Could not open stdout file: %m");
 		}
@@ -1269,12 +791,13 @@ srun_set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds)
 	if (err_shares_out) {
 		debug3("stdout and stderr sharing a file");
 		cio_fds->err.fd = cio_fds->out.fd;
+		cio_fds->err.taskid = cio_fds->out.taskid;
 	} else if (_is_local_file(job->efname)) {
 		if ((job->efname->name == NULL) || (job->efname->taskid != -1)) {
 			cio_fds->err.fd = STDERR_FILENO;
 		} else {
 			cio_fds->err.fd = open(job->efname->name,
-					       O_CREAT|O_WRONLY|O_TRUNC, 0644);
+					       file_flags, 0644);
 			if (cio_fds->err.fd == -1)
 				fatal("Could not open stderr file: %m");
 		}
@@ -1290,3 +813,286 @@ static void _define_symbols(void)
 {
 	slurm_signal_job_step(0,0,0);	/* needed by mvapich and mpichgm */
 }
+
+static void _pty_restore(void)
+{
+	/* STDIN is probably closed by now */
+	if (tcsetattr(STDOUT_FILENO, TCSANOW, &termdefaults) < 0)
+		fprintf(stderr, "tcsetattr: %s\n", strerror(errno));
+}
+
+/* opt.exclusive is set, disable user task layout controls */
+static void _step_opt_exclusive(void)
+{
+	if (opt.nodes_set) {
+		verbose("ignoring node count set by --nodes or SLURM_NNODES");
+		verbose("  it is incompatible with --exclusive");
+		opt.nodes_set = false;
+		opt.min_nodes = 1;
+		opt.max_nodes = 0;
+	}
+	if (!opt.nprocs_set)
+		fatal("--nprocs must be set with --exclusive");
+	if (opt.relative_set)
+		fatal("--relative disabled, incompatible with --exclusive");
+	if (opt.exc_nodes)
+		fatal("--exclude is incompatible with --exclusive");
+	if (opt.nodelist)
+		fatal("--nodelist is incompatible with --exclusive");
+}
+
+static void
+_task_start(launch_tasks_response_msg_t *msg)
+{
+	MPIR_PROCDESC *table;
+	int taskid;
+	int i;
+
+	verbose("Node %s (%d), %d tasks started",
+		msg->node_name, msg->srun_node_id, msg->count_of_pids);
+
+	for (i = 0; i < msg->count_of_pids; i++) {
+		taskid = msg->task_ids[i];
+		table = &MPIR_proctable[taskid];
+		table->host_name = xstrdup(msg->node_name);
+		/* table->executable_name is set elsewhere */
+		table->pid = msg->local_pids[i];
+
+		if (msg->return_code == 0) {
+			bit_set(task_state.start_success, taskid);
+		} else {
+			bit_set(task_state.start_failure, taskid);
+		}
+	}
+
+}
+
+static void
+_terminate_job_step(slurm_step_ctx_t *step_ctx)
+{
+	uint32_t job_id, step_id;
+
+	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_JOBID, &job_id);
+	slurm_step_ctx_get(step_ctx, SLURM_STEP_CTX_STEPID, &step_id);
+	info("Terminating job step %u.%u", job_id, step_id);
+	slurm_kill_job_step(job_id, step_id, SIGKILL);
+}
+
+static void
+_handle_max_wait(int signo)
+{
+	info("First task exited %ds ago", opt.max_wait);
+	_task_state_struct_print();
+	_terminate_job_step(job->step_ctx);
+}
+
+static void
+_task_finish(task_exit_msg_t *msg)
+{
+	static bool first_done = true;
+	static bool first_error = true;
+	int rc = 0;
+	int i;
+
+	verbose("%d tasks finished (rc=%u)",
+		msg->num_tasks, msg->return_code);
+	if (WIFEXITED(msg->return_code)) {
+		rc = WEXITSTATUS(msg->return_code);
+		if (rc != 0) {
+			for (i = 0; i < msg->num_tasks; i++) {
+				error("task %u exited with exit code %d",
+				      msg->task_id_list[i], rc);
+				bit_set(task_state.finish_abnormal,
+					msg->task_id_list[i]);
+			}
+		} else {
+			for (i = 0; i < msg->num_tasks; i++) {
+				bit_set(task_state.finish_normal,
+					msg->task_id_list[i]);
+			}
+		}
+	} else if (WIFSIGNALED(msg->return_code)) {
+		for (i = 0; i < msg->num_tasks; i++) {
+			verbose("task %u killed by signal %d",
+				msg->task_id_list[i],
+				WTERMSIG(msg->return_code));
+			bit_set(task_state.finish_abnormal,
+				msg->task_id_list[i]);
+		}
+		rc = 1;
+	}
+	global_rc = MAX(global_rc, rc);
+
+	if (first_error && rc > 0 && opt.kill_bad_exit) {
+		first_error = false;
+		_terminate_job_step(job->step_ctx);
+	} else if (first_done && opt.max_wait > 0) {
+		/* If these are the first tasks to finish we need to
+		 * start a timer to kill off the job step if the other
+		 * tasks don't finish within opt.max_wait seconds.
+		 */
+		first_done = false;
+		debug2("First task has exited");
+		xsignal(SIGALRM, _handle_max_wait);
+		verbose("starting alarm of %d seconds", opt.max_wait);
+		alarm(opt.max_wait);
+	}
+}
+
+static void
+_task_state_struct_init(int num_tasks)
+{
+	task_state.start_success = bit_alloc(num_tasks);
+	task_state.start_failure = bit_alloc(num_tasks);
+	task_state.finish_normal = bit_alloc(num_tasks);
+	task_state.finish_abnormal = bit_alloc(num_tasks);
+}
+
+/*
+ * Tasks will most likely have bits set in multiple of the task_state
+ * bit strings (e.g. a task can start normally and then later exit normally)
+ * so we ensure that a task is only "seen" once.
+ */
+static void
+_task_state_struct_print(void)
+{
+	bitstr_t *tmp, *seen, *not_seen;
+	char buf[BUFSIZ];
+	int len;
+
+	len = bit_size(task_state.finish_abnormal); /* all the same length */
+	tmp = bit_alloc(len);
+	seen = bit_alloc(len);
+	not_seen = bit_alloc(len);
+	bit_not(not_seen);
+
+	if (bit_set_count(task_state.finish_abnormal) > 0) {
+		bit_copybits(tmp, task_state.finish_abnormal);
+		bit_and(tmp, not_seen);
+		bit_fmt(buf, BUFSIZ, tmp);
+		info("task%s: exited abnormally", buf);
+		bit_or(seen, tmp);
+		bit_copybits(not_seen, seen);
+		bit_not(not_seen);
+	}
+
+	if (bit_set_count(task_state.finish_normal) > 0) {
+		bit_copybits(tmp, task_state.finish_normal);
+		bit_and(tmp, not_seen);
+		bit_fmt(buf, BUFSIZ, tmp);
+		info("task%s: exited", buf);
+		bit_or(seen, tmp);
+		bit_copybits(not_seen, seen);
+		bit_not(not_seen);
+	}
+
+	if (bit_set_count(task_state.start_failure) > 0) {
+		bit_copybits(tmp, task_state.start_failure);
+		bit_and(tmp, not_seen);
+		bit_fmt(buf, BUFSIZ, tmp);
+		info("task%s: failed to start", buf);
+		bit_or(seen, tmp);
+		bit_copybits(not_seen, seen);
+		bit_not(not_seen);
+	}
+
+	if (bit_set_count(task_state.start_success) > 0) {
+		bit_copybits(tmp, task_state.start_success);
+		bit_and(tmp, not_seen);
+		bit_fmt(buf, BUFSIZ, tmp);
+		info("task%s: running", buf);
+		bit_or(seen, tmp);
+		bit_copybits(not_seen, seen);
+		bit_not(not_seen);
+	}
+}
+
+static void
+_task_state_struct_free(void)
+{
+	bit_free(task_state.start_success);
+	bit_free(task_state.start_failure);
+	bit_free(task_state.finish_normal);
+	bit_free(task_state.finish_abnormal);
+}
+	
+static void _handle_intr()
+{
+	static time_t last_intr      = 0;
+	static time_t last_intr_sent = 0;
+	if (opt.quit_on_intr) {
+		job_force_termination(job);
+		slurm_step_launch_abort(job->step_ctx);
+		return;
+	}
+
+	if (((time(NULL) - last_intr) > 1) && !opt.disable_status) {
+		info("interrupt (one more within 1 sec to abort)");
+		_task_state_struct_print();
+		last_intr = time(NULL);
+	} else  { /* second Ctrl-C in half as many seconds */
+		update_job_state(job, SRUN_JOB_CANCELLED);
+		/* terminate job */
+		if (job->state < SRUN_JOB_FORCETERM) {
+			if ((time(NULL) - last_intr_sent) < 1) {
+				job_force_termination(job);
+				slurm_step_launch_abort(job->step_ctx);
+				return;
+			}
+
+			info("sending Ctrl-C to job");
+			last_intr_sent = time(NULL);
+			slurm_step_launch_fwd_signal(job->step_ctx, SIGINT);
+
+		} else {
+			job_force_termination(job);
+			slurm_step_launch_abort(job->step_ctx);
+		}
+	}
+}
+
+static void _handle_signal(int signo)
+{
+	debug2("got signal %d", signo);
+
+	switch (signo) {
+	case SIGINT:
+		_handle_intr();
+		break;
+	case SIGQUIT:
+		info("Quit");
+		/* continue with slurm_step_launch_abort */
+	case SIGTERM:
+	case SIGHUP:
+		job_force_termination(job);
+		slurm_step_launch_abort(job->step_ctx);
+		break;
+	/* case SIGTSTP: */
+/* 		debug3("got SIGTSTP"); */
+/* 		break; */
+	case SIGCONT:
+		debug3("got SIGCONT");
+		break;
+	default:
+		slurm_step_launch_fwd_signal(job->step_ctx, signo);
+		break;
+	}
+}
+
+static int _setup_signals()
+{
+	int sigarray[] = {
+		SIGINT,  SIGQUIT, /*SIGTSTP,*/ SIGCONT, SIGTERM,
+		SIGALRM, SIGUSR1, SIGUSR2, SIGPIPE, 0
+	};
+	int rc = SLURM_SUCCESS, i=0, signo;
+
+	xassert(job);
+	xassert(job->step_ctx);
+
+	while ((signo = sigarray[i++])) 
+		xsignal(signo, _handle_signal);
+
+	return rc;
+}
+
diff --git a/src/srun/srun.h b/src/srun/srun.h
index 90f9aaf6230dd64cab7ff97e2b7155da28f98335..edf3da93b3b0582d4634e8b68ca1b0d0cb965d6b 100644
--- a/src/srun/srun.h
+++ b/src/srun/srun.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -37,8 +37,6 @@
 #include "src/api/step_io.h"
 #include "src/srun/srun_job.h"
 
-extern pid_t srun_ppid;		/* required for OpenMPI checkpoint */
-
 void srun_set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds);
 
 #endif /* !_HAVE_SRUN_H */
diff --git a/src/srun/srun_job.c b/src/srun/srun_job.c
index 4c2ad315872de447cf5b9ed4434a5b478b568412..10d9daf4a80ee3cb940ee442b7fd5040629b2959 100644
--- a/src/srun/srun_job.c
+++ b/src/srun/srun_job.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <grondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,19 +56,16 @@
 #include "src/common/log.h"
 #include "src/common/read_config.h"
 #include "src/common/slurm_protocol_api.h"
-#include "src/common/slurm_cred.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
 #include "src/common/io_hdr.h"
 #include "src/common/forward.h"
+#include "src/common/fd.h"
 
 #include "src/srun/srun_job.h"
 #include "src/srun/opt.h"
 #include "src/srun/fname.h"
-#include "src/srun/attach.h"
-#include "src/srun/msg.h"
-
-typedef enum {DSH_NEW, DSH_ACTIVE, DSH_DONE, DSH_FAILED} state_t;
+#include "src/srun/debugger.h"
 
 /*
  * allocation information structure used to store general information
@@ -85,13 +82,6 @@ typedef struct allocation_info {
 	select_jobinfo_t select_jobinfo;
 } allocation_info_t;
 
-typedef struct thd {
-        pthread_t	thread;			/* thread ID */
-        pthread_attr_t	attr;			/* thread attributes */
-        state_t		state;      		/* thread state */
-} thd_t;
-
-int message_thread = 0;
 /*
  * Prototypes:
  */
@@ -99,9 +89,6 @@ static inline int _estimate_nports(int nclients, int cli_per_port);
 static int        _compute_task_count(allocation_info_t *info);
 static void       _set_nprocs(allocation_info_t *info);
 static srun_job_t *_job_create_structure(allocation_info_t *info);
-static void       _job_fake_cred(srun_job_t *job);
-static char *     _task_state_name(srun_task_state_t state_inx);
-static char *     _host_state_name(srun_host_state_t state_inx);
 static char *     _normalize_hostlist(const char *hostlist);
 
 
@@ -139,13 +126,9 @@ job_create_noalloc(void)
 	 * Create job, then fill in host addresses
 	 */
 	job = _job_create_structure(ai);
-	job->step_layout = fake_slurm_step_layout_create(job->nodelist, 
-							 NULL, NULL,
-							 job->nhosts,
-							 job->ntasks);
-		
-	_job_fake_cred(job);
+	
 	job_update_io_fnames(job);
+
    error:
 	xfree(ai);
 	return (job);
@@ -378,106 +361,17 @@ job_create_allocation(resource_allocation_response_msg_t *resp)
 	return (job);
 }
 
-/*
- * Create an srun job structure from a resource allocation response msg
- */
-static srun_job_t *
-_job_create_structure(allocation_info_t *ainfo)
-{
-	srun_job_t *job = xmalloc(sizeof(srun_job_t));
-	
-	_set_nprocs(ainfo);
-	debug2("creating job with %d tasks", opt.nprocs);
-
-	slurm_mutex_init(&job->state_mutex);
-	pthread_cond_init(&job->state_cond, NULL);
-	job->state = SRUN_JOB_INIT;
-
- 	job->nodelist = xstrdup(ainfo->nodelist); 
-	job->stepid  = ainfo->stepid;
-	
-#ifdef HAVE_FRONT_END	/* Limited job step support */
-	opt.overcommit = true;
-	job->nhosts = 1;
-#else
-	job->nhosts   = ainfo->nnodes;
-#endif
-
-#ifndef HAVE_FRONT_END
-	if(opt.min_nodes > job->nhosts) {
-		error("Only allocated %d nodes asked for %d",
-		      job->nhosts, opt.min_nodes);
-		if (opt.exc_nodes) {
-			/* When resources are pre-allocated and some nodes
-			 * are explicitly excluded, this error can occur. */
-			error("Are required nodes explicitly excluded?");
-		}
-		return NULL;
-	}	
-#endif
-	job->select_jobinfo = ainfo->select_jobinfo;
-	job->jobid   = ainfo->jobid;
-	
-	job->ntasks  = opt.nprocs;
-	job->task_prolog = xstrdup(opt.task_prolog);
-	job->task_epilog = xstrdup(opt.task_epilog);
-	/* Compute number of file descriptors / Ports needed for Job 
-	 * control info server
-	 */
-	job->njfds = _estimate_nports(opt.nprocs, 48);
-	debug3("njfds = %d", job->njfds);
-	job->jfd = (slurm_fd *)
-		xmalloc(job->njfds * sizeof(slurm_fd));
-	job->jaddr = (slurm_addr *) 
-		xmalloc(job->njfds * sizeof(slurm_addr));
-
- 	slurm_mutex_init(&job->task_mutex);
-	
-	job->old_job = false;
-	job->removed = false;
-	job->signaled = false;
-	job->rc       = -1;
-	
-	/* 
-	 *  Initialize Launch and Exit timeout values
-	 */
-	job->ltimeout = 0;
-	job->etimeout = 0;
-	
-	job->host_state =  xmalloc(job->nhosts * sizeof(srun_host_state_t));
-	
-	/* ntask task states and statii*/
-	job->task_state  =  xmalloc(opt.nprocs * sizeof(srun_task_state_t));
-	job->tstatus	 =  xmalloc(opt.nprocs * sizeof(int));
-	
-	job_update_io_fnames(job);
-	
-	return (job);	
-}
-
 void
 update_job_state(srun_job_t *job, srun_job_state_t state)
 {
-	pipe_enum_t pipe_enum = PIPE_JOB_STATE;
 	pthread_mutex_lock(&job->state_mutex);
 	if (job->state < state) {
 		job->state = state;
-		if(message_thread) {
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &pipe_enum, sizeof(int));
-			safe_write(job->forked_msg->par_msg->msg_pipe[1],
-				   &job->state, sizeof(int));
-		}
 		pthread_cond_signal(&job->state_cond);
 		
 	}
 	pthread_mutex_unlock(&job->state_mutex);
 	return;
-rwfail:
-	pthread_mutex_unlock(&job->state_mutex);
-	error("update_job_state: "
-	      "write from srun message-handler process failed");
-
 }
 
 srun_job_state_t 
@@ -494,245 +388,8 @@ job_state(srun_job_t *job)
 void 
 job_force_termination(srun_job_t *job)
 {
-	if (mode == MODE_ATTACH) {
-		info ("forcing detach");
-		update_job_state(job, SRUN_JOB_DETACHED);
-	} else {
-		info ("forcing job termination");
-		update_job_state(job, SRUN_JOB_FORCETERM);
-	}
-
-	client_io_handler_finish(job->client_io);
-}
-
-
-int
-set_job_rc(srun_job_t *job)
-{
-	int i, rc = 0, task_failed = 0;
-
-	/*
-	 *  return code set to at least one if any tasks failed launch
-	 */
-	for (i = 0; i < opt.nprocs; i++) {
-		if (job->task_state[i] == SRUN_TASK_FAILED)
-			task_failed = 1; 
-		if (job->rc < job->tstatus[i])
-			job->rc = job->tstatus[i];
-	}
-	if (task_failed && (job->rc <= 0)) {
-		job->rc = 1;
-		return 1;
-	}
-
-	if ((rc = WEXITSTATUS(job->rc)))
-		return rc;
-	if (WIFSIGNALED(job->rc))
-		return (128 + WTERMSIG(job->rc));
-	return job->rc;
-}
-
-
-void job_fatal(srun_job_t *job, const char *msg)
-{
-	if (msg) error(msg);
-
-	srun_job_destroy(job, errno);
-
-	exit(1);
-}
-
-
-void 
-srun_job_destroy(srun_job_t *job, int error)
-{
-	if (job->removed)
-		return;
-
-	if (job->old_job) {
-		debug("cancelling job step %u.%u", job->jobid, job->stepid);
-		slurm_kill_job_step(job->jobid, job->stepid, SIGKILL);
-	} else if (!opt.no_alloc) {
-		debug("cancelling job %u", job->jobid);
-		slurm_complete_job(job->jobid, error);
-	} else {
-		debug("no allocation to cancel, killing remote tasks");
-		fwd_signal(job, SIGKILL, opt.max_threads); 
-		return;
-	}
-
-	if (error) debugger_launch_failure(job);
-
-	job->removed = true;
-}
-
-
-void
-srun_job_kill(srun_job_t *job)
-{
-	if (!opt.no_alloc) {
-		if (slurm_kill_job_step(job->jobid, job->stepid, SIGKILL) < 0)
-			error ("slurm_kill_job_step: %m");
-	}
-	update_job_state(job, SRUN_JOB_FAILED);
-}
-	
-void 
-report_job_status(srun_job_t *job)
-{
-	int i;
-	hostlist_t hl = hostlist_create(job->nodelist);
-	char *name = NULL;
-
-	for (i = 0; i < job->nhosts; i++) {
-		name = hostlist_shift(hl);
-		info ("host:%s state:%s", name, 
-		      _host_state_name(job->host_state[i]));
-		free(name);
-	}
-}
-
-
-#define NTASK_STATES 6
-void 
-report_task_status(srun_job_t *job)
-{
-	int i;
-	char buf[MAXHOSTRANGELEN+2];
-	hostlist_t hl[NTASK_STATES];
-
-	for (i = 0; i < NTASK_STATES; i++)
-		hl[i] = hostlist_create(NULL);
-
-	for (i = 0; i < opt.nprocs; i++) {
-		int state = job->task_state[i];
-		debug3("  state of task %d is %d", i, state);
-		snprintf(buf, 256, "%d", i);
-		hostlist_push(hl[state], buf); 
-	}
-
-	for (i = 0; i< NTASK_STATES; i++) {
-		if (hostlist_count(hl[i]) > 0) {
-			hostlist_ranged_string(hl[i], MAXHOSTRANGELEN, buf);
-			info("task%s: %s", buf, _task_state_name(i));
-		}
-		hostlist_destroy(hl[i]);
-	}
-
-}
-
-void 
-fwd_signal(srun_job_t *job, int signo, int max_threads)
-{
-	int i;
-	slurm_msg_t req;
-	kill_tasks_msg_t msg;
-	static pthread_mutex_t sig_mutex = PTHREAD_MUTEX_INITIALIZER;
-	pipe_enum_t pipe_enum = PIPE_SIGNALED;
-	hostlist_t hl;
-	char *name = NULL;
-	char buf[8192];
-	List ret_list = NULL;
-	ListIterator itr;
-	ret_data_info_t *ret_data_info = NULL;
-	int rc = SLURM_SUCCESS;
-
-	slurm_mutex_lock(&sig_mutex);
-
-	if (signo == SIGKILL || signo == SIGINT || signo == SIGTERM) {
-		slurm_mutex_lock(&job->state_mutex);
-		job->signaled = true;
-		slurm_mutex_unlock(&job->state_mutex);
-		if(message_thread) {
-			write(job->forked_msg->par_msg->msg_pipe[1],
-			      &pipe_enum,sizeof(int));
-			write(job->forked_msg->par_msg->msg_pipe[1],
-			      &job->signaled,sizeof(int));
-		}
-	}
-
-	debug2("forward signal %d to job", signo);
-
-	/* common to all tasks */
-	msg.job_id      = job->jobid;
-	msg.job_step_id = job->stepid;
-	msg.signal      = (uint32_t) signo;
-	
-	hl = hostlist_create("");
-	for (i = 0; i < job->nhosts; i++) {
-		if (job->host_state[i] != SRUN_HOST_REPLIED) {
-			name = nodelist_nth_host(
-				job->step_layout->node_list, i);
-			debug2("%s has not yet replied\n", name);
-			free(name);
-			continue;
-		}
-		if (job_active_tasks_on_host(job, i) == 0)
-			continue;
-		name = nodelist_nth_host(job->step_layout->node_list, i);
-		hostlist_push(hl, name);
-		free(name);
-	}
-	if(!hostlist_count(hl)) {
-		hostlist_destroy(hl);
-		goto nothing_left;
-	}
-	hostlist_ranged_string(hl, sizeof(buf), buf);
-	hostlist_destroy(hl);
-	name = xstrdup(buf);
-
-	slurm_msg_t_init(&req);	
-	req.msg_type = REQUEST_SIGNAL_TASKS;
-	req.data     = &msg;
-	
-	debug3("sending signal to host %s", name);
-	
-	if (!(ret_list = slurm_send_recv_msgs(name, &req, 0))) { 
-		error("fwd_signal: slurm_send_recv_msgs really failed bad");
-		xfree(name);
-		slurm_mutex_unlock(&sig_mutex);
-		return;
-	}
-	xfree(name);
-	itr = list_iterator_create(ret_list);		
-	while((ret_data_info = list_next(itr))) {
-		rc = slurm_get_return_code(ret_data_info->type, 
-					   ret_data_info->data);
-		/*
-		 *  Report error unless it is "Invalid job id" which 
-		 *    probably just means the tasks exited in the meanwhile.
-		 */
-		if ((rc != 0) && (rc != ESLURM_INVALID_JOB_ID)
-		    &&  (rc != ESLURMD_JOB_NOTRUNNING) && (rc != ESRCH)) {
-			error("%s: signal: %s", 
-			      ret_data_info->node_name, 
-			      slurm_strerror(rc));
-		}
-	}
-	list_iterator_destroy(itr);
-	list_destroy(ret_list);
-nothing_left:
-	debug2("All tasks have been signalled");
-	
-	slurm_mutex_unlock(&sig_mutex);
-}
-
-int
-job_active_tasks_on_host(srun_job_t *job, int hostid)
-{
-	int i;
-	int retval = 0;
-
-	slurm_mutex_lock(&job->task_mutex);
-	for (i = 0; i < job->step_layout->tasks[hostid]; i++) {
-		uint32_t *tids = job->step_layout->tids[hostid];
-		xassert(tids != NULL);
-		debug("Task %d state: %d", tids[i], job->task_state[tids[i]]);
-		if (job->task_state[tids[i]] == SRUN_TASK_RUNNING) 
-			retval++;
-	}
-	slurm_mutex_unlock(&job->task_mutex);
-	return retval;
+	info ("forcing job termination");
+	update_job_state(job, SRUN_JOB_FORCETERM);
 }
 
 static inline int
@@ -767,63 +424,61 @@ _set_nprocs(allocation_info_t *info)
 	}
 }
 
-void
-job_update_io_fnames(srun_job_t *job)
+/*
+ * Create an srun job structure from a resource allocation response msg
+ */
+static srun_job_t *
+_job_create_structure(allocation_info_t *ainfo)
 {
-	job->ifname = fname_create(job, opt.ifname);
-	job->ofname = fname_create(job, opt.ofname);
-	job->efname = opt.efname ? fname_create(job, opt.efname) : job->ofname;
-}
+	srun_job_t *job = xmalloc(sizeof(srun_job_t));
+	
+	_set_nprocs(ainfo);
+	debug2("creating job with %d tasks", opt.nprocs);
 
-static void
-_job_fake_cred(srun_job_t *job)
-{
-	slurm_cred_arg_t arg;
-	arg.jobid    = job->jobid;
-	arg.stepid   = job->stepid;
-	arg.uid      = opt.uid;
-	arg.hostlist = job->nodelist;
-        arg.alloc_lps_cnt = 0;    
-        arg.alloc_lps     =  NULL; 
-	job->cred = slurm_cred_faker(&arg);
-}
+	slurm_mutex_init(&job->state_mutex);
+	pthread_cond_init(&job->state_cond, NULL);
+	job->state = SRUN_JOB_INIT;
 
-static char *
-_task_state_name(srun_task_state_t state_inx)
-{
-	switch (state_inx) {
-		case SRUN_TASK_INIT:
-			return "initializing";
-		case SRUN_TASK_RUNNING:
-			return "running";
-		case SRUN_TASK_FAILED:
-			return "failed";
-		case SRUN_TASK_EXITED:
-			return "exited";
-		case SRUN_TASK_IO_WAIT:
-			return "waiting for io";
-		case SRUN_TASK_ABNORMAL_EXIT:
-			return "exited abnormally";
-		default:
-			return "unknown";
-	}
+ 	job->nodelist = xstrdup(ainfo->nodelist); 
+	job->stepid  = ainfo->stepid;
+	
+#ifdef HAVE_FRONT_END	/* Limited job step support */
+	opt.overcommit = true;
+	job->nhosts = 1;
+#else
+	job->nhosts   = ainfo->nnodes;
+#endif
+
+#ifndef HAVE_FRONT_END
+	if(opt.min_nodes > job->nhosts) {
+		error("Only allocated %d nodes asked for %d",
+		      job->nhosts, opt.min_nodes);
+		if (opt.exc_nodes) {
+			/* When resources are pre-allocated and some nodes
+			 * are explicitly excluded, this error can occur. */
+			error("Are required nodes explicitly excluded?");
+		}
+		return NULL;
+	}	
+#endif
+	job->select_jobinfo = ainfo->select_jobinfo;
+	job->jobid   = ainfo->jobid;
+	
+	job->ntasks  = opt.nprocs;
+
+	job->rc       = -1;
+	
+	job_update_io_fnames(job);
+	
+	return (job);	
 }
 
-static char *
-_host_state_name(srun_host_state_t state_inx)
+void
+job_update_io_fnames(srun_job_t *job)
 {
-	switch (state_inx) {
-		case SRUN_HOST_INIT:
-			return "initial";
-		case SRUN_HOST_CONTACTED:
-			return "contacted";
-		case SRUN_HOST_UNREACHABLE:
-			return "unreachable";
-		case SRUN_HOST_REPLIED:
-			return "replied";
-		default:
-			return "unknown";
-	}
+	job->ifname = fname_create(job, opt.ifname);
+	job->ofname = fname_create(job, opt.ofname);
+	job->efname = opt.efname ? fname_create(job, opt.efname) : job->ofname;
 }
 
 static char *
diff --git a/src/srun/srun_job.h b/src/srun/srun_job.h
index 3f099448cca00c371352a57871e999c113dece44..200bf98382d098bf317fcba0216eb6b605c3948a 100644
--- a/src/srun/srun_job.h
+++ b/src/srun/srun_job.h
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Mark Grondona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -53,7 +53,6 @@
 #include "src/common/slurm_protocol_defs.h"
 #include "src/api/step_io.h"
 
-//#include "src/srun/fname.h"
 
 typedef enum {
 	SRUN_JOB_INIT = 0,         /* Job's initial state                   */
@@ -70,56 +69,25 @@ typedef enum {
 	SRUN_JOB_FORCETERM         /* Forced termination of IO thread       */
 } srun_job_state_t;
 
-typedef enum {
-	SRUN_HOST_INIT = 0,
-	SRUN_HOST_CONTACTED,
-	SRUN_HOST_UNREACHABLE,
-	SRUN_HOST_REPLIED
-} srun_host_state_t;
+enum io_t {
+	IO_ALL          = 0, /* multiplex output from all/bcast stdin to all */
+	IO_ONE          = 1, /* output from only one task/stdin to one task  */
+	IO_PER_TASK     = 2, /* separate output/input file per task          */
+	IO_NONE         = 3, /* close output/close stdin                     */
+};
 
-typedef enum {
-	SRUN_TASK_INIT = 0,
-	SRUN_TASK_RUNNING,
-	SRUN_TASK_FAILED,
-	SRUN_TASK_IO_WAIT,/* this state deprecated with new eio stdio engine */
-	SRUN_TASK_EXITED,
-	SRUN_TASK_ABNORMAL_EXIT
-} srun_task_state_t;
-
-typedef enum { 
-	PIPE_NONE = 0, 
-	PIPE_JOB_STATE, 
-	PIPE_TASK_STATE, 
-	PIPE_TASK_EXITCODE,
-	PIPE_HOST_STATE, 
-	PIPE_SIGNALED,
-	PIPE_MPIR_DEBUG_STATE,
-	PIPE_UPDATE_MPIR_PROCTABLE,
-	PIPE_UPDATE_STEP_LAYOUT,
-	PIPE_NODE_FAIL
-} pipe_enum_t;
-
-/* For Message thread */
-typedef struct forked_msg_pipe {
-	int msg_pipe[2];
-	int pid;
-} forked_msg_pipe_t;
-
-typedef struct forked_message {
-	forked_msg_pipe_t *          par_msg;
-	forked_msg_pipe_t *          msg_par;
-	enum job_states	*	     job_state;
-} forked_msg_t;
-
-typedef struct io_filename io_filename_t;
+#define format_io_t(t) (t == IO_ONE) ? "one" : (t == IO_ALL) ? \
+                                                     "all" : "per task"
+
+typedef struct fname {
+	char      *name;
+	enum io_t  type;
+	int        taskid;  /* taskid for IO if IO_ONE */
+} fname_t;
 
 typedef struct srun_job {
-	slurm_step_layout_t *step_layout; /* holds info about how the task is 
-					     laid out */
 	uint32_t jobid;		/* assigned job id 	                  */
 	uint32_t stepid;	/* assigned step id 	                  */
-	bool old_job;           /* run job step under previous allocation */
-	bool removed;       /* job has been removed from SLURM */
 
 	uint32_t nhosts;	/* node count */
 	uint32_t ntasks;	/* task count */
@@ -127,46 +95,26 @@ typedef struct srun_job {
 	pthread_mutex_t state_mutex; 
 	pthread_cond_t  state_cond;
 
-	bool signaled;          /* True if user generated signal to job   */
 	int  rc;                /* srun return code                       */
 
-	slurm_cred_t  cred;     /* Slurm job credential    */
 	char *nodelist;		/* nodelist in string form */
 
-	pthread_t sigid;	/* signals thread tid		  */
-
-	pthread_t jtid;		/* job control thread id 	  */
-	slurm_fd *jfd;		/* job control info fd   	  */
-	
-	pthread_t lid;		  /* launch thread id */
-
-	client_io_t *client_io;
-	time_t    ltimeout;       /* Time by which all tasks must be running */
-	time_t    etimeout;       /* exit timeout (see opt.max_wait          */
-
-	srun_host_state_t *host_state; /* nhost host states */
-
-	int *tstatus;	          /* ntask exit statii */
-	srun_task_state_t *task_state; /* ntask task states */
-	
-	switch_jobinfo_t switch_job;
-	io_filename_t *ifname;
-	io_filename_t *ofname;
-	io_filename_t *efname;
-	forked_msg_t *forked_msg;
-	char *task_epilog;	/* task-epilog */
-	char *task_prolog;	/* task-prolog */
-	pthread_mutex_t task_mutex;
-	int njfds;		/* number of job control info fds */
-	slurm_addr *jaddr;	/* job control info ports 	  */
-	int thr_count;  	/* count of threads in job launch */
+	fname_t *ifname;
+	fname_t *ofname;
+	fname_t *efname;
 
 	/* Output streams and stdin fileno */
 	select_jobinfo_t select_jobinfo;
-	
-} srun_job_t;
 
-extern int message_thread;
+	/* Pseudo terminial support */
+	pthread_t pty_id;	/* pthread to communicate window size changes */
+	int pty_fd;		/* file to communicate window size changes */ 
+	uint16_t pty_port;	/* used to communicate window size changes */
+	uint8_t ws_col;		/* window size, columns */
+	uint8_t ws_row;		/* window size, row count */
+	slurm_step_ctx_t *step_ctx;
+	slurm_step_ctx_params_t ctx_params;
+} srun_job_t;
 
 void    update_job_state(srun_job_t *job, srun_job_state_t newstate);
 void    job_force_termination(srun_job_t *job);
@@ -186,38 +134,7 @@ extern srun_job_t * job_create_structure(
  */
 void    job_update_io_fnames(srun_job_t *j);
 
-/* 
- * Issue a fatal error message and terminate running job
- */
-void    job_fatal(srun_job_t *job, const char *msg);
-
-/* 
- * Deallocates job and or job step via slurm API
- */
-void    srun_job_destroy(srun_job_t *job, int error);
-
-/* 
- * Send SIGKILL to running job via slurm controller
- */
-void    srun_job_kill(srun_job_t *job);
-
-/*
- * report current task status
- */
-void    report_task_status(srun_job_t *job);
-
-/*
- * report current node status
- */
-void    report_job_status(srun_job_t *job);
-
-/*
- * Sets job->rc to highest task exit value.
- * Returns job return code (for srun exit status)
- */
-int    set_job_rc(srun_job_t *job);
-
-void   fwd_signal(srun_job_t *job, int signal, int max_threads);
-int    job_active_tasks_on_host(srun_job_t *job, int hostid);
+/* Set up port to handle messages from slurmctld */
+slurm_fd slurmctld_msg_init(void);
 
 #endif /* !_HAVE_JOB_H */
diff --git a/src/srun/srun_pty.c b/src/srun/srun_pty.c
new file mode 100644
index 0000000000000000000000000000000000000000..8de09059434ac684b5e5415c8084230cea67fd6f
--- /dev/null
+++ b/src/srun/srun_pty.c
@@ -0,0 +1,171 @@
+/*****************************************************************************\
+ *  src/srun/srun_pty.c - pty handling for srun
+ *****************************************************************************
+ *  Copyright (C) 2002-2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette  <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#if HAVE_PTHREAD
+#include <pthread.h>
+#endif
+
+#include <signal.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+
+#include <slurm/slurm_errno.h>
+
+#include "src/common/log.h"
+#include "src/common/macros.h"
+#include "src/common/slurm_protocol_api.h"
+#include "src/common/slurm_protocol_defs.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+#include "src/common/xsignal.h"
+
+#include "src/srun/opt.h"
+#include "src/srun/srun_job.h"
+
+#define MAX_RETRIES 3
+
+/*  Processed by pty_thr() */
+static int pty_sigarray[] = { SIGWINCH, 0 };
+static int winch;
+
+/* 
+ * Static prototypes
+ */
+static void   _handle_sigwinch(int sig);
+static void * _pty_thread(void *arg);
+
+void set_winsize(srun_job_t *job)
+{
+	struct winsize ws;
+
+	if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws))
+		error("ioctl(TIOCGWINSZ): %m");
+	else {
+		job->ws_row = ws.ws_row;
+		job->ws_col = ws.ws_col;
+		debug2("winsize %u:%u", job->ws_row, job->ws_col);
+	}
+	return;
+}
+
+/* SIGWINCH should already be blocked by srun/signal.c */
+void block_sigwinch(void)
+{
+	xsignal_block(pty_sigarray);
+}
+
+void pty_thread_create(srun_job_t *job)
+{
+	slurm_addr pty_addr;
+	pthread_attr_t attr;
+
+	if ((job->pty_fd = slurm_init_msg_engine_port(0)) < 0) {
+		error("init_msg_engine_port: %m");
+		return;
+	}
+	if (slurm_get_stream_addr(job->pty_fd, &pty_addr) < 0) {
+		error("slurm_get_stream_addr: %m");
+		return;
+	}
+	job->pty_port = ntohs(((struct sockaddr_in) pty_addr).sin_port);
+	debug2("initialized job control port %hu\n", job->pty_port);
+
+	slurm_attr_init(&attr);
+	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	if ((pthread_create(&job->pty_id, &attr, &_pty_thread, (void *) job)))
+		error("pthread_create(pty_thread): %m");
+	slurm_attr_destroy(&attr);
+}
+
+static void  _handle_sigwinch(int sig)
+{
+	winch = 1;
+	xsignal(SIGWINCH, _handle_sigwinch);
+}
+
+static void _notify_winsize_change(int fd, srun_job_t *job)
+{
+	pty_winsz_t winsz;
+	int len;
+	char buf[4];
+
+	if (fd < 0) {
+		error("pty: no file to write window size changes to");
+		return;
+	}
+
+	winsz.cols = htons(job->ws_col);
+	winsz.rows = htons(job->ws_row);
+	memcpy(buf, &winsz.cols, 2);
+	memcpy(buf+2, &winsz.rows, 2);
+	len = slurm_write_stream(fd, buf, 4);
+	if (len < sizeof(winsz))
+		error("pty: window size change notification error: %m");
+}
+
+static void *_pty_thread(void *arg)
+{
+	int fd = -1;
+	srun_job_t *job = (srun_job_t *) arg;
+	slurm_addr client_addr;
+
+	xsignal_unblock(pty_sigarray);
+	xsignal(SIGWINCH, _handle_sigwinch);
+
+	if ((fd = slurm_accept_msg_conn(job->pty_fd, &client_addr)) < 0) {
+		error("pty: accept failure: %m");
+		return NULL;
+	}
+
+	while (job->state <= SRUN_JOB_RUNNING) {
+		debug2("waiting for SIGWINCH");
+		poll(NULL, 0, -1);
+		if (winch) {
+			set_winsize(job);
+			_notify_winsize_change(fd, job);
+		}
+		winch = 0;
+	}
+	return NULL;
+}
+
+
diff --git a/src/srun/signals.h b/src/srun/srun_pty.h
similarity index 89%
rename from src/srun/signals.h
rename to src/srun/srun_pty.h
index 0fb53db828f32e8e8e0ccdd832111b4338488619..56e8ded1a25d5a11c0f1e91a1b7b978d468f0992 100644
--- a/src/srun/signals.h
+++ b/src/srun/srun_pty.h
@@ -1,10 +1,10 @@
 /*****************************************************************************\
- * src/srun/signals.h - srun signal handling
+ * src/srun/srun_pty.h - srun signal handling
  *****************************************************************************
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grodnona <mgrondona@llnl.gov>.
- *  UCRL-CODE-226842.
+ *  Written by Moe Jette <jette@llnl.gov>.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -38,10 +38,12 @@
 #ifndef _SIGNALS_H
 #define _SIGNALS_H
 
+#include "src/srun/srun_job.h"
+
 typedef struct srun_job signal_job_t;
 
-int sig_setup_sigmask(void);
-int  sig_unblock_signals(void);
-int  sig_thr_create(signal_job_t *job);
+void block_sigwinch(void);
+void pty_thread_create(srun_job_t *job);
+void set_winsize(srun_job_t *job);
 
 #endif /* !_SIGNALS_H */
diff --git a/src/sstat/Makefile.am b/src/sstat/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..cdb0a0c6ead9946f76e1d907fdf99fdb2ecf9bed
--- /dev/null
+++ b/src/sstat/Makefile.am
@@ -0,0 +1,20 @@
+# Makefile for sstat
+
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = -I$(top_srcdir)
+
+bin_PROGRAMS = sstat
+
+sstat_LDADD = 	$(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la
+
+noinst_HEADERS = sstat.c 
+sstat_SOURCES = sstat.c process.c print.c options.c
+
+force:
+$(sstat_LDADD) : force
+	 @cd `dirname $@` && $(MAKE) `basename $@`
+
+sstat_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+
diff --git a/src/sstat/Makefile.in b/src/sstat/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..d752d24b74dcb0f1d5e09ae11742bea686c7652e
--- /dev/null
+++ b/src/sstat/Makefile.in
@@ -0,0 +1,563 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile for sstat
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+bin_PROGRAMS = sstat$(EXEEXT)
+subdir = src/sstat
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
+	$(top_srcdir)/auxdir/slurm.m4 \
+	$(top_srcdir)/auxdir/x_ac__system_configuration.m4 \
+	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
+	$(top_srcdir)/auxdir/x_ac_aix.m4 \
+	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
+	$(top_srcdir)/auxdir/x_ac_debug.m4 \
+	$(top_srcdir)/auxdir/x_ac_elan.m4 \
+	$(top_srcdir)/auxdir/x_ac_federation.m4 \
+	$(top_srcdir)/auxdir/x_ac_gpl_licensed.m4 \
+	$(top_srcdir)/auxdir/x_ac_gtk.m4 \
+	$(top_srcdir)/auxdir/x_ac_munge.m4 \
+	$(top_srcdir)/auxdir/x_ac_ncurses.m4 \
+	$(top_srcdir)/auxdir/x_ac_pam.m4 \
+	$(top_srcdir)/auxdir/x_ac_ptrace.m4 \
+	$(top_srcdir)/auxdir/x_ac_readline.m4 \
+	$(top_srcdir)/auxdir/x_ac_setpgrp.m4 \
+	$(top_srcdir)/auxdir/x_ac_setproctitle.m4 \
+	$(top_srcdir)/auxdir/x_ac_sgi_job.m4 \
+	$(top_srcdir)/auxdir/x_ac_slurm_ssl.m4 \
+	$(top_srcdir)/auxdir/x_ac_xcpu.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/slurm/slurm.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_sstat_OBJECTS = sstat.$(OBJEXT) process.$(OBJEXT) print.$(OBJEXT) \
+	options.$(OBJEXT)
+sstat_OBJECTS = $(am_sstat_OBJECTS)
+sstat_DEPENDENCIES = $(top_builddir)/src/common/libcommon.o \
+	$(top_builddir)/src/api/libslurmhelper.la
+sstat_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(sstat_LDFLAGS) \
+	$(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
+depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(sstat_SOURCES)
+DIST_SOURCES = $(sstat_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTHD_CFLAGS = @AUTHD_CFLAGS@
+AUTHD_LIBS = @AUTHD_LIBS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BG_INCLUDES = @BG_INCLUDES@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMD_LDFLAGS = @CMD_LDFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELAN_LIBS = @ELAN_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FEDERATION_LDFLAGS = @FEDERATION_LDFLAGS@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
+HAVEPKGCONFIG = @HAVEPKGCONFIG@
+HAVE_AIX = @HAVE_AIX@
+HAVE_ELAN = @HAVE_ELAN@
+HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
+HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_LDFLAGS = @LIB_LDFLAGS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
+MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
+MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
+NUMA_LIBS = @NUMA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_LIBS = @PAM_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PLPA_LIBS = @PLPA_LIBS@
+PROCTRACKDIR = @PROCTRACKDIR@
+PROJECT = @PROJECT@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE = @RELEASE@
+SED = @SED@
+SEMAPHORE_LIBS = @SEMAPHORE_LIBS@
+SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
+SLURMD_PORT = @SLURMD_PORT@
+SLURM_API_AGE = @SLURM_API_AGE@
+SLURM_API_CURRENT = @SLURM_API_CURRENT@
+SLURM_API_MAJOR = @SLURM_API_MAJOR@
+SLURM_API_REVISION = @SLURM_API_REVISION@
+SLURM_API_VERSION = @SLURM_API_VERSION@
+SLURM_MAJOR = @SLURM_MAJOR@
+SLURM_MICRO = @SLURM_MICRO@
+SLURM_MINOR = @SLURM_MINOR@
+SLURM_VERSION = @SLURM_VERSION@
+SO_LDFLAGS = @SO_LDFLAGS@
+SSL_CPPFLAGS = @SSL_CPPFLAGS@
+SSL_LDFLAGS = @SSL_LDFLAGS@
+SSL_LIBS = @SSL_LIBS@
+STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+INCLUDES = -I$(top_srcdir)
+sstat_LDADD = $(top_builddir)/src/common/libcommon.o -ldl \
+	$(top_builddir)/src/api/libslurmhelper.la
+
+noinst_HEADERS = sstat.c 
+sstat_SOURCES = sstat.c process.c print.c options.c
+sstat_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/sstat/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/sstat/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	     || test -f $$p1 \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+sstat$(EXEEXT): $(sstat_OBJECTS) $(sstat_DEPENDENCIES) 
+	@rm -f sstat$(EXEEXT)
+	$(sstat_LINK) $(sstat_OBJECTS) $(sstat_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sstat.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-binPROGRAMS install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am \
+	uninstall-binPROGRAMS
+
+
+force:
+$(sstat_LDADD) : force
+	 @cd `dirname $@` && $(MAKE) `basename $@`
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/sstat/options.c b/src/sstat/options.c
new file mode 100644
index 0000000000000000000000000000000000000000..a1aafaa40e9144a7dffa12e6288d026783cc6fb9
--- /dev/null
+++ b/src/sstat/options.c
@@ -0,0 +1,396 @@
+/*****************************************************************************\
+ *  options.c - option functions for sstat
+ *
+ *  $Id: options.c 7541 2006-03-18 01:44:58Z da $
+ *****************************************************************************
+ *  Copyright (C) 2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "src/common/read_config.h"
+#include "sstat.h"
+#include <time.h>
+
+void _help_fields_msg(void);
+void _help_msg(void);
+void _usage(void);
+void _init_params();
+
+void _help_fields_msg(void)
+{
+	int i;
+
+	for (i = 0; fields[i].name; i++) {
+		if (i & 3)
+			printf("  ");
+		else
+			printf("\n");
+		printf("%-10s", fields[i].name);
+	}
+	printf("\n");
+	return;
+}
+
+void _help_msg(void)
+{
+	printf("\n"
+	       "By default, sstat displays status data for job/step stated\n"
+	       "Options:\n"
+	       "-C, --cluster\n"
+	       "    Job is running on this cluster.\n"
+	       "-F <field-list>, --fields=<field-list>\n"
+	       "    Display the specified data (use \"--help-fields\" for a\n"
+	       "    list of available fields). If no field option is specified,\n"
+	       "    we use \"--fields=jobid,vsize,rss,pages,cputime,ntasks,state\".\n"
+	       "-h, --help\n"
+	       "    Print a general help message.\n"
+	       "--help-fields\n"
+	       "    Print a list of fields that can be specified with the\n"
+	       "    \"--fields\" option\n"
+	       "-j <job(.step)>, --jobs=<job(.step)>\n"
+	       "    Display information about this job or comma-separated\n"
+	       "    list of jobs. The default is all jobs. Adding .step will\n"
+	       "    display the specfic job step of that job.\n"
+	       "--noheader\n"
+	       "    Print (or don't print) a header. The default is to print a\n"
+	       "    header; the option has no effect if --dump is specified\n"
+	       "--usage\n"
+	       "    Pointer to this message.\n"
+	       "-v, --verbose\n"
+	       "    Primarily for debugging purposes, report the state of various\n"
+	       "    variables during processing.\n");
+
+	return;
+}
+
+void _usage(void)
+{
+	printf("\nUsage: sstat [options]\n\tUse --help for help\n");
+}
+
+
+void _do_help(void)
+{
+	switch (params.opt_help) {
+	case 1:
+		_help_msg();
+		break;
+	case 2:
+		_help_fields_msg();
+		break;
+	case 3:
+		_usage();
+		break;
+	default:
+		fprintf(stderr, "sacct bug: params.opt_help=%d\n", 
+			params.opt_help);
+	}
+}
+
+void _init_params()
+{
+	params.opt_cluster = NULL;	/* --cluster */
+	params.opt_completion = 0;	/* --completion */
+	params.opt_dump = 0;		/* --dump */
+	params.opt_dup = -1;		/* --duplicates; +1 = explicitly set */
+	params.opt_fdump = 0;		/* --formattted_dump */
+	params.opt_stat = 0;		/* --stat */
+	params.opt_gid = -1;		/* --gid (-1=wildcard, 0=root) */
+	params.opt_header = 1;		/* can only be cleared */
+	params.opt_help = 0;		/* --help */
+	params.opt_long = 0;		/* --long */
+	params.opt_lowmem = 0;		/* --low_memory */
+	params.opt_purge = 0;		/* --purge */
+	params.opt_total = 0;		/* --total */
+	params.opt_uid = -1;		/* --uid (-1=wildcard, 0=root) */
+	params.opt_uid_set = 0;
+	params.opt_verbose = 0;		/* --verbose */
+	params.opt_expire_timespec = NULL; /* --expire= */
+	params.opt_field_list = NULL;	/* --fields= */
+	params.opt_filein = NULL;	/* --file */
+	params.opt_job_list = NULL;	/* --jobs */
+	params.opt_partition_list = NULL;/* --partitions */
+	params.opt_state_list = NULL;	/* --states */
+}
+
+int decode_state_char(char *state)
+{
+	if (!strcasecmp(state, "p"))
+		return JOB_PENDING; 	/* we should never see this */
+	else if (!strcasecmp(state, "r"))
+		return JOB_RUNNING;
+	else if (!strcasecmp(state, "su"))
+		return JOB_SUSPENDED;
+	else if (!strcasecmp(state, "cd"))
+		return JOB_COMPLETE;
+	else if (!strcasecmp(state, "ca"))
+		return JOB_CANCELLED;
+	else if (!strcasecmp(state, "f"))
+		return JOB_FAILED;
+	else if (!strcasecmp(state, "to"))
+		return JOB_TIMEOUT;
+	else if (!strcasecmp(state, "nf"))
+		return JOB_NODE_FAIL;
+	else
+		return -1; // unknown
+} 
+
+void parse_command_line(int argc, char **argv, List selected_steps)
+{
+	extern int optind;
+	int c, i, optionIndex = 0;
+	char *end = NULL, *start = NULL;
+	jobacct_selected_step_t *selected_step = NULL;
+	ListIterator itr = NULL;
+	char *dot = NULL;
+	log_options_t logopt = LOG_OPTS_STDERR_ONLY;
+
+	static struct option long_options[] = {
+		{"cluster", 1, 0, 'C'},
+		{"fields", 1, 0, 'F'},
+		{"help", 0, &params.opt_help, 1},
+		{"help-fields", 0, &params.opt_help, 2},
+		{"jobs", 1, 0, 'j'},
+		{"noheader", 0, &params.opt_header, 0},
+		{"usage", 0, &params.opt_help, 3},
+		{"verbose", 0, 0, 'v'},
+		{"version", 0, 0, 'V'},
+		{0, 0, 0, 0}};
+
+	log_init(xbasename(argv[0]), logopt, 0, NULL);
+
+	_init_params();
+
+	if ((i=getuid()))
+		/* default to current user unless root*/
+		params.opt_uid = i;
+
+	opterr = 1;		/* Let getopt report problems to the user */
+
+	while (1) {		/* now cycle through the command line */
+		c = getopt_long(argc, argv, "C:F:hj:Vv",
+				long_options, &optionIndex);
+		if (c == -1)
+			break;
+		switch (c) {
+		case 'C':
+			params.opt_cluster = xstrdup(optarg);
+			break;
+		case 'F':
+			if(params.opt_field_list)
+				xfree(params.opt_field_list);
+			
+			params.opt_field_list =
+				xrealloc(params.opt_field_list,
+					 (params.opt_field_list==NULL? 0 :
+					  strlen(params.opt_field_list)) +
+					 strlen(optarg) + 1);
+			strcat(params.opt_field_list, optarg);
+			strcat(params.opt_field_list, ",");
+			break;
+		case 'h':
+			params.opt_help = 1;
+			break;
+		case 'j':
+			if ((strspn(optarg, "0123456789, ") < strlen(optarg))
+			    && (strspn(optarg, ".0123456789, ") 
+				< strlen(optarg))) {
+				fprintf(stderr, "Invalid jobs list: %s\n",
+					optarg);
+				exit(1);
+			}
+			params.opt_job_list =
+				xrealloc(params.opt_job_list,
+					 (params.opt_job_list==NULL? 0 :
+					  strlen(params.opt_job_list)) +
+					 strlen(optarg) + 1);
+			strcat(params.opt_job_list, optarg);
+			strcat(params.opt_job_list, ",");
+			break;
+		case 'v':
+			/* Handle -vvv thusly...
+			 * 0 - report only normal messages and errors
+			 * 1 - report options selected and major operations
+			 * 2 - report data anomalies probably not errors
+			 * 3 - blather on and on
+			 */
+			params.opt_verbose++;
+			break;
+
+		case 'V':
+		{
+			char	obuf[20]; /* should be long enough */
+			char	*rev="$Revision: 7267 $";
+			char	*s;
+
+			s=strstr(rev, " ")+1;
+			for (i=0; s[i]!=' '; i++)
+				obuf[i]=s[i];
+			obuf[i] = 0;
+			printf("%s: %s\n", argv[0], obuf);
+			exit(0);
+		}
+
+		case ':':
+		case '?':	/* getopt() has explained it */
+			exit(1); 
+		}
+	}
+
+	if(params.opt_help) {
+		_do_help();
+		exit(0);
+	}
+
+	if (optind < argc) {
+		optarg = argv[optind];
+		if ((strspn(optarg, "0123456789, ") < strlen(optarg))
+		    && (strspn(optarg, ".0123456789, ") 
+			< strlen(optarg))) {
+			fprintf(stderr, "Invalid jobs list: %s\n",
+				optarg);
+			exit(1);
+		}
+		params.opt_job_list =
+			xrealloc(params.opt_job_list,
+				 (params.opt_job_list==NULL? 0 :
+				  strlen(params.opt_job_list)) +
+				 strlen(optarg) + 1);
+		strcat(params.opt_job_list, optarg);
+		strcat(params.opt_job_list, ",");
+	}
+
+	if(!params.opt_field_list) {
+		params.opt_field_list = 
+			xmalloc(sizeof(STAT_FIELDS)+1);
+		strcat(params.opt_field_list, STAT_FIELDS);
+		strcat(params.opt_field_list, ",");
+	}
+
+
+	if (params.opt_verbose) {
+		fprintf(stderr, "Options selected:\n"
+			"\topt_cluster=%s\n"
+			"\topt_field_list=%s\n"
+			"\topt_header=%d\n"
+			"\topt_help=%d\n"
+			"\topt_job_list=%s\n"
+			"\topt_verbose=%d\n",
+			params.opt_cluster,
+			params.opt_field_list,
+			params.opt_header,
+			params.opt_help,
+			params.opt_job_list,
+			params.opt_verbose);
+		logopt.stderr_level += params.opt_verbose;
+		log_alter(logopt, 0, NULL);
+
+	}
+
+	/* specific jobs requested? */
+	if (params.opt_job_list) { 
+		start = params.opt_job_list;
+		while ((end = strstr(start, ",")) && start) {
+			*end = 0;
+			while (isspace(*start))
+				start++;	/* discard whitespace */
+			if(!(int)*start)
+				continue;
+			selected_step = 
+				xmalloc(sizeof(jobacct_selected_step_t));
+			list_append(selected_steps, selected_step);
+			
+			dot = strstr(start, ".");
+			if (dot == NULL) {
+				debug2("No jobstep requested");
+				selected_step->step = NULL;
+				selected_step->stepid = (uint32_t)NO_VAL;
+			} else {
+				*dot++ = 0;
+				selected_step->step = xstrdup(dot);
+				selected_step->stepid = atoi(dot);
+			}
+			selected_step->job = xstrdup(start);
+			selected_step->jobid = atoi(start);
+			start = end + 1;
+		}
+		if (params.opt_verbose) {
+			fprintf(stderr, "Jobs requested:\n");
+			itr = list_iterator_create(selected_steps);
+			while((selected_step = list_next(itr))) {
+				if(selected_step->step) 
+					fprintf(stderr, "\t: %s.%s\n",
+						selected_step->job,
+						selected_step->step);
+				else	
+					fprintf(stderr, "\t: %s\n", 
+						selected_step->job);
+			}
+			list_iterator_destroy(itr);
+		}
+	}
+
+	start = params.opt_field_list;
+	while ((end = strstr(start, ","))) {
+		*end = 0;
+		while (isspace(*start))
+			start++;	/* discard whitespace */
+		if(!(int)*start)
+			continue;
+		for (i = 0; fields[i].name; i++) {
+			if (!strcasecmp(fields[i].name, start))
+				goto foundfield;
+		}
+		fprintf(stderr,
+			"Invalid field requested: \"%s\"\n",
+			start);
+		exit(1);
+	foundfield:
+		printfields[nprintfields++] = i;
+		start = end + 1;
+	}
+
+	if (params.opt_verbose) {
+		fprintf(stderr, "%d field%s selected:\n",
+			nprintfields,
+			(nprintfields==1? "" : "s"));
+		for (i = 0; i < nprintfields; i++)
+			fprintf(stderr,
+				"\t%s\n",
+				fields[printfields[i]].name);
+	} 
+
+	return;
+}
+
+
diff --git a/src/sstat/print.c b/src/sstat/print.c
new file mode 100644
index 0000000000000000000000000000000000000000..0ff252c9d25bce0afd3a79b21507d9d0e0fb5119
--- /dev/null
+++ b/src/sstat/print.c
@@ -0,0 +1,438 @@
+/*****************************************************************************\
+ *  print.c - print functions for sacct
+ *
+ *  $Id: print.c 7541 2006-03-18 01:44:58Z da $
+ *****************************************************************************
+ *  Copyright (C) 2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "sstat.h"
+#include "src/common/parse_time.h"
+#include "slurm.h"
+#define FORMAT_STRING_SIZE 34
+
+void _elapsed_time(long secs, long usecs, char *str);
+
+void _elapsed_time(long secs, long usecs, char *str)
+{
+	long	days, hours, minutes, seconds;
+	long    subsec = 0;
+	
+	if(secs < 0) {
+		snprintf(str, FORMAT_STRING_SIZE, "'N/A'");
+		return;
+	}
+	
+	while (usecs >= 1E6) {
+		secs++;
+		usecs -= 1E6;
+	}
+	if(usecs > 0) {
+		/* give me 3 significant digits to tack onto the sec */
+		subsec = (usecs/1000);
+	}
+	seconds =  secs % 60;
+	minutes = (secs / 60)   % 60;
+	hours   = (secs / 3600) % 24;
+	days    =  secs / 86400;
+
+	if (days) 
+		snprintf(str, FORMAT_STRING_SIZE,
+			 "%ld-%2.2ld:%2.2ld:%2.2ld",
+		         days, hours, minutes, seconds);
+	else if (hours)
+		snprintf(str, FORMAT_STRING_SIZE,
+			 "%ld:%2.2ld:%2.2ld",
+		         hours, minutes, seconds);
+	else
+		snprintf(str, FORMAT_STRING_SIZE,
+			 "%ld:%2.2ld.%3.3ld",
+		         minutes, seconds, subsec);
+}
+
+extern void print_fields(type_t type, void *object)
+{
+	int f, pf;
+	for (f=0; f<nprintfields; f++) {
+		pf = printfields[f];
+		if (f)
+			printf(" ");
+		(fields[pf].print_routine)(type, object);
+	}
+	printf("\n");
+}
+
+/* Field-specific print routines */
+
+extern void print_cputime(type_t type, void *object)
+{ 
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char outbuf[FORMAT_STRING_SIZE];
+	char buf1[FORMAT_STRING_SIZE];
+	char buf2[FORMAT_STRING_SIZE];
+	char buf3[FORMAT_STRING_SIZE];
+	sacct_t sacct;
+	char *nodes = NULL;
+	uint32_t pos;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-37s", "MinCPUtime/Node:Task - Ave");
+		break;
+	case UNDERSCORE:
+		printf("%-37s", "-------------------------------------");
+		break;
+	case JOB:
+		sacct = job->sacct;
+		nodes = job->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		_elapsed_time((int)sacct.min_cpu, 0, buf1);
+		if(job->track_steps)
+			snprintf(outbuf, FORMAT_STRING_SIZE, 
+				 "%s/- - -", buf1);
+		else {
+			_elapsed_time((int)sacct.ave_cpu, 0, buf2);
+			find_hostname(pos, nodes, buf3);
+			snprintf(outbuf, FORMAT_STRING_SIZE, 
+				 "%s/%s:%u - %s", 
+				 buf1,
+				 buf3, 
+				 sacct.min_cpu_id.taskid, 
+				 buf2);
+		}
+		printf("%-37s", outbuf);
+		break;
+	case JOBSTEP:
+		sacct = step->sacct;
+		nodes = step->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		_elapsed_time((int)sacct.min_cpu, 0, buf1);
+		_elapsed_time((int)sacct.ave_cpu, 0, buf2);
+		find_hostname(pos, nodes, buf3);
+		snprintf(outbuf, FORMAT_STRING_SIZE, 
+			 "%s/%s:%u - %s", 
+			 buf1,
+			 buf3, 
+			 sacct.min_cpu_id.taskid, 
+			 buf2);
+		printf("%-37s", outbuf);
+		break;
+	default:
+		printf("%-37s", "n/a");
+		break;
+	} 
+}
+
+extern void print_jobid(type_t type, void *object)
+{
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char outbuf[10];
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-10s", "JobID");
+		break;
+	case UNDERSCORE:
+		printf("%-10s", "----------");
+		break;
+	case JOB:
+		printf("%-10u", job->jobid);
+		break;
+	case JOBCOMP:
+		printf("%-10u", jobcomp->jobid);
+		break;
+	case JOBSTEP:
+		snprintf(outbuf, sizeof(outbuf), "%u.%u",
+			 step->jobid,
+			 step->stepid);
+		printf("%-10s", outbuf);
+		break;
+	default:
+		printf("%-10s", "n/a");
+		break;
+	} 
+
+}
+
+extern void print_ntasks(type_t type, void *object)
+{ 
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-7s", "Ntasks");
+		break;
+	case UNDERSCORE:
+		printf("%-7s", "-------");
+		break;
+	case JOB:
+		printf("%-7u", job->alloc_cpus);
+		break;
+	case JOBSTEP:
+		printf("%-7u", step->ncpus);
+		break;
+	default:
+		printf("%-7s", "n/a");
+		break;
+	} 
+}
+
+extern void print_pages(type_t type, void *object)
+{ 
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char outbuf[FORMAT_STRING_SIZE];
+	char buf1[FORMAT_STRING_SIZE];
+	char buf2[FORMAT_STRING_SIZE];
+	char buf3[FORMAT_STRING_SIZE];
+	sacct_t sacct;
+	char *nodes = NULL;
+	uint32_t pos;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-34s", "MaxPages/Node:Task - Ave");
+		break;
+	case UNDERSCORE:
+		printf("%-34s", "----------------------------------");
+		break;
+	case JOB:
+		sacct = job->sacct;
+		nodes = job->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_pages, 
+				 buf1, sizeof(buf1), UNIT_NONE);
+
+		if(job->track_steps)
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
+		else {
+			convert_num_unit((float)sacct.ave_pages,
+					 buf2, sizeof(buf2), UNIT_NONE);
+			find_hostname(pos, nodes, buf3);
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+				 buf1,
+				 buf3,
+				 sacct.max_pages_id.taskid, 
+				 buf2);
+		}
+		printf("%-34s", outbuf);
+		break;
+	case JOBSTEP:
+		sacct = step->sacct;
+		nodes = step->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_pages, buf1, sizeof(buf1),
+				 UNIT_NONE);
+		convert_num_unit((float)sacct.ave_pages, buf2, sizeof(buf2),
+				 UNIT_NONE);
+		find_hostname(pos, nodes, buf3);
+		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+			 buf1,
+			 buf3,
+			 sacct.max_pages_id.taskid, 
+			 buf2);
+		printf("%-34s", outbuf);
+		break;
+	default:
+		printf("%-34s", "n/a");
+		break;
+	} 
+}
+
+extern void print_rss(type_t type, void *object)
+{ 
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char outbuf[FORMAT_STRING_SIZE];
+	char buf1[FORMAT_STRING_SIZE];
+	char buf2[FORMAT_STRING_SIZE];
+	char buf3[FORMAT_STRING_SIZE];
+	sacct_t sacct;
+	char *nodes = NULL;
+	uint32_t pos;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-34s", "MaxRSS/Node:Task - Ave");
+		break;
+	case UNDERSCORE:
+		printf("%-34s", "----------------------------------");
+		break;
+	case JOB:
+		sacct = job->sacct;
+		nodes = job->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
+				 UNIT_NONE);
+
+		if(job->track_steps)
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
+		else {
+			convert_num_unit((float)sacct.ave_rss, 
+					 buf2, sizeof(buf2), UNIT_NONE);
+			find_hostname(pos, nodes, buf3);
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+				 buf1,
+				 buf3, 
+				 sacct.max_rss_id.taskid, 
+				 buf2);
+		}
+		printf("%-34s", outbuf);
+		break;
+	case JOBSTEP:
+		sacct = step->sacct;
+		nodes = step->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_rss, buf1, sizeof(buf1),
+				 UNIT_NONE);
+		convert_num_unit((float)sacct.ave_rss, buf2, sizeof(buf2),
+				 UNIT_NONE);
+		find_hostname(pos, nodes, buf3);
+		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+			 buf1,
+			 buf3, 
+			 sacct.max_rss_id.taskid, 
+			 buf2);
+		printf("%-34s", outbuf);
+		break;
+	default:
+		printf("%-34s", "n/a");
+		break;
+	} 
+}
+
+extern void print_state(type_t type, void *object)
+{ 
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobcomp_job_rec_t *jobcomp = (jobcomp_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-20s", "State");
+		break;
+	case UNDERSCORE:
+		printf("%-20s", "--------------------");
+		break;
+	case JOB:
+		if ( job->state == JOB_CANCELLED) {
+			printf ("%-10s by %6d",
+				job_state_string(job->state), job->requid);
+		}
+		else {
+			printf("%-20s", job_state_string(job->state));
+		}
+		break;
+	case JOBCOMP:
+		printf("%-20s", jobcomp->state);
+		break;
+	case JOBSTEP:
+		if ( step->state == JOB_CANCELLED) {
+			printf ("%-10s by %6d",
+				job_state_string(step->state), step->requid);
+		}
+		else {
+			printf("%-20s", job_state_string(step->state));
+		}
+		break;
+	default:
+		printf("%-20s", "n/a");
+		break;
+	} 
+}
+
+extern void print_vsize(type_t type, void *object)
+{ 
+	jobacct_job_rec_t *job = (jobacct_job_rec_t *)object;
+	jobacct_step_rec_t *step = (jobacct_step_rec_t *)object;
+	char outbuf[FORMAT_STRING_SIZE];
+	char buf1[FORMAT_STRING_SIZE];
+	char buf2[FORMAT_STRING_SIZE];
+	char buf3[FORMAT_STRING_SIZE];
+	sacct_t sacct;
+	char *nodes = NULL;
+	uint32_t pos;
+
+	switch(type) {
+	case HEADLINE:
+		printf("%-34s", "MaxVSIZE/Node:Task - Ave");
+		break;
+	case UNDERSCORE:
+		printf("%-34s", "----------------------------------");
+		break;
+	case JOB:
+		sacct = job->sacct;
+		nodes = job->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_vsize, 
+				 buf1, sizeof(buf1),UNIT_NONE);
+		if(job->track_steps)
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/- - -", buf1);
+		else {
+			convert_num_unit((float)sacct.ave_vsize,
+					 buf2, sizeof(buf2), UNIT_NONE);
+			find_hostname(pos, nodes, buf3);
+			snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+				 buf1,
+				 buf3, 
+				 sacct.max_vsize_id.taskid, 
+				 buf2);
+		}
+		printf("%-34s", outbuf);
+		break;
+	case JOBSTEP:
+		sacct = step->sacct;
+		nodes = step->nodes;
+		pos = sacct.min_cpu_id.nodeid;				 
+		convert_num_unit((float)sacct.max_vsize, buf1, sizeof(buf1), 
+				 UNIT_NONE);
+		convert_num_unit((float)sacct.ave_vsize, buf2, sizeof(buf2),
+				 UNIT_NONE);
+		find_hostname(pos, nodes, buf3);
+		snprintf(outbuf, FORMAT_STRING_SIZE, "%s/%s:%u - %s", 
+			 buf1,
+			 buf3, 
+			 sacct.max_vsize_id.taskid, 
+			 buf2);
+		printf("%-34s", outbuf);
+		break;
+	default:
+		printf("%-34s", "n/a");
+		break;
+	} 
+}
diff --git a/src/sstat/process.c b/src/sstat/process.c
new file mode 100644
index 0000000000000000000000000000000000000000..433433519a9d748c6fe1ca781a449a4c9ab4afe7
--- /dev/null
+++ b/src/sstat/process.c
@@ -0,0 +1,90 @@
+/*****************************************************************************\
+ *  process.c - process functions for sacct
+ *
+ *  $Id: process.c 7541 2006-03-18 01:44:58Z da $
+ *****************************************************************************
+ *  Copyright (C) 2006 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Danny Auble <da@llnl.gov>.
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "sstat.h"
+
+
+void find_hostname(uint32_t pos, char *hosts, char *host)
+{
+	hostlist_t hostlist = NULL;
+	char *temp = NULL;
+
+	if(pos == (uint32_t)NO_VAL) {
+		snprintf(host, 50, "'N/A'");
+		return;
+	}
+	hostlist = hostlist_create(hosts);
+	temp = hostlist_nth(hostlist, pos);
+	if(temp) {
+		snprintf(host, 50, "%s", temp);
+		free(temp);
+	} else {
+		snprintf(host, 50, "'N/A'");
+	}
+	hostlist_destroy(hostlist);
+	return;
+}
+
+void aggregate_sacct(sacct_t *dest, sacct_t *from)
+{
+	if(dest->max_vsize < from->max_vsize) {
+		dest->max_vsize = from->max_vsize;
+		dest->max_vsize_id = from->max_vsize_id;
+	}
+	dest->ave_vsize += from->ave_vsize;
+	
+	if(dest->max_rss < from->max_rss) {
+		dest->max_rss = from->max_rss;
+		dest->max_rss_id = from->max_rss_id;
+	}
+	dest->ave_rss += from->ave_rss;
+	
+	if(dest->max_pages < from->max_pages) {
+		dest->max_pages = from->max_pages;
+		dest->max_pages_id = from->max_pages_id;
+	}
+	dest->ave_pages += from->ave_pages;
+	
+	if((dest->min_cpu > from->min_cpu) 
+	   || (dest->min_cpu == (float)NO_VAL)) {
+		dest->min_cpu = from->min_cpu;
+		dest->min_cpu_id = from->min_cpu_id;
+	}
+	dest->ave_cpu += from->ave_cpu;
+}
diff --git a/src/sstat/sstat.c b/src/sstat/sstat.c
new file mode 100644
index 0000000000000000000000000000000000000000..58f75d55df94ff5c51fdbf63c9ee3d86e662cdf4
--- /dev/null
+++ b/src/sstat/sstat.c
@@ -0,0 +1,273 @@
+/*****************************************************************************\
+ *  sstat.c - job accounting reports for SLURM's jobacct/log plugin
+ *****************************************************************************
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include "sstat.h"
+
+void _destroy_steps(void *object);
+void _print_header(void);
+void *_stat_thread(void *args);
+int _sstat_query(slurm_step_layout_t *step_layout, uint32_t job_id, 
+		 uint32_t step_id);
+int _process_results();
+int _do_stat(uint32_t jobid, uint32_t stepid);
+
+/*
+ * Globals
+ */
+	sacct_parameters_t params;
+fields_t fields[] = {{"cputime", print_cputime}, 
+		     {"jobid", print_jobid}, 
+		     {"ntasks", print_ntasks}, 
+		     {"pages", print_pages}, 
+		     {"rss", print_rss},
+		     {"state", print_state}, 
+		     {"vsize", print_vsize}, 
+		     {NULL, NULL}};
+
+List jobs = NULL;
+jobacct_step_rec_t step;
+
+int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
+	nprintfields = 0;
+
+void _destroy_steps(void *object)
+{
+	jobacct_selected_step_t *step = (jobacct_selected_step_t *)object;
+	if(step) {
+		xfree(step->job);
+		xfree(step->step);
+		xfree(step);
+	}
+}
+
+void _print_header(void)
+{
+	int	i,j;
+	for (i=0; i<nprintfields; i++) {
+		if (i)
+			printf(" ");
+		j=printfields[i];
+		(fields[j].print_routine)(HEADLINE, 0);
+	}
+	printf("\n");
+	for (i=0; i<nprintfields; i++) {
+		if (i)
+			printf(" ");
+		j=printfields[i];
+		(fields[j].print_routine)(UNDERSCORE, 0);
+	}
+	printf("\n");
+}
+
+int _sstat_query(slurm_step_layout_t *step_layout, uint32_t job_id,
+		 uint32_t step_id)
+{
+	slurm_msg_t msg;
+	stat_jobacct_msg_t r;
+	stat_jobacct_msg_t *jobacct_msg = NULL;
+	ListIterator itr;
+	List ret_list = NULL;
+	sacct_t temp_sacct;
+	ret_data_info_t *ret_data_info = NULL;
+	int rc = SLURM_SUCCESS;
+	int ntasks = 0;
+	int tot_tasks = 0;
+	debug("getting the stat of job %d on %d nodes", 
+	      job_id, step_layout->node_cnt);
+
+	memset(&temp_sacct, 0, sizeof(sacct_t));
+	temp_sacct.min_cpu = (float)NO_VAL;
+	memset(&step.sacct, 0, sizeof(sacct_t));
+	step.sacct.min_cpu = (float)NO_VAL;
+
+	step.jobid = job_id;
+	step.stepid = step_id;
+	step.nodes = step_layout->node_list;
+	step.stepname = NULL;
+	step.state = JOB_RUNNING;
+	slurm_msg_t_init(&msg);
+	/* Common message contents */
+	r.job_id      = job_id;
+	r.step_id     = step_id;
+	r.jobacct     = jobacct_gather_g_create(NULL);
+	msg.msg_type        = MESSAGE_STAT_JOBACCT;
+	msg.data            = &r;
+	
+	ret_list = slurm_send_recv_msgs(step_layout->node_list, &msg, 0);
+	if (!ret_list) {
+		error("got an error no list returned");
+		goto cleanup;
+	}
+	
+	itr = list_iterator_create(ret_list);		
+	while((ret_data_info = list_next(itr))) {
+		switch (ret_data_info->type) {
+		case MESSAGE_STAT_JOBACCT:
+			jobacct_msg = (stat_jobacct_msg_t *)
+				ret_data_info->data;
+			if(jobacct_msg) {
+				debug2("got it back for job %d", 
+				       jobacct_msg->job_id);
+				jobacct_gather_g_2_sacct(
+					&temp_sacct, 
+					jobacct_msg->jobacct);
+				ntasks += jobacct_msg->num_tasks;
+				aggregate_sacct(&step.sacct, &temp_sacct);
+			}
+			break;
+		case RESPONSE_SLURM_RC:
+			rc = slurm_get_return_code(ret_data_info->type, 
+						   ret_data_info->data);
+			error("there was an error with the request rc = %s", 
+			      slurm_strerror(rc));
+			break;
+		default:
+			rc = slurm_get_return_code(ret_data_info->type, 
+						   ret_data_info->data);
+			error("unknown return given %d rc = %s", 
+			      ret_data_info->type, slurm_strerror(rc));
+			break;
+		}
+	}
+	list_iterator_destroy(itr);
+	list_destroy(ret_list);
+
+	tot_tasks += ntasks;		
+cleanup:
+	
+	if(tot_tasks) {
+		step.sacct.ave_rss *= 1024;
+		step.sacct.max_rss *= 1024;
+		step.sacct.ave_vsize *= 1024;
+		step.sacct.max_vsize *= 1024;
+
+		step.sacct.ave_cpu /= tot_tasks;
+		step.sacct.ave_cpu /= 100;
+		step.sacct.min_cpu /= 100;
+		step.sacct.ave_rss /= tot_tasks;
+		step.sacct.ave_vsize /= tot_tasks;
+		step.sacct.ave_pages /= tot_tasks;
+	}
+	jobacct_gather_g_destroy(r.jobacct);	
+	return SLURM_SUCCESS;
+}
+
+int _process_results()
+{
+	print_fields(JOBSTEP, &step);
+	return SLURM_SUCCESS;
+}
+
+int _do_stat(uint32_t jobid, uint32_t stepid)
+{
+	slurm_msg_t req_msg;
+	slurm_msg_t resp_msg;
+	job_step_id_msg_t req;
+	slurm_step_layout_t *step_layout = NULL;
+	int rc = SLURM_SUCCESS;
+
+	slurm_msg_t_init(&req_msg);
+	slurm_msg_t_init(&resp_msg);
+	debug("requesting info for job %u.%u", jobid, stepid);
+	req.job_id = jobid;
+	req.step_id = stepid;
+	req_msg.msg_type = REQUEST_STEP_LAYOUT;
+	req_msg.data     = &req;
+	
+	if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) {
+		return SLURM_ERROR;
+	}
+		
+	switch (resp_msg.msg_type) {
+	case RESPONSE_STEP_LAYOUT:
+		step_layout = (slurm_step_layout_t *)resp_msg.data;
+		break;
+	case RESPONSE_SLURM_RC:
+		rc = ((return_code_msg_t *) resp_msg.data)->return_code;
+		slurm_free_return_code_msg(resp_msg.data);	
+		printf("problem getting job: %s\n", slurm_strerror(rc));
+		slurm_seterrno_ret(rc);
+		break;
+	default:
+		slurm_seterrno_ret(SLURM_UNEXPECTED_MSG_ERROR);
+		break;
+	}
+		
+	if(!step_layout) {
+		error("didn't get the job record rc = %s", slurm_strerror(rc));
+		return rc;
+	}
+
+	_sstat_query(step_layout, jobid, stepid);
+	
+	_process_results();
+	
+	slurm_step_layout_destroy(step_layout);	
+	
+	return rc;
+}
+
+int main(int argc, char **argv)
+{
+	ListIterator itr = NULL;
+	uint32_t jobid = 0;
+	uint32_t stepid = 0;
+	jobacct_selected_step_t *selected_step = NULL;
+	
+	List selected_steps = list_create(_destroy_steps);
+
+	parse_command_line(argc, argv, selected_steps);
+
+	if (params.opt_header) 	/* give them something to look */
+		_print_header();/* at while we think...        */
+	itr = list_iterator_create(selected_steps);
+	while((selected_step = list_next(itr))) {
+		jobid = atoi(selected_step->job);
+		if(selected_step->step)
+			stepid = atoi(selected_step->step);
+		else
+			stepid = 0;
+		_do_stat(jobid, stepid);
+	}
+	list_iterator_destroy(itr);
+		
+	list_destroy(selected_steps);
+
+	return 0;
+}
+
+
diff --git a/src/sstat/sstat.h b/src/sstat/sstat.h
new file mode 100644
index 0000000000000000000000000000000000000000..94b971980d51475d55cfd07aa8ad947d2d66c50a
--- /dev/null
+++ b/src/sstat/sstat.h
@@ -0,0 +1,119 @@
+/*****************************************************************************\
+ *  sstat.h - header file for sstat
+ *
+ *  $Id: sstat.h 7541 2006-03-18 01:44:58Z da $
+ *****************************************************************************
+ *  Copyright (C) 2002-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  In addition, as a special exception, the copyright holders give permission 
+ *  to link the code of portions of this program with the OpenSSL library under
+ *  certain conditions as described in each individual source file, and 
+ *  distribute linked combinations including the two. You must obey the GNU 
+ *  General Public License in all respects for all of the code used other than 
+ *  OpenSSL. If you modify file(s) with this exception, you may extend this 
+ *  exception to your version of the file(s), but you are not obligated to do 
+ *  so. If you do not wish to do so, delete this exception statement from your
+ *  version.  If you delete this exception statement from all source files in 
+ *  the program, then also delete it here.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+#ifndef _SSTAT_H
+#define _SSTAT_H
+
+#include <ctype.h>
+#include <errno.h>
+#include <grp.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "src/common/getopt.h"
+#include "src/common/xmalloc.h"
+#include "src/common/xstring.h"
+#include "src/common/list.h"
+#include "src/common/hostlist.h"
+#include "src/common/slurm_jobacct_gather.h"
+#include "src/common/slurm_accounting_storage.h"
+#include "src/common/slurm_jobcomp.h"
+
+#define ERROR 2
+
+#define STAT_FIELDS "jobid,vsize,rss,pages,cputime,ntasks,state"
+
+#define BUFFER_SIZE 4096
+#define STATE_COUNT 10
+
+#define MAX_PRINTFIELDS 100
+
+#define SECONDS_IN_MINUTE 60
+#define SECONDS_IN_HOUR (60*SECONDS_IN_MINUTE)
+#define SECONDS_IN_DAY (24*SECONDS_IN_HOUR)
+
+/* On output, use fields 12-37 from JOB_STEP */
+
+typedef enum {	HEADLINE,
+		UNDERSCORE,
+		JOB,
+		JOBSTEP,
+		JOBCOMP
+} type_t;
+
+
+typedef struct fields {
+	char *name;		/* Specified in --fields= */
+	void (*print_routine) ();	/* Who gets to print it? */
+} fields_t;
+
+extern fields_t fields[];
+extern sacct_parameters_t params;
+
+extern List jobs;
+
+extern int printfields[MAX_PRINTFIELDS],	/* Indexed into fields[] */
+	nprintfields;
+
+/* process.c */
+void find_hostname(uint32_t pos, char *hosts, char *host);
+void aggregate_sacct(sacct_t *dest, sacct_t *from);
+
+/* print.c */
+void print_cputime(type_t type, void *object);
+void print_fields(type_t type, void *object);
+void print_jobid(type_t type, void *object);
+void print_ntasks(type_t type, void *object);
+void print_pages(type_t type, void *object);
+void print_rss(type_t type, void *object);
+void print_state(type_t type, void *object);
+void print_vsize(type_t type, void *object);
+
+
+/* options.c */
+void parse_command_line(int argc, char **argv, List selected_steps);
+
+#endif /* !_SACCT_H */
diff --git a/src/strigger/Makefile.in b/src/strigger/Makefile.in
index ffb5dbbea011d1e3aca3039c4a33a6d4c5cc1e6a..1755ca5fadc86a3c545e847222037e2e5fc147ab 100644
--- a/src/strigger/Makefile.in
+++ b/src/strigger/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -48,6 +48,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -77,7 +79,7 @@ strigger_DEPENDENCIES = $(top_builddir)/src/api/libslurmhelper.la
 strigger_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(strigger_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -118,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -131,10 +134,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -154,7 +160,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -165,6 +174,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -180,6 +191,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -195,6 +207,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -299,8 +312,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -363,8 +376,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/strigger/opts.c b/src/strigger/opts.c
index 987d3cfc988f1ad3ddddfb4dabe22e0169640382..499e3e60feb5e389723bad5230b52f105eb1425a 100644
--- a/src/strigger/opts.c
+++ b/src/strigger/opts.c
@@ -2,9 +2,10 @@
  *  opts.c - strigger command line option processing functions
  *****************************************************************************
  *  Copyright (C) 2006-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -92,6 +93,8 @@ extern void parse_command_line(int argc, char *argv[])
 	static struct option long_options[] = {
 		{"block_err", no_argument,       0, OPT_LONG_BLOCK_ERR},
 		{"down",      no_argument,       0, 'd'},
+		{"drained",   no_argument,       0, 'D'},
+		{"fail",      no_argument,       0, 'F'},
 		{"fini",      no_argument,       0, 'f'},
 		{"id",        required_argument, 0, 'i'},
 		{"idle",      no_argument,       0, 'I'},
@@ -117,7 +120,7 @@ extern void parse_command_line(int argc, char *argv[])
 	_init_options();
 
 	optind = 0;
-	while((opt_char = getopt_long(argc, argv, "dfi:Ij:no:p:qrtuvV",
+	while((opt_char = getopt_long(argc, argv, "dDFfi:Ij:no:p:qrtuvV",
 			long_options, &option_index)) != -1) {
 		switch (opt_char) {
 		case (int)'?':
@@ -131,6 +134,12 @@ extern void parse_command_line(int argc, char *argv[])
 		case (int)'d':
 			params.node_down = true;
 			break;
+		case (int)'D':
+			params.node_drained = true;
+			break;
+		case (int)'F':
+			params.node_fail = true;
+			break;
 		case (int)'f':
 			params.job_fini = true;
 			break;
@@ -221,49 +230,53 @@ extern void parse_command_line(int argc, char *argv[])
 /* initialize the parameters */
 static void _init_options( void )
 {
-	params.mode_set   = false;
-	params.mode_get   = false;
-	params.mode_clear = false;
+	params.mode_set     = false;
+	params.mode_get     = false;
+	params.mode_clear   = false;
 
-	params.block_err  = false;
-	params.node_down  = false;
-	params.node_idle  = false;
-	params.trigger_id = 0;
-	params.job_fini   = false;
-	params.job_id     = 0;
-	params.node_id    = NULL;
-	params.offset     = 0;
-	params.program    = NULL;
-	params.quiet      = false;
-	params.reconfig   = false;
-	params.time_limit = false;
-	params.node_up    = false;
-	params.user_id    = 0;
-	params.verbose    = 0;
+	params.block_err    = false;
+	params.node_down    = false;
+	params.node_drained = false;
+	params.node_fail    = false;
+	params.node_idle    = false;
+	params.trigger_id   = 0;
+	params.job_fini     = false;
+	params.job_id       = 0;
+	params.node_id      = NULL;
+	params.offset       = 0;
+	params.program      = NULL;
+	params.quiet        = false;
+	params.reconfig     = false;
+	params.time_limit   = false;
+	params.node_up      = false;
+	params.user_id      = 0;
+	params.verbose      = 0;
 }
 
 /* print the parameters specified */
 static void _print_options( void )
 {
 	verbose("-----------------------------");
-	verbose("set        = %s", params.mode_set ? "true" : "false");
-	verbose("get        = %s", params.mode_get ? "true" : "false");
-	verbose("clear      = %s", params.mode_clear ? "true" : "false");
-	verbose("block_err  = %s", params.block_err ? "true" : "false");
-	verbose("job_id     = %u", params.job_id);
-	verbose("job_fini   = %s", params.job_fini ? "true" : "false");
-	verbose("node_down  = %s", params.node_down ? "true" : "false");
-	verbose("node_idle  = %s", params.node_idle ? "true" : "false");
-	verbose("node_up    = %s", params.node_up ? "true" : "false");
-	verbose("node       = %s", params.node_id);
-	verbose("offset     = %d secs", params.offset);
-	verbose("program    = %s", params.program);
-	verbose("quiet      = %s", params.quiet ? "true" : "false");
-	verbose("reconfig   = %s", params.reconfig ? "true" : "false");
-	verbose("time_limit = %s", params.time_limit ? "true" : "false");
-	verbose("trigger_id = %u", params.trigger_id);
-	verbose("user_id    = %u", params.user_id);
-	verbose("verbose    = %d", params.verbose);
+	verbose("set          = %s", params.mode_set ? "true" : "false");
+	verbose("get          = %s", params.mode_get ? "true" : "false");
+	verbose("clear        = %s", params.mode_clear ? "true" : "false");
+	verbose("block_err    = %s", params.block_err ? "true" : "false");
+	verbose("job_id       = %u", params.job_id);
+	verbose("job_fini     = %s", params.job_fini ? "true" : "false");
+	verbose("node_down    = %s", params.node_down ? "true" : "false");
+	verbose("node_drained = %s", params.node_drained ? "true" : "false");
+	verbose("node_fail    = %s", params.node_fail ? "true" : "false");
+	verbose("node_idle    = %s", params.node_idle ? "true" : "false");
+	verbose("node_up      = %s", params.node_up ? "true" : "false");
+	verbose("node         = %s", params.node_id);
+	verbose("offset       = %d secs", params.offset);
+	verbose("program      = %s", params.program);
+	verbose("quiet        = %s", params.quiet ? "true" : "false");
+	verbose("reconfig     = %s", params.reconfig ? "true" : "false");
+	verbose("time_limit   = %s", params.time_limit ? "true" : "false");
+	verbose("trigger_id   = %u", params.trigger_id);
+	verbose("user_id      = %u", params.user_id);
+	verbose("verbose      = %d", params.verbose);
 	verbose("-----------------------------");
 }
 
@@ -282,7 +295,8 @@ static void _validate_options( void )
 	}
 
 	if (params.mode_set
-	&&  ((params.node_down + params.node_idle + params.node_up + params.reconfig +
+	&&  ((params.node_down + params.node_drained + params.node_fail + 
+	      params.node_idle + params.node_up + params.reconfig +
 	      params.job_fini  + params.time_limit + params.block_err) == 0)) {
 		error("You must specify a trigger (--block_err, --down, --up, "
 			"--reconfig, --time or --fini)");
@@ -330,7 +344,7 @@ static void _print_version(void)
 
 static void _usage( void )
 {
-	printf("Usage: strigger [--set | --get | --clear | --version] [-dfiIjnoptuv]\n");
+	printf("Usage: strigger [--set | --get | --clear | --version] [-dDfiIjnoptuv]\n");
 }
 
 static void _help( void )
@@ -342,6 +356,8 @@ Usage: strigger [--set | --get | --clear] [OPTIONS]\n\
       --clear         delete a trigger\n\n\
       --block_err     trigger event on BlueGene block error\n\
   -d, --down          trigger event when node goes DOWN\n\
+  -D, --drained       trigger event when node becomes DRAINED\n\
+  -F, --fail          trigger event when node is expected to FAIL\n\
   -f, --fini          trigger event when job finishes\n\
   -i, --id=#          a trigger's ID number\n\
   -I, --idle          trigger event when node remains IDLE\n\
diff --git a/src/strigger/strigger.c b/src/strigger/strigger.c
index c8789e689cee843c434f772373c3543c98bbf17d..6371787d564f810c8defa84072652bf47c605492 100644
--- a/src/strigger/strigger.c
+++ b/src/strigger/strigger.c
@@ -2,9 +2,10 @@
  *  strigger.c - Manage slurm event triggers
  *****************************************************************************
  *  Copyright (C) 2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -147,6 +148,10 @@ static int _set_trigger(void)
 		ti.trig_type |= TRIGGER_TYPE_BLOCK_ERR;
 	if (params.node_down)
 		ti.trig_type |= TRIGGER_TYPE_DOWN;
+	if (params.node_drained)
+		ti.trig_type |= TRIGGER_TYPE_DRAINED;
+	if (params.node_fail)
+		ti.trig_type |= TRIGGER_TYPE_FAIL;
 	if (params.node_idle)
 		ti.trig_type |= TRIGGER_TYPE_IDLE;
 	if (params.node_up)
@@ -208,6 +213,20 @@ static int _get_trigger(void)
 					!= TRIGGER_TYPE_DOWN))
 				continue;
 		}
+		if (params.node_drained) {
+			if ((trig_msg->trigger_array[i].res_type  
+					!= TRIGGER_RES_TYPE_NODE)
+			||  (trig_msg->trigger_array[i].trig_type 
+					!= TRIGGER_TYPE_DRAINED))
+				continue;
+		}
+		if (params.node_fail) {
+			if ((trig_msg->trigger_array[i].res_type  
+					!= TRIGGER_RES_TYPE_NODE)
+			||  (trig_msg->trigger_array[i].trig_type 
+					!= TRIGGER_TYPE_FAIL))
+				continue;
+		}
 		if (params.node_id) {
 			if (trig_msg->trigger_array[i].res_type  
 					!= TRIGGER_RES_TYPE_NODE)
@@ -281,6 +300,10 @@ static char *_trig_type(uint16_t trig_type)
 		return "up";
 	else if (trig_type == TRIGGER_TYPE_DOWN)
 		return "down";
+	else if (trig_type == TRIGGER_TYPE_DRAINED)
+		return "drained";
+	else if (trig_type == TRIGGER_TYPE_FAIL)
+		return "fail";
 	else if (trig_type == TRIGGER_TYPE_IDLE)
 		return "idle";
 	else if (trig_type == TRIGGER_TYPE_TIME)
diff --git a/src/strigger/strigger.h b/src/strigger/strigger.h
index 8aa26706a26a0cdc442312b39274f1e0a196914f..a91c08b0febfff804c5551cbb734ab31aef8fd26 100644
--- a/src/strigger/strigger.h
+++ b/src/strigger/strigger.h
@@ -2,9 +2,10 @@
  *  strigger.h - definitions used for strigger functions
  *****************************************************************************
  *  Copyright (C) 2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -54,7 +55,9 @@ struct strigger_parameters {
 	bool     mode_get;
 	bool     mode_clear;
 	bool     node_down;
+	bool     node_drained;
 	char *   node_id;
+	bool     node_fail;
 	bool     node_idle;
 	bool     node_up;
 	int      offset;
diff --git a/src/sview/Makefile.am b/src/sview/Makefile.am
index 7d534584433894c665d7d4422c648c120369a7a7..bf2e360c942659dbcce70afc010bd8bb736fa318 100644
--- a/src/sview/Makefile.am
+++ b/src/sview/Makefile.am
@@ -10,7 +10,9 @@ if HAVE_GTK
 bin_PROGRAMS = sview
 
 sview_LDADD =					  \
-	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la  \
+	$(top_builddir)/src/api/libslurmhelper.la
+
 
 noinst_HEADERS = sview.h
 sview_SOURCES = sview.c popups.c grid.c part_info.c job_info.c \
diff --git a/src/sview/Makefile.in b/src/sview/Makefile.in
index f72b149de2415b3bdc9b58e7111dce431df9271e..c46c9bfb4a56128155e0127afc29fd5431979d51 100644
--- a/src/sview/Makefile.in
+++ b/src/sview/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -49,6 +49,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -88,11 +90,12 @@ am__EXTRA_sview_SOURCES_DIST = sview.h sview.c popups.c grid.c \
 	part_info.c job_info.c block_info.c node_info.c submit_info.c \
 	admin_info.c common.c
 sview_OBJECTS = $(am_sview_OBJECTS)
-@HAVE_GTK_TRUE@sview_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la
+@HAVE_GTK_TRUE@sview_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \
+@HAVE_GTK_TRUE@	$(top_builddir)/src/api/libslurmhelper.la
 sview_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(sview_CFLAGS) $(CFLAGS) $(sview_LDFLAGS) \
 	$(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -135,6 +138,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -148,10 +152,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -171,7 +178,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -182,6 +192,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -197,6 +209,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -212,6 +225,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -271,7 +285,8 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = foreign
 INCLUDES = -I$(top_srcdir) $(BG_INCLUDES)
 @HAVE_GTK_TRUE@sview_LDADD = \
-@HAVE_GTK_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la 
+@HAVE_GTK_TRUE@	$(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la  \
+@HAVE_GTK_TRUE@	$(top_builddir)/src/api/libslurmhelper.la
 
 @HAVE_GTK_TRUE@noinst_HEADERS = sview.h
 @HAVE_GTK_TRUE@sview_SOURCES = sview.c popups.c grid.c part_info.c job_info.c \
@@ -326,8 +341,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
 	     || test -f $$p1 \
 	  ; then \
 	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
 	  else :; fi; \
 	done
 
@@ -538,8 +553,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -551,8 +566,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -562,13 +577,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/src/sview/admin_info.c b/src/sview/admin_info.c
index 908fffa1f5e1e5292fb7ffbff7ff06f89606c321..a73189f4c3fa79af1aa7440955991f6f01f8cb6c 100644
--- a/src/sview/admin_info.c
+++ b/src/sview/admin_info.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sview/block_info.c b/src/sview/block_info.c
index ee1afa88e4063eaec4d3fdbedc030eb268244fc9..cc8e26892644f0bde1076baea7b82bfe88c5ffa2 100644
--- a/src/sview/block_info.c
+++ b/src/sview/block_info.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  * 
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sview/common.c b/src/sview/common.c
index 62330728bc6cb0baec64a9950a5c9cab90e56ac9..aecce533c8eb4e4cbb8d62cd30fe30b52f6988bb 100644
--- a/src/sview/common.c
+++ b/src/sview/common.c
@@ -5,7 +5,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sview/grid.c b/src/sview/grid.c
index 4d0fa0566b85eeb23a9d8383be1246d010b8cc15..1ebdcc20e8439c0527f03fb1ee3e46ea6f90c9aa 100644
--- a/src/sview/grid.c
+++ b/src/sview/grid.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -384,7 +384,6 @@ extern void get_button_list_from_main(List *button_list, int start, int end,
 		*button_list = list_create(destroy_grid_button);
 	
 	color_inx %= sview_colors_cnt;
-	
 	itr = list_iterator_create(grid_button_list);
 	while((grid_button = list_next(itr))) {
 		if ((grid_button->inx < start)
diff --git a/src/sview/job_info.c b/src/sview/job_info.c
index 2bbc43be2e2515d27974940737e6aea9107ea35d..7155dc4b4e5a37db8423d108ce1ca09a80971b8e 100644
--- a/src/sview/job_info.c
+++ b/src/sview/job_info.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842. 
+ *  LLNL-CODE-402394. 
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -87,7 +87,6 @@ enum {
 	SORTID_LINUXIMAGE,
 #endif
 	SORTID_MAX_CORES,
-	SORTID_MAX_MEM,
 	SORTID_MAX_NODES,
 	SORTID_MAX_SOCKETS,
 #ifdef HAVE_BG
@@ -263,8 +262,6 @@ static display_data_t display_data_job[] = {
 	 FALSE, EDIT_NONE, refresh_job, create_model_job, admin_edit_job},
 	{G_TYPE_STRING, SORTID_MIN_MEM, "Min Memory", 
 	 FALSE, EDIT_TEXTBOX, refresh_job, create_model_job, admin_edit_job},
-	{G_TYPE_STRING, SORTID_MAX_MEM, "Max Memory", 
-	 FALSE, EDIT_NONE, refresh_job, create_model_job, admin_edit_job},
 	{G_TYPE_STRING, SORTID_TMP_DISK, "Tmp Disk", 
 	 FALSE, EDIT_TEXTBOX, refresh_job, create_model_job, admin_edit_job},
 	{G_TYPE_STRING, SORTID_NICE, "Nice", 
@@ -696,12 +693,8 @@ static const char *_set_job_msg(job_desc_msg_t *job_msg, const char *new_text,
 		type = "account";
 		break;
 	case SORTID_DEPENDENCY:
-		temp_int = strtol(new_text, (char **)NULL, 10);
-		
+		job_msg->dependency = xstrdup(new_text);	
 		type = "dependency";
-		if(temp_int <= 0)
-			goto return_error;
-		job_msg->dependency = (uint32_t)temp_int;
 		break;
 #ifdef HAVE_BG
 	case SORTID_GEOMETRY:
@@ -1396,14 +1389,10 @@ static void _layout_job_record(GtkTreeView *treeview,
 						 SORTID_FEATURES),
 				   job_ptr->features);
 	
-	if(job_ptr->dependency > 0) 
-		sprintf(tmp_char, "%u", job_ptr->dependency);
-	else 
-		sprintf(tmp_char, " ");
 	add_display_treestore_line(update, treestore, &iter, 
 				   find_col_name(display_data_job,
 						 SORTID_DEPENDENCY),
-				   tmp_char);
+				   job_ptr->dependency);
 	
 	add_display_treestore_line(update, treestore, &iter, 
 				   find_col_name(display_data_job,
@@ -1679,21 +1668,16 @@ static void _update_job_record(sview_job_info_t *sview_job_info_ptr,
 	gtk_tree_store_set(treestore, iter,
 			   SORTID_MIN_MEM, tmp_char, -1);
 
-	sprintf(tmp_char, "%u", job_ptr->job_max_memory);
-	gtk_tree_store_set(treestore, iter,
-			   SORTID_MAX_MEM, tmp_char, -1);
-	
 	sprintf(tmp_char, "%u", job_ptr->job_min_tmp_disk);
 	gtk_tree_store_set(treestore, iter,
 			   SORTID_TMP_DISK, tmp_char, -1);
 
 	gtk_tree_store_set(treestore, iter,
 			   SORTID_ACCOUNT, job_ptr->account, -1);
-	if(job_ptr->dependency > 0) {
-		sprintf(tmp_char, "%u", job_ptr->dependency);
-		gtk_tree_store_set(treestore, iter,
-				   SORTID_DEPENDENCY, tmp_char, -1);
-	}
+
+	gtk_tree_store_set(treestore, iter,
+			   SORTID_DEPENDENCY, job_ptr->dependency, -1);
+
 	sprintf(tmp_char, "%u", job_ptr->priority);
 	gtk_tree_store_set(treestore, iter,
 			   SORTID_PRIORITY, tmp_char, -1);
@@ -2151,6 +2135,7 @@ static List _create_job_info_list(job_info_msg_t *job_info_ptr,
 		count = 0;
 		while(job_ptr->node_inx[count] != -1)
 			count++;
+		count++; // for the -1;
 #endif
 	
 		for(j = 0; j < step_info_ptr->job_step_count; j++) {
@@ -2214,6 +2199,7 @@ void _display_info_job(List info_list, popup_info_t *popup_win)
 	}
 	if(!list_count(popup_win->grid_button_list)) 
 		first_time = 1;
+
 need_refresh:
 	if(!spec_info->display_widget) {
 		treeview = create_treeview_2cols_attach_to_table(
diff --git a/src/sview/node_info.c b/src/sview/node_info.c
index 2330f0f8f71ece64c86c29da46cb8e2517bced10..53889f8ef94497b8702fa6dee918b0fcf37ff2b7 100644
--- a/src/sview/node_info.c
+++ b/src/sview/node_info.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sview/part_info.c b/src/sview/part_info.c
index bf53ddb10457eaa20b2e1f98c3d130f553e8be5f..ad0fb43e4152817632f0cfe2ad2972870a0f7165 100644
--- a/src/sview/part_info.c
+++ b/src/sview/part_info.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *   
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -88,6 +88,7 @@ enum {
 #endif
 	SORTID_NODES, 
 	SORTID_ONLY_LINE, 
+	SORTID_PRIORITY,
 	SORTID_REASON,
 	SORTID_ROOT, 
 	SORTID_SHARE, 
@@ -125,6 +126,8 @@ static display_data_t display_data_part[] = {
 #endif
 	{G_TYPE_STRING, SORTID_JOB_SIZE, "Job Size", FALSE,
 	 EDIT_NONE, refresh_part, create_model_part, admin_edit_part},
+	{G_TYPE_STRING, SORTID_PRIORITY, "Priority", FALSE,
+	 EDIT_TEXTBOX, refresh_part, create_model_part, admin_edit_part},
 	{G_TYPE_STRING, SORTID_MIN_NODES, "Min Nodes", FALSE,
 	 EDIT_TEXTBOX, refresh_part, create_model_part, admin_edit_part},
 	{G_TYPE_STRING, SORTID_MAX_NODES, "Max Nodes", FALSE,
@@ -332,6 +335,8 @@ static void _set_active_combo_part(GtkComboBox *combo,
 			action = 1;
 		else if(!strcmp(temp_char, "force"))
 			action = 2;
+		else if(!strcmp(temp_char, "exclusive"))
+			action = 3;
 		else 
 			action = 0;
 		break;
@@ -411,6 +416,11 @@ static const char *_set_part_msg(update_part_msg_t *part_msg,
 			goto return_error;
 		part_msg->max_time = (uint32_t)temp_int;
 		break;
+	case SORTID_PRIORITY:
+		temp_int = strtol(new_text, (char **)NULL, 10);
+		type = "priority";
+		part_msg->priority = (uint16_t)temp_int;
+		break;
 	case SORTID_MIN_NODES:
 		temp_int = strtol(new_text, (char **)NULL, 10);
 		type = "min_nodes";
@@ -442,11 +452,13 @@ static const char *_set_part_msg(update_part_msg_t *part_msg,
 		break;
 	case SORTID_SHARE:
 		if (!strcasecmp(new_text, "yes")) {
-			part_msg->shared = SHARED_YES;
-		} else if (!strcasecmp(new_text, "no")) {
-			part_msg->shared = SHARED_NO;
-		} else {
-			part_msg->shared = SHARED_FORCE;
+			 part_msg->max_share = 4;
+		} else if (!strcasecmp(new_text, "exclusive")) {
+			part_msg->max_share = 0;
+		} else if (!strcasecmp(new_text, "force")) {
+			part_msg->max_share = SHARED_FORCE | 4;
+		} else {	/* "no" */
+			part_msg->max_share = 1;
 		}
 		type = "share";
 		break;
@@ -722,7 +734,7 @@ static void _layout_part_record(GtkTreeView *treeview,
 {
 	GtkTreeIter iter;
 	ListIterator itr = NULL;
-	char time_buf[20];
+	char time_buf[20], tmp_buf[20];
 	char tmp_cnt[8];
 	char tmp_cnt1[8];
 	char tmp_cnt2[8];
@@ -794,7 +806,14 @@ static void _layout_part_record(GtkTreeView *treeview,
 				   find_col_name(display_data_part,
 						 SORTID_JOB_SIZE),
 				   time_buf);
-	
+
+	convert_num_unit((float)part_ptr->priority,
+			 time_buf, sizeof(time_buf), UNIT_NONE);
+	add_display_treestore_line(update, treestore, &iter,
+				   find_col_name(display_data_part,
+						 SORTID_PRIORITY),
+				   time_buf);
+				   
 	if (part_ptr->min_nodes == (uint32_t) INFINITE)
 		snprintf(time_buf, sizeof(time_buf), "infinite");
 	else {
@@ -825,11 +844,17 @@ static void _layout_part_record(GtkTreeView *treeview,
 						 SORTID_ROOT),
 				   temp_char);
 		
-	if(part_ptr->shared > 1)
-		temp_char = "force";
-	else if(part_ptr->shared)
-		temp_char = "yes";
-	else 
+	if(part_ptr->max_share & SHARED_FORCE) {
+		snprintf(tmp_buf, sizeof(tmp_buf), "force:%u", 
+			 (part_ptr->max_share & ~(SHARED_FORCE))); 
+		temp_char = tmp_buf;
+	} else if(part_ptr->max_share == 0)
+		temp_char = "exclusive";
+	else if(part_ptr->max_share > 1) {
+		snprintf(tmp_buf, sizeof(tmp_buf), "yes:%u", 
+			 part_ptr->max_share);
+		temp_char = tmp_buf;
+	} else 
 		temp_char = "no";
 	add_display_treestore_line(update, treestore, &iter,
 				   find_col_name(display_data_part,
@@ -921,7 +946,7 @@ static void _update_part_record(sview_part_info_t *sview_part_info,
 				GtkTreeStore *treestore, 
 				GtkTreeIter *iter)
 {
-	char time_buf[20];
+	char time_buf[20], tmp_buf[20];
 	char tmp_cnt[8];
 	char *temp_char = NULL;
 	partition_info_t *part_ptr = sview_part_info->part_ptr;
@@ -962,6 +987,11 @@ static void _update_part_record(sview_part_info_t *sview_part_info,
 			      part_ptr->max_nodes, true);
 	gtk_tree_store_set(treestore, iter, SORTID_JOB_SIZE, time_buf, -1);
 	
+	convert_num_unit((float)part_ptr->priority,
+			 time_buf, sizeof(time_buf), UNIT_NONE);
+	gtk_tree_store_set(treestore, iter, SORTID_PRIORITY,
+			   time_buf, -1);
+
 	if (part_ptr->min_nodes == (uint32_t) INFINITE)
 		snprintf(time_buf, sizeof(time_buf), "infinite");
 	else {
@@ -985,11 +1015,17 @@ static void _update_part_record(sview_part_info_t *sview_part_info,
 		temp_char = "no";
 	gtk_tree_store_set(treestore, iter, SORTID_ROOT, temp_char, -1);
 	
-	if(part_ptr->shared > 1)
-		temp_char = "force";
-	else if(part_ptr->shared)
-		temp_char = "yes";
-	else 
+	if(part_ptr->max_share & SHARED_FORCE) {
+		snprintf(tmp_buf, sizeof(tmp_buf), "force:%u", 
+			 (part_ptr->max_share & ~(SHARED_FORCE))); 
+		temp_char = tmp_buf;
+	} else if(part_ptr->max_share == 0)
+		temp_char = "exclusive";
+	else if(part_ptr->max_share > 1) {
+		snprintf(tmp_buf, sizeof(tmp_buf), "yes:%u", 
+			 part_ptr->max_share);
+		temp_char = tmp_buf;
+	} else 
 		temp_char = "no";
 	gtk_tree_store_set(treestore, iter, SORTID_SHARE, temp_char, -1);
 	
@@ -1566,7 +1602,7 @@ need_refresh:
 		treeview = GTK_TREE_VIEW(spec_info->display_widget);
 		update = 1;
 	}
-	
+
 	itr = list_iterator_create(info_list);
 	while ((sview_part_info = (sview_part_info_t*) list_next(itr))) {
 		part_ptr = sview_part_info->part_ptr;
@@ -1709,6 +1745,7 @@ extern GtkListStore *create_model_part(int type)
 				   -1);	
 
 		break;
+	case SORTID_PRIORITY:
 	case SORTID_TIMELIMIT:
 	case SORTID_MIN_NODES:
 	case SORTID_MAX_NODES:
@@ -1730,9 +1767,9 @@ extern GtkListStore *create_model_part(int type)
 		model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
 		gtk_list_store_append(model, &iter);
 		gtk_list_store_set(model, &iter,
-				   0, "yes",
+				   0, "force",
 				   1, SORTID_SHARE,
-				   -1);	
+				   -1);
 		gtk_list_store_append(model, &iter);
 		gtk_list_store_set(model, &iter,
 				   0, "no",
@@ -1740,9 +1777,14 @@ extern GtkListStore *create_model_part(int type)
 				   -1);	
 		gtk_list_store_append(model, &iter);
 		gtk_list_store_set(model, &iter,
-				   0, "force",
+				   0, "yes",
 				   1, SORTID_SHARE,
-				   -1);	
+				   -1);
+		gtk_list_store_append(model, &iter);	
+		gtk_list_store_set(model, &iter,
+				   0, "exclusive",
+				   1, SORTID_SHARE,
+				   -1);
 		break;
 	case SORTID_GROUPS:
 		break;
diff --git a/src/sview/popups.c b/src/sview/popups.c
index a2f1cefb689db4a31c18ec1282e0446faf053c42..f48612022787a4381144f1ffc9f96e99258c1c26 100644
--- a/src/sview/popups.c
+++ b/src/sview/popups.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -222,235 +222,326 @@ static void _layout_ctl_conf(GtkTreeStore *treestore,
 	slurm_make_time_str((time_t *)&slurm_ctl_conf_ptr->last_update, 
 			    temp_str, sizeof(temp_str));
 	add_display_treestore_line(update, treestore, &iter, 
-			    "Configuration data as of", temp_str);
+				   "Configuration data as of", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "AuthType",	slurm_ctl_conf_ptr->authtype);
+				   "AccountingStorageHost", 
+				   slurm_ctl_conf_ptr->accounting_storage_host);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "BackupAddr", slurm_ctl_conf_ptr->backup_addr);
+				   "AccountingStorageType", 
+				   slurm_ctl_conf_ptr->accounting_storage_type);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->accounting_storage_port);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "AccountingStoragePort", 
+				   temp_str);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "AccountingStorageUser", 
+				   slurm_ctl_conf_ptr->accounting_storage_user);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "AuthType", slurm_ctl_conf_ptr->authtype);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "BackupController", 
-			    slurm_ctl_conf_ptr->backup_controller);
+				   "BackupAddr",
+				   slurm_ctl_conf_ptr->backup_addr);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "BackupController", 
+				   slurm_ctl_conf_ptr->backup_controller);
+	slurm_make_time_str ((time_t *)&slurm_ctl_conf_ptr->boot_time,
+			     temp_str, sizeof(temp_str));
+	add_display_treestore_line(update, treestore, &iter, 
+				   "BOOT_TIME", temp_str); 
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->cache_groups);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "CacheGroups", temp_str); 
+				   "CacheGroups", temp_str); 
+	add_display_treestore_line(update, treestore, &iter, 
+				   "CheckpointType",
+				   slurm_ctl_conf_ptr->checkpoint_type);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "ControlAddr", 
+				   slurm_ctl_conf_ptr->control_addr);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "CheckpointType",
-			    slurm_ctl_conf_ptr->checkpoint_type);
+				   "ControlMachine", 
+				   slurm_ctl_conf_ptr->control_machine);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ControlAddr", 
-			    slurm_ctl_conf_ptr->control_addr);
+				   "CryptoType", 
+				   slurm_ctl_conf_ptr->crypto_type);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->def_mem_per_task);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ControlMachine", 
-			    slurm_ctl_conf_ptr->control_machine);
+				   "DefMemPerTask", 
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "Epilog", 
-			    slurm_ctl_conf_ptr->epilog);
+				   "Epilog", 
+				   slurm_ctl_conf_ptr->epilog);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->fast_schedule);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "FastSchedule", 
-			    temp_str);
+				   "FastSchedule", 
+				   temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->first_job_id);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "FirstJobId", 
-			    temp_str);
+				   "FirstJobId", 
+				   temp_str);
 #ifdef HAVE_XCPU
 	add_display_treestore_line(update, treestore, &iter, 
-			    "HAVE_XCPU", "1");
+				   "HAVE_XCPU", "1");
 #endif
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->inactive_limit);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "InactiveLimit", 
-			    temp_str);
+				   "InactiveLimit", 
+				   temp_str);
+
+	add_display_treestore_line(update, treestore, &iter, 
+				   "JobAcctGatherType", 
+				   slurm_ctl_conf_ptr->job_acct_gather_type);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->job_acct_gather_freq);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "JobAcctGatherFrequency",
+				   temp_str);
+
+	add_display_treestore_line(update, treestore, &iter, 
+				   "JobCompHost", 
+				   slurm_ctl_conf_ptr->job_comp_host);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobAcctLogFile", 
-			    slurm_ctl_conf_ptr->job_acct_logfile);
+				   "JobCompLoc", 
+				   slurm_ctl_conf_ptr->job_comp_loc);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
-		 slurm_ctl_conf_ptr->job_acct_freq);
+		 slurm_ctl_conf_ptr->job_comp_port);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobAcctFrequency",
-			    temp_str);
+				   "JobCompPort", 
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobAcctType", 
-			    slurm_ctl_conf_ptr->job_acct_type);
+				   "JobCompType", 
+				   slurm_ctl_conf_ptr->job_comp_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCompLoc", 
-			    slurm_ctl_conf_ptr->job_comp_loc);
+				   "JobCompUser", 
+				   slurm_ctl_conf_ptr->job_comp_user);
+
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCompType", 
-			    slurm_ctl_conf_ptr->job_comp_type);
+				   "JobCredentialPrivateKey", 
+				   slurm_ctl_conf_ptr->job_credential_private_key);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCredentialPrivateKey", 
-			    slurm_ctl_conf_ptr->job_credential_private_key);
+				   "JobCredentialPublicCertificate", 
+				   slurm_ctl_conf_ptr->
+				   job_credential_public_certificate);
+	snprintf(temp_str, sizeof(temp_str), "%u",
+		 slurm_ctl_conf_ptr->job_file_append);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "JobCredentialPublicCertificate", 
-			    slurm_ctl_conf_ptr->
-			    job_credential_public_certificate);
+				   "JobFileAppend", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->kill_wait);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "KillWait", 
-			    temp_str);
+				   "KillWait", 
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MailProg",
-			    slurm_ctl_conf_ptr->mail_prog);
+				   "MailProg",
+				   slurm_ctl_conf_ptr->mail_prog);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->max_job_cnt);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MaxJobCount", 
-			    temp_str);
+				   "MaxJobCount", 
+				   temp_str);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->max_mem_per_task);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "MaxMemPerTask", 
+				   temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->msg_timeout);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MessageTimeout",
-			    temp_str);
+				   "MessageTimeout",
+				   temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->min_job_age);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MinJobAge", 
-			    temp_str);
+				   "MinJobAge", 
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MpiDefault",
-			    slurm_ctl_conf_ptr->mpi_default);
+				   "MpiDefault",
+				   slurm_ctl_conf_ptr->mpi_default);
 #ifdef MULTIPLE_SLURMD
 	add_display_treestore_line(update, treestore, &iter, 
-			    "MULTIPLE_SLURMD", "1");
+				   "MULTIPLE_SLURMD", "1");
 #endif
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->next_job_id);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "NEXT_JOB_ID",
-			    temp_str);
+				   "NEXT_JOB_ID",
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "PluginDir", 
-			    slurm_ctl_conf_ptr->plugindir);
+				   "PluginDir", 
+				   slurm_ctl_conf_ptr->plugindir);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "PlugStackConfig",
+				   slurm_ctl_conf_ptr->plugstack);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->private_data);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "PlugStackConfig",
-			    slurm_ctl_conf_ptr->plugstack);
+				   "PrivateData",
+				   temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ProctrackType",
-			    slurm_ctl_conf_ptr->proctrack_type);
+				   "ProctrackType",
+				   slurm_ctl_conf_ptr->proctrack_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "Prolog", 
-			    slurm_ctl_conf_ptr->prolog);
+				   "Prolog", 
+				   slurm_ctl_conf_ptr->prolog);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->propagate_prio_process);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "PropagatePrioProcess", temp_str);
+				   "PropagatePrioProcess", temp_str);
         add_display_treestore_line(update, treestore, &iter, 
-			    "PropagateResourceLimits",
-			    slurm_ctl_conf_ptr->propagate_rlimits);
+				   "PropagateResourceLimits",
+				   slurm_ctl_conf_ptr->propagate_rlimits);
         add_display_treestore_line(update, treestore, &iter, 
-			    "PropagateResourceLimitsExcept", 
-			    slurm_ctl_conf_ptr->propagate_rlimits_except);
+				   "PropagateResourceLimitsExcept", 
+				   slurm_ctl_conf_ptr->
+				   propagate_rlimits_except);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "ResumeProgram", temp_str);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->resume_rate);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "ResumeRate", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->ret2service);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "ReturnToService", temp_str);
+				   "ReturnToService", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->schedport);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SchedulerPort", temp_str);
+				   "SchedulerPort", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->schedrootfltr);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SchedulerRootFilter", temp_str);
+				   "SchedulerRootFilter", temp_str);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->sched_time_slice);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "SchedulerTimeSlice", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SchedulerType",
-			    slurm_ctl_conf_ptr->schedtype);
+				   "SchedulerType",
+				   slurm_ctl_conf_ptr->schedtype);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SelectType",
-			    slurm_ctl_conf_ptr->select_type);
+				   "SelectType",
+				   slurm_ctl_conf_ptr->select_type);
 	snprintf(temp_str, sizeof(temp_str), "%s(%u)", 
 		 slurm_ctl_conf_ptr->slurm_user_name,
 		 slurm_ctl_conf_ptr->slurm_user_id);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmUser", temp_str);
+				   "SlurmUser", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmctld_debug);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldDebug", temp_str);
+				   "SlurmctldDebug", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldLogFile", 
-			    slurm_ctl_conf_ptr->slurmctld_logfile);
+				   "SlurmctldLogFile", 
+				   slurm_ctl_conf_ptr->slurmctld_logfile);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldPidFile", 
-			    slurm_ctl_conf_ptr->slurmctld_pidfile);
+				   "SlurmctldPidFile", 
+				   slurm_ctl_conf_ptr->slurmctld_pidfile);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmctld_port);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldPort", temp_str);
+				   "SlurmctldPort", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmctld_timeout);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmctldTimeout", temp_str);
+				   "SlurmctldTimeout", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmd_debug);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdDebug", temp_str);
+				   "SlurmdDebug", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdLogFile", 
-			    slurm_ctl_conf_ptr->slurmd_logfile);
+				   "SlurmdLogFile", 
+				   slurm_ctl_conf_ptr->slurmd_logfile);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdPidFile", 
-			    slurm_ctl_conf_ptr->slurmd_pidfile);
+				   "SlurmdPidFile", 
+				   slurm_ctl_conf_ptr->slurmd_pidfile);
 #ifndef MULTIPLE_SLURMD
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmd_port);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdPort", temp_str);
+				   "SlurmdPort", temp_str);
 #endif
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdSpoolDir", 
-			    slurm_ctl_conf_ptr->slurmd_spooldir);
+				   "SlurmdSpoolDir", 
+				   slurm_ctl_conf_ptr->slurmd_spooldir);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->slurmd_timeout);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SlurmdTimeout", temp_str);
+				   "SlurmdTimeout", temp_str);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "SLURM_CONFIG_FILE", 
+				   slurm_ctl_conf_ptr->slurm_conf);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "SLURM_VERSION", SLURM_VERSION);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "SrunEpilog",
+				   slurm_ctl_conf_ptr->srun_epilog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SLURM_CONFIG_FILE", 
-			    slurm_ctl_conf_ptr->slurm_conf);
+				   "SrunProlog",
+				   slurm_ctl_conf_ptr->srun_prolog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SLURM_VERSION", SLURM_VERSION);
+				   "StateSaveLocation", 
+				   slurm_ctl_conf_ptr->state_save_location);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "SuspendExcNodes", 
+				   slurm_ctl_conf_ptr->suspend_exc_nodes);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "SuspendExcParts", 
+				   slurm_ctl_conf_ptr->suspend_exc_parts);
+	add_display_treestore_line(update, treestore, &iter, 
+				   "SuspendProgram", 
+				   slurm_ctl_conf_ptr->suspend_program);
+	snprintf(temp_str, sizeof(temp_str), "%u", 
+		 slurm_ctl_conf_ptr->suspend_rate);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SrunProlog",
-			    slurm_ctl_conf_ptr->srun_prolog);
+				   "SuspendRate", temp_str);
+	snprintf(temp_str, sizeof(temp_str), "%d", 
+		 ((int)slurm_ctl_conf_ptr->suspend_time - 1));
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SrunEpilog",
-			    slurm_ctl_conf_ptr->srun_epilog);
+				   "SuspendTime", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "StateSaveLocation", 
-			    slurm_ctl_conf_ptr->state_save_location);
+				   "SwitchType",
+				   slurm_ctl_conf_ptr->switch_type);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "SwitchType",
-			    slurm_ctl_conf_ptr->switch_type);
+				   "TaskEpilog",
+				   slurm_ctl_conf_ptr->task_epilog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TaskEpilog",
-			    slurm_ctl_conf_ptr->task_epilog);
+				   "TaskPlugin",
+				   slurm_ctl_conf_ptr->task_plugin);
+        snprintf(temp_str, sizeof(temp_str), "%u",
+                 slurm_ctl_conf_ptr->task_plugin_param);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TaskPlugin",
-			    slurm_ctl_conf_ptr->task_plugin);
+				   "TaskPluginParam", temp_str);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TaskProlog",
-			    slurm_ctl_conf_ptr->task_prolog);
+				   "TaskProlog",
+				   slurm_ctl_conf_ptr->task_prolog);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TmpFS", 
-			    slurm_ctl_conf_ptr->tmp_fs);
+				   "TmpFS", 
+				   slurm_ctl_conf_ptr->tmp_fs);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->tree_width);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "TreeWidth", temp_str);
+				   "TreeWidth", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->use_pam);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "UsePam", temp_str);
+				   "UsePam", temp_str);
+	add_display_treestore_line(update, treestore, &iter,
+				   "UnkillableStepProgram",
+				     slurm_ctl_conf_ptr->unkillable_program);
+	snprintf(temp_str, sizeof(temp_str), "%u",
+		 slurm_ctl_conf_ptr->unkillable_timeout);
+	add_display_treestore_line(update, treestore, &iter,
+				   "UnkillableStepTimeout", temp_str);
 	snprintf(temp_str, sizeof(temp_str), "%u", 
 		 slurm_ctl_conf_ptr->wait_time);
 	add_display_treestore_line(update, treestore, &iter, 
-			    "WaitTime", temp_str);
+				   "WaitTime", temp_str);
 }
 
 extern void create_config_popup(GtkAction *action, gpointer user_data)
diff --git a/src/sview/submit_info.c b/src/sview/submit_info.c
index 5a07e14633bbda2664405147d5211a2ea347dd59..19543917b3a06c3cc7a838f92c118cf079dc5708 100644
--- a/src/sview/submit_info.c
+++ b/src/sview/submit_info.c
@@ -6,7 +6,7 @@
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
  *
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sview/sview.c b/src/sview/sview.c
index 5ddc8d5028bad418e72e02007ba4b328fb8dd447..f277da115700c57e8f1ffd4c9efedbb67afd5e1b 100644
--- a/src/sview/sview.c
+++ b/src/sview/sview.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>, et. al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/src/sview/sview.h b/src/sview/sview.h
index 5a57eefc84d26173650a679a0ca7ffa1bdbb63a7..9d70257edcf1e695929dd8b162a3606e845b1ed7 100644
--- a/src/sview/sview.h
+++ b/src/sview/sview.h
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Danny Auble <da@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index ac957c0b0ea1cd2b6ecfa3f872b49b60339ae5ab..e0e5c2fcae5b188c863de28af478c5dd74bdeca7 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -106,6 +108,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -119,10 +122,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -142,7 +148,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -153,6 +162,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -168,6 +179,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -183,6 +195,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -360,8 +373,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -386,8 +399,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -397,13 +410,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am
index 2d4cd215bcae34eca90b89d6361af384bf5260ca..61bf0d5f8d7e9bec57627e50bcaef622afa723a5 100644
--- a/testsuite/expect/Makefile.am
+++ b/testsuite/expect/Makefile.am
@@ -9,7 +9,7 @@ EXTRA_DIST = \
 	mpi-testscripts/barrier_timed.c	\
 	mpi-testscripts/Makefile	\
 	mpi-testscripts/script.slurm.sh	\
-	globals.example			\
+	globals				\
 	pkill				\
 	README				\
 	regression			\
@@ -29,9 +29,6 @@ EXTRA_DIST = \
 	test1.14			\
 	test1.15			\
 	test1.16			\
-	test1.17			\
-	test1.18			\
-	test1.18.prog.c			\
 	test1.19			\
 	test1.20			\
 	test1.21			\
@@ -49,27 +46,21 @@ EXTRA_DIST = \
 	test1.32			\
 	test1.32.prog.c			\
 	test1.33			\
-	test1.34			\
 	test1.35			\
 	test1.36			\
-	test1.37			\
 	test1.38			\
 	test1.39			\
 	test1.39.prog.c			\
-	test1.40			\
 	test1.41			\
 	test1.42			\
 	test1.43			\
 	test1.44			\
-	test1.45			\
 	test1.46			\
-	test1.47			\
 	test1.48			\
 	test1.49			\
 	test1.50			\
 	test1.51			\
 	test1.52			\
-	test1.53			\
 	test1.54			\
 	test1.55			\
 	test1.56			\
@@ -79,7 +70,6 @@ EXTRA_DIST = \
 	test1.82			\
 	test1.83			\
 	test1.84			\
-	test1.85			\
 	test1.86			\
 	test1.87			\
 	test1.88			\
@@ -102,6 +92,7 @@ EXTRA_DIST = \
 	test2.8				\
 	test2.9				\
 	test2.10			\
+	test2.11			\
 	test3.1				\
 	test3.2				\
 	test3.3				\
@@ -111,6 +102,8 @@ EXTRA_DIST = \
 	test3.7				\
 	test3.7.prog.c			\
 	test3.8				\
+	test3.9				\
+	test3.10			\
 	test4.1				\
 	test4.2				\
 	test4.3				\
@@ -137,11 +130,14 @@ EXTRA_DIST = \
 	test6.5				\
 	test6.6				\
 	test6.7				\
+	test6.7.prog.c			\
 	test6.8				\
 	test6.9				\
 	test6.10			\
 	test6.11			\
 	test6.12			\
+	test6.13			\
+	test6.13.prog.c			\
 	test7.1				\
 	test7.2				\
 	test7.2.prog.c			\
@@ -150,8 +146,6 @@ EXTRA_DIST = \
 	test7.3.prog.c			\
 	test7.4				\
 	test7.4.prog.c			\
-	test7.5				\
-	test7.5.prog.c			\
 	test7.6				\
 	test7.6.prog.c			\
 	test7.7				\
@@ -161,11 +155,17 @@ EXTRA_DIST = \
 	test7.8.prog.c			\
 	test7.9				\
 	test7.9.prog.c			\
+	test7.10			\
 	test8.1				\
 	test8.2				\
 	test8.3				\
 	test8.4				\
 	test8.4.prog.c			\
+	test8.5				\
+	test8.6				\
+	test8.7				\
+	test8.7.crypto.c		\
+	test8.7.prog.c			\
 	test9.1				\
 	test9.2				\
 	test9.3				\
@@ -266,51 +266,15 @@ EXTRA_DIST = \
 	test17.27			\
 	test17.28			\
 	test17.29			\
-	test17.30			\
 	test17.31			\
 	test17.32			\
-	test18.1			\
-	test18.2			\
-	test18.3			\
-	test18.4			\
-	test18.5			\
-	test18.6			\
-	test18.7			\
-	test18.8			\
-	test18.9			\
-	test18.10			\
-	test18.11			\
-	test18.12			\
-	test18.13			\
-	test18.14			\
-	test18.15			\
-	test18.16			\
-	test18.16.prog.c		\
-	test18.17			\
-	test18.18			\
-	test18.19			\
-	test18.19.prog.c		\
-	test18.20			\
-	test18.21			\
-	test18.22			\
-	test18.23			\
-	test18.24			\
-	test18.25			\
-	test18.26			\
-	test18.27			\
-	test18.28			\
-	test18.29			\
-	test18.30			\
-	test18.31			\
-	test18.32			\
-	test18.32.prog.c		\
-	test18.33			\
-	test18.34			\
-	test18.35			\
-	test18.36			\
-	test18.36.prog.c		\
-	test18.37			\
-	test18.37.prog.c		\
+	test19.1			\
+	test19.2			\
+	test19.3			\
+	test19.4			\
+	test19.5			\
+	test19.6			\
+	test19.7			\
 	usleep
 
 distclean-local:
diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in
index 2f48840aa79fee78124fa7a56cadbb769d1e1a10..e8c11f705307b65ebc10d7ebf2a88710a3bc845d 100644
--- a/testsuite/expect/Makefile.in
+++ b/testsuite/expect/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -87,6 +89,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -100,10 +103,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -123,7 +129,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -134,6 +143,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -149,6 +160,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -164,6 +176,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -229,7 +242,7 @@ EXTRA_DIST = \
 	mpi-testscripts/barrier_timed.c	\
 	mpi-testscripts/Makefile	\
 	mpi-testscripts/script.slurm.sh	\
-	globals.example			\
+	globals				\
 	pkill				\
 	README				\
 	regression			\
@@ -249,9 +262,6 @@ EXTRA_DIST = \
 	test1.14			\
 	test1.15			\
 	test1.16			\
-	test1.17			\
-	test1.18			\
-	test1.18.prog.c			\
 	test1.19			\
 	test1.20			\
 	test1.21			\
@@ -269,27 +279,21 @@ EXTRA_DIST = \
 	test1.32			\
 	test1.32.prog.c			\
 	test1.33			\
-	test1.34			\
 	test1.35			\
 	test1.36			\
-	test1.37			\
 	test1.38			\
 	test1.39			\
 	test1.39.prog.c			\
-	test1.40			\
 	test1.41			\
 	test1.42			\
 	test1.43			\
 	test1.44			\
-	test1.45			\
 	test1.46			\
-	test1.47			\
 	test1.48			\
 	test1.49			\
 	test1.50			\
 	test1.51			\
 	test1.52			\
-	test1.53			\
 	test1.54			\
 	test1.55			\
 	test1.56			\
@@ -299,7 +303,6 @@ EXTRA_DIST = \
 	test1.82			\
 	test1.83			\
 	test1.84			\
-	test1.85			\
 	test1.86			\
 	test1.87			\
 	test1.88			\
@@ -322,6 +325,7 @@ EXTRA_DIST = \
 	test2.8				\
 	test2.9				\
 	test2.10			\
+	test2.11			\
 	test3.1				\
 	test3.2				\
 	test3.3				\
@@ -331,6 +335,8 @@ EXTRA_DIST = \
 	test3.7				\
 	test3.7.prog.c			\
 	test3.8				\
+	test3.9				\
+	test3.10			\
 	test4.1				\
 	test4.2				\
 	test4.3				\
@@ -357,11 +363,14 @@ EXTRA_DIST = \
 	test6.5				\
 	test6.6				\
 	test6.7				\
+	test6.7.prog.c			\
 	test6.8				\
 	test6.9				\
 	test6.10			\
 	test6.11			\
 	test6.12			\
+	test6.13			\
+	test6.13.prog.c			\
 	test7.1				\
 	test7.2				\
 	test7.2.prog.c			\
@@ -370,8 +379,6 @@ EXTRA_DIST = \
 	test7.3.prog.c			\
 	test7.4				\
 	test7.4.prog.c			\
-	test7.5				\
-	test7.5.prog.c			\
 	test7.6				\
 	test7.6.prog.c			\
 	test7.7				\
@@ -381,11 +388,17 @@ EXTRA_DIST = \
 	test7.8.prog.c			\
 	test7.9				\
 	test7.9.prog.c			\
+	test7.10			\
 	test8.1				\
 	test8.2				\
 	test8.3				\
 	test8.4				\
 	test8.4.prog.c			\
+	test8.5				\
+	test8.6				\
+	test8.7				\
+	test8.7.crypto.c		\
+	test8.7.prog.c			\
 	test9.1				\
 	test9.2				\
 	test9.3				\
@@ -486,51 +499,15 @@ EXTRA_DIST = \
 	test17.27			\
 	test17.28			\
 	test17.29			\
-	test17.30			\
 	test17.31			\
 	test17.32			\
-	test18.1			\
-	test18.2			\
-	test18.3			\
-	test18.4			\
-	test18.5			\
-	test18.6			\
-	test18.7			\
-	test18.8			\
-	test18.9			\
-	test18.10			\
-	test18.11			\
-	test18.12			\
-	test18.13			\
-	test18.14			\
-	test18.15			\
-	test18.16			\
-	test18.16.prog.c		\
-	test18.17			\
-	test18.18			\
-	test18.19			\
-	test18.19.prog.c		\
-	test18.20			\
-	test18.21			\
-	test18.22			\
-	test18.23			\
-	test18.24			\
-	test18.25			\
-	test18.26			\
-	test18.27			\
-	test18.28			\
-	test18.29			\
-	test18.30			\
-	test18.31			\
-	test18.32			\
-	test18.32.prog.c		\
-	test18.33			\
-	test18.34			\
-	test18.35			\
-	test18.36			\
-	test18.36.prog.c		\
-	test18.37			\
-	test18.37.prog.c		\
+	test19.1			\
+	test19.2			\
+	test19.3			\
+	test19.4			\
+	test19.5			\
+	test19.6			\
+	test19.7			\
 	usleep
 
 all: all-am
diff --git a/testsuite/expect/README b/testsuite/expect/README
index 6d1ae1ad0a081f36a0f514c77ee41671d3e1d3f5..102284a02063900392035e84a018a3c71588e04b 100644
--- a/testsuite/expect/README
+++ b/testsuite/expect/README
@@ -1,8 +1,10 @@
 ############################################################################
+# Copyright (C) 2008 Lawrence Livermore National Security.
 # Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# Additionals by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
 #
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -92,18 +94,15 @@ test1.8    Confirm that basic srun stdin, stdout, and stderr options work
            (--input, --output, and --error option respectively). 
 test1.9    Test of srun verbose mode (--verbose option).
 test1.10   Test of srun/slurmd debug mode (--debug option).
-test1.11   Test of batch job and job name options (--batch and --job-name 
-           options).
-test1.12   Test of processors, memory, and temporary disk space 
-           constraints options (--mincpus, --mem, and --tmp options).
-           Also test that priority zero job is not started (--hold option).
+test1.11   Test job name option (--job-name).
+test1.12   Test of --checkpoint option. This does not validate the 
+           checkpoint file itself.
 test1.13   Test of immediate allocation option (--immediate option).
-test1.14   Test of shared and contiguous options (--shared and --contiguous).
-           Also uses --batch and --hold options. Also see test1.53.
+test1.14   Test exclusive resource allocation for a step (--exclusive option).
 test1.15   Test of wait option (--wait option).
 test1.16   Confirm that srun buffering can be disabled (--unbuffered option).
-test1.17   Confirm that srun allocation mode (--allocate option).
-test1.18   Test of srun attach to existing job (--attach and --join options).
+test1.17   Test of srun --open-mode (truncate or append) option.
+test1.18   Test of --licenses option
 test1.19   Test srun stdout/err file name formatting (--output and --error 
            options with %j, %J, %n, %s and %t specifications).
 test1.20   Test srun stdout/err disabling (--output and --error options with 
@@ -128,31 +127,28 @@ test1.31   Verify that SLURM directed environment variables are processed:
            SLURM_STDOUTMODE.
 test1.32   Test of srun signal forwarding
 test1.33   Test of srun application exit code reporting
-test1.34   Verify that command arguments get forwarded to job script 
-           (--batch option).
+test1.34   REMOVED
 test1.35   Test of batch job with multiple concurrent job steps
 test1.36   Test parallel launch of srun (e.g. "srun srun hostname")
-test1.37   Confirm that node sharing flags are respected  (--nodelist and 
-           --share options).
+test1.37   REMOVED
 test1.38   Test srun handling of SIGINT to get task status or kill the job
            (--quit-on-interrupt option).
 test1.39   Test of linux light-weight core files.
-test1.40   Test of stand-alone srun resource allocation (--uid and --no-shell
-           options).
+test1.40   REMOVED
 test1.41   Validate SLURM debugger infrastructure (--debugger-test option).
-test1.42   Test of account number and job dependencies (--account, --begin 
+test1.42   Test of account number and job dependencies (--account,
            and --depedency options).
 test1.43   Test of slurm_job_will_run API, (srun --test-only option).
 test1.44   Read srun's stdout slowly and test for lost data.   
-test1.45   Test the launch of a batch job within an existing job allocation.
+test1.45   REMOVED
 test1.46   Test srun option --kill-on-bad-exit
-test1.47   Tests #SLURM entry functionality in a batch script.
+test1.47   REMOVED
 test1.48   Test of srun mail options (--mail-type and --mail-user options).
 test1.49   Test of srun task-prolog and task-epilog options.
 test1.50   Test of running non-existant job, confirm timely termination.
 test1.51   Test propagation of umask to spawned tasks.
 test1.52   Test of hostfile logic
-test1.53   Test of nice value specification (--nice option).
+test1.53   REMOVED
 test1.54   Test of running different executables with different arguments
            for each task (--multi-prog option).
 test1.55   Make certain that srun behaves when its controlling terminal
@@ -175,8 +171,7 @@ test1.83   Test of contiguous option with multiple nodes (--contiguous option).
            Also see test1.14.
 test1.84   Test of cpus-per-task option on a single node (--cpus-per-task  
            option).
-test1.85   Test of partition specification on job submission (--partition  
-           option).
+test1.85   REMOVED
 test1.86   Confirm node selection from within a job step on existing allocation
            (--nodelist, --exclude, --nodes and --nprocs options).
 test1.87   Confirm node selection from within a job step on existing allocation
@@ -186,6 +181,7 @@ test1.89   Test of CPU affinity support.
 test1.90   Test of memory affinity support for NUMA systems.
 test1.91   Test of CPU affinity for multi-core systems.
 test1.92   Test of task distribution support on multi-core systems.
+test1.93   Test of LAM-MPI functionality
 **NOTE**   The above tests for mutliple processor/partition systems only
 
 test2.#    Testing of scontrol options (to be run as unprivileged user). 
@@ -215,6 +211,7 @@ test3.6    Testing of hidden partitions.
 test3.7    Test of job suspend/resume.
 test3.8    Test of batch job requeue.
 test3.9    Test of "scontrol show slurmd"
+test3.10   Test of "scontrol notify <jobid> <message>"
 UNTESTED   "scontrol abort"    would stop slurm 
 UNTESTED   "scontrol shutdown" would stop slurm
 
@@ -276,14 +273,13 @@ test7.#    Testing of other functionality.
 ==========================================
 test7.1    Test priorities slurmctld assigns to jobs. Uses srun --hold and 
            --batch options.
-test7.2    Test of PMI functions available via API library. Uses srun and 
-           slaunch. Tests --pmi-threads option in both commands.
+test7.2    Test of PMI functions available via API library. Tests 
+           --pmi-threads option in srun command.
 test7.3    Test of slurm_step_launch API with spawn_io=true
            (needed by poe on IBM AIX systems).
 test7.4    Test of TotalView operation with srun, with and without bulk 
            transfer.
-test7.5    Test of TotalView operation with slaunch, with and without bulk
-           transfer.
+test7.5    REMOVED
 test7.6    Test of TotalView operation with sattach
 test7.7    Test of sched/wiki2 plugin. This is intended to execute in the 
            place of Moab or Maui and emulate its actions to confirm proper
@@ -298,13 +294,13 @@ test7.10   Test if we can trick SLURM into using the wrong user ID
 
 test8.#    Test of Blue Gene specific functionality.
 =================================================
-test8.1    Test of Blue Gene specific srun command line options
-test8.2    Test of Blue Gene specific srun environment variables
+test8.1    Test of Blue Gene specific sbatch command line options
+test8.2    Test of Blue Gene specific sbatch environment variables
 test8.3    Test of Blue Gene specific job geometry support
 test8.4    Test of Blue Gene MPI job execution
 test8.5    Confirm we can make a 32, 128, and 512 cnode block.
 test8.6    Stress test Dynamic mode block creation.
-
+test8.7    Test of Blue Gene scheduling with sched/wik2 plugin.
 
 test9.#    System stress testing. Exercises all commands and daemons.
 =====================================================================
@@ -475,67 +471,9 @@ test17.29  Verify that command arguments get forwarded to job script.
 test17.30  Test of comment field specification (--comment option).
 test17.31  Tests #PBS entry functionality in a batch script.
 test17.32  Test of --overcommit option.
+test17.33  Test of --open-mode option.
 
 
-test18.#   Testing of slaunch options.
-======================================
-test18.1   Confirm slaunch usage option works (--usage option).
-test18.2   Confirm slaunch help option works (--help option).
-test18.3   Confirm that slaunch reports a proper version number
-           (--version option).
-test18.4   Confirm that a job executes with the proper task count (--tasks
-           and --overcommit options).
-test18.5   Confirm that slauch local stdin, stdout, and stderr options work
-           (options --slaunch-input, --slaunch-output and --slaunch-error 
-           respectively).
-test18.6   Test of slaunch verbose mode (--verbose option).
-test18.7   Test of slaunch/slurmd debug mode (--slurmd_debug option).
-test18.8   Confirm that slaunch buffering can be disabled (--unbuffered option).
-test18.9   Test of wait option (--wait option).
-test18.10  Test slaunch task stdout/err disabling (--task-output and 
-           --task-error options).
-test18.11  Test slaunch stdout/err file name formatting (--task-output and 
-           --task-error options with %j, %J, %n, %s and %t specifications).
-test18.12  Test slaunch stdin routing to specific task (--slaunch-input-filter
-           option with numeric argument).
-test18.13  Confirm that slaunch sets appropriate working directory (--workdir
-           option).
-test18.14  Verify the appropriate job environment variables are set
-test18.15  Verify that user environment variables are propagated to the job
-test18.16  Verify that user limits are propagated to the job
-test18.17  Test of salloc and slaunch exit code reporting
-test18.18  Test of parallel launch of slaunch ("slaunch slaunch id").
-test18.19  Test of slaunch signal forwarding (actually using scancel, for 
-           now anyway)
-test18.20  Run "slaunch cat" and read slaunch's stdout SLOWLY, creating
-           stdout back pressure in slaunch.
-test18.21  Test of slaunch's --kill-on-bad-exit option.
-test18.22  Test of slaunch task-prolog and task-epilog option.
-test18.23  Test of running non-existant job, confirm timely termination.
-test18.24  Test propagation of umask to spawned tasks.
-test18.25  Test of --task-layout-file option.
-test18.26  Test of running different executables with different arguments
-           for each task (--multi-prog option).
-test18.27  Confirm that a job executes with the proper task distribution
-           (--nodes and --distribution options).
-test18.28  Confirm that a job executes with the proper node count
-           (--nodes option).
-test18.29  Test of slaunch --cpus-per-task option.
-test18.30  Confirm that a job executes with the proper node count
-           (--nodes option).
-test18.31  Confirm that a job executes with the specified nodes
-            (--relative, --nodelist-byname and --nodelist-byid).
-test18.32  Basic MPI functionality tests via slaunch.
-test18.33  Verify environment variables controlling slaunch are processed:
-           SLAUNCH_DEBUG, SLAUNCH_DISTRIBUTION, SLAUNCH_LABELIO and 
-           SLAUNCH_OVERCOMMIT
-test18.34  Test slaunch's ability to set the job step's name (--name option)
-test18.35  Test of task layout controls (--task-layout-byid, 
-           --task-layout-byname and --task-layout-file options).
-test18.36  Test of CPU affinity support (--cpu-bind option).
-test18.37  Test of memory affinity support for NUMA systems (--mem-bind option).
-test18.38  Test of slaunch --jobid
-
 test19.#   Testing of strigger options.
 =======================================
 test19.1   strigger --help
@@ -554,3 +492,12 @@ test20.2   qstat command tests
 test20.3   qdel command tests
 test20.4   pbsnodes command tests
 
+
+test21.#   Testing of sacctmgr commands and options.
+=================================================
+test21.1   sacctmgr --usage
+test21.2   sacctmgr --help
+test21.3   sacctmgr -V
+test21.4   sacctmgr version
+test21.5   sacctmgr add, list, and delete a cluster
+test21.6   sacctmgr add, list, and delete multiple cluster
diff --git a/testsuite/expect/globals b/testsuite/expect/globals
index 4e249c9464fe2c626e844ccb9878e0308c48cb81..8fc3abccb3c34773bbce91bb21d7c8de531158df 100755
--- a/testsuite/expect/globals
+++ b/testsuite/expect/globals
@@ -11,10 +11,12 @@
 # set mpicc     "/usr/local/bin/mpicc"
 #
 ############################################################################
+# Copyright (C) 2008 Lawrence Livermore National Security.
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# Additions by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -34,7 +36,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 ############################################################################
 
-global sacct salloc sattach sbatch sbcast scancel scontrol sinfo slaunch smap squeue srun
+global sacctmgr sacct salloc sattach sbatch sbcast scancel scontrol sinfo smap squeue srun
 
 # Conditional set.  Only set variable if variable does not yet exist.
 proc cset {name value} {
@@ -53,6 +55,8 @@ if [file exists globals.local] {
 # Used to locate binaries, libraries, and header files.
 #
 cset slurm_dir   "/usr"
+cset build_dir   "../../"
+cset sacctmgr    "${slurm_dir}/bin/sacctmgr"
 cset sacct       "${slurm_dir}/bin/sacct"
 cset salloc      "${slurm_dir}/bin/salloc"
 cset sattach     "${slurm_dir}/bin/sattach"
@@ -61,7 +65,6 @@ cset sbcast      "${slurm_dir}/bin/sbcast"
 cset scancel     "${slurm_dir}/bin/scancel"
 cset scontrol    "${slurm_dir}/bin/scontrol"
 cset sinfo       "${slurm_dir}/bin/sinfo"
-cset slaunch     "${slurm_dir}/bin/slaunch"
 cset smap        "${slurm_dir}/bin/smap"
 cset squeue      "${slurm_dir}/bin/squeue"
 cset srun        "${slurm_dir}/bin/srun"
@@ -100,7 +103,7 @@ cset prompt "(%|#|\\\$|]|\[^>]>) *(|\[^ ]* *)$"
 # Only the shell names (e.g. bin_bash) must be full pathnames
 #
 cset bin_awk 	"awk"
-cset bin_bash   [exec which bash | tail -1]
+cset bin_bash   [exec which bash | tail -n 1]
 cset bin_cat	"cat"
 cset bin_cc	"gcc"
 cset bin_chmod	"chmod"
@@ -162,7 +165,7 @@ cset sleep_error_message "(invalid time interval)|(bad character in argument)"
 set alpha                "\[a-zA-Z\]+"
 set alpha_cap            "\[A-Z\]+"
 set alpha_numeric        "\[a-zA-Z0-9\]+"
-set alpha_numeric_under  "\[a-zA-Z0-9_\]+"
+set alpha_numeric_under  "\[a-zA-Z0-9_\-\]+"
 set alpha_under          "\[A-Z_\]+"
 set end_of_line          "\[\r\n\]"
 set number               "\[0-9\]+"
diff --git a/testsuite/expect/pkill b/testsuite/expect/pkill
index 58b263065387008cbf8aeb69d6a860fa3c71321e..8c648f22ce302a6403cb6f36a698f94e2f88604b 100755
--- a/testsuite/expect/pkill
+++ b/testsuite/expect/pkill
@@ -7,7 +7,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/regression b/testsuite/expect/regression
index 4a386b89cb3a7112a989fce243b294e6d6ab57c4..b59af852566793b015831428666601a4ed3a12a7 100755
--- a/testsuite/expect/regression
+++ b/testsuite/expect/regression
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -54,9 +54,9 @@ BEGIN_TIME=`date +%s`
 for major in `seq 1 20`; do
 	for minor in `seq 1 100`; do
 		TEST=test${major}.${minor}
-		if [ ! -f $TEST ]; then continue; fi
+		if [ ! -f ./$TEST ]; then continue; fi
 
-		$TEST
+		./$TEST
 		if [ $? -eq 0 ]
 		then
 			COMPLETIONS=$((COMPLETIONS+1))
diff --git a/testsuite/expect/regression.py b/testsuite/expect/regression.py
index 66de8f8a528a5fd6735fc6fa2eaa2dfa77a3d349..a1e706430f01adebcd29bee0ffdd70368d96ab63 100755
--- a/testsuite/expect/regression.py
+++ b/testsuite/expect/regression.py
@@ -3,7 +3,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Christopher J. Morrone <morrone2@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -140,19 +140,23 @@ def main(argv=None):
         sys.stdout.flush()
 
 def test_cmp(testA, testB):
-    if testA[0] < testB[0]:
-        return -1
-    elif testA[0] > testB[0]:
-        return 1
-    else:
-        if testA[1] < testB[1]:
-            return -1
-        elif testA[1] > testB[1]:
-            return 1
-        else:
-            return 0
+    rc = cmp(testA[0], testB[0])
+    if rc != 0:
+        return rc
+    return cmp(testA[1], testB[1])
 
 def test_in_list(major, minor, test_list):
+    '''Test for whether a test numbered major.minor is in test_list.
+
+    "major" and "minor" must be integers.  "test_list" is a list of
+    tuples, each tuple representing one test.  The tuples are of the
+    form:
+
+       (major, minor, filename)
+
+    Returns True if the test is in the list, and False otherwise.
+    '''
+
     if not test_list:
         return False
     for test in test_list:
@@ -162,15 +166,38 @@ def test_in_list(major, minor, test_list):
     return False
 
 def test_parser(option, opt_str, value, parser):
-    splitter = re.compile('[,\s]+')
-    # On error: raise OptionValueError
-    # parser.values.exclude
-    # setattr(parser.values, option.dest, 1)
+    '''Option callback function for the optparse.OptionParser class.
+
+    Will take a string representing one or more test names and append
+    a tuple representing the test into a list in the options's destination
+    variable.
+
+    A string representing test names must patch the regular expression
+    named "test_re" below.  Some examples of exceptable options are:
+
+        '1.5'
+        'test9.8'
+        '2.6 test3.1 14.2'
+        '3.4,6.7,8.3'
+        '1.*'
+        '*.2'
+        '1.*,3.8,9.2'
+
+    Raises OptionValueError on error.
+    '''
+
+    # Initialize the option's destination array, if is does not already exist.
     if not hasattr(parser.values, option.dest):
         setattr(parser.values, option.dest, [])
     if getattr(parser.values, option.dest) is None:
         setattr(parser.values, option.dest, [])
+
+    # Get a pointer to the option's destination array.
     l = getattr(parser.values, option.dest)
+
+    # Split the user's option string into a series of tuples that represent
+    # each test, and add each tuple to the destination array.
+    splitter = re.compile('[,\s]+')
     val = splitter.split(value)
     test_re = re.compile('(test)?((\d+)|\*)\.((\d+)|\*)$')
     for v in val:
@@ -186,6 +213,13 @@ def test_parser(option, opt_str, value, parser):
         l.append((major, minor))
 
 class poor_Popen_substitute:
+    '''subprocess.Popen work-alike function.
+
+    The subprocess module and its subprocess.Popen class were
+    added in Python 2.4.  This function is provided to supply the
+    subset of Popen functionality need by this program if run under
+    older python interpreters.
+    '''
     def __init__(self, args, shell=False, stdout=None, stderr=None):
         if shell is not False:
             raise Exception("This substitute Popen only supports shell=True")
diff --git a/testsuite/expect/test1.1 b/testsuite/expect/test1.1
index 06f2ef541503654078a6e936573486782744f3f6..19516084daadcf0ae593da42a5fba16251e216ac 100755
--- a/testsuite/expect/test1.1
+++ b/testsuite/expect/test1.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.10 b/testsuite/expect/test1.10
index 7fbeac42fb191c49a23fb36dea147b2cf8df2f8c..f8268d040df1b06694b07d78c791fed09a8e006e 100755
--- a/testsuite/expect/test1.10
+++ b/testsuite/expect/test1.10
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.11 b/testsuite/expect/test1.11
index e4844c231fa71a80ced024ceed9ae9513c1a11dc..b27adc5a7372d7a55de14ff67ee9012466c81e21 100755
--- a/testsuite/expect/test1.11
+++ b/testsuite/expect/test1.11
@@ -14,7 +14,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -36,10 +36,6 @@
 source ./globals
 
 set test_id     "1.11"
-set file_in     "test$test_id.input"
-set file_out    "test$test_id.output"
-set file_err    "test$test_id.error"
-set job_name    "jobname$test_id"
 set name_read   ""
 
 set complete_flag        0
@@ -53,125 +49,6 @@ set got_login_grps       0
 
 print_header $test_id
 
-#
-# Delete left-over input script plus stdout/err files
-# Build input script file that runs two job steps
-#
-exec $bin_rm -f $file_in $file_out $file_err
-make_bash_script $file_in "
-    $bin_id
-    $srun $bin_sleep 1
-    $srun $bin_sleep 1
-"
-
-#
-# Spawn a srun batch job that uses stdout/err and confirm their contents
-#
-set timeout $max_job_delay
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err --job-name=$job_name -t1 $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$job_id == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	exit 1
-}
-
-#
-# Wait for job to complete
-#
-if {[wait_for_job $job_id "DONE"] != 0} {
-	send_user "\nFAILURE: waiting for job to complete\n"
-	set exit_code 1
-}
-
-spawn $scontrol show job $job_id
-expect {
-	-re "Name=$job_name" {
-		set name_flag 1
-		exp_continue
-	}
-	-re "JobState=COMPLETE" {
-		set complete_flag 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$name_flag == 0} {
-	send_user "\nFAILURE: batch job name failure\n"
-	set exit_code 1
-}
-
-if {$complete_flag == 0} {
-	send_user "\nFAILURE: batch job termination failure\n"
-	set exit_code 1
-} 
-
-#
-# Check user id and group id in stdout
-#
-spawn $bin_id
-expect {
-	-re "(uid=.*\n)" {
-		set login_grp_info $expect_out(1,string)
-		set got_login_grps 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-
-if {[wait_for_file $file_out] == 0} {
-	spawn $bin_cat $file_out
-	expect {
-		-re "(uid=.*\n)" {
-			set job_grp_info $expect_out(1,string)
-			set got_job_grps 1
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-}
-
-if {$got_login_grps == 0} {
-	send_user "\nFAILURE: Unable to get user and group ID info\n"
-	set exit_code 1
-}
-if {$got_job_grps == 0} {
-	send_user "\nFAILURE: User and group ID info missing from stdout\n"
-	set exit_code 1
-}
-if {[string compare $login_grp_info $job_grp_info] != 0} {
-	send_user "\nFAILURE: Login and slurm user info mismatch\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_out $file_err
-}
-
 #
 # Spawn a srun job with a really long name and confirm it is accepted or truncated
 #
@@ -180,7 +57,7 @@ set job_id         0
 
 set srun_pid [spawn $srun --verbose --job-name=$job_name -t1 $bin_id]
 expect {
-	-re "launching ($number).0 on host" {
+	-re "jobid ($number):" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test1.12 b/testsuite/expect/test1.12
index 2d64951bca493af9b92e1d8e5465c8adb376bfea..a0c173d5036a6675429c41867071c1e69ae30d41 100755
--- a/testsuite/expect/test1.12
+++ b/testsuite/expect/test1.12
@@ -1,19 +1,17 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of processors, memory, and temporary disk space 
-#          constraints options (--mincpus, --mem, and --tmp options).
-#          Also test that priority zero job is not started (--hold 
-#          option).
+#          Test of --checkpoint option. This does not validate the 
+#           checkpoint file itself.
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
+# Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -30,40 +28,36 @@
 # 
 # You should have received a copy of the GNU General Public License along
 # with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 ############################################################################
 source ./globals
 
-set test_id     "1.12"
-set exit_code   0
-set file_in     "test$test_id.input"
-set job_id      0
-
-set cpu_cnt     1
-set mem_size    13
-set tmp_size    2
-set matches     0
+set test_id              "1.12"
+set exit_code            0
+set file_in              "test$test_id.input"
+set ckpt_in              12
+set ckpt_out             -1
 
 print_header $test_id
 
 #
-# Delete left-over input script
-# Build input script file
+# Submit a slurm job that print it's info from scontrol
 #
 exec $bin_rm -f $file_in
 make_bash_script $file_in "
-  $bin_sleep 10
+  $scontrol show step \$SLURM_JOBID.\$SLURM_STEPID
 "
 
-#
-# Spawn a srun batch job with constraints and stdout/err
-#
-set srun_pid [spawn $srun --batch --output=none --error=none --mincpus=$cpu_cnt --mem=$mem_size --tmp=$tmp_size --hold -t1 $file_in]
+set srun_pid [spawn $srun -N1 -t1 --checkpoint=$ckpt_in $file_in]
 expect {
-	-re "jobid ($number) submitted" {
-		set job_id $expect_out(1,string)
+	-re "Checkpoint=($number)" {
+		set ckpt_out $expect_out(1,string)
 		exp_continue
 	}
+	-re "Unable to contact" {
+		send_user "\nFAILURE: slurm appears to be down\n"
+		exit 1
+	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
 		slow_kill $srun_pid
@@ -74,67 +68,14 @@ expect {
 	}
 }
 
-if {$job_id == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	exit 1
-}
-
-#
-# Confirm constraints are registered and wait for job completion
-#
-spawn $scontrol show job $job_id
-expect {
-	-re "Priority=($number)" {
-		set read_prio $expect_out(1,string)
-		if {$read_prio == 0} {
-			incr matches
-			send_user "match of Priority\n"
-		}
-		exp_continue
-	}
-	-re "JobState=PENDING" {
-		incr matches
-		send_user "match of JobState\n"
-		exp_continue
-	}
-	-re "MinProcs=($number)" {
-		set read_proc $expect_out(1,string)
-		if {$read_proc == $cpu_cnt} {
-			incr matches
-			send_user "match of MinProcs\n"
-		}
-		exp_continue
-	}
-	-re "MinMemory=($number)" {
-		set read_mem $expect_out(1,string)
-		if {$read_mem == $mem_size} {
-			incr matches
-			send_user "match of MinMemory\n"
-		}
-		exp_continue
-	}
-	-re "MinTmpDisk=($number)" {
-		set read_disk $expect_out(1,string)
-		if {$read_disk == $tmp_size} {
-			incr matches
-			send_user "match of MinTmpDisk\n"
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-cancel_job $job_id
-
-if {$matches != 5} {
-	send_user "\nFAILURE: Did not get proper constraints\n"
+if {$ckpt_out == -1} {
+	send_user "\nFAILURE: No Checkpoint time reported for job step\n"
+	set exit_code 1
+} elseif {$ckpt_in != $ckpt_out} {
+	send_user "\nFAILURE: No Checkpoint time not set properly\n"
 	set exit_code 1
 }
+
 if {$exit_code == 0} {
 	exec $bin_rm -f $file_in
 	send_user "\nSUCCESS\n"
diff --git a/testsuite/expect/test1.13 b/testsuite/expect/test1.13
index f509a140235a6a3d97c5effdc00e52c2ac41d15e..2d31d61bf7cf4299546fffbbd88b26b74318b255 100755
--- a/testsuite/expect/test1.13
+++ b/testsuite/expect/test1.13
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -45,7 +45,7 @@ set timeout 10
 set srun_pid [spawn $srun --immediate --hold -t1 $bin_pwd]
 expect {
 	-re "Unable to allocate resources" {
-		send_user "This error is expected, no worries\n"
+		send_user "\nThis error is expected, no worries\n"
 		incr matches
 		exp_continue
 	}
@@ -72,11 +72,11 @@ set matches 0
 set srun_pid [spawn $srun --immediate -v -t1 $bin_pwd]
 expect {
 	-re "error" {
-		send_user "This error is not unexpected, no worries\n"
+		send_user "\nThis error is not unexpected, no worries\n"
 		incr matches
 		exp_continue
 	}
-	-re "launching" {
+	-re "tasks started" {
 		incr matches
 		exp_continue
 	}
diff --git a/testsuite/expect/test1.14 b/testsuite/expect/test1.14
index 114ef40c7f296c09be540050131a40ffcc7ba0a1..86f8f9dfc81ee0841d60b68124f0c86cbe90d7da 100755
--- a/testsuite/expect/test1.14
+++ b/testsuite/expect/test1.14
@@ -1,17 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of shared and contiguous options (--shared and --contiguous).
-#          Also uses --batch and --hold options.  Also see test1.53.
+#          Test exclusive resource allocation for a step (--exclusive option).
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
+# Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -28,127 +27,194 @@
 # 
 # You should have received a copy of the GNU General Public License along
 # with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 ############################################################################
 source ./globals
 
-set test_id              "1.14"
-set exit_code            0
-set job_id               0
-set matches              0
+set test_id          "1.14"
+set exit_code        0
+set file_in         "test$test_id.input"
+set file_out        "test$test_id.output"
+set job_id           0
+set sleep_secs       10
 
 print_header $test_id
 
+if {[test_bluegene]} {
+        send_user "\nWARNING: This test is incompatable with bluegene systems\n"
+        exit $exit_code
+}
+
 #
-# Spawn a srun batch job with shared option only
+# Delete left-over input script
+# Build input script file
+# Run one more step than allocated CPUs and make sure it waits
+# The "sleep 2" is meant to insure the earlier job steps start first
+#
+exec $bin_rm -f $file_in $file_out
+make_bash_script $file_in "
+  inx=0
+  while \[ \$inx -lt \$SLURM_TASKS_PER_NODE \]
+  do
+    $srun --exclusive -n1 sleep $sleep_secs &
+    inx=\$((inx+1))
+  done
+  $bin_sleep 2
+  $srun -v --exclusive -n1 $bin_printenv SLURMD_NODENAME &
+  wait
+"
+
 #
-set srun_pid [spawn $srun --share --hold --batch -t1 $bin_pwd]
+# Spawn a job via sbatch
+#
+spawn $sbatch -N1 -t1 --output=$file_out $file_in
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		send_user "\nFAILURE: sbatch not responding\n"
 		set exit_code 1
+		exp_continue
 	}
 	eof {
 		wait
 	}
 }
+if { $job_id == 0 } {
+	send_user "\nFAILURE: failed to submit job\n"
+	exit 1
+}
 
 #
-# Confirm shared and contiguous flag values
-#
-if {$job_id != 0} {
-	spawn $scontrol show job $job_id
-	expect {
-		-re "Shared=($number)" {
-			set shared_val $expect_out(1,string)
-			if {$shared_val == 1} {
-				incr matches
-			}
-			exp_continue
-		}
-		-re "Contiguous=($number)" {
-			set cont_val $expect_out(1,string)
-			if {$cont_val == 0} {
-				incr matches
-			}
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: scontrol not responding\n"
-			set exit_code   1
-		}
-		eof {
-			wait
-		}
-	}
+# Wait for job to complete
+#
+if {[wait_for_job $job_id "DONE"] != 0} {
+	send_user "\nFAILURE: waiting for job to complete\n"
 	cancel_job $job_id
-	set job_id 0
+	set exit_code 1
+}
+
+#
+# Check for desired output
+#
+if {[wait_for_file $file_out] != 0} {
+	send_user "\nFAILURE: Output file $file_out is missing\n"
+	exit 1
+}
+set match1 0
+set match2 0
+spawn $bin_cat $file_out
+expect {
+	-re "Job step creation temporarily disabled, retrying" {
+		incr match1
+		exp_continue
+	}
+	-re "Job step created" {
+		incr match2
+		exp_continue
+	}
+	eof {
+		wait
+	}
+}
+
+if { $match1 != 1 || $match2 != 1 } {
+	send_user "\nFAILURE: Problem with exclusive resource allocation "
+	send_user "for step ($match1, $match2)\n"
+	set exit_code 1
+}
+
+if {$exit_code == 0} {
+	send_user "\nSo far, so good. Trying with --imediate option\n\n"
 } else {
-	set exit_code   1
+	exit $exit_code
 }
 
 #
-# Spawn a srun batch job with contiguous option only
+# Delete left-over input script
+# Build another input script file
+# Run one more step than allocated CPUs with immediate option and make aborts
+# The "sleep 2" is meant to insure the earlier job steps start first
+#
+exec $bin_rm -f $file_in $file_out
+make_bash_script $file_in "
+  inx=0
+  while \[ \$inx -lt \$SLURM_TASKS_PER_NODE \]
+  do
+    $srun --exclusive -n1 sleep $sleep_secs &
+    inx=\$((inx+1))
+  done
+  $bin_sleep 2
+  $srun --exclusive -n1 --immediate hostname &
+  wait
+"
+
 #
-set job_id 0
-spawn $srun --contiguous --hold --batch -t1 $bin_pwd
+# Spawn a job via sbatch
+#
+spawn $sbatch -N1 -t1 --output=$file_out $file_in
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		exit 1
+		send_user "\nFAILURE: sbatch not responding\n"
+		set exit_code 1
+		exp_continue
 	}
 	eof {
 		wait
 	}
 }
+if { $job_id == 0 } {
+	send_user "\nFAILURE: failed to submit job\n"
+	exit 1
+}
 
 #
-# Confirm shared and contiguous flag values
-#
-if {$job_id != 0} {
-	spawn $scontrol show job $job_id
-	expect {
-	        -re "Shared=($alpha)" {
-			set shared_val $expect_out(1,string)
-		        if {[string compare $shared_val OK] == 0} {
-				incr matches
-			}
-			exp_continue
-		}
-		-re "Contiguous=($number)" {
-			set cont_val $expect_out(1,string)
-			if {$cont_val == 1} {
-				incr matches
-			}
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: scontrol not responding\n"
-			set exit_code 1
-		}
-		eof {
-			wait
-		}
-	}
+# Wait for job to complete
+#
+if {[wait_for_job $job_id "DONE"] != 0} {
+	send_user "\nFAILURE: waiting for job to complete\n"
 	cancel_job $job_id
-} else {
 	set exit_code 1
 }
 
-if {$matches != 4} {
-	send_user "\nFAILURE: Did not properly set shared and contiguous flags\n"
+#
+# Check for desired output
+#
+if {[wait_for_file $file_out] != 0} {
+	send_user "\nFAILURE: Output file $file_out is missing\n"
+	exit 1
+}
+set match1 0
+spawn $bin_cat $file_out
+expect {
+	-re "Job step creation temporarily disabled, retrying" {
+		send_user "\nFAILURE: Problem --exclusive and --immediate option for step\n"
+		set exit_code 1
+		exp_continue
+	}
+	-re "Unable to create job step" {
+		send_user "This error was expected, no worries\n"
+		incr match1
+		exp_continue
+	}
+	eof {
+		wait
+	}
+}
+
+if { $match1 != 1 } {
+	send_user "\nFAILURE: Problem --exclusive and --immediate option for step\n"
 	set exit_code 1
 }
+
 if {$exit_code == 0} {
+	exec $bin_rm -f $file_in $file_out
 	send_user "\nSUCCESS\n"
 }
 exit $exit_code
diff --git a/testsuite/expect/test1.15 b/testsuite/expect/test1.15
index 682b5570066cf826a13b7617a46efdf61ff3dbe8..4237f3afa5b748d69bbe964090d688913032a858 100755
--- a/testsuite/expect/test1.15
+++ b/testsuite/expect/test1.15
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -65,6 +65,10 @@ expect {
 		incr matches
 		exp_continue
 	}
+	-re "exited with exit code" {
+		send_user "This error is expected, no worries\n"
+		exp_continue
+	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
 		slow_kill $srun_pid
diff --git a/testsuite/expect/test1.16 b/testsuite/expect/test1.16
index 98e6b27263aa74cc5257b6301a4d5a7f2967f1a4..5d7465a95ed3bb1998f474f11e7911bbe4a249cf 100755
--- a/testsuite/expect/test1.16
+++ b/testsuite/expect/test1.16
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.17 b/testsuite/expect/test1.17
index c92cbce48193ab4aacaa8382aa7fad6107b8e9c5..e1adfa1ae5d5b96d0061e9147d5ed241a2da86d4 100755
--- a/testsuite/expect/test1.17
+++ b/testsuite/expect/test1.17
@@ -1,16 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Confirm that srun allocation mode (--allocate option).
+#          Test of srun --open-mode (truncate or append) option.
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2002 The Regents of the University of California.
+# Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -31,40 +31,55 @@
 ############################################################################
 source ./globals
 
-set test_id            "1.17"
-set exit_code          0
-set job_id             0
-set slurm_jobid        0
+set test_id     "1.17"
+set file_in     "test$test_id.input"
+set file_out    "test$test_id.output"
+set file_err    "test$test_id.error"
+set exit_code            0
+set login_grp_info       ""
+set got_job_grps         0
+set got_login_grps       0
+set got_sleep_err        0
 
 print_header $test_id
 
 #
-# Submit a slurm allocate job
-# Interactively print $SLURM_JOBID
+# Delete left-over stdin/out/err files
+# Build stdin file
 #
-set timeout $max_job_delay
-set match 0
-set srun_pid [spawn $srun --allocate --verbose -t1]
+exec $bin_rm -f $file_in $file_out $file_err
+make_bash_script $file_in "
+  $bin_id
+  $bin_sleep aaa
+  exit 0"
+exec echo "$bin_echo INITIAL_VALUE" >$file_err
+exec echo "$bin_echo INITIAL_VALUE" >$file_out
+
+#
+# Get user id and group id for comparison with stdout
+#
+spawn $bin_id
 expect {
-	-re "jobid ($number).*" {
-		set job_id $expect_out(1,string)
-		send "$bin_echo MY_ID=\$SLURM_JOBID \n"
+	-re "(uid=$number)" {
+		set login_grp_info $expect_out(1,string)
+		set got_login_grps 1
 		exp_continue
 	}
-	-re "MY_ID=($number)" {
-		set slurm_jobid $expect_out(1,string)
-		send "exit 2\n"
-		exp_continue
-	}
-	-re "MY_ID=" {
-#		no environment variable
-		send "exit 2\n"
-		exp_continue
+	eof {
+		wait
 	}
-	-re "\[Ee\]xit 2" {
-		send_user "This error was expected, no worries\n"
-		set match 1
-		exp_continue
+}
+
+#
+# Spawn a shell via srun that uses stdin/out/err in truncate mode
+# and confirm their contents
+#
+set timeout $max_job_delay
+set srun_pid [spawn $srun --input=$file_in --output=$file_out --error=$file_err --open-mode=t -t1 $bin_bash]
+expect {
+	-re "Unable to contact" {
+		send_user "\nFAILURE: slurm appears to be down\n"
+		exit 1
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
@@ -76,29 +91,134 @@ expect {
 	}
 }
 
+if {[wait_for_file $file_out] == 0} {
+	spawn $bin_cat $file_out
+	expect {
+		-re "INITIAL_VALUE" {
+			send_user "\nFAILURE: stdout file not truncated\n"
+			set exit_code 1
+		}
+		-re "$login_grp_info" {
+			incr got_job_grps
+			exp_continue
+		}
+		eof {
+			wait
+		}
+	}
+}
+
+if {$got_login_grps == 0} {
+	send_user "\nFAILURE: Unable to get user and group ID info\n"
+	set exit_code 1
+}
+if {$got_job_grps != 1} {
+	send_user "\nFAILURE: User and group ID info missing from stdout\n"
+	set exit_code 1
+}
 
 #
-# Confirm the job_ids match.
+# Check for sleep input specification error in stderr
 #
-if { $job_id == 0 } {
-	send_user "\nFAILURE: srun --allocate failure\n"
+if {[wait_for_file $file_err] == 0} {
+	spawn $bin_cat $file_err
+	expect {
+		-re "INITIAL_VALUE" {
+			send_user "\nFAILURE: stderr file not truncated\n"
+			set exit_code 1
+		}
+		-re "$sleep_error_message" {
+			send_user "\nNo worries, this error is expected\n"
+			incr got_sleep_err
+			exp_continue
+		}
+		-re "Specify time as a positive integer.*\n" {
+			incr got_sleep_err
+			exp_continue
+		}
+		eof {
+			wait
+		}
+	}
+}
+if {$got_sleep_err != 1} {
+	send_user "\nFAILURE: Unexpected stderr contents\n"
 	set exit_code 1
-} else {
-	if { $job_id != $slurm_jobid } {
-		send_user "\nFAILURE: srun job_id mis-match\n"
+}
+
+if {$exit_code != 0} {
+	exit $exit_code
+}
+
+
+#
+# Spawn a shell via srun that uses stdin/out/err in append mode
+# and confirm their contents
+#
+set timeout $max_job_delay
+set srun_pid [spawn $srun --input=$file_in --output=$file_out --error=$file_err --open-mode=a -t1 $bin_bash]
+expect {
+	-re "Unable to contact" {
+		send_user "\nFAILURE: slurm appears to be down\n"
+		exit 1
+	}
+	timeout {
+		send_user "\nFAILURE: srun not responding\n"
+		slow_kill $srun_pid
 		set exit_code 1
 	}
+	eof {
+		wait
+	}
+}
+
+set got_job_grps 0
+if {[wait_for_file $file_out] == 0} {
+	spawn $bin_cat $file_out
+	expect {
+		-re "$login_grp_info" {
+			incr got_job_grps
+			exp_continue
+		}
+		eof {
+			wait
+		}
+	}
+}
+if {$got_job_grps != 2} {
+	send_user "\nFAILURE: User and group ID info missing from stdout\n"
+	set exit_code 1
 }
 
 #
-# Confirm exit code is propogated
+# Check for sleep input specification error in stderr
 #
-if { $match != 1 } {
-	send_user "\nFAILURE: srun exit code not reported\n"
+set got_sleep_err 0
+if {[wait_for_file $file_err] == 0} {
+	spawn $bin_cat $file_err
+	expect {
+		-re "$sleep_error_message" {
+			send_user "\nNo worries, this error is expected\n"
+			incr got_sleep_err
+			exp_continue
+		}
+		-re "Specify time as a positive integer.*\n" {
+			incr got_sleep_err
+			exp_continue
+		}
+		eof {
+			wait
+		}
+	}
+}
+if {$got_sleep_err != 2} {
+	send_user "\nFAILURE: Unexpected stderr contents\n"
 	set exit_code 1
 }
 
-if { $exit_code == 0 } {
+
+if {$exit_code == 0} {
+	exec $bin_rm -f $file_in $file_out $file_err
 	send_user "\nSUCCESS\n"
 }
 exit $exit_code
diff --git a/testsuite/expect/test1.18 b/testsuite/expect/test1.18
index 5419a058e4879d148cc71bf0793591228f9fadbe..38b44203995c2e97ebae2a89b049835ffb2cbf9c 100755
--- a/testsuite/expect/test1.18
+++ b/testsuite/expect/test1.18
@@ -1,16 +1,17 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of srun attach to existing job (--attach and --join options).
+#          Test of --licenses option
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "WARNING: ..." with an explanation of why the test can't be made, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
+# Copyright (C) 2008 Lawrence Livermore National Security.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -33,110 +34,77 @@ source ./globals
 
 set test_id     "1.18"
 set exit_code   0
-set file_prog   "test$test_id.prog"
-set job_id      0
-set matches     0
-set tasks       8
 
 print_header $test_id
-if { [test_bluegene] } {
-	set tasks       1
-	set node_cnt 1-512
-} else {
-	set tasks       8
-	set node_cnt 1-$tasks
-}
-
-#
-# Delete left-over program and rebuild it
-#
-exec $bin_rm -f $file_prog
-exec $bin_make -f /dev/null $file_prog
-exec $bin_chmod 700 $file_prog
 
 #
-# Spawn initial program via srun
+# Run a job attempting to get some dummy license name
 #
-set timeout $max_job_delay
-set srun_pid [spawn $srun -N$node_cnt -n$tasks -O -v -t5 -l $file_prog]
-set init_id $spawn_id
+set match 0
+set srun_pid [spawn $srun --licenses=DUMMY_FOR_TESTING $bin_hostname]
 expect {
-        -i $init_id
-	-re "launching ($number).0 on host" {
-		set job_id $expect_out(1,string)
+	-re "invalid license" {
+		set match 1
+		send_user "This error was expected, no worries\n\n"
 		exp_continue
 	}
-	-re "WAITING" {
-		incr matches
-		if {$matches < $tasks} {
-			exp_continue
-		}
-	}
 	timeout {
-		send_user "\nFAILURE: srun (launch) not responding\n"
+		send_user "\nFAILURE: srun not responding\n"
 		slow_kill $srun_pid
-		set exit_code 1
+		exit 1
 	}
 	eof {
 		wait
 	}
 }
-if {$job_id == 0} {
-	send_user "\nFAILURE: job submit failure\n"
-	exit 1
-}
-if {$matches == 0} {
-	send_user "\nFAILURE: job run time failure\n"
-	exit 1
+if {$match == 0} {
+	send_user "\nFAILURE: No error on with bad license name\n"
+	set exit_code 1
 }
 
 #
-# Attach to initial program via srun
+# Test if any licenses are configured.
 #
-set matches     0
-set timeout     10
-set attach_pid [spawn $srun -vv -l --attach=$job_id --join]
-set attach_id $spawn_id
+log_user 0
+set licenses ""
+spawn $scontrol show config
 expect {
-        -i $attach_id
-	-re "WAITING" {
-		incr matches
-		send_user "\nsending exit message\n"
-		send -i $attach_id "exit\n"
-	}
-	timeout {
-		send_user "\nFAILURE: srun (attach) not responding\n"
-		slow_kill $attach_pid
-		set exit_code 1
+	-re "Licenses *= ($alpha_numeric_under)" {
+		set licenses $expect_out(1,string)
+		exp_continue
 	}
 	eof {
 		wait
 	}
 }
-if {$matches == 0} {
-	send_user "\nFAILURE: job run time failure\n"
-	set exit_code   1
+log_user 1
+
+if {[string compare $licenses ""] != 0} {
+	set srun_pid [spawn $srun --licenses=$licenses $bin_hostname]
+	expect {
+		-re "invalid license" {
+			send_user "\nFAILURE: Error getting license\n"
+			set exit_code 1
+			exp_continue
+		}
+		timeout {
+			send_user "\nNOTE: srun not responding\n"
+			send_user "  This test can fail if the selected "
+			send_user "license is in use.\n"
+			set exit_code 1
+		}
+		eof {
+			wait
+		}
+	}
 }
 
 #
-# Make sure initial program terminates too
+# Run a job attempting to get a legitimate license name
 #
-# Explicitly reset spawn_id for wait call
-set spawn_id $init_id
-expect {
-	timeout {
-		send_user "\nFAILURE: srun (terminate) not responding\n"
-		set exit_code   1
-	}
-	eof {
-		wait
-	}
-}
 
 if {$exit_code == 0} {
-	exec $bin_rm -f $file_prog
 	send_user "\nSUCCESS\n"
-} else {
-	cancel_job $job_id
 }
 exit $exit_code
+
diff --git a/testsuite/expect/test1.18.prog.c b/testsuite/expect/test1.18.prog.c
deleted file mode 100644
index ca25b635f34adc5258c3224f8892ff1666e90e32..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.18.prog.c
+++ /dev/null
@@ -1,53 +0,0 @@
- /*****************************************************************************\
- *  test1.18.proc.c - Simple I/O test program for SLURM regression test1.18.
- *  Print "waiting\n" to stdout and wait for "exit" as stdin.
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-main (int argc, char **argv) 
-{
-	char in_line[10];
-	int i;
-
-	fprintf(stdout, "WAITING\n");
-	fflush(stdout);
-
-	for (i=0; i<sizeof(in_line); ) {
-		in_line[i] = getc(stdin);
-		if ((in_line[i] < 'a') ||
-		    (in_line[i] > 'z'))
-			i = 0;
-		else if (strncmp(in_line, "exit", 4) == 0)
-			exit(0);
-		else
-			i++;
-	}
-
-	fprintf(stderr, "Invalid input\n");
-	exit(1);
-}
diff --git a/testsuite/expect/test1.19 b/testsuite/expect/test1.19
index e34b769c438246057735fefa9b6db59a9f1bdc6b..b4e33b96686b4884bd68aae3322ac3a2f916b63a 100755
--- a/testsuite/expect/test1.19
+++ b/testsuite/expect/test1.19
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -240,10 +240,12 @@ if { [test_bluegene] } {
 	set task_cnt 4
 }
 
+# Note: Task count is in the script for each srun
+#	There is not oversubscribe option for sbatch.
 set job_id   0
-set srun_pid [spawn $srun --batch --output=/dev/null -N$node_cnt -n$task_cnt -O -t1 $file_in]
+set srun_pid [spawn $sbatch --output=/dev/null -N$node_cnt -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test1.2 b/testsuite/expect/test1.2
index e5098fd3ea067ef5c773966c2b109bffd1d37b9e..f49b9ee0ffba228c3fb66b28dcf498fbcc04e794 100755
--- a/testsuite/expect/test1.2
+++ b/testsuite/expect/test1.2
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.20 b/testsuite/expect/test1.20
index ade317dfbbb5d09ff8b4559615e88bbb3f3883d2..3f10914c19920bb6f569cc08517de83bff7f1b78 100755
--- a/testsuite/expect/test1.20
+++ b/testsuite/expect/test1.20
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.21 b/testsuite/expect/test1.21
index e920d7766a0789c2149b13aee632834025068ee9..9b258cae2aaa36d8500124b7a146aff974b300a3 100755
--- a/testsuite/expect/test1.21
+++ b/testsuite/expect/test1.21
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -79,6 +79,14 @@ if {$matches != 1} {
 	send_user "\nFAILURE: stdin to specific task_id failed\n"
 	set exit_code 1
 }
+
+if {[test_bluegene]} {
+	if {$exit_code == 0} {
+		send_user "\nSUCCESS\n"
+	}
+	exit $exit_code
+}
+
 if {$exit_code == 0} {
 	send_user "\nSo far... stdin to specific task worked fine\n\n\n"
 }
diff --git a/testsuite/expect/test1.22 b/testsuite/expect/test1.22
index 7cc93f6663963bd9659eebed664280099db9b968..69f73ee1b0af20ef8e1dd1b4a26047b8728eb753 100755
--- a/testsuite/expect/test1.22
+++ b/testsuite/expect/test1.22
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -84,6 +84,10 @@ set host_0      ""
 set timeout $max_job_delay
 set srun_pid [spawn $srun -N$node_cnt -n32 -O -l --threads=32 -t1 $bin_hostname]
 expect {
+	-re "Memory required by task is not available" {
+		send_user "\nWARNING: DefMemPerTask is configured too high for this test\n"
+		set host_0 "warn"
+	} 
 	-re "0: ($alpha_numeric)" {
 		set host_0 $expect_out(1,string)
 		exp_continue
diff --git a/testsuite/expect/test1.23 b/testsuite/expect/test1.23
index d4de7f1c9eff7b214c5a0363599d65d24477846a..ab47df6699f5e4a9ebed3bf66321758dc9863a95 100755
--- a/testsuite/expect/test1.23
+++ b/testsuite/expect/test1.23
@@ -12,7 +12,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.24 b/testsuite/expect/test1.24
index 572e5535dd6a26d4cb7bb5f190af4b479620841a..096b698a2facaffbaebeb1fe375aaf8aed0a3aca 100755
--- a/testsuite/expect/test1.24
+++ b/testsuite/expect/test1.24
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.25 b/testsuite/expect/test1.25
index 321fd778880da1c2742761d69601a169e93bcc3b..35ec82df5612c123e74c19964520402ed2515416 100755
--- a/testsuite/expect/test1.25
+++ b/testsuite/expect/test1.25
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.26 b/testsuite/expect/test1.26
index 6a225fb74838a0dc0df6c77a08feea631bbb2f8e..51744936aa47fde969b4fb1d823974b9d56f0642 100755
--- a/testsuite/expect/test1.26
+++ b/testsuite/expect/test1.26
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -61,15 +61,15 @@ set nodelist_name ""
 set timeout $max_job_delay
 set srun_pid [spawn $srun -v -N1 -l $bin_printenv SLURMD_NODENAME]
 expect {
-	-re "on host ($alpha_numeric)," {
+	-re "on host ($alpha_numeric_under)," {
 		set nodelist_name $expect_out(1,string)
 		exp_continue
 	}
-	-re "^0: ($alpha_numeric)" {
+	-re "^0: ($alpha_numeric_under)" {
 		set host_0 $expect_out(1,string)
 		exp_continue
 	}
-	-re "\n0: ($alpha_numeric)" {
+	-re "\n0: ($alpha_numeric_under)" {
 		set host_0 $expect_out(1,string)
 		exp_continue
 	}
@@ -122,7 +122,7 @@ expect {
 	-re "error: .*exit code 1" {
 		exp_continue
 	}
-	-re "0: ($alpha_numeric)" {
+	-re "0: ($alpha_numeric_under)" {
 		set host_1 $expect_out(1,string)
 		exp_continue
 	}
@@ -276,7 +276,7 @@ for {set inx 0} {$inx < $interations} {incr inx} {
 			set failures 1
 			exp_continue
 		}
-		-re "0: ($alpha_numeric)" {
+		-re "0: ($alpha_numeric_under)" {
 			set host_0 $expect_out(1,string)
 			exp_continue
 		}
diff --git a/testsuite/expect/test1.27 b/testsuite/expect/test1.27
index 73d96ac4a8fa88c0a657fddee06efbe93e4b682b..636aa59fea8b2fd55ba62293d43fd7ab5cdc1e56 100755
--- a/testsuite/expect/test1.27
+++ b/testsuite/expect/test1.27
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.28 b/testsuite/expect/test1.28
index f4b780c4d57baf7a9567e13a6c803da3c3f1a6aa..4dc41c5c4dc3715ff1fdbd8b099fc66e7c0c2d45 100755
--- a/testsuite/expect/test1.28
+++ b/testsuite/expect/test1.28
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.29 b/testsuite/expect/test1.29
index f8d1878f099b63f08ac941099d2e4762d2997195..c055e47dcc2d49c4b9cb05acf6474b1d166afe6c 100755
--- a/testsuite/expect/test1.29
+++ b/testsuite/expect/test1.29
@@ -13,7 +13,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -133,9 +133,9 @@ make_bash_script $file_in "
 
 
 set timeout $max_job_delay
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err -t1 ./$file_in]
+set srun_pid [spawn $sbatch --output=$file_out --error=$file_err -t1 ./$file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test1.29.prog.c b/testsuite/expect/test1.29.prog.c
index d47f5b78bd8edb67de0d6ce5fd7b7a02a1646afb..d6e2317004c7bb8e80da75752e6f9747d918e4bc 100644
--- a/testsuite/expect/test1.29.prog.c
+++ b/testsuite/expect/test1.29.prog.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.3 b/testsuite/expect/test1.3
index 74623b7f806c9e54bc84acd3362293c2552f759a..a0f68f4714f6f82b4f64acb3265ea4147f045c0d 100755
--- a/testsuite/expect/test1.3
+++ b/testsuite/expect/test1.3
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.30 b/testsuite/expect/test1.30
index edb502734b04c0ad23cba45b771149efb12a09a0..c4916678541a863253587e5ac4e364efb0ed58e3 100755
--- a/testsuite/expect/test1.30
+++ b/testsuite/expect/test1.30
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.31 b/testsuite/expect/test1.31
index b1316242a432a31e3c15b20085dcd7a5e9cefaf5..58e0e093274a0688f2c2831cf1c9da80803c4420 100755
--- a/testsuite/expect/test1.31
+++ b/testsuite/expect/test1.31
@@ -12,7 +12,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.32 b/testsuite/expect/test1.32
index f833cb4ec90bb06e6b684560ba80795ae2e41fb7..9275a8bee37f4a211638afa0cd2ad08c745ac543 100755
--- a/testsuite/expect/test1.32
+++ b/testsuite/expect/test1.32
@@ -13,7 +13,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -38,6 +38,7 @@ set test_id     "1.32"
 set exit_code   0
 set file_prog   "test$test_id.prog"
 set matches     0
+set fini_cnt    0
 set usr1cnt     0
 set usr2cnt     0
 
@@ -100,6 +101,10 @@ expect {
 		send_user "\nDon't worry about the error...\n"
 		exp_continue
 	}
+	-re "FINI" {
+		incr fini_cnt
+		exp_continue
+	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
 		slow_kill $srun_pid
@@ -122,6 +127,11 @@ if {$usr2cnt != 1} {
 	send_user "\nFAILURE: $file_prog received $usr2cnt SIGUSR2 (not 1)\n"
 	set exit_code 1
 }
+if {$fini_cnt != 1} {
+	send_user "\nFAILURE: srun failed to terminate properly\n"
+	set exit_code 1
+}
+
 
 #
 # Post-processing
diff --git a/testsuite/expect/test1.32.prog.c b/testsuite/expect/test1.32.prog.c
index f5e315dbd11a83821403360d391adff186fd489f..2f206dab8815fbd37709b2b6eb289c783afc04b5 100644
--- a/testsuite/expect/test1.32.prog.c
+++ b/testsuite/expect/test1.32.prog.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -77,5 +77,6 @@ main (int argc, char **argv)
 		sleep(1);
 	}
 
+	printf("FINI\n");
 	exit(0);
 }
diff --git a/testsuite/expect/test1.33 b/testsuite/expect/test1.33
index 543eed115c59281cc3c11c291296e981fd2d0f7e..30511eef17d19f1bfb6fb3c3b91211f9890ac526 100755
--- a/testsuite/expect/test1.33
+++ b/testsuite/expect/test1.33
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.34 b/testsuite/expect/test1.34
deleted file mode 100755
index b2e6bb76f6c000dd6493e796b526e1293b660439..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.34
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Verify that arguments get forwarded to job script (--batch option). 
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-#
-# Note:    This script generates and then deletes files in the working directory 
-#          named test1.34.input, test1.34.output, and test1.34.error
-############################################################################
-# Copyright (C) 2002 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id     "1.34"
-set file_in     "test$test_id.input"
-set file_out    "test$test_id.output"
-set file_err    "test$test_id.error"
-
-set arg1        "arg_one"
-set arg2        "arg_two"
-set arg_match   0
-set exit_code   0
-set job_id      0
-
-print_header $test_id
-
-#
-# Delete left-over input script plus stdout/err files
-# Build input script file
-#
-exec $bin_rm -f $file_in $file_out $file_err
-make_bash_script $file_in "$bin_echo \$1,\$2"
-
-#
-# Spawn a srun batch job with arguments
-#
-set timeout $max_job_delay
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err -t1 $file_in $arg1 $arg2]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$job_id == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	exit 1
-}
-
-#
-# Wait for job to complete
-#
-if {[wait_for_job $job_id "DONE"] != 0} {
-	send_user "\nFAILURE: waiting for job to complete\n"
-	cancel_job $job_id
-	set exit_code 1
-}
-
-#
-# Check arguments returned in stdout
-#
-if {[wait_for_file $file_out] == 0} {
-	spawn $bin_cat $file_out
-	expect {
-		-re "$arg1,$arg2" {
-			set arg_match 1
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-}
-
-if {$arg_match == 0} {
-	send_user "\nFAILURE: Failed to pass script arguments\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-	exec $bin_rm -f $file_in $file_out $file_err
-}
-exit $exit_code
diff --git a/testsuite/expect/test1.35 b/testsuite/expect/test1.35
index b19e81a00f46696993f784d32d6205b0713700e9..298c223fa3bca723d69ab33718f5dbba698822e0 100755
--- a/testsuite/expect/test1.35
+++ b/testsuite/expect/test1.35
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -52,7 +52,6 @@ make_bash_script $file_in "
   for ((i = 0; i < $steps_started; i++)); do
     j=`expr $steps_started + 10 - \$i`
     $srun $bin_sleep \$j &
-#    $slaunch $bin_sleep \$j &
     $bin_sleep 1
   done
   $bin_sleep 2
@@ -75,9 +74,9 @@ if { [test_bluegene] } {
 	}
 }
 
-set srun_pid [spawn $srun --batch -N$node_cnt --output=$file_out --error=$file_err -t1 $file_in]
+set srun_pid [spawn $sbatch -N$node_cnt --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test1.36 b/testsuite/expect/test1.36
index 3adb14a9c6cefef187e1fbf58b56a30b63c25651..a5570a7be95ff7fe384a2b232488d351dda64253 100755
--- a/testsuite/expect/test1.36
+++ b/testsuite/expect/test1.36
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.37 b/testsuite/expect/test1.37
deleted file mode 100755
index a505b0a1a6a54e3657d9676c8773170416d84feb..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.37
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Confirm that node sharing flags are respected  (--nodelist and 
-#          --share options).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id      "1.37"
-set exit_code    0
-set file_err     "test$test_id.error"
-set file_in      "test$test_id.input"
-set file_out     "test$test_id.output"
-set job_id1      0
-set host_name    ""
-set nodelist_name ""
-
-print_header $test_id
-
-#
-# Submit a job and get the node's NodeName from the nodelist
-#
-set timeout $max_job_delay
-set srun_pid [spawn $srun -v -N1 -l -t1 $bin_hostname]
-expect {
-	-re "on host ($alpha_numeric)," {
-		set nodelist_name $expect_out(1,string)
-		exp_continue
-	}
-	-re "0: ($alpha_numeric)" {
-		set host_name $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {[string compare $nodelist_name ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	exit 1
-}
-if {[test_front_end] != 0} {
-	send_user "\nWARNING: Additional testing is incompatable with front-end systems\n"
-	exit $exit_code
-}
-
-#
-# Delete left-over input script
-# Build input script file
-#
-exec $bin_rm -f $file_in
-make_bash_script $file_in "$srun $bin_sleep 5"
-
-#
-# Submit two jobs to the same node, one with no sharing, the other 
-# with sharing permitted. Insure the first job completes before the 
-# second job is started.
-#
-set srun_pid [spawn $srun --batch -N1 --exclusive --nodelist=$nodelist_name -t1 --output=$file_out --error=$file_err $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id1 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id1 == 0} {
-	send_user "\nFAILURE: srun failed to report jobid\n"
-	exit 1
-}
-
-set partition "dummy"
-set waited 1
-set timeout [expr $timeout + 5]
-set srun_pid [spawn $srun -N1 --nodelist=$nodelist_name -t1 --share $scontrol -o show job $job_id1]
-expect {
-	-re "Partition=($alpha_numeric)" {
-		set partition $expect_out(1,string)
-		exp_continue
-	}
-	-re "JobState=RUN" {
-		set waited 0 
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$waited == 0} {
-	spawn $scontrol show partition
-	expect {
-		-re "Shared=FORCE" {
-			send_user "\nWARNING: Test incompatable with Shared=FORCE\n"
-			set waited 1
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-}
-if {$waited == 0} {
-	send_user "\nFAILURE: srun failed to wait for non-sharing job to complete\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_err $file_in $file_out
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test1.38 b/testsuite/expect/test1.38
index 0477ac897d4739b66d191d8c45c0caa1933178de..074f9a67a25b235a0ceba8532c1a926500308eb8 100755
--- a/testsuite/expect/test1.38
+++ b/testsuite/expect/test1.38
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -147,6 +147,7 @@ expect {
 		wait
 	}
 }
+cancel_job $job_id
 if {$matches != 2} {
 	send_user "\nFAILURE: srun failed to properly process SIGINT\n"
 	set exit_code 1
diff --git a/testsuite/expect/test1.39 b/testsuite/expect/test1.39
index dd51d690cfbb1fd0135c38616888022f089c34fa..2a2a15cf9e0a26fe1eb2df6cf26f00aaafd11ed0 100755
--- a/testsuite/expect/test1.39
+++ b/testsuite/expect/test1.39
@@ -10,7 +10,7 @@
 # Copyright (C) 2004-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.39.prog.c b/testsuite/expect/test1.39.prog.c
index ac36ef9679c78a4baa78678b00865eb8a1091969..fccca258a33b255527c25b2a4f0cb888be0b8ff2 100644
--- a/testsuite/expect/test1.39.prog.c
+++ b/testsuite/expect/test1.39.prog.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.4 b/testsuite/expect/test1.4
index eb77f9915dee03f152062b57480d46776705acbe..85389cc91e8dcb6c883bb8f58fcb6eace769c1e1 100755
--- a/testsuite/expect/test1.4
+++ b/testsuite/expect/test1.4
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.40 b/testsuite/expect/test1.40
deleted file mode 100755
index 89e870ae8d533c0059d9e68b050be8ae7d4f6644..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.40
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of stand-alone srun resource allocation (--uid and --no-shell
-#          options).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id            "1.40"
-set exit_code          0
-set job_id             0
-
-print_header $test_id
-
-#
-# Submit a slurm allocate job
-#
-set timeout $max_job_delay
-set srun_pid [spawn $srun --allocate -t1 --no-shell]
-expect {
-	-re "SLURM_JOBID=($number).*" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if { $job_id == 0 } {
-	send_user "\nFAILURE: job_id not captured\n"
-	exit 1
-}
-
-#
-# The srun should have completed, confirm the job is active
-#
-set found_job 0
-spawn $squeue --states=running --jobs=$job_id
-expect {
-	-re $job_id {
-		set found_job 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: squeue not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if { $found_job == 0 } {
-	send_user "\nFAILURE: job $job_id not in run state\n"
-	exit 1
-}
-
-#
-# Kill the job
-#
-cancel_job $job_id
-
-#
-# Create a job allocation as some other user, namely root
-#
-set job_id 0
-set srun_pid [spawn $srun --allocate -t1 --no-shell --uid=0]
-expect {
-	-re "SLURM_JOBID=($number).*" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "Invalid user id" {
-		set job_id -1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if { $job_id == 0 } {
-	send_user "\nFAILURE: job_id not captured\n"
-	exit 1
-}
-
-if { $job_id == -1 } {
-	send_user "\nNo worries, this is expected for non-privileged users\n"
-} else {
-#
-#	The srun should have completed, confirm the job is active
-#
-	set found_job 0
-	spawn $squeue --states=running --jobs=$job_id --user=root
-	expect {
-		-re $job_id {
-			set found_job 1
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: squeue not responding\n"
-			set exit_code 1
-		}
-		eof {
-			wait
-		}
-	}
-	if { $found_job == 0 } {
-		send_user "\nFAILURE: job $job_id not in run state\n"
-		exit 1
-	}
-	cancel_job $job_id
-}
-
-if { $exit_code == 0 } {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test1.41 b/testsuite/expect/test1.41
index 2bef5df23955d1355f8ad496c88920c19dd940f4..ee367ee273f77ab50cda673ceb6821ee6c8d376f 100755
--- a/testsuite/expect/test1.41
+++ b/testsuite/expect/test1.41
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.42 b/testsuite/expect/test1.42
index 38a01776b992d06b4661ce14e58e393a988939aa..430d7d5af42a5286a76faba1affdcc192447a64f 100755
--- a/testsuite/expect/test1.42
+++ b/testsuite/expect/test1.42
@@ -1,17 +1,17 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of account number and job dependencies (--account, --begin
-#          and --depedency options).
+#          Test of account number and job dependencies (--account, and
+#          --depedency options).
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2004 The Regents of the University of California.
+# Copyright (C) 2004-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -52,9 +52,9 @@ make_bash_script $file_in "$bin_sleep 5"
 # Spawn a srun batch job that just sleeps for a while
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --account=MY_ACCT -t1 $file_in]
+set srun_pid [spawn $sbatch --output=/dev/null --error=/dev/null --account=MY_ACCT -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
@@ -77,7 +77,7 @@ if {$job_id1 == 0} {
 #
 set match_acct  0
 set match_state 0
-set srun_pid [spawn $srun -v --dependency=$job_id1 $scontrol show job $job_id1]
+set srun_pid [spawn $srun -v --dependency=afterany:$job_id1 $scontrol show job $job_id1]
 expect {
 	-re "launching ($number).0" {
 		set job_id2 $expect_out(1,string)
@@ -117,7 +117,7 @@ set match_acct 0
 set match_jobid 0
 spawn $scontrol show job $job_id2
 expect {
-	-re "Dependency=($number)" {
+	-re "Dependency=afterany:($number)" {
 		set match_jobid $expect_out(1,string)
 		exp_continue
 	}
@@ -142,100 +142,6 @@ if {$match_jobid != $job_id1} {
 	set exit_code 1
 }
 
-#
-# Submit a job to run at noon tomorrow
-#
-set job_id1 0
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --begin=noon-tomorrow $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id1 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id1 == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	exit 1
-}
-exec $bin_sleep 5
-set match 0
-spawn $scontrol show job $job_id1
-expect {
-	-re "JobState=PENDING" {
-		incr match
-		exp_continue
-	}
-	-re "StartTime=($number)/($number)-12:00:00" {
-		incr match
-		exp_continue
-	}
-	-re "StartTime=($number)-($number)-($number)T12:00:00" {
-		incr match
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-if {$match != 2} {
-	send_user "\nFAILURE: unexpected JobState or StartTime\n"
-	set exit_code 1
-}
-# Reset start time and test for completion
-spawn $scontrol update JobId=$job_id1 StartTime=now
-expect {
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-set delayed 0
-set is_done 0
-while { $delayed < $max_job_delay } {
-	exec $bin_sleep 10
-	incr delayed +10
-	spawn $scontrol show job $job_id1
-	expect {
-		-re "JobState=COMPLETED" {
-			set is_done 1
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: scontrol not responding\n"
-			set exit_code 1
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-	if {$is_done == 1} {
-		break
-	}
-}
-if {$is_done == 0} {
-	send_user "\nFAILURE: unexpected JobState\n"
-	cancel_job $job_id1
-	set exit_code 1
-}
-
 
 if {$exit_code == 0} {
 	exec $bin_rm -f $file_in
diff --git a/testsuite/expect/test1.43 b/testsuite/expect/test1.43
index 2dfb3e417700a5dcbb7e1d621840393e8097202f..c88b1d9ea4d82f6cdfbc7db3b52d23cc9e63e8ea 100755
--- a/testsuite/expect/test1.43
+++ b/testsuite/expect/test1.43
@@ -10,7 +10,7 @@
 # Copyright (C) 2005 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.44 b/testsuite/expect/test1.44
index 1c29b0219a66992508991b739233b8953ac1ef2e..e66c46909981a9f8113d39acb95d575881f5cf1c 100755
--- a/testsuite/expect/test1.44
+++ b/testsuite/expect/test1.44
@@ -11,7 +11,7 @@
 # Copyright (C) 2005 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Chris Morrone <morrone2@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.45 b/testsuite/expect/test1.45
deleted file mode 100755
index d6cbe2a1b591ff293a40b1875b8f92431538b82c..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.45
+++ /dev/null
@@ -1,213 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test the launch of a batch job within an existing job allocation.
-#          This logic is used by LSF
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2005-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id      "1.45"
-set file_in      "test$test_id.input"
-set file_out1    "test$test_id.output1"
-set file_out2    "test$test_id.output2"
-set exit_code    0
-set job_id_0     0
-set job_id_1     0
-set job_id_2     0
-
-print_header $test_id
-
-#
-# Delete left-over stdout/err files
-#
-exec $bin_rm -f $file_in $file_out1 $file_out2
-
-#
-# Build input script file
-#
-make_bash_script $file_in "
-  $bin_id
-  $bin_sleep 20"
-
-#
-# Spawn a srun batch job that uses stdout/err and confirm their contents
-#
-if { [test_bluegene] } {
-	set node_cnt 1-2048
-} else {
-	if { [test_xcpu] } {
-		set node_cnt 1-1
-	} else {
-		set node_cnt 1-4
-	}
-}
-
-set timeout $max_job_delay
-set srun_pid [spawn $srun -N$node_cnt -A -v -t1]
-expect {
-	-re "jobid ($number):" {
-		set job_id_0 $expect_out(1,string)
-		send "$srun -b --jobid=$job_id_0 -o $file_out1 $file_in \n"
-		exp_continue
-	}
-	-re "jobid ($number).0 submitted" {
-		set job_id_1 $expect_out(1,string)
-		send "$srun -b --jobid=$job_id_0 -o $file_out2 $bin_id \n"
-		exp_continue
-	}
-	-re "jobid ($number).1 submitted" {
-		set job_id_2 $expect_out(1,string)
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-
-if {$job_id_0 == 0} {
-	send_user "\nFAILURE: job allocation failure\n"
-	slow_kill $srun_pid
-	exit 1
-}
-if {($job_id_1 == 0) || ($job_id_2 == 0)} {
-	send_user "\nFAILURE: batch job submit failure\n"
-	cancel_job $job_id_0
-	exit 1
-}
-
-if {($job_id_0 != $job_id_2) || ($job_id_1 != $job_id_2)} {
-	send_user "\nFAILURE: batch job did not run in existing allocation\n"
-	cancel_job $job_id_0
-	cancel_job $job_id_1
-	cancel_job $job_id_2
-	exit 1
-}
-
-#
-# Check that the job step is reported
-#
-set matches 0
-spawn $scontrol show step $job_id_0.0
-expect {
-	-re "Invalid" {
-		send_user "\nFAILURE: batch step not found\n"
-		set matches 1
-		set exit_code 1
-		exp_continue
-	}
-	-re "$job_id_0.0" {
-		set matches 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$matches == 0} {
-	send_user "\nFAILURE: batch step not found\n"
-	set exit_code 1
-}
-
-#
-# Check batch job step output
-#
-if {[wait_for_file $file_out1] == 0} {
-	set matches 0
-	spawn $bin_cat $file_out1
-	expect {
-		-re "uid=" {
-			set matches 1
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-	if {$matches == 0} {
-		send_user "\nFAILURE: Job output missing\n"
-		set exit_code 1
-	}
-}
-if {[wait_for_file $file_out2] == 0} {
-	set matches 0
-	spawn $bin_cat $file_out2
-	expect {
-		-re "uid=" {
-			set matches 1
-			exp_continue
-		}
-		-re "srun.*command not found" {
-			send_user "\nWARNING: srun is not installed on this computer\n"
-			set matches 1
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-	if {$matches == 0} {
-		send_user "\nFAILURE: Job output missing\n"
-		set exit_code 1
-	}
-}
-
-#
-# Make sure job is still active, then cancel it
-#
-set matches 0
-spawn $scontrol -o show job $job_id_0
-expect {
-	-re "JobState=RUNNING" {
-		set matches 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-if {$matches == 0} {
-	send_user "\nFAILURE: Job not still running\n"
-	set exit_code 1
-}
-cancel_job $job_id_0
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-	exec $bin_rm -f $file_in $file_out1 $file_out2
-}
-exit $exit_code
diff --git a/testsuite/expect/test1.46 b/testsuite/expect/test1.46
index 4a2c66c2b3e42555f4e3c1b318d3c22a8ebfb6e5..57abc964a4d73224f07dfe5f51dab3f5360ae439 100755
--- a/testsuite/expect/test1.46
+++ b/testsuite/expect/test1.46
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.47 b/testsuite/expect/test1.47
deleted file mode 100755
index 7c6b8bfe18076b13f1587978e96477ed913434c9..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.47
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Tests #SLURM entry functionality in a batch script.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2005-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id     "1.47"
-set exit_code   0
-set file_in     "test$test_id.input"
-set file_out    "test$test_id.output"
-set job_acct    "TEST_ACCT"
-set job_name    "TEST_NAME"
-set delay       1
-
-print_header $test_id
-
-make_bash_script $file_in "
-  #SLURM --job-name=$job_name
-  #SLURM --account=$job_acct
-  $bin_sleep $delay
-"
-
-set timeout $max_job_delay
-set job_id 0
-set srun_pid [spawn $srun -o $file_out -b $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	exit 1
-}
-set matches 0
-spawn $scontrol show job $job_id
-expect {
-	-re "Name=$job_name" {
-		incr matches
-		exp_continue
-	}
-	-re "Account=$job_acct" {
-		incr matches
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-if {$matches != 2} {
-	send_user "\nFAILURE: did not set job name and account from batch script\n"
-	set exit_code 1
-}
-
-#
-# Build input script file
-# NOTE: The initial sleep is so that all of the submissions have time 
-#   to occur before contending with a multitude of job step creations.
-#   This is especially important on very slow systems (e.g. AIX).
-#
-make_bash_script $file_in "
-  #SLURM -N1000000k
-  $bin_sleep $delay
-"
-
-set matches 0
-set srun_pid [spawn $srun -o $file_out -b $file_in]
-expect {
-	-re "More .* requested than permitted" {	
-		send_user "This error was expected, no worries\n\n"
-		incr matches
-		exp_continue
-	}	
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$matches != 1} {
-	send_user "\nFAILURE: srun didn't read the correct options from batch file\n"
-	set exit_code 1
-}
-
-make_bash_script $file_in "
-  #SLURM -N650000
-  $bin_sleep $delay
-"
-
-set srun_pid [spawn $srun -N1 -o $file_out -b $file_in]
-expect {
-	-re "More nodes requested than permitted" {
-		send_user "\nFAILURE: srun read from the batch file options"
-		send_user "over writing the commandline options\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Post-processing
-#
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_out
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test1.48 b/testsuite/expect/test1.48
index c2b70ef510ae114b70a9612a575b383dfb2a276a..ac41d29958775940d368b16a2634888ebb482bc4 100755
--- a/testsuite/expect/test1.48
+++ b/testsuite/expect/test1.48
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.49 b/testsuite/expect/test1.49
index a6c77fed54f2f6b48b57a62f248bf7f9153e0dba..fdbc7cfef486c8914612cf695beab10cbffa9179 100755
--- a/testsuite/expect/test1.49
+++ b/testsuite/expect/test1.49
@@ -10,7 +10,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.5 b/testsuite/expect/test1.5
index 32ef1a90d3ad34e6c612459f381cb880e2e5f234..79427066b3ef312e35ffbd3d6f2091608bf01923 100755
--- a/testsuite/expect/test1.5
+++ b/testsuite/expect/test1.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.50 b/testsuite/expect/test1.50
index 68fb338a855dbd4998955928d11b83148d39c87d..d04076e92f73bb3f8b0181b12cfa3131aceb965f 100755
--- a/testsuite/expect/test1.50
+++ b/testsuite/expect/test1.50
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.51 b/testsuite/expect/test1.51
index 0a39e33c10c05e5e8527709b3bc8c1a5c7b55117..34528e12e2569cacd86e2ffcfba12a013d5b01ee 100755
--- a/testsuite/expect/test1.51
+++ b/testsuite/expect/test1.51
@@ -11,7 +11,7 @@
 # Copyright (C) 2005 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.52 b/testsuite/expect/test1.52
index e67eb9cfc3e3ecfb8330b83f62d9d0c9169ab2f4..b488a13df7598fbded018a7758296ef3a6a54c7b 100755
--- a/testsuite/expect/test1.52
+++ b/testsuite/expect/test1.52
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.53 b/testsuite/expect/test1.53
deleted file mode 100755
index 8f033ed3f7f50910e04c2aab2e9474fac99c4473..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.53
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of nice value specification (--nice option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2005 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id     "1.53"
-set exit_code   0
-set file_in     "test$test_id.input"
-set job_id1     0
-set job_id2     0
-set job_id3     0
-set job_prio1   0
-set job_prio2   0
-set job_prio3   0
-
-print_header $test_id
-
-#
-# Build input script file
-#
-make_bash_script $file_in "$bin_sleep 60"
-
-#
-# Submit three jobs with differing nice values
-#
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t2 $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id1 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id1 == 0} {
-	send_user "\nFAILURE: srun submit failed\n"
-	exit 1
-}
-
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t2 --nice $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id2 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		cancel_job $job_id1
-		slow_kill $srun_pid
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id2 == 0} {
-	send_user "\nFAILURE: srun submit failed\n"
-	cancel_job $job_id1
-	exit 1
-}
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t2 --nice=200 $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id3 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		cancel_job $job_id1
-		cancel_job $job_id2
-		slow_kill $srun_pid
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-
-exec $bin_rm -f $file_in
-
-#
-# Get the priority of each job job with scontrol
-#
-spawn $scontrol show job $job_id1
-expect {
-	-re "Priority=($number)" {
-		set job_prio1 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-spawn $scontrol show job $job_id2
-expect {
-	-re "Priority=($number)" {
-		set job_prio2 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-spawn $scontrol show job $job_id3
-expect {
-	-re "Priority=($number)" {
-		set job_prio3 $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: scontrol not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Make sure the job priorities are as expected
-#
-if {$job_prio1 == 0 || $job_prio2 == 0 || $job_prio3 == 0} {
-	send_user "\nFAILURE: failed to job priorities of each submitted job\n"
-	set exit_code 1
-} else {
-	set diff2 [expr $job_prio1 - $job_prio2]
-	set diff3 [expr $job_prio1 - $job_prio3]
-#	Target for diff2 is 101
-	if {$diff2 < 91 || $diff2 > 111} {
-		send_user "\nFAILURE: job2 priority delta bad $diff2\n"
-		set exit_code 1
-	}
-#	Target for diff3 is 202
-	if {$diff3 < 192 || $diff3 > 212} {
-		send_user "\nFAILURE: job3 priority delta bad $diff3\n"
-		set exit_code 1
-	}
-}
-
-cancel_job $job_id1
-cancel_job $job_id2
-cancel_job $job_id3
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
-
diff --git a/testsuite/expect/test1.54 b/testsuite/expect/test1.54
index 21a153bfb34e04ff38dfb6b6de8d7135d0038195..cd235cf73306d0abf8950b7112dceeb75951ebb0 100755
--- a/testsuite/expect/test1.54
+++ b/testsuite/expect/test1.54
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -119,9 +119,14 @@ puts $file "# multi-program configuration file
 close $file
 exec $bin_chmod 700 $file_in
 
+set job_id    -
 set matches   0
-set srun_pid [spawn $srun -N1 -n4 --overcommit -l -t1 --multi-prog --debugger-test ./$file_in]
+set srun_pid [spawn $srun -N1 -n4 --overcommit -l -t1 --multi-prog --debugger-test -v ./$file_in]
 expect {
+	-re "launching ($number)" {
+		set job_id $expect_out(1,string)
+		exp_continue
+	}
 	-re "executable:(/bin/)($alpha)" {
 		if {[string compare $expect_out(2,string) "date"] != 0} {
 			incr matches
@@ -147,6 +152,12 @@ if {$matches != 4} {
 	send_user "\nFAILURE: did not generate full list of executables.\n"
 	set exit_code 1
 }
+if {$job_id == 0} {
+	send_user "\nFAILURE: failed to get job id\n"
+	set exit_code 1
+} else {
+	cancel_job $job_id
+}
 
 if {$exit_code != 0} {
 	exit $exit_code
diff --git a/testsuite/expect/test1.55 b/testsuite/expect/test1.55
index f2239f0a9a95421de8f1c752bfcab993f6e0373c..6879d7563050018e24f5307b3a2039935a4cf1a5 100755
--- a/testsuite/expect/test1.55
+++ b/testsuite/expect/test1.55
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Christopher J. Morrone <morrone2@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -57,7 +57,7 @@ make_bash_script $test_script {
 set timeout $max_job_delay
 set jobid  0
 set stepid 0
-set srun_pid [spawn $srun -u -v -n1 $test_script]
+set srun_pid [spawn $srun -u -v -n1 -t1 $test_script]
 expect {
 	-re "launching (($number)\.0)" {
 		set stepid $expect_out(1,string)
@@ -105,14 +105,37 @@ send_user "Test sees step is gone, srun should have exited as well.\n"
 
 #
 # And finally check to see if srun is still hanging around (it should
-# have exited by now).
+# have exited by now) and job has completed
 #
 if [catch {exec kill -0 $srun_pid}] {
+	send_user "\nsrun command is terminated, as desired\n"
+	set exit_code 0
+} else {
+	send_user "\nFAILURE: srun is still running after job exits!\n"
+	set exit_code 1
+}
+spawn $squeue --noheader --jobs=$jobid
+expect {
+	-re "R" {
+		send_user "\nFAILURE: job not completed!\n"
+		set exit_code 1
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: squeue not responding\n"
+		set exit_code 1
+		exit 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$exit_code == 0} {
 	send_user "\nSUCCESS\n"
 	exec $bin_rm -f $test_script
 	exit 0
 } else {
-	send_user "\nFAILURE: srun is still running after job exits!\n"
-	exec kill -9 $srun_pid
+	cancel_job $jobid
 	exit 1
 }
diff --git a/testsuite/expect/test1.56 b/testsuite/expect/test1.56
index 58af957356840b89750b107425898bc1712f5183..67e539c97937685f43b6b3e0dd18041335085301 100755
--- a/testsuite/expect/test1.56
+++ b/testsuite/expect/test1.56
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Christopher J. Morrone <morrone2@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -59,7 +59,7 @@ close $file
 # Launch the test script
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -v -n1 --input=$file_in --output=$file_out --error=- cat]
+set srun_pid [spawn $srun -v -n1 -t1 --input=$file_in --output=$file_out --error=- cat]
 expect {
 	-re {launching ($number)\.($number)} {
 		set jobid $expect_out(1,string)
diff --git a/testsuite/expect/test1.57 b/testsuite/expect/test1.57
index 4c6916acd829d672d1b869eb76785b6861b92c4a..e117600011f9cd34ee89c59c0acbb51a7d29ded6 100755
--- a/testsuite/expect/test1.57
+++ b/testsuite/expect/test1.57
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.58 b/testsuite/expect/test1.58
index 917b978205a70d2202c587495378a2bf55ee6c35..6d467811c9c6f4989160ae336f5758c326acc55b 100755
--- a/testsuite/expect/test1.58
+++ b/testsuite/expect/test1.58
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Christopher J. Morrone <morrone2@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -42,10 +42,10 @@ set timeout $max_job_delay
 # Run an srun to grab a single node allocation, but not start any
 # job steps.
 #
-set srun_alloc_pid [spawn $srun -v -N1 -n1 -A $bin_sleep 600]
+set srun_alloc_pid [spawn $salloc -v -N1 -n1 $bin_sleep 600]
 set srun_alloc_sid $spawn_id
 expect {
-	-re "srun: jobid ($number)" {
+	-re "salloc: Granted job allocation ($number)" {
 		set jobid $expect_out(1,string)
 	}
 	timeout {
@@ -90,7 +90,7 @@ if {$got_pattern == 0} {
 }
 
 #
-# Release the allocation by killing the first srun (really it kills the "sleep")
+# Release the allocation by killing salloc (really it kills the "sleep")
 #
 cancel_job $jobid
 set spawn_id $srun_alloc_sid
diff --git a/testsuite/expect/test1.59 b/testsuite/expect/test1.59
index 8796b02188e47d51f9cef221412a96d5443464c8..a6f7256e559661ee8711c3babb3ebaa1b4df240b 100755
--- a/testsuite/expect/test1.59
+++ b/testsuite/expect/test1.59
@@ -84,9 +84,9 @@ set node3 0
 set node4 0
 
 set timeout $max_job_delay
-spawn $srun -N$num_nodes -A -v bash
+spawn $salloc -N$num_nodes -v bash
 expect {
-	-re "jobid ($number):" {
+	-re "salloc: Granted job allocation ($number):" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
@@ -173,7 +173,7 @@ for {set i 0} {$i<4} {incr i} {
 	#
 	send "$srun -l $extra -O $bin_printenv SLURMD_NODENAME\n"
 	expect {
-		-re "($number): ($alpha_numeric)" {
+		-re "($number): ($alpha_numeric_under)" {
 			set task_id $expect_out(1,string)
 			if {$task_id == 0} {
 				set node0 $expect_out(2,string)
@@ -326,7 +326,7 @@ for {set i 0} {$i<5} {incr i} {
 	send "$srun -l $extra -O $bin_printenv SLURMD_NODENAME\n"
 	
 	expect {
-		-re "($number): ($alpha_numeric)" {
+		-re "($number): ($alpha_numeric_under)" {
 			set task_id $expect_out(1,string)
 			if {$task_id == 0} {
 				set node0 $expect_out(2,string)
diff --git a/testsuite/expect/test1.6 b/testsuite/expect/test1.6
index d854161d0ac19b7d478a160fc19dde82be698038..5b6ffcb9fe64c682003e35f0607d5350f84d8bc8 100755
--- a/testsuite/expect/test1.6
+++ b/testsuite/expect/test1.6
@@ -13,7 +13,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.7 b/testsuite/expect/test1.7
index af3f663cf02eb2b04583580d16b396f095734923..9bca53f859245f6edc19d11cb9e4b08b71367750 100755
--- a/testsuite/expect/test1.7
+++ b/testsuite/expect/test1.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.8 b/testsuite/expect/test1.8
index 270ee7b56e2b93f3f0253d180dcd731399454f99..e46a26558c8843dd288b7e981641434ebe23e5c6 100755
--- a/testsuite/expect/test1.8
+++ b/testsuite/expect/test1.8
@@ -14,7 +14,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.80 b/testsuite/expect/test1.80
index 1cf18dfdb52fb1e16df31c2125f2738e8051318e..404781af5525d0f03c7cc60a7a76197e7ca6d971 100755
--- a/testsuite/expect/test1.80
+++ b/testsuite/expect/test1.80
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.81 b/testsuite/expect/test1.81
index 9bddb103b08198fe1bede4a9a8bb26f2fa332d70..bd48d432e294cf143cbeb4c08ccd7252c56fe4dc 100755
--- a/testsuite/expect/test1.81
+++ b/testsuite/expect/test1.81
@@ -12,7 +12,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.82 b/testsuite/expect/test1.82
index 84616961be0fa7b77ae17c509ff58e587d320525..e91a3f388867b6b43aab0c81dd86e2efa0145b60 100755
--- a/testsuite/expect/test1.82
+++ b/testsuite/expect/test1.82
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.83 b/testsuite/expect/test1.83
index 6da63e7b0550d4d9d13d6a382bf78b2580f3ede5..a5ec1a9b41a692e6d303942b97f0cf6b17fe02f4 100755
--- a/testsuite/expect/test1.83
+++ b/testsuite/expect/test1.83
@@ -16,7 +16,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -74,7 +74,7 @@ expect {
 		send_user "\nWARNING: can't test srun task distribution\n"
 		exit $exit_code
 	}
-	-re "($number): ($alpha)($number)" {
+	-re "($number): ($alpha_numeric_under)($number)" {
 		set task_id $expect_out(1,string)
 		if {$task_id == 0} {
 			set host_0_name $expect_out(2,string)
@@ -90,7 +90,7 @@ expect {
 		}
 		exp_continue
 	}
-	-re "($number): ($alpha)" {
+	-re "($number): ($alpha_numeric_under)" {
 		set task_id $expect_out(1,string)
 		if {$task_id == 0} {
 			set host_0_name $expect_out(2,string)
diff --git a/testsuite/expect/test1.84 b/testsuite/expect/test1.84
index 15051b73172720ed988505ff0bcf1c30982b30e8..e23d88f0112b4c150bdfd031c4812b909ecdc650 100755
--- a/testsuite/expect/test1.84
+++ b/testsuite/expect/test1.84
@@ -16,7 +16,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.85 b/testsuite/expect/test1.85
deleted file mode 100755
index dbf0fc2fa4e5a7abc713e06505e1b4d2464af615..0000000000000000000000000000000000000000
--- a/testsuite/expect/test1.85
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of partition specification on job submission (--partition  
-#          option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id          "1.85"
-set def_part_name    ""
-set exit_code        0
-set file_in          "test$test_id.input"
-set job_id           0
-set other_part_name  ""
-
-print_header $test_id
-
-#
-# Identify the partitions in the cluster, identifying the default
-#
-spawn $sinfo --summarize  
-expect {
-	-re "($end_of_line)($alpha_numeric)(\[ \*\]) *up" {
-		if (![string compare $expect_out(3,string) "*"]) {
-			set def_part_name   $expect_out(2,string)
-		} else {
-			set other_part_name $expect_out(2,string)
-		}
-		exp_continue
-	}
-	-re "Unable to contact" {
-		send_user "\nFAILURE: slurm appears to be down\n"
-		exit 1
-	}
-	timeout {
-		send_user "\nFAILURE: sinfo not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Build input script file
-#
-make_bash_script $file_in "$srun $bin_sleep $max_job_delay"
-
-#
-# Submit a batch job explicitly to the default partition
-#
-set job_id           0
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --hold --partition=$def_part_name -t1 $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-# Confirm the job's partition
-if {$job_id == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	set exit_code 1
-} else {
-	set read_part ""
-	spawn $scontrol show job $job_id
-	expect {
-		-re "Partition=($alpha_numeric)" {
-			set read_part $expect_out(1,string)
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: scontrol not responding\n"
-			set exit_code 1
-		}
-		eof {
-			wait
-		}
-	}
-	if ([string compare $read_part $def_part_name]) {
-		send_user "\nFAILURE: Improper partition selected\n"
-		set exit_code 1
-	}
-	cancel_job $job_id
-}
-
-#
-# Test if a non-default partition exists, terminate if none
-#
-if (![string compare $other_part_name ""]) {
-	send_user "\nWARNING: can't test srun partition option"
-	send_user " only the default partition exists\n"
-	exec $bin_rm -f $file_in
-	exit $exit_code
-}
-
-#
-# Submit job explicitly to a non-default partition
-#
-set job_id           0
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --hold --partition=$other_part_name -t1 $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-exec $bin_rm -f $file_in
-# Confirm the job's partition
-if {$job_id == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	set exit_code 1
-} else {
-	set read_part ""
-	spawn $scontrol show job $job_id
-	expect {
-		-re "Partition=($alpha_numeric)" {
-			set read_part $expect_out(1,string)
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: scontrol not responding\n"
-			set exit_code 1
-		}
-		eof {
-			wait
-		}
-	}
-	if ([string compare $read_part $other_part_name]) {
-		send_user "\nFAILURE: Improper partition selected\n"
-		set exit_code 1
-	}
-	cancel_job $job_id
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test1.86 b/testsuite/expect/test1.86
index 434858e2410b5b8430b65ec18d76ef033a139a2c..380e80997e4846e18d8e3af5fcbaf2faba812aab 100755
--- a/testsuite/expect/test1.86
+++ b/testsuite/expect/test1.86
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -36,7 +36,7 @@ source ./globals
 set test_id     "1.86"
 set exit_code   0
 set file_in     "test$test_id.input"
-set prompt      "SLURM_QA_PROMPT: "
+set prompt      "PROMPT: "
 
 print_header $test_id
 
@@ -62,7 +62,7 @@ make_bash_script $file_in "
 # Submit a 2 node job
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N2 -A $file_in]
+set salloc_pid [spawn $salloc -N2 -t1 ./$file_in]
 expect {
 	-re "More ($alpha) requested than permitted" {
 		send_user "\nWARNING: can't test srun task distribution\n"
@@ -78,7 +78,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -115,7 +115,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -163,7 +163,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -200,7 +200,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -244,7 +244,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -281,7 +281,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -318,7 +318,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -352,7 +352,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -391,7 +391,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -423,7 +423,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -448,7 +448,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
@@ -474,7 +474,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test1.87 b/testsuite/expect/test1.87
index be5f10717f5c11e181f79259268e2eb827e66143..9442883ed3bfaa1effc051dad1dd7eb042a79251 100755
--- a/testsuite/expect/test1.87
+++ b/testsuite/expect/test1.87
@@ -12,7 +12,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -57,7 +57,7 @@ make_bash_script $file_in "
 # Submit a 4 node job
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N4 -A $file_in]
+set srun_pid [spawn $salloc -N4 ./$file_in]
 expect {
 	-re "More ($alpha) requested than permitted" {
 		send_user "\nWARNING: can't test srun task distribution\n"
diff --git a/testsuite/expect/test1.88 b/testsuite/expect/test1.88
index b23295b916f54d291f12bcb2fd06a5004c6f38c5..d10421f8fdfcce04e86ef5758f99bf35905c69da 100755
--- a/testsuite/expect/test1.88
+++ b/testsuite/expect/test1.88
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -102,13 +102,13 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn a srun batch job that uses stdout/err and confirm their contents
+# Spawn an sbatch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
 set no_start 0
-set srun_pid [spawn $srun -N3 -n6 --batch --output=$file_out --error=$file_err -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N3 -n6 --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
@@ -126,7 +126,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
@@ -176,7 +176,7 @@ if {[wait_for_file $file_out] == 0} {
                 }
         }
 	if {$matches == 0} {
-		send_user "\nFAILURE: No MPI communications occured\n"
+		send_user "\nFAILURE: No MPI communications occurred\n"
 		send_user "  The version of MPI you are using may be incompatible "
 		send_user "with the configured switch\n"
 		send_user "  Core files may be present from failed MPI tasks\n\n"
diff --git a/testsuite/expect/test1.88.prog.c b/testsuite/expect/test1.88.prog.c
index 09ab2a7e77e23b23f75baf233abb16fa73442ea4..e56cb74be02e9f7a3f87b1218e67d6d8a9e8d5d8 100644
--- a/testsuite/expect/test1.88.prog.c
+++ b/testsuite/expect/test1.88.prog.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Dong Ang <dahn@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.89 b/testsuite/expect/test1.89
index c314a4f41c3def049091e7c65a692a544ac28514..7c561700af7eee0f61e9077043e2ac7d61fcca17 100755
--- a/testsuite/expect/test1.89
+++ b/testsuite/expect/test1.89
@@ -11,7 +11,7 @@
 # Copyright (C) 2005 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -64,13 +64,13 @@ send_user "\ntask affinity plugin installed\n"
 # Build a test program to report affinity by task
 #
 exec $bin_rm -f $file_prog
-exec $bin_make -f /dev/null $file_prog
+exec $bin_cc -I$build_dir $file_prog.c -o $file_prog
 exec $bin_chmod 700 $file_prog
 
 #
 # Create an allocation
 #
-set srun_pid [spawn $srun --allocate -N1 --verbose -t2]
+set salloc_pid [spawn $salloc -N1 --verbose -t2 $bin_bash]
 
 #
 # Run a job step to get allocated processor count and affinity
@@ -91,9 +91,9 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		exit 1
 	}
 	-re $prompt
@@ -116,7 +116,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 	}
@@ -143,7 +143,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 	}
@@ -166,7 +166,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 	}
@@ -196,7 +196,7 @@ while {$cpu_cnt < $task_cnt} {
 			exp_continue
 		}
 		timeout {
-			send_user "\nFAILURE: srun (from --allocate) not "
+			send_user "\nFAILURE: salloc not "
 			send_user "responding or failure to recognize prompt\n"
 			set exit_code 1
 			exp_continue
@@ -230,7 +230,7 @@ while {$cpu_cnt < $task_cnt} {
 			exp_continue
 		}
 		timeout {
-			send_user "\nFAILURE: srun (from --allocate) not "
+			send_user "\nFAILURE: salloc not "
 			send_user "responding or failure to recognize prompt\n"
 			set exit_code 1
 			exp_continue
@@ -306,7 +306,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -334,7 +334,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -362,7 +362,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -390,7 +390,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -418,7 +418,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -446,7 +446,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -468,9 +468,9 @@ expect {
 		set exit_code 1
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test1.89.prog.c b/testsuite/expect/test1.89.prog.c
index bcd2c40ec02dfa8477fc0d1026e238c216fcc168..2a1824921d3c1b2820c11448563e1f57ecb55daa 100644
--- a/testsuite/expect/test1.89.prog.c
+++ b/testsuite/expect/test1.89.prog.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -32,7 +32,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "../../config.h"
+#include "config.h"
 
 static void _load_mask(cpu_set_t *mask)
 {
diff --git a/testsuite/expect/test1.9 b/testsuite/expect/test1.9
index a16f027c73031befa7d08fad37d4b3160d5b4b43..f6002c958430026d8efd526e407f6d77d29c15cf 100755
--- a/testsuite/expect/test1.9
+++ b/testsuite/expect/test1.9
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.90 b/testsuite/expect/test1.90
index 374978e9f5ea85ebedf9fbf10c0f19058e594d42..e7b6538e44cc69265ef5e92ea66b7e88e02ce378 100755
--- a/testsuite/expect/test1.90
+++ b/testsuite/expect/test1.90
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -89,7 +89,7 @@ exec $bin_chmod 700 $file_prog
 #
 # Create an allocation
 #
-set srun_pid [spawn $srun --allocate -N1 --exclusive --verbose -t2]
+set salloc_pid [spawn $salloc -N1 --exclusive --verbose -t2 $bin_bash]
 
 #
 # Run a job step to get allocated processor count and affinity
@@ -110,7 +110,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 	}
@@ -135,7 +135,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 	}
@@ -163,7 +163,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 	}
@@ -186,7 +186,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 	}
@@ -215,7 +215,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -242,7 +242,7 @@ while {$cpu_cnt < $task_cnt} {
 			exp_continue
 		}
 		timeout {
-			send_user "\nFAILURE: srun (from --allocate) not "
+			send_user "\nFAILURE: salloc not "
 			send_user "responding or failure to recognize prompt\n"
 			set exit_code 1
 			exp_continue
@@ -276,7 +276,7 @@ while {$cpu_cnt < $task_cnt} {
 			exp_continue
 		}
 		timeout {
-			send_user "\nFAILURE: srun (from --allocate) not "
+			send_user "\nFAILURE: salloc not "
 			send_user "responding or failure to recognize prompt\n"
 			set exit_code 1
 			exp_continue
@@ -352,7 +352,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -380,7 +380,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -408,7 +408,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -436,7 +436,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -464,7 +464,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -492,7 +492,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
 		set exit_code 1
 		exp_continue
@@ -514,9 +514,9 @@ expect {
 		set exit_code 1
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding "
+		send_user "\nFAILURE: salloc not responding "
 		send_user "or failure to recognize prompt\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		set exit_code 1
 	}
 	eof {
@@ -530,7 +530,6 @@ if {$exit_code == 0} {
 } else {
 	send_user "\nNOTE: This test can fail if the node configuration in slurm.conf \n"
 	send_user "  (sockets, cores, threads) differs from the actual configuration\n"
-
 }
 exit $exit_code
 
diff --git a/testsuite/expect/test1.90.prog.c b/testsuite/expect/test1.90.prog.c
index b24730c3f259229aa72db0becd39d17da8745c80..b6f9a2c1232d097a53662ccc2e8aedc3f519ac83 100644
--- a/testsuite/expect/test1.90.prog.c
+++ b/testsuite/expect/test1.90.prog.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.91 b/testsuite/expect/test1.91
index a8f375a6a0a3169b15764de7d3430f90c23d1853..71c5a832a6d7e3667064001fdc9ef65968628974 100755
--- a/testsuite/expect/test1.91
+++ b/testsuite/expect/test1.91
@@ -11,7 +11,7 @@
 # Copyright (C) 2005-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -93,7 +93,7 @@ send_user "Node config: Sockets=$num_sockets Cores=$num_cores Threads=$num_threa
 # Build a test program to report affinity by task
 #
 exec $bin_rm -f $file_prog
-exec $bin_make -f /dev/null $file_prog
+exec $bin_cc -I$build_dir $file_prog.c -o $file_prog
 exec $bin_chmod 700 $file_prog
 
 #
@@ -411,6 +411,9 @@ expect {
 if {$exit_code == 0} {
 	exec $bin_rm -f $file_prog
 	send_user "\nSUCCESS\n"
+} else {
+	send_user "\nNOTE: This test can fail if the node configuration in slurm.conf \n"
+	send_user "  (sockets, cores, threads) differs from the actual configuration\n"
 }
 exit $exit_code
 
diff --git a/testsuite/expect/test1.91.prog.c b/testsuite/expect/test1.91.prog.c
index bcd2c40ec02dfa8477fc0d1026e238c216fcc168..ad98f3ec862a9aa57375d5ace51f846d10102455 100644
--- a/testsuite/expect/test1.91.prog.c
+++ b/testsuite/expect/test1.91.prog.c
@@ -1,12 +1,12 @@
 /*****************************************************************************\
- *  test1.89.prog.c - Simple test program for SLURM regression test1.89.
+ *  test1.91.prog.c - Simple test program for SLURM regression test1.91.
  *  Reports SLURM task ID and the CPU mask,
  *  similar functionality to "taskset" command
  *****************************************************************************
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -32,7 +32,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "../../config.h"
+#include "config.h"
 
 static void _load_mask(cpu_set_t *mask)
 {
diff --git a/testsuite/expect/test1.92 b/testsuite/expect/test1.92
index 1abef4fa823cb57f894007a274e847096b2df4f5..a4f1719a9d5fee4152be202f3199ffc4c2214b87 100755
--- a/testsuite/expect/test1.92
+++ b/testsuite/expect/test1.92
@@ -11,7 +11,7 @@
 # Copyright (C) 2005 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test1.93 b/testsuite/expect/test1.93
new file mode 100755
index 0000000000000000000000000000000000000000..6ff305d4cde70002947dd8e6ee68e262bb146e6e
--- /dev/null
+++ b/testsuite/expect/test1.93
@@ -0,0 +1,156 @@
+#!/usr/bin/expect
+############################################################################
+# Purpose: Test of SLURM functionality
+#          Test of LAM-MPI functionality
+#
+# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "WARNING: ..." with an explanation of why the test can't be made, OR
+#          "FAILURE: ..." otherwise with an explanation of the failure, OR
+#          anything else indicates a failure mode that must be investigated.
+############################################################################
+# Copyright (C) 2008 Lawrence Livermore National Security.
+# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+# Written by Morris Jette <jette1@llnl.gov>
+# LLNL-CODE-402394.
+# 
+# This file is part of SLURM, a resource management program.
+# For details, see <http://www.llnl.gov/linux/slurm/>.
+#  
+# SLURM is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+# 
+# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with SLURM; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+############################################################################
+source ./globals
+
+set test_id     "1.93"
+set exit_code   0
+set file_in     "test$test_id.input"
+set prompt      "PROMPT: "
+
+print_header $test_id
+
+if {[test_front_end] != 0} {
+	send_user "\nWARNING: This test is incompatable with front-end systems\n"
+	exit 0
+}
+
+#
+# Build input script file
+#
+make_bash_script $file_in "
+  export PS1=\"$prompt\"
+  $bin_bash --norc
+"
+
+#
+# Submit a 2 node job
+#
+set timeout $max_job_delay
+set salloc_pid [spawn $salloc -t1 -n2 ./$file_in]
+expect {
+	-re "More ($alpha) requested than permitted" {
+		send_user "\nWARNING: can't test srun task distribution\n"
+		exec $bin_rm -f $file_in
+		exit $exit_code
+	}
+	-re "Unable to contact" {
+		send_user "\nFAILURE: slurm appears to be down\n"
+		exit 1
+	}
+	"$prompt" {
+		send_user "Job initiated\n"
+	}
+	timeout {
+		send_user "\nFAILURE: srun not responding\n"
+		slow_kill $salloc_pid
+		exit 1
+	}
+	eof {
+		wait
+		send_user "\nFAILURE: srun terminated\n"
+		exit 1
+	}
+}
+exec $bin_rm -f $file_in
+
+#
+# Get node names
+#
+set host_0      ""
+set host_1      ""
+send "$srun -l --mpi=lam $bin_hostname\n"
+expect {
+	-re "($number): ($alpha_numeric)" {
+		set host_inx $expect_out(1,string)
+		if {$host_inx == 0} {
+			set host_0 $expect_out(2,string)
+		} 
+		if {$host_inx == 1} {
+			set host_1 $expect_out(2,string)
+		}
+		exp_continue
+	}
+	-re "Unable to contact" {
+		send_user "\nFAILURE: slurm appears to be down\n"
+		exit 1
+	}
+	"$prompt" {
+		send_user "srun completed\n\n"
+	}
+	timeout {
+		send_user "\nFAILURE: srun not responding\n"
+		slow_kill $salloc_pid
+		exit 1
+	}
+	eof {
+		send_user "\nFAILURE: srun EOF\n"
+		exit 1
+	}
+}
+
+#
+# Verify node count
+#
+if {[string compare $host_0 ""] == 0} {
+	send_user "\nFAILURE: no response from task zero\n"
+	set exit_code   1
+}
+if {[string compare $host_0 $host_1] == 0} {
+	send_user "\nFAILURE: mulitple tasks ran on a single node with --mpi=lam option\n"
+	set exit_code   1
+}
+
+#
+# Post-processing
+#
+send "exit\n"
+expect {
+	-re "error" {
+		send_user "\nFAILURE: Some error occured\n"
+		set exit_code   1
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: srun not responding\n"
+		slow_kill $salloc_pid
+		exit 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$exit_code == 0} {
+	send_user "\nSUCCESS\n"
+}
+exit $exit_code
diff --git a/testsuite/expect/test10.1 b/testsuite/expect/test10.1
index 27941c8195e1b4b50c96a7446728fcbb4935fa62..cabb509153e25cd5b48bf685d940c239505521bd 100755
--- a/testsuite/expect/test10.1
+++ b/testsuite/expect/test10.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.10 b/testsuite/expect/test10.10
index 3eb202c65395e4d0c26e1a521b211b4bd011ab19..6124c5ed8d3f95b37f03eb50da99ce67f93c960c 100755
--- a/testsuite/expect/test10.10
+++ b/testsuite/expect/test10.10
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.11 b/testsuite/expect/test10.11
index 42adfd0235536230ff8624f978f24979732fe0bc..2906380109fcdc33df24f627095ab0a97cb4ee8e 100755
--- a/testsuite/expect/test10.11
+++ b/testsuite/expect/test10.11
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.12 b/testsuite/expect/test10.12
index 3ce11585b2a57b5bdf801acf58d0fdefe6c2e16c..09dabf14bf31808183e8120ff575f12a8b514198 100755
--- a/testsuite/expect/test10.12
+++ b/testsuite/expect/test10.12
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -49,7 +49,7 @@ if { [test_bluegene] == 0 } {
 #
 spawn $smap --resolve 000
 expect {
-	-re "must be on BG SN to resolve." {
+	-re "Must be on BG" {
 		set non_bg 1
 		exp_continue;
 	}
diff --git a/testsuite/expect/test10.13 b/testsuite/expect/test10.13
index 5f5739f0c7ded35d3b93cca1f3a949558f4422d6..4f3a5d38ab81bcafa49f57b488eec0cafc226385 100755
--- a/testsuite/expect/test10.13
+++ b/testsuite/expect/test10.13
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.2 b/testsuite/expect/test10.2
index 0cd448d341e9f1fc9dd3580f2777d875575a4d50..85106edd7e50463d617db8536a19f951876e86c6 100755
--- a/testsuite/expect/test10.2
+++ b/testsuite/expect/test10.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.3 b/testsuite/expect/test10.3
index 6fd734719566dd286b014b3001b89bc21bca68c4..fe21a8dc41f939019894d968aed1247322dccaed 100755
--- a/testsuite/expect/test10.3
+++ b/testsuite/expect/test10.3
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.4 b/testsuite/expect/test10.4
index bc03bbd5ceaa850a5d3b7ccb330fb6fbbc7cb838..fbf8b19904ae1d82beef406c94f1f30f09f29f76 100755
--- a/testsuite/expect/test10.4
+++ b/testsuite/expect/test10.4
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.5 b/testsuite/expect/test10.5
index d48da0b53189df911b0a2e722386a93d451d413a..563e009a321e99fa65c3af073e085e05f3658752 100755
--- a/testsuite/expect/test10.5
+++ b/testsuite/expect/test10.5
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.6 b/testsuite/expect/test10.6
index 038e9331be98d992465eef326637926f15e54b76..8e42cf2cde687c7e7b6aae53c229afade7c48760 100755
--- a/testsuite/expect/test10.6
+++ b/testsuite/expect/test10.6
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.7 b/testsuite/expect/test10.7
index 1434afaad7c0667582af93546c160d8537dd0f59..143edfd6cd87cb4520f6099e8a22b0368b1c00ea 100755
--- a/testsuite/expect/test10.7
+++ b/testsuite/expect/test10.7
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.8 b/testsuite/expect/test10.8
index ba3d6e920e38e9af52e5e0fd92024339ad1c85e8..7a53961ac750554323a0dd1106545d3c0f5af1e9 100755
--- a/testsuite/expect/test10.8
+++ b/testsuite/expect/test10.8
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test10.9 b/testsuite/expect/test10.9
index d10cd780f3c111d421e302931cb72e3a2e92f76a..9cb315ca92ab06913b8290be799c2b921ca36a23 100755
--- a/testsuite/expect/test10.9
+++ b/testsuite/expect/test10.9
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test11.1 b/testsuite/expect/test11.1
index 80521b7a871aeb3990a8381e91c1c391dc471e2e..a67bf66924f13aaa8251bfcdd4368e3f552d7ca7 100755
--- a/testsuite/expect/test11.1
+++ b/testsuite/expect/test11.1
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test11.2 b/testsuite/expect/test11.2
index 75b66819892975a805e6add25f2d6c6d704f9e6d..9012250c415a557ef3f7dfc9e17f334a76c54512 100755
--- a/testsuite/expect/test11.2
+++ b/testsuite/expect/test11.2
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test11.3 b/testsuite/expect/test11.3
index 71edfa253e91224f532eabd7d8273e708884f969..af784f1edb83e829f541da87c9c4b48b5eee176b 100755
--- a/testsuite/expect/test11.3
+++ b/testsuite/expect/test11.3
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test11.4 b/testsuite/expect/test11.4
index cf5ccef64cdc40ae208bebfed7c2767bbe7b0b87..10e119cffbb4320807f9de613b4879d804ab64eb 100755
--- a/testsuite/expect/test11.4
+++ b/testsuite/expect/test11.4
@@ -12,7 +12,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test11.5 b/testsuite/expect/test11.5
index 243487b305787a7ce26252034f87e37bc0b00295..ae5c79c62ffb05498de57e74d74dc9ccd27db3a3 100755
--- a/testsuite/expect/test11.5
+++ b/testsuite/expect/test11.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -50,16 +50,16 @@ make_bash_script $file_in "
 #
 # Submit a job so we have something to work with
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t2 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t2 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
 		if {$job_id == 0} {
-			slow_kill $srun_pid
+			slow_kill $sbatch_pid
 		} else {
 			cancel_job $job_id
 		}
diff --git a/testsuite/expect/test11.6 b/testsuite/expect/test11.6
index 4bb373f8d8e9163e189975ba15a7d974613dfa89..afa4414df030b867703ac51359215ef8eec66cd5 100755
--- a/testsuite/expect/test11.6
+++ b/testsuite/expect/test11.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test11.7 b/testsuite/expect/test11.7
index df544a280857837a2749e9ee0f9a6e77c623e6b4..abd36558ff66c1b7de7676a553bf8e87cc5eace9 100755
--- a/testsuite/expect/test11.7
+++ b/testsuite/expect/test11.7
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test12.1 b/testsuite/expect/test12.1
index 5c9f538c91553a26912707a96fabeac642bb799b..4e704b3d2f42a904d7eb558114c5818790a5de69 100755
--- a/testsuite/expect/test12.1
+++ b/testsuite/expect/test12.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -44,7 +44,7 @@ print_header $test_id
  
 spawn $sacct --help
 expect {
-	-re "SLURM accounting is disabled" {
+	-re "SLURM accounting storage is disabled" {
 		set not_support 1
 		exp_continue
 	}
diff --git a/testsuite/expect/test12.2 b/testsuite/expect/test12.2
index e931af63932f390ad4d76c7d8ed306c986a8f0d0..30f006010f9734d8e9724153e1286491cb32aaf4 100755
--- a/testsuite/expect/test12.2
+++ b/testsuite/expect/test12.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2005 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -55,17 +55,27 @@ if {[test_bluegene] != 0} {
 #
 # Check if accounting is enabled
 #
-set supported 0
+set supported_gather  0
+set supported_storage 1
 log_user 0
 spawn $scontrol show config
 expect {
-	-re "JobAcctType *= jobacct/linux" {
-		set supported 1
+	-re "AccountingStorageType *= accounting_storage/none" {
+		set supported_storage 0
 		exp_continue
 	}
-	-re "JobAcctType *= jobacct/aix" {
-		set supported 1
+	-re "JobAcctGatherType *= jobacct_gather/linux" {
+		set supported_gather 1
+		exp_continue
+	}
+	-re "JobAcctGatherType *= jobacct_gather/aix" {
+		set supported_gather 1
 		set aix 1
+		send_user "AIX doesn't do a great job tracking memory usage,\n"
+		send_user "as long as some memory number was\n"
+		send_user "returned we are ok since users are looking for\n"
+		send_user "mostly abnormalities between tasks instead\n"
+		send_user "of actual memory usuage.\n"
 		exp_continue
 	}
 	eof {
@@ -73,8 +83,12 @@ expect {
 	}
 }
 log_user 1
-if {$supported == 0} {
-	send_user "\nWARNING: job accounting not configured on this system\n"
+if {$supported_gather == 0} {
+	send_user "\nWARNING: Job accounting information not gathered on this system\n"
+	exit 0
+}
+if {$supported_storage == 0} {
+	send_user "\nWARNING: Job accounting information not stored on this system\n"
 	exit 0
 }
 
@@ -95,15 +109,15 @@ make_bash_script $file_in "
 # Usage: test12.2.prog <exit_code> <sleep_secs> <mem_kb>
 #
 set timeout [expr $max_job_delay + $sleep_time]
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err -t2 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out --error=$file_err -t2 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -255,7 +269,7 @@ set diff_time [expr $elapsed_time - $sleep_time]
 set error_time [expr abs($diff_time)]
 if {$error_time > 5} {
 	send_user "\nFAILURE: sacct elapsed time discrepancy of $error_time secs\n"
-	send_user "  Wanted $sleep_time secs, got $error_time secs\n"
+	send_user "  Wanted $sleep_time secs, got $elapsed_time secs\n"
 	set exit_code 1
 } else {
 	send_user "\nSUCCESS: sacct elapsed time discrepancy of $error_time secs\n"
diff --git a/testsuite/expect/test12.2.prog.c b/testsuite/expect/test12.2.prog.c
index 1f155042282cd734e0bfcac844d177118d14e6e1..a87085124798d3eb406cd7aaf39fa1b5dec0ebc3 100644
--- a/testsuite/expect/test12.2.prog.c
+++ b/testsuite/expect/test12.2.prog.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -31,7 +31,7 @@
 
 main (int argc, char **argv) 
 {
-	int exit_code, i, sleep_time, mem_kb;
+	int exit_code, sleep_time, mem_kb;
 	char *mem;
 
 	if (argc != 4) {
@@ -46,10 +46,11 @@ main (int argc, char **argv)
 	mem_kb     = atoi(argv[3]);
 
 	mem = malloc(mem_kb * 1024);
-	/* We need to actually use the memory for
-	 * AIX to the allocation */
-	for (i=0; i<(mem_kb * 1024); i++)
-		mem[i] = i%64;
+	/* need to do a memset on the memory or AIX will not give it
+	 * to me! 
+	 */
+	memset(mem, 0, (mem_kb * 1024));
 	sleep(sleep_time);
+	free(mem);
 	exit(exit_code);
 }
diff --git a/testsuite/expect/test13.1 b/testsuite/expect/test13.1
index 0e9299632ae2e5bc3321647a0a9e837417ab8675..dfe37a3cb3b20daa2d4d64f910399752b95a6d19 100755
--- a/testsuite/expect/test13.1
+++ b/testsuite/expect/test13.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -92,8 +92,8 @@ set timeout $max_job_delay
 set job_id 0
 set matches 0
 
-set srun_pid [spawn $srun --allocate -N1 --verbose -t2]
-expect -re "jobid ($number).*"
+set srun_pid [spawn $salloc -N1 --verbose -t2 $bin_bash]
+expect -re "Granted job allocation ($number)"
 set job_id $expect_out(1,string)
 
 # start initial job step to claim some switch windows
@@ -113,7 +113,7 @@ for {set inx 0} {$inx < $windows_iterations} {incr inx} {
 			send "$srun -N1 -O -n$windows_used true\n"
 		}
 		timeout {
-			send_user "\nFAILURE: srun (from --allocate) not responding\n"
+			send_user "\nFAILURE: salloc not responding\n"
 			slow_kill $srun_pid
 			exit 1
 		}
@@ -138,7 +138,7 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun (from --allocate) not responding\n"
+		send_user "\nFAILURE: salloc not responding\n"
 		slow_kill $srun_pid
 		exit 1
 	}
diff --git a/testsuite/expect/test14.1 b/testsuite/expect/test14.1
index 7122f3202c44681c26c8c59d1584683d8cd97502..fed1099e99a259d33006e7e81eb65a23c1ed753c 100755
--- a/testsuite/expect/test14.1
+++ b/testsuite/expect/test14.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test14.2 b/testsuite/expect/test14.2
index 24d5f0d3a86e99b553169e4d6eb2c2e019f65c1e..564f091e3ef9209622f984351aae77c2f884603c 100755
--- a/testsuite/expect/test14.2
+++ b/testsuite/expect/test14.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test14.3 b/testsuite/expect/test14.3
index f8d9850326e23f1ae2ffee15c9c138571b6193fb..1037ca76d775a61a2238cd82dec345d5c3abed88 100755
--- a/testsuite/expect/test14.3
+++ b/testsuite/expect/test14.3
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test14.4 b/testsuite/expect/test14.4
index 9af3b58ae3870df20c4b598c7a83d7ba4b3e64b5..8c7b3636ca7669637c9729e045a8260644e5da1b 100755
--- a/testsuite/expect/test14.4
+++ b/testsuite/expect/test14.4
@@ -13,7 +13,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -77,18 +77,18 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn a srun batch job that uses stdout/err and confirm their contents
+# Spawn an sbatch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N1-4 --batch --output=$file_out --error=$file_err -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N1-4 --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test14.5 b/testsuite/expect/test14.5
index 20a6a9d25ab045d73cdc6a0eb55d1363ab75b1d4..4cdc56176068f15c83d3d2dbf8efe8b181205e59 100755
--- a/testsuite/expect/test14.5
+++ b/testsuite/expect/test14.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -69,18 +69,18 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn a srun batch job that uses stdout/err and confirm their contents
+# Spawn an sbatch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N1-1 --batch --output=$file_out --error=$file_err -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N1 --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test14.6 b/testsuite/expect/test14.6
index 90f64d18dd22d2cf08a34af9e5fd466a8b5427ce..3f5e82c96e99afecf908387a21588d6f36cc3dde 100755
--- a/testsuite/expect/test14.6
+++ b/testsuite/expect/test14.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -61,18 +61,18 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn a srun batch job that uses stdout/err and confirm their contents
+# Spawn an sbatch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N1-1 --batch --output=$file_out --error=$file_err -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N1 --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test14.7 b/testsuite/expect/test14.7
index a296a63e4b07af737ae4aca5d0d598b3f767f6b2..a66eb24da1deddd078a46e6c2ba753577c52ae2f 100755
--- a/testsuite/expect/test14.7
+++ b/testsuite/expect/test14.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -74,18 +74,18 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn a srun batch job that uses stdout/err and confirm their contents
+# Spawn an sbatch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N1 --batch --output=$file_out --error=$file_err -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N1 --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test14.8 b/testsuite/expect/test14.8
index 9fe39f60b1f2e616227fca5155ec4707e2b99a3d..967c95717a2b5abf9c819c839dcff86cad926f92 100755
--- a/testsuite/expect/test14.8
+++ b/testsuite/expect/test14.8
@@ -14,7 +14,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -75,18 +75,18 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn a srun batch job that uses stdout and confirm its contents
+# Spawn an sbatch job that uses stdout and confirm its contents
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N1-4 --batch --output=$file_out -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N1-4 --output=$file_out -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test15.1 b/testsuite/expect/test15.1
index 97085562ef0d681fc33f49c675d4bb23f1f4968d..e94ca83020df62ad005d448d37958a17abdac70c 100755
--- a/testsuite/expect/test15.1
+++ b/testsuite/expect/test15.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.10 b/testsuite/expect/test15.10
index 8261a446199b9349aeeb04766e4dd9571763e4a1..511b2020ede0b64dea3677f5b5dec5c2a783b3cb 100755
--- a/testsuite/expect/test15.10
+++ b/testsuite/expect/test15.10
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.11 b/testsuite/expect/test15.11
index d0833377fe9b302bf2aafe3c5a968af36c4230da..845f0b2e67818c4adc73084f93c5d5149dc936fd 100755
--- a/testsuite/expect/test15.11
+++ b/testsuite/expect/test15.11
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.12 b/testsuite/expect/test15.12
index e16f9e97b696781c63239481208547dee8d4ec73..2b95da58ac3038803c77dc19041f65549365332e 100755
--- a/testsuite/expect/test15.12
+++ b/testsuite/expect/test15.12
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.13 b/testsuite/expect/test15.13
index 0330913787e00c46f6f7b95fcec257b17e98dcd6..3015134dc105cdba1b332a6bb84c8007415c583c 100755
--- a/testsuite/expect/test15.13
+++ b/testsuite/expect/test15.13
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.14 b/testsuite/expect/test15.14
index e28c4ba7d1544cbb1674b69ea94313ce01b96675..b59f3867a7dfaaee2f30b0b1bcf55b1aefd73c7b 100755
--- a/testsuite/expect/test15.14
+++ b/testsuite/expect/test15.14
@@ -8,10 +8,10 @@
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2004-2006 The Regents of the University of California.
+# Copyright (C) 2004-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -76,7 +76,7 @@ if {$job_id1 == 0} {
 #
 set match_acct  0
 set match_state 0
-set salloc_pid [spawn $salloc --dependency=$job_id1 $slaunch $scontrol show job $job_id1]
+set salloc_pid [spawn $salloc --dependency=afterany:$job_id1 $srun $scontrol show job $job_id1]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id2 $expect_out(1,string)
@@ -119,7 +119,7 @@ set match_acct 0
 set match_jobid 0
 spawn $scontrol show job $job_id2
 expect {
-	-re "Dependency=($number)" {
+	-re "Dependency=afterany:($number)" {
 		set match_jobid $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test15.15 b/testsuite/expect/test15.15
index 2a90c1d8d2a3569332849c28d3905d6c7a5c6277..bb310ec97e1ce70f1cb26877524b5d0da1e20d76 100755
--- a/testsuite/expect/test15.15
+++ b/testsuite/expect/test15.15
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.16 b/testsuite/expect/test15.16
index f2f08d16e2cf78435247b0daf1740c931f8bb661..8c03be953572b45602ffcecd8204cca4b4cae401 100755
--- a/testsuite/expect/test15.16
+++ b/testsuite/expect/test15.16
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.17 b/testsuite/expect/test15.17
index 1f47dc50e95f3738d44004749c60f19bc0305d86..2adfadf8135651c0d0863ec05a35ce99bb017f02 100755
--- a/testsuite/expect/test15.17
+++ b/testsuite/expect/test15.17
@@ -11,7 +11,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.18 b/testsuite/expect/test15.18
index ef6dbbe865939631cdeac6d1e1c746fe5547e0ea..7c40c9fde894cae724e0c9302da86d375b9fd468 100755
--- a/testsuite/expect/test15.18
+++ b/testsuite/expect/test15.18
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.19 b/testsuite/expect/test15.19
index 4a2c9ae94d9246f78f5c06f280372c011d4dcfea..54c93c518538b1563ac35216bb8535768b7bfbe6 100755
--- a/testsuite/expect/test15.19
+++ b/testsuite/expect/test15.19
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -46,7 +46,7 @@ set job_id      0
 set host_0      ""
 set task_cnt  0
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1-1 -t1 $slaunch -c 1 -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N1-1 -t1 $srun -c 1 -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
@@ -59,7 +59,7 @@ expect {
 		}
 		exp_continue
 	}
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$task_cnt == 0} {
 			set host_0 $expect_out(1,string)
 		}
@@ -90,7 +90,7 @@ if {[string compare $host_0 ""] == 0} {
 set alloc_fail 0
 set job_id     0
 set task_cnt2  0
-set salloc_pid [spawn $salloc -N1-1 -w $host_0 -t1 $slaunch -n [expr $task_cnt + 1] -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N1-1 -w $host_0 -t1 $srun -n [expr $task_cnt + 1] -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
@@ -133,13 +133,13 @@ set job_id      0
 set host_0      ""
 set host_1      ""
 
-set salloc_pid [spawn $salloc -N1-1 -t1 $slaunch -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N1-1 -t1 $srun -l $bin_printenv SLURMD_NODENAME]
 expect {
 	 -re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
@@ -185,13 +185,13 @@ set host_1      ""
 set host_2      ""
 set host_3      ""
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1-3 -t1 $slaunch -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N1-3 -t1 $srun -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
@@ -254,7 +254,7 @@ set host_1      ""
 set host_2      ""
 set host_3      ""
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N2-3 -t1 $slaunch -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N2-3 -t1 $srun -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
@@ -264,7 +264,7 @@ expect {
 		send_user "\nWARNING: can't test salloc task distribution\n"
 		exit $exit_code
 	}
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
diff --git a/testsuite/expect/test15.2 b/testsuite/expect/test15.2
index c61c60a2e79bb4362e33c329409340cd6cfc844b..fd397cbf82edf178c1f44280ab6dd3aa6306cba4 100755
--- a/testsuite/expect/test15.2
+++ b/testsuite/expect/test15.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.20 b/testsuite/expect/test15.20
index 567ff05084d72eb93da855ab5ea9ae270710dd76..17138750945addcb9caf28c6ab348a83e308e2c8 100755
--- a/testsuite/expect/test15.20
+++ b/testsuite/expect/test15.20
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -65,7 +65,7 @@ if {$available < $node_cnt} {
     exit $exit_code
 }
 
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N$node_cnt -t1 $srun -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
@@ -80,7 +80,7 @@ expect {
 		send_user "WARNING: partition too small for test\n"
 		exit 0
 	}
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
@@ -155,7 +155,7 @@ set host_1      ""
 set host_2      ""
 set job_id      0
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N2 -t1 --exclude=$exclude_node $slaunch -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N2 -t1 --exclude=$exclude_node $srun -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
@@ -168,7 +168,7 @@ expect {
 		exit 0	
 	}
 		
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
@@ -227,13 +227,13 @@ set host_0      ""
 set host_1      ""
 set job_id      0
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 --nodelist=$include_node $slaunch -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N1 -t1 --nodelist=$include_node $srun -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
diff --git a/testsuite/expect/test15.21 b/testsuite/expect/test15.21
index 37d47f7d247c5fb9b6e599a217e65adbb2e3f0c1..05cd8bce843ca9949c6a55d84ffd596e8e2c4af9 100755
--- a/testsuite/expect/test15.21
+++ b/testsuite/expect/test15.21
@@ -15,7 +15,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -63,7 +63,7 @@ set host_1_num       0
 set host_2_num       0
 set job_id           0
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N3-3 --contiguous --immediate -t1 $slaunch -l $bin_printenv SLURMD_NODENAME]
+set salloc_pid [spawn $salloc -N3-3 --contiguous --immediate -t1 $srun -l $bin_printenv SLURMD_NODENAME]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
@@ -73,7 +73,7 @@ expect {
 		send_user "\nWARNING: can't test salloc task distribution\n"
 		exit $exit_code
 	}
-	-re "($number): ($alpha)($number)" {
+	-re "($number): ($alpha_numeric_under)($number)" {
 		set task_id $expect_out(1,string)
 		if {$task_id == 0} {
 			set host_0_name $expect_out(2,string)
@@ -89,7 +89,7 @@ expect {
 		}
 		exp_continue
 	}
-	-re "($number): ($alpha)" {
+	-re "($number): ($alpha_numeric_under)" {
 		set task_id $expect_out(1,string)
 		if {$task_id == 0} {
 			set host_0_name $expect_out(2,string)
@@ -107,11 +107,7 @@ expect {
 			cancel_job $job_id
 		}
 		slow_kill [expr 0 - $salloc_pid]
-		if {$waiting == 1} {
-			send_user "\nWARNING: salloc still not responding, quiting\n"
-		} else {
-			send_user "\nFAILURE: salloc not responding\n"
-		}
+		send_user "\nFAILURE: salloc not responding\n"
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test15.22 b/testsuite/expect/test15.22
index 74823cb37485e473b7ae3ce3537a8b8441230b33..63aaaa4b4e163713da5be077759314e0206d8b7a 100755
--- a/testsuite/expect/test15.22
+++ b/testsuite/expect/test15.22
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.23 b/testsuite/expect/test15.23
index 5e81434a5f978139caea493faeade3d8717cf36e..3ef5b70a66a02dbb0486664e6c78047054e1af9a 100755
--- a/testsuite/expect/test15.23
+++ b/testsuite/expect/test15.23
@@ -1,7 +1,7 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Verify environment variables controlling sallocare processed:
+#          Verify environment variables controlling salloc are processed:
 #          SALLOC_ACCOUNT, SALLOC_DEBUG and SALLOC_TIMELIMIT
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -48,12 +48,12 @@ set env(SALLOC_DEBUG)         2
 set env(SALLOC_TIMELIMIT)     2
 
 #
-# Spawn a job via slaunch using these environment variables
+# Spawn a job via salloc using these environment variables
 #
 set matches 0
 set salloc_pid [spawn $salloc -N1 $bin_bash]
 expect {
-	-re "debug:  Entering _msg_thr_create" {
+	-re "debug:  Entering _msg_thr_internal" {
 		incr matches
 		exp_continue
 	}
@@ -62,8 +62,9 @@ expect {
 		send "$scontrol show job $job_id\n"
 		exp_continue
 	}
-	-re "TimeLimit=($number)" {
-		if {$expect_out(1,string) == 2} {
+	-re "TimeLimit=($number):($number):" {
+		set time_limit [expr $expect_out(1,string) * 60 + $expect_out(2,string)]
+		if {$time_limit == 2} {
 			incr matches
 		} else {
 			send_user "FAILURE: TimeLimit not set\n"
diff --git a/testsuite/expect/test15.24 b/testsuite/expect/test15.24
index 4f64f8509c45f57087391e9575b0e877f375cfc5..21ba71c8ef81be8bc9ac29ac281f757c02f56378 100755
--- a/testsuite/expect/test15.24
+++ b/testsuite/expect/test15.24
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -54,7 +54,7 @@ make_bash_script $file_in "
 set timeout     $max_job_delay
 set matches     0
 set tasks       0
-spawn $salloc --tasks=$task_cnt --overcommit -N1 -t1 $file_in
+spawn $salloc --ntasks=$task_cnt --overcommit -N1 -t1 ./$file_in
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
diff --git a/testsuite/expect/test15.3 b/testsuite/expect/test15.3
index 0a04fc0789ff5aa38a4375b165d6be44f8b64bd4..9598d575a49c0612ecea08807d84123113bf653a 100755
--- a/testsuite/expect/test15.3
+++ b/testsuite/expect/test15.3
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.4 b/testsuite/expect/test15.4
index 584459b3b26081fad56c203c08e9e450a511b790..515a1f132535953faec33b4ba53b738b8de61fc4 100755
--- a/testsuite/expect/test15.4
+++ b/testsuite/expect/test15.4
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -71,7 +71,7 @@ if {$got_login_grps == 0} {
 #
 set timeout $max_job_delay
 set job_id 0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch $bin_id]
+set salloc_pid [spawn $salloc -N1 -t1 $srun $bin_id]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
diff --git a/testsuite/expect/test15.5 b/testsuite/expect/test15.5
index a9fe64296d7f36903dc7901f398096a2d502f6ed..84a5f0d86509145ef418f60f86bcb3c486ee884a 100755
--- a/testsuite/expect/test15.5
+++ b/testsuite/expect/test15.5
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.6 b/testsuite/expect/test15.6
index 2ce58a43f411eb0025a5b8ef9883063f8013b9be..9c002d753355b4763e96d91b48aacd515a87175f 100755
--- a/testsuite/expect/test15.6
+++ b/testsuite/expect/test15.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.7 b/testsuite/expect/test15.7
index 862b7b3e5296e76376f2c0a514b09a8bb875f3cb..ee9a6e126d01f5f8b8fe40d6b8ed3b32b4e930be 100755
--- a/testsuite/expect/test15.7
+++ b/testsuite/expect/test15.7
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.8 b/testsuite/expect/test15.8
index 1060aa71b2cc67bad3dcf0771002e781e033e1c7..077d3694eda19ae060877970f20756ca7c0eef5c 100755
--- a/testsuite/expect/test15.8
+++ b/testsuite/expect/test15.8
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test15.9 b/testsuite/expect/test15.9
index 74899a386a5f9bb16f350c41f5b0e3ba9e86bc7a..f7cc37cff1e86d272e9842173b0c532cc6e00685 100755
--- a/testsuite/expect/test15.9
+++ b/testsuite/expect/test15.9
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -61,10 +61,10 @@ expect {
 				break
 			}
 		}
-		send "exit 0\n"
+		send "exit 4\n"
 		exp_continue
 	}
-	-re "\[Ee\]xit 0" {
+	-re "\[Ee\]xit 4" {
 		set match 1
 		exp_continue
 	}
@@ -86,7 +86,7 @@ expect {
 # Confirm the job_ids match.
 #
 if { $job_id == 0 } {
-	send_user "\nFAILURE: salloc --allocate failure\n"
+	send_user "\nFAILURE: salloc  failure\n"
 	set exit_code 1
 } else {
 	if { $job_id != $slurm_jobid } {
diff --git a/testsuite/expect/test16.1 b/testsuite/expect/test16.1
index dba33284acf137b4506cf80fe9aff7fe6480f8f5..ad2a8d1eb3be304757d784cee8c389aabe8fe89c 100755
--- a/testsuite/expect/test16.1
+++ b/testsuite/expect/test16.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test16.2 b/testsuite/expect/test16.2
index 22f2445c416fcda7602c8901cbd8d5dde325c209..bcc9893810a5bbd836fc6f01189558351e5f3842 100755
--- a/testsuite/expect/test16.2
+++ b/testsuite/expect/test16.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test16.3 b/testsuite/expect/test16.3
index a3a2693fdb91da032b21129439166b7b6449a46c..91dc0efaae50dc1fcc9cfec264607c2bef238ef0 100755
--- a/testsuite/expect/test16.3
+++ b/testsuite/expect/test16.3
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test16.4 b/testsuite/expect/test16.4
index 5be31b4911c00a3433db312cc16c15d6f701354a..eede3faef05f49b28dd05399046f16096adbacb0 100755
--- a/testsuite/expect/test16.4
+++ b/testsuite/expect/test16.4
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,7 +56,7 @@ exec $bin_chmod 700 $file_prog
 # Spawn initial program via srun
 #
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1-4 -t2 $slaunch -n4 --overcommit $file_prog]
+set salloc_pid [spawn $salloc -N1-4 -t2 $srun -n4 --overcommit $file_prog]
 set init_id $spawn_id
 expect {
         -i $init_id
diff --git a/testsuite/expect/test16.4.prog.c b/testsuite/expect/test16.4.prog.c
index ca25b635f34adc5258c3224f8892ff1666e90e32..323926345a3fdb95468ed6b753c013742d5ab711 100644
--- a/testsuite/expect/test16.4.prog.c
+++ b/testsuite/expect/test16.4.prog.c
@@ -5,7 +5,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.1 b/testsuite/expect/test17.1
index f16bedf0fe606c03c0db17f220fc865162ef5a19..f9c4dde8d7e98cc9bbafac90a0a4a484f0c8e8ba 100755
--- a/testsuite/expect/test17.1
+++ b/testsuite/expect/test17.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.10 b/testsuite/expect/test17.10
index c8d0c72c6663a50b7625b0d999a660fca08a90c8..e50a538e22ab4b5b5a9d031ef56d4fc8562a1ccc 100755
--- a/testsuite/expect/test17.10
+++ b/testsuite/expect/test17.10
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.11 b/testsuite/expect/test17.11
index 61f8b55977a7961309b1d7c8b0e811875edb2dc0..2978fbb93eba8dfb0355cba7b388f98331b277f9 100755
--- a/testsuite/expect/test17.11
+++ b/testsuite/expect/test17.11
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.12 b/testsuite/expect/test17.12
index ca4f20a2cf60260c15322129a1e6098f6f7b20fb..da5499ef6c306667adab7a6bff43d8809dfb23a4 100755
--- a/testsuite/expect/test17.12
+++ b/testsuite/expect/test17.12
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.13 b/testsuite/expect/test17.13
index ae34b33466fa95489496ee462d5dc95b952172ba..30f7b295270f98002e6afe5cc402f67d15ce9088 100755
--- a/testsuite/expect/test17.13
+++ b/testsuite/expect/test17.13
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.14 b/testsuite/expect/test17.14
index d7c1b581cf265f3ae06b8ed168f39c92fd8f2ebb..c13b6ce7d5a108bd7082568e04ef5d624bbeb67c 100755
--- a/testsuite/expect/test17.14
+++ b/testsuite/expect/test17.14
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.15 b/testsuite/expect/test17.15
index 9630882817da90c05949826b9d0ab5e85a132ff3..2bfa3b89a240f61bb08d0d54b632b00316f3003c 100755
--- a/testsuite/expect/test17.15
+++ b/testsuite/expect/test17.15
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -44,7 +44,7 @@ set job_id           0
 set limit_core       943
 set limit_fsize      274515
 set limit_nofile     1016
-set limit_nproc      123
+set limit_nproc      1230
 set limit_stack      2021
 set matches          0
 
@@ -117,11 +117,11 @@ if {$cur_stack != -1} {
 # Spawn a job via sbatch to print environment variables and user limits
 #
 make_bash_script $file_in "
-  ulimit -c $limit_core
-  ulimit -f $limit_fsize
-  ulimit -n $limit_nofile
-  ulimit -u $limit_nproc
-  ulimit -s $limit_stack
+  ulimit -S -c $limit_core
+  ulimit -S -f $limit_fsize
+  ulimit -S -n $limit_nofile
+  ulimit -S -u $limit_nproc
+  ulimit -S -s $limit_stack
   ./$file_prog_get
 "
 
diff --git a/testsuite/expect/test17.15.prog.c b/testsuite/expect/test17.15.prog.c
index f499663290e8ace6f5ba807f2b4321c446811124..520d927990cf7700c3dae37f15e74a9bd5082243 100644
--- a/testsuite/expect/test17.15.prog.c
+++ b/testsuite/expect/test17.15.prog.c
@@ -6,7 +6,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.16 b/testsuite/expect/test17.16
index 6a2345802d42b3691e888647f80fd59fad4d9965..63d9498a812f083a8a44823b5e82e6227bfb51a4 100755
--- a/testsuite/expect/test17.16
+++ b/testsuite/expect/test17.16
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.17 b/testsuite/expect/test17.17
index 5f99e433d2aa314a8cf1c2f2ad2c3768ff20db0f..105e0b642c472f5afb61922fc7a27cc38aec577d 100755
--- a/testsuite/expect/test17.17
+++ b/testsuite/expect/test17.17
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -50,11 +50,11 @@ print_header $test_id
 set timeout $max_job_delay
 set srun_pid [spawn $srun -v -N1 -l -t1 $bin_hostname]
 expect {
-	-re "on host ($alpha_numeric)," {
+	-re "on host ($alpha_numeric_under)," {
 		set nodelist_name $expect_out(1,string)
 		exp_continue
 	}
-	-re "0: ($alpha_numeric)" {
+	-re "0: ($alpha_numeric_under)" {
 		set host_name $expect_out(1,string)
 		exp_continue
 	}
@@ -113,7 +113,7 @@ set waited 1
 set timeout [expr $timeout + 5]
 set srun_pid [spawn $srun -N1 --nodelist=$nodelist_name -t1 --share $scontrol -o show job $job_id1]
 expect {
-	-re "Partition=($alpha_numeric)" {
+	-re "Partition=($alpha_numeric_under)" {
 		set partition $expect_out(1,string)
 		exp_continue
 	}
@@ -124,6 +124,7 @@ expect {
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
 		slow_kill $srun_pid
+		cancel_job $job_id1
 		exit 1
 	}
 	eof {
@@ -148,6 +149,7 @@ if {$waited == 0} {
 	set exit_code 1
 }
 
+cancel_job $job_id1
 if {$exit_code == 0} {
 	exec $bin_rm -f $file_err $file_in $file_out
 	send_user "\nSUCCESS\n"
diff --git a/testsuite/expect/test17.18 b/testsuite/expect/test17.18
index 3a23344af31c90a875a671282656b70ab0a90f47..f6c03097b90398abc3858c0f924a6cc9964d0299 100755
--- a/testsuite/expect/test17.18
+++ b/testsuite/expect/test17.18
@@ -8,10 +8,10 @@
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2004-2006 The Regents of the University of California.
+# Copyright (C) 2004-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -82,7 +82,7 @@ make_bash_script $file_in "$scontrol show job $job_id1"
 set match_acct  0
 set match_state 0
 set timeout 30
-spawn $sbatch --dependency=$job_id1 --output=$file_out $file_in
+spawn $sbatch --dependency=afterany:$job_id1 --output=$file_out $file_in
 expect {
 	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
@@ -101,8 +101,11 @@ if {$job_id2 == 0} {
 #
 if {[wait_for_job $job_id2 "DONE"] != 0} {
 	send_user "\nFAILURE: waiting for job to complete\n"
+	cancel_job $job_id2
+	cancel_job $job_id1
 	exit 1
 }
+cancel_job $job_id1
 
 #
 # Inspect the job's output file
@@ -113,7 +116,8 @@ if {[wait_for_file $file_out] != 0} {
 
 spawn $bin_cat $file_out
 expect {
-	-re "JobState=COMPLETED" {
+#	Could be COMPLETED or COMPLETING
+	-re "JobState=COMPLET" {
 		set match_state 1
 		exp_continue
 	}
@@ -142,7 +146,7 @@ set match_acct 0
 set match_jobid 0
 spawn $scontrol show job $job_id2
 expect {
-	-re "Dependency=($number)" {
+	-re "Dependency=afterany:($number)" {
 		set match_jobid $expect_out(1,string)
 		exp_continue
 	}
@@ -185,6 +189,7 @@ if {$job_id1 == 0} {
 	send_user "\nFAILURE: batch submit failure\n"
 	exit 1
 }
+
 exec $bin_sleep 5
 set match 0
 spawn $scontrol show job $job_id1
@@ -214,6 +219,7 @@ if {$match != 2} {
 	send_user "\nFAILURE: unexpected JobState or StartTime\n"
 	set exit_code 1
 }
+
 # Reset start time and test for completion
 spawn $scontrol update JobId=$job_id1 StartTime=now
 expect {
diff --git a/testsuite/expect/test17.19 b/testsuite/expect/test17.19
index 5edc0b5b9e44d7270938d81995c5f9c288e5d6ac..1be95bb18cb4fc23fbc094ac800f72b53059c756 100755
--- a/testsuite/expect/test17.19
+++ b/testsuite/expect/test17.19
@@ -11,7 +11,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -47,7 +47,7 @@ exec $bin_rm -f $file_in
 make_bash_script $file_in "$bin_hostname"
 
 #
-# Spawn a srun batch job that uses stdout/err and confirm their contents
+# Spawn a batch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
 if { [test_bluegene] } {
@@ -60,9 +60,9 @@ if { [test_bluegene] } {
 	}
 }
 
-set srun_pid [spawn $srun -N$node_cnt -A -v -t1]
+set salloc_pid [spawn $salloc -N$node_cnt -v -t1 $bin_bash]
 expect {
-	-re "jobid ($number):" {
+	-re "Granted job allocation ($number)" {
 		set job_id_1 $expect_out(1,string)
 		send "$sbatch --jobid=$job_id_1 -o none -e none $file_in \n"
 		exp_continue
@@ -79,7 +79,7 @@ expect {
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $salloc_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test17.2 b/testsuite/expect/test17.2
index 88979f6e44ee412028779cad2e810641ff177c98..c10ca2aad67e74feb776c3dbdb164308345a95f2 100755
--- a/testsuite/expect/test17.2
+++ b/testsuite/expect/test17.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.20 b/testsuite/expect/test17.20
index 934e92836cdfb5f614bec8b4be1a4ba31fc47409..f95f02a2314ca7b714ea5812a06f419c24586852 100755
--- a/testsuite/expect/test17.20
+++ b/testsuite/expect/test17.20
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -96,8 +96,9 @@ if {$job_id == 0} {
 # Wait for job to complete
 #
 if {[wait_for_job $job_id "DONE"] != 0} {
-        send_user "\nFAILURE: waiting for job to complete\n"
-        set exit_code 1
+	send_user "\nFAILURE: waiting for job to complete\n"
+	cancel_job $job_id
+	exit 1
 }
 
 if {[wait_for_file $file_out] != 0} {
diff --git a/testsuite/expect/test17.21 b/testsuite/expect/test17.21
index e4a7a005f286a0383b126bc727aad3791eef5baf..099e10fa24dc8328b27851d46299558be35a25c3 100755
--- a/testsuite/expect/test17.21
+++ b/testsuite/expect/test17.21
@@ -10,7 +10,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.22 b/testsuite/expect/test17.22
index 6c50acfe517b9476c3b5adc56de8a616029b1e1c..b97ef0ce0e839f949a123b585baa7e4cb524cda0 100755
--- a/testsuite/expect/test17.22
+++ b/testsuite/expect/test17.22
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.23 b/testsuite/expect/test17.23
index 6db886574ed9d370ef388e999863f442727d3935..9eb4646f82a3fb2c1df5d85367eaef6636b98daa 100755
--- a/testsuite/expect/test17.23
+++ b/testsuite/expect/test17.23
@@ -10,7 +10,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.24 b/testsuite/expect/test17.24
index baad6823462526c73a154426662315bfc5b03464..7a1a57d3d67a82611798b60625f7bebe6b3d8a9b 100755
--- a/testsuite/expect/test17.24
+++ b/testsuite/expect/test17.24
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.25 b/testsuite/expect/test17.25
index cc81950cde9ec0f81a341e8763a221e8a750b615..f09f79ca74044a2a69a01ae5f1b9a3677c8cbb84 100755
--- a/testsuite/expect/test17.25
+++ b/testsuite/expect/test17.25
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -56,7 +56,7 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn a job via slaunch using these environment variables
+# Spawn a job via sbatch using these environment variables
 #
 set matches 0
 spawn $sbatch -N1 --output=none $file_in
@@ -99,4 +99,5 @@ if {$exit_code == 0} {
 	exec $bin_rm -f $file_in
 	send_user "\nSUCCESS\n"
 }
+cancel_job $job_id
 exit $exit_code
diff --git a/testsuite/expect/test17.26 b/testsuite/expect/test17.26
index 5898ee19f138c250a6ef068a8a04b36526a5d529..99fb08cbbd27c0daf417dec87fce45b57b75fa3e 100755
--- a/testsuite/expect/test17.26
+++ b/testsuite/expect/test17.26
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -51,7 +51,7 @@ close $fd
 make_bash_script $file_script "$bin_cat"
 
 #
-# Spawn a job via slaunch using these environment variables
+# Spawn a job via sbatch using these environment variables
 #
 set matches 0
 spawn $sbatch -N1 --input=$file_in --output=$file_out $file_script
diff --git a/testsuite/expect/test17.27 b/testsuite/expect/test17.27
index f936989e23b535b34e431ae57d71c36a89a05076..97b7e48bc815d034c92323cd8322c3d88bb68e9a 100755
--- a/testsuite/expect/test17.27
+++ b/testsuite/expect/test17.27
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -69,7 +69,7 @@ if {$available < $node_cnt} {
 #
 # Build input script file
 #
-make_bash_script $file_in "$slaunch -l $bin_printenv SLURMD_NODENAME"
+make_bash_script $file_in "$srun -l $bin_printenv SLURMD_NODENAME"
 
 #
 # Run job to determine what nodes are available
@@ -95,9 +95,14 @@ expect {
 		wait
 	}
 }
+if {$job_id == 0} {
+	send_user "\nFAILURE: job not submitted\n"
+	exit 1
+}
 if {[wait_for_job $job_id "DONE"] != 0} {
 	send_user "\nFAILURE: job did not complete\n"
-	set exit_code 1
+	cancel_job $job_id
+	exit 1
 }
 if {[wait_for_file $file_out] != 0} {
 	send_user "\nFAILURE: no output file\n"
@@ -105,7 +110,7 @@ if {[wait_for_file $file_out] != 0} {
 }
 spawn $bin_cat $file_out
 expect {
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
@@ -196,7 +201,7 @@ if {[wait_for_file $file_out] != 0} {
 }
 spawn $bin_cat $file_out
 expect {
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
@@ -272,7 +277,7 @@ if {[wait_for_file $file_out] != 0} {
 spawn $bin_cat $file_out
 expect {
 
-	-re "($number): ($alpha_numeric)" {
+	-re "($number): ($alpha_numeric_under)" {
 		if {$expect_out(1,string) == 0} {
 			set host_0 $expect_out(2,string)
 		}
diff --git a/testsuite/expect/test17.28 b/testsuite/expect/test17.28
index 8921309bec1b6d3fbf5f001a1909cad1d0f8e001..ca9c67733c1c49f41402826ba43c4b9509ceed50 100755
--- a/testsuite/expect/test17.28
+++ b/testsuite/expect/test17.28
@@ -10,7 +10,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -91,6 +91,7 @@ if {$matches != 2} {
 	send_user "\nFAILURE: did not set job name and account from batch script\n"
 	set exit_code 1
 }
+cancel_job $job_id
 
 #
 # Build input script file
@@ -102,7 +103,7 @@ make_bash_script $file_in "
 #SBATCH -N1000000k
 $bin_sleep $delay
 "
-
+set job_id  0
 set matches 0
 spawn $sbatch -o $file_out $file_in
 expect {
@@ -111,6 +112,10 @@ expect {
 		incr matches
 		exp_continue
 	}	
+	-re "Submitted batch job ($number)" {
+		set job_id $expect_out(1,string)
+		exp_continue
+	}
 	timeout {
 		send_user "\nFAILURE: sbatch not responding\n"
 		set exit_code 1
@@ -124,12 +129,18 @@ if {$matches != 1} {
 	send_user "\nFAILURE: sbatch didn't read the correct options from batch file\n"
 	set exit_code 1
 }
+if {$job_id != 0} {
+	send_user "\nFAILURE: sbatch didn't reject job with invalid size\n"
+	cancel_job $job_id
+	set exit_code 1
+}
 
 make_bash_script $file_in "
 #SBATCH -N650000
 $bin_sleep $delay
 "
 
+set job_id  0
 spawn $sbatch -N1 -o $file_out $file_in
 expect {
 	-re "More nodes requested than permitted" {
@@ -138,6 +149,10 @@ expect {
 		set exit_code 1
 		exp_continue
 	}
+	-re "Submitted batch job ($number)" {
+		set job_id $expect_out(1,string)
+		exp_continue
+	}
 	timeout {
 		send_user "\nFAILURE: sbatch not responding\n"
 		set exit_code 1
@@ -147,6 +162,11 @@ expect {
 		wait
 	}
 }
+if {$job_id == 0} {
+	send_user "\nFAILURE: sbatch didn't reject job with invalid size\n"
+	cancel_job $job_id
+	set exit_code 1
+}
 
 #
 # Post-processing
diff --git a/testsuite/expect/test17.29 b/testsuite/expect/test17.29
index 9d4d783a807f18ec2e992ca778eb08421f57d7e3..ae7f9744614528956c0cdcfde6c1caba6fad1b04 100755
--- a/testsuite/expect/test17.29
+++ b/testsuite/expect/test17.29
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -80,6 +80,7 @@ if {$job_id == 0} {
 #
 if {[wait_for_job $job_id "DONE"] != 0} {
 	send_user "\nFAILURE: waiting for job to complete\n"
+	cancel_job $job_id
 	set exit_code 1
 }
 
diff --git a/testsuite/expect/test17.3 b/testsuite/expect/test17.3
index ff88f3c37bd252b36e9f62a78a3806e7db1b9a1f..9455d10ce2e0d5b18409e4324efe9aa840dad2bc 100755
--- a/testsuite/expect/test17.3
+++ b/testsuite/expect/test17.3
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.31 b/testsuite/expect/test17.31
index 681f2e6b71e05b036daa4805466cb191ee4fdb68..4f9daf6769f148d64c36876ccde381036216ea47 100755
--- a/testsuite/expect/test17.31
+++ b/testsuite/expect/test17.31
@@ -10,7 +10,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -146,12 +146,16 @@ expect {
 		wait
 	}
 }
-
-
 if {$matches != 3} {
 	send_user "\nFAILURE: sbatch didn't read the correct options from batch file\n"
 	set exit_code 1
 }
+if {$job_id == 0} {
+	send_user "\nFAILURE: sbatch failed to submit the job\n"
+	set exit_code 1
+} else {
+	cancel_job $job_id
+}
 
 #
 # Post-processing
diff --git a/testsuite/expect/test17.32 b/testsuite/expect/test17.32
index 0a408b0197b6c9fa48cf84e837c68c3d92d76653..22e0c172688f315d339e8a1fd2a76ce465c323bd 100755
--- a/testsuite/expect/test17.32
+++ b/testsuite/expect/test17.32
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -76,6 +76,7 @@ expect {
 #
 if {[wait_for_job $job_id "DONE"] != 0} {
 	send_user "\nFAILURE: waiting for job to complete\n"
+	cancel_job $job_id
 	set exit_code 1
 }
 set matches     0
diff --git a/testsuite/expect/test18.5 b/testsuite/expect/test17.33
similarity index 54%
rename from testsuite/expect/test18.5
rename to testsuite/expect/test17.33
index d1606bf0f23d09e721e35d12afff4df99625905c..c26cc08f9e5b953eb3d28215bc8431b7164b5f45 100755
--- a/testsuite/expect/test18.5
+++ b/testsuite/expect/test17.33
@@ -1,18 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Confirm that slauch local stdin, stdout, and stderr options work 
-#          (options --slaunch-input, --slaunch-output and --slaunch-error 
-#          respectively).
+#          Test of sbatch --open-mode (truncate or append) option.
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2002 The Regents of the University of California.
+# Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -29,18 +27,16 @@
 # 
 # You should have received a copy of the GNU General Public License along
 # with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 ############################################################################
 source ./globals
 
-set test_id     "18.5"
+set test_id     "17.33"
 set file_in     "test$test_id.input"
 set file_out    "test$test_id.output"
 set file_err    "test$test_id.error"
-
 set exit_code            0
 set login_grp_info       ""
-set job_grp_info         ""
 set got_job_grps         0
 set got_login_grps       0
 set got_sleep_err        0
@@ -52,60 +48,62 @@ print_header $test_id
 # Build stdin file
 #
 exec $bin_rm -f $file_in $file_out $file_err
-exec echo "$bin_id"         >$file_in
-exec echo "$bin_sleep aaa" >>$file_in
-exec echo "exit 0"         >>$file_in
-exec $bin_chmod 700 $file_in
+make_bash_script $file_in "
+  $bin_id
+  $bin_sleep aaa
+  exit 0"
+exec echo "$bin_echo INITIAL_VALUE" >$file_err
+exec echo "$bin_echo INITIAL_VALUE" >$file_out
 
 #
-# Spawn a shell via slaunch that uses stdin/out/err and confirm their contents
+# Get user id and group id for comparison with stdout
 #
-set job_id  0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --slaunch-input=$file_in --slaunch-output=$file_out --slaunch-error=$file_err $bin_bash]
+spawn $bin_id
 expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
+	-re "(uid=$number)" {
+		set login_grp_info $expect_out(1,string)
+		set got_login_grps 1
 		exp_continue
 	}
-	-re "Unable to contact" {
-		send_user "\nFAILURE: slurm appears to be down\n"
-		exit 1
-	}
-	timeout {
-		send_user "\nFAILURE: salloc/slaunch not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
 	eof {
 		wait
 	}
 }
 
 #
-# Check user id and group id in stdout
+# Spawn a shell via srun that uses stdin/out/err in truncate mode
+# and confirm their contents
 #
-spawn $bin_id
+set job_id 0
+set srun_pid [spawn $sbatch --output=$file_out --error=$file_err --open-mode=t -t1 $file_in]
 expect {
-	-re "(uid=.*\n)" {
-		set login_grp_info $expect_out(1,string)
-		set got_login_grps 1
+	-re "Submitted batch job ($number)" {
+		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	eof {
 		wait
 	}
 }
+if {$job_id == 0} {
+	send_user "\nFAILURE: sbatch failed to submit job\n"
+	exit 1
+}
+if {[wait_for_job $job_id "DONE"] != 0} {
+	send_user "\nFAILURE: waiting for job to complete\n"
+	cancel_job $job_id
+	exit 1
+}
 
 if {[wait_for_file $file_out] == 0} {
 	spawn $bin_cat $file_out
 	expect {
-		-re "(uid=.*\n)" {
-			set job_grp_info $expect_out(1,string)
-			set got_job_grps 1
+		-re "INITIAL_VALUE" {
+			send_user "\nFAILURE: stdout file not truncated\n"
+			set exit_code 1
+		}
+		-re "$login_grp_info" {
+			incr got_job_grps
 			exp_continue
 		}
 		eof {
@@ -118,14 +116,10 @@ if {$got_login_grps == 0} {
 	send_user "\nFAILURE: Unable to get user and group ID info\n"
 	set exit_code 1
 }
-if {$got_job_grps == 0} {
+if {$got_job_grps != 1} {
 	send_user "\nFAILURE: User and group ID info missing from stdout\n"
 	set exit_code 1
 }
-if {[string compare $login_grp_info $job_grp_info] != 0} {
-	send_user "\nFAILURE: Login and slurm user info mismatch\n"
-	set exit_code 1
-}
 
 #
 # Check for sleep input specification error in stderr
@@ -133,13 +127,17 @@ if {[string compare $login_grp_info $job_grp_info] != 0} {
 if {[wait_for_file $file_err] == 0} {
 	spawn $bin_cat $file_err
 	expect {
+		-re "INITIAL_VALUE" {
+			send_user "\nFAILURE: stderr file not truncated\n"
+			set exit_code 1
+		}
 		-re "$sleep_error_message" {
 			send_user "\nNo worries, this error is expected\n"
-			set got_sleep_err 1
+			incr got_sleep_err
 			exp_continue
 		}
 		-re "Specify time as a positive integer.*\n" {
-			set got_sleep_err 1
+			incr got_sleep_err
 			exp_continue
 		}
 		eof {
@@ -147,47 +145,85 @@ if {[wait_for_file $file_err] == 0} {
 		}
 	}
 }
-if {$got_sleep_err == 0} {
+if {$got_sleep_err != 1} {
 	send_user "\nFAILURE: Unexpected stderr contents\n"
 	set exit_code 1
 }
 
+if {$exit_code != 0} {
+	exit $exit_code
+}
+
+
 #
-# Spawn a program to run for a while with no input, output or error
+# Spawn a shell via srun that uses stdin/out/err in append mode
+# and confirm their contents
 #
 set job_id 0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --slaunch-input=none --slaunch-output=none --slaunch-error=none $bin_od -c $srun]
+set srun_pid [spawn $sbatch --output=$file_out --error=$file_err --open-mode=a -t1 $file_in]
 expect {
-	-re "Granted job allocation ($number)" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
-	-re "Unable to contact" {
-		send_user "\nFAILURE: slurm appears to be down\n"
-		exit 1
-	}
-	-re "Terminated" {
-		send_user "\nFAILURE: srun failed to complete\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re "job exceeded timelimit" {
-		send_user "\nFAILURE: srun failed to complete\n"
-		set exit_code 1
-		exp_continue
+	eof {
+		wait
 	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
+}
+if {$job_id == 0} {
+	send_user "\nFAILURE: sbatch failed to submit job\n"
+	exit 1
+}
+if {[wait_for_job $job_id "DONE"] != 0} {
+	send_user "\nFAILURE: waiting for job to complete\n"
+	cancel_job $job_id
+	exit 1
+}
+
+set got_job_grps 0
+if {[wait_for_file $file_out] == 0} {
+	spawn $bin_cat $file_out
+	expect {
+		-re "$login_grp_info" {
+			incr got_job_grps
+			exp_continue
+		}
+		eof {
+			wait
 		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
 	}
-	eof {
-		wait
+}
+if {$got_job_grps != 2} {
+	send_user "\nFAILURE: User and group ID info missing from stdout\n"
+	set exit_code 1
+}
+
+#
+# Check for sleep input specification error in stderr
+#
+set got_sleep_err 0
+if {[wait_for_file $file_err] == 0} {
+	spawn $bin_cat $file_err
+	expect {
+		-re "$sleep_error_message" {
+			send_user "\nNo worries, this error is expected\n"
+			incr got_sleep_err
+			exp_continue
+		}
+		-re "Specify time as a positive integer.*\n" {
+			incr got_sleep_err
+			exp_continue
+		}
+		eof {
+			wait
+		}
 	}
 }
+if {$got_sleep_err != 2} {
+	send_user "\nFAILURE: Unexpected stderr contents\n"
+	set exit_code 1
+}
+
 
 if {$exit_code == 0} {
 	exec $bin_rm -f $file_in $file_out $file_err
diff --git a/testsuite/expect/test17.4 b/testsuite/expect/test17.4
index 77006a48ab5e9495b9ca79fc29112a252fe53bfe..1c65f51f430daffc23651432f76d2d7abcc16027 100755
--- a/testsuite/expect/test17.4
+++ b/testsuite/expect/test17.4
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test17.5 b/testsuite/expect/test17.5
index 5dce3b47d2d548410537d1d399bffdd43985433e..e8a72451a45515991113789eab6bf0c9d5449162 100755
--- a/testsuite/expect/test17.5
+++ b/testsuite/expect/test17.5
@@ -11,7 +11,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -34,6 +34,7 @@ source ./globals
 
 set test_id     "17.5"
 set file_in     "test$test_id.input"
+set file_script "test$test_id.bash"
 set file_out    "test$test_id.output"
 set file_err    "test$test_id.error"
 set file_out_j  "test$test_id.j.%j.output"
@@ -46,13 +47,66 @@ print_header $test_id
 # Delete left-over stdin/out/err files
 # Build stdin file
 #
-exec $bin_rm -f $file_in $file_out $file_err
+exec $bin_rm -f $file_in $file_script $file_out $file_err
 make_bash_script $file_in "
   $bin_id
   $bin_sleep aaa
   exit 0
 "
 
+set cwd "[$bin_pwd]"
+make_bash_script $file_script "
+  cd /tmp
+  $sbatch -N1 --workdir=$cwd --output=$file_out --error=$file_err -t1 $cwd/$file_in
+  exit 0
+"
+
+#
+# Spawn a shell via sbatch that submits from a different directory and uses stdout/err 
+# and confirm their contents
+#
+set job_id 0
+spawn $file_script
+expect {
+	-re "Submitted batch job ($number)" {
+		set job_id $expect_out(1,string)
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sbatch not responding\n"
+		set exit_code 1
+		exp_continue
+	}
+	eof {
+		wait
+	}
+}
+if { $job_id == 0 } {
+	send_user "\nFAILURE: failed to submit job\n"
+	exit 1
+}
+
+#
+# Wait for job to complete
+#
+if {[wait_for_job $job_id "DONE"] != 0} {
+	send_user "\nFAILURE: waiting for job to complete\n"
+	set exit_code 1
+}
+
+#
+# Check for desired output
+#
+if {[wait_for_file $file_out] != 0} {
+	send_user "\nFAILURE: Missing stdout\n"
+	set exit_code 1
+}
+if {[wait_for_file $file_err] != 0} {
+	send_user "\nFAILURE: Missing stderr\n"
+	set exit_code 1
+}
+exec $bin_rm -f $file_script $file_out $file_err
+
 #
 # Spawn a shell via sbatch that uses stdout/err and confirm their contents
 #
@@ -227,7 +281,7 @@ if { [file exists $file_err2] } {
 }
  
 if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_out $file_err
+	exec $bin_rm -f $file_in $file_script $file_out $file_err
 	send_user "\nSUCCESS\n"
 }
 exit $exit_code
diff --git a/testsuite/expect/test17.6 b/testsuite/expect/test17.6
index ef1df747e2c0396d6f277358b8f2983bbcbcd9fb..29b9f0b13de7e1dbce818bfb7e7ed1000ac69f30 100755
--- a/testsuite/expect/test17.6
+++ b/testsuite/expect/test17.6
@@ -1,7 +1,7 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Confirm that a job executes with the proper task count (--tasks
+#          Confirm that a job executes with the proper task count (--ntasks
 #          option).
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -45,7 +45,7 @@ print_header $test_id
 # Submit a slurm job that will execute 'id' on $task_cnt tasks (or try anyway)
 #
 file delete $file_in $file_out
-make_bash_script $file_in "$slaunch $bin_id"
+make_bash_script $file_in "$srun $bin_id"
 set job_id 0
 set no_run 0
 spawn $sbatch --ntasks=$task_cnt --output=$file_out -t1 $file_in
diff --git a/testsuite/expect/test17.7 b/testsuite/expect/test17.7
index f2a66d8eb75efbfdb8c269c2d9a6a32190853787..1e68235fceee6773a4c43f542e6917f4c1bcbdf0 100755
--- a/testsuite/expect/test17.7
+++ b/testsuite/expect/test17.7
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -33,9 +33,11 @@
 source ./globals
 
 set test_id     "17.7"
+set cwd         "[$bin_pwd]"
 set exit_code   0
+set file_err    "test$test_id.error"
 set file_in     "test$test_id.input"
-set file_out    "test$test_id.output"
+set file_out    "$cwd/test$test_id.output"
 set tmp_dir     "/tmp"
 
 print_header $test_id
@@ -44,16 +46,17 @@ print_header $test_id
 # Delete left-over stdin/out/err files
 # Build stdin file
 #
-exec $bin_rm -f $file_in $file_out
+exec $bin_rm -f $file_in $file_out $file_err
 make_bash_script $file_in "
   $bin_pwd
+  $bin_cat /no/such/file
 "
 
 #
 # Submit a slurm job that will execute 'pwd'
 #
 set job_id 0
-spawn $sbatch -N1 --output=$file_out --workdir=$tmp_dir -t1 $file_in
+spawn $sbatch -N1 --error=$file_err --output=$file_out --workdir=$tmp_dir -t1 $file_in
 expect {
 	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
@@ -89,6 +92,10 @@ if {[wait_for_file $file_out] == 0} {
 			set matches 1
 			exp_continue
 		}
+		-re "No such" {
+			send_user "\nFAILURE: sbatch stderr in stdout file\n"
+			set exit_code 1
+		}
 		eof {
 			wait
 		}
@@ -99,8 +106,13 @@ if {$matches != 1} {
 	set exit_code 1
 }
 
+if [file exists $file_err] {
+	send_user "\nFAILURE: sbatch failed to create error file in working directory\n"
+	set exit_code 1
+}
+
 if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_out
+	exec $bin_rm -f $file_in $file_out $file_err
 	send_user "\nSUCCESS\n"
 }
 exit $exit_code
diff --git a/testsuite/expect/test17.8 b/testsuite/expect/test17.8
index 10349c324933ce618888caae4547c2f85f269286..d17db4023e63e78c9e4f76fd96cc0a0094d916cf 100755
--- a/testsuite/expect/test17.8
+++ b/testsuite/expect/test17.8
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -77,8 +77,8 @@ if { $job_id == 0 } {
 
 spawn $scontrol show job $job_id
 expect {
-	-re "TimeLimit=($number)" {
-		set time_get $expect_out(1,string)
+	-re "TimeLimit=($number):($number):" {
+		set time_get [expr $expect_out(1,string) * 60 + $expect_out(2,string)]
 		exp_continue
 	}
 	eof {
@@ -121,8 +121,8 @@ if { $job_id == 0 } {
 
 spawn $scontrol show job $job_id
 expect {
-	-re "TimeLimit=($number)" {
-		set time_get $expect_out(1,string)
+	-re "TimeLimit=($number):($number):" {
+		set time_get [expr $expect_out(1,string) * 60 + $expect_out(2,string)]
 		exp_continue
 	}
 	eof {
@@ -165,8 +165,8 @@ if { $job_id == 0 } {
 
 spawn $scontrol show job $job_id
 expect {
-	-re "TimeLimit=($number)" {
-		set time_get $expect_out(1,string)
+	-re "TimeLimit=($number)-($number):($number):" {
+		set time_get [expr $expect_out(1,string) * 1440 + $expect_out(2,string) * 60 + $expect_out(3,string)]
 		exp_continue
 	}
 	eof {
diff --git a/testsuite/expect/test17.9 b/testsuite/expect/test17.9
index 54f779ac47304e468eea1edbee96807fe736ab90..f3aa6c12f41ec1a22b36a89e790fcda67284a6d2 100755
--- a/testsuite/expect/test17.9
+++ b/testsuite/expect/test17.9
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test18.10 b/testsuite/expect/test18.10
deleted file mode 100755
index 5889f4862c19a618bea7c2e116ed29b22d8424df..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.10
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test slaunch task stdout/err disabling (--task-output and 
-#          --task-error options).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id          "18.10"
-set exit_code        0
-set job_id           0
-
-print_header $test_id
-
-#
-# Spawn a program via slaunch with stdout forwarding disabled
-#
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -t1 $slaunch --task-output=none $bin_id]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "uid=" {
-		send_user "\nFAILURE: slaunch improperly forwarded stdout\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re "groups=" {
-		send_user "\nFAILURE: slaunch improperly forwarded stdout\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Spawn a program via slaunch with stderr forwarding disabled
-#
-set job_id    0
-set matches   0
-set salloc_pid [spawn $salloc -t1 -v $slaunch --task-error=/dev/null $bin_sleep aaa]
-expect {
-	-re "Pending job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "invalid" {
-		send_user "\nFAILURE: slaunch improperly forwarded stderr\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re "exit code $number" {
-		send_user "This error is expected, no worries\n"
-		set matches 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$matches != 1} {
-	send_user "\nFAILURE: slaunch exit code does not indicate error\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.11 b/testsuite/expect/test18.11
deleted file mode 100755
index 7bb9961774819dfbc0aaee8ef6a1466df3517cf1..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.11
+++ /dev/null
@@ -1,304 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test slaunch stdout/err file name formatting (--task-output and 
-#          --task-error options with %j, %J, %n, %s and %t specifications).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id          "18.11"
-set exit_code        0
-set file_err_j       "test$test_id.j.%j.error"
-set file_in          "test$test_id.input"
-set file_out_J       "test$test_id.J.%J.output"
-set file_out_n       "test$test_id.n.%n.output"
-set file_out_s       "test$test_id.s.%s.output"
-set file_out_t       "test$test_id.t.%t.output"
-set job_id           0
-set task_cnt         5
-
-print_header $test_id
-
-#
-# Spawn a program that includes "task_id" (%t) in stdout file names
-# and confirm they are created
-#
-file delete [glob -nocomplain "test$test_id.s.*.output"]
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --task-output=$file_out_t -n$task_cnt --overcommit $bin_id]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: job initiation failed\n"
-	exit 1
-}
-
-set file_cnt 0
-for {set task_id 0} {$task_id < $task_cnt} {incr task_id} {
-	set file_out_t_glob  "test$test_id.t.$task_id.output"
-	if {[wait_for_file $file_out_t_glob] != 0} {
-		set exit_code 1
-	} else {
-		file delete $file_out_t_glob
-		incr file_cnt
-	}
-}
-if {$file_cnt != $task_cnt} {
-	send_user "\nFAILURE: file format of %t in stdout failed\n"
-	set exit_code 1
-}
-
-#
-# Spawn a program that includes "jobid" (%j) in stderr file name
-# and confirm it is created
-#
-set job_id    0
-set matches   0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --task-output=/dev/null --task-error=$file_err_j -n$task_cnt --overcommit $bin_sleep aaa]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "exit code $number" {
-		send_user "This error is expected, no worries\n"
-		set matches 1
-		exp_continue;
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: job initiation failed\n"
-	exit 1
-}
-if {$matches == 0} {
-	send_user "\nFAILURE: exit code failed to indicate an error\n"
-	set exit_code 1
-}
-
-set file_err_j_glob  "test$test_id.j.$job_id.error"
-if {[wait_for_file $file_err_j_glob] == 0} {
-	file delete $file_err_j_glob
-} else {
-	send_user "\nFAILURE: file format of %j in stderr failed\n"
-	set exit_code 1
-}
-
-#
-# Spawn a program that includes "job_id.step_id" (%J) in stdout
-# file name and confirm it is created
-#
-set job_id   0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --task-output=$file_out_J $bin_hostname]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: job initiation failed\n"
-	exit 1
-}
-set task_id  0
-set file_out_J_glob  "test$test_id.J.$job_id.$task_id.output"
-if {[wait_for_file $file_out_J_glob] != 0} {
-	send_user "\nFAILURE: file format of %J in stdout failed\n"
-	set exit_code 1
-} else {
-	file delete $file_out_J_glob
-}
-
-#
-# Spawn a program that includes "node_id" (%n) in stdout
-#  file name and confirm it is created
-#
-set node_id 0
-set file_out_n_glob  "test$test_id.n.$node_id.output"
-file delete $file_out_n_glob
-
-set job_id   0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --task-output=$file_out_n -n2 --overcommit $bin_hostname]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: job initiation failed\n"
-	exit 1
-}
-set file_cnt 0
-for {set node_id 0} {$node_id < 2} {incr node_id} {
-	set file_out_n_glob  "test$test_id.n.$node_id.output"
-
-	if {($node_id == 0) && ([wait_for_file $file_out_n_glob] != 0)} {
-		send_user "\nFAILURE: Missing file $file_out_n_glob\n"
-		set exit_code 1
-	} else {
-		exec $bin_sleep 1
-	}
-	if [file exists $file_out_n_glob] {
-		file delete $file_out_n_glob
-		incr file_cnt
-	}
-}
-
-if {$file_cnt != 1} {
-	send_user "\nFAILURE: file format of %n in stdout failed\n"
-	set exit_code 1
-}
-
-#
-# Spawn a program that includes "step_id" (%s) in stdout
-# file name and confirm it is created. Use two step batch job.
-#
-make_bash_script $file_in "
-  $slaunch -n4 --overcommit --task-output=$file_out_s $bin_hostname
-  $slaunch -n4 --overcommit --task-output=$file_out_s $bin_hostname
-"
-
-file delete [glob -nocomplain "test$test_id.s.\[0-4].output"]
-
-if { [test_bluegene] } {
-	set node_cnt 32-2048
-	set task_cnt 32
-} else {
-	if { [test_xcpu] } {
-		set node_cnt 1-1
-	} else {
-		set node_cnt 1-4
-	}
-	set task_cnt 4
-}
-
-set job_id   0
-set sbatch_pid [spawn $sbatch --output=/dev/null -N$node_cnt -t1 $file_in]
-expect {
-	-re "Submitted batch job ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: sbatch not responding\n"
-		slow_kill $sbatch_pid
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: job initiation failed\n"
-	exit 1
-} else {
-	if {[wait_for_job $job_id DONE] != 0} {
-		send_user "\nFAILURE: error completing job $job_id\n"
-		cancel_job $job_id
-		set exit_code 1
-	}
-}
-
-set file_cnt 0
-for {set step_id 0} {$step_id < 3} {incr step_id} {
-	set file_out_s_glob  "test$test_id.s.$step_id.output"
-
-	if {($step_id < 2) && ([wait_for_file $file_out_s_glob] != 0)} {
-		send_user "\nFAILURE: Missing file $file_out_s_glob\n"
-		set exit_code 1
-	} else {
-		exec $bin_sleep 1
-	}
-	if [file exists $file_out_s_glob] {
-		file delete $file_out_s_glob
-		incr file_cnt
-	}
-}
-
-if {$file_cnt != 2} {
-	send_user "\nFAILURE: file format of %s in stdout failed($file_cnt)\n"
-	set exit_code 1
-}
-
-#
-# Post-processing
-#
-if {$exit_code == 0} {
-	file delete $file_in
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.12 b/testsuite/expect/test18.12
deleted file mode 100755
index 48cecadf021896c51ba2d93a77821b67ea39bf53..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.12
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test slaunch stdin routing to specific task (--slaunch-input-filter 
-#          option with numeric argument).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id          "18.12"
-set exit_code        0
-set job_id           0
-set matches          0
-set task_id          3
-
-print_header $test_id
-
-#
-# Spawn a shell via slaunch
-#
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -v -N1 -t1 $slaunch -n10 --overcommit --wait=2 --slaunch-input-filter=3 $bin_bash]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		send "$bin_env\n"
-		exp_continue
-	}
-	-re "SLURM_PROCID=($number)" {
-		set proc_id $expect_out(1,string)
-		if {$task_id == $proc_id} {
-			incr matches
-		} else {
-			send_user "\nFAILURE: wrong task_id responded\n"
-			set exit_code 1
-		}
-		send "exit\n"
-		exp_continue
-	}
-	-re "error: First task exited" {
-		send_user "This error is expected, no worries\n"
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$matches != 1} {
-	send_user "\nFAILURE: specific task_id failed to respond\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.14 b/testsuite/expect/test18.14
deleted file mode 100755
index cf2bbceaced8d69c3de7c054ef63059e0a2d8222..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.14
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Verify the appropriate job environment variables are set
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.14"
-set exit_code   0
-set job_id      0
-set matches     0
-set timeout     $max_job_delay
-
-print_header $test_id
-
-# These are the variables for which we are checking existence.
-# If the number following a variable name is 1, then we check to make
-# certain that the value of the env variable is greater than 0
-array set good_vars {
-    SLURM_JOB_ID 1
-    SLURM_JOB_NUM_NODES 1
-    SLURM_JOB_NODELIST 0
-    SLURM_JOB_CPUS_PER_NODE 1
-
-    SLURM_CPUS_ON_NODE 1
-    SLURM_CPUS_PER_TASK 1
-    SLURM_JOBID 1
-    SLURM_LAUNCH_NODE_IPADDR 0
-    SLURM_LOCALID 0
-    SLURM_NNODES 0
-    SLURM_NODEID 0
-    SLURM_NODELIST 0
-    SLURM_NPROCS 1
-    SLURM_PROCID 0
-    SLURM_SRUN_COMM_HOST 0
-    SLURM_SRUN_COMM_PORT 1
-    SLURM_STEPID 0
-    SLURM_TASKS_PER_NODE 1
-    SLURM_TASK_PID 1
-    SLURM_UMASK 0
-}
-
-#
-# Spawn a job via salloc to print environment variables
-#
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch $bin_env]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "(SLURM_$alpha_under)=($alpha_numeric)" {
-		set found_vars($expect_out(1,string)) "$expect_out(2,string)"
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-set total 0
-set good 0
-send_user "\n"
-foreach {slurm_var check_flag} [array get good_vars] {
-	incr total
-	if {[info exists found_vars($slurm_var)]} {
-		if { $check_flag == 1 && $found_vars($slurm_var) <= 0 } {
-			send_user "FAILURE: Found $slurm_var, "
-			send_user "but $found_vars($slurm_var) <= 0\n"
-		} else {
-			incr good
-		}
-	} else {
-		send_user "FAILURE: Variable $slurm_var not found\n"
-	}
-}
-
-if {$good < $total} {
-	send_user "\nFAILURE: Only $good of $total SLURM environment variables set\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.15 b/testsuite/expect/test18.15
deleted file mode 100755
index 7d8161cef88a1f8bc82ab906a33ed87dd6fb4337..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.15
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Verify that user environment variables are propagated to the job
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id          "18.15"
-set test_env_name    "TEST_ENV_$test_id"
-set test_env_val     123
-set exit_code        0
-set job_id           0
-set matches          0
-set timeout          $max_job_delay
-
-global env
-set env($test_env_name) $test_env_val
-
-print_header $test_id
-
-#
-# Spawn a job via sbatch to print environment variables
-#
-set env($test_env_name) $test_env_val
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch $bin_env]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "$test_env_name=($number)" {
-		if {$expect_out(1,string) == $test_env_val} {
-			incr matches
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$matches != 1} {
-	send_user "\nFAILURE: Environment variables not propagated\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.16 b/testsuite/expect/test18.16
deleted file mode 100755
index 160773903837d873d206802366eb74425dedbc9d..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.16
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Verify that user limits are propagated to the job
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-#
-# Note:    AIX does not support the NPROC limit, but this test should 
-#          otherwise succeed
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id          "18.16"
-set exit_code        0
-set job_id           0
-set limit_core       943
-set limit_fsize      274515
-set limit_nofile     1016
-set limit_nproc      345
-set limit_stack      2021
-set matches          0
-set file_in          "test$test_id.input"
-set file_prog_get    "test$test_id.prog"
-set timeout          $max_job_delay
-
-print_header $test_id
-
-#
-# Delete left-over programs and rebuild them.
-# We use our own program to get ulimit values since the output 
-# of the ulimit program is inconsistent across systems.
-#
-exec $bin_rm -f $file_prog_get
-exec $bin_make -f /dev/null $file_prog_get
-
-#
-# Get our current limits and adjust targets accordingly
-#
-set cur_core   -1
-set cur_fsize  -1
-set cur_nofile -1
-set cur_nproc  -1
-set cur_stack  -1
-spawn ./$file_prog_get
-expect {
-	-re "USER_CORE=($number)" {
-		set cur_core $expect_out(1,string)
-		exp_continue
-	}
-	-re "USER_FSIZE=($number)" {
-		set cur_fsize $expect_out(1,string)
-		exp_continue
-	}
-	-re "USER_NOFILE=($number)" {
-		set cur_nofile $expect_out(1,string)
-		exp_continue
-	}
-	-re "USER_NPROC=($number)" {
-		set cur_nproc $expect_out(1,string)
-		exp_continue
-	}
-	-re "USER_STACK=($number)" {
-		set cur_stack $expect_out(1,string)
-		exp_continue
-	}
-}
-if {$cur_core != -1} {
-	if {$cur_core == 0} {
-		set limit_core 0
-	} else {
-		set limit_core [expr ($cur_core / 1024) - 2]
-	}
-}
-if {$cur_fsize != -1} {
-	if {$cur_fsize == 0} {
-		set limit_fsize 0
-	} else {
-		set limit_fsize [expr ($cur_fsize / 1024) - 2]
-	}
-}
-if {$cur_nofile != -1} {
-	set limit_nofile [expr $cur_nofile - 2]
-}
-if {$cur_nproc != -1} {
-	set limit_nproc [expr $cur_nproc - 2]
-}
-if {$cur_stack != -1} {
-	set limit_stack [expr ($cur_stack / 1024) - 2]
-}
-
-#
-# Spawn a job via salloc/slaunch to print environment variables and 
-# user limits
-#
-make_bash_script $file_in "
-  ulimit -c $limit_core
-  ulimit -f $limit_fsize
-  ulimit -n $limit_nofile
-  ulimit -u $limit_nproc
-  ulimit -s $limit_stack
-  ./$file_prog_get
-"
-
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch ./$file_in]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "USER_CORE=($number)" {
-		if {$expect_out(1,string) == [expr $limit_core * 1024]} {
-			incr matches
-		}
-		exp_continue
-	}
-	-re "USER_FSIZE=($number)" {
-		if {$expect_out(1,string) == [expr $limit_fsize * 1024]} {
-			incr matches
-		}
-		exp_continue
-	}
-	-re "USER_NOFILE=($number)" {
-		if {$expect_out(1,string) == $limit_nofile} {
-			incr matches
-		}
-		exp_continue
-	}
-	-re "USER_NPROC=($number)" {
-		if {$expect_out(1,string) == $limit_nproc} {
-			incr matches
-		}
-		exp_continue
-	}
-	-re "USER_NPROC unsupported" {
-		incr matches
-		exp_continue
-	}
-	-re "USER_STACK=($number)" {
-		if {$expect_out(1,string) == [expr $limit_stack * 1024]} {
-			incr matches
-		}
-		exp_continue
-	}
-	-re "USER_STACK unsupported" {
-		incr matches
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$matches != 5} {
-	send_user "\nFAILURE: User limits not propagated\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-        exec $bin_rm -f $file_in $file_prog_get
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.16.prog.c b/testsuite/expect/test18.16.prog.c
deleted file mode 100644
index f499663290e8ace6f5ba807f2b4321c446811124..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.16.prog.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************\
- *  proc1.29.proc.c - Simple user limit set program for SLURM regression 
- *  test1.29. Get the core, fsize, nofile, and nproc limits and print their 
- *  values in the same format as SLURM environment variables.
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <unistd.h>
-
-main (int argc, char **argv) 
-{
-	struct rlimit u_limit;
-	int exit_code = 0;
-
-	(void) getrlimit(RLIMIT_CORE, &u_limit);
-	printf("USER_CORE=%d\n", u_limit.rlim_cur);
-	(void) getrlimit(RLIMIT_FSIZE, &u_limit);
-	printf("USER_FSIZE=%d\n", u_limit.rlim_cur);
-	(void) getrlimit(RLIMIT_NOFILE, &u_limit);
-	printf("USER_NOFILE=%d\n", u_limit.rlim_cur);
-#ifdef RLIMIT_NPROC
-	(void) getrlimit(RLIMIT_NPROC, &u_limit);
-	printf("USER_NPROC=%d\n", u_limit.rlim_cur);
-#else
-	printf("USER_NPROC unsupported\n");
-#endif
-#ifdef RLIMIT_STACK
-        (void) getrlimit(RLIMIT_STACK, &u_limit);
-        printf("USER_STACK=%d\n", u_limit.rlim_cur);
-#else
-        printf("USER_STACK unsupported\n");
-#endif
-
-	exit(exit_code);
-}
diff --git a/testsuite/expect/test18.17 b/testsuite/expect/test18.17
deleted file mode 100755
index 7ecf979653a099999a1c2e69509f8462bb296997..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.17
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of salloc and slaunch exit code reporting
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id        "18.17"
-set exit_code      0
-set exit_script    "./test$test_id.exit.bash"
-set test_script    "./test$test_id.bash"
-print_header $test_id
-
-set timeout $max_job_delay
-
-#
-# Delete left-over scripts and build new ones
-#
-make_bash_script $exit_script {exit $((SLURM_PROCID + 10))}
-
-#
-# Check the return code of slaunch.  To do so, we spawn
-# salloc and slaunch command seperately.
-#
-set job_id  0
-set matches 0
-
-# First start salloc and wait for the allocation
-set salloc_pid [spawn $salloc -N1 -t1 --kill-command sleep 300]
-set salloc_spawn_id $spawn_id
-set spawn_id $salloc_spawn_id
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-	}
-	timeout {
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		send_user "\nFAILURE: salloc not responding\n"
-		exit 1
-	}
-}
-
-# Then spawn slaunch using the job allocation from the previous salloc
-set slaunch_pid [spawn $slaunch --jobid=$job_id -n2 --overcommit $exit_script]
-set slaunch_spawn_id $spawn_id
-set spawn_id $slaunch_spawn_id
-set sum 0
-expect {
-	-re "exit code ($number)" {
-		send_user "\nThis error is expected, no worries\n"
-		incr sum $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding\n"
-		slow_kill $slaunch_pid
-		set exit_code 1
-		exp_continue
-	}
-	eof {
-		set slaunch_rc [lindex [wait] 3]
-	}
-}
-if {$sum != 21} {
-	send_user "\nFAILURE: slaunch failed to report individual task error codes\n"
-	set exit_code 1
-}
-send_user "slaunch rc = $slaunch_rc\n"
-if {$slaunch_rc != 11} {
-	send_user "\nFAILURE: slaunch's return code was not the maximum task return code\n"
-	set exit_code 1
-}
-
-# signal the entire process group of salloc to kill the "sleep 300"
-exec $bin_kill -s INT "-$salloc_pid"
-set salloc_rc [lindex [wait -i $salloc_spawn_id] 3]
-# We don't care about salloc's return code (it is probably 1 because
-# we are killing the sleep command with SIGINT.
-#send_user "salloc rc = $salloc_rc\n"
-
-#
-# Post-processing
-#
-if {$exit_code == 0} {
-	exec $bin_rm -f $exit_script $test_script
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.18 b/testsuite/expect/test18.18
deleted file mode 100755
index aa27a91068056bea38e8e4fcb4c22f6c8e24aaaf..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.18
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test parallel launch of slaunch ("slaunch slaunch id").
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.18"
-
-set exit_code    0
-set mult         4
-set task_output  0
-if {[test_aix]} {
-    set task_cnt 3
-} else {
-    set task_cnt 4
-}
-print_header $test_id
-
-#
-# Spawn slaunch with $task_cnt tasks each of which runs a $mult way /bin/id
-#
-set timeout $max_job_delay
-
-if { [test_bluegene] } {
-	set node_cnt 1-2048
-} else {
-	if { [test_xcpu] } {
-		set node_cnt 1-1
-	} else {
-		set node_cnt 1-4
-	}
-}
-
-set job_id  0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -n$task_cnt --overcommit $slaunch -l -n$mult --overcommit $bin_id]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "($number): uid=" {
-		incr task_output
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$task_output != [expr $task_cnt * $mult]} {
-	send_user "\nFAILURE: failed to get output from all tasks\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.19 b/testsuite/expect/test18.19
deleted file mode 100755
index 757ee908b5839ca77a75ff4071754f82db6cfe64..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.19
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of slaunch signal forwarding (actually using scancel, for
-#          now anyway)
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.19"
-set exit_code   0
-set file_prog   "test$test_id.prog"
-set matches     0
-set usr1cnt     0
-set usr2cnt     0
-
-print_header $test_id
-
-if { [test_xcpu] } {
-	send_user "\nWARNING: This test is incompatable with XCPU systems\n"
-	exit $exit_code
-}
-
-#
-# Delete left-over program and rebuild it
-#
-exec $bin_rm -f $file_prog
-exec $bin_make -f /dev/null $file_prog
-exec $bin_chmod 700 $file_prog
-
-#
-# Get uid
-#
-spawn $bin_id -u
-expect {
-	-re "($number)" {
-		set uid $expect_out(1,string)
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Spawn initial program via salloc/slaunch
-# Note: For systems supporting proper pthreads, instead use
-#       exec $bin_kill -USR1 $salloc_pid, otherwise we need pkill 
-#       and can get multiple signals delivered
-# Note: We send the signals right after task startup rather than
-#	interspersed with messages because some versions of 
-#	Expect have difficulties handling unbuffered slaunch output
-#
-set timeout $max_job_delay
-set job_id       0
-set slaunch_pid  0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch -vv --unbuffered $file_prog]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "slaunch pid ($number)" {
-		set slaunch_pid $expect_out(1,string)
-		exp_continue
-	}
-	-re "WAITING" {
-		incr matches
-                if {$slaunch_pid != 0} {
-#			exec $bin_kill -USR1 $slaunch_pid
-#			exec $bin_kill -USR2 $slaunch_pid
-			exec $scancel --signal=USR1 $job_id.0
-			exec $scancel --signal=USR2 $job_id.0
-			exp_continue
-		}
-	}
-	-re "SIGUSR1" {
-		set usr1cnt [expr $usr1cnt + 1]
-		exp_continue
-	}
-	-re "SIGUSR2" {
-		set usr2cnt [expr $usr2cnt + 1]
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-	}
-	-re "error.*not running" {
-		send_user "\nDon't worry about the error...\n"
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		send_user "\nEOF\n"
-		wait
-	}
-}
-if {$matches != 1} {
-	send_user "\nFAILURE: salloc failed to initialize properly\n"
-	set exit_code 1
-}
-if {$usr1cnt != 1} {
-	send_user "\nFAILURE: $file_prog received $usr1cnt SIGUSR1 (not 1)\n"
-	set exit_code 1
-}
-if {$usr2cnt != 1} {
-	send_user "\nFAILURE: $file_prog received $usr2cnt SIGUSR2 (not 1)\n"
-	set exit_code 1
-}
-
-#
-# Post-processing
-#
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_prog
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.19.prog.c b/testsuite/expect/test18.19.prog.c
deleted file mode 100644
index bbf1d3b076ff61ba98c9a376d1588096446031c1..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.19.prog.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*****************************************************************************\
- *  prog18.19.prog.c - Simple signal catching test program for SLURM regression 
- *  test18.19. Report caught signals. Exit after SIGUSR1 and SIGUSR2 received.
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-
-int sigusr1_cnt = 0, sigusr2_cnt = 0;
-
-void sig_handler(int sig)
-{
-	switch (sig)
-	{
-		case SIGUSR1:
-			printf("Received SIGUSR1\n");
-			fflush(stdout);
-			sigusr1_cnt++;
-			break;
-		case SIGUSR2:
-			printf("Received SIGUSR2\n");
-			fflush(stdout);
-			sigusr2_cnt++;
-			break;
-		default:
-			printf("Received signal %d\n", sig);
-			fflush(stdout);
-	}
-}
-
-main (int argc, char **argv) 
-{
-	struct sigaction act;
-
-	act.sa_handler = sig_handler;
-	sigemptyset(&act.sa_mask);
-	act.sa_flags = 0;
-	if (sigaction(SIGUSR1, &act, NULL) < 0) {
-		perror("setting SIGUSR1 handler");
-		exit(2);
-	}
-	if (sigaction(SIGUSR2, &act, NULL) < 0) {
-		perror("setting SIGUSR2 handler");
-		exit(2);
-	}
-
-	printf("WAITING\n");
-	fflush(stdout);
-
-	while (!sigusr1_cnt || !sigusr2_cnt) {
-		sleep(1);
-	}
-
-	exit(0);
-}
diff --git a/testsuite/expect/test18.20 b/testsuite/expect/test18.20
deleted file mode 100755
index b10f11255c7eb65aef0ccb0dc17db46341fc7ffe..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.20
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Run "slaunch cat" and read slaunch's stdout SLOWLY, creating
-#          stdout back pressure in slaunch.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-#
-############################################################################
-# Copyright (C) 2005-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Chris Morrone <morrone2@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id      "18.20"
-set cycle_count  3
-set target_lines 1000
-set exit_code    0
-set file_in      "test$test_id.input"
-set file_out     "test$test_id.output"
-set file_err     "test$test_id.error"
-set task_cnt     1
-
-print_header $test_id
-
-# Execute an slaunch job to cat input_file.  Read slaunch's stdout SLOWLY 
-# (1k/sec) to create back pressure which used to reveal a stdout data-loss bug.
-# Write the slaunch's stdout to a file so that the caller can compare the sizes
-# of input_file and output_file.
-proc run_cat_backpressure { input_file output_file } {
-	global bin_cat bin_sleep bin_rm salloc slaunch 
-	global node_cnt task_cnt timeout file_err
-
-	send_user "Running run_cat_backpressure (This is slow)."
-	exec $bin_rm -f $file_err $output_file
-	set iter 0
-
-	set output [open $output_file w]
-	set slaunch_output [open "| $salloc -N1 -t2 $slaunch --task-error=$file_err $bin_cat $input_file" r]
-	while {![eof $slaunch_output]} {
-		puts -nonewline $output [read $slaunch_output 1]
-		incr iter
-		if {[expr $iter % 1000] == 0} {
-			send_user "."
-			exec $bin_sleep 1
-		}
-	}
-
-	send_user "\n"
-	flush $output
-	close $output
-}
-
-#
-# Create a sizable text file
-#
-exec $bin_rm -f $file_in $file_out
-for {set inx 0} {$inx < 10} {incr inx} {
-	exec $bin_cat /etc/hosts  >>$file_out
-	exec $bin_cat /etc/passwd >>$file_out
-}
-exec head -n $target_lines <$file_out >$file_in
-exec $bin_rm -f $file_out
-
-set stdin_lines [get_line_cnt $file_in]
-set stdout_target [expr $stdin_lines * $task_cnt]
-
-#
-# Run cycle_count jobs to copy job input to job output and compare sizes
-#
-set success_cnt 0
-set timeout $max_job_delay
-for {set inx 0} {$inx < $cycle_count} {incr inx} {
-	run_cat_backpressure $file_in $file_out
-	set stdout_lines [get_line_cnt $file_out]
-	if {$stdout_lines != $stdout_target} {
-		exec $bin_sleep 1
-		set stdout_lines [get_line_cnt $file_out]
-	}
-	if {$stdout_lines != $stdout_target} {
-		send_user "\nFAILURE: stdout is incomplete\n"
-	        set exit_code 1
-	        break
-	} else {
-		incr success_cnt
-	}
-}
-exec $bin_rm -f $file_in $file_out $file_err
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-	exec $bin_rm -f $file_err $file_in $file_out
-} else {
-	send_user "\nFAILURE\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.21 b/testsuite/expect/test18.21
deleted file mode 100755
index 6b78a7c135297a373879b71f9892e97c3aab4fe7..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.21
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of slaunch's --kill-on-bad-exit option.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.21"
-set exit_code   0
-set file_in     "test$test_id.prog"
-set matches     0
-
-print_header $test_id
-
-#
-# Delete left-over input script
-# Build input script file
-#
-# We have the last of the tasks exit.  proctrack/linuxproc will not
-# signal processes named "slurmstepd" and later user tasks could still
-# be named "slurmstepd" when the termination signal comes in.
-#
-exec $bin_rm -f $file_in
-set fd [open "$file_in.c" w]
-puts $fd {
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-main()
-{
-	char *id = getenv("SLURM_PROCID");
-	if (atoi(id) == 9) {
-		sleep(1); /* helps with proctrack/linuxproc problem */
-		exit(2);
-	}
-	sleep(15);
-	printf("SHOULD_NOT_BE_HERE\n");
-}
-}
-close $fd
-# Add delay due to sporatic error "Clock skew detected"
-exec $bin_sleep 1
-exec $bin_make -f /dev/null $file_in
-exec $bin_chmod 700 $file_in
-
-#
-# Spawn a shell via sattach/slaunch and send exit command to task 1 only
-#
-set timeout $max_job_delay
-set job_id  0
-set salloc_pid [spawn $salloc -t1 -N1 $slaunch -n10 --overcommit --kill-on-bad-exit $file_in]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "exit code 2" {
-		send_user "This error is expected, no worries\n"
-		incr matches
-		exp_continue
-	}
-	-re "SHOULD_NOT_BE_HERE" {
-		set matches -10
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id_1
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$matches != 1} {
-	send_user "\nFAILURE: problem with --kill-on-bad-exit option\n"
-	set exit_code 1
-}
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_in.c
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.22 b/testsuite/expect/test18.22
deleted file mode 100755
index d4398c40e73b49f64ff0cdb78d26e118108dc7e5..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.22
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of slaunch task-prolog and task-epilog option.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2005-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id              "18.22"
-set exit_code            0
-set cwd                  "[$bin_pwd]"
-set tasks                4
-set file_in		 "$cwd/test$test_id.in"
-set task_prolog          "$cwd/test$test_id.prolog"
-set task_epilog          "$cwd/test$test_id.epilog"
-set file_out_pre         "$cwd/test$test_id.output_pre"
-set file_out_post        "$cwd/test$test_id.output_post"
-
-print_header $test_id
-
-#
-# Delete left-over scripts and rebuild, 
-# The sleep command just forces slurmd to kill the user's (long running) epilog
-#
-file delete $task_prolog $task_epilog
-file delete $file_out_pre $file_out_post
-exec $bin_touch $file_out_pre
-exec $bin_touch $file_out_post
-
-make_bash_script $task_prolog "
-  $bin_id >> $file_out_pre
-  echo export TEST=prolog_qa
-"
-
-make_bash_script $task_epilog "
-  $bin_id >> $file_out_post
-  $bin_sleep 200
-"
-
-make_bash_script $file_in "
-  echo TEST==\$TEST
-  #env
-"
-
-#
-# Submit a slurm job that will execute $tasks tasks
-# Note: If running on more than one node and writing to an 
-#    NFS file, overwritting of data has been observed, this
-#    causes the test to fail
-#
-set job_id  0
-set matches 0
-set timeout $max_job_delay
-if { [test_bluegene] } {
-	set node_cnt 1-1024
-} else {
-	set node_cnt 1
-}
-
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -n$tasks --overcommit --task-prolog=$task_prolog --task-epilog=$task_epilog $file_in]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "TEST==prolog_qa" {
-		incr matches
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: Error running salloc/slaunch\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$exit_code != 0} {
-	exit $exit_code
-}
-if {$matches != $tasks} {
-	send_user "\nFAILURE: prolog exported env var failure ($matches != $tasks)\n"
-	set exit_code 1
-}
-
-#
-# Get my id to compare with output
-#
-set my_uid -1
-spawn $bin_id
-expect {
-	-re "uid=($number)" {
-		set my_uid $expect_out(1,string)
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Make sure we have two records in both prolog and epilog output (one for each task)
-# Wait a few seconds for various delays
-#
-set matches 0
-if {[wait_for_file $file_out_pre] == 0} {
-	set timeout 5
-	spawn $bin_cat $file_out_pre
-	expect {
-		"uid=$my_uid" {
-			incr matches
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-}
-if {$matches != $tasks} {
-	send_user "\nFAILURE: task prolog output is missing or uid mismatch ($matches:$tasks)\n"
-	set exit_code 1
-}
-
-
-set matches 0
-spawn $bin_cat $file_out_post
-expect {
-	"uid=$my_uid" {
-		incr matches
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-if {$matches != $tasks} {
-	send_user "\nFAILURE: task epilog output is missing or uid mismatch ($matches:$tasks)\n"
-	set exit_code 1
-}
-	
-
-if {$exit_code == 0} {
-	file delete $task_prolog $task_epilog $file_in 
-	file delete $file_out_pre $file_out_post
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.23 b/testsuite/expect/test18.23
deleted file mode 100755
index 45eb00430687f811ff6aa9e07acbdb949200fc90..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.23
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of running non-existant job, confirm timely termination.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id              "18.23"
-set exit_code            0
-
-print_header $test_id
-
-if {[test_front_end] != 0 && [test_super_user] == 0} {
-	send_user "\nWARNING: This test is incompatable with front-end systems\n"
-	exit $exit_code
-}
-
-#
-# Submit a slurm job that will execute bogus job name
-#
-set job_id  0
-set matches 0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch /bad/bad/bad]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "No such file" {
-		send_user "\nNo worries, this error is expected\n"
-		set matches 1
-		exp_continue
-	}
-	-re "Unable to run executable" {
-		send_user "\nNo worries, this error is expected\n"
-		set matches 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$matches == 0} {
-	send_user "\nFAILURE: unexpected output from bad job name\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.24 b/testsuite/expect/test18.24
deleted file mode 100755
index f88c728fb7e51687f9a8dd491efeabd7143f1ee6..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.24
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test propagation of umask to spawned tasks.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2005 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id      "18.24"
-set exit_code    0
-set file_in      "test$test_id.input"
-set file_script  "test$test_id.script"
-
-print_header $test_id
-
-if {[test_front_end] != 0} {
-	send_user "\nWARNING: This test is incompatable with front-end systems\n"
-	exit $exit_code
-}
-
-#
-# Build input script files
-#
-make_bash_script $file_in "umask"
-
-make_bash_script $file_script "
-  umask 0123
-  $salloc -N1 -t1 $slaunch ./$file_in
-"
-
-#
-# Set umask and confirm it is propagated
-#
-set job_id  0
-set matches 0
-set salloc_pid [spawn ./$file_script]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re (0123|123) {
-		set matches 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			 cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$matches != 1} {
-	send_user "\nFAILURE: umask not propagated\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_script
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.25 b/testsuite/expect/test18.25
deleted file mode 100755
index f9f7c7998ea36623f6dca6ce4df7fa87ce92af80..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.25
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of slaunch functionality
-#          Test of HOSTFILE environment variable.
-#          
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.25"
-set exit_code   0
-set node_count  0
-set job_id      0
-set hostfile    "test$test_id.hostfile"
-
-print_header $test_id
-
-exec $bin_rm -f $hostfile
-if { [test_front_end] } {
-	send_user "\nWARNING: This test incompatable with front-end systems\n"
-	exit $exit_code
-}
-
-if {[string compare [switch_type] "elan"] == 0} {
-	send_user "\nWARNING: This test incompatable with elan switch\n"
-	exit $exit_code
-}
-
-#find out if we have enough nodes to test functionality
-set node_count [available_nodes [default_partition]]
-if { $node_count < 2 } {
-	send_user "WARNING: system must have at least 2 nodes to run this test.\n" 
-	exit $exit_code
-}
-
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N2 sleep 30]
-set salloc_spawn_id $spawn_id
-expect {
-	-re "Granted job allocation ($number)" {
-		set jobid $expect_out(1,string)
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-}
-
-#
-# First launch 2 tasks on 2 nodes, and find out the default task layout order
-#
-set node0 0
-set node1 0
-spawn $slaunch --jobid $jobid -l $bin_printenv SLURMD_NODENAME
-expect {
-	-re "($number): ($alpha_numeric)" {
-		set task_id $expect_out(1,string)
-		if {$task_id == 0} {
-			set node0 $expect_out(2,string)
-		} else {
-			set node1 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-
-
-#
-# Then create a hostfile laying out the tasks in the opposite order of
-# the default.
-#
-if { $node0 == 0 || $node1 == 0 } {
-	send_user "\nFAILURE: node names not set from previous srun\n"
-	exit 1
-}
-set env(SLURM_HOSTFILE) $hostfile
-set 1node0 $node0
-set 1node1 $node1
-set file [open $hostfile "w"]
-puts $file "$node1"
-puts $file "$node0"
-close $file
-
-#
-# slaunch the tasks using the hostfile
-#
-spawn $slaunch --jobid $jobid -l --task-layout-file $hostfile $bin_printenv SLURMD_NODENAME
-expect {
-	-re "($number): ($alpha_numeric)" {
-		set task_id $expect_out(1,string)
-		if {$task_id == 0} {
-			set node0 $expect_out(2,string)
-		} else {
-			set node1 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Kill salloc (by signalling its process group and killing the sleep 30)
-#
-exec $bin_kill -s SIGINT -$salloc_pid
-set spawn_id $salloc_spawn_id
-expect {
-	eof {
-		wait
-	}
-}
-
-if { [string compare $node0 $1node1] } {
-	send_user "\n FAILURE: tasks not distributed by hostfile\n"
-	set exit_code 1
-} elseif { [string compare $node1 $1node0] } {
-	send_user "\nFAILURE: tasks not distributed by hostfile\n"
-	set exit_code 1
-}
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.26 b/testsuite/expect/test18.26
deleted file mode 100755
index 55497a2cbdc9bb75a307c1b2da767fde86294d9e..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.26
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of running different executables with different arguments
-#          for each task (--multi-prog option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.26"
-set file_in     "test$test_id.input"
-set exit_code   0
-
-print_header $test_id
-
-if {[test_front_end] != 0} {
-        send_user "\nThis test is incompatable with front-end systems\n"
-}
-
-#
-# Delete left-over input script
-# Build input script file
-#
-exec $bin_rm -f $file_in
-set file [open $file_in "w"]
-puts $file "# multi-program configuration file
-1-2   /bin/echo task:%t:offset:%o
-0,3   echo task:%t:offset:%o
-"
-close $file
-exec $bin_chmod 700 $file_in
-
-#
-# Submit a slurm job that will execute different programs and arguments by task number
-#
-set job_id  0
-set matches 0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch -n4 --overcommit -l --multi-prog $file_in]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "($number): task:($number):offset:($number)" {
-		set label       $expect_out(1,string)
-		set task_id     $expect_out(2,string)
-		set task_offset $expect_out(3,string)
-		if {$label == 0 && $task_id == 0 && $task_offset == 0} {
-			incr matches
-		}
-		if {$label == 1 && $task_id == 1 && $task_offset == 0} {
-			incr matches
-		}
-		if {$label == 2 && $task_id == 2 && $task_offset == 1} {
-			incr matches
-		}
-		if {$label == 3 && $task_id == 3 && $task_offset == 1} {
-			incr matches
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$matches != 4} {
-	send_user "\nFAILURE: Did not get expected multi-program output\n"
-	set exit_code 1
-}
-if {$exit_code != 0} {
-	exit $exit_code
-}
-
-#
-# Submit a slurm job that will execute different executables and check debug info
-#
-# Timeout is max_job_delay (to spawn task) + 
-#       60 (job time limit) +
-#       60 (slurmctld time limit check poll interval) +
-#       KillWait
-#
-set timeout [expr $max_job_delay + 60 + 60 + 60]
-
-file delete $file_in
-set file [open $file_in "w"]
-puts $file "# multi-program configuration file
-1-2   /bin/hostname
-0,3   /bin/date
-"
-close $file
-exec $bin_chmod 700 $file_in
-
-set job_id    0
-set matches   0
-set timed_out 0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch -n4 --overcommit -l --multi-prog --debugger-test $file_in]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "executable:(/bin/)($alpha)" {
-		if {[string compare $expect_out(2,string) "date"] == 0} {
-			incr matches
-		}
-		if {[string compare $expect_out(2,string) "hostname"] == 0} {
-			incr matches
-		}
-		if { $matches == 4} {
-			# set the debugged processes running again
-			exec $scancel -s CONT $job_id.0
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$timed_out == 1} {
-	send_user "\nEarly termination is expected, no worries.\n"
-}
-if {$matches != 4} {
-	send_user "\nFAILURE: did not generate full list of executables.\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	file delete $file_in
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.27 b/testsuite/expect/test18.27
deleted file mode 100755
index a0542642a069bcb140f635f198d1f66323d68b3b..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.27
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Confirm that a job executes with the proper task distribution
-#          (--nodes and --distribution options).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.27"
-set exit_code   0
-
-print_header $test_id
-
-if {[test_front_end] != 0} {
-	send_user "\nWARNING: Additional testing is incompatable with front-end systems\n"
-	exit $exit_code
-}
-
-#
-# Submit a two node job with block distribution
-#
-set job_id      0
-set timeout $max_job_delay
-set expected_layout [list 0 0 1 1]
-set tested_layout [list -1 -1 -1 -1] 
-set salloc_pid [spawn $salloc -N2 -t1 $slaunch -n4 --overcommit -l --distribution=block $bin_printenv SLURM_NODEID]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "More ($alpha) requested than permitted" {
-		send_user "\nWARNING: can't test slaunch task distribution\n"
-		exit 0
-	}
-	-re "($number): ($number)" {
-		set index $expect_out(1,string)
-		set value $expect_out(2,string)
-		lset tested_layout $index $value
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify block distribution of tasks
-#
-send_user "Expected layout was: $expected_layout\n"
-send_user "Tested layout was  : $tested_layout\n"
-if {[string compare $expected_layout $tested_layout] != 0} {
-	send_user "\FAILURE: failed to distribute tasks in block fashion\n"
-	set exit_code 1
-}
-
-#
-# Submit a two node job with cyclic distribution
-#
-set job_id      0
-set timeout $max_job_delay
-set expected_layout [list 0 1 0 1]
-set tested_layout [list -1 -1 -1 -1] 
-set salloc_pid [spawn $salloc -N2 -t1 $slaunch -n4 --overcommit -l --distribution=cyclic $bin_printenv SLURM_NODEID]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "More ($alpha) requested than permitted" {
-		send_user "\nWARNING: can't test slaunch task distribution\n"
-		exit 0
-	}
-	-re "($number): ($number)" {
-		set index $expect_out(1,string)
-		set value $expect_out(2,string)
-		lset tested_layout $index $value
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify cyclic distribution of tasks
-#
-send_user "Expected layout was: $expected_layout\n"
-send_user "Tested layout was  : $tested_layout\n"
-if {[string compare $expected_layout $tested_layout] != 0} {
-	send_user "\FAILURE: failed to distribute tasks in cyclic fashion\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.28 b/testsuite/expect/test18.28
deleted file mode 100755
index d7e0a955828e136555118cf5f7273ff104d399aa..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.28
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Confirm that a job executes with the proper node count
-#          (--nodes option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.28"
-set exit_code   0
-
-print_header $test_id
-
-if { [test_xcpu] } {
-	send_user "\nWARNING: This test is incompatable with XCPU systems\n"
-	exit 0
-}
-
-#
-# Submit jobs of various node counts and validate task count
-#
-for {set inx 1} {$inx <= 4} {set inx [expr $inx * 2]} {
-	set job_id      0
-	set host_0      ""
-	set host_1      ""
-	set host_2      ""
-	set host_3      ""
-	set no_fit      0
-	set task_cnt    0
-	set timeout $max_job_delay
-	set salloc_pid [spawn $salloc -N1-4 -t1 $slaunch -N$inx -l $bin_printenv SLURM_NODEID]
-	expect {
-		-re "Granted job allocation ($number)" {
-			set job_id $expect_out(1,string)
-			exp_continue
-		}
-		-re " Requested node configuration is not available" {
-			set no_fit 1
-			exp_continue
-		}
-		-re "($number): ($number)" {
-			incr task_cnt
-			if {$expect_out(1,string) == 0} {
-				set host_0 $expect_out(2,string)
-			}
-			if {$expect_out(1,string) == 1} {
-				set host_1 $expect_out(2,string)
-			}
-			if {$expect_out(1,string) == 2} {
-				set host_2 $expect_out(2,string)
-			}
-			if {$expect_out(1,string) == 3} {
-				set host_3 $expect_out(2,string)
-			}
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: salloc not responding\n"
-			if {$job_id != 0} {
-				cancel_job $job_id
-			}
-			slow_kill [expr 0 - $salloc_pid]
-			exit 1
-		}
-		eof {
-			wait
-		}
-	}
-	if { $no_fit == 0 && $task_cnt != $inx } {
-		send_user "\nFAILURE: slaunch failed to launch specified tasks count\n"
-		set exit_code   1
-	}
-	if {$no_fit == 0 && $task_cnt == 2} {
-		if {[string compare $host_0 $host_1] == 0} {
-			send_user "\nFAILURE: Re-used a node in the allocation\n"
-			set exit_code   1
-		}
-	}
-	if {$no_fit == 0 && $task_cnt == 4} {
-		set dup_host 0
-		if {[string compare $host_0 $host_1] == 0} {
-			 set dup_host 1
-		}
-		if {[string compare $host_0 $host_2] == 0} {
-			set dup_host 1
-		}
-		if {[string compare $host_0 $host_3] == 0} {
-			set dup_host 1
-		}
-		if {[string compare $host_1 $host_2] == 0} {
-			set dup_host 1
-		}
-		if {[string compare $host_1 $host_3] == 0} {
-			set dup_host 1
-		}
-		if {[string compare $host_2 $host_3] == 0} {
-			set dup_host 1
-		}
-		if {$dup_host == 1} {
-			send_user "\nFAILURE: Re-used a node in the allocation\n"
-			set exit_code   1
-		}
-	}
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.29 b/testsuite/expect/test18.29
deleted file mode 100755
index 94a105c1cb9286f6d8a20bc071e91e30e6dd983c..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.29
+++ /dev/null
@@ -1,207 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of slaunch --cpus-per-task option.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.29"
-set exit_code   0
-set file_in     "test$test_id.input"
-
-print_header $test_id
-
-if { [test_front_end] } {
-	send_user "\nWARNING: This test is incompatable with FRONT_END systems\n"
-	exit 0
-}
-if {[test_multiple_slurmd] != 0} {
-	send_user "\nWARNING: This test is incompatable with multiple slurmd systems\n"
-	exit 0
-}
-
-set cpu_cnt        0
-set job_id         0
-set timeout        $max_job_delay
-set node_cnt       2
-
-set available [available_nodes [default_partition]]
-if {$available < 2} {
-        send_user "\nWARNING: not enough nodes currently available"
-        send_user " ($available avail, 2)\n"
-        exit $exit_code
-}
-
-make_bash_script $file_in "
-   env | grep SLURM_JOB_CPUS_PER_NODE
-   $bin_hostname"
-
-
-# Script will print SLURM_JOB_CPUS_PER_NODE, then hold the allocation
-# for a long time.
-set script_name test18.28.sh
-make_bash_script $script_name {
-    printenv SLURM_JOB_CPUS_PER_NODE
-    sleep 600
-}
-set salloc_pid [spawn $salloc -N $node_cnt $slaunch -n 1 $script_name]
-set salloc_spawn_id $spawn_id
-expect {
-	-re "Granted job allocation ($number)" {
-		set jobid $expect_out(1,string)
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-}
-expect {
-	-re "($number)" {
-		set cpu_cnt $expect_out(1,string)
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		cancel_job $job_id
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-}
-file delete $script_name
-
-send_user "cpu count is $cpu_cnt\n"
-
-# Check CPU count
-if {$cpu_cnt < 2} {
-	send_user "\nWARNING: The node only has one CPU\n"
-	cancel_job $jobid
-	exec $bin_rm -f $file_in
-	exit $exit_code
-}
-
-#
-# Now start the real testing of --cpus-per-task.
-#
-
-#
-# Test A
-# Should run: --cpus-per-task=1, -n=(node_count*cpu count)
-#
-set task_cnt 0
-set pid [spawn $slaunch --jobid $jobid -l --cpus-per-task 1 -n [expr $node_cnt * $cpu_cnt] $bin_printenv SLURMD_NODENAME]
-expect {
-	-re "($number): ($alpha_numeric)" {
-		incr task_cnt
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-set expected_task_cnt [expr $node_cnt * $cpu_cnt]
-if {$task_cnt < $expected_task_cnt} {
-	send_user "\nFAILURE Test A: Fewer tasks ($task_cnt) then expected ($expected_task_cnt)\n"
-	set exit_code 1
-}
-if {$task_cnt > $expected_task_cnt} {
-	send_user "\nFAILURE Test A: More tasks ($task_cnt) then "
-	send_user "expected ($expected_task_cnt)\n"
-	set exit_code 1
-}
-
-#
-# Test B
-# Should NOT run: --cpus-per-task=2, -n=(2*cpu count)
-#
-set task_cnt 0
-set pid [spawn $slaunch --jobid $jobid -l --cpus-per-task $cpu_cnt -n [expr $node_cnt * $cpu_cnt] $bin_printenv SLURMD_NODENAME]
-expect {
-	-re "($number): ($alpha_numeric)" {
-		incr task_cnt
-		exp_continue
-	}
-	"error: Failed creating job step context" {
-		send_user "This error was expected!\n"
-	}
-	eof {
-		wait
-	}
-}
-if {$task_cnt > 0} {
-	send_user "FAILURE Test B: Test should NOT have run.\n"
-	set exit_code 1
-}
-
-
-#
-# Test C
-# Should run: --cpus-per-task=2, -n=(cpu count)
-#
-set task_cnt 0
-set pid [spawn $slaunch --jobid $jobid -l --cpus-per-task $cpu_cnt -n $node_cnt $bin_printenv SLURMD_NODENAME]
-expect {
-	-re "($number): ($alpha_numeric)" {
-		incr task_cnt
-		exp_continue
-	}
-    	eof {
-		wait
-	}
-}
-set expected_task_cnt $node_cnt
-if {$task_cnt < $expected_task_cnt} {
-	send_user "\nFAILURE Test C: Fewer tasks ($task_cnt) then expected ($expected_task_cnt)\n"
-	set exit_code 1
-}
-if {$task_cnt > $expected_task_cnt} {
-	send_user "\nFAILURE Test C: More tasks ($task_cnt) then expected ($expected_task_cnt)\n"
-	set exit_code 1
-}
-
-#
-# Clean up the job allocation.
-#
-cancel_job $jobid
-set spawn_id $salloc_spawn_id
-expect {
-	eof {
-		wait
-	}
-}
-
-
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_in
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.30 b/testsuite/expect/test18.30
deleted file mode 100755
index bdaea5b4d543b3e026b6b4846184e2a2f6eb1936..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.30
+++ /dev/null
@@ -1,204 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Confirm that a job executes with the proper node count
-#          (--nodes option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.30"
-set exit_code   0
-
-print_header $test_id
-
-if { [test_xcpu] } {
-	send_user "\nWARNING: This test is incompatable with XCPU systems\n"
-	exit 0
-}
-
-#
-# Submit a 3+ node job
-#
-set host_0      ""
-set host_1      ""
-set host_2      ""
-set host_3      ""
-set job_id      0
-set timeout $max_job_delay
-
-if { [test_bluegene] } {
-        set node_cnt 1536
-} else {
-        set node_cnt 3
-}
-set available [available_nodes [default_partition]]
-if {$available < $node_cnt} {
-	send_user "\nWARNING: not enough nodes currently available"
-	send_user " ($available avail, $node_cnt needed)\n"
-	exit $exit_code
-}
-
-#
-# Allocate a 3+ node job, launch 1 node task
-#
-set job_id      0
-set host_0      ""
-set host_1      ""
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -l -N1 $bin_printenv SLURM_NODEID]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "More ($alpha) requested than permitted" {
-		send_user "\nWARNING: can't test salloc task distribution\n"
-		exit $exit_code
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get SLURM_NODEID of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] != 0} {
-	send_user "\nFAILURE: Started more than one task\n"
-	set exit_code   1	
-}
-
-#
-# Allocate a 3+ node job, launch 3 node task
-#
-set job_id      0
-set host_0      ""
-set host_1      ""
-set host_2      ""
-set host_3      ""
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -l -N3 $bin_printenv SLURM_NODEID]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "More ($alpha) requested than permitted" {
-		send_user "\nWARNING: can't test salloc task distribution\n"
-		exit $exit_code
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 2} {
-			set host_2 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 3} {
-			set host_3 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get SLURM_NODEID of task 0\n"
-	set exit_code   1
-}
-if {[string compare $host_1 ""] == 0} {
-	send_user "\nFAILURE: Did not get SLURM_NODEID of task 1\n"
-	set exit_code   1
-}
-if {[string compare $host_2 ""] == 0} {
-	send_user "\nFAILURE: Did not get SLURM_NODEID of task 2\n"
-	set exit_code   1
-}
-if {[string compare $host_3 ""] != 0} {
-	send_user "\nFAILURE: Started more than three task\n"
-	set exit_code   1
-}
-
-set dup_host 0
-if {[string compare $host_0 $host_1] == 0} {
-	set dup_host 1	
-}
-if {[string compare $host_0 $host_2] == 0} {
-	set dup_host 1	
-}
-if {[string compare $host_0 $host_3] == 0} {
-	set dup_host 1	
-}
-if {$dup_host == 1} {
-	send_user "\nFAILURE: Re-used a node in the allocation\n"
-	set exit_code   1	
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.31 b/testsuite/expect/test18.31
deleted file mode 100755
index c7088231b7ae3cf6b1592c743f19dbe42bf784e6..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.31
+++ /dev/null
@@ -1,333 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Confirm that a job executes with the specified nodes
-#          (--relative, --nodelist-byname and --nodelist-byid).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.31"
-set exit_code   0
-
-print_header $test_id
-
-if { [test_xcpu] } {
-	send_user "\nWARNING: This test is incompatable with XCPU systems\n"
-	exit 0
-}
-
-if { [test_bluegene] } {
-	send_user "\nWARNING: test incompatable with Blue Gene systems\n"
-	exit $exit_code
-} else {
-	set node_cnt 3
-}
-
-set available [available_nodes [default_partition]]
-if {$available < $node_cnt} {
-	send_user "\nWARNING: not enough nodes currently available"
-	send_user " ($available avail, $node_cnt needed)\n"
-	exit $exit_code
-}
-
-#
-# Submit a 3 node job
-#
-set host_0      ""
-set host_1      ""
-set host_2      ""
-set host_3      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -l $bin_printenv SLURMD_NODENAME]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		send "$bin_echo MY_ID=\$SLURM_JOBID \n"
-		exp_continue
-	}
-	-re "More ($alpha) requested than permitted" {
-		send_user "\nWARNING: can't test salloc task distribution\n"
-		exit $exit_code
-	}
-	-re "configuration not available" {
-		send_user "WARNING: partition too small for test\n"
-		exit 0
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 2} {
-			set host_2 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 3} {
-			set host_3 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 1\n"
-	set exit_code   1	
-}
-if {[string compare $host_2 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 2\n"
-	set exit_code   1	
-}
-if {[string compare $host_3 ""] != 0} {
-	send_user "\nFAILURE: Started more than three tasks\n"
-	set exit_code   1	
-}
-
-set dup_hostname 0
-if {[string compare $host_0 $host_1] == 0} {
-	incr dup_hostname 	
-}
-if {[string compare $host_0 $host_2] == 0} {
-	incr dup_hostname 1	
-}
-if {$dup_hostname == 1} {
-	send_user "\nFAILURE: Re-used a node in the allocation\n"
-	set exit_code   1	
-}
-set all_nodes $host_0,$host_1,$host_2
-set exclude_node $host_0
-set include_node $host_2
-
-#
-# Submit a job explicitly skip node 0
-#
-set host_0      ""
-set host_1      ""
-set host_2      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt -t1 --nodelist=$all_nodes $slaunch -N2 --relative=1 -l $bin_printenv SLURMD_NODENAME]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "Invalid node name specified" {
-		send_user "\nWARNING: Appears you are using "
-		send_user "multiple slurmd testing.\n"
-		send_user "This test won't work in that fashion.\n"
-		exit 0	
-	}
-		
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 2} {
-			set host_2 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count and names
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 1\n"
-	set exit_code   1	
-}
-if {[string compare $host_2 ""] != 0} {
-	send_user "\nFAILURE: Started more than two tasks\n"
-	set exit_code   1	
-}
-set dup_hostname 0
-if {[string compare $host_0 $exclude_node] == 0} {
-	set dup_hostname 1	
-}
-if {[string compare $host_1 $exclude_node] == 0} {
-	set dup_hostname 1	
-}
-if {$dup_hostname == 1} {
-	send_user "\nFAILURE: Allocated an excluded node\n"
-	set exit_code   1	
-}
-
-#
-# Submit a job explicitly including a node by name
-#
-set host_0      ""
-set host_1      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt --nodelist=$all_nodes -t1  $slaunch -N1 --nodelist-byname=$include_node -l $bin_printenv SLURMD_NODENAME]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count and names
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] != 0} {
-	send_user "\nFAILURE: Started more than one task\n"
-	set exit_code   1	
-}
-set dup_hostname 0
-if {[string compare $host_0 $include_node] == 0} {
-	set dup_hostname 1	
-}
-if {$dup_hostname == 0} {
-	send_user "\nFAILURE: Allocation lacked an included node\n"
-	set exit_code   1	
-}
-
-#
-# Submit a job explicitly including a node by id
-#
-set host_0      ""
-set host_1      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt --nodelist=$all_nodes -t1  $slaunch -N1 --nodelist-byid=2 -l $bin_printenv SLURMD_NODENAME]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count and names
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] != 0} {
-	send_user "\nFAILURE: Started more than one task\n"
-	set exit_code   1	
-}
-set dup_hostname 0
-if {[string compare $host_0 $include_node] == 0} {
-	set dup_hostname 1	
-}
-if {$dup_hostname == 0} {
-	send_user "\nFAILURE: Allocation lacked an included node\n"
-	set exit_code   1	
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.32 b/testsuite/expect/test18.32
deleted file mode 100755
index 19fb1c1abc49548761c058208dca5a5517f614bd..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.32
+++ /dev/null
@@ -1,218 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Basic test of MPI functionality via slaunch
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id            "18.32"
-set exit_code          0
-set file_in            "test$test_id.input"
-set file_out           "test$test_id.output"
-set file_err           "test$test_id.error"
-set test_prog          "test$test_id.prog"
-set job_id             0
-
-print_header $test_id
-
-#
-# Test for existence of mpi compiler
-#
-if {[info exists mpicc] == 0} {
-	send_user "\nWARNING: mpicc not defined, can't perform mpi testing\n"
-	exit 0
-}
-if {[file executable $mpicc] == 0} {
-	send_user "\nWARNING: $mpicc does not exists\n"
-	exit 0
-}
-if {[test_front_end] != 0} {
-        send_user "\nWARNING: This test is incompatable with front-end systems\n"
-        exit 0
-}
-
-#
-# Delete left-over program and rebuild it
-#
-exec $bin_rm -f $test_prog ${test_prog}.o
-if {$use_pmi} {
-	set pmi_link "-rpath $slurm_dir/lib -L $slurm_dir/lib -lpmi"
-	exec $mpicc -Xlinker $pmi_link -o $test_prog ${test_prog}.c
-} else {
-	exec $mpicc -o $test_prog ${test_prog}.c
-}
-	
-
-# Delete left-over stdout/err files
-file delete $file_out $file_err
-
-#
-# Build input script file
-#
-make_bash_script $file_in "
-  $bin_date
-  $bin_echo test1_N3_n6_cyclic
-  $slaunch -n6 --distribution=cyclic $test_prog
-
-  $bin_date
-  $bin_echo test2_n6_block
-  $slaunch -n6 --distribution=block  $test_prog
-
-  $bin_date
-  $bin_echo test3_n4_cyclic
-  $slaunch -n4 --distribution=cyclic $test_prog
-
-  $bin_date
-  $bin_echo test4_n4_block
-  $slaunch -n4 --distribution=block  $test_prog
-
-  $bin_date
-  $bin_echo test5_N2_n4_with_hole
-  $slaunch -N2 -n4 --distribution=cyclic --nodelist-byid=0,2  $test_prog
-
-  $bin_date
-  $bin_echo TEST_COMPLETE
-"
-
-#
-# Spawn a srun batch job that uses stdout/err and confirm their contents
-#
-set timeout $max_job_delay
-set no_start 0
-set srun_pid [spawn $srun -N3 -n6 --batch --output=$file_out --error=$file_err -t1 $file_in]
-expect {
-	-re "jobid ($number) submitted" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "configuration not available" {
-		set no_start 1
-		exp_continue
-	}
-	-re "Unable to submit batch job" {
-		set no_start 1
-		exp_continue
-	}
-	-re "Unable to contact" {
-		send_user "\nFAILURE: slurm appears to be down\n"
-		exit 1
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$no_start != 0} {
-	send_user "\nWARNING: partition too small for test\n"
-	if {$job_id != 0} {
-		cancel_job $job_id
-	}
-	exit 0
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: batch submit failure\n"
-	exit 1
-}
-
-#
-# Wait for job to complete
-#
-if {[wait_for_job $job_id "DONE"] != 0} {
-	send_user "\nFAILURE: waiting for job to complete\n"
-	set exit_code 1
-}
-
-#
-# Check for desired output in stdout
-#
-set expected [expr 6 + 6 + 4 + 4 + 4]
-if {[wait_for_file $file_out] == 0} {
-	set matches  0
-	set complete 0
-	spawn $bin_cat $file_out
-	expect {
-                -re "I just received msg from Rank" {
-			incr matches
-                        exp_continue
-                }
-		-re "TEST_COMPLETE" {
-			incr complete
-			exp_continue
-		}
-                eof {
-			wait
-                }
-        }
-	if {$matches == 0} {
-		send_user "\nFAILURE: No MPI communications occured\n"
-		send_user "  The version of MPI you are using may be incompatible "
-		send_user "with the configured switch\n"
-		send_user "  Core files may be present from failed MPI tasks\n\n"
-		set exit_code 1
-	} elseif {$matches != $expected} {
-		send_user "\nFAILURE: unexpected output ($matches of $expected)\n"
-		set exit_code 1
-	} elseif {$complete == 0} {
-		send_user "\nFAILURE: test failed to complete\n"
-		set exit_code 1
-	}
-} else {
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_out $file_err $test_prog ${test_prog}.o
-	send_user "\nSUCCESS\n"
-} else {
-	set matches
-	spawn head $file_err
-	expect {
-		-re "Error creating CQ" {
-			incr matches
-			exp_continue
-		}
-		eof {
-			wait
-		}
-	}
-	if {$matches != 0} {
-		send_user "WARNING: If using MVAPICH then\n"
-		send_user "         Configure \"PropagateResourceLimitsExcept=MEMLOCK\"\n"
-		send_user "         Also start slurmd with \"ulimit -l unlimited\"\n"
-	} else {
-		send_user "Check contents of $file_err\n"
-	}
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.32.prog.c b/testsuite/expect/test18.32.prog.c
deleted file mode 100644
index 52e37db06c767e8bc40a17a5d6dda12b9e83867a..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.32.prog.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************************\
- *  test18.32.prog.c - Simple ping test of operation with SLURM.
- *****************************************************************************
- *  Copyright (C) 2004 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Dong Ang <dahn@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#include <stdio.h>
-#include <mpi.h>
-
-#define COMM_TAG 1000
-
-static void pass_its_neighbor(const int rank, const int size, const int* buf)
-{
-	MPI_Request request[2];
-	MPI_Status status[2];
-
-	MPI_Irecv((void *)buf, 1, MPI_INT, ((rank+size-1)%size), COMM_TAG,
-		MPI_COMM_WORLD, &request[0]);
-	MPI_Isend((void *)&rank, 1, MPI_INT, ((rank+1)%size), COMM_TAG,
-		MPI_COMM_WORLD, &request[1]);
-	MPI_Waitall(2, request, status);
-
-	fprintf(stdout, "Rank[%d] I just received msg from Rank %d\n", 
-		rank, *buf);
-}
-
-int main(int argc, char * argv[])
-{
-	int size, rank,buf;
-
-	MPI_Init(&argc, &argv);
-	MPI_Comm_size(MPI_COMM_WORLD, &size);
-	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-
-	buf = rank;	/* we only pass rank */
-
-	pass_its_neighbor(rank, size, &buf);
-
-	MPI_Finalize();
-	return 0;
-}
-
diff --git a/testsuite/expect/test18.33 b/testsuite/expect/test18.33
deleted file mode 100755
index d4b44d8cb5d0fc2b27b56dca3e913deae9255d44..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.33
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Verify environment variables controlling slaunch are processed:
-#          SLAUNCH_DEBUG, SLAUNCH_DISTRIBUTION, SLAUNCH_LABELIO and 
-#          SLAUNCH_OVERCOMMIT
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id          "18.33"
-set exit_code        0
-set job_id           0
-set timeout          $max_job_delay
-
-print_header $test_id
-
-#
-# Set target environment variables
-#
-global env
-set env(SLAUNCH_DEBUG)        2
-set env(SLAUNCH_DISTRIBUTION) block
-set env(SLAUNCH_LABELIO)      1
-set env(SLAUNCH_OVERCOMMIT)   1
-#
-# Spawn a job via slaunch using these environment variables
-#
-set matches 0
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch $bin_hostname]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "distribution *: block" {
-		incr matches
-		exp_continue
-	}
-	-re "verbose *: 2" {
-		incr matches
-		exp_continue
-	}
-	-re "label output *: true" {
-		incr matches
-		exp_continue
-	}
-	-re "overcommit *: true" {
-		incr matches
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$job_id == 0} {
-	send_user "\nFAILURE: did not get job_id\n" 
-	exit 1
-}
-if {$matches != 4} {
-	send_user "\nFAILURE: processed $matches of 4 environment variables\n"
-	set exit_code 1
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.34 b/testsuite/expect/test18.34
deleted file mode 100755
index 5bead7daaa0255b20f2991030972b5bdc3792160..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.34
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#           Test slaunch's ability to set the job step's name (--name option)
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-#
-# NOTE:    Due to symbolic links, we only look to match the last component
-#          of the directory name (e.g "cd /tmp; pwd" might return "/var/tmp").
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.34"
-set exit_code   0
-set job_id      0
-set matches     0
-set step_name   "aaa.$test_id"
-
-print_header $test_id
-
-#
-# Change working directory on execute line and then print where jobs runs
-#
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --name=$step_name $scontrol show step]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "Name=$step_name" {
-		incr matches
-		exp_continue
-	}
-	-re "Unable to contact" {
-		send_user "\nFAILURE: slurm appears to be down\n"
-		exit 1
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$matches != 1} {
-	send_user "\nFAILURE: slaunch failed to set name\n"
-	set exit_code 1
-}
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.35 b/testsuite/expect/test18.35
deleted file mode 100755
index 5eb9a5e843dc04b0b843b53b9c63f9861cf70502..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.35
+++ /dev/null
@@ -1,352 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of task layout controls (--task-layout-byid,
-#          --task-layout-byname and --task-layout-file options).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.35"
-set hostfile    "test$test_id.hostfile"
-set exit_code   0
-
-print_header $test_id
-
-if { [test_xcpu] } {
-	send_user "\nWARNING: This test is incompatable with XCPU systems\n"
-	exit 0
-}
-
-if { [test_bluegene] } {
-	send_user "\nWARNING: test incompatable with Blue Gene systems\n"
-	exit $exit_code
-} else {
-	set node_cnt 3
-}
-
-set available [available_nodes [default_partition]]
-if {$available < $node_cnt} {
-	send_user "\nWARNING: not enough nodes currently available"
-	send_user " ($available avail, $node_cnt needed)\n"
-	exit $exit_code
-}
-
-#
-# Submit a 3 node job
-#
-set host_0      ""
-set host_1      ""
-set host_2      ""
-set host_3      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -l $bin_printenv SLURMD_NODENAME]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		send "$bin_echo MY_ID=\$SLURM_JOBID \n"
-		exp_continue
-	}
-	-re "More ($alpha) requested than permitted" {
-		send_user "\nWARNING: can't test salloc task distribution\n"
-		exit $exit_code
-	}
-	-re "configuration not available" {
-		exec $bin_rm -f $hostfile
-		send_user "WARNING: partition too small for test\n"
-		exit 0
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 2} {
-			set host_2 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 3} {
-			set host_3 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 1\n"
-	set exit_code   1	
-}
-if {[string compare $host_2 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 2\n"
-	set exit_code   1	
-}
-if {[string compare $host_3 ""] != 0} {
-	send_user "\nFAILURE: Started more than three tasks\n"
-	set exit_code   1	
-}
-
-set dup_hostname 0
-if {[string compare $host_0 $host_1] == 0} {
-	incr dup_hostname 	
-}
-if {[string compare $host_0 $host_2] == 0} {
-	incr dup_hostname 1	
-}
-if {$dup_hostname == 1} {
-	send_user "\nFAILURE: Re-used a node in the allocation\n"
-	set exit_code   1	
-}
-set all_nodes $host_0,$host_1,$host_2
-set exclude_node $host_0
-set include_node $host_2
-
-#
-# Submit a job explicitly skip node 0 via --task-layout-byid
-#
-set invalid     0
-set host_0      ""
-set host_1      ""
-set host_2      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt -t1 --nodelist=$all_nodes $slaunch -n2 --task-layout-byid=1,2 -l $bin_hostname]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "Invalid node name specified" {
-		send_user "\nWARNING: Appears you are using "
-		send_user "multiple slurmd testing.\n"
-		send_user "This test won't work in that fashion.\n"
-		set invalid 1
-		exp_continue
-	}
-	-re "SwitchType does not permit" {
-		send_user "\nNo worries, just stop the test now\n"
-		set invalid 1
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 2} {
-			set host_2 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-	eof {
-		wait
-	}
-}
-if {$invalid != 0} {
-	if {$exit_code == 0} {
-		exec $bin_rm -f $hostfile
-		send_user "\nSUCCESS\n"
-	}
-	exit $exit_code
-}
-
-#
-# Verify node count and names
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 1\n"
-	set exit_code   1	
-}
-if {[string compare $host_2 ""] != 0} {
-	send_user "\nFAILURE: Started more than two tasks\n"
-	set exit_code   1	
-}
-set dup_hostname 0
-if {[string compare $host_0 $exclude_node] == 0} {
-	set dup_hostname 1	
-}
-if {[string compare $host_1 $exclude_node] == 0} {
-	set dup_hostname 1	
-}
-if {$dup_hostname == 1} {
-	send_user "\nFAILURE: Allocated an excluded node\n"
-	set exit_code   1	
-}
-
-#
-# Submit a job step using --task-layout-byname
-#
-set host_0      ""
-set host_1      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt --nodelist=$all_nodes -t1  $slaunch -n1 --task-layout-byname=$include_node -l $bin_printenv SLURMD_NODENAME]  
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count and names
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] != 0} {
-	send_user "\nFAILURE: Started more than one task\n"
-	set exit_code   1	
-}
-set dup_hostname 0
-if {[string compare $host_0 $include_node] == 0} {
-	set dup_hostname 1	
-}
-if {$dup_hostname == 0} {
-	send_user "\nFAILURE: Allocation lacked an included node\n"
-	set exit_code   1	
-}
-
-#
-# Submit a job explicitly including a node by id
-#
-set file [open $hostfile "w"]
-puts $file "$include_node"
-close $file
-
-set host_0      ""
-set host_1      ""
-set job_id      0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N$node_cnt --nodelist=$all_nodes -t1  $slaunch -n1 --task-layout-file=$hostfile -l $bin_printenv SLURMD_NODENAME]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "($number): ($alpha_numeric)" {
-		if {$expect_out(1,string) == 0} {
-			set host_0 $expect_out(2,string)
-		}
-		if {$expect_out(1,string) == 1} {
-			set host_1 $expect_out(2,string)
-		}
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Verify node count and names
-#
-if {[string compare $host_0 ""] == 0} {
-	send_user "\nFAILURE: Did not get hostname of task 0\n"
-	set exit_code   1	
-}
-if {[string compare $host_1 ""] != 0} {
-	send_user "\nFAILURE: Started more than one task\n"
-	set exit_code   1	
-}
-set dup_hostname 0
-if {[string compare $host_0 $include_node] == 0} {
-	set dup_hostname 1	
-}
-if {$dup_hostname == 0} {
-	send_user "\nFAILURE: Allocation lacked an included node\n"
-	set exit_code   1	
-}
-
-if {$exit_code == 0} {
-	exec $bin_rm -f $hostfile
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.36 b/testsuite/expect/test18.36
deleted file mode 100755
index 8f7a6be43239a97b704e8329cbd0b74929e24b72..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.36
+++ /dev/null
@@ -1,499 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of CPU affinity support.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2005-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.36"
-set exit_code   0
-set job_id      0
-set file_prog   "test$test_id.prog"
-
-print_header $test_id
-
-#
-# Test if task affinity support is supported.
-#
-set affinity 0
-log_user 0
-spawn $scontrol show config
-expect {
-	-re "task/affinity" {
-		set affinity 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-log_user 1
-if {$affinity == 0} {
-	send_user "\nWARNING: task affinity not supported on this system\n"
-	exit 0
-}
-send_user "\ntask affinity plugin installed\n"
-
-#
-# Build a test program to report affinity by task
-#
-exec $bin_rm -f $file_prog
-exec $bin_make -f /dev/null $file_prog
-exec $bin_chmod 700 $file_prog
-
-#
-# Create an allocation
-#
-set salloc_pid [spawn $salloc -N1 --verbose -t2 $bin_bash]
-expect {
-	-re "Granted job allocation ($number)" {
-		set jobid $expect_out(1,string)
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-}
-
-send "env |grep SLURM_JOB_CPUS_PER_NODE\n"
-expect {
-    -re "SLURM_JOB_CPUS_PER_NODE=($number)" {
-	set available_cpus $expect_out(1,string)
-    }
-}
-
-#
-# Run a job step to get allocated processor count and affinity
-#
-expect -re $prompt
-set mask 0
-set task_cnt 0
-send "$slaunch -n $available_cpus $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_cnt
-		set mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-
-#
-# Run a job step with affinity
-#
-set expected_mask [ expr ((1 << $task_cnt) - 1) ]
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=rank $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-if {$task_mask != $expected_mask} {
-	send_user "\nFAILURE: affinity mask inconsistency ($task_mask,$mask)\n"
-	set exit_code 1
-}
-
-#
-# Run a job step with verbosity and all tasks on CPU 0
-#
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=verbose,map_cpu:0 $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-if {$task_mask != $task_cnt} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$task_cnt)\n"
-	set exit_code 1
-}
-set verbose_cnt 0
-send "$slaunch -n $available_cpus --cpu_bind=verbose,map_cpu:0 $file_prog\n"
-expect {
-	-re "cpu_bind=MAP" {
-		incr verbose_cnt
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-if {$verbose_cnt != $task_cnt} {
-	send_user "\nFAILURE: verbose messages count inconsisent ($verbose_cnt,$task_cnt)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks all bound to the same CPU by specifying a map (for each CPU)
-#
-set cpu_cnt 0
-while {$cpu_cnt < $task_cnt} {
-	set mask_sum 0
-	set mask [ expr 1 << $cpu_cnt ]
-	send "$slaunch -n $available_cpus --cpu_bind=map_cpu:$cpu_cnt $file_prog\n"
-	expect {
-		-re "TASK_ID:($number),MASK:($number)" {
-			incr mask_sum $expect_out(2,string)
-			exp_continue
-		}
-		-re "error" {
-			send_user "\nFAILURE: some error occurred\n"
-			set exit_code 1
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-			set exit_code 1
-			exp_continue
-		}
-		-re $prompt
-	}
-	if {$mask_sum != $task_cnt * $mask} {
-		send_user "\nFAILURE: affinity mask inconsistent ($mask_sum,$task_cnt)\n"
-		set exit_code 1
-	}
-	incr cpu_cnt 1
-}
-
-#
-# Run all tasks all bound to the same CPU by specifying a mask (for each CPU)
-#
-set cpu_cnt 0
-while {$cpu_cnt < $task_cnt} {
-	set mask_sum 0
-	set mask [ expr 1 << $cpu_cnt ]
-	set mstr [ dec2hex16 $mask]
-	send "$slaunch -n $available_cpus --cpu_bind=mask_cpu:$mstr $file_prog\n"
-	expect {
-		-re "TASK_ID:($number),MASK:($number)" {
-			incr mask_sum $expect_out(2,string)
-			exp_continue
-		}
-		-re "error" {
-			send_user "\nFAILURE: some error occurred\n"
-			set exit_code 1
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-			set exit_code 1
-			exp_continue
-		}
-		-re $prompt
-	}
-	if {$mask_sum != $task_cnt * $mask} {
-		send_user "\nFAILURE: affinity mask inconsistent ($mask_sum,$task_cnt)\n"
-		set exit_code 1
-	}
-	incr cpu_cnt 1
-}
-
-#
-# Generate foward and reverse masks and maps
-#
-set cpu_cnt 0
-set fwd_mask ""
-set fwd_map  ""
-set rev_mask ""
-set rev_map  ""
-set alt_mask ""
-set alt_map  ""
-set full_mask [ expr (1 << $task_cnt) - 1 ]
-while {$cpu_cnt < $task_cnt} {
-	set mask_sum 0
-	set mask [ expr 1 << $cpu_cnt ]
-	set mstr [ dec2hex16  $mask]
-	set fwd_mask "$fwd_mask,$mstr"
-	set fwd_map  "$fwd_map,$cpu_cnt"
-	set rev_mask "$mstr,$rev_mask"
-	set rev_map  "$cpu_cnt,$rev_map"
-	if { $cpu_cnt % 2 } {
-		set alt_mask "$mstr,$alt_mask"
-		set alt_map  "$cpu_cnt,$alt_map"
-	} else {
-		set alt_mask "$alt_mask,$mstr"
-		set alt_map  "$alt_map,$cpu_cnt"
-	}
-	if { $cpu_cnt == 0 } {
-		set fwd_mask "$mstr"
-		set fwd_map  "$cpu_cnt"
-		set rev_mask "$mstr"
-		set rev_map  "$cpu_cnt"
-		set alt_mask "$mstr"
-		set alt_map  "$cpu_cnt"
-	}
-	incr cpu_cnt 1
-}
-
-send_user "\n"
-send_user "full_mask: $full_mask\n"
-send_user "fwd_map:  $fwd_map\n"
-send_user "fwd_mask: $fwd_mask\n"
-send_user "rev_map:  $rev_map\n"
-send_user "rev_mask: $rev_mask\n"
-send_user "alt_map:  $alt_map\n"
-send_user "alt_mask: $alt_mask\n"
-
-#
-# Run all tasks bound to a different CPU by specifying a forward map
-#
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=map_cpu:$fwd_map $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU by specifying a reverse map
-#
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=map_cpu:$rev_map $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU by specifying an alternating map
-#
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=map_cpu:$alt_map $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU by specifying a forward mask
-#
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=mask_cpu:$fwd_mask $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU by specifying a reverse mask
-#
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=mask_cpu:$rev_mask $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU by specifying an alternating mask
-#
-set task_mask 0
-send "$slaunch -n $available_cpus --cpu_bind=mask_cpu:$alt_mask $file_prog\n"
-expect {
-	-re "TASK_ID:($number),MASK:($number)" {
-		incr task_mask $expect_out(2,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Terminate the job, free the allocation
-#
-send "exit\n"
-expect {
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding or failure to recognize prompt\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-	
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_prog
-	send_user "\nSUCCESS\n"
-} else {
-	send_user "\nNOTE: This test can fail if the node configuration in slurm.conf \n"
-	send_user "  (sockets, cores, threads) differs from the actual configuration\n"
-}
-exit $exit_code
-
diff --git a/testsuite/expect/test18.36.prog.c b/testsuite/expect/test18.36.prog.c
deleted file mode 100644
index bcd2c40ec02dfa8477fc0d1026e238c216fcc168..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.36.prog.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*****************************************************************************\
- *  test1.89.prog.c - Simple test program for SLURM regression test1.89.
- *  Reports SLURM task ID and the CPU mask,
- *  similar functionality to "taskset" command
- *****************************************************************************
- *  Copyright (C) 2005 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-#define _GNU_SOURCE
-#define __USE_GNU
-#include <errno.h>
-#include <sched.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../../config.h"
-
-static void _load_mask(cpu_set_t *mask)
-{
-	int rc;
-
-#ifdef SCHED_GETAFFINITY_THREE_ARGS
-	rc = sched_getaffinity((pid_t) 0, (unsigned int) sizeof(cpu_set_t), 
-		mask);
-#else
-	rc = sched_getaffinity((pid_t) 0, mask);
-#endif
-	if (rc != 0) {
-		fprintf(stderr, "ERROR: sched_getaffinity: %s\n",
-			strerror(errno));
-		exit(1);
-	}
-}
-
-static int _mask_to_int(cpu_set_t *mask)
-{
-	int i, rc = 0;
-	for (i=0; i<CPU_SETSIZE; i++) {
-		if (CPU_ISSET(i, mask))
-			rc += (1 << i);
-	}
-	return rc;
-}
-	
-	
-main (int argc, char **argv)
-{
-	char *task_str;
-	cpu_set_t mask;
-	int task_id;
-
-	_load_mask(&mask);
-	if ((task_str = getenv("SLURM_PROCID")) == NULL) {
-		fprintf(stderr, "ERROR: getenv(SLURM_PROCID) failed\n");
-		exit(1);
-	}
-	task_id = atoi(task_str);
-	printf("TASK_ID:%d,MASK:%u\n", task_id, _mask_to_int(&mask));
-	exit(0);
-}
diff --git a/testsuite/expect/test18.37 b/testsuite/expect/test18.37
deleted file mode 100755
index ccdcfb461aed1844bfc33bb85153aabf2918a3d2..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.37
+++ /dev/null
@@ -1,538 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of memory affinity support for NUMA systems.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.37"
-set exit_code   0
-set job_id      0
-set file_prog   "test$test_id.prog"
-
-print_header $test_id
-
-#
-# Test if memory affinity support is supported.
-#
-set affinity 0
-set fast_sched 0
-log_user 0
-spawn $scontrol show config
-expect {
-	-re "FastSchedule *= ($number)" {
-		set fast_sched $expect_out(1,string)
-		exp_continue
-	}
-	-re "task/affinity" {
-		set affinity 1
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-if {$fast_sched > 1} {
-	send_user "\nWARNING: FastSchedule > 1 not compatable with this test\n"
-	exit 0
-}
-spawn ls /usr/include/numa.h
-expect {
-	-nocase "no such file" {
-		set affinity 0
-		exp_continue
-	}
-	eof {
-		wait
-	}
-}
-log_user 1
-if {$affinity == 0} {
-	send_user "\nWARNING: memory affinity not supported on this system\n"
-	exit 0
-}
-send_user "\ntask affinity plugin installed with numa support\n"
-
-#
-# Build a test program to report affinity by task
-#
-exec $bin_rm -f $file_prog
-exec $bin_cc $file_prog.c -o $file_prog -lnuma
-exec $bin_chmod 700 $file_prog
-
-#
-# Create an allocation
-#
-set salloc_pid [spawn $salloc -N1 --exclusive --verbose -t2 $bin_bash]
-expect {
-	-re "Granted job allocation ($number)" {
-		set jobid $expect_out(1,string)
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-}
-
-#
-# Run a job step to get allocated processor count and affinity
-#
-expect -re $prompt
-set task_cnt 0
-set full_mask 0
-send "$srun -c1 $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		set full_mask $expect_out(2,string)
-		incr task_cnt
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-
-#
-# Run a job step with memory affinity
-#
-set cpu_mask 0
-set mem_mask 0
-send "$srun -c1 --mem_bind=rank $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr cpu_mask $expect_out(2,string)
-		incr mem_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-if {$mem_mask != $full_mask} {
-	send_user "\nFAILURE: memory affinity mask inconsistency ($mem_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run a job step with verbosity and all tasks using memory of CPU 0
-#
-set task_mask 0
-set verbose_cnt 0
-send "$srun -c1 --mem_bind=verbose,map_mem:0 $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr task_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-if {$task_mask != $task_cnt} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$task_cnt)\n"
-	set exit_code 1
-}
-set verbose_cnt 0
-send "$srun -c1 --mem_bind=verbose,map_mem:0 $file_prog\n"
-expect {
-	-re "mem_bind=MAP" {
-		incr verbose_cnt
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-	}
-	-re $prompt
-}
-if {$verbose_cnt != $task_cnt} {
-	send_user "\nFAILURE: verbose messages count inconsisent ($verbose_cnt,$task_cnt)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks all bound to the same CPU's memory (local CPU)
-#
-send "$srun -c1 --cpu_bind=rank --mem_bind=local $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		if {$expect_out(2,string) != $expect_out(3,string)} {
-			send_user "\nFAILURE: failed to use local memory for a task\n"
-			set exit_code 1
-		}
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-
-#
-# Run all tasks all bound to the same CPU's memory by specifying a map (for each CPU)
-#
-set cpu_cnt 0
-while {$cpu_cnt < $task_cnt} {
-	set mask_sum 0
-	set mask [ expr 1 << $cpu_cnt ]
-	send "$srun -c1 --mem_bind=map_mem:$cpu_cnt $file_prog\n"
-	expect {
-		-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-			incr mask_sum $expect_out(3,string)
-			exp_continue
-		}
-		-re "error" {
-			send_user "\nFAILURE: some error occurred\n"
-			set exit_code 1
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-			set exit_code 1
-			exp_continue
-		}
-		-re $prompt
-	}
-	if {$mask_sum != $task_cnt * $mask} {
-		send_user "\nFAILURE: affinity mask inconsistent ($mask_sum,$task_cnt)\n"
-		set exit_code 1
-	}
-	incr cpu_cnt 1
-}
-
-#
-# Run all tasks all bound to the same CPU's memory by specifying a mask (for each CPU)
-#
-set cpu_cnt 0
-while {$cpu_cnt < $task_cnt} {
-	set mask_sum 0
-	set mask [ expr 1 << $cpu_cnt ]
-	set mstr [ dec2hex16 $mask]
-	send "$srun -c1 --mem_bind=mask_mem:$mstr $file_prog\n"
-	expect {
-		 -re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-			incr mask_sum $expect_out(3,string)
-			exp_continue
-		}
-		-re "error" {
-			send_user "\nFAILURE: some error occurred\n"
-			set exit_code 1
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-			set exit_code 1
-			exp_continue
-		}
-		-re $prompt
-	}
-	if {$mask_sum != $task_cnt * $mask} {
-		send_user "\nFAILURE: affinity mask inconsistent ($mask_sum,$task_cnt)\n"
-		set exit_code 1
-	}
-	incr cpu_cnt 1
-}
-
-#
-# Generate foward and reverse masks and maps
-#
-set cpu_cnt 0
-set fwd_mask ""
-set fwd_map  ""
-set rev_mask ""
-set rev_map  ""
-set alt_mask ""
-set alt_map  ""
-set full_mask [ expr (1 << $task_cnt) - 1 ]
-while {$cpu_cnt < $task_cnt} {
-	set mask_sum 0
-	set mask [ expr 1 << $cpu_cnt ]
-	set mstr [ dec2hex16  $mask]
-	set fwd_mask "$fwd_mask,$mstr"
-	set fwd_map  "$fwd_map,$cpu_cnt"
-	set rev_mask "$mstr,$rev_mask"
-	set rev_map  "$cpu_cnt,$rev_map"
-	if { $cpu_cnt % 2 } {
-		set alt_mask "$mstr,$alt_mask"
-		set alt_map  "$cpu_cnt,$alt_map"
-	} else {
-		set alt_mask "$alt_mask,$mstr"
-		set alt_map  "$alt_map,$cpu_cnt"
-	}
-	if { $cpu_cnt == 0 } {
-		set fwd_mask "$mstr"
-		set fwd_map  "$cpu_cnt"
-		set rev_mask "$mstr"
-		set rev_map  "$cpu_cnt"
-		set alt_mask "$mstr"
-		set alt_map  "$cpu_cnt"
-	}
-	incr cpu_cnt 1
-}
-
-send_user "\n"
-send_user "full_mask: $full_mask\n"
-send_user "fwd_map:  $fwd_map\n"
-send_user "fwd_mask: $fwd_mask\n"
-send_user "rev_map:  $rev_map\n"
-send_user "rev_mask: $rev_mask\n"
-send_user "alt_map:  $alt_map\n"
-send_user "alt_mask: $alt_mask\n"
-
-#
-# Run all tasks bound to a different CPU's memory by specifying a forward map
-#
-set task_mask 0
-send "$srun -c1 --mem_bind=map_mem:$fwd_map $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr task_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU's memory by specifying a reverse map
-#
-set task_mask 0
-send "$srun -c1 --mem_bind=map_mem:$rev_map $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr task_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU's memroy by specifying an alternating map
-#
-set task_mask 0
-send "$srun -c1 --mem_bind=map_mem:$alt_map $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr task_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU's memory by specifying a forward mask
-#
-set task_mask 0
-send "$srun -c1 --mem_bind=mask_mem:$fwd_mask $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr task_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU's memory by specifying a reverse mask
-#
-set task_mask 0
-send "$srun -c1 --mem_bind=mask_mem:$rev_mask $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr task_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Run all tasks bound to a different CPU's memory by specifying an alternating mask
-#
-set task_mask 0
-send "$srun -c1 --mem_bind=mask_mem:$alt_mask $file_prog\n"
-expect {
-	-re "TASK_ID:($number),CPU_MASK:($number),MEM_MASK:($number)" {
-		incr task_mask $expect_out(3,string)
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: srun not responding or failure to recognize prompt\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re $prompt
-}
-if {$task_mask != $full_mask} {
-	send_user "\nFAILURE: affinity mask inconsistent ($task_mask,$full_mask)\n"
-	set exit_code 1
-}
-
-#
-# Terminate the job, free the allocation
-#
-send "exit\n"
-expect {
-	-re "error" {
-		send_user "\nFAILURE: some error occurred\n"
-		set exit_code 1
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding or failure to recognize prompt\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-	
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_prog
-	send_user "\nSUCCESS\n"
-} else {
-	send_user "\nNOTE: This test can fail if the node configuration in slurm.conf \n"
-	send_user "  (sockets, cores, threads) differs from the actual configuration\n"
-}
-exit $exit_code
-
diff --git a/testsuite/expect/test18.37.prog.c b/testsuite/expect/test18.37.prog.c
deleted file mode 100644
index b24730c3f259229aa72db0becd39d17da8745c80..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.37.prog.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*****************************************************************************\
- *  test1.90.prog.c - Simple test program for SLURM regression test1.90.
- *  Reports SLURM task ID, the CPU mask, and memory mask,
- *  similar functionality to "taskset" command
- *****************************************************************************
- *  Copyright (C) 2006 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-#define _GNU_SOURCE
-#include <numa.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void _load_cpu_mask(nodemask_t *cpu_mask)
-{
-	*cpu_mask = numa_get_run_node_mask();
-}
-
-static void _load_mem_mask(nodemask_t *mem_mask)
-{
-	*mem_mask = numa_get_membind();
-}
-
-static unsigned long _mask_to_int(nodemask_t *mask)
-{
-	int i;
-	unsigned long rc = 0;
-	for (i=0; i<NUMA_NUM_NODES; i++) {
-		if (nodemask_isset(mask, i))
-			rc += (1 << i);
-	}
-	return rc;
-}
-
-main (int argc, char **argv)
-{
-	char *task_str;
-	nodemask_t cpu_mask, mem_mask;
-	int task_id;
-
-	if (numa_available() < 0) {
-		fprintf(stderr, "ERROR: numa support not available\n");
-		exit(1);
-	}
-
-	if ((task_str = getenv("SLURM_PROCID")) == NULL) {
-		fprintf(stderr, "ERROR: getenv(SLURM_PROCID) failed\n");
-		exit(1);
-	}
-	task_id = atoi(task_str);
-	_load_cpu_mask(&cpu_mask);
-	_load_mem_mask(&mem_mask);
-	printf("TASK_ID:%d,CPU_MASK:%lu,MEM_MASK:%lu\n", 
-		task_id, _mask_to_int(&cpu_mask), _mask_to_int(&mem_mask));
-	exit(0);
-}
diff --git a/testsuite/expect/test18.38 b/testsuite/expect/test18.38
deleted file mode 100755
index a036d0dc2a375bac281ba4b2aa461a14466714fa..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.38
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of slaunch --jobid option
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Christopher J. Morrone <morrone2@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id              "18.38"
-set exit_code            0
-set jobid                0
-
-print_header $test_id
-set timeout $max_job_delay
-
-#
-# Run an salloc to grab a single node allocation.
-#
-set salloc_pid [spawn $salloc -N1 $slaunch $bin_sleep 600]
-set salloc_sid $spawn_id
-expect {
-	-re "Granted job allocation ($number)" {
-		set jobid $expect_out(1,string)
-	}
-	timeout {
-		send_user "\nFAILURE: salloc failed to grab an allocation "
-		send_user "in a timely manner.\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		exit 1
-	}
-}
-if {$jobid == 0} {
-	send_user "\nFAILURE: salloc failed to allocate resources\n"
-	exit 1
-}
-
-#
-# Now try to use the slaunch --jobid option to run in the already existing
-# allocation.
-#
-set pattern "xcoetn46398vnk"
-set got_pattern 0
-set slaunch_pid [spawn $slaunch --jobid $jobid echo $pattern]
-expect {
-	-re "error" {
-		send_user "\nFAILURE: unexpected error occurred\n"
-		set exit_code 1
-	}
-	-re $pattern {
-		set got_pattern 1
-		exp_continue
-	}
-	timeout {
-		exec kill $slaunch_pid
-		exec kill -9 $slaunch_pid
-	}
-	eof {
-		wait
-	}
-}
-
-if {$got_pattern == 0} {
-	send_user "\nFAILURE: unable to srun step under existing job allocation\n"
-	set exit_code 1
-}
-
-#
-# Release the allocation by killing the first srun (really it kills the "sleep")
-#
-cancel_job $jobid
-exec kill $salloc_pid
-set spawn_id $salloc_sid
-expect {
-	-re "error.*already completed" {
-		send_user "The \"already completed\" error is normal.\n"
-		exp_continue
-	}
-	timeout {
-		exec kill -9 $salloc_pid
-	}
-	eof {
-		wait
-	}
-}
-
-if {$got_pattern == 1} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.4 b/testsuite/expect/test18.4
deleted file mode 100755
index ad913915eed1f06911848165b35a063e69f681b2..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.4
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Confirm that a job executes with the proper task count (--tasks
-#          and --overcommit options).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.4"
-set exit_code   0
-set job_id      0
-
-print_header $test_id
-
-if { [test_xcpu] } {
-	set max_tasks 1
-} else {
-	set max_tasks 8
-}
-
-for {set inx 1} {$inx <= $max_tasks} {set inx [expr $inx * 2]} {
-	set tasks_set $inx
-	set tasks_get 0
-	set timeout $max_job_delay
-	set salloc_pid [spawn $salloc -N1-4 -t1 $slaunch -n$tasks_set --overcommit $bin_id]
-	expect {
-		-re "Granted job allocation ($number)" {
-			set job_id $expect_out(1,string)
-			exp_continue
-		}
-		-re "uid=" {
-			incr tasks_get
-			exp_continue
-		}
-		timeout {
-			send_user "\nFAILURE: salloc not responding\n"
-			if {$job_id != 0} {
-				cancel_job $job_id
-			}
-			slow_kill [expr 0 - $salloc_pid]
-			set exit_code 1
-		}
-		eof {
-			if {$tasks_get < $tasks_set} {
-				send_user "\nFAILURE: Did not get proper number of tasks: "
-				send_user "$tasks_get < $tasks_set\n"
-				set exit_code 1
-			} else {
-				send_user "test of $tasks_get tasks good\n\n"
-			}			
-			wait
-		}
-	}
-}
-
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.7 b/testsuite/expect/test18.7
deleted file mode 100755
index 9673ce2914d3ca50f7fce50e534ff2715bd4a00e..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.7
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of slaunch/slurmd debug mode (--slurmd-debug option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.7"
-set debug_get   0
-set debug_set   4
-set exit_code   0
-set job_id      0
-
-print_header $test_id
-
-#
-# Submit a slurm job that will bogus executable
-# Debug debug level is 2, value set with --debug has that offset
-#
-set debug_offset [expr $debug_set - 2]
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch -d$debug_offset /invalid_executable ]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "debug level = ($number)" {
-		set debug_get $expect_out(1,string)
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-}
-
-if {$debug_get != $debug_set} {
-	send_user "\nFAILURE: Did not log at proper level ($debug_get != $debug_set)\n"
-	set exit_code 1
-}
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.8 b/testsuite/expect/test18.8
deleted file mode 100755
index eaf972a76ce17f2c281f32fa6388b70dc4bff06a..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.8
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Confirm that slaunch buffering can be disabled (--unbuffered option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id            "18.8"
-set exit_code          0
-set job_id             0
-set matches            0
-set scratch_file       "scratch.$test_id"
-
-print_header $test_id
-
-#
-# Create a scratch file
-#
-exec $bin_touch $scratch_file
-
-#
-# Submit a slurm job that will execute 'rm -i'
-# The --unbuffered option will send the message which lacks a '\n'
-#
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -t1 $slaunch --unbuffered $bin_rm -i $scratch_file]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "\[Rr\]emove .*\?" {
-		set matches 1
-		send "y\n"
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Confirm message send before '\n' (unbuffered).
-#
- 
-if {$matches != 1} {
-	send_user "\nFAILURE: slaunch --unbuffered option failure\n"
-	exec $bin_rm -f $scratch_file
-	set exit_code 1
-}
-if {$exit_code == 0} {
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test18.9 b/testsuite/expect/test18.9
deleted file mode 100755
index 97ff034f1aad8de49e2ab7eaade9086b215c0d08..0000000000000000000000000000000000000000
--- a/testsuite/expect/test18.9
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of wait option (--wait option).
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-############################################################################
-source ./globals
-
-set test_id     "18.9"
-set exit_code   0
-set file_in     "test$test_id.input"
-set job_id      0
-set matches     0
-
-print_header $test_id
-
-#
-# Delete left-over input script
-# Build input script file
-#
-exec $bin_rm -f $file_in
-make_bash_script $file_in "
-    if ((\$SLURM_PROCID == 1))
-        then exit
-    fi
-    $bin_sleep 300
-"
-
-#
-# Spawn tasks via slaunch and immediately exit task 1 only
-#
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t2 $slaunch -n10 --overcommit -W2 $file_in]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "First task exited" {
-		send_user "This error is expected, no worries\n"
-		incr matches
-		exp_continue
-	}
-	-re "task\\\[0,2-9]: running" {
-		incr matches
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: slaunch not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-if {$matches != 2} {
-	send_user "\nFAILURE: problem with slaunch wait option\n"
-	set exit_code 1
-}
-if {$exit_code == 0} {
-	exec $bin_rm -f $file_in
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test19.1 b/testsuite/expect/test19.1
index 9d1b507a34fb32ec0948bef8a2684a9234cb4322..de04f2465d3953c30df58bbe95f84ee1c9b55f29 100755
--- a/testsuite/expect/test19.1
+++ b/testsuite/expect/test19.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test19.2 b/testsuite/expect/test19.2
index d34a086b0c0d73f0bacd1f974fde30272b04eb0c..c897eecc3695cec73dcbc53482d5213a9dd47512 100755
--- a/testsuite/expect/test19.2
+++ b/testsuite/expect/test19.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test19.3 b/testsuite/expect/test19.3
index e0d1e95ce03da31508678988e4f3436c4b3ace34..41b7007182f1f18a4477d446e2a48dcd5a95eb24 100755
--- a/testsuite/expect/test19.3
+++ b/testsuite/expect/test19.3
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test19.4 b/testsuite/expect/test19.4
index 0bc05190d3fbd72e5c494bbb7e2e18c466281f06..789e4a9aa67fe1065163da30ff704b9c2c6f55d8 100755
--- a/testsuite/expect/test19.4
+++ b/testsuite/expect/test19.4
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test19.5 b/testsuite/expect/test19.5
index d0c45dceaa3fc721530fcb29cea4f8369300ba0b..609541be0455bde5feec982a927bf8de31a21472 100755
--- a/testsuite/expect/test19.5
+++ b/testsuite/expect/test19.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -67,9 +67,9 @@ exec $strigger --clear --quiet --user=$uid
 make_bash_script $file_in "sleep 60"
 
 set job_id 0
-spawn $srun --batch --output=/dev/null -t2 $file_in
+spawn $sbatch --output=/dev/null -t2 $file_in
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test19.6 b/testsuite/expect/test19.6
index 8c264c87cf07360510036542509167d8def27c75..b2d17013b481c7be08d2be37dfd89f2e1bb1b18a 100755
--- a/testsuite/expect/test19.6
+++ b/testsuite/expect/test19.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -74,9 +74,9 @@ make_bash_script $file_in_down     "sleep 1"
 make_bash_script $file_in_reconfig "sleep 1"
 
 set job_id 0
-spawn $srun --batch --output=/dev/null -t1 $file_in
+spawn $sbatch --output=/dev/null -t1 $file_in
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test19.7 b/testsuite/expect/test19.7
index 336cd0627178f908f49c2b04d7566c5465d426b3..8dd3ddee3c626b79e870cd58ecc8a7797eca70a6 100755
--- a/testsuite/expect/test19.7
+++ b/testsuite/expect/test19.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -68,9 +68,9 @@ make_bash_script $file_in          "sleep 6"
 make_bash_script $file_in_idle     "echo \$1 >$cwd/$file_out"
 
 set job_id 0
-spawn $srun --batch --output=/dev/null -t1 $file_in
+spawn $sbatch --output=/dev/null -t1 $file_in
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test2.1 b/testsuite/expect/test2.1
index 986cf4d34b054fdc6eb13bea8da6734cf1bd882a..044ac6e1b2275af2bf4391a70e6637c5bf5ab242 100755
--- a/testsuite/expect/test2.1
+++ b/testsuite/expect/test2.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test2.10 b/testsuite/expect/test2.10
index cf62a6e767b03b1f922685e19b86e3a4bc0199ac..ac754a01b7237771e484131cc647defb7c046e43 100755
--- a/testsuite/expect/test2.10
+++ b/testsuite/expect/test2.10
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test2.11 b/testsuite/expect/test2.11
index 9457b7f2f61c6ce9af4c3950d5ec7da27554a88e..3ae4cdfdc8939bccbfe01568037a2996c3b79969 100755
--- a/testsuite/expect/test2.11
+++ b/testsuite/expect/test2.11
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -57,15 +57,15 @@ make_bash_script $file_in "
 #
 # Spawn a srun batch job that uses stdout/err and confirm their contents
 #
-set srun_pid [spawn $srun --batch --output=$file_out -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test2.2 b/testsuite/expect/test2.2
index 52b9c479b84ae2b43637b4becba5e7f17898d2df..fd894a5e0ff4f145389a25ef44bb741682677b1d 100755
--- a/testsuite/expect/test2.2
+++ b/testsuite/expect/test2.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test2.3 b/testsuite/expect/test2.3
index 6cfe92713714223c4ddd9aed353d780464db6011..6d069fdce71aa057253fc1d36c771c14dfbadd74 100755
--- a/testsuite/expect/test2.3
+++ b/testsuite/expect/test2.3
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test2.4 b/testsuite/expect/test2.4
index 6a122d7f688c196e5f8d04764f66d8ff62f75537..12142fac7cd14e9b010debd1c8947647ad7b5d1d 100755
--- a/testsuite/expect/test2.4
+++ b/testsuite/expect/test2.4
@@ -14,7 +14,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test2.5 b/testsuite/expect/test2.5
index e2c520bf8642bf5b02f05d25239406e0aea3e1ae..b378fdd4a30806fe699a323a677636cad3246d51 100755
--- a/testsuite/expect/test2.5
+++ b/testsuite/expect/test2.5
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -80,7 +80,7 @@ set matches     0
 set part_name   ""
 spawn $scontrol show partition
 expect {
-	-re "PartitionName=($alpha_numeric)" {
+	-re "PartitionName=($alpha_numeric_under)" {
 		set part_name $expect_out(1,string)
 		incr matches
 		exp_continue
@@ -104,7 +104,7 @@ if {$matches < 1} {
 set matches     0
 spawn $scontrol show partition $part_name
 expect {
-	-re "PartitionName=($alpha_numeric)" {
+	-re "PartitionName=($alpha_numeric_under)" {
 		if {[string compare $expect_out(1,string) $part_name] == 0} {
 			incr matches
 		}
@@ -131,7 +131,7 @@ set matches     0
 set node_name   ""
 spawn $scontrol show node
 expect {
-	-re "NodeName=($alpha_numeric)" {
+	-re "NodeName=($alpha_numeric_under)" {
 		set node_name $expect_out(1,string)
 		incr matches
 		exp_continue
@@ -155,7 +155,7 @@ if {$matches < 1} {
 set matches     0
 spawn $scontrol show node $node_name
 expect {
-	-re "NodeName=($alpha_numeric)" {
+	-re "NodeName=($alpha_numeric_under)" {
 		if {[string compare $expect_out(1,string) $node_name] == 0} {
 			incr matches
 		}
diff --git a/testsuite/expect/test2.6 b/testsuite/expect/test2.6
index 877e2980cc8eea4e765066dada0efcfb8a98b110..49e3ab2aa770f494d978d4d80bf18f26a43aa3a7 100755
--- a/testsuite/expect/test2.6
+++ b/testsuite/expect/test2.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test2.7 b/testsuite/expect/test2.7
index 62b163988d261d8747b799a1a09ce16c99fbfd4e..4bea531a7c6fc6c03d3438c559d8be35253c982e 100755
--- a/testsuite/expect/test2.7
+++ b/testsuite/expect/test2.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -52,9 +52,9 @@ make_bash_script $file_in "$scontrol pidinfo \$\$"
 #
 # Spawn a srun batch job that uses stdout/err and confirm their contents
 #
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err -t1 $file_in]
+set srun_pid [spawn $sbatch --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
@@ -107,7 +107,7 @@ if {$rem_time > 60} {
 	send_user "\nFAILURE: job remaining time is wrong $rem_time\n"
 	set exit_code 1
 }
-if {$rem_time < 59} {
+if {$rem_time < 58} {
 	send_user "\nFAILURE: job remaining time seems too small\n"
 	set exit_code 1
 }
diff --git a/testsuite/expect/test2.8 b/testsuite/expect/test2.8
index 182dc812769ffb42fc6560aa0e8fa49c3eb3c421..39bf4363b8211adaa8cd060588c2bccff430ad21 100755
--- a/testsuite/expect/test2.8
+++ b/testsuite/expect/test2.8
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -50,15 +50,15 @@ make_bash_script $file_in "
 #
 # Submit a couple jobs so we have something to work with
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t5 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -70,16 +70,16 @@ if {$job_id1 == 0} {
 	exit 1
 }
 
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t5 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
 		cancel_job $job_id1
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test2.9 b/testsuite/expect/test2.9
index 411d040afd925307c83c320e72fb87c6988a194b..fc317de68928047b3eb1fa9ed4c9179b5d79bd3c 100755
--- a/testsuite/expect/test2.9
+++ b/testsuite/expect/test2.9
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test20.1 b/testsuite/expect/test20.1
index 70d7f1e6da4aa0672bf9035f94234b54eb83036a..201f01815311d860eb71b47e7577b97c24d1d17e 100755
--- a/testsuite/expect/test20.1
+++ b/testsuite/expect/test20.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test20.2 b/testsuite/expect/test20.2
index 9caca3a3a95f484cf24827bd2b9a0c9987479635..f07bdac769c25d0ba3d1ef3812958677e1dec2d9 100755
--- a/testsuite/expect/test20.2
+++ b/testsuite/expect/test20.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test20.3 b/testsuite/expect/test20.3
index e564f6f5ce157c5247359a754a43857bb674b2bf..50679cab7e8c7cb88eeeeb8cc4ee9e37eae06801 100755
--- a/testsuite/expect/test20.3
+++ b/testsuite/expect/test20.3
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test20.4 b/testsuite/expect/test20.4
index 133ce152bcfb7a1eb10e0369c392dd51e2e3a05c..4a8acc7833f263ce2e48365ee9c8949be9b8ac84 100755
--- a/testsuite/expect/test20.4
+++ b/testsuite/expect/test20.4
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test18.6 b/testsuite/expect/test21.1
similarity index 63%
rename from testsuite/expect/test18.6
rename to testsuite/expect/test21.1
index 2534fe058c439b3def993127a4ff3fbdf05252e0..e2e217a3e16c1bbaa994e9f923eb681632a1248e 100755
--- a/testsuite/expect/test18.6
+++ b/testsuite/expect/test21.1
@@ -1,16 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of slaunch verbose mode (-v option).
+#          Test sacctmgr --usage option. (initially same as --help)
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
+# Copyright (C) 2008 Lawrence Livermore National Security.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# Written by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -27,51 +27,49 @@
 # 
 # You should have received a copy of the GNU General Public License along
 # with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 ############################################################################
 source ./globals
 
-set test_id     "18.6"
+set test_id     "21.1"
 set exit_code   0
-set job_id      0
-set verbosity   0
+set matches     0
+set not_support 0
 
 print_header $test_id
 
 #
-# Submit a slurm job that will execute 'id' on 1 node and over task_cnt tasks
+# Report the sacctmgr usage format
 #
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch -vv $bin_printenv SLURMD_NODENAME]
+ 
+spawn $sacctmgr --usage
 expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
+	-re "commit changes immediately" {
+		incr matches
 		exp_continue
 	}
-	-re "debug:" {
-		set verbosity 1
+	-re "display tool version number" {
+		incr matches
 		exp_continue
 	}
-	-re "Unable to contact" {
-		send_user "\nFAILURE: slurm appears to be down\n"
-		exit 1
+	-re "add cluster" {
+		incr matches
+		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: slurm not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
+		send_user "\nFAILURE: sacctmgr not responding\n"
 		set exit_code 1
 	}
 	eof {
 		wait
 	}
 }
-if {$verbosity != 1} {
-	send_user "\nFAILURE: Did not report debug message verbosity on\n"
+
+if {$matches != 3} {
+	send_user "\nFAILURE: sacctmgr --usage failed ($matches)\n"
 	set exit_code 1
 }
+
 if {$exit_code == 0} {
 	send_user "\nSUCCESS\n"
 }
diff --git a/testsuite/expect/test18.3 b/testsuite/expect/test21.2
similarity index 71%
rename from testsuite/expect/test18.3
rename to testsuite/expect/test21.2
index 4311290c7767906f836ca87d920baa6d61d532fa..90fa0218ad23c5caf2b8ae4d8e94c37e08967901 100755
--- a/testsuite/expect/test18.3
+++ b/testsuite/expect/test21.2
@@ -1,17 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Confirm that slaunch reports a proper version number (--version 
-#          option).
+#          Test sacctmgr --help option.
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2006 The Regents of the University of California.
+# Copyright (C) 2008 Lawrence Livermore National Security.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# Written by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -28,39 +27,49 @@
 # 
 # You should have received a copy of the GNU General Public License along
 # with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 ############################################################################
 source ./globals
 
-set test_id     "18.3"
+set test_id     "21.2"
 set exit_code   0
-set version     0
+set matches     0
+set not_support 0
 
 print_header $test_id
 
 #
-# Report the slaunch version number
+# Report the sacctmgr help format
 #
-spawn $slaunch --version
+ 
+spawn $sacctmgr --help
 expect {
-	-re "(slurm ($number)\.($number)\.($number).*\n)" {
-		incr version
+	-re "commit changes immediately" {
+		incr matches
+		exp_continue
+	}
+	-re "display tool version number" {
+		incr matches
+		exp_continue
+	}
+	-re "add cluster" {
+		incr matches
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: slaunch not responding\n"
+		send_user "\nFAILURE: sacctmgr not responding\n"
 		set exit_code 1
-		exp_continue
 	}
 	eof {
 		wait
 	}
 }
 
-if {$version != 1} {
-	send_user "\nFAILURE: Did not get proper slaunch version number\n"
+if {$matches != 3} {
+	send_user "\nFAILURE: sacctmgr --help failed ($matches)\n"
 	set exit_code 1
 }
+
 if {$exit_code == 0} {
 	send_user "\nSUCCESS\n"
 }
diff --git a/testsuite/expect/test18.1 b/testsuite/expect/test21.3
similarity index 77%
rename from testsuite/expect/test18.1
rename to testsuite/expect/test21.3
index 884eb1118b2bd5edfb6335476f42828349f0b74e..55086164a51d695a97b48ad7fc42312020fa3dc5 100755
--- a/testsuite/expect/test18.1
+++ b/testsuite/expect/test21.3
@@ -1,16 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Confirm that slaunch usage option works (--usage option).
+#          Test sacctmgr -V	(display version)
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2006 The Regents of the University of California.
+# Copyright (C) 2008 Lawrence Livermore National Security.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# Written by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -27,28 +27,29 @@
 # 
 # You should have received a copy of the GNU General Public License along
 # with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 ############################################################################
 source ./globals
 
-set test_id     "18.1"
+set test_id     "21.3"
 set exit_code   0
 set matches     0
+set not_support 0
 
 print_header $test_id
 
 #
-# Report the slaunch usage format
+# Report the sacctmgr version format
 #
  
-spawn $slaunch --usage  
+spawn $sacctmgr -V
 expect {
-	-re "Usage: .*slaunch.*" {
+	-re "slurm \[0-9]*.\[0-9]*.\[0-9]*" {
 		incr matches
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: slaunch not responding\n"
+		send_user "\nFAILURE: sacctmgr not responding\n"
 		set exit_code 1
 	}
 	eof {
@@ -57,9 +58,10 @@ expect {
 }
 
 if {$matches != 1} {
-	send_user "\nFAILURE: slaunch failed to report usage format\n"
+	send_user "\nFAILURE: sacctmgr -V failed ($matches)\n"
 	set exit_code 1
 }
+
 if {$exit_code == 0} {
 	send_user "\nSUCCESS\n"
 }
diff --git a/testsuite/expect/test18.2 b/testsuite/expect/test21.4
similarity index 74%
rename from testsuite/expect/test18.2
rename to testsuite/expect/test21.4
index d56c73da013208da4fa25922f6b125ea6caf8e46..fc088c5d25f6edd1f9cef42f4b8ce56da0daa762 100755
--- a/testsuite/expect/test18.2
+++ b/testsuite/expect/test21.4
@@ -1,16 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Confirm that slaunch help option works (--help option).
+#          Test sacctmgr version	(display version)
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
 ############################################################################
-# Copyright (C) 2006 The Regents of the University of California.
+# Copyright (C) 2008 Lawrence Livermore National Security.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# Written by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -27,32 +27,29 @@
 # 
 # You should have received a copy of the GNU General Public License along
 # with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 ############################################################################
 source ./globals
 
-set test_id     "18.2"
+set test_id     "21.4"
 set exit_code   0
 set matches     0
+set not_support 0
 
 print_header $test_id
 
 #
-# Report the slaunch help message
+# Report the sacctmgr version keyword
 #
  
-spawn $slaunch --help  
+spawn $sacctmgr version
 expect {
-	-re "Usage:" {
-		incr matches
-		exp_continue
-	}
-	-re "Help options" {
+	-re "slurm \[0-9]*.\[0-9]*.\[0-9]*" {
 		incr matches
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: slaunch not responding\n"
+		send_user "\nFAILURE: sacctmgr not responding\n"
 		set exit_code 1
 	}
 	eof {
@@ -60,10 +57,11 @@ expect {
 	}
 }
 
-if {$matches != 2} {
-	send_user "\nFAILURE: slaunch failed to report help message\n"
+if {$matches != 1} {
+	send_user "\nFAILURE: sacctmgr version failed ($matches)\n"
 	set exit_code 1
 }
+
 if {$exit_code == 0} {
 	send_user "\nSUCCESS\n"
 }
diff --git a/testsuite/expect/test21.5 b/testsuite/expect/test21.5
new file mode 100755
index 0000000000000000000000000000000000000000..cee55d8f806a5b66def55d021131cde74a396685
--- /dev/null
+++ b/testsuite/expect/test21.5
@@ -0,0 +1,157 @@
+#!/usr/bin/expect
+############################################################################
+# Purpose: Test of SLURM functionality
+#          sacctmgr add, list, and delete a cluster
+#
+# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "FAILURE: ..." otherwise with an explanation of the failure, OR
+#          anything else indicates a failure mode that must be investigated.
+############################################################################
+# Copyright (C) 2008 Lawrence Livermore National Security.
+# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+# Written by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
+# 
+# This file is part of SLURM, a resource management program.
+# For details, see <http://www.llnl.gov/linux/slurm/>.
+#  
+# SLURM is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+# 
+# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with SLURM; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+############################################################################
+source ./globals
+
+set test_id     "21.5"
+set exit_code   0
+set amatches     0
+set lmatches     0
+set dmatches     0
+set not_support 0
+set add		add
+set lis		list
+set del		delete
+set mod		modify
+set clu		cluster
+set tc1		tCluster1
+
+
+print_header $test_id
+
+#
+# Use sacctmgr to create a cluster
+#
+set sadd_pid [spawn $sacctmgr $add $clu $tc1]
+expect {
+	-re "Adding Cluster" {
+		incr amatches
+		exp_continue
+	}
+	-re "Name *= $tc1" {
+		incr amatches
+		exp_continue
+	}
+	-re "Would you like to commit changes\\\? \\\(You have 30 seconds to decide\\\)" {
+		incr amatches
+		exp_continue
+	}
+	-re "\\\(N\\\/y\\\):" {
+		incr amatches
+		send "Y\r"
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr add not responding\n"
+		slow_kill $sadd_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$amatches != 4} {
+	send_user "\nFAILURE:  sacctmgr had a problem adding clusters\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to list the addition of cluster
+#
+set slist_pid [spawn $sacctmgr $lis $clu $tc1]
+expect {
+	-re "Name" {
+		incr lmatches
+		exp_continue
+	}
+	-re "$tc1" {
+		incr lmatches
+		exp_continue
+		send_user "\nFound $tc1 in database\n"
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr list not responding\n"
+		slow_kill $slist_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$lmatches != 2} {
+	send_user "\nFAILURE:  sacctmgr had a problem listing clusters\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to delete the test cluster
+#
+set sadel_pid [spawn $sacctmgr $del $clu $tc1]
+expect {
+	-re "Deleting clusters" {
+		incr dmatches
+		exp_continue
+	}
+	-re "$tc1" {
+		incr dmatches
+		exp_continue
+	}
+	-re "Would you like to commit changes\\\? \\\(You have 30 seconds to decide\\\)" {
+		incr dmatches
+		exp_continue
+	}
+	-re "\\\(N\\\/y\\\):" {
+		incr dmatches
+		send "Y\r"
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr delete not responding\n"
+		slow_kill $sadel_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$dmatches != 4} {
+	send_user "\nFAILURE: sacctmgr had a problem deleting cluster\n"
+	set exit_code 1
+}
+
+if {$exit_code == 0} {
+	send_user "\nSUCCESS\n"
+}
+
+exit $exit_code
diff --git a/testsuite/expect/test21.6 b/testsuite/expect/test21.6
new file mode 100755
index 0000000000000000000000000000000000000000..8cf05b9e7ae03bdc1ebc6bfca9b1923e074507fb
--- /dev/null
+++ b/testsuite/expect/test21.6
@@ -0,0 +1,169 @@
+#!/usr/bin/expect
+############################################################################
+# Purpose: Test of SLURM functionality
+#          sacctmgr add, list, and delete multiple clusters
+#
+# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "FAILURE: ..." otherwise with an explanation of the failure, OR
+#          anything else indicates a failure mode that must be investigated.
+############################################################################
+# Copyright (C) 2008 Lawrence Livermore National Security.
+# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+# Written by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
+# 
+# This file is part of SLURM, a resource management program.
+# For details, see <http://www.llnl.gov/linux/slurm/>.
+#  
+# SLURM is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+# 
+# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with SLURM; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+############################################################################
+source ./globals
+
+set test_id     "21.6"
+set exit_code   0
+set amatches     0
+set lmatches     0
+set dmatches     0
+set not_support 0
+set add		add
+set lis		list
+set del		delete
+set mod		modify
+set clu		cluster
+set tc1		tCluster1
+set tc2		tCluster2
+set tc3		tCluster3
+
+
+print_header $test_id
+
+#
+# Use sacctmgr to create a cluster
+#
+set sadd_pid [spawn $sacctmgr $add $clu $tc1,$tc2,$tc3]
+expect {
+	-re "Adding Cluster" {
+		incr amatches
+		exp_continue
+	}
+	-re "Name *= $tc1" {
+		incr amatches
+		exp_continue
+	}
+	-re "Would you like to commit changes\\\? \\\(You have 30 seconds to decide\\\)" {
+		incr amatches
+		exp_continue
+	}
+	-re "\\\(N\\\/y\\\):" {
+		incr amatches
+		send "Y\r"
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr add not responding\n"
+		slow_kill $sadd_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$amatches != 4} {
+	send_user "\nFAILURE:  sacctmgr had a problem adding clusters\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to list the addition of cluster
+#
+set slist_pid [spawn $sacctmgr $lis $clu $tc1,$tc2,$tc3]
+expect {
+	-re "Name" {
+		incr lmatches
+		exp_continue
+	}
+	-re "$tc1" {
+		incr lmatches
+		exp_continue
+		send_user "\nFound $tc1 in database\n"
+	}
+	-re "$tc2" {
+		incr lmatches
+		exp_continue
+		send_user "\nFound $tc1 in database\n"
+	}
+	-re "$tc3" {
+		incr lmatches
+		exp_continue
+		send_user "\nFound $tc1 in database\n"
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr list not responding\n"
+		slow_kill $slist_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$lmatches != 4} {
+	send_user "\nFAILURE:  sacctmgr had a problem listing clusters\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to delete the test cluster
+#
+set sadel_pid [spawn $sacctmgr $del $clu $tc1,$tc2,$tc3]
+expect {
+	-re "Deleting clusters" {
+		incr dmatches
+		exp_continue
+	}
+	-re "$tc1" {
+		incr dmatches
+		exp_continue
+	}
+	-re "Would you like to commit changes\\\? \\\(You have 30 seconds to decide\\\)" {
+		incr dmatches
+		exp_continue
+	}
+	-re "\\\(N\\\/y\\\):" {
+		incr dmatches
+		send "Y\r"
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr delete not responding\n"
+		slow_kill $sadel_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$dmatches != 4} {
+	send_user "\nFAILURE: sacctmgr had a problem deleting cluster\n"
+	set exit_code 1
+}
+
+if {$exit_code == 0} {
+	send_user "\nSUCCESS\n"
+}
+
+exit $exit_code
diff --git a/testsuite/expect/test3.1 b/testsuite/expect/test3.1
index 14685b53987f378a0bb8c9fa7452bd4d23c6707d..10d286e32257fcb25d063ae2f70344a77accefd4 100755
--- a/testsuite/expect/test3.1
+++ b/testsuite/expect/test3.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test18.13 b/testsuite/expect/test3.10
similarity index 61%
rename from testsuite/expect/test18.13
rename to testsuite/expect/test3.10
index ea0d78a537d7c3033f73f5628fb54436484b353d..4197f9dd90dcdb012bc65937d7dd44993f1d6ba0 100755
--- a/testsuite/expect/test18.13
+++ b/testsuite/expect/test3.10
@@ -1,20 +1,16 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Confirm that slaunch sets appropriate working directory (--workdir
-#          option).
+#          Test of "scontrol notify <jobid> <message>"
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
 #          anything else indicates a failure mode that must be investigated.
-#
-# NOTE:    Due to symbolic links, we only look to match the last component
-#          of the directory name (e.g "cd /tmp; pwd" might return "/var/tmp").
 ############################################################################
-# Copyright (C) 2002-2006 The Regents of the University of California.
+# Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -35,49 +31,78 @@
 ############################################################################
 source ./globals
 
-set test_id     "18.13"
-set exit_code   0
-set job_id      0
-set matches     0
-set tmp_dir	"/tmp"
+set test_id        "3.10"
+set authorized     1
+set exit_code      0
+set job_id         0
 
 print_header $test_id
 
 #
-# Change working directory on execute line and then print where jobs runs
+# Start a test program
 #
 set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1 -t1 $slaunch --workdir=$tmp_dir $bin_pwd]
+set srun_pid [spawn $srun -N1 -t1 -v $bin_sleep 10]
+set srun_spawn_id $spawn_id
 expect {
-	-re "Granted job allocation ($number)" {
+	-re "launching ($number).0" {
 		set job_id $expect_out(1,string)
+	}
+	timeout {
+		send_user "\nFAILURE: srun not responding\n"
+		slow_kill $srun_pid
+		exit 1
+	}
+}
+if {$job_id == 0} {
+	send_user "\nFAILURE: srun failed to create job\n"
+	exit 1
+}
+
+#
+# Send the program a message
+#
+spawn $scontrol notify $job_id TEST_NOTIFY
+expect {
+	-re "Invalid user id" {
+		set authorized 0
 		exp_continue
 	}
-	-re "$tmp_dir$end_of_line" {
+	eof {
+		wait
+	}
+}
+if {$authorized == 0} {
+	send_user "\nWARNING: You are not authorized to run this test\n"
+	cancel_job $job_id
+	exit 0
+}
+
+#
+# Look for the message
+#
+set matches 0
+set spawn_id $srun_spawn_id
+expect {
+	-re "TEST_NOTIFY" {
 		set matches 1
 		exp_continue
 	}
-	-re "Unable to contact" {
-		send_user "\nFAILURE: slurm appears to be down\n"
-		exit 1
-	}
 	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
+		send_user "\nFAILURE: srun not responding\n"
+		slow_kill $srun_pid
+		exit 1
 	}
 	eof {
 		wait
 	}
 }
-
-if {$matches != 1} {
-	send_user "\nFAILURE: slaunch failed to change working directory\n"
+if {$matches == 0} {
+	send_user "\nFAILURE: notification not received by srun\n"
 	set exit_code 1
 }
+	
+cancel_job $job_id
 if {$exit_code == 0} {
 	send_user "\nSUCCESS\n"
 }
diff --git a/testsuite/expect/test3.2 b/testsuite/expect/test3.2
index 417a97459c67160cc4b942d67e692e02007dadd7..8696ca4565ea5e9839310e25f4d86a93c7662ff0 100755
--- a/testsuite/expect/test3.2
+++ b/testsuite/expect/test3.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test3.3 b/testsuite/expect/test3.3
index ce6f8af163153fee74ed4b2a098e82ca114d8a96..9ccee66e77708982d72a11c933f033e99a8671a9 100755
--- a/testsuite/expect/test3.3
+++ b/testsuite/expect/test3.3
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test3.4 b/testsuite/expect/test3.4
index d968f266df26b8d85044faabd714330b48be4a67..dda1237d00634930374a9d322e66cbfe29ebe603 100755
--- a/testsuite/expect/test3.4
+++ b/testsuite/expect/test3.4
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -49,9 +49,9 @@ make_bash_script $file_in "$srun $bin_sleep 60"
 #
 # Submit a job so we have something to work with
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t1 --hold $file_in]
+set srun_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t1 --hold $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test3.5 b/testsuite/expect/test3.5
index 1d2412a9d2a78c57ba1e5256a43f520b9776ed35..3a41159da40cfd913fd4a7c54479eb85e7ffabc0 100755
--- a/testsuite/expect/test3.5
+++ b/testsuite/expect/test3.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test3.6 b/testsuite/expect/test3.6
index a64073c4ba96d879d03f182eeba6f2014fd34fbe..9b4896c655ae68056890ec977785f95f65a260a7 100755
--- a/testsuite/expect/test3.6
+++ b/testsuite/expect/test3.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test3.7 b/testsuite/expect/test3.7
index 1e0d425c4f3195350ce657b459546926ba26fce2..9d8b4f8841c8db67cb34f1725cd64e81493de785 100755
--- a/testsuite/expect/test3.7
+++ b/testsuite/expect/test3.7
@@ -11,7 +11,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -122,9 +122,9 @@ exec $bin_chmod 700 $file_prog
 #
 # Submit two jobs to the same node
 #
-set srun_pid [spawn $srun --batch -N1 -t1 --output=$file_out1 $file_prog_sh1]
+set srun_pid [spawn $sbatch -N1 -t1 --output=$file_out1 $file_prog_sh1]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
@@ -171,9 +171,9 @@ if {[string compare $host_name ""] == 0} {
 	exit 1
 }
 # Submit another job to that same node
-set srun_pid [spawn $srun --batch -N1 -t1 --output=$file_out2 $file_prog_sh2]
+set srun_pid [spawn $sbatch -N1 -t1 --output=$file_out2 $file_prog_sh2]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
diff --git a/testsuite/expect/test3.7.prog.c b/testsuite/expect/test3.7.prog.c
index a5e0280d3b80818c92f8d75a75a7c55b89839f60..489c3456447dada70ab3709efdfd931c8d32054b 100644
--- a/testsuite/expect/test3.7.prog.c
+++ b/testsuite/expect/test3.7.prog.c
@@ -7,7 +7,7 @@
  *  Copyright (C) 2005 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test3.8 b/testsuite/expect/test3.8
index 0bd675e1f7b17bb2e73007c668b80f60aa6d0c10..1d5b4e949c75ca1a81f92bba993127c34b3f253f 100755
--- a/testsuite/expect/test3.8
+++ b/testsuite/expect/test3.8
@@ -14,7 +14,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -84,15 +84,15 @@ if { [test_bluegene] } {
 # Spawn a srun batch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N$node_cnt --batch --output=$file_out --error=$file_err -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N$node_cnt --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
@@ -184,15 +184,15 @@ set job_id        0
 
 exec $bin_rm -f $file_flag_1 $file_flag_2 $file_flag_3 $file_flag_4
 
-set srun_pid [spawn $srun --no-requeue --batch --output=$file_out --error=$file_err -t1 $file_in]
+set sbatch_pid [spawn $sbatch --no-requeue --output=$file_out --error=$file_err -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test3.9 b/testsuite/expect/test3.9
index e6822c6065487983052c2fa6bc2f698edaa61b52..5f9cc1f4c43a76909a32dfe3aef75d8616e8c11a 100755
--- a/testsuite/expect/test3.9
+++ b/testsuite/expect/test3.9
@@ -10,7 +10,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.1 b/testsuite/expect/test4.1
index d3cfad3e2938df771e127fb59e2911436a2814c3..3fd1144df941945cad047bd2446342a36db37814 100755
--- a/testsuite/expect/test4.1
+++ b/testsuite/expect/test4.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.10 b/testsuite/expect/test4.10
index 6ce5f806e56468471cea411e3557b4761a072fb0..9e9affad6096e86b7a341b7563b8025888181d92 100755
--- a/testsuite/expect/test4.10
+++ b/testsuite/expect/test4.10
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.11 b/testsuite/expect/test4.11
index 83ac4fe7d848c5f9a6af1c3ca80211947991c520..ca4f488c34ebe75fbe5debab1a6f3937a52bb412 100755
--- a/testsuite/expect/test4.11
+++ b/testsuite/expect/test4.11
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.2 b/testsuite/expect/test4.2
index 4a078f4d852832390fd2e7e868377de7f631cfac..b5727a15f1d22b548baf6742f228dc71d077faf8 100755
--- a/testsuite/expect/test4.2
+++ b/testsuite/expect/test4.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.3 b/testsuite/expect/test4.3
index bc90494e8026dc60b91fd3b44f2542f06c9b344f..43bd867f60033b4028bbf29a9e2f149647ded1a4 100755
--- a/testsuite/expect/test4.3
+++ b/testsuite/expect/test4.3
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.4 b/testsuite/expect/test4.4
index 414f455aaffaecaa44b491c3c0702d49c153663f..49e714054d8a95ebee637d7e7f647c040d7a2b2a 100755
--- a/testsuite/expect/test4.4
+++ b/testsuite/expect/test4.4
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.5 b/testsuite/expect/test4.5
index 8245c81dd2a97955a5af5922e4faca8a460946b1..2c17640358f1e66f5e319ee9c64fad93ff6c1eb0 100755
--- a/testsuite/expect/test4.5
+++ b/testsuite/expect/test4.5
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.6 b/testsuite/expect/test4.6
index e129e28fdf55aa69e25192f681cb3cee91902b72..357ed35707c0851bd10155cf0b158e6bc6788cf4 100755
--- a/testsuite/expect/test4.6
+++ b/testsuite/expect/test4.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.7 b/testsuite/expect/test4.7
index 3489ee636ef067cad4af56c024a796a86e32eaf1..31e7e3be653a6cd381e5ac7b501af89bbe3ff7cc 100755
--- a/testsuite/expect/test4.7
+++ b/testsuite/expect/test4.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.8 b/testsuite/expect/test4.8
index 240106feba4ffeeb313b145dd1a585ea09dd3e99..e6c9452bd67591d2e25a40a4441effa4334a34b3 100755
--- a/testsuite/expect/test4.8
+++ b/testsuite/expect/test4.8
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test4.9 b/testsuite/expect/test4.9
index 00b4dc85fe39d791dc397d5de27277cfe8221083..c8599cd0474ef80649766622fd859617fa27cf7e 100755
--- a/testsuite/expect/test4.9
+++ b/testsuite/expect/test4.9
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test5.1 b/testsuite/expect/test5.1
index 0d542231aae67ea0eee4957c7c3d0e2452a131e1..df2e4c4b390091b7b1772bc9212025fe4641ded2 100755
--- a/testsuite/expect/test5.1
+++ b/testsuite/expect/test5.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test5.2 b/testsuite/expect/test5.2
index 1b1f313486ed9c2cbeefc406f210c50ae7c09087..a4c7cd94548be106891a6ae9e612ce77cc1f2892 100755
--- a/testsuite/expect/test5.2
+++ b/testsuite/expect/test5.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test5.3 b/testsuite/expect/test5.3
index 10f8a41d553aa37cb4ab5efae01b7018ce38b93e..85bc7d468131039ea9011850d47f18f168fbd095 100755
--- a/testsuite/expect/test5.3
+++ b/testsuite/expect/test5.3
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test5.4 b/testsuite/expect/test5.4
index 3bb4112c6b0182573970ac3d75067a1bca750f14..9258116b32276db9ca5933c617469b2020b41325 100755
--- a/testsuite/expect/test5.4
+++ b/testsuite/expect/test5.4
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -48,15 +48,15 @@ make_bash_script $file_in "$srun $bin_sleep 90"
 #
 # Submit a couple of job so we have something to look at
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -68,15 +68,15 @@ if {$job_id1 == 0} {
 	exit 1
 }
 
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --hold -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --hold -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test5.5 b/testsuite/expect/test5.5
index 0a33aa2b26ec15403a278282a2456e199a613345..34d224e235ad13cd410c6c19d609c3f7848f3860 100755
--- a/testsuite/expect/test5.5
+++ b/testsuite/expect/test5.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -49,15 +49,15 @@ make_bash_script $file_in "$srun $bin_sleep 10"
 #
 # Submit a couple of jobs so we have something to look at
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --job-name=$job_name1 -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --job-name=$job_name1 -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -69,15 +69,15 @@ if {$job_id1 == 0} {
 	exit 1
 }
 
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --job-name=$job_name2 --hold -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --job-name=$job_name2 --hold -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test5.6 b/testsuite/expect/test5.6
index c9d9c88056c7846eae3196140111942960a8a2ff..b6b74ac737fe0183813cfe2c5247f913d61aa553 100755
--- a/testsuite/expect/test5.6
+++ b/testsuite/expect/test5.6
@@ -11,7 +11,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -52,15 +52,15 @@ if { [test_bluegene] } {
 #
 # Submit a couple of job so we have something to look at
 #
-set srun_pid [spawn $srun --batch -N$node_cnt --output=/dev/null --error=/dev/null -t5 $file_in]
+set sbatch_pid [spawn $sbatch -N$node_cnt --output=/dev/null --error=/dev/null -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -72,15 +72,15 @@ if {$job_id1 == 0} {
 	exit 1
 }
 
-set srun_pid [spawn $srun --batch -N$node_cnt --output=/dev/null --error=/dev/null --hold -t5 $file_in]
+set sbatch_pid [spawn $sbatch -N$node_cnt --output=/dev/null --error=/dev/null --hold -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		cancel_job $job_id1
 		exit 1
 	}
@@ -149,7 +149,7 @@ expect {
 #
 spawn $bin_id -un 
 expect {
-	-re "($alpha_numeric)" {
+	-re "($alpha_numeric_under)" {
 		set this_user $expect_out(1,string)
 		exp_continue
 	}
@@ -159,7 +159,7 @@ expect {
 }
 spawn $squeue --format=%u --noheader --user=$this_user 
 expect {
-	-re "($alpha_numeric)" {
+	-re "($alpha_numeric_under)" {
 		if {[string compare $expect_out(1,string) $this_user]} {
 			send_user "\nFAILURE: squeue user filter failure\n"
 			set exit_code 1
@@ -190,7 +190,7 @@ expect {
 }
 spawn $squeue --format=%u --noheader --user=$this_uid
 expect {
-	-re "($alpha_numeric)" {
+	-re "($alpha_numeric_under)" {
 		if {[string compare $expect_out(1,string) $this_user]} {
 			send_user "\nFAILURE: squeue user filter failure\n"
 			set exit_code 1
@@ -211,7 +211,7 @@ expect {
 #
 spawn $squeue --format=%u --noheader --user=$this_uid --node=dummy_name
 expect {
-	-re "($alpha_numeric)" {
+	-re "($alpha_numeric_under)" {
 		send_user "\nFAILURE: squeue node filter failure\n"
 		set exit_code 1
 	}
@@ -227,7 +227,7 @@ expect {
 set node_name_set 0
 spawn $squeue --format=%N --noheader --jobs=$job_id1 --states=RUNNING
 expect {
-	-re "($alpha_numeric)" {
+	-re "($alpha_numeric_under)" {
 		set node_name $expect_out(1,string)
 		set node_name_set 1
 		exp_continue
@@ -243,7 +243,7 @@ expect {
 if {$node_name_set == 1} {
 	spawn $squeue --format=%u --noheader --user=$this_uid --node=$node_name
 	expect {
-		-re "($alpha_numeric)" {
+		-re "($alpha_numeric_under)" {
 			set node_name_set 0
 			exp_continue
 		}
@@ -269,11 +269,12 @@ set partition1 ""
 set partition2 ""
 spawn $squeue --format=%P --noheader 
 expect {
-	-re "($alpha_numeric)" {
+	-re "($alpha_numeric_under)" {
 		if {![string compare $partition1 ""]} {
 			set partition1 $expect_out(1,string)
+			exp_continue
 		}
-		if {[string compare $expect_out(1,string) $partition1]} {
+		if {![string compare $expect_out(1,string) $partition1]} {
 			set partition2 $expect_out(1,string)
 		}
 		exp_continue
@@ -287,11 +288,11 @@ expect {
 	}
 }
 if {[string compare partition2 ""]} {
-	set partition1 $partition2
+	set partition2 $partition1
 }
 spawn $squeue --format=%P --noheader --partitions=$partition1
 expect {
-	-re "($alpha_numeric)" {
+	-re "($alpha_numeric_under)" {
 		if {[string compare $expect_out(1,string) $partition1]} {
 			send_user "\nFAILURE: squeue partition filter error\n"
 			set exit_code 1
diff --git a/testsuite/expect/test5.7 b/testsuite/expect/test5.7
index 2a7ff3b5a62c39d0bb5ec29ebbb8384fbe098282..f5e0bb32c45aeb05884d8430689d43a3afafa700 100755
--- a/testsuite/expect/test5.7
+++ b/testsuite/expect/test5.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test5.8 b/testsuite/expect/test5.8
index d1fb63f7daf6c3ec152e61fbd47966e153069f32..51ca309f29243e85109a0adc7bd7b2e73b4c91a9 100755
--- a/testsuite/expect/test5.8
+++ b/testsuite/expect/test5.8
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test6.1 b/testsuite/expect/test6.1
index c37b6bd944928d727a5d18642784ffcaa5ea8be9..b983bc7315aecd7a691fc5cf122de765c81c032f 100755
--- a/testsuite/expect/test6.1
+++ b/testsuite/expect/test6.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test6.10 b/testsuite/expect/test6.10
index f5efd09425ff42d4ca06b939e9dc06ee96cd3d9f..ccbac2166d36e4f5af2fcc25df120efd9e705b07 100755
--- a/testsuite/expect/test6.10
+++ b/testsuite/expect/test6.10
@@ -14,7 +14,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -71,17 +71,17 @@ if { $got_login == 0 } {
 make_bash_script $file_in "$srun $bin_sleep $max_job_delay"
 
 #
-# Spawn a srun batch job
+# Spawn a sbatch job
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --hold -t5 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --hold -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test6.11 b/testsuite/expect/test6.11
index 64b30d755524ab705bed68a9f38c4d171c8f2288..c32482491a45d5f94bba1ea20913fad39cc00e81 100755
--- a/testsuite/expect/test6.11
+++ b/testsuite/expect/test6.11
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -38,18 +38,20 @@ set job_id       0
 
 print_header $test_id
 
+make_bash_script "id_script" { $bin_id }
+
 #
 # Submit a job so we have something to work with
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --hold -t1 $bin_id]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --hold -t1 id_script]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
@@ -121,6 +123,7 @@ expect {
 }
 
 if {$exit_code == 0} {
+	exec $bin_rm -f id_script
 	send_user "\nSUCCESS\n"
 }
 exit $exit_code
diff --git a/testsuite/expect/test6.12 b/testsuite/expect/test6.12
index bb10a827a110eb87aee215fe98ff8a00f36ba54d..191eef1b860cd739728ad9241e8891ae5c13171a 100755
--- a/testsuite/expect/test6.12
+++ b/testsuite/expect/test6.12
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -73,18 +73,18 @@ done
 "
 
 #
-# Spawn a srun batch job with arguments
+# Spawn a sbatch job with arguments
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err -t2 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out --error=$file_err -t2 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -158,15 +158,15 @@ file delete $file_out $file_err
 make_bash_script $file_in "$bin_sleep 500"
 
 set job_id 0
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err -t2 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out --error=$file_err -t2 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -236,15 +236,15 @@ set job_id      0
 file delete $file_out $file_err
 make_bash_script $file_in "$srun $bin_sleep 500"
 
-set srun_pid [spawn $srun --batch --output=$file_out --error=$file_err -t2 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out --error=$file_err -t2 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test6.13 b/testsuite/expect/test6.13
index b939416850e66bc46ba818a80db1cc451482c32a..9f41d43af601d79cc66e9524abf5dd4dedc29572 100755
--- a/testsuite/expect/test6.13
+++ b/testsuite/expect/test6.13
@@ -55,15 +55,15 @@ make_bash_script $file_in "
 # Submit a job so we have something to work with
 #
 set job_id 0
-set srun_pid [spawn $srun --batch --output=$file_out -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 		exp_continue
 	}
@@ -71,7 +71,10 @@ expect {
 		wait
 	}
 }
-
+if {$job_id == 0} {
+	send_user "\nFAILURE: job submission failed\n"
+	exit 1
+}
 if {[wait_for_job $job_id RUNNING] != 0} {
 	send_user "\nFAILURE: error starting job $job_id\n"
 	cancel_job $job_id
@@ -161,15 +164,15 @@ make_bash_script $file_in "
 # Submit a job so we have something to work with
 #
 set job_id 0
-set srun_pid [spawn $srun --batch --output=$file_out -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 		exp_continue
 	}
diff --git a/testsuite/expect/test6.2 b/testsuite/expect/test6.2
index 68a95184debbb2959eeea5c02be0a95d9743175d..770dccd3b64eb71b06442a202dbd8f83cbde5084 100755
--- a/testsuite/expect/test6.2
+++ b/testsuite/expect/test6.2
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test6.3 b/testsuite/expect/test6.3
index 3ee399fd02a0f327e5c88afaf17fddbf86003c85..f9146f72c0f87b6a736954dc4b7b07ede6fd48dd 100755
--- a/testsuite/expect/test6.3
+++ b/testsuite/expect/test6.3
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -47,15 +47,15 @@ make_bash_script $file_in "$srun $bin_sleep 600"
 #
 # Submit a job so we have something to work with
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test6.4 b/testsuite/expect/test6.4
index 8065dd1f6ab8253ab01c95316730624b4fc739fd..a8eae405eded89de46889b4596636d6e11c88bcb 100755
--- a/testsuite/expect/test6.4
+++ b/testsuite/expect/test6.4
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -47,15 +47,15 @@ make_bash_script $file_in "$srun $bin_sleep 10"
 #
 # Submit a couple of jobs so we have something to work with
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --job-name=job1 -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --job-name=job1 -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
@@ -67,15 +67,15 @@ if {$job_id1 == 0} {
 	exit 1
 }
 
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --job-name=job2 -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --job-name=job2 -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test6.5 b/testsuite/expect/test6.5
index 17d81980862fc617e4d1acacb8b584bc8005ad46..52675a60921f2f0ee1acc702a775c7ce77bbf67d 100755
--- a/testsuite/expect/test6.5
+++ b/testsuite/expect/test6.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -49,15 +49,15 @@ make_bash_script $file_in "$srun $bin_sleep 10"
 # Submit a couple of jobs so we have something to work with
 #
 set timeout 10
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -69,15 +69,15 @@ if {$job_id1 == 0} {
 	exit 1
 }
 
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test6.6 b/testsuite/expect/test6.6
index eb800069dc5f91570847c0f16500cb5ff0c1e6c3..ff9a2aa6c367daeda72ec2453ec9132444e8bf5b 100755
--- a/testsuite/expect/test6.6
+++ b/testsuite/expect/test6.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test6.7 b/testsuite/expect/test6.7
index 269e76c384321b47a8887705263599732218242d..bac8f26fe5a6968ccc067962860f51e0fe2f270b 100755
--- a/testsuite/expect/test6.7
+++ b/testsuite/expect/test6.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2002-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -54,22 +54,25 @@ make_bash_script $file_in "
 # Submit a job so we have something to work with
 #
 set job_id 0
-set srun_pid [spawn $srun --batch --output=$file_out -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
 		wait
 	}
 }
-
+if {$job_id == 0} {
+	send_user "\nFAILURE: error submitting job\n"
+	exit 1
+}
 if {[wait_for_job $job_id RUNNING] != 0} {
 	send_user "\nFAILURE: error starting job $job_id\n"
 	cancel_job $job_id
@@ -160,15 +163,15 @@ make_bash_script $file_in "
 # Submit a job so we have something to work with
 #
 set job_id 0
-set srun_pid [spawn $srun --batch --output=$file_out -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill srun_pid
+		slow_kill sbatch_pid
 		set exit_code 1
 		exp_continue
 	}
diff --git a/testsuite/expect/test6.8 b/testsuite/expect/test6.8
index 006285d458e481df6feeea714cbbab93ffbe64f8..ec2bb097fc073258fc8778f708bcf3c30ac40f55 100755
--- a/testsuite/expect/test6.8
+++ b/testsuite/expect/test6.8
@@ -13,7 +13,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -48,17 +48,17 @@ print_header $test_id
 make_bash_script $file_in "$srun $bin_sleep $max_job_delay"
 
 #
-# Spawn a couple of srun batch jobs
+# Spawn a couple of sbatch jobs
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --job-name=job.$test_id --hold -t5 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --job-name=job.$test_id --hold -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
@@ -70,15 +70,15 @@ if {$job_id1 == 0} {
 	exit 1
 }
 
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --job-name=job.$test_id -t5 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --job-name=job.$test_id -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test6.9 b/testsuite/expect/test6.9
index b9c7c699af6b92304b321ec461b7984950e21072..c1651e765a56fa47f501f80b9e09db6992a1f1e7 100755
--- a/testsuite/expect/test6.9
+++ b/testsuite/expect/test6.9
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -52,17 +52,17 @@ make_bash_script $file_in "
 "
 
 #
-# Spawn srun batch job
+# Spawn sbatch job
 #
-set srun_pid [spawn $srun --batch --output=/dev/null --error=/dev/null --job-name=job.$test_id -t5 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null --job-name=job.$test_id -t5 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test7.1 b/testsuite/expect/test7.1
index b4313b88f0bf9df4418500e6b4669968d2e39c3a..ab4923b0fd6ea4c2da6ed246ea3612da9f59b42f 100755
--- a/testsuite/expect/test7.1
+++ b/testsuite/expect/test7.1
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -42,48 +42,50 @@ set prio3                -1
 
 print_header $test_id
 
+make_bash_script "pwd_script" { $bin_pwd }
+
 #
-# Spawn three srun batch job, one held
+# Spawn three sbatch job, one held
 #
-set srun_pid [spawn $srun --batch -t1 --output=/dev/null --error=/dev/null  $bin_pwd]
+set sbatch_pid [spawn $sbatch -t1 --output=/dev/null --error=/dev/null  pwd_script]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
 		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
 		wait
 	}
 }
-set srun_pid [spawn $srun --batch -t1 --output=/dev/null --error=/dev/null $bin_pwd]
+set sbatch_pid [spawn $sbatch -t1 --output=/dev/null --error=/dev/null pwd_script]
 expect {
-        -re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
                 set job_id2 $expect_out(1,string)
                 exp_continue
         }
         timeout {
                 send_user "\nFAILURE: srun not responding\n"
-                slow_kill $srun_pid
+                slow_kill $sbatch_pid
                 exit 1
         }
         eof {
 		wait
         }
 }
-set srun_pid [spawn $srun --batch -t1 --output=/dev/null --error=/dev/null --hold $bin_pwd]
+set sbatch_pid [spawn $sbatch -t1 --output=/dev/null --error=/dev/null --hold pwd_script]
 expect {
-        -re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
                 set job_id3 $expect_out(1,string)
                 exp_continue
         }
         timeout {
                 send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		slow_kill $sbatch_pid
                 exit 1
         }
         eof {
@@ -169,6 +171,7 @@ if {$prio3 != 0} {
 }
 
 if {$exit_code == 0} {
+	exec $bin_rm -f pwd_script
 	send_user "\nSUCCESS\n"
 }
 exit $exit_code
diff --git a/testsuite/expect/test7.10 b/testsuite/expect/test7.10
index 67df1ba83ee29b076c7d512f758bfe69d8ad4894..bcfb40eb2e791dd94d33994a2bb5a04eb389ba87 100755
--- a/testsuite/expect/test7.10
+++ b/testsuite/expect/test7.10
@@ -11,7 +11,7 @@
 # Copyright (C) 2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.2 b/testsuite/expect/test7.2
index 0002e1e7b5a390561c0d589ea5bf0d2b1acf2123..6827f407531ec269f141bafd3786431e5c2cf619 100755
--- a/testsuite/expect/test7.2
+++ b/testsuite/expect/test7.2
@@ -1,8 +1,8 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of PMI functions available via API library. Uses srun and 
-#          slaunch. Tests --pmi-threads option in both commands.
+#          Test of PMI functions available via API library. Tests 
+#          --pmi-threads option in srun command.
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
@@ -11,7 +11,7 @@
 # Copyright (C) 2005-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -66,19 +66,19 @@ if { [test_bluegene] } {
 	}
 }
 
-# First test uses srun based task launch
+# Test uses srun based task launch
 # Adjust time limits as needed for large task counts */
 #                   times are here  vv 
 set timeout [expr $max_job_delay +  60]
 set srun_pid [spawn $srun -l -N$node_cnt -n$task_cnt -O -t1 --threads=1 $file_prog_get]
 expect {
 	-re "FAILURE" {
-		send_user "\nFAILURE: some error occured\n"
+		send_user "\nFAILURE: some error occurred\n"
 		set exit_code 1
 		exp_continue
 	}
 	-re "error" {
-		send_user "\nFAILURE: some error occured\n"
+		send_user "\nFAILURE: some error occurred\n"
 		set exit_code 1
 		exp_continue
 	}
@@ -92,39 +92,6 @@ expect {
 	}
 }
 
-# Second test uses slaunch based task launch
-# Adjust time limits as needed for large task counts */
-#                   times are here  vv 
-set timeout [expr $max_job_delay +  60]
-set job_id 0
-set salloc_pid [spawn $salloc -N$node_cnt -t1 $slaunch -n8 --overcommit -l --pmi-threads=3 $file_prog_get]
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-		exp_continue
-	}
-	-re "FAILURE" {
-		send_user "\nFAILURE: some error occured\n"
-		set exit_code 1
-		exp_continue
-	}
-	-re "error" {
-		send_user "\nFAILURE: some error occured\n"
-		set exit_code 1
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc not responding\n"
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
 if {$exit_code == 0} {
 	send_user "\nSUCCESS\n"
         exec $bin_rm -f $file_prog_get
diff --git a/testsuite/expect/test7.2.prog.c b/testsuite/expect/test7.2.prog.c
index 9c18cca82a2b27784989f14f8854b70d7aa87c6b..e3b2e34df5b21594bc45842f0d248512205cac64 100644
--- a/testsuite/expect/test7.2.prog.c
+++ b/testsuite/expect/test7.2.prog.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2005-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.3 b/testsuite/expect/test7.3
index 340e332805361c355dbf15a5aecec43def86e1ea..2fe04f5df123caf17d041353461470dc06a3416d 100755
--- a/testsuite/expect/test7.3
+++ b/testsuite/expect/test7.3
@@ -12,7 +12,7 @@
 # Copyright (C) 2004 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -55,7 +55,8 @@ exec $bin_chmod 700 $io_prog
 
 send_user "slurm_dir is $slurm_dir\n"
 if {![test_aix]} {
-	exec $bin_cc ${test_prog}.c -g -pthread -o ${test_prog} -I${slurm_dir}/include -Wl,--rpath=${slurm_dir}/lib -L${slurm_dir}/lib -lslurm
+	send_user "$bin_cc ${test_prog}.c -g -pthread -o ${test_prog} -I${slurm_dir}/include -Wl,--rpath=${slurm_dir}/lib -L${slurm_dir}/lib -lslurm\n"
+	exec       $bin_cc ${test_prog}.c -g -pthread -o ${test_prog} -I${slurm_dir}/include -Wl,--rpath=${slurm_dir}/lib -L${slurm_dir}/lib -lslurm
 } else {
 	send_user "$bin_cc ${test_prog}.c -Wl,-brtl -g -pthread -o ${test_prog} -I${slurm_dir}/include  -L${slurm_dir}/lib -lslurm -lntbl\n"
 	exec       $bin_cc ${test_prog}.c -Wl,-brtl -g -pthread -o ${test_prog} -I${slurm_dir}/include  -L${slurm_dir}/lib -lslurm -lntbl
diff --git a/testsuite/expect/test7.3.io.c b/testsuite/expect/test7.3.io.c
index e42c80a18073c113af1d3a30ddf8228a8e73eb67..0f3917aeae3927d3571b6a9fa3dfe3e1eb24c634 100644
--- a/testsuite/expect/test7.3.io.c
+++ b/testsuite/expect/test7.3.io.c
@@ -9,7 +9,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.3.prog.c b/testsuite/expect/test7.3.prog.c
index a29698bb36c1c8838115fb24b6874f8980f705ae..0089321c11e2bec87dde81f432a82918e122701a 100644
--- a/testsuite/expect/test7.3.prog.c
+++ b/testsuite/expect/test7.3.prog.c
@@ -8,7 +8,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -144,7 +144,7 @@ int main (int argc, char *argv[])
 	launch->user_managed_io = true; /* This is the key to using
 					  "user managed" IO */
 	
-	if (slurm_step_launch(ctx, launch, NULL) != SLURM_SUCCESS) {
+	if (slurm_step_launch(ctx, "", launch, NULL) != SLURM_SUCCESS) {
 		slurm_perror("slurm_step_launch");
 		rc = 1;
 		goto done;
diff --git a/testsuite/expect/test7.4 b/testsuite/expect/test7.4
index 72f130d30945cd786833f1587358f91a0e815558..6ffda3dd69dd93b3b79675d3c562c785fd664d6e 100755
--- a/testsuite/expect/test7.4
+++ b/testsuite/expect/test7.4
@@ -12,7 +12,7 @@
 # Copyright (C) 2004-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov> and Dong Ang <dahn@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.4.prog.c b/testsuite/expect/test7.4.prog.c
index d836d51e1637e080d8d96e7aeb8cfed12ef124d1..fc688154637d7d497cae5572ca30c659e55960db 100644
--- a/testsuite/expect/test7.4.prog.c
+++ b/testsuite/expect/test7.4.prog.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Dong Ang <dahn@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.5 b/testsuite/expect/test7.5
deleted file mode 100755
index 44a87f73c64f780652136754a00451bf99c61057..0000000000000000000000000000000000000000
--- a/testsuite/expect/test7.5
+++ /dev/null
@@ -1,304 +0,0 @@
-#!/usr/bin/expect
-############################################################################
-# Purpose: Test of SLURM functionality
-#          Test of TotalView operation with slaunch, with and without bulk
-#          transfer.
-#
-# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
-#          "WARNING: ..." with an explanation of why the test can't be made, OR
-#          "FAILURE: ..." otherwise with an explanation of the failure, OR
-#          anything else indicates a failure mode that must be investigated.
-############################################################################
-# Copyright (C) 2004-2006 The Regents of the University of California.
-# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
-# Written by Morris Jette <jette1@llnl.gov> and Dong Ang <dahn@llnl.gov>
-# UCRL-CODE-226842.
-# 
-# This file is part of SLURM, a resource management program.
-# For details, see <http://www.llnl.gov/linux/slurm/>.
-#  
-# SLURM is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option)
-# any later version.
-#
-# In addition, as a special exception, the copyright holders give permission
-# to link the code of portions of this program with the OpenSSL library under
-# certain conditions as described in each individual source file, and
-# distribute linked combinations including the two. You must obey the GNU
-# General Public License in all respects for all of the code used other than
-# OpenSSL. If you modify file(s) with this exception, you may extend this
-# exception to your version of the file(s), but you are not obligated to do
-# so. If you do not wish to do so, delete this exception statement from your
-# version.  If you delete this exception statement from all source files in
-# the program, then also delete it here.
-# 
-# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with SLURM; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-############################################################################
-source ./globals
-
-set test_id       "7.5"
-set exit_code     0
-set test_prog     "test$test_id.prog"
-
-print_header $test_id
-
-#
-# Test for existence of mpi compiler and totalview
-#
-if {[info exists mpicc] == 0} {
-	send_user "\nWARNING: mpicc not defined, can't perform mpi testing\n"
-	exit 0
-}
-if {[file executable $mpicc] == 0} {
-	send_user "\nWARNING: $mpicc does not exists\n"
-	exit 0
-}
-if {[info exists totalviewcli] == 0} {
-	send_user "\nWARNING: totalviewcli not defined, can't perform mpi testing\n"
-	exit 0
-}
-if {[file executable $totalviewcli] == 0} {
-	send_user "\nWARNING: $totalviewcli does not exists\n"
-	exit 0
-}
-if {[test_front_end] != 0} {
-        send_user "\nWARNING: This test is incompatable with front-end systems\n"
-        exit 0
-}
-if {[test_aix] == 1} {
-	send_user "WARNING: Test is incompatible with AIX\n"
-	exit 0
-}
-
-#
-# Put desired SLURM install directory at head of search path for bulk launch
-# command to work (runs "slaunch" without path)
-#
-global env
-set env(PATH) "$slurm_dir/bin:$env(PATH)"
-send_user "\n $env(PATH)\n"
-
-#
-# Delete left-over program and rebuild it
-#
-exec $bin_rm -f $test_prog ${test_prog}.o ${test_prog}.TVD.v3breakpoints
-exec $mpicc -o $test_prog ${test_prog}.c
-
-#
-# Create the slurm job allocation
-#
-set job_id  0
-set matches 0
-set no_capability 0
-set timeout $max_job_delay
-set salloc_pid [spawn $salloc -N1-2 -t1 $bin_bash]
-set salloc_spawn_id $spawn_id
-expect {
-	-re "Granted job allocation ($number)" {
-		set job_id $expect_out(1,string)
-	}
-	timeout {
-		if {$job_id != 0} {
-			cancel_job $job_id
-		}
-		slow_kill [expr 0 - $salloc_pid]
-	}
-}
-if {$job_id == 0} {
-	send_user "\nFAILURE: failed to create job allocation\n"
-	exit 1
-}
-
-# Note this appears as a single argv value to totalviewcli
-set bulk "set issue_dgo false; dset TV::bulk_launch_enabled true; dset TV::bulk_launch_string {$slaunch --jobid=%J -N%N -n%N -w`awk -F. \'BEGIN {ORS=\",\"} {if (NR==%N) ORS=\"\"; print \$1}\' %t1` -l -i /dev/null %B/tvdsvr%K -callback_host %H -callback_ports %L -set_pws %P -verbosity %V -working_directory %D %F}"
-set no_bulk "set issue_dgo false; dset TV::bulk_launch_enabled false"
-
-#
-# Now run totalviewcli (command line interface to TotalView)
-#
-send_user "======================================================================\n"
-send_user "=======================  Run without bulk transfer ===================\n"
-send_user "======================================================================\n"
-spawn $totalviewcli -verbosity info -e $no_bulk $slaunch -a --jobid $job_id -v -i /dev/null -n4 --overcommit $test_prog
-expect {
-	-re "d1.<>" {
-		if {$matches == 0} {
-			incr matches
-			send "G\n"
-		}
-		if {$no_capability != 0} {
-			send "quit\n"
-		}
-		exp_continue
-	}
-	-re "cannot open shared object" {
-		send_user "\nWARNING: Set LD_LIBRARY_PATH environment variable "
-		send_user "to include this object's directory\n"
-		exp_continue
-	}
-	-re "Do you want to stop the job now?.*:" {
-		incr matches
-		send "yes\n"
-		exp_continue
-	}
-	-re "Attached to parallel task ($number)" {
-		incr matches
-		exp_continue
-	}
-	-re "Loaded MPI support.*" {
-		exec sleep 2
-		send "G\n"
-		exp_continue
-	}
-	-re "I just received msg from Rank" {
-		incr matches
-		exp_continue
-	}
-	-re "elan_init: No capability, can't continue" {
-		incr no_capability
-		exp_continue
-	}
-	-re "Process 1 has exited.*" {
-		incr matches
-		exec sleep 2
-		send "quit\n"
-		exp_continue
-	}
-	-re "Do you really wish to exit TotalView?" {
-		incr matches
-		send "yes\n"
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: totalviewcli not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-if {$no_capability != 0} {
-	send_user "\nWARNING: Unable to run test with present configuration\n"
-	exit 0
-}
-if {$matches != 12} {
-	send_user "\nFAILURE: totalviewcli operation matches $matches of 12\n"
-	send_user "Remove your ~/.totalview directory and try again\n"
-	set exit_code 1
-} else {
-	send_user "\nSo far, so good...\n\n\n"
-}
-
-#
-# Now run totalviewcli (command line interface to TotalView)
-#
-set matches 0
-set no_capability 0
-send_user "======================================================================\n"
-send_user "=====================  Run with bulk transfer ========================\n"
-send_user "======================================================================\n"
-spawn $totalviewcli -verbosity info -e $bulk $slaunch -a --jobid $job_id -i /dev/null -n4 --overcommit $test_prog
-expect {
-	-re "d1.<>" {
-		if {$matches == 0} {
-			incr matches
-			send "G\n"
-		}
-		if {$no_capability != 0} {
-			send "quit\n"
-		}
-		exp_continue
-	}
-	-re "cannot open shared object" {
-		send_user "\nWARNING: Set LD_LIBRARY_PATH environment variable "
-		send_user "to include this object's directory\n"
-		exp_continue
-	}
-	-re "Do you want to stop the job now?.*:" {
-		incr matches
-		send "yes\n"
-		exp_continue
-	}
-	-re "Attached to parallel task ($number)" {
-		incr matches
-		exp_continue
-	}
-	-re "Loaded MPI support.*" {
-		exec sleep 2
-		send "G\n"
-		exp_continue
-	}
-	-re "I just received msg from Rank" {
-		incr matches
-		exp_continue
-	}
-	-re "elan_init: No capability, can't continue" {
-		incr no_capability
-		exp_continue
-	}
-	-re "Process 1 has exited.*" {
-		incr matches
-		exec sleep 2
-		send "quit\n"
-		exp_continue
-	}
-	-re "Do you really wish to exit TotalView?" {
-		incr matches
-		send "yes\n"
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: totalviewcli not responding\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-#
-# Check the results of bulk transfer test above
-#
-if {$no_capability != 0} {
-	send_user "\nWARNING: Unable to run test with present configuration\n"
-} else {
-	if {$matches != 12} {
-		send_user "\nFAILURE: totalviewcli operation matches $matches of 12\n"
-		send_user "Remove your ~/.totalview directory and try again\n"
-		set exit_code 1
-	}
-}
-
-#
-# terminate the job
-#
-cancel_job $job_id
-set spawn_id $salloc_spawn_id
-expect {
-	-re "Job allocation $job_id has been revoked." {
-		send "exit\n"
-		exp_continue
-	}
-	timeout {
-		send_user "\nFAILURE: salloc did not terminate as expected\n"
-		set exit_code 1
-	}
-	eof {
-		wait
-	}
-}
-
-
-if {$exit_code == 0} {
-	exec $bin_rm -f $test_prog ${test_prog}.o ${test_prog}.TVD.b3breakpoints
-	send_user "\nSUCCESS\n"
-}
-exit $exit_code
diff --git a/testsuite/expect/test7.5.prog.c b/testsuite/expect/test7.5.prog.c
deleted file mode 100644
index fb7d5323b6fa86605c9e2ad4dbf71a9ffc135b8f..0000000000000000000000000000000000000000
--- a/testsuite/expect/test7.5.prog.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************************\
- *  test7.5.prog.c - Test of TotalView operation with SLURM.
- *****************************************************************************
- *  Copyright (C) 2004 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Dong Ang <dahn@llnl.gov>
- *  UCRL-CODE-226842.
- *  
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *  
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *  
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *  
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
-\*****************************************************************************/
-
-#include <stdio.h>
-#include <mpi.h>
-
-#define COMM_TAG 1000
-
-static void pass_its_neighbor(const int rank, const int size, const int* buf)
-{
-	MPI_Request request[2];
-	MPI_Status status[2];
-
-	MPI_Irecv((void *)buf, 1, MPI_INT, ((rank+size-1)%size), COMM_TAG,
-		MPI_COMM_WORLD, &request[0]);
-	MPI_Isend((void *)&rank, 1, MPI_INT, ((rank+1)%size), COMM_TAG,
-		MPI_COMM_WORLD, &request[1]);
-	MPI_Waitall(2, request, status);
-
-	fprintf(stdout, "Rank[%d] I just received msg from Rank %d\n", 
-		rank, *buf);
-}
-
-int main(int argc, char * argv[])
-{
-	int size, rank,buf;
-
-	MPI_Init(&argc, &argv);
-	MPI_Comm_size(MPI_COMM_WORLD, &size);
-	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-
-	buf = rank;	/* we only pass rank */
-
-	pass_its_neighbor(rank, size, &buf);
-
-	MPI_Finalize();
-	return 0;
-}
-
diff --git a/testsuite/expect/test7.6 b/testsuite/expect/test7.6
index 84eb5b7af4c5a095dee0fb0d7d87d6cf2ca6f065..dee627741ee3106440486fd51633fac49157f1a7 100755
--- a/testsuite/expect/test7.6
+++ b/testsuite/expect/test7.6
@@ -11,7 +11,7 @@
 # Copyright (C) 2004-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov> and Dong Ang <dahn@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -98,7 +98,7 @@ exec $mpicc -o $test_prog ${test_prog}.c
 #
 # Create a slurm job step
 #
-set salloc_pid [spawn $salloc -N1-2 -t1 $slaunch --input=none -n4 --overcommit $test_prog]
+set salloc_pid [spawn $salloc -N1-2 -t1 $srun --input=none -n4 --overcommit ./$test_prog]
 expect {
 	-re "Granted job allocation ($number)" {
 		set job_id $expect_out(1,string)
diff --git a/testsuite/expect/test7.6.prog.c b/testsuite/expect/test7.6.prog.c
index 6f6d7ef93c05c3a7f3a31dae9e3f305b29de0a2b..f2afcc281d1542a8c8ef5408e6658d0389484531 100644
--- a/testsuite/expect/test7.6.prog.c
+++ b/testsuite/expect/test7.6.prog.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Dong Ang <dahn@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.7 b/testsuite/expect/test7.7
index a594d00c15e67954ca7da56bfc0bf13e22278094..c9e2969a5c90c4d587efc6ca2eb819b346254e7a 100755
--- a/testsuite/expect/test7.7
+++ b/testsuite/expect/test7.7
@@ -12,7 +12,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -136,6 +136,12 @@ if {$agg_time != 0} {
 }
 #send_user "\nAuthKey=$auth_key\nEPort=$e_port\n"
 
+if { [test_bluegene] } {
+	set is_bluegene 1
+} else {
+	set is_bluegene 0
+}
+
 #
 # Submit a job to work with
 #
@@ -147,15 +153,15 @@ make_bash_script $file_in "
   exit 123"
 set job_id1 0
 set job_id2 0
-set srun_pid [spawn $srun -N1-6 --output=$file_out --comment=test --batch -t1 $file_in]
+set sbatch_pid [spawn $sbatch -N1-1024 --output=$file_out --comment=test -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id1 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		catch {exec $bin_kill -KILL $srun_pid}
+		send_user "\nFAILURE: sbatch not responding\n"
+		catch {exec $bin_kill -KILL $sbatch_pid}
 		set exit_code 1
 	}
 	eof {
@@ -174,7 +180,7 @@ set timeout 60
 exec $bin_rm -f $test_prog
 exec $bin_make -f /dev/null $test_prog
 set success 0
-set moab_pid [spawn $test_prog $auth_key $control_addr $e_port $job_id1 $sched_port]
+set moab_pid [spawn $test_prog $auth_key $control_addr $e_port $job_id1 $sched_port $is_bluegene]
 set master_id $spawn_id
 expect {
 	-re "READY" {
@@ -192,15 +198,15 @@ expect {
 	}
 }
 
-set srun_pid [spawn $srun --output=/dev/null --batch -t1 $file_in]
+set sbatch_pid [spawn $sbatch --output=/dev/null -t1 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id2 $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		catch {exec $bin_kill -KILL $srun_pid}
+		send_user "\nFAILURE: sbatch not responding\n"
+		catch {exec $bin_kill -KILL $sbatch_pid}
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test7.7.prog.c b/testsuite/expect/test7.7.prog.c
index 438a76100b68cea4e4dae6484e30eacd2fd89355..cc8a536858b54c702e6dc654f2885ea9747c66bf 100644
--- a/testsuite/expect/test7.7.prog.c
+++ b/testsuite/expect/test7.7.prog.c
@@ -2,9 +2,10 @@
  *  test7.7.prog.c - Test of sched/wiki2 plugin
  *****************************************************************************
  *  Copyright (C) 2006-2007 The Regents of the University of California.
+ *  Copyright (C) 2008 Lawrence Livermore National Security.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -33,9 +34,11 @@
 
 #include "./test7.7.crypto.c"
 
+#define _DEBUG 0
+
 /* global variables */
 char *auth_key, *control_addr;
-int   e_port, sched_port;
+int   e_port, is_bluegene, sched_port;
 long  job_id;
 
 static int _conn_wiki_port(char *host, int port)
@@ -333,6 +336,7 @@ static void _modify_job(long my_job_id)
 		"TS=%u AUTH=root DT=CMD=MODIFYJOB ARG=%ld "
 		/* "MINSTARTTIME=55555 " */
 		/* "JOBNAME=foo " */
+		/* "RFEATURES=big " */
 		/* "PARTITION=pdebug " */
 		/* "NODES=2 " */ 
 		/* "DEPEND=afterany:3 " */
@@ -349,7 +353,7 @@ static void _notify_job(long my_job_id)
 
 	snprintf(out_msg, sizeof(out_msg),
 		"TS=%u AUTH=root DT=CMD=NOTIFYJOB ARG=%ld "
-		"MSG=this is a test",
+		"MSG=this_is_a_test",
 		(uint32_t) now, my_job_id);
 	_xmit(out_msg);
 }
@@ -382,9 +386,9 @@ static void _job_will_run(long my_job_id)
 	char out_msg[128];
 
 	snprintf(out_msg, sizeof(out_msg),
-		"TS=%u AUTH=root DT=CMD=JOBWILLRUN ARG=%ld %s",
+		"TS=%u AUTH=root DT=CMD=JOBWILLRUN ARG=JOBID=%ld,%s",
 		(uint32_t) now, my_job_id,
-		"TASKLIST=");	/* put desired node list here */
+		"");		/* put available node list here */
 	_xmit(out_msg);
 }
 
@@ -394,16 +398,28 @@ static void _initialize(void)
 	char out_msg[128];
 
 	snprintf(out_msg, sizeof(out_msg),
-		"TS=%u AUTH=root DT=CMD=INITIALIZE ARG=USEHOSTEXP=T EPORT=%u",
+		"TS=%u AUTH=root DT=CMD=INITIALIZE ARG=USEHOSTEXP=N EPORT=%u",
 		(uint32_t) now, e_port);
 	_xmit(out_msg);
 }
 
+static void _single_msg(void)
+{
+	time_t now = time(NULL);
+	char out_msg[1024];
+
+	snprintf(out_msg, sizeof(out_msg),
+		"TS=%u AUTH=root DT=CMD=%s",
+		(uint32_t) now, 
+		"JOBWILLRUN ARG=JOBID=65537,bgl[000x733] JOBID=65539,bgl[000x733] JOBID=65538,bgl[000x733]");
+	_xmit(out_msg);
+}
+
 int main(int argc, char * argv[])
 {
-	if (argc < 4) {
+	if (argc < 6) {
 		printf("Usage: %s, auth_key control_addr e_port "
-			"job_id sched_port\n", argv[0]);
+			"job_id sched_port is_bluegene\n", argv[0]);
 		exit(1);
 	}
 
@@ -412,20 +428,27 @@ int main(int argc, char * argv[])
 	e_port       = atoi(argv[3]);
 	job_id       = atoi(argv[4]);
 	sched_port   = atoi(argv[5]);
-	printf("auth_key=%s control_addr=%s e_port=%d job_id=%d sched_port=%d\n", 
-		auth_key, control_addr, e_port, job_id, sched_port);
-
+	is_bluegene  = atoi(argv[6]);
+	printf("auth_key=%s control_addr=%s e_port=%d job_id=%d sched_port=%d "
+		"is_bluegene=%d\n", 
+		auth_key, control_addr, e_port, job_id, sched_port, is_bluegene);
+
+#if _DEBUG
+	_single_msg();
+#else
 	_initialize();
 	_get_jobs();
 	_get_nodes();
 	_job_will_run(job_id);
 	_modify_job(job_id);
-	/* _notify_job(65544); */
 	_get_jobs();
 	_start_job(job_id);
 	_get_jobs();
-	_suspend_job(job_id);
-	_resume_job(job_id);
+	if (!is_bluegene) {
+		_suspend_job(job_id);
+		_resume_job(job_id);
+	}
+	_notify_job(job_id);
 	_signal_job(job_id);
 	if (e_port)
 		_event_mgr();
@@ -438,7 +461,7 @@ int main(int argc, char * argv[])
 	sleep(15);
 	_start_job(job_id);
 	_get_jobs();
-
+#endif
 	printf("SUCCESS\n");
 	exit(0);
 }
diff --git a/testsuite/expect/test7.8 b/testsuite/expect/test7.8
index 8f5c0a134c203c43b46b3566700a5983c277bdda..17c66fa5ee9e732067e57fdb00f1f21a5831fc22 100755
--- a/testsuite/expect/test7.8
+++ b/testsuite/expect/test7.8
@@ -12,7 +12,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.8.prog.c b/testsuite/expect/test7.8.prog.c
index d88ca12450c9d535e0d57d44872910796533feee..4f40119664b992684b15e201ee4e537e9ba8f438 100644
--- a/testsuite/expect/test7.8.prog.c
+++ b/testsuite/expect/test7.8.prog.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test7.9 b/testsuite/expect/test7.9
index f8eb960b2521c749768eeac3ff54ea3256f5c907..e58d5243a5952d95a26a3f5024c35d2136354ea0 100755
--- a/testsuite/expect/test7.9
+++ b/testsuite/expect/test7.9
@@ -11,7 +11,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -102,6 +102,7 @@ make_bash_script $file_in "
   for ((i=0; i<$iterations; i++)) ; do
     $srun $file_prog
   done
+  $bin_echo 'fini'
 "
 
 set job_id 0
@@ -134,6 +135,7 @@ if {[wait_for_job $job_id "DONE"] != 0} {
 if {[wait_for_file $file_out] != 0} {
 	exit 1
 }
+set fini    0
 set matches 0
 spawn $bin_cat $file_out
 expect {
@@ -141,6 +143,10 @@ expect {
 		incr matches
 		exp_continue
 	}
+	-re "fini" {
+		set fini 1
+		exp_continue
+	}
 	timeout {
 		send_user "\nFAILURE: /bin/cat not responding\n"
 		set exit_code 1
@@ -149,6 +155,10 @@ expect {
 		wait
 	}
 }
+if {$fini != 1} {
+	send_user "\nFAILURE: script never completed\n"
+	set exit_code 1
+}
 if {$matches != 0} {
 	set tot [expr $iterations + 1]
 	if {$matches <= 1} {
diff --git a/testsuite/expect/test7.9.prog.c b/testsuite/expect/test7.9.prog.c
index 11e844c781bc8e3c88f5ce31d6b336deec55ca10..dc01a5e24dad18f40fe9f2715892881f434e5d76 100644
--- a/testsuite/expect/test7.9.prog.c
+++ b/testsuite/expect/test7.9.prog.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -32,7 +32,8 @@
 #include <time.h>
 #include <unistd.h>
 
-#define _DEBUG 0
+#define _DEBUG         0
+#define _EXTREME_DEBUG 0
 
 main (int argc, char **argv) 
 {
@@ -51,16 +52,17 @@ main (int argc, char **argv)
 		printf("FAILED: File descriptor %d is open\n", i);
 #if _DEBUG
 {
-		char data[64];
-		int j;
-		size_t data_size;
-
 		printf("  st_mode:    0%o\n",(int) buf.st_mode);
 		printf("  st_uid:     %d\n", (int) buf.st_uid);
 		printf("  st_gid:     %d\n", (int) buf.st_gid);
 		printf("  st_size:    %d\n", (int) buf.st_size);
 		printf("  st_ino:     %d\n", (int) buf.st_ino);
 		printf("  st_dev:     %d\n", (int) buf.st_dev);
+#if _EXTREME_DEBUG
+	{
+		char data[64];
+		int j;
+		size_t data_size;
 
 		lseek(i, 0, SEEK_SET);
 		data_size = read(i, data, 64);
@@ -71,6 +73,8 @@ main (int argc, char **argv)
 			for (j=0; j<data_size; j++)
 				printf("  data[%d]:0x%x\n", j, data[j]);
 		}
+	}
+#endif
 }
 #endif
 	}
diff --git a/testsuite/expect/test8.1 b/testsuite/expect/test8.1
index ea2c05e4f05967571f42fc7665ed597b9d2d895f..30ef18be376069d69e4858ab64a92a8e237ce046 100755
--- a/testsuite/expect/test8.1
+++ b/testsuite/expect/test8.1
@@ -1,7 +1,7 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of Blue Gene specific srun command line options
+#          Test of Blue Gene specific sbatch command line options
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
@@ -10,7 +10,7 @@
 # Copyright (C) 2004 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -58,14 +58,14 @@ exec echo "$bin_sleep 1 &"     >>$file_in
 exec $bin_chmod 700 $file_in
 
 #
-# Submit a slurm job using various srun options for blue gene
+# Submit a slurm job using various sbatch options for blue gene
 #
 set timeout $max_job_delay
 
 for {set inx 0} {$inx < $cycle_count} {incr inx} {
-	set srun_pid [spawn $srun -N$num_nodes --geometry=$geometry --no-rotate --conn-type=$connection --batch --output=/dev/null --error=/dev/null $file_in]
+	set sbatch_pid [spawn $sbatch -N$num_nodes --geometry=$geometry --no-rotate --conn-type=$connection --output=/dev/null --error=/dev/null $file_in]
 	expect {
-		-re "jobid ($number) submitted" {
+		-re "Submitted batch job ($number)" {
 			set job_id $expect_out(1,string)
 			set inx $cycle_count
 			exp_continue
@@ -76,8 +76,8 @@ for {set inx 0} {$inx < $cycle_count} {incr inx} {
 			exp_continue
 		}
 		timeout {
-			send_user "\nFAILURE: srun not responding\n"
-			slow_kill $srun_pid
+			send_user "\nFAILURE: sbatch not responding\n"
+			slow_kill $sbatch_pid
 			exit 1
 		}
 		eof {
@@ -133,15 +133,15 @@ cancel_job $job_id
 #
 set job_id      0
 set timeout $max_job_delay
-set srun_pid [spawn $srun -N$num_nodes --geometry=$geometry --no-rotate --conn-type=$connection --batch --output=/dev/null --error=/dev/null $file_in]
+set sbatch_pid [spawn $sbatch -N$num_nodes --geometry=$geometry --no-rotate --conn-type=$connection --output=/dev/null --error=/dev/null $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test8.2 b/testsuite/expect/test8.2
index bcb8488aff70c0e605d79a38530d34eef36807bc..64f630a12e0d82092a9efd31e6913014c830a55d 100755
--- a/testsuite/expect/test8.2
+++ b/testsuite/expect/test8.2
@@ -1,7 +1,7 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test of Blue Gene specific srun environment variables
+#          Test of Blue Gene specific sbatch environment variables
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -48,9 +48,9 @@ if {[test_bluegene] == 0} {
 # Set target environment variables
 #
 global env
-set env(SLURM_CONN_TYPE)    torus
-set env(SLURM_GEOMETRY)     1x1x1
-set env(SLURM_NO_ROTATE)    1
+set env(SBATCH_CONN_TYPE)    torus
+set env(SBATCH_GEOMETRY)     1x1x1
+set env(SBATCH_NO_ROTATE)    1
 
 #
 # Delete left-over input script files
@@ -65,15 +65,15 @@ exec $bin_chmod 700 $file_in
 # Spawn a job via srun using these environment variables
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun --batch --output=$file_out --error=/dev/null $file_in]
+set sbatch_pid [spawn $sbatch --output=$file_out --error=/dev/null $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test8.3 b/testsuite/expect/test8.3
index 54d30905f6dbe7c69bf2f1e2a8cc596dd55e2c96..f5ab3ebbec06489c7695257dd3adbeac78e86879 100755
--- a/testsuite/expect/test8.3
+++ b/testsuite/expect/test8.3
@@ -13,7 +13,7 @@
 # Copyright (C) 2004 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -59,9 +59,9 @@ exec $bin_chmod 700 $file_in
 # Submit a slurm job for blue gene with geometry of 2x1x1
 #
 set timeout $max_job_delay
-set srun_pid [spawn $srun --geometry=2x1x1 --no-rotate --nodes=1k-1k --batch --output=/dev/null --error=/dev/null $file_in]
+set sbatch_pid [spawn $sbatch --geometry=2x1x1 --no-rotate --nodes=1k-1k --output=/dev/null --error=/dev/null $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
@@ -70,8 +70,8 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -114,9 +114,9 @@ if {$job_id != 0} {
 # Submit a slurm job for blue gene with geometry of 1x2x1
 #
 set jobid 0
-set srun_pid [spawn $srun --geometry=1x2x1 --no-rotate --nodes=1k-1k --batch --output=/dev/null --error=/dev/null $file_in]
+set sbatch_pid [spawn $sbatch --geometry=1x2x1 --no-rotate --nodes=1k-1k --output=/dev/null --error=/dev/null $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
@@ -125,8 +125,8 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -166,9 +166,9 @@ if {$job_id != 0} {
 # Submit a slurm job for blue gene with geometry of 1x1x2
 #
 set jobid 0
-set srun_pid [spawn $srun --geometry=1x1x2 --no-rotate --nodes=1k-1k --batch --output=/dev/null --error=/dev/null $file_in]
+set sbatch_pid [spawn $sbatch --geometry=1x1x2 --no-rotate --nodes=1k-1k --output=/dev/null --error=/dev/null $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
@@ -177,8 +177,8 @@ expect {
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
diff --git a/testsuite/expect/test8.4 b/testsuite/expect/test8.4
index 72039852410eecdea5f2624523ad1b2a4001771c..e96045fd010440a6d3e6d6f495e7c3898c37d986 100755
--- a/testsuite/expect/test8.4
+++ b/testsuite/expect/test8.4
@@ -14,7 +14,7 @@
 # Copyright (C) 2004 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -85,13 +85,13 @@ exec echo "$bin_echo TEST_COMPLETE"			>>$file_in
 exec $bin_chmod 700 $file_in
 
 #
-# Spawn a srun batch job that uses stdout/err and confirm their contents
+# Spawn an sbatch job that uses stdout/err and confirm their contents
 #
 set timeout $max_job_delay
 set no_start 0
-set srun_pid [spawn $srun -N1-1 --batch --output=$file_out --error=$file_err -t4 $file_in]
+set sbatch_pid [spawn $sbatch -N1-1 --output=$file_out --error=$file_err -t4 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
@@ -104,8 +104,8 @@ expect {
 		exit 1
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		slow_kill $srun_pid
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		set exit_code 1
 	}
 	eof {
diff --git a/testsuite/expect/test8.4.prog.c b/testsuite/expect/test8.4.prog.c
index 25ae9da0fe9dbb9b35cfb69171a600bf05a4ff9f..c5b704cc81eab48b2fe091eb255c5f0702efb159 100644
--- a/testsuite/expect/test8.4.prog.c
+++ b/testsuite/expect/test8.4.prog.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Dong Ang <dahn@llnl.gov>
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *  
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test8.5 b/testsuite/expect/test8.5
index 6db642750fe77c70635809e6b2df16c7c9fc426a..b86b03569660f6934054284952e3241471c6c012 100755
--- a/testsuite/expect/test8.5
+++ b/testsuite/expect/test8.5
@@ -10,7 +10,7 @@
 # Copyright (C) 2006-2007 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,15 +62,15 @@ set timeout [expr $max_job_delay + $sleep_time]
 
 # make a 512 cnode block
 
-spawn $srun --batch --output=$file_out --error=$file_err -t2 -N512-512 $file_in
+set sbatch_pid [spawn $sbatch --output=$file_out --error=$file_err -t2 -N512-512 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		kill_srun
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -127,15 +127,15 @@ if {$exit_code != 0} {
 # make a 128 cnode block
 
 
-spawn $srun --batch --output=$file_out --error=$file_err -t2 -N128-128 $file_in
+set sbatch_pid [spawn $sbatch --output=$file_out --error=$file_err -t2 -N128-128 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		kill_srun
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -195,15 +195,15 @@ if {$matches != 1} {
 
 # make a 32 cnode block
 
-spawn $srun --batch --output=$file_out --error=$file_err -t2 -N32-32 $file_in
+set sbatch_pid [spawn $sbatch --output=$file_out --error=$file_err -t2 -N32-32 $file_in]
 expect {
-	-re "jobid ($number) submitted" {
+	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
 	}
 	timeout {
-		send_user "\nFAILURE: srun not responding\n"
-		kill_srun
+		send_user "\nFAILURE: sbatch not responding\n"
+		slow_kill $sbatch_pid
 		exit 1
 	}
 	eof {
@@ -226,7 +226,8 @@ if {[wait_for_job $job_id "DONE"] != 0} {
 set matches 0
 spawn $scontrol show job $job_id
 expect {
-	-re "BP_List=$alpha_numeric\[$number-$number\]" {
+#	Could be one or multiple node cards (e.g. "bgl000[0]" or "bgl000[0-1]")
+	-re "BP_List=$alpha_numeric\[$number" {
 		incr matches
 		exp_continue
 	}
diff --git a/testsuite/expect/test8.6 b/testsuite/expect/test8.6
index 1834f6d982b4a229268b6a03decc3431799f60f4..91c0ef46e43f4a8d2687ecc9b21677fa8d88c738 100755
--- a/testsuite/expect/test8.6
+++ b/testsuite/expect/test8.6
@@ -10,7 +10,7 @@
 # Copyright (C) 2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Danny Auble <da@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -39,9 +39,9 @@ set matches     0
 set 32node_block_cnt 16
 set 128node_block_cnt 8
 set 512node_block_cnt 8
-set 1knode_block_cnt 8
-set 4knode_block_cnt 8
-set 8knode_block_cnt 8
+set 1knode_block_cnt  8
+set 4knode_block_cnt  8
+set 8knode_block_cnt  8
 set 16knode_block_cnt 8
 set 32knode_block_cnt 8
 
@@ -55,33 +55,25 @@ if {[test_bluegene] == 0} {
 	exit $exit_code
 }
 
-#
-# Delete left-over input script files
-# Build input script file
-#
-exec $bin_rm -f $file_in
-exec echo "#!$bin_bash"    >$file_in
-exec echo "$bin_sleep $sleep_time "     >>$file_in
-exec $bin_chmod 700 $file_in
-
-#
+make_bash_script $file_in "$bin_sleep $sleep_time"
 set timeout [expr $max_job_delay + $sleep_time]
 
-# make a bunch of 32 cnode blocks
-
+# make a bunch of blocks of the specified size (node_cnt)
 proc run_batch_jobs { node_cnt job_cnt file_in } {
-	global srun number kill_srun
+	global sbatch srun number kill_srun
 	set start_cnt 0	
 	for {set inx 0} {$inx < $job_cnt} {incr inx} {
-		set srun_pid [spawn $srun --batch --output=/dev/null -t2 -N$node_cnt-$node_cnt $file_in]
+		set sbatch_pid [spawn $sbatch --output=/dev/null -t5 -N$node_cnt-$node_cnt $file_in]
 		expect {
-			-re "More processors requested than permitted"
-			{
+			-re "More processors requested than permitted" {
+				send_user "This error was expected, no worries\n"
+				return -1
+			}
+			-re "Requested node configuration is not available" {
 				send_user "This error was expected, no worries\n"
 				return -1
-	
 			}
-			-re "jobid ($number) submitted" {
+			-re "Submitted batch job ($number)" {
 				incr start_cnt
 				exp_continue
 			}
@@ -90,8 +82,8 @@ proc run_batch_jobs { node_cnt job_cnt file_in } {
 				exp_continue
 			}
 			timeout {
-				send_user "\nFAILURE: srun not responding\n"
-				slow_kill $srun_pid
+				send_user "\nFAILURE: sbatch not responding\n"
+				slow_kill $sbatch_pid
 				return 0
 			}
 			eof {
@@ -109,12 +101,11 @@ proc run_batch_jobs { node_cnt job_cnt file_in } {
 # Wait up to 900 seconds for all jobs to terminate
 # Return 0 if all jobs done, remainin job count otherwise
 proc wait_for_all_jobs { job_name } {
-	global squeue bin_sleep
+	global scancel squeue bin_sleep file_in
 
 	set last_matches 0
 	send_user "Waiting for all jobs to terminate\n"
-	for {set inx 0} {$inx < 60} {incr inx} {
-		exec $bin_sleep 15
+	for {set inx 0} {$inx < 600} {incr inx} {
 		set matches 0
 		log_user 0
 		spawn $squeue -o %j
@@ -123,6 +114,13 @@ proc wait_for_all_jobs { job_name } {
 				incr matches
 				exp_continue
 			}
+			-re "error" {
+				set matches -1
+			}
+			timeout {
+				send_user "No response from squeue\n"
+				set matches -1
+			}
 			eof {
 				wait
 			}
@@ -130,23 +128,35 @@ proc wait_for_all_jobs { job_name } {
 		log_user 1
 		if {$matches == 0} { 
 			send_user "All jobs complete\n"
-			return 0
+			break
 		}
-		send_user "  $matches jobs remaining\n"
-		if {$matches == $last_matches} {
-			return $matches
+		if {$matches > 0} {
+			send_user "  $matches jobs remaining\n"
+#			Moab can slow throughput down a lot, 
+#			so don't return here
+#			if {$matches == $last_matches} {
+#				send_user "Running jobs hung\n"
+#				break
+#			}
+#			set last_matches $matches
+			exec $bin_sleep 15
 		}
-		set last_matches $matches
 	}
+	exec $scancel -n $file_in
 	return $matches
 }
 
-if {[run_batch_jobs 32 $32node_block_cnt $file_in ] != 1} {
+#
+# Run the jobs here. We can be reasonably sure of running 
+# 512 cnode jobs (one midplane). Other sizes may not be supported
+# due to architecture (I/O node count) and/or slurm configuration
+#
+if {[run_batch_jobs 32 $32node_block_cnt $file_in ] == 0} {
 	send_user "\nFAILURE: 32 cnodes can't be created\n"
 	set exit_code 1	
 }
 
-if {[run_batch_jobs 128 $32node_block_cnt $file_in ] != 1} {
+if {[run_batch_jobs 128 $128node_block_cnt $file_in ] == 0} {
 	send_user "\nFAILURE: 128 cnodes can't be created\n"
 	set exit_code 1	
 }
@@ -156,7 +166,7 @@ if {[run_batch_jobs 512 $512node_block_cnt $file_in ] != 1} {
 	set exit_code 1	
 }
 
-if {[run_batch_jobs 1k $1knode_block_cnt $file_in ] != 1} {
+if {[run_batch_jobs 1k $1knode_block_cnt $file_in ] == 0} {
 	send_user "\nFAILURE: 1k cnodes can't be created\n"
 	set exit_code 1	
 }
@@ -181,7 +191,7 @@ if {[run_batch_jobs 32k $32knode_block_cnt $file_in ] == 0} {
 	set exit_code 1	
 }
 
-if {[run_batch_jobs 1k $1knode_block_cnt $file_in ] != 1} {
+if {[run_batch_jobs 1k $1knode_block_cnt $file_in ] == 0} {
 	send_user "\nFAILURE: 1k cnodes can't be created\n"
 	set exit_code 1	
 }
@@ -191,17 +201,17 @@ if {[run_batch_jobs 512 $512node_block_cnt $file_in ] != 1} {
 	set exit_code 1	
 }
 
-if {[run_batch_jobs 128 $128node_block_cnt $file_in ] != 1} {
+if {[run_batch_jobs 128 $128node_block_cnt $file_in ] == 0} {
 	send_user "\nFAILURE: 128 cnodes can't be created\n"
 	set exit_code 1	
 }
 
-if {[run_batch_jobs 32 $32node_block_cnt $file_in ] != 1} {
+if {[run_batch_jobs 32 $32node_block_cnt $file_in ] == 0} {
 	send_user "\nFAILURE: 32 cnodes can't be created\n"
 	set exit_code 1	
 }
 
-if {[run_batch_jobs 512 $512node_block_cnt $file_in ] != 1} {
+if {[run_batch_jobs 512 $512node_block_cnt $file_in ] == 0} {
 	send_user "\nFAILURE: 512 cnodes can't be created\n"
 	set exit_code 1	
 }
diff --git a/testsuite/expect/test8.7 b/testsuite/expect/test8.7
new file mode 100755
index 0000000000000000000000000000000000000000..060a3598e389349a82b86c3299029b557d86e585
--- /dev/null
+++ b/testsuite/expect/test8.7
@@ -0,0 +1,256 @@
+#!/usr/bin/expect
+############################################################################
+# Purpose: Test of SLURM functionality
+#          Test of Blue Gene scheduling with sched/wik2 plugin.
+#
+# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "FAILURE: ..." otherwise with an explanation of the failure, OR
+#          anything else indicates a failure mode that must be investigated.
+############################################################################
+# Copyright (C) 2006-2007 The Regents of the University of California.
+# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+# Written by Morris Jette <jette1@llnl.gov>
+# LLNL-CODE-402394.
+# 
+# This file is part of SLURM, a resource management program.
+# For details, see <http://www.llnl.gov/linux/slurm/>.
+#  
+# SLURM is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+# 
+# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with SLURM; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+############################################################################
+source ./globals
+
+set test_id     "8.7"
+set exit_code   0
+set file_in     "test$test_id.in"
+set test_prog   "test$test_id.prog"
+
+print_header $test_id
+
+#
+# Submit a batch job to slurm
+# Input is node count and script name
+# Output is job_id or zero on failure
+#
+proc submit_job { size script } {
+	global number sbatch
+
+	set job_id 0
+	set sbatch_pid [spawn $sbatch -N $size --output=/dev/null --comment=test -t1 $script]
+	expect {
+		-re "Submitted batch job ($number)" {
+			set job_id $expect_out(1,string)
+			exp_continue
+		}
+		timeout {
+			send_user "\nFAILURE: sbatch not responding\n"
+			catch {exec $bin_kill -KILL $sbatch_pid}
+			if {job_id != 0} {
+				cancel_job $job_id
+				set job_id 0
+			}
+		}
+		eof {
+			wait
+		}
+	}
+
+	return $job_id
+}
+
+#
+# Check if we have sched/wiki2 configured
+#
+log_user 0
+set conf_dir     ""
+set control_addr ""
+set is_bluegene  0
+set sched_port   0
+set sched_wiki   0
+exec $bin_rm -f $file_in $test_prog
+spawn $scontrol show config
+expect {
+	-re "ControlAddr *= ($alpha_numeric)" {
+		set control_addr $expect_out(1,string)
+		exp_continue
+	}
+	-re "SchedulerPort *= ($number)" {
+		set sched_port $expect_out(1,string)
+		exp_continue
+	}
+	-re "sched/wiki2" {
+		set sched_wiki 1
+		exp_continue
+	}
+	-re "select/bluegene" {
+		set is_bluegene 1
+		exp_continue
+	}
+	-re "SLURM_CONFIG_FILE *= (.*)/slurm.conf" {
+		set conf_dir $expect_out(1,string)
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: scontrol not responding\n"
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+log_user 1
+if {$sched_wiki == 0} {
+	send_user "\nWARNING: not running sched/wiki2, test is not applicable\n"
+	exit $exit_code
+}
+if {$is_bluegene == 0} {
+	send_user "\nWARNING: not running select/bluegene, test is not applicable\n"
+	exit $exit_code
+}
+if {[string compare $control_addr ""] == 0} {
+	send_user "\nFAILURE: ControlAddr not set\n"
+	exit 1
+}
+if {$sched_port == 0} {
+	send_user "\nFAILURE: SchedulerPort = 0\n"
+	exit 1
+}
+
+#
+# Try to get the AuthKey from wiki.conf
+#
+set auth_key  0
+set e_port    0
+set agg_time  999
+set wiki_file "$conf_dir/wiki.conf"
+if {[file readable $wiki_file] == 0}  {
+	send_user "\nWARNING: Unable to read $wiki_file\n"
+	exit $exit_code
+}
+log_user 0
+spawn $bin_sort $wiki_file
+expect {
+	-re "AuthKey=($number)" {
+		set auth_key $expect_out(1,string)
+		exp_continue
+	}
+	-re "EPort=($number)" {
+		set e_port $expect_out(1,string)
+		exp_continue
+	}
+	-re "JobAggregationTime=($number)" {
+		set agg_time $expect_out(1,string)
+		exp_continue
+	}
+	-re
+	eof {
+		wait
+	}
+}
+log_user 1
+if {$auth_key == 0} {
+	send_user "\nWARNING: AuthKey not found in $wiki_file\n"
+	exit 1
+}
+if {$e_port == 0} {
+	send_user "\nWARNING: EPort not found in $wiki_file\n"
+	exit 1
+}
+if {$agg_time != 0} {
+	send_user "\nWARNING: JobAggregationTime != 0 in $wiki_file\n"
+	exit 1
+}
+#send_user "\nAuthKey=$auth_key\nEPort=$e_port\n"
+
+#
+# Submit four jobs to work with
+#
+make_bash_script $file_in "
+  echo BEGIN
+  $bin_sleep 30
+  echo FINI
+  exit 123"
+set job_id1 [submit_job 1024 $file_in]
+if {$job_id1 == 0} {
+	send_user "\nFAILURE: srun job submit failed\n"
+	exit 1
+}
+
+set job_id2 [submit_job 512 $file_in]
+if {$job_id2 == 0} {
+	send_user "\nFAILURE: srun job submit failed\n"
+	[cancel_job $job_id1]
+	exit 1
+}
+
+set job_id3 [submit_job 256 $file_in]
+if {$job_id3 == 0} {
+	send_user "\nFAILURE: srun job submit failed\n"
+	[cancel_job $job_id1]
+	[cancel_job $job_id2]
+	exit 1
+}
+
+set job_id4 [submit_job 32 $file_in]
+if {$job_id4 == 0} {
+	send_user "\nFAILURE: srun job submit failed\n"
+	[cancel_job $job_id1]
+	[cancel_job $job_id2]
+	[cancel_job $job_id4]
+	exit 1
+}
+
+#
+# Start our Moab emulator ($test_prog) to manage the job
+#
+set timeout 60
+exec $bin_rm -f $test_prog
+exec $bin_make -f /dev/null $test_prog
+set success 0
+set moab_pid [spawn $test_prog $auth_key $control_addr $e_port $sched_port $job_id1 $job_id2 $job_id3 $job_id4]
+set master_id $spawn_id
+expect {
+	-re "FAILURE" {
+		set exit_code 1
+		exp_continue
+	}
+	-re "SUCCESS" {
+		set success 1
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: Moab emulator not responding\n"
+		catch {exec $bin_kill -KILL $moab_pid}
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+if {$success == 0} {
+	send_user "\nFAILURE: Moab emulator failed\n"
+	set exit_code 1
+}
+
+cancel_job $job_id1
+cancel_job $job_id2
+cancel_job $job_id3
+cancel_job $job_id4
+
+if { $exit_code == 0 } {
+	exec $bin_rm -f $file_in $test_prog
+	send_user "\nSUCCESS\n"
+}
+exit $exit_code
+
diff --git a/testsuite/expect/test8.7.crypto.c b/testsuite/expect/test8.7.crypto.c
new file mode 100644
index 0000000000000000000000000000000000000000..153c2ef57bc6c4a0b75e602dbf26183127f5b9eb
--- /dev/null
+++ b/testsuite/expect/test8.7.crypto.c
@@ -0,0 +1,134 @@
+/*****************************************************************************\
+ *  crypto.c - DES cryptographic routines.
+ *****************************************************************************
+ *  Produced by Cluster Resources, Inc., no rights reserved. 
+\*****************************************************************************/
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAX_ITERATION 4
+
+/**************************************************************
+ * des
+ **************************************************************
+ * DESCRIPTION
+ * Compute a DES digest for a CRC according to a particular
+ * key.
+ *  
+ * ARGUMENTS
+ * lword (in/out) - The CRC to encode, which becomes the first
+ *		lexical segment of the checksum.
+ * irword (in/out ) - The key with which to encode the CRC,
+ *		which becomes the second lexical segment of
+ *		the checksum.
+ *  
+ * RETURNS
+ * None.
+ *
+ * SOURCE
+ * Cluster Resources, Inc., no rights reserved.
+ **************************************************************/
+static void des( uint32_t *lword, uint32_t *irword )
+{
+	int idx;
+	uint32_t ia, ib, iswap, itmph, itmpl;
+
+	static uint32_t c1[ MAX_ITERATION ] = {
+		0xcba4e531,
+		0x537158eb,
+		0x145cdc3c,
+		0x0d3fdeb2
+	};
+	static uint32_t c2[ MAX_ITERATION ] = {
+		0x12be4590,
+		0xab54ce58,
+		0x6954c7a6,
+		0x15a2ca46
+	};
+
+	itmph = 0;
+	itmpl = 0;
+
+	for ( idx = 0; idx < MAX_ITERATION; ++idx ) {
+		iswap = *irword;
+		ia = iswap ^ c1[ idx ];
+		itmpl = ia & 0xffff;
+		itmph = ia >> 16;
+		ib = itmpl * itmpl + ~( itmph * itmph );
+		ia = (ib >> 16) | ( (ib & 0xffff) << 16 );
+		*irword = (*lword) ^ ( (ia ^c2[ idx ]) + (itmpl * itmph) );
+		*lword = iswap;
+	}
+}
+
+/**************************************************************
+ * compute_crc
+ **************************************************************
+ * DESCRIPTION
+ * Compute a cyclic redundancy check (CRC) character-wise.
+ *  
+ * ARGUMENTS
+ * crc (in) - The CRC computed thus far.
+ * onech (in) - The character to be added to the CRC.
+ * 
+ * RETURNS
+ * The new CRC value.
+ *
+ * SOURCE
+ * Cluster Resources, Inc., no rights reserved.
+ **************************************************************/
+static uint16_t compute_crc( uint16_t crc, uint8_t onech )
+{
+	int idx;
+	uint32_t ans  = ( crc ^ onech << 8 );
+
+	for ( idx = 0; idx < 8; ++idx ) {
+		if ( ans & 0x8000 ) {
+			ans <<= 1;
+			ans = ans ^ 4129;
+		} else {
+			ans <<= 1;
+		}
+	}
+
+	return ans;
+}
+
+/**************************************************************
+ * checksum
+ **************************************************************
+ * DESCRIPTION
+ * Compute a Wiki checksum for the current message contents
+ * and return the result as a Wiki name-value pair.
+ * 
+ * ARGUMENTS
+ * sum (out) - The string in which to store the resulting
+ *		checksum.
+ * key(in) - The seed value for the checksum.  This must be
+ *		coordinated with the scheduler so that they
+ *		both use the same value.  It is a string of
+ *		ASCII decimal digits.
+ *  
+ * RETURNS
+ * None.
+ **************************************************************/
+extern void checksum( char *sum, const char * key, const char * buf )
+{
+	uint32_t crc = 0;
+	uint32_t lword, irword;
+	int idx, buf_len = strlen(buf);
+	uint32_t seed = (uint32_t) strtoul( key, NULL, 0 );
+
+	for ( idx = 0; idx < buf_len; ++idx ) {
+		crc = (uint32_t) compute_crc( crc, buf[idx] );
+	}
+
+	lword = crc;
+	irword = seed;
+
+	des( &lword, &irword );
+
+	sprintf(sum, "CK=%08x%08x", lword, irword);
+}
diff --git a/testsuite/expect/test8.7.prog.c b/testsuite/expect/test8.7.prog.c
new file mode 100644
index 0000000000000000000000000000000000000000..58b6c373abf24677599696e75e8cc1f1bd9ca771
--- /dev/null
+++ b/testsuite/expect/test8.7.prog.c
@@ -0,0 +1,329 @@
+/*****************************************************************************\
+ *  test8.7.prog.c - Test of Blue Gene scheduling with sched/wik2 plugin.
+ *****************************************************************************
+ *  Copyright (C) 2006-2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Morris Jette <jette1@llnl.gov>
+ *  LLNL-CODE-402394.
+ *  
+ *  This file is part of SLURM, a resource management program.
+ *  For details, see <http://www.llnl.gov/linux/slurm/>.
+ *  
+ *  SLURM is free software; you can redistribute it and/or modify it under
+ *  the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *  
+ *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+ *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ *  details.
+ *  
+ *  You should have received a copy of the GNU General Public License along
+ *  with SLURM; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+\*****************************************************************************/
+
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "./test7.7.crypto.c"
+
+/* global variables */
+char *auth_key, *control_addr;
+int   e_port, sched_port;
+long  job_id1, job_id2, job_id3, job_id4;
+
+static int _conn_wiki_port(char *host, int port)
+{
+	int sock_fd;
+	struct sockaddr_in wiki_addr;
+	struct hostent *hptr;
+
+	hptr = gethostbyname(host);
+	if (hptr == NULL) {
+		perror("gethostbyname");
+		exit(1);
+	}
+	if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+		perror("socket");
+		exit(1);
+	}
+	bzero((char *) &wiki_addr, sizeof(wiki_addr));
+	wiki_addr.sin_family = AF_INET;
+	wiki_addr.sin_port   = htons(port);
+	memcpy(&wiki_addr.sin_addr.s_addr, hptr->h_addr, hptr->h_length);		
+	sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (connect(sock_fd, (struct sockaddr *) &wiki_addr, 
+			sizeof(wiki_addr))) {
+		perror("connect");
+		exit(1);
+	}
+	return sock_fd;
+}
+
+static int _conn_event_port(char *host, int port)
+{
+	int sock_fd;
+	struct sockaddr_in wiki_addr;
+	struct hostent *hptr;
+
+	hptr = gethostbyname(host);
+	if (hptr == NULL) {
+		perror("gethostbyname");
+		exit(1);
+	}
+	if ((sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
+		perror("socket");
+		exit(1);
+	}
+	bzero((char *) &wiki_addr, sizeof(wiki_addr));
+	wiki_addr.sin_family = AF_INET;
+	wiki_addr.sin_port   = htons(port);
+	memcpy(&wiki_addr.sin_addr.s_addr, hptr->h_addr, hptr->h_length);
+	if (bind(sock_fd, (struct sockaddr *) &wiki_addr,
+			sizeof(wiki_addr))) {
+		printf("WARNING: bind to port %i failed, may not be real error\n",
+			port);
+		return -1;
+	}
+	listen(sock_fd, 1);
+	return sock_fd;
+}
+
+static size_t _read_bytes(int fd, char *buf, const size_t size)
+{
+	size_t bytes_remaining, bytes_read;
+	char *ptr;
+
+	bytes_remaining = size;
+	ptr = buf;
+	while (bytes_remaining > 0) {
+		bytes_read = read(fd, ptr, bytes_remaining);
+		if (bytes_read <= 0)
+			return 0;
+		bytes_remaining -= bytes_read;
+		ptr += bytes_read;
+	}
+
+	return size;
+}
+
+static size_t _write_bytes(int fd, char *buf, const size_t size)
+{
+	size_t bytes_remaining, bytes_written;
+	char *ptr;
+
+	bytes_remaining = size;
+	ptr = buf;
+	while (bytes_remaining > 0) {
+		bytes_written = write(fd, ptr, bytes_remaining);
+		if (bytes_written < 0)
+			return 0;
+		bytes_remaining -= bytes_written;
+		ptr += bytes_written;
+	}
+	return size;
+}
+
+static size_t _send_msg(int fd, char *buf, size_t size)
+{
+	char header[10];
+	size_t data_sent;
+
+	(void) sprintf(header, "%08lu\n", (uint32_t) size);
+	if (_write_bytes(fd, header, 9) != 9) {
+		perror("writing message header");
+		exit(1);
+	}
+
+	data_sent = _write_bytes(fd, buf, size);
+	if (data_sent != size) {
+		perror("writing message");
+		exit(1);
+	}
+
+	return data_sent;
+}
+
+static char *_recv_msg(int fd)
+{
+	char header[10];
+	uint32_t size;
+	char *buf;
+
+	if (_read_bytes(fd, header, 9) != 9) {
+		perror("reading message header");
+		exit(1);
+	}
+	if (sscanf(header, "%ul", &size) != 1) {
+		perror("parsing message header");
+		exit(1);
+	}
+	buf = calloc(1, (size+1));	/* need '\0' on end to print */
+	if (buf == NULL) {
+		perror("malloc");
+		exit(1);
+	}
+	if (_read_bytes(fd, buf, size) != size) {
+		perror("reading message");
+		exit(1);
+	}
+	return buf;
+}	
+
+static void _xmit(char *msg)
+{
+	int msg_len = strlen(msg);
+	char *out_msg, *in_msg, sum[20], *sc_ptr;
+	int wiki_fd = _conn_wiki_port(control_addr, sched_port);
+	int sc;
+
+	out_msg = calloc(1, (msg_len+100));
+	if (out_msg == NULL) {
+		perror("malloc");
+		exit(1);
+	}
+	checksum(sum, auth_key, msg);
+	sprintf(out_msg, "%s %s", sum, msg);
+	printf("send:%s\n", out_msg);
+	_send_msg(wiki_fd, out_msg, strlen(out_msg));
+	in_msg = _recv_msg(wiki_fd);
+	printf("recv:%s\n\n", in_msg);
+	sc_ptr = strstr(in_msg, "SC=");
+	sc = atoi(sc_ptr+3);
+	if (sc != 0) {
+		fprintf(stderr, "RPC FAILURE\n");
+		exit(1);
+	} 
+	free(in_msg);
+	close(wiki_fd);
+}
+
+static void _event_mgr(void)
+{
+	int accept_fd, event_fd;
+	int accept_addr_len = sizeof(struct sockaddr);
+	size_t cnt;
+	char in_msg[5];
+	struct sockaddr_in accept_addr;
+
+	if ((event_fd = _conn_event_port(control_addr, e_port)) < 0)
+		return;
+	printf("READY_FOR_EVENT\n");
+	if ((accept_fd = accept(event_fd, (struct sockaddr *) &accept_addr,
+			&accept_addr_len)) < 0) {
+		perror("accept");
+		exit(1);
+	}
+	close(event_fd);
+
+	cnt = _read_bytes(accept_fd, in_msg, sizeof(in_msg));
+	if (cnt > 0)
+		printf("event recv:%s\n\n", in_msg);
+	close(accept_fd);
+}
+
+static void _get_jobs(void)
+{
+	time_t now = time(NULL);
+	char out_msg[128];
+
+	/* Dump all data */
+	snprintf(out_msg, sizeof(out_msg),
+		"TS=%u AUTH=root DT=%s",
+		(uint32_t) now, "CMD=GETJOBS ARG=0:ALL");
+	_xmit(out_msg);
+}
+
+static void _get_nodes(void)
+{
+	time_t now = time(NULL);
+	char out_msg[128];
+
+	/* Dump all data */
+	snprintf(out_msg, sizeof(out_msg),
+		"TS=%u AUTH=root DT=%s", 
+		(uint32_t) now, "CMD=GETNODES ARG=0:ALL");
+	_xmit(out_msg);
+}
+
+static void _cancel_job(long my_job_id)
+{
+	time_t now = time(NULL);
+	char out_msg[128];
+
+	snprintf(out_msg, sizeof(out_msg),
+		"TS=%u AUTH=root DT=CMD=CANCELJOB ARG=%ld TYPE=ADMIN",
+		(uint32_t) now, my_job_id);
+	_xmit(out_msg);
+}
+
+static void _start_job(long my_job_id)
+{
+	time_t now = time(NULL);
+	char out_msg[128];
+
+	snprintf(out_msg, sizeof(out_msg),
+		"TS=%u AUTH=root DT=CMD=STARTJOB ARG=%ld TASKLIST=",
+		/* Empty TASKLIST means we don't care */
+		(uint32_t) now, my_job_id);
+	_xmit(out_msg);
+}
+
+static void _initialize(void)
+{
+	time_t now = time(NULL);
+	char out_msg[128];
+
+	snprintf(out_msg, sizeof(out_msg),
+		"TS=%u AUTH=root DT=CMD=INITIALIZE ARG=USEHOSTEXP=T EPORT=%u",
+		(uint32_t) now, e_port);
+	_xmit(out_msg);
+}
+
+int main(int argc, char * argv[])
+{
+	if (argc < 8) {
+		printf("Usage: %s, auth_key control_addr e_port "
+			"sched_port job_id1 job_id2 job_id3 job_id4\n", argv[0]);
+		exit(1);
+	}
+
+	auth_key     = argv[1];
+	control_addr = argv[2];
+	e_port       = atoi(argv[3]);
+	sched_port   = atoi(argv[4]);
+	job_id1      = atoi(argv[5]);
+	job_id2      = atoi(argv[6]);
+	job_id3      = atoi(argv[7]);
+	job_id4      = atoi(argv[8]);
+	printf("auth_key=%s control_addr=%s e_port=%d sched_port=%d\n",
+		auth_key, control_addr, e_port, sched_port);
+	printf("job_id1=%d job_id2=%d job_id3=%d job_id4=%d \n", 
+		job_id1, job_id2, job_id3, job_id4);
+
+	_initialize();
+	_get_jobs();
+	_get_nodes();
+
+	/* FIXME: Replace with new RPC containing multiple jobs and reserved nodes */
+	_start_job(job_id1);
+	_start_job(job_id2);
+	_start_job(job_id3);
+	_start_job(job_id4);
+	_get_jobs();
+
+	_cancel_job(job_id1);
+	_cancel_job(job_id2);
+	_cancel_job(job_id3);
+	_cancel_job(job_id4);
+
+	printf("SUCCESS\n");
+	exit(0);
+}
+
diff --git a/testsuite/expect/test9.1 b/testsuite/expect/test9.1
index 035f39b7e0b6b999ac22dd931ea76866d3d0337b..b2e1f3bb47cd0d67b9c682597147d36c10d15a45 100755
--- a/testsuite/expect/test9.1
+++ b/testsuite/expect/test9.1
@@ -12,7 +12,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -106,14 +106,16 @@ for {set inx 0} {$inx < $cycle_count} {incr inx} {
 	}
 	if {$stdout_lines != $stdout_target} {
 		send_user "\nFAILURE: stdout is incomplete\n"
+		set cycle_count [expr $inx + 1]
 		set exit_code 1
+		break
 	} else {
 		incr success_cnt
 	}
 }
-exec $bin_rm -f $file_in $file_out
 
 if {$exit_code == 0} {
+	exec $bin_rm -f $file_in $file_out
 	send_user "\nSUCCESS\n"
 } else {
 	send_user "\nFAILURE: Only $success_cnt of $cycle_count"
diff --git a/testsuite/expect/test9.2 b/testsuite/expect/test9.2
index a2fcb12a264c3bf2a75c9de34d24b37dbd78e233..34a71af12aa03dfc38f4d74cf8a22958487f9cd5 100755
--- a/testsuite/expect/test9.2
+++ b/testsuite/expect/test9.2
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -96,14 +96,16 @@ for {set inx 0} {$inx < $cycle_count} {incr inx} {
 	}
 	if {$stdout_lines != $task_cnt} {
 		send_user "\nFAILURE:stdout is incomplete\n"
+		set cycle_count [expr $inx + 1]
 		set exit_code 1
+		break
 	} else {
 		incr success_cnt
 	}
 }
-exec $bin_rm -f $file_out
 
 if {$exit_code == 0} {
+	exec $bin_rm -f $file_out
 	send_user "\nSUCCESS\n"
 } else {
 	send_user "\nFAILURE: Only $success_cnt of $cycle_count"
diff --git a/testsuite/expect/test9.3 b/testsuite/expect/test9.3
index 021b82d6f7a4d0843e5538e9e1a2202f6fe5f33e..7a392520bedf436538a0c0c1992bcb6d0952573e 100755
--- a/testsuite/expect/test9.3
+++ b/testsuite/expect/test9.3
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -106,17 +106,19 @@ for {set inx 0} {$inx < $cycle_count} {incr inx} {
 	}
 	if {$stdout_lines != $stdout_target} {
 		send_user "\nFAILURE:stdout is incomplete\n"
+		set cycle_count [expr $inx + 1]
 		set exit_code 1
+		break
 	} else {
 		incr success_cnt
 	}
 }
-exec $bin_rm -f $file_in $file_out
 
 if {$exit_code == 0} {
+	exec $bin_rm -f $file_in $file_out
 	send_user "\nSUCCESS\n"
 } else {
-	send_user "\nFAILURE: Only $success_cnt of $cycle_count hostname"
-	send_user " output tests passed\n"
+	send_user "\nFAILURE: Only $success_cnt of $cycle_count I/O"
+	send_user " tests passed\n"
 }
 exit $exit_code
diff --git a/testsuite/expect/test9.4 b/testsuite/expect/test9.4
index 66c01d440dabe3f3807b956ca12d57a830b9f28a..0b7d95750089249dafca2c10c4d22ba2ccb8f9ce 100755
--- a/testsuite/expect/test9.4
+++ b/testsuite/expect/test9.4
@@ -16,7 +16,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test9.5 b/testsuite/expect/test9.5
index 8bd4c003f288d2881cc4506417f62d123d02cb7e..fb8a46b9b082abe576da9ce896d5ba77d0b9a121 100755
--- a/testsuite/expect/test9.5
+++ b/testsuite/expect/test9.5
@@ -9,7 +9,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test9.6 b/testsuite/expect/test9.6
index 1f88f07e0864b0ba4a7a300dd49d6237ed578b95..a057883f1210f2a0e1fc472473bc528e19c25d74 100755
--- a/testsuite/expect/test9.6
+++ b/testsuite/expect/test9.6
@@ -12,7 +12,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -107,14 +107,16 @@ for {set inx 0} {$inx < $cycle_count} {incr inx} {
 	}
 	if {$stdout_lines != $stdout_target} {
 		send_user "\nFAILURE:stdout is missing output\n"
+		set cycle_count [expr $inx + 1]
 		set exit_code 1
+		break
 	} else {
 		incr success_cnt
 	}
 }
-exec $bin_rm -f $file_in $file_out
 
 if {$exit_code == 0} {
+	exec $bin_rm -f $file_in $file_out
 	send_user "\nSUCCESS\n"
 } else {
 	send_user "\nFAILURE: Only $success_cnt of $cycle_count hostname"
diff --git a/testsuite/expect/test9.7 b/testsuite/expect/test9.7
index cf4362510c012c4cdf0ba95910d6375ed44e9f33..fee3304135c181cb6c5dc76206ae97207fb93adb 100755
--- a/testsuite/expect/test9.7
+++ b/testsuite/expect/test9.7
@@ -10,7 +10,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test9.7.bash b/testsuite/expect/test9.7.bash
index 1056eadc6862eefe718082655dd577f92bd8f37e..15d53995b6e5f1556e5236c55a42bfd893287bf0 100755
--- a/testsuite/expect/test9.7.bash
+++ b/testsuite/expect/test9.7.bash
@@ -7,7 +7,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/expect/test9.8 b/testsuite/expect/test9.8
index c1f9d44e8b8fc1b17ae35dbf245a38316e801fca..494e51ab46ba1559969326855ee837a180c60d2d 100755
--- a/testsuite/expect/test9.8
+++ b/testsuite/expect/test9.8
@@ -13,7 +13,7 @@
 # Copyright (C) 2002-2006 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
@@ -62,9 +62,9 @@ if {[test_front_end] != 0} {
 make_bash_script $file_in "
 $bin_sleep $delay
 for ((inx=0; inx < $task_cnt; inx++)) ; do
-        $srun $bin_sleep $sleep_time &
+        $srun -N1 -n1 $bin_sleep $sleep_time &
 done
-$srun $bin_sleep $sleep_time
+$srun -N1 -n1 $bin_sleep $sleep_time
 "
 
 #
@@ -73,9 +73,9 @@ $srun $bin_sleep $sleep_time
 set start_cnt 0
 set timeout $delay
 for {set inx 0} {$inx < $job_cnt} {incr inx} {
-	set srun_pid [spawn $srun --job-name=$job_name --batch --output=/dev/null --error=/dev/null -t5 $file_in]
+	set sbatch_pid [spawn $sbatch --job-name=$job_name --output=/dev/null --error=/dev/null -t5 $file_in]
 	expect {
-		-re "jobid ($number) submitted" {
+		-re "Submitted batch job ($number)" {
 			incr start_cnt
 			exp_continue
 		}
@@ -85,7 +85,7 @@ for {set inx 0} {$inx < $job_cnt} {incr inx} {
 		}
 		timeout {
 			send_user "\nFAILURE: srun not responding\n"
-			slow_kill $srun_pid
+			slow_kill $sbatch_pid
 			exit 1
 		}
 		eof {
diff --git a/testsuite/expect/usleep b/testsuite/expect/usleep
index 3af6bd6bef7217dc838568a442c803c8a9b660bc..5759a4602700b883ae0546e1166c6f9b8fa745d1 100755
--- a/testsuite/expect/usleep
+++ b/testsuite/expect/usleep
@@ -7,7 +7,7 @@
 # Copyright (C) 2002 The Regents of the University of California.
 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 # Written by Morris Jette <jette1@llnl.gov>
-# UCRL-CODE-226842.
+# LLNL-CODE-402394.
 # 
 # This file is part of SLURM, a resource management program.
 # For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/Makefile.in b/testsuite/slurm_unit/Makefile.in
index 48c72e40cf36431fb0603c724944d6bb891dfce9..e4e4fe3c700d06e8af98406cc970764f2d6ab17e 100644
--- a/testsuite/slurm_unit/Makefile.in
+++ b/testsuite/slurm_unit/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -41,6 +41,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -99,6 +101,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -112,10 +115,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -135,7 +141,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -146,6 +155,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -161,6 +172,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -176,6 +188,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -350,8 +363,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -376,8 +389,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -387,13 +400,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/testsuite/slurm_unit/api/Makefile.in b/testsuite/slurm_unit/api/Makefile.in
index bd6610ab200981f7c3d503a164f61515b37b2294..25a05ccffb14dcc18cf382c190cd8c60f0bcd943 100644
--- a/testsuite/slurm_unit/api/Makefile.in
+++ b/testsuite/slurm_unit/api/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -69,7 +71,7 @@ api_test_OBJECTS = api-test.$(OBJEXT)
 api_test_LDADD = $(LDADD)
 api_test_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
 	$(top_builddir)/src/api/libslurm.la
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -119,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -132,10 +135,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -155,7 +161,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -166,6 +175,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -181,6 +192,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -196,6 +208,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -412,8 +425,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -438,8 +451,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -449,13 +462,12 @@ ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/testsuite/slurm_unit/api/manual/Makefile.in b/testsuite/slurm_unit/api/manual/Makefile.in
index 5e77e3dca40639fbac9ef2d8c338305898cbd5fe..9f721d2e518ef382ffb72279a128cc9b0b234fe2 100644
--- a/testsuite/slurm_unit/api/manual/Makefile.in
+++ b/testsuite/slurm_unit/api/manual/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -97,7 +99,7 @@ update_config_tst_SOURCES = update_config-tst.c
 update_config_tst_OBJECTS = update_config-tst.$(OBJEXT)
 update_config_tst_LDADD = $(LDADD)
 update_config_tst_DEPENDENCIES = $(top_builddir)/src/api/libslurm.la
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -141,6 +143,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -154,10 +157,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -177,7 +183,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -188,6 +197,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -203,6 +214,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -218,6 +230,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -389,8 +402,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -402,8 +415,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -413,13 +426,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/testsuite/slurm_unit/api/manual/cancel-tst.c b/testsuite/slurm_unit/api/manual/cancel-tst.c
index 1562fe53911d368922d0ef6925bcd7203c7d9713..8fce7808d63b89d9369a10988d0ab999f33e08c2 100644
--- a/testsuite/slurm_unit/api/manual/cancel-tst.c
+++ b/testsuite/slurm_unit/api/manual/cancel-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/api/manual/complete-tst.c b/testsuite/slurm_unit/api/manual/complete-tst.c
index 93f8ddaaaae683e042fe1060a71bdbc5e4ed6d1d..06926437d0a6ed391ea52048b8c8d05157af76bc 100644
--- a/testsuite/slurm_unit/api/manual/complete-tst.c
+++ b/testsuite/slurm_unit/api/manual/complete-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/api/manual/job_info-tst.c b/testsuite/slurm_unit/api/manual/job_info-tst.c
index 59ee9bed4ac859fb95e763c11f0dcefe00b28189..967e42088e19d1decc23e5565c6f070b8cc78c9b 100644
--- a/testsuite/slurm_unit/api/manual/job_info-tst.c
+++ b/testsuite/slurm_unit/api/manual/job_info-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/api/manual/node_info-tst.c b/testsuite/slurm_unit/api/manual/node_info-tst.c
index 1065673f9c028499a99dffa7fdf4139c3bd05ea8..9db08b49a496686fc201e7b65d2bfd8fc84ca010 100644
--- a/testsuite/slurm_unit/api/manual/node_info-tst.c
+++ b/testsuite/slurm_unit/api/manual/node_info-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/api/manual/partition_info-tst.c b/testsuite/slurm_unit/api/manual/partition_info-tst.c
index 4749ac35b2a101f6982a6116abe1ea269bb8a989..c75d98a26f994af4ab580bee664687c4e8ce0e70 100644
--- a/testsuite/slurm_unit/api/manual/partition_info-tst.c
+++ b/testsuite/slurm_unit/api/manual/partition_info-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/api/manual/reconfigure-tst.c b/testsuite/slurm_unit/api/manual/reconfigure-tst.c
index f8c1c2225af6270601f790acbfa45fd62dc6f76a..2064b77fd4b63f7498ce692d01a9ef094aee723e 100644
--- a/testsuite/slurm_unit/api/manual/reconfigure-tst.c
+++ b/testsuite/slurm_unit/api/manual/reconfigure-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/api/manual/submit-tst.c b/testsuite/slurm_unit/api/manual/submit-tst.c
index c1079e327df9ff8fdc5b7ba9fc829f95a0e6963e..f4b54bb321cc1cc5562aae2f066ea3164b5c2c28 100644
--- a/testsuite/slurm_unit/api/manual/submit-tst.c
+++ b/testsuite/slurm_unit/api/manual/submit-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/api/manual/update_config-tst.c b/testsuite/slurm_unit/api/manual/update_config-tst.c
index 2fa8d5355453567fd33a0d60851dbc9ec3ad3cf5..637622a8f19e5ebee8080018b475e0e97931ef43 100644
--- a/testsuite/slurm_unit/api/manual/update_config-tst.c
+++ b/testsuite/slurm_unit/api/manual/update_config-tst.c
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-226842.
+ *  LLNL-CODE-402394.
  *
  *  This file is part of SLURM, a resource management program.
  *  For details, see <http://www.llnl.gov/linux/slurm/>.
diff --git a/testsuite/slurm_unit/common/Makefile.in b/testsuite/slurm_unit/common/Makefile.in
index 6dd0bbce7f09cd4c5b193f796597e1ea32ef121d..b56d8fd5953e1b8179fc6c884212fbc3f06e70cd 100644
--- a/testsuite/slurm_unit/common/Makefile.in
+++ b/testsuite/slurm_unit/common/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -87,7 +89,7 @@ runqsw_OBJECTS = runqsw.$(OBJEXT)
 runqsw_LDADD = $(LDADD)
 runqsw_DEPENDENCIES = $(top_builddir)/src/common/libcommon.la \
 	$(am__DEPENDENCIES_1)
-DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/slurm@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/slurm
 depcomp = $(SHELL) $(top_srcdir)/auxdir/depcomp
 am__depfiles_maybe = depfiles
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -127,6 +129,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -140,10 +143,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -163,7 +169,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -174,6 +183,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -189,6 +200,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -204,6 +216,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -365,8 +378,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
@@ -378,8 +391,8 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
 	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
@@ -389,13 +402,12 @@ ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$tags $$unique
diff --git a/testsuite/slurm_unit/common/pack-test.c b/testsuite/slurm_unit/common/pack-test.c
index e883df4cc2ba407617f0a17fb8bd898fdb363399..bf1b7c0e27aef50a50503ae143b835e74c147d45 100644
--- a/testsuite/slurm_unit/common/pack-test.c
+++ b/testsuite/slurm_unit/common/pack-test.c
@@ -1,4 +1,4 @@
-/* $Id: pack-test.c 1528 2002-10-31 15:56:56Z grondo $ */
+/* $Id: pack-test.c 13654 2008-03-18 23:00:20Z jette $ */
 
 #if HAVE_CONFIG_H
 #  include <config.h>
@@ -32,8 +32,8 @@
 int main (int argc, char *argv[])
 {
 	Buf buffer;
-	uint16_t test16 = 1234, out16, byte_cnt;
-	uint32_t test32 = 5678, out32;
+	uint16_t test16 = 1234, out16;
+	uint32_t test32 = 5678, out32, byte_cnt;
 	char testbytes[] = "TEST BYTES", *outbytes;
 	char teststring[] = "TEST STRING",  *outstring = NULL;
 	char *nullstr = NULL;
diff --git a/testsuite/slurm_unit/slurmctld/Makefile.in b/testsuite/slurm_unit/slurmctld/Makefile.in
index 83f24177749e371617997c0b7fc0627378543050..aae4a75662998874e83e952caa8a5564ae7571ce 100644
--- a/testsuite/slurm_unit/slurmctld/Makefile.in
+++ b/testsuite/slurm_unit/slurmctld/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -90,6 +92,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -103,10 +106,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -126,7 +132,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -137,6 +146,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -152,6 +163,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -167,6 +179,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
diff --git a/testsuite/slurm_unit/slurmctld/security_2_1.py b/testsuite/slurm_unit/slurmctld/security_2_1.py
index 6a2b573f4ca0d8697355c6d0805b2502a040e63c..ee82500a5932a5e8d03016f3b3a026d0889b559f 100755
--- a/testsuite/slurm_unit/slurmctld/security_2_1.py
+++ b/testsuite/slurm_unit/slurmctld/security_2_1.py
@@ -54,6 +54,8 @@ def main(argv=None):
     #
     print
     print "NOTE: slurm_epilog and slurm_prolog only exist on BlueGene systems"
+    print "NOTE: federation.conf only exists on AIX systems"
+    print "NOTE: sview, slurmdbd and slurmdbd.conf exists only on selected systems"
     print "NOTE: JobCredentialPrivateKey, SlurmctldLogFile, and StateSaveLocation only on control host"
     print "NOTE: SlurmdLogFile and SlurmdSpoolDir only exist on compute servers" 
     print
@@ -63,9 +65,12 @@ def main(argv=None):
     files.append(options.conf)
     files.append(options.sysconfdir+'/bluegene.conf')
     files.append(options.sysconfdir+'/federation.conf')
+    files.append(options.sysconfdir+'/slurm.conf')
+    files.append(options.sysconfdir+'/slurmdbd.conf')
     files.append(options.sysconfdir+'/wiki.conf')
-    files.append(options.prefix+'/bin/srun')
+    files.append(options.prefix+'/bin/mpiexec')
     files.append(options.prefix+'/bin/sacct')
+    files.append(options.prefix+'/bin/sacctmgr')
     files.append(options.prefix+'/bin/salloc')
     files.append(options.prefix+'/bin/sattach')
     files.append(options.prefix+'/bin/sbatch')
@@ -73,13 +78,14 @@ def main(argv=None):
     files.append(options.prefix+'/bin/scancel')
     files.append(options.prefix+'/bin/scontrol')
     files.append(options.prefix+'/bin/sinfo')
-    files.append(options.prefix+'/bin/slaunch')
     files.append(options.prefix+'/bin/smap')
     files.append(options.prefix+'/bin/squeue')
+    files.append(options.prefix+'/bin/srun')
     files.append(options.prefix+'/bin/strigger')
     files.append(options.prefix+'/bin/sview')
     files.append(options.prefix+'/sbin/slurmctld')
     files.append(options.prefix+'/sbin/slurmd')
+    files.append(options.prefix+'/sbin/slurmdbd')
     files.append(options.prefix+'/sbin/slurmstepd')
     files.append(options.prefix+'/sbin/slurm_epilog')
     files.append(options.prefix+'/sbin/slurm_prolog')
@@ -108,6 +114,7 @@ def main(argv=None):
     print "Ensuring the following are not world readable:"
     files = []
     append_file(files, confpairs, 'JobCredentialPrivateKey')
+    files.append(options.sysconfdir+'/slurmdbd.conf')
     files.append(options.sysconfdir+'/wiki.conf')
 
     for fname in files:
diff --git a/testsuite/slurm_unit/slurmctld/security_2_2a.sh b/testsuite/slurm_unit/slurmctld/security_2_2a.sh
new file mode 100755
index 0000000000000000000000000000000000000000..946aadc46a8d905716e62646bbae80c91759ff0c
--- /dev/null
+++ b/testsuite/slurm_unit/slurmctld/security_2_2a.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+echo "#!/bin/sh"     >tmp2.$$
+echo "id"           >>tmp2.$$
+
+# Run srun using this config file
+${slurm_bin}sbatch tmp2.$$
+
+# Clean up
+rm -f tmp2.$$
diff --git a/testsuite/slurm_unit/slurmctld/security_2_2.sh b/testsuite/slurm_unit/slurmctld/security_2_2b.sh
similarity index 79%
rename from testsuite/slurm_unit/slurmctld/security_2_2.sh
rename to testsuite/slurm_unit/slurmctld/security_2_2b.sh
index 02e8a44b30c78e32b2354cba86f5d77e9c611561..cf429a869a2e7e720f68f6a95b435185aa7c40b0 100755
--- a/testsuite/slurm_unit/slurmctld/security_2_2.sh
+++ b/testsuite/slurm_unit/slurmctld/security_2_2b.sh
@@ -8,9 +8,12 @@ file_orig=`${slurm_bin}scontrol show config | awk '{ if ( $1 ~ /SLURM_CONFIG_FIL
 grep -iv AuthType <$file_orig >tmp.$$
 echo "AuthType=auth/dummy" >>tmp.$$
 
+echo "#!/bin/sh"     >tmp2.$$
+echo "id"           >>tmp2.$$
+
 # Run srun using this config file
 export SLURM_CONF=tmp.$$ 
-${slurm_bin}srun /usr/bin/id
+${slurm_bin}sbatch tmp2.$$
 
 # Clean up
-rm tmp.$$
+rm -f tmp.$$ tmp2.$$
diff --git a/testsuite/slurm_unit/slurmd/Makefile.in b/testsuite/slurm_unit/slurmd/Makefile.in
index 2be30e7ad9130ed655ed1e4d3cdd45c51cb7dee7..c78fa4e545c4b4470632f48b299f319897fa1ee9 100644
--- a/testsuite/slurm_unit/slurmd/Makefile.in
+++ b/testsuite/slurm_unit/slurmd/Makefile.in
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/auxdir/acx_pthread.m4 \
 	$(top_srcdir)/auxdir/x_ac_affinity.m4 \
 	$(top_srcdir)/auxdir/x_ac_aix.m4 \
 	$(top_srcdir)/auxdir/x_ac_bluegene.m4 \
+	$(top_srcdir)/auxdir/x_ac_cflags.m4 \
+	$(top_srcdir)/auxdir/x_ac_databases.m4 \
 	$(top_srcdir)/auxdir/x_ac_debug.m4 \
 	$(top_srcdir)/auxdir/x_ac_elan.m4 \
 	$(top_srcdir)/auxdir/x_ac_federation.m4 \
@@ -90,6 +92,7 @@ CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
@@ -103,10 +106,13 @@ FFLAGS = @FFLAGS@
 GREP = @GREP@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
+HAVEMYSQLCONFIG = @HAVEMYSQLCONFIG@
+HAVEPGCONFIG = @HAVEPGCONFIG@
 HAVEPKGCONFIG = @HAVEPKGCONFIG@
 HAVE_AIX = @HAVE_AIX@
 HAVE_ELAN = @HAVE_ELAN@
 HAVE_FEDERATION = @HAVE_FEDERATION@
+HAVE_OPENSSL = @HAVE_OPENSSL@
 HAVE_SOME_CURSES = @HAVE_SOME_CURSES@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -126,7 +132,10 @@ MKDIR_P = @MKDIR_P@
 MUNGE_CPPFLAGS = @MUNGE_CPPFLAGS@
 MUNGE_LDFLAGS = @MUNGE_LDFLAGS@
 MUNGE_LIBS = @MUNGE_LIBS@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
 NCURSES = @NCURSES@
+NMEDIT = @NMEDIT@
 NUMA_LIBS = @NUMA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
@@ -137,6 +146,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PAM_LIBS = @PAM_LIBS@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
 PLPA_LIBS = @PLPA_LIBS@
 PROCTRACKDIR = @PROCTRACKDIR@
 PROJECT = @PROJECT@
@@ -152,6 +163,7 @@ SEMAPHORE_SOURCES = @SEMAPHORE_SOURCES@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SLURMCTLD_PORT = @SLURMCTLD_PORT@
+SLURMDBD_PORT = @SLURMDBD_PORT@
 SLURMD_PORT = @SLURMD_PORT@
 SLURM_API_AGE = @SLURM_API_AGE@
 SLURM_API_CURRENT = @SLURM_API_CURRENT@
@@ -167,6 +179,7 @@ SSL_CPPFLAGS = @SSL_CPPFLAGS@
 SSL_LDFLAGS = @SSL_LDFLAGS@
 SSL_LIBS = @SSL_LIBS@
 STRIP = @STRIP@
+UTIL_LIBS = @UTIL_LIBS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@