'Hacking' COMSOL so it 'll use the right license

April 2010


COMSOL comes without command line options that alter the license. This is inconvenient, since it would require us to do one setup for students and one for staff. But in the script comsolroot/bin/comsol, the license file location gets set like this:

setlicfile () {
FEMLAB_LICENSE_FILE=${FLROOT}/license/license.dat
export FEMLAB_LICENSE_FILE
LMCOMSOL_LICENSE_FILE=${FLROOT}/license/license.dat
export LMCOMSOL_LICENSE_FILE
}
    

We alter it to:

setlicfile () {
FEMLAB_LICENSE_FILE=${FLROOT}/license/license.dat
if echo ${USER} | grep -q ^s ; then
      FEMLAB_LICENSE_FILE=${FLROOT}/license/license.std.dat
fi
export FEMLAB_LICENSE_FILE
LMCOMSOL_LICENSE_FILE=${FLROOT}/license/license.dat
if echo ${USER} | grep -q ^s ; then
    LMCOMSOL_LICENSE_FILE=${FLROOT}/license/license.std.dat
fi
export LMCOMSOL_LICENSE_FILE
}
    

Now the students' license is used if somebody with a username starting with an 's' starts the program.