From: <ha...@us...> - 2012-04-06 13:09:27
|
Revision: 16976 http://jmol.svn.sourceforge.net/jmol/?rev=16976&view=rev Author: hansonr Date: 2012-04-06 13:09:20 +0000 (Fri, 06 Apr 2012) Log Message: ----------- version=12.3.20_dev # bug fix: Molden reader hack for bad Molden files with ** instead of atom number in [GTO] Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java 2012-04-05 18:08:32 UTC (rev 16975) +++ trunk/Jmol/src/org/jmol/adapter/readers/quantum/MoldenReader.java 2012-04-06 13:09:20 UTC (rev 16976) @@ -69,7 +69,46 @@ checkOrbitalType(line); return true; } - + + @Override + public void finalizeReader() { + // a hack to make up for Molden's ** limitation in writing shell information + // assumption is that there is an atom of the same type just prior to the missing one. + if (bsBadIndex.isEmpty()) + return; + try { + int ilast = 0; + Atom[] atoms = atomSetCollection.getAtoms(); + int nAtoms = atomSetCollection.getAtomCount(); + bsAtomOK.set(nAtoms); + int n = shells.size(); + for (int i = 0; i < n; i++) { + int iatom = shells.get(i)[0]; + if (iatom != Integer.MAX_VALUE) { + ilast = atoms[iatom].elementNumber; + continue; + } + for (int j = bsAtomOK.nextClearBit(0); j >= 0; j = bsAtomOK + .nextClearBit(j + 1)) { + if (atoms[j].elementNumber == ilast) { + shells.get(i)[0] = j; + Logger.info("MoldenReader assigning shells starting with " + i + + " for ** to atom " + (j + 1) + " z " + ilast); + for (; ++i < n && !bsBadIndex.get(i) + && shells.get(i)[0] == Integer.MAX_VALUE;) + shells.get(i)[0] = j; + i--; + bsAtomOK.set(j); + break; + } + } + } + } catch (Exception e) { + Logger.error("Molden reader could not assign shells -- abandoning MOs"); + atomSetCollection.setAtomSetAuxiliaryInfo("moData", null); + } + + } private void readAtoms() throws Exception { /* [Atoms] {Angs|AU} @@ -112,6 +151,9 @@ } } + private BitSet bsAtomOK = new BitSet(); + private BitSet bsBadIndex = new BitSet(); + private boolean readGaussianBasis() throws Exception { /* [GTO] @@ -141,8 +183,13 @@ // The 0 following the atom index is now optional String[] tokens = getTokens(); + // Molden may have ** in place of the atom index when there are > 99 atoms atomIndex = parseInt(tokens[0]) - 1; - + if (atomIndex == Integer.MAX_VALUE) { + bsBadIndex.set(shells.size()); + } else { + bsAtomOK.set(atomIndex); + } // Next is a sequence of shells and their primitives while (readLine() != null && line.trim().length() > 0) { // Next line has the shell label and a count of the number of primitives Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2012-04-05 18:08:32 UTC (rev 16975) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2012-04-06 13:09:20 UTC (rev 16976) @@ -3,6 +3,7 @@ version=12.3.20_dev +# bug fix: Molden reader hack for bad Molden files with ** instead of atom number in [GTO] # new feature: app flag -R restricts file access -- no local file reading; no writing, no logging # // disables WRITE, LOAD file:/, set logFile # // command line -g and -w options ARE available for final writing of image This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |