Skip to content
Lori A. Burns edited this page Apr 28, 2017 · 12 revisions

STOP! This page is out-of-date and is superseded by the docs


###How to choose CMake variables for a non-vital non-Fortran module

Two Signals:

  • ENABLE_CHEMPS2 means the user wants this code built. Build will fail if can’t build the code. If non-vital, fails with instructions on how to disable.

  • CHEMPS2_ROOT means try to use an existing system build of code to link into Psi4. If existing system not found or unsuitable, builds internal.


How to use valgrind with Psi4

When you naively use Valgrind with Psi4, you're likely to get incomprehensible mess of garbage or it may just crash with a boost overflow error. This happens because the boost python layer looks really really bad as far as Valgrind is concerned, i.e. it looks like a ton of memory leaks. It really isn't, so we want to ignore all such errors/warnings. Valgrind has a mechanism for this in the way of suppression files. Calling Valgrind as:

valgrind --suppressions=<file_name>

will run valgrind with the suppression file located on disk at "file_name". Lucky for you, Psi4 comes with such a suppression file at $top-level-psi4-dir/lib/valgrind-python.supp. This should remove all the boost python errors.

The other error, boost overflow error arises from src/lib/libmints/sieve.cc where the inverse of the complementary error function is being called. The internet seems to claim that this is a bug the arises only in debugging mode and has something to do with the exponent boost chooses for the default zero tolerance. Anyways, commenting out lines 47 to 49, for valgrind purposes, should allow you to run valgrind. The consequence of commenting out these lines are you get no integeral screening, so make sure you uncomment them when you actually run.


How to see the actual compiling commands (or errors) with cmake?

CMake by default hides a lot of useful debugging information to make the compilation cleaner. Issue make VERBOSE=1 to display the full compilation commands and errors.


How to get vi to highlight git's merge conflict syntax?

Edit your ~/.vimrc file to include the lines below. Hitting the F7 key will toggle highlighting of git's conflict markers.

>>> cat ~/.vimrc
set hlsearch
map <F7> :/\(<<<<<<<\\|=======\\|>>>>>>>\)<CR>

How to see what setup and cmake commands are active for the object directory?

In your object directory, examine the contents of file setup_command.

>>> cat setup_command
# setup command was executed 06-February-2015 16:04:22
../setup --type debug --plugins on

# cmake command generated by this setup command was: 
#  cmake  -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DENABLE_MPI=OFF -DENABLE_SGI_MPT=OFF -DENABLE_OMP=ON -DENABLE_VECTORIZATION=OFF -DENABLE_CSR=OFF -DENABLE_SCALAPACK=OFF -DENABLE_SCALASCA=OFF -DENABLE_UNIT_TESTS=OFF -DENABLE_STATIC_LINKING=OFF -DENABLE_PLUGINS=ON -DENABLE_LIBERD=OFF -DENABLE_JKFACTORY=OFF -DENABLE_GPU_DFCC=OFF -DENABLE_DUMMY_PLUGIN=OFF -DENABLE_PCMSOLVER=OFF -DENABLE_CXX11_SUPPORT=ON -DLIBINT_OPT_AM=5 -DEXECUTABLE_SUFFIX= -DCMAKE_INSTALL_PREFIX=/usr/local/psi4 -DCMAKE_BUILD_TYPE=debug /Users/johndoe/psi4

How to change the scratch location for compiling LibInt and LibDeriv

ATTN: the procedure described in the following paragraph existed with Makefile but seems to have gotten lost in CMake. need to revive?

The libint integrals library creates rather large files (multiple GB) during compilation, especially if higher angular momentum functions are enabled. These are normally written to directory /tmp, which on some computers may be too small. Alternatively, the user can specify a location for these files by setting the environmental variable $PSI_SCRATCH (if this is not set, $SCRATCH will also be checked). These files should be written to a local disk (not a network-mounted NFS share) if possible, otherwise the compilation may be very slow.


###How to handle "runtime library may be hidden" when building with Anaconda Python

When building against Anaconda python (e.g., setup --python /path/to/conda/bin/python), the warning below often appears. It is harmless, proceed.

CMake Warning at src/bin/psi4/CMakeLists.txt:58 (add_executable):
  Cannot generate a safe runtime search path for target psi4 because files in
  some directories may conflict with libraries in implicit directories:

    runtime library [libm.so.6] in /usr/lib64 may be hidden by files in:
      /theoryfs2/common/software/anaconda/lib

Some of these libraries may not be found correctly.

###How to know the pass/fail status of a job.

After running your own regression tests you may have some tests fail. At this point there are some tests that fail on all systems. So as a good programmer you will want to know if the failed jobs were broken or if you broke them. Try this link: CTest Dashboard


