Bug#690482: unblock: nwchem/6.1-4
Hi,
On Mon, Dec 10, 2012 at 09:27:03PM +0100, Julien Cristau wrote:
> On Sat, Nov 24, 2012 at 21:16:18 +0100, Michael Banck wrote:
> > If they are absolutely not possible to review, can we at least get the
> > patch in which fixes the outstanding testsuite failure (though note that
> > the Debian package only runs a tiny portion of the upstream testsuite to
> > be buildd-friendly) via t-p-u? Should we file a seperate bug for that
> > before uploading?
> >
> I haven't had time to look at the upstream changes, but from the 6.1-4
> diff, at least the part about adding python stuff is a no-go as far as
> I'm concerned.
I have uploaded nwchem_6.1-5, which reverts the other changes from the
previous revision, leaving only the upstream changes patch for #695540,
plus the removal of the bogus debian/control.new file which I hope is
fine:
changelog | 60
control.new | 118 -
patches/09_backported_6.1.1_fixes.patch | 2192 ++++++++++++++++++++++++++++++++
patches/series | 1
4 files changed, 2253 insertions(+), 118 deletions(-)
The new debdiff is attached.
Cheers,
Michael
diff -Nru nwchem-6.1/debian/changelog nwchem-6.1/debian/changelog
--- nwchem-6.1/debian/changelog 2012-03-31 12:04:22.000000000 +0200
+++ nwchem-6.1/debian/changelog 2012-12-14 14:44:25.000000000 +0100
@@ -1,3 +1,63 @@
+nwchem (6.1-5) unstable; urgency=low
+
+ * Reverted subversion revisions 3824, 3834 and 3876.
+
+ -- Michael Banck <mbanck@debian.org> Fri, 14 Dec 2012 14:44:22 +0100
+
+nwchem (6.1-4) unstable; urgency=low
+
+ [ Michael Banck ]
+ * debian/patches/09_backported_6.1.1_fixes.patch: New patch, backports the
+ source code changes of the nwchem-6.1.1 bugfix release (Closes: #695540):
+ + PW: Fixed backspace issues on file I/O that caused I/O errors.
+ + DFT: Removed dummy and bq centers from the Grimme dispersion
+ corrections.
+ + DFT: Fixed a race condition in the density fitting code.
+ + DFT: Added a check for singularities in the HCTH functionals.
+ + DFT: Fixed a problem with the DFT grids which caused strange behaviors
+ if the number of cores is so large that some cores do not get any grid
+ points.
+ + HF&DFT: Fixed rolling back to distributed memory Fock-builder if not
+ enough memory is available to use the replicated data one. Previously
+ the code would crash trying to use non-existing GAs.
+ + HF&DFT: Fixed clashes between MPI and GA communication when using OpenIB
+ which enhances the stability.
+ + MP2&DFT: On systems with limited I/O capabilities some quantities like
+ 2-electron integrals and DFT grids are now stored in memory rather than
+ on disk.
+ + CASSCF: Added ga_sync to fix race conditions that can cause the Davidson
+ diagonalizer to fail.
+ + CASSCF: Fixed a problem with the phase in the Lagrangian that caused
+ problems with the gradient evaluation.
+ + RAMAN: A number of problems with static polarizabilities were fixed.
+ + Property: Fixed an issue with add_patch that caused unexpected results
+ with dynamic polarizabilities.
+ + DRDY: Removed system calls to copy files avoiding forking from NWChem
+ processes which is relatively likely to fail due to the resources
+ attached to such a process.
+ + Input: Fixed some issues with GEOM LOAD that caused the selection of
+ centers to fail in some cases.
+ + Geometry: Dummy centers are no longer removed from a geometry so that
+ constraints involving those centers remain valid.
+ + Memory: All shared memory (global memory region) is now allocated at the
+ start.
+
+ [ Daniel Leidert ]
+ * debian/control: Added X-Python-Version.
+ (Build-Depends): Added python-dev. Use texlive to fix manual build.
+ (Standards-Version): Bumped to recent 3.9.3.
+ * debian/nwchem.1: Added.
+ * debian/nwchem.doc-base: Ditto.
+ * debian/nwchem.lintian-overrides: Ditto.
+ * debian/nwchem.manpages: Ditto.
+ * debian/nwchem-data.lintian-overrides: Ditto.
+ * debian/rules: Added PYTHONVERSION, PYTHONHOME. Enable parallel building.
+ (NWCHEM_MODULES): Build with python support (pnnl).
+ * debian/patches/02_makefile_flags.patch: Adjusted.
+ - src/config/makefile.h: Fix linker flags building with python support.
+
+ -- Michael Banck <mbanck@debian.org> Thu, 13 Sep 2012 14:35:37 +0200
+
nwchem (6.1-3) unstable; urgency=low
* debian/testsuite: Removed cosmo_trichloroethene, as it takes much longer
diff -Nru nwchem-6.1/debian/control.new nwchem-6.1/debian/control.new
--- nwchem-6.1/debian/control.new 2012-02-12 15:57:04.000000000 +0100
+++ nwchem-6.1/debian/control.new 1970-01-01 01:00:00.000000000 +0100
@@ -1,118 +0,0 @@
-Source: nwchem
-Section: science
-Priority: extra
-Maintainer: Debichem Team <debichem-devel@lists.alioth.debian.org>
-Uploaders: Michael Banck <mbanck@debian.org>
-Build-Depends: csh,
- openssh-client,
- debhelper (>= 7.0.50~),
- gfortran,
- libblacs-mpi-dev,
- mpi-default-bin,
- mpi-default-dev,
- texlive-latex-base
-Standards-Version: 3.9.2
-Homepage: http://www.nwchem-sw.org
-Vcs-Browser: http://svn.debian.org/wsvn/debichem/unstable/nwchem/
-Vcs-Svn: svn://svn.debian.org/svn/debichem/unstable/nwchem/
-
-Package: nwchem
-Architecture: any
-Depends: mpi-default-bin,
- nwchem-data (= ${source:Version}),
- ${misc:Depends},
- ${shlibs:Depends}
-Description: High-performance computational chemistry software
- NWCHem is a computational chemistry program package. It provides methods
- which are scalable both in their ability to treat large scientific
- computational chemistry problems efficiently, and in their use of available
- parallel computing resources from high-performance parallel supercomputers to
- conventional workstation clusters.
- .
- NWChem can handle:
- .
- * Molecular electronic structure methods using gaussian
- basis functions for high-accuracy calculations of molecules
- * Pseudopotentials plane-wave electronic structure methods for calculating
- molecules, liquids, crystals, surfaces, semi-conductors or metals
- * Ab-initio and classical molecular dynamics simulations
- * Mixed quantum-classical simulations
- * Parallel scaling to thousands of processors
- .
- Features include:
- * Molecular electronic structure methods, analytic second derivatives:
- - Restricted/unrestricted Hartree-Fock (RHF, UHF)
- - Restricted Density Functional Theory (DFT) using many local,
- non-local (gradient- corrected) or hybrid (local, non-local, and HF)
- exchange-correlation potentials
- * Molecular electronic structure methods, analytic gradients:
- - Restricted open-shell Hartree-Fock (ROHF)
- - Unrestricted Density Functional Theory (DFT)
- - Second-order Moeller-Plesset perturbation theory (MP2), using RHF and UHF
- reference
- - Complete active space SCF (CASSCF)
- * Molecular electronic structure methods, single-point energies:
- - MP2 with resolution of the identity integral approximation (RI-MP2), using
- RHF and UHF reference
- - Coupled cluster singles and doubles, triples or pertubative triples (CCSD,
- CCSDT, CCSD(T)), with RHF and UHF reference
- - Configuration interaction (CISD, CISDT, and CISDTQ)
- - Second-order approximate coupled-cluster singles doubles (CC2)
- * Further molecular electronic structure features:
- - Geometry optimization including transition state searches, constraints
- and minimum energy paths
- - Vibrational frequencies
- - Equation-of-motion (EOM)-CCSD, EOM-CCSDT, EOM-CCSD(T), CC2,
- Configuration-Interaction singles (CIS), time-dependent HF (TDHF) and
- TDDFT, for excited states with RHF, UHF, RDFT, or UDFT reference
- - Solvatisation using the Conductor-like screening model (COSMO) for RHF,
- ROHF and DFT
- - Hybrid calculations using the two- and three-layer ONIOM method
- - Relativistic effects via spin-free and spin-orbit one-electron
- Douglas-Kroll and zeroth-order regular approximations (ZORA) and
- one-electron spin-orbit effects for DFT via spin-orbit potentials
- * Pseudopotential plane-wave electronic structure:
- - Pseudopotential Plane-Wave (PSPW), Projector Augmented Wave (PAW) or band
- structure methods for calculating molecules, liquids, crystals, surfaces,
- semi-conductors or metals
- - Geometry/unit cell optimization including transition state searches
- - Vibrational frequencies
- - LDA, PBE96, and PBE0 exchange-correlation potentials (restricted and
- unrestricted)
- - SIC, pert-OEP, Hartree-Fock, and hybrid functionals (restricted and
- unrestricted)
- - Hamann, Troullier-Martins and Hartwigsen-Goedecker-Hutter norm-conserving
- pseudopotentials with semicore corrections
- - Wavefunction, density, electrostatic and Wannier plotting
- - Band structure and density of states generation
- * Car-Parrinello ab-initio molecular dynamics:
- - Constant energy and constant temperature dynamics
- * Classical molecular dynamics:
- - Single configuration energy evaluation
- - Energy minimization
- - Molecular dynamics simulation
- - Free energy simulation (multistep thermodynamic perturbation (MSTP) or
- multiconfiguration thermodynamic integration (MCTI) methods with options of
- single and/or dual topologies, double wide sampling, and separation-
- shifted scaling)
- - Force fields providing effective pair potentials, first order
- polarization, self consistent polarization, smooth particle mesh Ewald
- (SPME), periodic boundary conditions and SHAKE constraints
- * Mixed quantum-classical:
- - Mixed quantum-mechanics and molecular-mechanics (QM/MM) minimizations and
- molecular dynamics simulations
- - Quantum molecular dynamics simulation by using any of the quantum
- mechanical methods capable of returning gradients.
-
-Package: nwchem-data
-Architecture: all
-Depends: ${misc:Depends}, ${shlibs:Depends}
-Description: High-performance computational chemistry software (data files)
- NWCHem is a computational chemistry program package. It provides methods
- which are scalable both in their ability to treat large scientific
- computational chemistry problems efficiently, and in their use of available
- parallel computing resources from high-performance parallel supercomputers to
- conventional workstation clusters.
- .
- This package contains the basis sets, pseudopotentials and AMBER/CHARMM
- parameter files.
diff -Nru nwchem-6.1/debian/patches/09_backported_6.1.1_fixes.patch nwchem-6.1/debian/patches/09_backported_6.1.1_fixes.patch
--- nwchem-6.1/debian/patches/09_backported_6.1.1_fixes.patch 1970-01-01 01:00:00.000000000 +0100
+++ nwchem-6.1/debian/patches/09_backported_6.1.1_fixes.patch 2012-12-14 13:17:34.000000000 +0100
@@ -0,0 +1,2192 @@
+Index: nwchem-6.1/src/basis/basis.F
+===================================================================
+--- nwchem-6.1.orig/src/basis/basis.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/basis/basis.F 2012-09-09 16:22:33.000000000 +0200
+@@ -1184,6 +1184,7 @@
+ c For aa*, first check if tag_to_add matches star tag itself
+ c For Bq, if B* is used and geometry tag is Bq, skip, only when Bq*
+ c is used we need to go on
++c Skip and do not load a basis for dummy center X
+ c
+ if (inp_contains(.true.,'*',star_tag(istar),ilen)) then
+ if (ilen .gt. 1) then
+@@ -1193,6 +1194,9 @@
+ if (inp_compare(.false.,'Bq',tag_to_add(1:2)).and..not.
+ & inp_compare(.false.,'Bq',star_tag(istar)(1:2)))
+ & goto 00011
++ if (inp_compare(.false.,'X',tag_to_add(1:1)).and..not.
++ & inp_compare(.false.,'Xe',tag_to_add(1:2)))
++ & goto 00011
+ endif
+ c
+ c There is a match between the tag_to_add and the star_tag, check for
+Index: nwchem-6.1/src/drdy/wfiles.F
+===================================================================
+--- nwchem-6.1.orig/src/drdy/wfiles.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/drdy/wfiles.F 2012-09-09 16:22:33.000000000 +0200
+@@ -10,12 +10,14 @@
+ #include "nwc_drdyP.fh"
+ #include "inp.fh"
+ #include "rtdb.fh"
++#include "stdio.fh"
+ C
+ Integer i,nstrs,ilen
+ Character*1 chsval(5),schar(6),char2(255)
+ Character*32 theory
+ Character*255 cmd,cmd1
+ Character*255 dummy_file
++ Character*255 filein,fileout
+ Double Precision absswf
+ C
+ Integer util_system
+@@ -65,42 +67,28 @@
+ & RTDB_ERR)
+ call drdy_get_movecname(my_rtdb,theory,dummy_file)
+ ilen = inp_strlen(dummy_file)
+- cmd = 'cp '
+- write(cmd1,'(a,'' '',a,'' '',a,''.'')')
+- * cmd(1:inp_strlen(cmd)),dummy_file(1:ilen),
+- * dummy_file(1:ilen)
+- cmd = cmd1
+- ilen = inp_strlen(cmd)
++ filein = dummy_file(1:ilen)
++ fileout = dummy_file(1:ilen)//"."
++ ilen = inp_strlen(fileout)
+ do i=1,nstrs
+- char2(i+ilen) = schar(i)
++ fileout(i+ilen:i+ilen) = schar(i)
+ enddo
+- if (util_system (cmd) .eq. 0) then
+- Write (fu6,600) cmd
+- else
+- Write (fu6,601) cmd
+- call errquit('drdy_wfiles: problem with system call',
+- * 555, UNKNOWN_ERR)
+- endif
++ write(luout,*)'copy '//filein(1:inp_strlen(filein))//
++ + ' --> '//fileout(1:inp_strlen(fileout))
++ call util_file_copy(filein,fileout)
+ endif
+ if(lgs(38).ge.2) then
+ call util_file_name('hess', .false., .false.,dummy_file)
+ ilen = inp_strlen(dummy_file)
+- cmd = 'cp '
+- write(cmd1,'(a,'' '',a,'' '',a,''.'')')
+- * cmd(1:inp_strlen(cmd)),dummy_file(1:ilen),
+- * dummy_file(1:ilen)
+- cmd = cmd1
+- ilen = inp_strlen(cmd)
++ filein = dummy_file(1:ilen)
++ fileout = dummy_file(1:ilen)//"."
++ ilen = inp_strlen(fileout)
+ do i=1,nstrs
+- char2(i+ilen) = schar(i)
++ fileout(i+ilen:i+ilen) = schar(i)
+ enddo
+- if (util_system (cmd) .eq. 0) then
+- Write (fu6,600) cmd
+- else
+- Write (fu6,601) cmd
+- call errquit('drdy_wfiles: problem with system call',
+- * 555, UNKNOWN_ERR)
+- endif
++ write(luout,*)'copy '//filein(1:inp_strlen(filein))//
++ + ' --> '//fileout(1:inp_strlen(fileout))
++ call util_file_copy(filein,fileout)
+ endif
+ else
+ if(.not.rtdb_cget(my_rtdb,'drdy:sptheory',1,theory))
+@@ -108,22 +96,15 @@
+ & RTDB_ERR)
+ call drdy_get_movecname(my_rtdb,theory,dummy_file)
+ ilen = inp_strlen(dummy_file)
+- cmd = 'cp '
+- write(cmd1,'(a,'' '',a,'' '',a,''.sp.'')')
+- * cmd(1:inp_strlen(cmd)),dummy_file(1:ilen),
+- * dummy_file(1:ilen)
+- cmd = cmd1
+- ilen = inp_strlen(cmd)
++ filein = dummy_file(1:ilen)
++ fileout = dummy_file(1:ilen)//".sp."
++ ilen = inp_strlen(fileout)
+ do i=1,nstrs
+- char2(i+ilen) = schar(i)
++ fileout(i+ilen:i+ilen) = schar(i)
+ enddo
+- if (util_system (cmd) .eq. 0) then
+- Write (fu6,600) cmd
+- else
+- Write (fu6,601) cmd
+- call errquit('drdy_wfiles: problem with system call',
+- * 555, INPUT_ERR)
+- endif
++ write(luout,*)'copy '//filein(1:inp_strlen(filein))//
++ + ' --> '//fileout(1:inp_strlen(fileout))
++ call util_file_copy(filein,fileout)
+ endif
+ endif
+ C
+Index: nwchem-6.1/src/driver/opt_drv.F
+===================================================================
+--- nwchem-6.1.orig/src/driver/opt_drv.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/driver/opt_drv.F 2012-09-09 16:22:33.000000000 +0200
+@@ -63,6 +63,9 @@
+ if (.not. task_gradient(rtdb))
+ $ call errquit('driver: task_gradient failed',0, GEOM_ERR)
+ call opt_get_grad(rtdb,geom) ! Into gx
++ if (ostress2) then
++ call sym_lattice_stress2(geom,gx(nat_real*3+1))
++ endif
+ if (.not. rtdb_get(rtdb,'task:energy', mt_dbl, 1, energy))
+ $ call errquit('driver: could not get energy',0, RTDB_ERR)
+ c
+@@ -1621,6 +1624,7 @@
+ $ l_hess, k_hess)) call errquit
+ $ ('driver_search_dir: memory for hessian',nvar**2, MA_ERR)
+ call driver_project_hess_grad(dbl_mb(k_hess), pg)
++ if (ostress2) call sym_lattice_stress2(geom,pg(3*nat_real+1))
+ c
+ c Diagonalize the Hessian. Should really do the generalized
+ c eigenvalue problem since the underlying basis is not independent
+@@ -2848,7 +2852,7 @@
+ $ g, 1, 0d0, pg, 1)
+ if (odebug) then
+ write(6,*) ' Gradient after projection'
+- call doutput(g, 1, nvar, 1, 1, nvar, 1, 1)
++ call doutput(pg, 1, nvar, 1, 1, nvar, 1, 1)
+ endif
+ c
+ c PHP + 1000*(1-P)
+@@ -3729,6 +3733,11 @@
+ if (.not. task_gradient(rtdb))
+ $ call errquit('driver: task_gradient failed',0,0)
+ call opt_get_grad(rtdb,geom) ! Into gx
++
++ if (ostress2) then
++ call sym_lattice_stress2(geom,gx(nat_real*3+1))
++ endif
++
+ if (.not. rtdb_get(rtdb,'task:energy', mt_dbl, 1, e0))
+ $ call errquit('driver: could not get energy',0,0)
+
+Index: nwchem-6.1/src/geom/geom.F
+===================================================================
+--- nwchem-6.1.orig/src/geom/geom.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/geom/geom.F 2012-09-09 16:22:33.000000000 +0200
+@@ -709,10 +709,12 @@
+ endif
+ c
+ if (.not. s) then
++ if (ga_nodeid().eq.0) then
+ write(LuOut,*) ' geom_rtdb_load: not found or rtdb corrupt: ',
+ $ names(geom)(1:lenn(geom)), ' -> ',
+ $ trans(geom)(1:lent(geom))
+ call geom_err_info('geom_rtdb_load')
++ endif
+ geom_rtdb_load = .false.
+ return
+ end if
+Index: nwchem-6.1/src/geom/geom_input.F
+===================================================================
+--- nwchem-6.1.orig/src/geom/geom_input.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/geom/geom_input.F 2012-09-09 16:22:33.000000000 +0200
+@@ -708,7 +708,6 @@
+ logical ignore,l1
+ c
+ pname = "geom_external_input"
+-#define MARAT_DEBUG
+ #ifdef MARAT_DEBUG
+ write(*,*) "in "//pname
+ #endif
+@@ -842,7 +841,7 @@
+ do i=1,ns
+ write(*,*) isel(2*i-1),isel(2*i)
+ end do
+- stop
++c stop
+ #endif
+ return
+ 998 call errquit(pname//message(1:inp_strlen(message)),
+@@ -943,6 +942,9 @@
+ + lsel)
+
+ if(.not.lsel) n=n-1
++#ifdef MARAT_DEBUG
++ write(*,*) "atom accepted",i,lsel
++#endif
+ end do
+ #ifdef MARAT_DEBUG
+ write(*,*) "n=",n
+@@ -1049,7 +1051,6 @@
+ if(i.eq.1) tags(n)=a16(2:)
+ c end of selection processing
+ end do
+-#define MARAT_DEBUG
+ #ifdef MARAT_DEBUG
+ write(*,*) "n=",n
+ do i=1,n
+@@ -1062,7 +1063,6 @@
+ 40 continue
+ call errquit(message(1:inp_strlen(message)+1)//pname,0,0)
+ end
+-#define MARAT_DEBUG
+ subroutine geom_selection(id,
+ + resi,
+ + tag,
+@@ -1109,42 +1109,35 @@
+ atag = tag
+ artag = rtag
+ lsel=.true.
++ if(ns.eq.0) return
+ c first we check for id
+- write(*,*) "testing for id"
+- otest = .false.
+ do is=1,ns
+ asel0=asel(is)
+ lnot = asel0(1:1).eq."-"
+ asel0=asel0(2:)
+- write(*,*) "asel0",asel0
+ if(asel0.eq."id") then
+- otest = .true.
+ ilo = isel(2*is-1)
+ ihi = isel(2*is)
+- write(*,*) "id,ilo,ihi,lsel",resi,ilo,ihi,lnot
+ if(id.ge.ilo.and.id.le.ihi) then
+ lsel=.not.lnot
+ else
+ lsel = lnot
+ end if
++ if(lsel) exit
+ #ifdef MARAT_DEBUG
++ write(*,*) "should not be here if ", lsel
++ write(*,*) "id,ilo,ihi,lsel",id,ilo,ihi,lsel
+ write(*,*) "new lsel",lsel
+ #endif
+ end if
+- write(*,*) "fininshed testing for id",lsel
+- if(lsel.and.otest) exit
+ end do
+-
+ if(.not.lsel) return
+
+- lsel=.true.
+- otest = .false.
+ do is=1,ns
+ asel0=asel(is)
+ lnot = asel0(1:1).eq."-"
+ asel0=asel0(2:)
+ if(asel0.eq."resi") then
+- otest=.true.
+ ilo = isel(2*is-1)
+ ihi = isel(2*is)
+ #ifdef MARAT_DEBUG
+@@ -1155,35 +1148,32 @@
+ else
+ lsel = lnot
+ end if
++ if(lsel) exit
+ #ifdef MARAT_DEBUG
+ write(*,*) "new lsel",lsel
+ #endif
+ end if
+- if(lsel.and.otest) exit
+ end do
+
+ if(.not.lsel) return
+
+- lsel=.true.
+- otest = .false.
+ do is=1,ns
+ asel0=asel(is)
+ lnot = asel0(1:1).eq."-"
+ asel0=asel0(2:)
+ if(asel0(1:5).eq."aname") then
+- otest = .true.
+ if(atag.eq.asel0(6:)) then
+ lsel=.not.lnot
+ else
+ lsel = lnot
+ end if
+ end if
+- if(lsel.and.otest) exit
++ if(lsel) exit
++ message = 'lsel.and.otest 1183'
+ end do
++
+ if(.not.lsel) return
+
+- lsel = .true.
+- otest = .false.
+ do is=1,ns
+ asel0=asel(is)
+ lnot = asel0(1:1).eq."-"
+@@ -1195,9 +1185,9 @@
+ lsel = lnot
+ end if
+ end if
+- if(lsel.and.otest) exit
++ message = 'lsel.and.otest 1201'
++ if(lsel) exit
+ end do
+- if(.not.lsel) return
+
+ #ifdef MARAT_DEBUG
+ write(*,*) "out "//pname
+@@ -1282,7 +1272,8 @@
+ lsel=.not.lsel
+ end if
+ end if
+- if(.not.lsel) exit
++ message = '.not.lsel 1289'
++ if(.not.lsel) goto 40
+ end do
+ #ifdef MARAT_DEBUG
+ write(*,*) "out "//pname
+@@ -3620,22 +3611,22 @@
+ c ----- Special check for Xe --------------------------------------
+ c ----- Bq are ghost centers and not to be touched ----------------
+ c
+- 230 continue
+- do icenter=1,ncenter
+- if ((inp_compare(.false.,tags(icenter)(1:1),'x')).and.
+- & (.not.inp_compare(.false.,tags(icenter)(1:2),'xe'))) then
+- do jcenter=icenter+1,ncenter
+- coords(1,jcenter-1)=coords(1,jcenter)
+- coords(2,jcenter-1)=coords(2,jcenter)
+- coords(3,jcenter-1)=coords(3,jcenter)
+- charge(jcenter-1)=charge(jcenter)
+- tags(jcenter-1)=tags(jcenter)
+- enddo
+- ncenter=ncenter-1
+- found_cart = .true.
+- goto 230
+- endif
+- enddo
++c230 continue
++c do icenter=1,ncenter
++c if ((inp_compare(.false.,tags(icenter)(1:1),'x')).and.
++c & (.not.inp_compare(.false.,tags(icenter)(1:2),'xe'))) then
++c do jcenter=icenter+1,ncenter
++c coords(1,jcenter-1)=coords(1,jcenter)
++c coords(2,jcenter-1)=coords(2,jcenter)
++c coords(3,jcenter-1)=coords(3,jcenter)
++c charge(jcenter-1)=charge(jcenter)
++c tags(jcenter-1)=tags(jcenter)
++c enddo
++c ncenter=ncenter-1
++c found_cart = .true.
++c goto 230
++c endif
++c enddo
+ C
+ RETURN
+ 9999 FORMAT(A80)
+Index: nwchem-6.1/src/gradients/grad_force.F
+===================================================================
+--- nwchem-6.1.orig/src/gradients/grad_force.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/gradients/grad_force.F 2012-09-09 16:22:33.000000000 +0200
+@@ -215,8 +215,8 @@
+ if (.not. rtdb_cget(rtdb, 'mcscf:input vectors', 1, movecs_in))
+ $ call errquit('gradients: MCSCF MO vectors not defined',0,
+ & RTDB_ERR)
+- scftype = 'mcscf'
+- lscftype = 'mcscf'
++ scftype = 'MCSCF'
++ lscftype = 'MCSCF'
+ else if (theory .eq. 'dft') then
+ odft = .true.
+ if (.not. rtdb_cget(rtdb, 'dft:input vectors', 1, movecs_in))
+@@ -256,10 +256,13 @@
+ else
+ omp2 = .false.
+ end if
+-
++c
++ call inp_ucase(scftype)
++ call inp_ucase(lscftype)
++c
+ C scftype: MCSCF, RHF, ROHF or UHF
+
+- if (scftype .eq. 'mcscf') then
++ if (scftype .eq. 'MCSCF') then
+ if (.not. rtdb_get(rtdb, 'mcscf:nclosed', mt_int, 1, nclosed))
+ $ nclosed = 0
+ if (.not. rtdb_get(rtdb, 'mcscf:nact', mt_int, 1, nopen))
+@@ -304,8 +307,6 @@
+ end if
+
+ end if
+-c
+- call inp_ucase(scftype)
+
+ C # of eigenvalues and density matrices
+ if (omp2) then
+Index: nwchem-6.1/src/input/memory_def.F
+===================================================================
+--- nwchem-6.1.orig/src/input/memory_def.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/input/memory_def.F 2012-09-09 16:22:33.000000000 +0200
+@@ -38,7 +38,7 @@
+ C the lowest priority quantit(y/ies) will be modified to resolve
+ C them.
+ C
+-C On input, ?Source = 'U' indicates user-provided input. All others
++C On input, Source = 'U' indicates user-provided input. All others
+ C must be 'N' for "not specified". On output, notations may be:
+ C N)ot specified
+ C F)ile .nwchemrc
+@@ -216,6 +216,20 @@
+ Total = Total_Dflt
+ TSource = 'D' ! Default
+ EndIf
++c
++c Set up defaults, the remaining inputs are considered as
++c modifications of the defaults
++c
++ If (inp_compare(.false.,GSource, 'N')) Then
++ Global = Global_Frc*Total_Dflt
++ EndIf
++ If (inp_compare(.false.,HSource, 'N')) Then
++ Heap = Heap_Frc*Total_Dflt
++ EndIf
++ If (inp_compare(.false.,SSource, 'N')) Then
++ Stack = Stack_Frc*Total_Dflt
++ EndIf
++c
+ C
+ C Work out which variable(s) may be overridden based on the sources
+ C of the others.
+@@ -225,66 +239,139 @@
+ HOverride = memory_override(HSource,TSource,SSource,GSource)
+ GOverride = memory_override(GSource,TSource,SSource,HSource)
+ c
+- if (.not.(TOverride.or.SOverride.or.HOverride.or.GOverride)) then
++c There are 16 potential cases which we work out below
++c
++ if (TOverride) then
++ if (SOverride) then
++ if (HOverride) then
++ if (GOverride) then
++c T T T T: all settings have equal priority so they must
++c match
+ if (Total .ne. Stack + Heap + Global) then
+ Call ErrQuit(
+ & 'Memory_Defaults: Inconsistent memory specification',
+ & Total-Stack-Heap-Global, INPUT_ERR)
+ endif
+- else if (SOverride.or.HOverride.or.GOverride) then
+- if (SOverride.and.HOverride.and.GOverride) then
+- Stack = Stack_Frc*Total
++ else ! GOverride
++c T T T F: global is set, all others to be computed.
++c compute total as sum of the rest.
++ TSource = 'C'
++ Total = Stack+Heap+Global
++ endif ! GOverride
++ else ! HOverride
++ if (GOverride) then
++c T T F T: heap is set, all others to be computed.
++c compute total as sum of the rest
++ TSource = 'C'
++ Total = Stack+Heap+Global
++ else ! GOverride
++c T T F F: heap and global are set all others to be computed.
++c compute total as sum of the rest
++ TSource = 'C'
++ Total = Stack+Heap+Global
++ endif ! GOverride
++ endif ! HOverride
++ else ! SOverride
++ if (HOverride) then
++ if (GOverride) then
++c T F T T: stack is set, all others to be computed.
++c compute total as sum of the rest
++ TSource = 'C'
++ Total = Stack+Heap+Global
++ else ! GOverride
++c T F T F: stack and global are set, all others to be computed.
++c compute total as sum of the rest
++ TSource = 'C'
++ Total = Stack+Heap+Global
++ endif ! GOverride
++ else ! HOverride
++ if (GOverride) then
++c T F F T: stack and heap are set, all others to be computed.
++c compute total as sum of the rest
++ TSource = 'C'
++ Total = Stack+Heap+Global
++ else ! GOverride
++c T F F F: stack, heap and global are set, total to be computed.
++c compute total as sum of the rest
++ TSource = 'C'
++ Total = Stack+Heap+Global
++ endif ! GOverride
++ endif ! HOverride
++ endif ! SOVerride
++ else ! TOverride
++ if (SOverride) then
++ if (HOverride) then
++ if (GOverride) then
++c F T T T: total is set, all others are to be computed.
++c split total according to standard fractions
+ SSource = 'C'
+- Heap = Heap_Frc*Total
+ HSource = 'C'
+- Global = Global_Frc*Total
+ GSource = 'C'
+- else if ((.not.SOverride).and.HOverride.and.GOverride) then
+- Heap = Heap_Frc*(Total-Stack)
++ Stack = Stack_Frc*Total
++ Heap = Heap_Frc*Total
++ Global = Global_Frc*Total
++ else ! GOverride
++c F T T F: total and global are set, all others are to be computed.
++c split remainder of total according to standard fractions
++ SSource = 'C'
+ HSource = 'C'
+- Global = Global_Frc*(Total-Stack)
+- GSource = 'C'
+- else if ((.not.HOverride).and.SOverride.and.GOverride) then
+- Stack = Stack_Frc*(Total-Heap)
++ Stack = Stack_Frc*(Total-Global)/(Stack_Frc+Heap_Frc)
++ Heap = Heap_Frc*(Total-Global)/(Stack_Frc+Heap_Frc)
++ endif ! GOverride
++ else ! HOverride
++ if (GOverride) then
++c F T F T: total and heap are set, all others are to be computed.
++c split remainder of total according to standard fractions
+ SSource = 'C'
+- Global = Global_Frc*(Total-Heap)
+ GSource = 'C'
+- else if ((.not.GOverride).and.SOverride.and.HOverride) then
+- Stack = Stack_Frc*(Total-Global)
++ Stack = Stack_Frc*(Total-Heap)/(Stack_Frc+Global_Frc)
++ Global = Global_Frc*(Total-Heap)/(Stack_Frc+Global_Frc)
++ else ! GOverride
++c F T F F: total, heap and global are set, stack is to be computed.
+ SSource = 'C'
+- Heap = Heap_Frc*(Total-Global)
+- GSource = 'C'
+- else if ((.not.SOverride).and.(.not.HOverride).and.GOverride)
+- & then
+- Global = Global_Frc*(Total-Stack-Heap)
++ Stack = Total-Heap-Global
++ endif ! GOverride
++ endif ! HOverride
++ else ! SOverride
++ if (HOverride) then
++ if (GOverride) then
++c F F T T: total and stack are set, all others are to be computed.
++c split remainder of total according to standard fractions
++ HSource = 'C'
+ GSource = 'C'
+- else if ((.not.HOverride).and.(.not.GOverride).and.SOverride)
+- & then
+- Stack = Stack_Frc*(Total-Heap-Global)
+- SSource = 'C'
+- else if ((.not.SOverride).and.(.not.GOverride).and.HOverride)
+- & then
+- Heap = Heap_Frc*(Total-Stack-Global)
++ Heap = Heap_Frc*(Total-Stack)/(Global_Frc+Heap_Frc)
++ Global = Global_Frc*(Total-Stack)/(Global_Frc+Heap_Frc)
++ else ! GOverride
++c F F T F: total, stack and global are set, heap is to be computed.
+ HSource = 'C'
+- endif
+- Heap = max(0,Heap)
+- Stack = max(0,Stack)
+- Global = max(0,Global)
+- if (TOverride) then
++ Heap = Total-Stack-Global
++ endif ! GOverride
++ else ! HOverride
++ if (GOverride) then
++c F F F T: total, stack and heap are set, global is to be computed.
++ GSource = 'C'
++ Global = Total-Stack-Heap
++ else ! GOverride
++c F F F F: total, stack, heap and global are set, the settings
++c better match
+ if (Total .ne. Stack + Heap + Global) then
+- Total = Stack + Heap + Global
+- TSource = 'R'
+- endif
++ Call ErrQuit(
++ & 'Memory_Defaults: Inconsistent memory specification',
++ & Total-Stack-Heap-Global, INPUT_ERR)
+ endif
+- else ! (TOverride)
++ endif ! GOverride
++ endif ! HOverride
++ endif ! SOVerride
++ endif ! TOverride
++c
+ Heap = max(0,Heap)
+ Stack = max(0,Stack)
+ Global = max(0,Global)
++ Total = max(0,Total)
+ if (Total .ne. Stack + Heap + Global) then
+ Total = Stack + Heap + Global
+ TSource = 'R'
+ endif
+- endif
+ *
+ * rjh: ensure that heap+stack are at least 6 mb
+ *
+@@ -343,8 +430,8 @@
+ c
+ Highest = 'N'
+ Lowest = 'U'
+- if ((Highest.eq.'N').and.(Tvar1.eq.'D'.or.Tvar1.eq.'F'.or.
+- & Tvar1.eq.'E'.or.Tvar1.eq.'U')) then
++ if ((Highest.eq.'N').and.(Tvar1.eq.'F'.or.Tvar1.eq.'E'.or.
++ & Tvar1.eq.'U')) then
+ Highest = Tvar1
+ else if ((Highest.eq.'D').and.(Tvar1.eq.'F'.or.Tvar1.eq.'E'.or.
+ & Tvar1.eq.'U')) then
+@@ -354,8 +441,8 @@
+ else if ((Highest.eq.'E').and.(Tvar1.eq.'U')) then
+ Highest = Tvar1
+ endif
+- if ((Highest.eq.'N').and.(Tvar2.eq.'D'.or.Tvar2.eq.'F'.or.
+- & Tvar2.eq.'E'.or.Tvar2.eq.'U')) then
++ if ((Highest.eq.'N').and.(Tvar2.eq.'F'.or.Tvar2.eq.'E'.or.
++ & Tvar2.eq.'U')) then
+ Highest = Tvar2
+ else if ((Highest.eq.'D').and.(Tvar2.eq.'F'.or.Tvar2.eq.'E'.or.
+ & Tvar2.eq.'U')) then
+@@ -365,8 +452,8 @@
+ else if ((Highest.eq.'E').and.(Tvar2.eq.'U')) then
+ Highest = Tvar2
+ endif
+- if ((Highest.eq.'N').and.(Tvar3.eq.'D'.or.Tvar3.eq.'F'.or.
+- & Tvar3.eq.'E'.or.Tvar3.eq.'U')) then
++ if ((Highest.eq.'N').and.(Tvar3.eq.'F'.or.Tvar3.eq.'E'.or.
++ & Tvar3.eq.'U')) then
+ Highest = Tvar3
+ else if ((Highest.eq.'D').and.(Tvar3.eq.'F'.or.Tvar3.eq.'E'.or.
+ & Tvar3.eq.'U')) then
+@@ -445,6 +532,8 @@
+ memory_override = .true.
+ else if ((Lowest.eq.'D').and.(Tcandidate.eq.'N')) then
+ memory_override = .true.
++ else if ((Lowest.eq.'N').and.(Tcandidate.eq.'D')) then
++ memory_override = .true.
+ endif
+ endif
+ c
+Index: nwchem-6.1/src/mcscf/mcscf.F
+===================================================================
+--- nwchem-6.1.orig/src/mcscf/mcscf.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/mcscf/mcscf.F 2012-09-09 16:22:33.000000000 +0200
+@@ -595,6 +595,7 @@
+ call sym_movecs_adapt(basis, 1.d-8, g_movecs,
+ $ int_mb(k_sym), nmixed)
+ call ga_orthog_mos(basis, g_movecs)
++ call movecs_fix_phase(g_movecs)
+ c
+ call mcscf_save_vec(rtdb,geom,basis, nbf,
+ $ dbl_mb(k_evals), dbl_mb(k_occ), g_movecs)
+@@ -671,7 +672,6 @@
+ call ecce_print1('two-electron energy', mt_dbl, etwo, 1)
+ call ecce_print1('one-electron energy', mt_dbl, eone, 1)
+ call ecce_print1('nuclear repulsion energy', mt_dbl, enrep, 1)
+- call movecs_fix_phase(g_movecs)
+ call movecs_ecce(nbf, nbf, 1, min(nclosed+nact+20,nbf),
+ $ dbl_mb(k_evals),
+ $ dbl_mb(k_occ), int_mb(k_sym),
+Index: nwchem-6.1/src/mcscf/mcscf_fcore.F
+===================================================================
+--- nwchem-6.1.orig/src/mcscf/mcscf_fcore.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/mcscf/mcscf_fcore.F 2012-09-09 16:22:33.000000000 +0200
+@@ -75,8 +75,8 @@
+ endif
+ enddo
+ enddo
+-
+ c
++ call ga_sync()
+ c
+ c
+ return
+Index: nwchem-6.1/src/moints/moints_semi.F
+===================================================================
+--- nwchem-6.1.orig/src/moints/moints_semi.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/moints/moints_semi.F 2012-09-09 16:22:33.000000000 +0200
+@@ -259,10 +259,12 @@
+ if(eaf_size_in_mb.ne.0) then
+ eaftype=1000000+eaf_size_in_mb*1024*1024
+ else
+- eaftype=1000000+inntsize*k_file_size*11/10
++ eaftype=1000000+(inntsize*max(1024d0,k_file_size)*
++ * 11)/10
+ endif
+ if(ga_nodeid().eq.0) then
+- write(6,*)' EAF moints', eaf_size_in_mb, eaftype
++ write(6,*)' EAF moints', eaf_size_in_mb, eaftype,
++ C k_file_size
+ call util_flush(6)
+ endif
+ #else
+Index: nwchem-6.1/src/mp2_grad/mp2_back_transform.F
+===================================================================
+--- nwchem-6.1.orig/src/mp2_grad/mp2_back_transform.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/mp2_grad/mp2_back_transform.F 2012-09-09 16:22:33.000000000 +0200
+@@ -147,7 +147,8 @@
+ if(eaf_size_in_mb.ne.0) then
+ eaftype=1000000+eaf_size_in_mb*1024*1024
+ else
+- eaftype=1000000+inntsize*p_file_size*11/10
++ eaftype=1000000+(inntsize*max(1024d0,p_file_size)*
++ * 11)/10
+ endif
+ if(ga_nodeid().eq.0) then
+ write(6,*)' EAF nonsep ',
+Index: nwchem-6.1/src/mp2_grad/mp2_grad_doit.F
+===================================================================
+--- nwchem-6.1.orig/src/mp2_grad/mp2_grad_doit.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/mp2_grad/mp2_grad_doit.F 2012-09-09 16:22:33.000000000 +0200
+@@ -272,7 +272,8 @@
+ if(eaf_size_in_mb.ne.0) then
+ eaftype=1000000+eaf_size_in_mb*1024*1024
+ else
+- eaftype=1000000+inntsize*k_file_size*11/10
++ eaftype=1000000+(inntsize*max(1024d0,k_file_size)*
++ * 11)/10
+ endif
+ #else
+ eaftype=EAF_RW
+Index: nwchem-6.1/src/nwdft/coulomb/dft_fitcd.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/coulomb/dft_fitcd.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/coulomb/dft_fitcd.F 2012-09-09 16:22:33.000000000 +0200
+@@ -567,6 +567,7 @@
+ #else
+ call dcopy(nbf_cd,0.D0,0,dbl_mb(iTcgtf),1)
+ c
++ call ga_sync()
+ call ga_distribution(g_cdinv,me,ilo,ihi,jlo,jhi)
+ if (ilo.gt.0) then
+ call ga_access(g_cdinv, ilo, ihi, jlo, jhi, adrc, ldc)
+@@ -584,7 +585,7 @@
+ call ga_release(g_cdinv, ilo, ihi, jlo, jhi)
+ endif
+ #endif
+-cedo call ga_sync
++ call ga_sync
+ call ga_dgop(Msg_CD_coef,CD_coef,nbf_cd*nfit,'+')
+ c!!! What Msg should be here? !!!
+ call ga_dgop(Msg_Tcgtf,dbl_mb(iTcgtf),nbf_cd,'+')
+Index: nwchem-6.1/src/nwdft/coulomb/dft_fitvc.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/coulomb/dft_fitvc.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/coulomb/dft_fitvc.F 2012-09-09 16:22:33.000000000 +0200
+@@ -240,12 +240,11 @@
+ if(dermat) then
+ call errquit('fitvc: not coded yet',0,0)
+ else
+- if(ifirstd.ne.ifirstc)
+- S call dscal(nshbfc*nshbfd, 2d0, dbl_mb(isvec), 1)
+- call ga_put(g_vc,
+- * ifirstd,ilastd,
+- * ifirstc,ilastc,
+- * dbl_mb(isvec),nshbfd)
++ call sca_lab_mat(AO_bas_han,ishc,ishd,
++ & nshbfc,nshbfd,g_vc,
++!old & DBL_MB(isvec+(imat-1)*Nao2),dbl_mb(isvec2),
++ & DBL_MB(isvec),dbl_mb(isvec2),
++ . 'put')
+ endif
+ c
+ endif
+@@ -411,12 +410,10 @@
+ & DBL_MB(isvec),dbl_mb(isvec2),
+ . 'put')
+ else
+- if(ifirstd.ne.ifirstc)
+- S call dscal(nshbfc*nshbfd, 2d0, dbl_mb(isvec), 1)
+- call ga_put(g_vc,
+- * ifirstd,ilastd,
+- * ifirstc,ilastc,
+- * dbl_mb(isvec),nshbfd)
++ call sca_lab_mat(AO_bas_han,ishc,ishd,
++ & nshbfc,nshbfd,g_vc,
++ & DBL_MB(isvec),dbl_mb(isvec2),
++ . 'put')
+ endif
+ endif
+ c
+@@ -447,7 +444,6 @@
+ c
+ c
+ n1 = nxtask(-nproc,icount)
+- call ga_symmetrize(g_vc)
+ c
+ if(.not.ma_pop_stack(lcd_shell))
+ & call errquit('dft_fitvc: cannot pop stack',0,0)
+@@ -470,6 +466,7 @@
+ c !!! Looks like g_2ceri not needed in that case
+ c
+ Ecoul2=0.D0
++ call ga_sync()
+ call ga_distribution(g_2ceri,me,ilo,ihi,jlo,jhi)
+ if (ilo.gt.0) then
+ call ga_access(g_2ceri, ilo, ihi, jlo, jhi, adrc, ldc)
+@@ -486,7 +483,7 @@
+ Ecoul2=Ecoul2*0.5D0
+ c
+ c write(*,*)'*** After destroy g_2ceri'
+-c call ga_sync
++ call ga_sync
+ call ga_dgop(Msg_Ecoul2,Ecoul2,1,'+')
+ if (IOLGC)then
+ if (.not. ga_destroy(g_2ceri)) call errquit
+Index: nwchem-6.1/src/nwdft/grid/grid_atom_type_info.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/grid/grid_atom_type_info.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/grid/grid_atom_type_info.F 2012-09-09 16:22:33.000000000 +0200
+@@ -162,11 +162,19 @@
+ c
+ if (abs(znuc_atom_type(itype)).lt.EPS) then ! uncharged ghost atom;
+ c
+-c identify atom label following "bq"
++c identify atom label following "bq" or "x" (we already know this
++c cannot be element Xeon).
+ c
+ iptr=3
+ c hack for nbo
+ if(tag(3:4).eq.'gh') iptr=5
++c
++c Dummy centers (i.e. X, XH, X1, whatever) by convention
++c cannot have charges or basis sets. They are purely
++c mathematical constructs to specify complex Z-matrices.
++c Hence they should always have i_atomic_number .eq. 0
++c no matter what follows the X.
++c
+ if(tag(1:1).eq.'X'.or.tag(1:1).eq.'x') iptr=2
+ if (.not. geom_tag_to_element(tag(iptr:), symbol,
+ & element, i_atomic_number)) then
+@@ -180,6 +188,10 @@
+ & 0, INPUT_ERR)
+ &
+ endif
++ else
++ if (inp_compare(.false.,tag(1:1),'X')) then
++ i_atomic_number = 0
++ endif
+ endif
+ c
+ c
+Index: nwchem-6.1/src/nwdft/grid/grid_cleanup.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/grid/grid_cleanup.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/grid/grid_cleanup.F 2012-09-09 16:22:33.000000000 +0200
+@@ -17,21 +17,15 @@
+ c
+ c case of pure HF X
+ c
+- if(.not.xc_gotxc()) return
++ if(.not.xc_gotxc().or.(.not.file_opened)) return
+ c
+ c
+ call grid_closecache
+ if(.not.largenode) then
+ if(.not.grid_file_close(okeep)) call
+ . errquit(' grclup: file_close failed',0, DISK_ERR)
+-#if 0
+- if(.not.okeep) then
+- open(unit=gr_unit,file=grinfo)
+- close(unit=gr_unit,status='delete')
+- endif
+-#else
+-#endif
+ endif
++ file_opened=.false.
+
+ c
+ return
+Index: nwchem-6.1/src/nwdft/grid/grid_eaf.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/grid/grid_eaf.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/grid/grid_eaf.F 2012-09-09 16:22:33.000000000 +0200
+@@ -11,6 +11,7 @@
+ #include "stdio.fh"
+ #include "util.fh"
+ #include "grid_eaf.fh"
++#include "inp.fh"
+ integer fdg
+ character*(*) grinfo, what
+ double precision enuc_in
+@@ -26,7 +27,7 @@
+ cgrinfo enuc in first record
+ if(what.eq.'write') then
+ uenuc=enuc_in
+-#if 0
++#if 1
+ cdump garbage on next record to invalidate fields
+ uvect(1)=-123
+ uvect(2)=-123
+@@ -61,6 +62,7 @@
+ c
+ integer foplog,ierr
+ logical otrace
++ ierr=0
+ c
+ otrace = util_print('grinfodebug',print_debug)
+ if(otrace) then
+@@ -78,14 +80,19 @@
+ uvect(2)=max_cache_rec
+ uvect(3)=n_rec_in_file
+ uvect(4)=foplog
++ fdg=1
+ else
+ max_file_rec =uvect(1)
+ max_cache_rec=uvect(2)
+ n_rec_in_file=uvect(3)
+ foplog =uvect(4)
+ file_opened=foplog.eq.1
++c if(fdg.eq.-1) then
++c ierr=-1
++c file_opened=.false.
++c n_rec_in_file=0
++c endif
+ endif
+- ierr=0
+ if (otrace) then
+ write(LuOut,*) '2INFO ' // what(1:4) // ' from ',grinfo
+ write(LuOut,*) ' ierr ',ierr
+Index: nwchem-6.1/src/nwdft/grid/grid_file.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/grid/grid_file.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/grid/grid_file.F 2012-09-09 16:22:33.000000000 +0200
+@@ -42,10 +42,9 @@
+ character*80 errmsg
+ character*256 grinfo_in
+ external util_scratch_dir_avail_for_me
+- logical grid_file_rewind
++ logical grid_file_rewind,grid_file_close
+ logical oreafail
+- integer eaftypegr
+- external grid_file_rewind
++ external grid_file_rewind,grid_file_close
+ logical grid_grinfoinit,grid_grinfo2,grid_ptsalloc
+ external grid_grinfoinit,grid_grinfo2,grid_ptsalloc
+ c Open file returning CHEMIO filehandle (not yet)
+@@ -191,6 +190,9 @@
+ grid_file_open=.true.
+ if (.not. grid_file_rewind())
+ $ call errquit('grfile: rewinding gridpts?',1, DISK_ERR)
++cbugfix for idle procs
++ if(n_rec_in_file.le.0) return
++
+ file_opened=.false.
+ filedump_opened=.false.
+ #ifndef EAFHACK
+@@ -198,7 +200,7 @@
+ #else
+ ierr=-1
+ if(grid_ptsalloc(fd,eaf_size_in_dbl,
+- C actualname))ierr=0
++ C 'gridpts'))ierr=0
+ #endif
+ if (ierr .ne. 0) then
+ call eaf_errmsg(ierr,errmsg)
+@@ -231,7 +233,7 @@
+ logical oprint,lstatus
+ integer ierr
+ double precision ll
+- logical grid_grinfo2,grid_ptsdel
++ logical grid_grinfo2,grid_ptsdel,file_closedone
+ external grid_grinfo2,grid_ptsdel
+ oprint=util_print('iostats',print_high).and.ga_nodeid().eq.0
+ c
+@@ -242,15 +244,7 @@
+ if (eaf_close(fd) .ne. 0) call errquit
+ $ ('grid_file_close: eaf_close failed',0, DISK_ERR)
+ #endif
+- if (.not. okeep) then
+-#ifndef EAFHACK
+- if (eaf_delete(actualname) .ne. 0) call errquit
+- $ ('grid_file_close: delete failed', 0, DISK_ERR)
+-#else
+- if (.not.grid_ptsdel(fd)) call errquit
+- $ ('grid_file_close: delete failed', 1, MA_ERR)
+-#endif
+- endif
++ file_closedone=.true.
+ endif
+ c
+ if(okeep) then
+@@ -262,10 +256,25 @@
+ fdg=-1
+ endif
+ else
++#ifndef EAFHACK
++ if(fd.ne.-1) then
++ if(.not.file_closedone) then
++ if (eaf_close(fd) .ne. 0) call errquit
++ $ ('grid_file_close: eaf_close2 for fd ',fd, DISK_ERR)
++ endif
++ if (eaf_delete(actualname) .ne. 0) call errquit
++ $ ('grid_file_close: delete failed', 0, DISK_ERR)
++ endif
++#else
++ if (.not.grid_ptsdel(fd)) call errquit
++ $ ('grid_file_close: delete failed', 1, MA_ERR)
++#endif
+ fdg=-1
+ endif
+ c
++#ifdef OLD
+ call ga_igop(msg_grid_stat1, n_rec_in_file, 1, '+')
++#endif
+ if (oprint) then
+ write(LuOut,1) n_rec_in_file
+ 1 format(/
+@@ -273,6 +282,7 @@
+ call util_flush(LuOut)
+ end if
+ 2001 continue
++
+ if (otrace) then
+ write(LuOut,*) ' grid_file: closing ',
+ $ actualname(1:inp_strlen(actualname))
+@@ -340,8 +350,8 @@
+ #include "stdio.fh"
+ #include "global.fh"
+ logical oend ! [input]
+- logical grid_opencache,status,grid_ptsalloc
+- external grid_opencache,grid_ptsalloc
++ logical grid_opencache,status,grid_ptsalloc,grid_file_close
++ external grid_opencache,grid_ptsalloc,grid_file_close
+ c
+ c Write the grid_pts buffer to disk. For all but the
+ c end record it is called with oend=.false. meaning
+@@ -395,7 +405,7 @@
+ #else
+ ierr=-1
+ if(grid_ptsalloc(fd,eaftype-1000000,
+- C actualname)) ierr=0
++ C 'gridpts')) ierr=0
+ #endif
+ if(ierr.ne.0) call
+ E errquit('grid_pckbufw: eaf_open failed', 0,
+@@ -662,7 +672,7 @@
+ c
+ grid_test_mem = .false.
+ c
+- if (file_opened) return
++cbad if (file_opened) return
+ oreopen=.false.
+ if (.not. rtdb_get(rtdb, 'grid:filesize',
+ $ MT_INT, 1, filesize)) filesize = 0
+@@ -902,7 +912,6 @@
+ #include "errquit.fh"
+ #include "geom.fh"
+ #include "cgridfile.fh"
+-cedo#include "bgj.fh"
+ c
+ integer geom ![in]
+ c
+Index: nwchem-6.1/src/nwdft/so_dft/dft_scaleMO_so.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/so_dft/dft_scaleMO_so.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/so_dft/dft_scaleMO_so.F 2012-09-09 16:22:33.000000000 +0200
+@@ -95,7 +95,9 @@
+ write(*,191) nTotOcc,ac_occ,diff_occ,error_Iocc
+ 191 format('(nTotOcc,ac_occ,diff_occ,error_Iocc)=(',i4,',',f15.8,
+ & ',',f15.8,',',f15.8)
+- stop
++ call errquit('scaleMO_so: no. electrons from occupations '//
++ & 'keyword does not match the total no. electrons',
++ & ac_occ,UERR)
+ else
+ c ---- Calculate Sqrt(n_i)
+ c if (ga_nodeid().eq.0)
+Index: nwchem-6.1/src/nwdft/so_dft/dft_scf_so.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/so_dft/dft_scf_so.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/so_dft/dft_scf_so.F 2012-09-09 16:22:33.000000000 +0200
+@@ -461,25 +461,25 @@
+ & g_moso(1)))
+ & call errquit('dft_scf_so: error creating Movecs Re',0,
+ & GA_ERR)
+- if(.not.ga_create(mt_dbl,nbf_ao,nbf_ao,'Movecs Re',0,0,
+- & g_gmovecs(1)))
+- & call errquit('dft_scf_so: error creating Movecs Re',0,
+- & GA_ERR)
++c if(.not.ga_create(mt_dbl,nbf_ao,nbf_ao,'Movecs Re',0,0,
++c & g_gmovecs(1)))
++c & call errquit('dft_scf_so: error creating Movecs Re',0,
++c & GA_ERR)
+ c
+ c imaginary molecular orbital vectors
+ if(.not.ga_create(mt_dbl,nbf_mo, nbf_mo,'Movecs Im',0,0,
+ & g_moso(2)))
+ & call errquit('dft_scf_so: error creating Movecs Im',0,
+ & GA_ERR)
+- if(.not.ga_create(mt_dbl,nbf_ao, nbf_ao,'Movecs Im',0,0,
+- & g_gmovecs(2)))
+- & call errquit('dft_scf_so: error creating Movecs Im',0,
+- & GA_ERR)
++c if(.not.ga_create(mt_dbl,nbf_ao, nbf_ao,'Movecs Im',0,0,
++c & g_gmovecs(2)))
++c & call errquit('dft_scf_so: error creating Movecs Im',0,
++c & GA_ERR)
+ c
+ call ga_zero(g_moso(1))
+ call ga_zero(g_moso(2))
+- call ga_zero(g_gmovecs(1))
+- call ga_zero(g_gmovecs(2))
++c call ga_zero(g_gmovecs(1))
++c call ga_zero(g_gmovecs(2))
+ c
+ call ga_sync()
+ c
+Index: nwchem-6.1/src/nwdft/util/get_col.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/util/get_col.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/util/get_col.F 2012-09-09 16:22:33.000000000 +0200
+@@ -1,17 +1,27 @@
+ subroutine get_col(g_a,n,i,vec)
+-C$Id: get_col.F 19696 2010-10-29 16:53:42Z d3y133 $
++C$Id: get_col.F 22276 2012-04-04 23:20:49Z d3y133 $
+ implicit none
++c
++c Apparently this is a wrapper routine to get a single column out
++c of a Global Array. So logically VEC is intended as an array of
++c N-by-1, and hence the leading dimension fed to GA_GET should be N.
++c
+ integer g_a,n,i
+- double precision vec(n)
+- call ga_get(g_a,
+- * 1,n,i,i,vec,1)
++ double precision vec(n,1)
++ call ga_get(g_a,1,n,i,i,vec,n)
+ return
+ end
++
++
+ subroutine put_col(g_a,n,i,vec)
+ implicit none
++c
++c Apparently this is a wrapper routine to put a single column into
++c a Global Array. So logically VEC is intended as an array of
++c N-by-1, and hence the leading dimension fed to GA_PUT should be N.
++c
+ integer g_a,n,i
+- double precision vec(n)
+- call ga_put(g_a,
+- * 1,n,i,i,vec,1)
++ double precision vec(n,1)
++ call ga_put(g_a,1,n,i,i,vec,n)
+ return
+ end
+Index: nwchem-6.1/src/nwdft/xc/xc_exso.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/xc/xc_exso.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/xc/xc_exso.F 2012-09-09 16:22:33.000000000 +0200
+@@ -91,14 +91,16 @@
+ call ga_zero(g_jk(2))
+ call ga_zero(g_jk(3))
+ call ga_zero(g_jk(4))
++c
+ jfac(1)=zero
+ jfac(2)=zero
+ jfac(3)=zero
+ jfac(4)=zero
++c
+ kfac(1)=zero
+- kfac(2)=one
++ kfac(2)=-one
+ kfac(3)=zero
+- kfac(4)=one
++ kfac(4)=-one
+ c
+ c Im(Kaa) and Im(Kbb) (g_dens(1) and g_dens(2))
+ c
+@@ -120,14 +122,13 @@
+ endif
+ call fock_2e(geom, AO_bas_han, 4, jfac, kfac,
+ & tol2e, oskel, g_d(1), g_jk(1), .true.)
+- call ga_scale(g_jk(2),dble(-1.0d0))
+- call ga_scale(g_jk(4),dble(-1.0d0))
+- call asym_fock2e(g_jk(2))
+- call asym_fock2e(g_jk(4))
++ call asym_fock2e(g_jk(2)) ! asymmetrize outside
++ call asym_fock2e(g_jk(4)) ! asymmetrize outside
+ c
+ exc(1) = exc(1) + xfac(1)*0.5d0*( ! All exchange energy (i.i=-1)
+ $ onem*ga_ddot(g_dens(1),g_jk(2)) +
+ $ onem*ga_ddot(g_dens(2),g_jk(4)))
++c
+ call ga_dadd_patch(1.0d0,g_fockso(2),1,nao,1,nao,
+ & xfac(1),g_jk(2), 1,nao,1,nao,
+ & g_fockso(2),1,nao,1,nao)
+@@ -165,22 +166,28 @@
+ g_d(4) = g_dens(2)
+ call fock_2e(geom, AO_bas_han, 4, jfac, kfac,
+ & tol2e, oskel, g_d(1), g_jk(1), .true.)
+- call ga_scale(g_jk(2),dble(-1.0d0))
+- call ga_scale(g_jk(4),dble(-1.0d0))
+ call ga_transpose(g_jk(4),g_jk(1))
+ call ga_add(dble(0.5d0),g_jk(2),dble(0.5d0),g_jk(1),
+- & g_jk(2)) !g_jk(2) has Kab
+- call ga_transpose(g_jk(2),g_jk(4))
++ & g_jk(1))
++c
++ call ga_transpose(g_jk(2),g_jk(3))
++ call ga_add(dble(0.5d0),g_jk(4),dble(0.5d0),g_jk(3),
++ & g_jk(3))
+ c
+- exc(1) = exc(1) - xfac(1)*0.5d0*( ! All exchange energy
++ call ga_copy(g_jk(1),g_jk(2))
++ call ga_copy(g_jk(3),g_jk(4))
++c
++ exc(1) = exc(1) + xfac(1)*0.5d0*( ! All exchange energy
+ $ ga_ddot(g_dens(1),g_jk(2)) +
+ $ ga_ddot(g_dens(2),g_jk(4)))
++c
+ call ga_dadd_patch(1.0d0,g_fockso(1),1,nao,nao+1,2*nao,
+- & -xfac(1),g_jk(2), 1,nao,1,nao,
++ & xfac(1),g_jk(2), 1,nao,1,nao,
+ & g_fockso(1),1,nao,nao+1,2*nao)
+ call ga_dadd_patch(1.0d0,g_fockso(1),nao+1,2*nao,1,nao,
+- & -xfac(1),g_jk(4), 1,nao,1,nao,
++ & xfac(1),g_jk(4), 1,nao,1,nao,
+ & g_fockso(1),nao+1,2*nao,1,nao)
++c
+ if (oprint_intermediate_xc)then
+ if(me.eq.0)write(*,*)'Fock XC matrix:Re(Kab) and Im(Kab):'
+ call ga_print(g_jk(2))
+@@ -209,23 +216,29 @@
+ g_d(4) = g_dens(2)
+ call fock_2e(geom, AO_bas_han, 4, jfac, kfac,
+ & tol2e, oskel, g_d(1), g_jk(1), .true.)
+- call ga_scale(g_jk(2),dble(-1.0d0))
+- call ga_scale(g_jk(4),dble(-1.0d0))
++c
+ call ga_transpose(g_jk(4),g_jk(1))
+ call ga_add(dble(0.5d0),g_jk(2),dble(-0.5d0),g_jk(1),
+- & g_jk(2))
+- call ga_transpose(g_jk(2),g_jk(4))
+- call ga_scale(g_jk(4),dble(-1.0d0))
++ & g_jk(1))
++c
++ call ga_transpose(g_jk(2),g_jk(3))
++ call ga_add(dble(0.5d0),g_jk(4),dble(-0.5d0),g_jk(3),
++ & g_jk(3))
++c
++ call ga_copy(g_jk(1),g_jk(2))
++ call ga_copy(g_jk(3),g_jk(4))
+ c
+ exc(1) = exc(1) + xfac(1)*0.5d0*( ! All exchange energy
+ $ onem*ga_ddot(g_dens(1),g_jk(2)) +
+ $ onem*ga_ddot(g_dens(2),g_jk(4)))
++c
+ call ga_dadd_patch(1.0d0,g_fockso(2),1,nao,nao+1,2*nao,
+ & xfac(1),g_jk(2), 1,nao,1,nao,
+ & g_fockso(2),1,nao,nao+1,2*nao)
+ call ga_dadd_patch(1.0d0,g_fockso(2),nao+1,2*nao,1,nao,
+ & xfac(1),g_jk(4), 1,nao,1,nao,
+ & g_fockso(2),nao+1,2*nao,1,nao)
++c
+ if (oprint_intermediate_xc)then
+ if(me.eq.0)write(*,*)'Fock XC matrix:Re(Kba) and Im(Kba):'
+ call ga_print(g_jk(2))
+@@ -247,6 +260,7 @@
+ $ ('xc_exso: ga corrupt?',1, GA_ERR)
+ endif
+ if (oprint_time)call dft_tstamp(' After call to fock_2e. ')
++c
+ if (oprint_intermediate_xc)then
+ if(me.eq.0)write(*,*)'Fock XC matrix:Leaving xc_exso:'
+ c call ga_print(g_fockso(1))
+@@ -260,6 +274,7 @@
+ return
+ end
+ c
++c antisymmetrize fock matrix
+ subroutine asym_fock2e(g_fock)
+ implicit none
+ #include "errquit.fh"
+Index: nwchem-6.1/src/nwdft/xc/xc_hcth.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/xc/xc_hcth.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/xc/xc_hcth.F 2012-09-09 16:22:33.000000000 +0200
+@@ -682,9 +682,11 @@
+ rho = rhoa + rhob
+
+ s_a2=0.d0
+- if(za.gt.tol_rho) s_a2 = za**2.D0 / rhoa**(8.D0/3.D0)
++ if(za.gt.tol_rho.and.rhoa.gt.tol_rho)
++ + s_a2 = za**2.D0 / rhoa**(8.D0/3.D0)
+ s_b2=0.d0
+- if(zb.gt.tol_rho) s_b2 = zb**2.D0 / rhob**(8.D0/3.D0)
++ if(zb.gt.tol_rho.and.rhob.gt.tol_rho)
++ + s_b2 = zb**2.D0 / rhob**(8.D0/3.D0)
+ s_avg2 = 0.5D0*(s_a2 + s_b2)
+
+ u_caa = 0.2D0*s_a2/(1.D0+0.2D0*s_a2)
+Index: nwchem-6.1/src/nwdft/xc/xc_kt1.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/xc/xc_kt1.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/xc/xc_kt1.F 2012-09-09 16:22:33.000000000 +0200
+@@ -152,7 +152,7 @@
+ g = GAMKT * gamma * gdenom
+ c
+ Ex = Ex + g*qwght(n)*fac
+- if (ldew) func(n) = func(n) + 2d0*g*fac
++ if (ldew) func(n) = func(n) + g*fac
+ Amat(n,1) = Amat(n,1) - (4d0/3d0)*GAMKT*gamma*rho13*
+ & gdenom2*fac
+ Cmat(n,D1_GAA) = Cmat(n,D1_GAA) + GAMKT*gdenom*fac
+@@ -192,7 +192,7 @@
+ g = GAMKT * gamma * gdenom
+ c
+ Ex = Ex + g*qwght(n)*fac
+- if (ldew) func(n) = func(n) + 2d0*g*fac
++ if (ldew) func(n) = func(n) + g*fac
+ Amat(n,2) = Amat(n,2) - (4d0/3d0)*GAMKT*gamma*rho13*
+ & fac*gdenom2
+ Cmat(n,D1_GBB) = Cmat(n,D1_GBB) + GAMKT*gdenom*fac
+Index: nwchem-6.1/src/nwdft/xc/xc_replicated.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/xc/xc_replicated.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/xc/xc_replicated.F 2012-09-09 16:22:33.000000000 +0200
+@@ -38,17 +38,20 @@
+ c
+ oprint = util_print('xcreplicated', print_high)
+
+- k_repxc(1)=-1
++ do ii = 1, ipol
++ k_repxc(ii)=-1
++ g_repdm(ii)=-1
++ enddo
+ c non blocking
+ if (.not. rtdb_get(rtdb, 'dft:truerepdm', mt_log, 1,
+- N truerepdm)) truerepdm=.false.
++ + truerepdm)) truerepdm=.false.
+ if (.not. rtdb_get(rtdb, 'dft:truerepxc', mt_log, 1,
+- N truerepxc)) truerepxc=.false.
++ + truerepxc)) truerepxc=.false.
+ truerep=truerepdm.or.truerepxc
+ if (.not. rtdb_get(rtdb, 'dft:nbacc', mt_log, 1,
+- N dftnbacc)) dftnbacc=.false.
++ + dftnbacc)) dftnbacc=.false.
+ if (.not. rtdb_get(rtdb, 'dft:nbget', mt_log, 1,
+- N dftnbget)) dftnbget=.false.
++ + dftnbget)) dftnbget=.false.
+
+ c we do not mirror 3D GAs for now
+
+@@ -59,7 +62,6 @@
+ c Check number of nodes to decide to use Mirror Array
+ if(ga_cluster_nnodes().eq.1.and.(.not.truerep)) return
+
+-
+ if (.not. rtdb_get(rtdb, 'dft:dorepdm', mt_log, 1,
+ & dorepdm))
+ & dorepdm=.true.
+@@ -68,7 +70,7 @@
+ & dorepxc=.true.
+ if (rtdb_get(rtdb, 'dft:xcreplicated', mt_log, 1,
+ & xcreplicated_l)) then
+- if(.not.xcreplicated_l) return
++ if(.not.xcreplicated_l.and.(.not.truerep)) return
+ else
+ xcreplicated_l=.false.
+ endif
+@@ -117,13 +119,13 @@
+ c allocate replicated D matrix
+ c
+ truerepdm=ma_push_get(MT_Dbl,ntwo12*ipol,
+- . 'dmat',l_repdm(1),k_repdm(1))
++ + 'dmat',l_repdm(1),k_repdm(1))
+ if(truerepdm) then
+ k_repdm(2)=k_repdm(1)+ntwo12/ipol
+ if (odftps) call pstat_on(ps_xcopy)
+ do ii=1,ipol
+ call xc_bcastdm(geom,basis,nbf_ao,
+- A g_dens(ii),dbl_mb(k_repdm(ii)))
++ + g_dens(ii),dbl_mb(k_repdm(ii)))
+ enddo
+ if (odftps) call pstat_off(ps_xcopy)
+ endif
+@@ -157,20 +159,20 @@
+ if(xcrepirrg) then
+ procsmp=ga_cluster_nprocs(ga_cluster_nodeid())
+ if(.not.ma_push_get(MT_int,procsmp*2,
+- . 'ga block maps',l_map,k_map)) then
++ + 'ga block maps',l_map,k_map)) then
+ call errquit('xcrepl: not enough local mem',
+- . procsmp*2, MA_ERR)
++ + procsmp*2, MA_ERR)
+ endif
+
+ call util_atom_blocked(procsmp,
+- . geom, basis, int_mb(k_map), nblock)
++ + geom, basis, int_mb(k_map), nblock)
+
+ c
+ c compress map array
+ c
+ do ii=0,nblock(2)-1
+ int_mb(k_map+nblock(1)+ii)=
+- = int_mb(k_map+procsmp+ii)
++ + int_mb(k_map+procsmp+ii)
+ enddo
+ endif
+
+@@ -182,37 +184,41 @@
+ if(.not.dograd) then
+ if(xcrepirrg) then
+ xcrep_ga=nga_create_irreg_config(MT_DBL, 2, dims,
+- . 'replicatedxcGA',int_mb(k_map),nblock,plist,
+- . k_repxc(ii))
++ + 'replicatedxcGA',int_mb(k_map),nblock,plist,
++ + k_repxc(ii))
+ if(.not.xcrep_ga) goto 1984
+ call ga_zero(k_repxc(ii))
+ else
+ xcrep_ga=util_mirrmat(1,g_dens(ii),k_repxc(ii),
+- . .false.,.true.)
++ + .false.,.true.)
+
+ if(.not.xcrep_ga) goto 1984
+ endif
+ endif
++ else
++ xcrep_ga = .true.
+ endif
+
+
+ if(dorepdm) then
+ if(xcrepirrg) then
+ xcreplicated_l=nga_create_irreg_config(MT_DBL, 2, dims,
+- . 'replicated DM GA',int_mb(k_map),nblock,plist,
+- . g_repdm(ii))
++ + 'replicated DM GA',int_mb(k_map),nblock,plist,
++ + g_repdm(ii))
+ if(.not.xcreplicated_l) goto 1984
+
+ call ga_mask_sync(.true.,.false.)
+ call ga_copy(g_dens(ii),g_repdm(ii))
+ else
+ xcreplicated_l=
+- X util_mirrmat(1,g_dens(ii),g_repdm(ii),
+- T .true.,.false.)
++ + util_mirrmat(1,g_dens(ii),g_repdm(ii),
++ + .true.,.false.)
+
+ if(.not.xcreplicated_l) goto 1984
+
+ endif
++ else
++ xcreplicated_l = .true.
+ end if
+
+ enddo
+@@ -227,7 +233,7 @@
+ endif
+ endif
+ xcrep_glob=0
+- if(xcreplicated_l) xcrep_glob=1
++ if(xcreplicated_l.and.xcrep_ga) xcrep_glob=1
+ call ga_igop(375,xcrep_glob,1, '+')
+ xcreplicated=xcrep_glob.eq.ga_nnodes()
+
+@@ -248,14 +254,16 @@
+ $ to computing without mirrored array '
+
+ c Destroy the ones that are allocated
++c Just attempt the destroy operations. If the array is allocated
++c the destroy operation should succeed, if it is not we do not
++c care that the destroy operation fails.
++c
+ do ii=1,ipol
+- if(xcreplicated_l) then
+- if(.not.ga_destroy(g_repdm(ii)))
+- $ call errquit('grep quit', 2, 0)
+- end if
+- if(xcrep_ga) then
+- if(.not.ga_destroy(k_repxc(ii)))
+- $ call errquit('grep quit', 3,0)
++ if(.not.ga_destroy(g_repdm(ii))) then
++c we do not need to do anything
++ end if
++ if(.not.ga_destroy(k_repxc(ii))) then
++c we do not need to do anything
+ end if
+ end do
+ endif
+Index: nwchem-6.1/src/nwdft/xc/xc_vdw.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/xc/xc_vdw.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/xc/xc_vdw.F 2012-09-09 16:22:33.000000000 +0200
+@@ -237,6 +237,7 @@
+ force(1,A)=0d0
+ force(2,A)=0d0
+ force(3,A)=0d0
++ if (Z(A).ne.0) then
+ do j=1,n
+ if(A.ne.j) then
+ rAj=sqrt(
+@@ -254,6 +255,7 @@
+ enddo
+ endif
+ enddo
++ endif
+ enddo
+ if(abs(s6-1d0).gt.1d-9)
+ F call dscal(3*n,s6,force,1)
+@@ -275,6 +277,7 @@
+ force(1,A)=0.0d0
+ force(2,A)=0.0d0
+ force(3,A)=0.0d0
++ if (Z(A).ne.0) then
+ do j=1,n
+ if(A.ne.j) then
+ dxAj=x(1,A)-x(1,j)
+@@ -407,6 +410,7 @@
+ 910 continue
+ endif
+ enddo
++ endif
+ enddo
+ if (.not.ma_pop_stack(l_cnijk))
+ $ call errquit('xcvdw cnijk: cannot pop cnijk',4, MA_ERR)
+@@ -511,6 +515,7 @@
+ c
+ if (ivdw.le.2) then
+ do i=1,n-1
++ if (Z(i).ne.0) then
+ do j=i+1,n
+ rij=dsqrt(
+ + (x(1,i)-x(1,j))**2 +
+@@ -520,6 +525,7 @@
+ * fdmp(rij,r0(z(i))+r0(z(j)))*
+ * (rij)**(-6.0d0)
+ enddo
++ endif
+ enddo
+ xc_vdw_e=xc_vdw_e*s6
+ c
+@@ -527,6 +533,7 @@
+ c
+ else if (ivdw.eq.3) then
+ do i=1,n-1
++ if (Z(i).ne.0) then
+ do j=i+1,n
+ rij=dsqrt(
+ + (x(1,i)-x(1,j))**2 +
+@@ -541,6 +548,7 @@
+ e8=e8-c8*fdmp3(rij,r0AB(z(i),z(j))*sr8,alpha+2.0d0)*
+ * (rij)**(-8.0d0)
+ enddo
++ endif
+ enddo
+ xc_vdw_e=e6*s6+e8*s8
+ endif
+@@ -1156,14 +1164,13 @@
+ return
+ 99900 continue
+ write(luout,*)'hess_file => ',filehess
+- call errquit('hess_read: error opening file: "filehess"',911)
++ call errquit('xc_vdw_hess 99900', 911, DISK_ERR)
+ 99901 continue
+ write(luout,*)'hess_file => ',filehess
+- call errquit('hess_read: error reading file: "filehess"',911)
++ call errquit('xc_vdw_hess 99901', 911, DISK_ERR)
+ 99902 continue
+ write(luout,*)'hess_file => ',filehess
+- call errquit
+- & ('hess_read: unexpected EOF when reading file: "filehess"',911)
++ call errquit('xc_vdw_hess 99902', 911, DISK_ERR)
+ end
+ c
+ c fdmp(x1,x2)=1.0d0/(1.0d0+exp(-alpha*((x1/x2)-1.0d0)))
+Index: nwchem-6.1/src/nwdft/xc/xc_xm05.F
+===================================================================
+--- nwchem-6.1.orig/src/nwdft/xc/xc_xm05.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwdft/xc/xc_xm05.F 2012-09-09 16:22:33.000000000 +0200
+@@ -155,7 +155,6 @@
+ & tau(n,2,1) +
+ & tau(n,3,1)
+ tauu=tauN
+- if (taun.lt.sqrt(DTol)) goto 10
+ Gamma2 = delrho(n,1,1)*delrho(n,1,1) +
+ & delrho(n,2,1)*delrho(n,2,1) +
+ & delrho(n,3,1)*delrho(n,3,1)
+Index: nwchem-6.1/src/nwpw/band/cpsd/band_cpmd.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/band/cpsd/band_cpmd.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/band/cpsd/band_cpmd.F 2012-09-09 16:22:33.000000000 +0200
+@@ -722,7 +722,7 @@
+ icount_shift = icount_shift + 1
+ end do
+ 100 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(GCC46)
+ backspace 31
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/band/lib/electron/c_electron.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/band/lib/electron/c_electron.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/band/lib/electron/c_electron.F 2012-09-09 16:22:33.000000000 +0200
+@@ -1009,7 +1009,7 @@
+ * ******************
+ * **** get Hpsi ****
+ * ******************
+- call cpsi_Horb(.true.,nb,ispin,ms,
++ call cpsi_Horb(.true.,nb,ispin,ms,psi_r_tag,
+ > dcpl_mb(vall(1)),
+ > dbl_mb(psik_shift),
+ > dbl_mb(psir_shift),
+Index: nwchem-6.1/src/nwpw/nwpwlib/ion/shake/molecular.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/nwpwlib/ion/shake/molecular.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/nwpwlib/ion/shake/molecular.F 2012-09-09 16:22:33.000000000 +0200
+@@ -98,7 +98,7 @@
+ read(51,*,end=100) gabs(1)
+ end do
+ 100 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)|| defined(GCC46)
+ backspace 31
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/nwpwlib/ion/xyz.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/nwpwlib/ion/xyz.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/nwpwlib/ion/xyz.F 2012-09-09 16:22:33.000000000 +0200
+@@ -61,7 +61,7 @@
+ read(18,*,end=100)
+ end do
+ 100 continue
+-#if defined(FUJITSU_SOLARIS) || defined(SOLARIS) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(SOLARIS) || defined(__crayx1) || defined(GCC46)
+ backspace 18
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/nwpwlib/pseudopotential/psp_generator_input.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/nwpwlib/pseudopotential/psp_generator_input.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/nwpwlib/pseudopotential/psp_generator_input.F 2012-09-09 16:22:33.000000000 +0200
+@@ -643,7 +643,7 @@
+ read(99,*,ERR=30,END=30) ch_tmp
+ end do
+ 30 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX) || defined(GCC46)
+ backspace 99
+ #endif
+ write(99,*) '<exchange> pbe96 <end>'
+@@ -658,7 +658,7 @@
+ read(99,*,ERR=31,END=31) ch_tmp
+ end do
+ 31 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX) || defined(GCC46)
+ backspace 99
+ #endif
+ write(99,*) '<exchange> becke <end>'
+@@ -673,7 +673,7 @@
+ read(99,*,ERR=32,END=32) ch_tmp
+ end do
+ 32 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX) || defined(GCC46)
+ backspace 99
+ #endif
+ write(99,*) '<exchange> revpbe <end>'
+@@ -911,7 +911,7 @@
+ read(99,*,ERR=30,END=30) ch_tmp
+ end do
+ 30 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX) || defined(GCC46)
+ backspace 99
+ #endif
+ write(99,*) '<exchange> pbe96 <end>'
+@@ -926,7 +926,7 @@
+ read(99,*,ERR=31,END=31) ch_tmp
+ end do
+ 31 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX) || defined(GCC46)
+ backspace 99
+ #endif
+ write(99,*) '<exchange> becke <end>'
+@@ -941,7 +941,7 @@
+ read(99,*,ERR=32,END=32) ch_tmp
+ end do
+ 32 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(MACX) || defined(GCC46)
+ backspace 99
+ #endif
+ write(99,*) '<exchange> revpbe <end>'
+Index: nwchem-6.1/src/nwpw/nwpwlib/utilities/CIF_write.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/nwpwlib/utilities/CIF_write.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/nwpwlib/utilities/CIF_write.F 2012-09-09 16:22:33.000000000 +0200
+@@ -63,7 +63,7 @@
+ read(19,*,ERR=30,END=30) ch_tmp
+ end do
+ 30 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(GCC46)
+ backspace 19
+ #endif
+
+Index: nwchem-6.1/src/nwpw/paw/cpsd/paw_cpmd.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/paw/cpsd/paw_cpmd.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/paw/cpsd/paw_cpmd.F 2012-09-09 16:22:33.000000000 +0200
+@@ -779,7 +779,7 @@
+ icount_shift = icount_shift + 1
+ end do
+ 100 continue
+-#if defined(FUJITSU_SOLARIS) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(__crayx1) || defined(GCC46)
+ backspace 31
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/pspw/analysis/orb.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/pspw/analysis/orb.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/pspw/analysis/orb.F 2012-09-09 16:22:33.000000000 +0200
+@@ -101,7 +101,7 @@
+ read(18,*,end=100)
+ end do
+ 100 continue
+-#ifdef FUJITSU_SOLARIS
++#if defined(FUJITSU_SOLARIS)||defined(GCC46)
+ backspace 18
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/pspw/cgsd/mmmdv1.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/pspw/cgsd/mmmdv1.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/pspw/cgsd/mmmdv1.F 2012-09-09 16:22:33.000000000 +0200
+@@ -410,7 +410,7 @@
+ icount_shift = icount_shift + 1
+ end do
+ 100 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(GCC46)
+ backspace 31
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/pspw/cpsd/cpmd_qmmm_start.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/pspw/cpsd/cpmd_qmmm_start.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/pspw/cpsd/cpmd_qmmm_start.F 2012-09-09 16:22:33.000000000 +0200
+@@ -583,7 +583,7 @@
+ icount_shift = icount_shift + 1
+ end do
+ 100 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(GCC46)
+ backspace 31
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/pspw/cpsd/cpmdv5.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/pspw/cpsd/cpmdv5.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/pspw/cpsd/cpmdv5.F 2012-09-09 16:22:33.000000000 +0200
+@@ -716,7 +716,7 @@
+ icount_shift = icount_shift + 1
+ end do
+ 100 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(GCC46)
+ backspace 31
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/pspw/cpsd/fei_output.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/pspw/cpsd/fei_output.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/pspw/cpsd/fei_output.F 2012-09-09 16:22:33.000000000 +0200
+@@ -77,7 +77,7 @@
+ end do
+ end do
+ 30 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1) || defined(GCC46)
+ backspace 35
+ #endif
+ else
+Index: nwchem-6.1/src/nwpw/pspw/lib/psp/MOTION.F
+===================================================================
+--- nwchem-6.1.orig/src/nwpw/pspw/lib/psp/MOTION.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/nwpw/pspw/lib/psp/MOTION.F 2012-09-09 16:22:33.000000000 +0200
+@@ -90,7 +90,7 @@
+ read(19,*,ERR=30,END=30) ch_tmp
+ end do
+ 30 continue
+-#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)
++#if defined(FUJITSU_SOLARIS) || defined(PSCALE) || defined(__crayx1)||defined(GCC46)
+ backspace 19
+ #endif
+
+Index: nwchem-6.1/src/property/prop_input.F
+===================================================================
+--- nwchem-6.1.orig/src/property/prop_input.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/property/prop_input.F 2012-09-09 16:22:33.000000000 +0200
+@@ -155,7 +155,7 @@
+ else
+ write(6,'(a,a,i4,a)')
+ & 'NMR hyperfine property input found',
+- & ' viewer atoms than expected, only',icount,
++ & ' fewer atoms than expected, only',icount,
+ & ' will be used'
+ hfineatoms = icount
+ if (icount.eq.0) then
+@@ -182,7 +182,7 @@
+ else
+ write(6,'(a,a,i4,a)')
+ & 'Spin-spin property input found',
+- & ' viewer pairs than expected, only',icount,
++ & ' fewer pairs than expected, only',icount,
+ & ' will be used'
+ if (icount.gt.0) then
+ do jj = 0, icount-1
+Index: nwchem-6.1/src/property/raman.F
+===================================================================
+--- nwchem-6.1.orig/src/property/raman.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/property/raman.F 2012-09-09 16:22:33.000000000 +0200
+@@ -438,7 +438,7 @@
+ end
+ c ----------------end raman_scattering---------------------------------------
+ c
+- subroutine raman_save(rtdb,ii,junk3,junk4)
++ subroutine raman_save(rtdb,ii,temp3,temp4)
+ c
+ implicit none
+ #include "errquit.fh"
+@@ -453,32 +453,39 @@
+ integer i,j,n,ii ! counting indexes
+ integer rtdb ! [input] rtdb handle
+ double precision alfare(3,3),alfaim(3,3) ! [aoresponse] real and imaginary polarizanbility
+- double precision junk3(6,3),junk4(6,3) ! temp. arrays for FD of polarizanbility
++ double precision temp3(6,3),temp4(6,3) ! temp. arrays for FD of polarizanbility
+ logical debug
+ logical status
++ logical lalfare,lalfaim
+ c
+ debug = (.false. .and. ga_nodeid().eq.0) ! produce debug output
+ status = rtdb_parallel(.true.)
+ c -------------get raman ploarizability from rtdb ----------------------------
++ lalfare = .true.
+ if (.not. rtdb_get(rtdb, 'raman:alfare ', mt_dbl, 9, alfare))
+- & call errquit('raman_save:failed to get alfare', 1, RTDB_ERR)
++ & lalfare = .false.
++
++ lalfaim = .true.
+ if (.not. rtdb_get(rtdb, 'raman:alfaim ', mt_dbl, 9, alfaim))
+- & call errquit('raman_save:failed to get alfaim', 2, RTDB_ERR)
++ & lalfaim = .false.
+ c
+ n=(ii-1)*3
+ DO i=1,3
+ n=n+1
+ DO j=1,3
+- junk3(n,j)= alfare(i,j) ! add AORESPONSE real data to array for finite_differencing
+- junk4(n,j)= alfaim(i,j) ! add AORESPONSE imaginary data to array for finite_differencing
++ temp3(n,j)= 0.d0
++ if (lalfare) temp3(n,j)= alfare(i,j) ! add AORESPONSE real data to array for finite_differencing
++ temp4(n,j)= 0.d0
++ if (lalfaim) temp4(n,j)= alfaim(i,j) ! add AORESPONSE imag data to array for finite_differencing
+ enddo ! j loop
+ enddo ! i loop
++
+ c -------------delete raman ploarizability from rtdb ----------------------------
+ IF (debug) THEN
+- write(luout,*) 'junk3'
+- call output(junk3,1,6,1,3,6,3,1)
+- write(luout,*) 'junk4'
+- call output(junk4,1,6,1,3,6,3,1)
++ write(luout,*) 'temp3'
++ call output(temp3,1,6,1,3,6,3,1)
++ write(luout,*) 'temp4'
++ call output(temp4,1,6,1,3,6,3,1)
+ write(luout,*) 'alfare'
+ call output(alfare,1,3,1,3,3,3,1)
+ write(luout,*) 'alfaim'
+Index: nwchem-6.1/src/property/task_raman.F
+===================================================================
+--- nwchem-6.1.orig/src/property/task_raman.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/property/task_raman.F 2012-09-09 16:22:33.000000000 +0200
+@@ -173,9 +173,8 @@
+ c -------------grab laser freq(s) from rtdb---------------------------
+ c (blatanly stolen from aoresponse_driver.F)
+ c
+- if (.not.rtdb_get(rtdb, 'aoresponse:nfreq', mt_int, 1, nfreq))then
+- call errquit(pname//'nfreq failed ',0, RTDB_ERR)
+- endif
++ if (.not.rtdb_get(rtdb, 'aoresponse:nfreq', mt_int, 1, nfreq))
++ & nfreq = 0
+ if (debug) write (luout,*) 'nfreq',nfreq
+ c
+ c at present we will tie the response order to the number
+@@ -191,6 +190,10 @@
+ call errquit (pname//'nfreq .lt. zero',nfreq,RTDB_ERR)
+ end if
+ c
++c exit if response order is larger than one (TEMPORARY)
++ if (response_order.gt.1)
++ & call errquit (pname//'order>1',response_order,INPUT_ERR)
++c
+ c allocate memory for frequencies list and read values
+ c into dbl_mb(k_fr). If nfreq = 0, assign a single frequency = 0
+ c
+@@ -209,9 +212,7 @@
+ dbl_mb(k_fr + (i-1)) = 0d0
+ end do
+ endif ! nfreq.ne.0
+-c exit if response order is larger than one (TEMPORARY)
+- if (response_order.gt.1)
+- & call errquit (pname//'order>1',response_order,INPUT_ERR)
++c
+ c force nfreq = 1 if response order equals 1 (no freq. input)
+ if (response_order.eq.1 .and. nfreq.ne.1) nfreq = 1
+ if (debug) write (luout,*) 'freqs',dbl_mb(k_fr)
+Index: nwchem-6.1/src/tce/tce_ao2e_disk.F
+===================================================================
+--- nwchem-6.1.orig/src/tce/tce_ao2e_disk.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/tce/tce_ao2e_disk.F 2012-09-09 16:22:33.000000000 +0200
+@@ -16,6 +16,7 @@
+ #include "errquit.fh"
+ #include "tce.fh"
+ #include "tce_main.fh"
++#include "inp.fh"
+ integer rtdb ! Run-time database
+ logical nodezero ! True if node zero
+ integer d_ao2e ! AO integrals
+@@ -95,7 +96,7 @@
+ 9000 format(1x,'2-e (intermediate) file size = ',i15)
+ call tce_filename_4ind(1,'v2i',filename)
+ if (nodezero.and.util_print('mo1e',print_default))
+- 1 write(LuOut,9010) filename(1:20)
++ 1 write(LuOut,9010) filename(1:inp_strlen(filename))
+ 9010 format(1x,'2-e (intermediate) file name = ',A)
+ c
+ c call createfile(filename,d_ao2e,sf_size_pq*sf_size_kl)
+Index: nwchem-6.1/src/tce/tce_ao2e.F
+===================================================================
+--- nwchem-6.1.orig/src/tce/tce_ao2e.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/tce/tce_ao2e.F 2012-09-09 16:22:33.000000000 +0200
+@@ -16,6 +16,7 @@
+ #include "errquit.fh"
+ #include "tce.fh"
+ #include "tce_main.fh"
++#include "inp.fh"
+ integer rtdb ! Run-time database
+ logical nodezero ! True if node zero
+ integer d_ao2e ! AO integrals
+@@ -104,7 +105,7 @@
+ 9000 format(1x,'2-e (intermediate) file size = ',i15)
+ call tce_filename('v2i',filename)
+ if (nodezero.and.util_print('mo1e',print_default))
+- 1 write(LuOut,9010) filename(1:20)
++ 1 write(LuOut,9010) filename(1:inp_strlen(filename))
+ 9010 format(1x,'2-e (intermediate) file name = ',A)
+ call createfile(filename,d_ao2e,sf_size_pq*sf_size_kl)
+ c
+Index: nwchem-6.1/src/tce/tce_ao2e_new.F
+===================================================================
+--- nwchem-6.1.orig/src/tce/tce_ao2e_new.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/tce/tce_ao2e_new.F 2012-09-09 16:22:33.000000000 +0200
+@@ -21,6 +21,7 @@
+ #include "errquit.fh"
+ #include "tce.fh"
+ #include "tce_main.fh"
++#include "inp.fh"
+ integer rtdb ! Run-time database
+ logical nodezero ! True if node zero
+ integer d_ao2e ! AO integrals
+@@ -152,7 +153,7 @@
+ 9000 format(1x,'2-e (intermediate) file size = ',i15)
+ call tce_filename('v2i',filename)
+ if (nodezero.and.util_print('mo1e',print_default))
+- 1 write(LuOut,9010) filename(1:20)
++ 1 write(LuOut,9010) filename(1:inp_strlen(filename))
+ 9010 format(1x,'2-e (intermediate) file name = ',A)
+ call createfile(filename,d_ao2e,sf_size_pq*sf_size_kl)
+ c
+Index: nwchem-6.1/src/util/GNUmakefile
+===================================================================
+--- nwchem-6.1.orig/src/util/GNUmakefile 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/util/GNUmakefile 2012-09-09 16:22:34.000000000 +0200
+@@ -173,6 +173,7 @@
+ nw_inp_from_file.o \
+ bgj.o movecs_ecce.o\
+ get_density.o moeig_read.o\
++ util_file_copy.o \
+ util_debug.o \
+ util_erf.o \
+ ga_it2.o \
+@@ -321,3 +322,6 @@
+ $(BINDIR)/jobtime_pbs.pl: jobtime_pbs.pl
+ /bin/cp $^ $@
+ endif
++
++clean:
++ -$(RM) util_version.F
+Index: nwchem-6.1/src/util/util_cpusec.F
+===================================================================
+--- nwchem-6.1.orig/src/util/util_cpusec.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/util/util_cpusec.F 2012-09-09 16:22:34.000000000 +0200
+@@ -1,38 +1,44 @@
+ double precision function util_cpusec()
+ implicit none
+-c $Id: util_cpusec.F 19707 2010-10-29 17:59:36Z d3y133 $
++c $Id: util_cpusec.F 22351 2012-04-27 09:01:10Z jhammond $
+ *
+ * routine to give cpu seconds since start of execution
+ * delta times are handled by all applications
+ *
+-#if defined(IBM) || defined(SP1) ||defined(HPUX)
++#if defined(BGL) || defined(BGP) || defined(BGQ) && !defined(__UTIL_CPUSEC__)
++#define __UTIL_CPUSEC__
++ EXTERNAL MPI_WTIME
++ REAL*8 MPI_WTIME
++ util_cpusec = MPI_WTIME()
++#endif
++
++#if defined(IBM) || defined(SP1) ||defined(HPUX) &&!defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ double precision ibm_cputime
+ external ibm_cputime
+ util_cpusec = ibm_cputime()
+ #endif
+-#if defined(KSR)
++
++#if defined(KSR) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ *--KSR-start
+ real ksr_cputime
+ external ksr_cputime
+-c
+ util_cpusec = ksr_cputime()
+ *--KSR-end
+ #endif
+-#if defined(SUN) || defined(__PARAGON__) || defined(DECOSF) || defined(SOLARIS) || defined(FUJITSU_VPP)|| defined(LINUXALPHA) || defined(MACX)
++
++#if defined(SUN) || defined(__PARAGON__) || defined(DECOSF) || defined(SOLARIS) || defined(FUJITSU_VPP)|| defined(LINUXALPHA) || defined(MACX) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ real*4 tarray(2)
+ real*4 etime
+ #ifndef GCC4
+ external etime
+ #endif
+-c
+ util_cpusec = etime(tarray)
+-c
+ #endif
+
+-#if defined(SGI)
++#if defined(SGI) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ #if defined(SGITFP)
+ real*4 tarray(2) ! nb: real == real*8 on TFP
+@@ -46,39 +52,35 @@
+ util_cpusec = etime(tarray)
+ #endif
+
+-#if defined(DELTA)
++#if defined(DELTA) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ double precision dclock
+ external dclock
+ double precision first
+ logical ofirst
+ data ofirst /.true./
+-c
+ if (ofirst) then
+ first = dclock()
+ ofirst = .false.
+ endif
+-c
+ util_cpusec = dclock() - first
+ #endif
+
+-#if (defined(LINUX) || defined(CYGNUS)) && !defined(LINUXIA64) &&! defined(CATAMOUNT)
++#if (defined(LINUX) || defined(CYGNUS)) && !defined(LINUXIA64) &&! defined(CATAMOUNT) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ double precision linux_cputime
+ external linux_cputime
+-c
+ util_cpusec = linux_cputime()
+ #endif
+
+-#if defined(WIN32) || defined(LINUXIA64)
++#if defined(WIN32) || defined(LINUXIA64) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ double precision win32_cputime
+ external win32_cputime
+-c
+ util_cpusec = win32_cputime()
+ #endif
+
+-#if defined(CRAY)
++#if defined(CRAY) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ double precision secondr
+ external secondr
+@@ -86,16 +88,14 @@
+ logical ofirst
+ save first, ofirst
+ data ofirst /.true./
+-c
+ if (ofirst) then
+ first = secondr()
+ ofirst = .false.
+ endif
+-c
+ util_cpusec = secondr() - first ! Actually wall time
+ #endif
+
+-#if defined(FUJITSU_SOLARIS) || defined(CATAMOUNT)
++#if defined(FUJITSU_SOLARIS) || defined(CATAMOUNT) && !defined(__UTIL_CPUSEC__)
+ #define __UTIL_CPUSEC__
+ #ifdef FUJITSU_SOLARIS
+ intrinsic cpu_time
+Index: nwchem-6.1/src/util/util_file_name.F
+===================================================================
+--- nwchem-6.1.orig/src/util/util_file_name.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/util/util_file_name.F 2012-09-09 16:22:34.000000000 +0200
+@@ -478,9 +478,9 @@
+ call util_set_default_scratch_dir(scratch_dir)
+ call util_set_default_permanent_dir(permanent_dir)
+ iocheckk=.true.
+-#if defined(CRAYXT) || defined(BGP)
++#if defined(CRAYXT) || defined(BGP) || defined(BGQ)
+ c on catamount all fs are parallel, therefore we need only node0
+-c on BGP all fs are parallel, therefore we need only node0
++c on BGP/BGQ all fs are parallel, therefore we need only node0
+ iocheckk=ga_nodeid().eq.0
+ #endif
+ c
+Index: nwchem-6.1/src/util/util_random.F
+===================================================================
+--- nwchem-6.1.orig/src/util/util_random.F 2012-09-09 16:22:30.000000000 +0200
++++ nwchem-6.1/src/util/util_random.F 2012-09-09 16:22:34.000000000 +0200
+@@ -1,13 +1,13 @@
+ double precision function util_random(iseed)
+ implicit none
+ #include "errquit.fh"
+-c $Id: util_random.F 19707 2010-10-29 17:59:36Z d3y133 $
++c $Id: util_random.F 22350 2012-04-27 09:00:05Z jhammond $
+ c
+ c routine to give a random number [0,1]
+ c
+ c iseed is an integer seed when non-zero used to initialize the sequence
+ c
+-#if defined(IBM) || defined(SP1)
++#if defined(IBM) || defined(SP1) || defined(BGQ)
+ #define SET_RANDOM
+ integer iseed
+ if(iseed.gt.0) call srand(dble(iseed))
diff -Nru nwchem-6.1/debian/patches/series nwchem-6.1/debian/patches/series
--- nwchem-6.1/debian/patches/series 2012-02-11 19:34:37.000000000 +0100
+++ nwchem-6.1/debian/patches/series 2012-12-14 13:17:34.000000000 +0100
@@ -6,3 +6,4 @@
06_statfs_kfreebsd.patch
07_ga_target_force_linux.patch
08_lapack_constants_headers.patch
+09_backported_6.1.1_fixes.patch
Reply to: