qsimulate-open / bagel

Brilliantly Advanced General Electronic-structure Library
GNU General Public License v3.0
92 stars 44 forks source link

printing ROHF orbitals to molden file leads to crash #193

Closed humeniuka closed 4 years ago

humeniuka commented 4 years ago

Input file for reproducing bug:

{ "bagel": [

    { 
    "title": "molecule",
    "basis": "svp",
    "df_basis": "svp-jkfit",
    "angstrom": true,
    "geometry": [
        {"atom": "H",
         "xyz" : [ -0.227, -0.825, -2.666] },
        {"atom": "O",
         "xyz" : [  0.186, -0.147, -3.258] },
        {"atom": "H",
         "xyz" : [  0.030,  0.714, -2.796] }
    ]
    },

    {
    "title"  : "rohf",
    "charge" : 1
    },

    {
    "title"    : "print",
    "file"     : "h2o+_rohf.molden",
    "orbitals" : true
    }
]}

Without the "print" section no segmentation fault occurs. It seems that the crash is caused by line 161 in util/io/moldenout.cc. Replacing

ss << " Occup=" << setw(12) << occupB[i] << endl;

with

ss << " Occup=" << setw(12) << (occupB.empty() ? 0.0 : occupB[i]) << endl;

apparently solves the problem.

shiozaki commented 4 years ago

Fixed by 7da3dd22c91949b7042345aa9daae9a76a8d75c3 (I referenced a wrong number there)