###How to build Psi4 as an importable python module / shared object library

A cmake target is available to build $objdir/bin/psi4.so. Minimal recompilation is required when the executable target $objdir/bin/psi from make psi4 has already been built. Note that forming psi4.so requires linking against Boost as shared libraries (not Psi4's default) or as archives compiled with -fpic (also not Psi4's default). The easiest way to get a compatible Boost is to let Psi4 build its internal Boost after changing set(Boost_USE_STATIC_LIBS ON) to OFF in $top-level-psi4-dir/cmake/ConfigBoost.cmake.

>>> make psi4so

After building, a simple python script like the below should print CC-PVDZ. Note that building psi4.so gets you http://psicode.org/psi4manual/master/autodoc_psimod.html (the C++ guts), not http://psicode.org/psi4manual/master/energy.html (the driver). The best route to a user-friendly Psi4 using the shared library is in the works.

import sys
sys.path.append('$objdir/bin')
import psi4

psi4.set_global_option('BASIS', 'CC-PVDZ')
print psi4.get_option('SCF', 'BASIS')

###How to fix No module named request or urllib on Mac

When you get an error like the below on Mac, it means that your which python is conda/anaconda python, but Psi4 is linked against system python (this can happen even if you pass anaconda python into cmake).

Traceback (most recent call last):
  File "/Users/johndoe/psi4/share/python/inputparser.py", line 38, in <module>
    import pubchem
  File "/Users/johndoe/psi4/share/python/pubchem.py", line 47, in <module>
    from urllib.request import urlopen
ImportError: No module named request

The library dependency of your executable will look something like below. Note the exact name (may be a full path) to the python library, in this case libpython2.7.dylib.

>>> otool -L bin/psi4
bin/psi4:
	libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)

Now find the full name of your anaconda python library, in this case /Users/johndoe/anaconda//lib/libpython2.7.dylib. Now run install_name_tool -change on your executable as below.

>>> export PYTHONHOME=/Users/johndoe/anaconda
>>> install_name_tool -change libpython2.7.dylib $PYTHONHOME/lib/libpython2.7.dylib bin/psi4

Now, the linked python library is the conda/anaconda and all is well. This will have to be repeated upon recompilation.

>>> otool -L bin/psi4
bin/psi4:
	/Users/johndoe/anaconda/lib/libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)

###How do I set up the scratch directory ?

The scratch directory is where Psi4 stores potentially large files during computation. It should thus be on a local, fast disk to minimize any computational inefficiencies caused by I/O. The scratch directory is commonly set up through the PSI_SCRATCH environment variable:

For csh/tcsh:

    setenv PSI_SCRATCH /scratch/user

For bash:

    export PSI_SCRATCH=/scratch/user

See also the more general scratch documentation.


###How do I retain specific Psi4 scratch files ?

You can set up a specific path for Psi4 scratch file and keep them for later use through the psi4_io handler.


###How to use Psi4 within a PBS queue ?

You will usually need to set up a PBS job script that is setting all necessary environment variables, making sure the scratch directories are set up, and invokes the executable. An example PBS script is provided in the manual, but make sure to also consult your own PBS documentation for appropriate setup.


###How to satisfy the GCC >= 4.9 requirement without updating the OS

# See if GCC too old (in this case, yes)
gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)

Even if you're not using GCC as a compiler, your Intel compiler seeks gcc to generate code compatible with your current GCC version. If your GCC is too old (like above), you can update your system GCC through your package manager or install an acceptable version elsewhere on your system. The latter route, tested on Linux with Intel compilers, is below.

# Install GCC 5.2 into a non-primary conda environment
>>> conda create -n gcc52 -c msarahan gcc-5

# To Build, either:
#    (A) activate environment (prepends PATH)
>>> source activate gcc52
#    (B) tell CMake to tell the compiler which GCC to use
>>> vi do-configure
   GCC5=/path/to/miniconda/envs/gcc52
   cmake -H. -Bbuild \
     -DCMAKE_C_COMPILER=icc \
     -DCMAKE_CXX_COMPILER=icpc \
     -DCMAKE_C_FLAGS="-gcc-name=${GCC5}/bin/gcc" \
     -DCMAKE_CXX_FLAGS="-gcc-name=${GCC5}/bin/gcc -gxx-name=${GCC5}/bin/g++" \
     ...

# Configure and build

# To Run:
>>> export LD_LIBRARY_PATH=${GCC5}/lib:$LD_LIBRARY_PATH

###How to fix undefined symbol: _Py_FalseStruct

You're probably loading a Py3-compiled Psi4 in Py2. Switch interpreters and re-run. A python of proper Py2 or Py3-ness is baked into the psi4 "executable", so you'll see this error only for Psi4-as-Py-module.