home

Archive for the 'linux issues' Category

Private Internet Access, OpenVPN (2.3.2), and Ubuntu 14.04 (.2 LTS) – Yet Another Reported Way To Get Them Working (And The Only One That Works For Me)

Friday, July 17th, 2015

If you sign up for an account with Private Internet Access (and this may go for some other VPN providers as well) and follow the only prominent Ubuntu link (12.04) in the Support Section (www.privateinternetaccess.com/pages/client-support/ubuntu-openvpn), you’ll be taken to a reasonably straightforward 9-step process that walks you through the OpenVPN setup – from the install_ubuntu.sh script download to the selection of PIA-points (I just made that up) in your Network Manager GUI (that radial wifi icon or arrows in the upper-right corner).

That is, for Ubuntu 12.04.

The Problem

If you try this in Ubuntu 14.04, everything more-or-less looks and runs the same way. That said, when you try to connect to a PIA-point in the Network Manager, nothing happens. Your wifi radial doesn’t change, flash, or provide any indication that something has gone right or wrong. More importantly (to the lack of feedback, anyway), you are not asked for your PIA password (having put in your username in the install process). This lack of password requesting turns out to be the real kicker (and diagnostic for the fix presented down below).

If you look in /etc/NetworkManager/system-connections, you’ll see that all of the PIA files have been successfully installed.

-rw——- 1 root root 326 Jul 16 16:14 PIA – AU Melbourne
-rw——- 1 root root 313 Jul 16 16:14 PIA – AU Sydney
-rw——- 1 root root 313 Jul 16 16:14 PIA – Brazil
-rw——- 1 root root 316 Jul 16 16:14 PIA – CA North York
-rw——- 1 root root 321 Jul 16 16:14 PIA – CA Toronto
-rw——- 1 root root 313 Jul 16 16:14 PIA – France
-rw——- 1 root root 315 Jul 16 16:14 PIA – Germany
-rw——- 1 root root 312 Jul 16 16:14 PIA – Hong Kong
-rw——- 1 root root 350 Jul 17 15:49 PIA – Ireland
-rw——- 1 root root 313 Jul 16 16:14 PIA – Israel
-rw——- 1 root root 311 Jul 16 16:14 PIA – Japan
-rw——- 1 root root 313 Jul 16 16:14 PIA – Mexico
-rw——- 1 root root 314 Jul 16 16:14 PIA – Netherlands
-rw——- 1 root root 310 Jul 16 16:14 PIA – Romania
-rw——- 1 root root 313 Jul 16 16:14 PIA – Russia
-rw——- 1 root root 312 Jul 16 16:14 PIA – Singapore
-rw——- 1 root root 313 Jul 16 16:14 PIA – Sweden
-rw——- 1 root root 317 Jul 16 16:14 PIA – Switzerland
-rw——- 1 root root 313 Jul 16 16:14 PIA – Turkey
-rw——- 1 root root 319 Jul 16 16:14 PIA – UK London
-rw——- 1 root root 329 Jul 16 16:14 PIA – UK Southampton
-rw——- 1 root root 327 Jul 16 16:14 PIA – US California
-rw——- 1 root root 315 Jul 16 16:14 PIA – US East
-rw——- 1 root root 321 Jul 16 16:14 PIA – US Florida
-rw——- 1 root root 321 Jul 16 16:14 PIA – US Midwest
-rw——- 1 root root 331 Jul 16 16:14 PIA – US New York City
-rw——- 1 root root 321 Jul 16 16:14 PIA – US Seattle
-rw——- 1 root root 334 Jul 16 16:14 PIA – US Silicon Valley
-rw——- 1 root root 317 Jul 16 16:14 PIA – US Texas
-rw——- 1 root root 315 Jul 16 16:14 PIA – US West

My first attempts at troubleshooting brought me to the installing privateinternetaccess on ubuntu 14.04 LTS page at askubuntu.com. The first response seems to be regurgitating the 12.04 installation process on the PIA site (which doesn’t work. For me, anyway), while the second response provides a list of installs that the install_ubuntu.sh script may or may not have successfully installed.

sudo apt-get install openvpn network-manager-openvpn network-manager-openvpn-gnome

The second commenter then walks through the install process as if the .ovpn config files didn’t exist (setting up from scratch, which can be laborious if you want to add all of the PIA points) but uses the contents of the openvpn.zip file downloaded by the question-asker.

The fix to the whole matter is partly in the questioner and second answer, but some additional work needs to be done. What’s described below is the process I used to figure out what was going on (showing all work), including using some alternatively-official .ovpn files (and the official ca.crt and crl.pem files provided by PIA).

The Diagnosing (What May Have Brought You Here)

With the failure to get any feedback from Network Manager (or the GUI) after the install, I went straight to the syslog to see if anything revealing appears (var/log/syslog). The error report for my VPN connection attempts reads as follows:

cd /var/log/syslog
more syslog

Jul 16 08:54:04 randommachine NetworkManager[13049]: Starting VPN service ‘openvpn’…
Jul 16 08:54:04 randommachine NetworkManager[13049]:
VPN service ‘openvpn’ started (org.freedesktop.NetworkManager.openvpn), PID 13164
Jul 16 08:54:04 randommachine NetworkManager[13049]:
VPN service ‘openvpn’ appeared; activating connections
Jul 16 08:54:04 randommachine NetworkManager[13049]: [1437051244.977042] [nm-vpn-connection.c:1374] get_secrets_cb(): Failed to request VPN secrets #2: (6) No agents were available for this request.
Jul 16 08:54:04 randommachine NetworkManager[13049]: Policy set ‘randomrouter’ (wlan0) as default for IPv4 routing and DNS.
Jul 16 08:54:10 randommachine NetworkManager[13049]:
VPN service ‘openvpn’ disappeared

A google search for “Failed to request VPN secrets #2“ (I can’t stress enough the value of quotes in troubleshooting Linux issues) dragged me to several pages that didn’t directly address my Network Manager issue, but indicated that one should consider running OpenPVN from the Terminal anyway. Extracting openvpn.zip (downloaded from the PIA website) and cd’ing into that folder (I assume you’re in Downloads), the following commands:

cd Downloads
unzip openvpn.zip
openvpn US\ East.ovpn 

Produces the following output – asking for username and password, but then failing to connect (and I include all the output below, assuming the error brought you here).

Thu Jul 16 09:06:55 2015 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Dec 1 2014
Enter Auth Username:pXXXXXXX
Enter Auth Password:
Thu Jul 16 09:07:11 2015 UDPv4 link local: [undef]
Thu Jul 16 09:07:11 2015 UDPv4 link remote: [AF_INET]208.167.254.223:1194
Thu Jul 16 09:07:11 2015 WARNING: this configuration may cache passwords in memory — use the auth-nocache option to prevent this
Thu Jul 16 09:07:11 2015 [Private Internet Access] Peer Connection Initiated with [AF_INET]208.167.254.223:1194
Thu Jul 16 09:07:14 2015 ERROR: Cannot ioctl TUNSETIFF tun: Operation not permitted (errno=1)
Thu Jul 16 09:07:14 2015 Exiting due to fatal error

That said, when you apply root privileges:

sudo openvpn US\ East.ovpn

You get the following:

Thu Jul 16 09:07:28 2015 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Dec 1 2014
Enter Auth Username:pXXXXXXX
Enter Auth Password:
Thu Jul 16 09:07:36 2015 UDPv4 link local: [undef]
Thu Jul 16 09:07:36 2015 UDPv4 link remote: [AF_INET]208.167.254.223:1194
Thu Jul 16 09:07:36 2015 WARNING: this configuration may cache passwords in memory — use the auth-nocache option to prevent this
Thu Jul 16 09:07:37 2015 [Private Internet Access] Peer Connection Initiated with [AF_INET]208.167.254.223:1194
Thu Jul 16 09:07:39 2015 TUN/TAP device tun0 opened
Thu Jul 16 09:07:39 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Thu Jul 16 09:07:39 2015 /sbin/ip link set dev tun0 up mtu 1500
Thu Jul 16 09:07:39 2015 /sbin/ip addr add dev tun0 local 10.134.1.6 peer 10.134.1.5
Thu Jul 16 09:07:39 2015 Initialization Sequence Completed

Works great (can verify at whatsmyipaddress.com or other). And it asks for your username (because the .ovpn files haven’t been configured yet from the script) and password, so we were already ahead of the game from the Network Manager GUI.

OpenVPN seems to work fine and the .ovpn files work, so the problem is somewhere in Network Manager or how it and OpenVPN are interacting (which I’ve not yet found the answer to). Now, you’re supposed to be asked for the password when you try to establish the VPN connection with Network Manager. To see if that was the only problem with the .ovpn files, I simply added my password to the US East.ovpn file as follows (in US /East.ovpn):

nano US /East.ovpn

And add the following somewhere in the file:

password=put-your-password-here

Then restart the Network Manager (and wait a few seconds)

sudo service network-manager restart

And that didn’t work. That said, there’s another password flag in the file (aptly names password_flags) to play with. A search for details lead me to a post at forums.kali.org that goes into some detail about Network Manager NOT strong the VPN password correctly because the user keyring isn’t root-accessible.

Changing password-flags from 1 to 0 and attempting to connect with Network Manager = success!

So, the problem is somewhere in the failed password negotiation between Network Manager and OpenVPN, and providing that info in the .ovpn files from openvpn.zip and a network-manager restart solves the problem.

Now then, the differences between the .ovpn files in openvpn.zip (download-able from https://www.privateinternetaccess.com/openvpn/openvpn.zip) and the PIA VPN files installed using install_ubuntu.sh are as follows:

US East.ovpn

client
dev tun
proto udp
remote us-east.privateinternetaccess.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
tls-client
remote-cert-tls server
auth-user-pass
comp-lzo
verb 1
reneg-sec 0
crl-verify crl.pem

PIA US East

[connection]
id=PIA – US East
uuid=856fc7ec-cd90-4ab1-96c1-2d827e46ea8f
type=vpn
autoconnect=false

[vpn]
service-type=org.freedesktop.NetworkManager.openvpn
username=p9681681
comp-lzo=yes
remote=us-east.privateinternetaccess.com
connection-type=password
password-flags=0
ca=/etc/openvpn/ca.crt

[ipv4]
method=auto

The new format is so clean! It’s also the format you get if you go through the New Connection process through Network Manager. The formatting seems to be important for the fix I’m going to propose below, so I’m going to modify the newer format files below.

The Solution

The solution is, after many hours, stupid-simple – run the install_ubuntu.sh as described on the PIA website (which will also make you install a few extra programs if you don’t have them already- and it places ca.crt into your OpenVPN folder, which is then called by the VPN files), modify all of the PIA files in your /etc/NetworkManager/system-connections folder by putting your password into each (in the format as below), and restart network-manager from the Terminal. That, in theory, should be it. You’ll have to have root access to do this, though, as the file permissions are all (or should be) 600.

1. https://www.privateinternetaccess.com/pages/client-support/ubuntu-openvpn

2. Open Terminal

3. Move to the system-connections folder:

cd /etc/NetworkManager/system-connections

4. Edit all the PIA files. To each of the PIA files, all you have to do is add the following:

[vpn-secrets]
password=put-your-password-here

The [vpn-secrets] is important! I would have thought this to be a comment block for organizational purposes, but adding thr password line alone won’t cut it.

NOTE: If you’re trying to connect through the GUI and the VPN Connections DO NOT appear in the list – provided your password is in the file, your problem is very likely that the file permissions are wrong. If they’re not -rw——, then Network-Manager will not read them.

5. Extra bookkeeping step: double-confirm the permissions on the PIA files:

chmod 600 PIA*

6. Restart network-manager

sudo service network-manager restart

I do not know if/when the fix will come in between OpenVPN and Network Manager (or something else in Ubuntu) that will obviate the need for this workaround. In the meantime, the procedure above works just fine (works at all) on a clean install of 14.04.2 LTS. The problem seems to be with OpenVPN as it plays with 14.04, a recurring theme I’ve found from lots of people (or, perhaps more specifically, the use of the GUI to call OpenVPN). Given several reports of PIA/14.04, I’m surprised there isn’t more, perhaps specifically on the PIA website, to address this issue. Hopefully a proper fix from PIA, OpenVPN, or Ubuntu developers in en route.

Happy more safe/more secure surfing. And if you’re so inclined, the Litecoin bubble has not, yet, right now, burst (scroll to the bottom of http://www.somewhereville.com/?p=1896).

GROMACS 5.0.x CUDA/GPU Detection Failure With Ubuntu 14.04 nVidia 331.113 Update – Fix With An apt-get

Saturday, January 3rd, 2015

If not for the near-20x speedup I’ve achieved running GROMACS on an nVidia GTX 770 Classified over an Intel i7 Extreme 6-core, nVidia in Ubuntu would almost be more trouble than its worth. The initial installation of the nVidia drivers from the nVidia website works, then the first time Ubuntu auto-updates the drivers to the latest-and-greatest, you’re never entirely sure what the next boot is going to look like – usually a black screen at best. And, if you found this page while looking for a solution to the nVidia driver update black/blank screen, my solution (which has worked without issue to date) is to ditch lightdm and use the GNOME Display Manager (gdm) instead (this apparently appears to be a theme with Ubuntu 14.04 installs on SSD drives as well).

sudo apt-get install gdm

Now, with that settled, the latest update (331.113) broke my GROMACS GPU install (performed using the steps outlined at: GROMACS 5.0.1, nVidia CUDA Toolkit, And FFTW3 Under Ubuntu 14.04 LTS (64-bit); The Virtues Of VirtualBox). The error for my system looks as follows:

GROMACS:      gmx mdrun, VERSION 5.0.1
Executable:   /opt/gromacs_gpu/bin/gmx
Library dir:  /opt/gromacs_gpu/share/gromacs/top
Command line:
  gmx mdrun -v -deffnm RUN_solv_em -s RUN_ions.tpr -o RUN_em.trr -gpu_id 0


NOTE: Error occurred during GPU detection:
      unknown error
      Can not use GPU acceleration, will fall back to CPU kernels.

Reading file RUN_ions.tpr, VERSION 5.0.1 (single precision)
Using 1 MPI thread
Using 12 OpenMP threads 

That said, nvidia-smi sees all three cards in my system just fine.

+------------------------------------------------------+                       
| NVIDIA-SMI 331.113    Driver Version: 331.113        |                       
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 650     Off  | 0000:01:00.0     N/A |                  N/A |
| 21%   30C  N/A     N/A /  N/A |    183MiB /  1023MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 770     Off  | 0000:02:00.0     N/A |                  N/A |
| 35%   29C  N/A     N/A /  N/A |      9MiB /  4095MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
|   2  GeForce GTX 770     Off  | 0000:03:00.0     N/A |                  N/A |
| 35%   25C  N/A     N/A /  N/A |      9MiB /  4095MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Compute processes:                                               GPU Memory |
|  GPU       PID  Process name                                     Usage      |
|=============================================================================|
|    0            Not Supported                                               |
|    1            Not Supported                                               |
|    2            Not Supported                                               |
+-----------------------------------------------------------------------------+

Concerned that this might be some kind of issue with the drivers and my compiled version of 5.0.1, I compiled a copy of 5.0.4 using the same build parameters in cmake. The result? Same problem.

The simple solution (which may apply to all things OpenCL as well, but my concern was simply GROMACS) is to install nvidia-modprobe.

sudo apt-get install nvidia-modprobe

Whatever happened in the install, GROMACS now sees the GPU cards just fine.

GROMACS:      gmx mdrun, VERSION 5.0.4
Executable:   /opt/gromacs_gpu_504/bin/gmx
Library dir:  /opt/gromacs_gpu_504/share/gromacs/top
Command line:
  gmx mdrun -v -deffnm RUN_solv_em -s RUN_ions.tpr -o RUN_em.trr -gpu_id 0

Reading file RUN_md.tpr, VERSION 5.0.4 (single precision)

Using 1 MPI thread
Using 12 OpenMP threads 

3 GPUs detected:
  #0: NVIDIA GeForce GTX 770, compute cap.: 3.0, ECC:  no, stat: compatible
  #1: NVIDIA GeForce GTX 650, compute cap.: 3.0, ECC:  no, stat: compatible
  #2: NVIDIA GeForce GTX 770, compute cap.: 3.0, ECC:  no, stat: compatible

0 GPU user-selected for this run.
Mapping of GPU to the 1 PP rank in this node: #0

GROMACS 5.0.1, nVidia CUDA Toolkit, And FFTW3 Under Ubuntu 14.04 LTS (64-bit); The Virtues Of VirtualBox

Monday, September 22nd, 2014

Summarized below are the catches and fixes from a recent effort to build GROMACS 5.0.1 with FFTW3 (single- and double-precision) and GPU support (so, single-precision). Also, a trick I’ve been doing with great success lately, using a virtual machine to keep my real machine as clean as possible.

0. The Virtues Of VirtualBox

Open source means never having to say you’re sorry.

I’ve made the above proclamation to anyone who’d listen lately who has any interest in using Linux software (because, regardless of what anyone says on the matter, it ain’t there yet as an operating system for general scientific users with general computing know-how). You will very likely find yourself stuck at a configure or make step in one or more prerequisite codes to some final build you’re trying to do, leaving yourself to google error messages to try to come up with some kind of solution. Invariably, you’ll try something that seems to work, only to find it doesn’t, potentially leaving a trail of orphaned files, version-breaking changes, and random downgrading only to find something else stupid (or not) fixed your build problems.

I’ve an install I’m quite happy with that has all of the working code I want on it working – and I’ve no interest in having to perform re-installs to get back to a working state again.

My solution, which I’ve used to great success with GAMESS-US, GROMACS, NWChem, and Amber (so far), is to break a virtual instance in VirtualBox first. For those who don’t know (and briefly), VirtualBox lets you install a fully-working OS inside of your own OS that simply sits as a file in a Virtual VM folder in your user directory. My procedure has been to install a 60 GB VirtualBox instance of (currently) Ubuntu 14.04 (which I will refer to here as PROTOTYPE), fully update it to the current state of my RealBox (updates, upgrades, program installs, etc.), then copy PROTOTYPE somewhere else on the machine. The only limitation of this approach is that VirtualBox doesn’t give you access to the GPU if you’re testing CUDA-specific calculations. That said, it does let you install the CUDA Development Toolkit and compile code just fine, so you can at least work your way through a full build to make sure you don’t run into problems.

When you’re done trashing your VirtualBox after a particularly heinous build, just delete PROTOTYPE from Virtual VM and re-copy your copy back into Virtual VM – voila! You’re ready for another build operation (or to make sure your “final” build actually works flawlessly before committing the build to your RealBox.

That’s all I have to say on the matter. Consider it as your default procedure (at this point, I won’t touch my RealBox with new installs until I know it’s safe in VirtualBox).

1. The State Of My Machine Pre-GROMACS And All Other apt-get’s Used Below

What follows below is pretty straightforward. Errors you might get that don’t appear below might be related to the lack of certain installs on your machine that I installed on VirtualBox. That is, my standard PROTOTYPE comes standard with Intel’s Fortran and C Compilers (for code optimization). Those installs required a few installs above the base Ubuntu install. These are (and are pretty standard anyway, so I say install them anyway):

sudo apt-get install build-essential gcc-multilib rpm openjdk-7-jre-headless 

I could have just installed a fresh version of 14.04 onto a machine to try this myself, but I’m not that motivated. Also, note this list does not include the all-important cmake. We’ll get to that.

And for the rest of GROMACS (at least for older versions), there were lots of mesa/gnuplot/motif-specific dependencies in older versions of GROMACS to build all of the files included in the GROMACS package. Regardless of GPU builds or not, I tend to default to install all the packages below just to have them (which all, for 14.04, currently apt-get properly).

sudo apt-get install openmpi-bin openmpi-common gfortran csh grace menu x11proto-print-dev motif-clients freeglut3-dev libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libgl1-mesa-dri libcurl-ocaml-dev libcurl4-gnutls-dev gnuplot

If you don’t install the libblas3gf libblas-doc libblas-dev liblapack3gf liblapack-doc liblapack-dev series, you’ll see the following note from your cmake steps in GROMACS.

— A library with BLAS API not found. Please specify library location.
— Using GROMACS built-in BLAS.
— LAPACK requires BLAS
— A library with LAPACK API not found. Please specify library location.
— Using GROMACS built-in LAPACK.

My own preference is to use the (assumedly newer) Ubuntu-specific libraries from apt-get.

sudo apt-get install libblas3gf libblas-doc libblas-dev liblapack3gf liblapack-doc liblapack-dev

GPU-Specific? One More apt-get

My first passes at proper GPU compilation involved several steps for the nVidia Developer Toolkit install. That’s now taken care of with apt-get, so perform the final apt-get to complete the component/dependency installations.

sudo apt-get install nvidia-cuda-dev nvidia-cuda-toolkit

With luck, your first attempt at a GPU-based installation will look like the following:

[0%] Building NVCC (Device) object src/gromacs/gmxlib/cuda_tools/CMakeFiles/cuda_tools.dir//./cuda_tools_generated_copyrite_gpu.cu.o

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable ../../bin/gmx
[100%] Built target gmx

2. Nothing Happens Without cmake

Install cmake! Reproducing the output below to make sure you’re using the same versions for everything (in the event something breaks in the future).

sudo apt-get install cmake

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
cmake-data
Suggested packages:
codeblocks eclipse
The following NEW packages will be installed:
cmake cmake-data
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,294 kB of archives.
After this operation, 16.6 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main cmake-data all 2.8.12.2-0ubuntu3 [676 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main cmake amd64 2.8.12.2-0ubuntu3 [2,618 kB]
Fetched 3,294 kB in 30s (106 kB/s)
Selecting previously unselected package cmake-data.
(Reading database … 258157 files and directories currently installed.)
Preparing to unpack …/cmake-data_2.8.12.2-0ubuntu3_all.deb …
Unpacking cmake-data (2.8.12.2-0ubuntu3) …
Selecting previously unselected package cmake.
Preparing to unpack …/cmake_2.8.12.2-0ubuntu3_amd64.deb …
Unpacking cmake (2.8.12.2-0ubuntu3) …
Processing triggers for man-db (2.6.7.1-1) …
Setting up cmake-data (2.8.12.2-0ubuntu3) …
Setting up cmake (2.8.12.2-0ubuntu3) …

3. First Pass At GROMACS

The make install step will place GROMACS where you want it on your machine, so you’re just as good building in $HOME/Downloads as you are anywhere else. I will be performing all operations from $HOME/Downloads unless otherwise stated.

According to the GROMACS Installation Manual, your quick-and-dirty install need only involve the following:

$ tar xvfz gromacs-src.tar.gz
$ ls
gromacs-src
$ mkdir build
$ cd build
$ cmake ../gromacs-src
$ make

This allows you build “out-of-source” as they put it. Frankly, I just dive right into the GROMACS folder and have at it.

CMake Error: The source directory “/home/user/Downloads/gromacs-5.0.1/build” does not appear to contain CMakeLists.txt.
Specify –help for usage, or press the help button on the CMake GUI.

And did you see the above error? If so, you read the GROMACS quick-and-dirty procedure backwards. I’m not running it this way, so doesn’t matter to what follows.

My first attempt at building GROMACS produced the following output from PROTOTYPE (reproducing all the text below).

user@PROTOTYPE:~$ cd Downloads/
user@PROTOTYPE:~/Downloads$ gunzip gromacs-5.0.1.tar.gz 
user@PROTOTYPE:~/Downloads$ tar xvf gromacs-5.0.1.tar 

gromacs-5.0.1/README
gromacs-5.0.1/INSTALL

gromacs-5.0.1/tests/CppCheck.cmake
gromacs-5.0.1/tests/CMakeLists.txt

user@PROTOTYPE:~/Downloads$ cd gromacs-5.0.1/
user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF

NOTE: If you just run cmake, you’ll get the following…

cmake version 2.8.12.2
Usage

cmake [options] cmake [options]

… which is to say, cmake requires at least one option be specified. Above, I’m just using -DGMX_GPU=OFF to start the process.

The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2
— Check for working C compiler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Check for working CXX compiler: /usr/bin/c++
— Check for working CXX compiler: /usr/bin/c++ — works
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info – done
— Checking for GCC x86 inline asm
— Checking for GCC x86 inline asm – supported
— Detecting best SIMD instructions for this CPU
— Detected best SIMD instructions for this CPU – SSE2
— Try OpenMP C flag = [-fopenmp]
— Performing Test OpenMP_FLAG_DETECTED
— Performing Test OpenMP_FLAG_DETECTED – Success
— Try OpenMP CXX flag = [-fopenmp]
— Performing Test OpenMP_FLAG_DETECTED
— Performing Test OpenMP_FLAG_DETECTED – Success
— Found OpenMP: -fopenmp
— Performing Test CFLAGS_WARN
— Performing Test CFLAGS_WARN – Success
— Performing Test CFLAGS_WARN_EXTRA
— Performing Test CFLAGS_WARN_EXTRA – Success
— Performing Test CFLAGS_WARN_REL
— Performing Test CFLAGS_WARN_REL – Success
— Performing Test CFLAGS_WARN_UNINIT
— Performing Test CFLAGS_WARN_UNINIT – Success
— Performing Test CFLAGS_EXCESS_PREC
— Performing Test CFLAGS_EXCESS_PREC – Success
— Performing Test CFLAGS_COPT
— Performing Test CFLAGS_COPT – Success
— Performing Test CFLAGS_NOINLINE
— Performing Test CFLAGS_NOINLINE – Success
— Performing Test CXXFLAGS_WARN
— Performing Test CXXFLAGS_WARN – Success
— Performing Test CXXFLAGS_WARN_EXTRA
— Performing Test CXXFLAGS_WARN_EXTRA – Success
— Performing Test CXXFLAGS_WARN_REL
— Performing Test CXXFLAGS_WARN_REL – Success
— Performing Test CXXFLAGS_EXCESS_PREC
— Performing Test CXXFLAGS_EXCESS_PREC – Success
— Performing Test CXXFLAGS_COPT
— Performing Test CXXFLAGS_COPT – Success
— Performing Test CXXFLAGS_NOINLINE
— Performing Test CXXFLAGS_NOINLINE – Success
— Looking for include file unistd.h
— Looking for include file unistd.h – found
— Looking for include file pwd.h
— Looking for include file pwd.h – found
— Looking for include file dirent.h
— Looking for include file dirent.h – found
— Looking for include file time.h
— Looking for include file time.h – found
— Looking for include file sys/time.h
— Looking for include file sys/time.h – found
— Looking for include file io.h
— Looking for include file io.h – not found
— Looking for include file sched.h
— Looking for include file sched.h – found
— Looking for include file regex.h
— Looking for include file regex.h – found
— Looking for C++ include regex
— Looking for C++ include regex – not found
— Looking for posix_memalign
— Looking for posix_memalign – found
— Looking for memalign
— Looking for memalign – found
— Looking for _aligned_malloc
— Looking for _aligned_malloc – not found
— Looking for gettimeofday
— Looking for gettimeofday – found
— Looking for fsync
— Looking for fsync – found
— Looking for _fileno
— Looking for _fileno – not found
— Looking for fileno
— Looking for fileno – found
— Looking for _commit
— Looking for _commit – not found
— Looking for sigaction
— Looking for sigaction – found
— Looking for sysconf
— Looking for sysconf – found
— Looking for rsqrt
— Looking for rsqrt – not found
— Looking for rsqrtf
— Looking for rsqrtf – not found
— Looking for sqrtf
— Looking for sqrtf – not found
— Looking for sqrt in m
— Looking for sqrt in m – found
— Looking for clock_gettime in rt
— Looking for clock_gettime in rt – found
— Checking for sched.h GNU affinity API
— Performing Test sched_affinity_compile
— Performing Test sched_affinity_compile – Success
— Check if the system is big endian
— Searching 16 bit integer
— Looking for sys/types.h
— Looking for sys/types.h – found
— Looking for stdint.h
— Looking for stdint.h – found
— Looking for stddef.h
— Looking for stddef.h – found
— Check size of unsigned short
— Check size of unsigned short – done
— Using unsigned short
— Check if the system is big endian – little endian
— Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version “2.9.1”)
— Looking for xmlTextWriterEndAttribute in /usr/lib/x86_64-linux-gnu/libxml2.so
— Looking for xmlTextWriterEndAttribute in /usr/lib/x86_64-linux-gnu/libxml2.so – found
— Looking for include file libxml/parser.h
— Looking for include file libxml/parser.h – found
— Looking for include file pthread.h
— Looking for include file pthread.h – found
— Looking for pthread_create
— Looking for pthread_create – not found
— Looking for pthread_create in pthreads
— Looking for pthread_create in pthreads – not found
— Looking for pthread_create in pthread
— Looking for pthread_create in pthread – found
— Found Threads: TRUE
— Looking for include file pthread.h
— Looking for include file pthread.h – found
— Atomic operations found
— Performing Test PTHREAD_SETAFFINITY
— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so – found
— Setting build user/date/host/cpu information
— Setting build user & time – OK
— Checking floating point format
— Checking floating point format – IEEE754 (LE byte, LE word)
— Checking for 64-bit off_t
— Checking for 64-bit off_t – present
— Checking for fseeko/ftello
— Checking for fseeko/ftello – present
— Checking for SIGUSR1
— Checking for SIGUSR1 – found
— Checking for pipe support
— Checking for isfinite
— Performing Test isfinite_compile_ok
— Performing Test isfinite_compile_ok – Success
— Checking for isfinite – yes
— Checking for _isfinite
— Performing Test _isfinite_compile_ok
— Performing Test _isfinite_compile_ok – Failed
— Checking for _isfinite – no
— Checking for _finite
— Performing Test _finite_compile_ok
— Performing Test _finite_compile_ok – Failed
— Checking for _finite – no
— Performing Test CXXFLAG_STD_CXX0X
— Performing Test CXXFLAG_STD_CXX0X – Success
— Performing Test GMX_CXX11_SUPPORTED
— Performing Test GMX_CXX11_SUPPORTED – Success
— Checking for system XDR support
— Checking for system XDR support – present
— Try C compiler SSE2 flag = [-msse2]
— Performing Test C_FLAG_msse2
— Performing Test C_FLAG_msse2 – Success
— Performing Test C_SIMD_COMPILES_FLAG_msse2
— Performing Test C_SIMD_COMPILES_FLAG_msse2 – Success
— Try C++ compiler SSE2 flag = [-msse2]
— Performing Test CXX_FLAG_msse2
— Performing Test CXX_FLAG_msse2 – Success
— Performing Test CXX_SIMD_COMPILES_FLAG_msse2
— Performing Test CXX_SIMD_COMPILES_FLAG_msse2 – Success
— Enabling SSE2 SIMD instructions
— Performing Test _callconv___vectorcall
— Performing Test _callconv___vectorcall – Failed
— Performing Test _callconv___regcall
— Performing Test _callconv___regcall – Failed
— Performing Test _callconv_
— Performing Test _callconv_ – Success
— checking for module ‘fftw3f’
— package ‘fftw3f’ not found
— pkg-config could not detect fftw3f, trying generic detection
Could not find fftw3f library named libfftw3f, please specify its location in CMAKE_PREFIX_PATH or FFTWF_LIBRARY by hand (e.g. -DFFTWF_LIBRARY=’/path/to/libfftw3f.so’)
CMake Error at cmake/gmxManageFFTLibraries.cmake:76 (MESSAGE):
Cannot find FFTW 3 (with correct precision – libfftw3f for mixed-precision
GROMACS or libfftw3 for double-precision GROMACS). Either choose the right
precision, choose another FFT(W) library (-DGMX_FFT_LIBRARY), enable the
advanced option to let GROMACS build FFTW 3 for you
(-GMX_BUILD_OWN_FFTW=ON), or use the really slow GROMACS built-in fftpack
library (-DGMX_FFT_LIBRARY=fftpack).
Call Stack (most recent call first):
CMakeLists.txt:733 (include)

— Configuring incomplete, errors occurred!
See also “/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeOutput.log”.
See also “/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeError.log”.

Lots of little things to address here. We’ll get to the Boost problem later. Meantime, you can see the critical error is in (1) the lack of FFTW3 and (2) the lack of my specifically asking for -DGMX_BUILD_OWN_FFTW=ON in the cmake process.

NOTE: If you try to fix the FFTW3 problem as described above, you’ll get the following error:

-GMX_BUILD_OWN_FFTW=ON

CMake Error: Could not create named generator MX_BUILD_OWN_FFTW=ON

Make sure to put the “D” in:

-DGMX_BUILD_OWN_FFTW=ON

4. If You Don’t Use DGMX_BUILD_OWN_FFTW=ON To Build FFTW3…

This is a skip-able section if you’re letting cmake do the dirty work (and letting cmake do it is preferred, at least for getting GROMACS built). In trying sudo apt-get install fftw*, you see (currently) the following: fftw2 fftw-dev fftw-docs

No good. So, the procedure is to build FFTW3 from source (which is just as easy as installing from .deb or .rpm files if you installed everything I mentioned above). That said, your attempts to build FFTW3 and build GROMACS may have run into several errors because of how you built FFTW3. Beginning with your extracting and prep for make:

user@PROTOTYPE:~/Downloads$ tar xvf fftw-3.3.4.tar 
user@PROTOTYPE:~/Downloads$ cd fftw-3.3.4/

Any of the combinations below produce the same error:

user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure 
user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure -enable-shared=yes
user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure --enable-threads --enable-float

checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes

config.status: executing depfiles commands
config.status: executing libtool commands

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF
user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF -DFFTWF_LIBRARY='/usr/local/lib/libfftw3.a'

— The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2
— Check for working C compiler: /usr/bin/cc

— Performing Test PTHREAD_SETAFFINITY
— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so – found

— checking for module ‘fftw3f’
— package ‘fftw3f’ not found
— pkg-config could not detect fftw3f, trying generic detection
Could not find fftw3f library named libfftw3f, please specify its location in CMAKE_PREFIX_PATH or FFTWF_LIBRARY by hand (e.g. -DFFTWF_LIBRARY=’/path/to/libfftw3f.so’)
CMake Error at cmake/gmxManageFFTLibraries.cmake:76 (MESSAGE):
Cannot find FFTW 3 (with correct precision – libfftw3f for mixed-precision
GROMACS or libfftw3 for double-precision GROMACS). Either choose the right
precision, choose another FFT(W) library (-DGMX_FFT_LIBRARY), enable the
advanced option to let GROMACS build FFTW 3 for you
(-GMX_BUILD_OWN_FFTW=ON), or use the really slow GROMACS built-in fftpack
library (-DGMX_FFT_LIBRARY=fftpack).
Call Stack (most recent call first):
CMakeLists.txt:733 (include)

— Configuring incomplete, errors occurred!
See also “/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeOutput.log”.
See also “/home/user/Downloads/gromacs-5.0.1/CMakeFiles/CMakeError.log”.

Including –enable-shared takes care of this error and gets you to a successful GROMACS build.

user@PROTOTYPE:~/Downloads/fftw-3.3.4$ ./configure --enable-threads --enable-float --enable-shared

— The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2
— Check for working C compiler: /usr/bin/cc

— Performing Test PTHREAD_SETAFFINITY
— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so – found

— checking for module ‘fftw3f’
— found fftw3f, version 3.3.4
— Looking for fftwf_plan_r2r_1d in /usr/local/lib/libfftw3f.so
— Looking for fftwf_plan_r2r_1d in /usr/local/lib/libfftw3f.so – found
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_sse2 in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_sse2 in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_avx in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_altivec in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_altivec in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_simd_neon in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_simd_neon in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_sse2 in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_sse2 in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_sse in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_sse in /usr/local/lib/libfftw3f.so – not found
— Looking for fftwf_have_altivec in /usr/local/lib/libfftw3f.so
— Looking for fftwf_have_altivec in /usr/local/lib/libfftw3f.so – not found
CMake Warning at cmake/gmxManageFFTLibraries.cmake:89 (message):
The fftw library found is compiled without SIMD support, which makes it
slow. Consider recompiling it or contact your admin
Call Stack (most recent call first):
CMakeLists.txt:733 (include)

— Using external FFT library – FFTW3
— Looking for sgemm_

— Configuring done
— Generating done
— Build files have been written to: /home/user/Downloads/gromacs-5.0.1

And out of a first-pass GROMACS build…

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=OFF

Scanning dependencies of target libgromacs
[0%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/__/external/tng_io/src/compression/bwlzh.c.o
[0%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/__/external/tng_io/src/compression/bwt.c.o

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable ../../bin/gmx
[100%] Built target gmx

5. But You Let cmake Build FFTW3. So, Continuing The Build Process

With all of the dependencies above installed, the one note I wanted to address was that for Boost:


— Performing Test PTHREAD_SETAFFINITY – Success
— Could NOT find Boost
Boost >= 1.44 not found. Using minimal internal version. This may cause trouble if you plan on compiling/linking other software that uses Boost against Gromacs.
— Looking for zlibVersion in /usr/lib/x86_64-linux-gnu/libz.so

It certainly isn’t a major issue, but I wanted to try to get an warning-free build. Installing Boost 1.56 produced the following negative result:

user@PROTOTYPE:~/Downloads/boost_1_56_0$ ./bootstrap.sh 

Building Boost.Build engine with toolset gcc… tools/build/src/engine/bin.linuxx86_64/b2
Detecting Python version… 2.7
Detecting Python root… /usr
Unicode/ICU support for Boost.Regex?… not found.
Generating Boost.Build configuration in project-config.jam…

Bootstrapping is done. To build, run:

./b2

To adjust configuration, edit ‘project-config.jam’.
Further information:

– Command line help:
./b2 –help

– Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html

– Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html

user@PROTOTYPE:~/Downloads/boost_1_56_0$ sudo ./b2 install

Performing configuration checks

– 32-bit : no (cached)
– 64-bit : yes (cached)
– arm : no (cached)

…failed updating 58 targets…
…skipped 12 targets…
…updated 11322 targets…

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=ON -DGMX_DOUBLE=OFF
user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ make

[0%] Building NVCC (Device) object src/gromacs/gmxlib/cuda_tools/CMakeFiles/cuda_tools.dir//./cuda_tools_generated_copyrite_gpu.cu.o
[0%] Building NVCC (Device) object src/gromacs/gmxlib/cuda_tools/CMakeFiles/cuda_tools.dir//./cuda_tools_generated_pmalloc_cuda.cu.o

[7%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/commandline/cmdlinehelpwriter.cpp.o
In file included from /home/user/Downloads/gromacs-5.0.1/src/gromacs/options/basicoptions.h:52:0,
from /home/user/Downloads/gromacs-5.0.1/src/gromacs/commandline/cmdlinehelpwriter.cpp:55:
/home/user/Downloads/gromacs-5.0.1/src/gromacs/options/../utility/gmxassert.h:47:57: fatal error: boost/exception/detail/attribute_noreturn.hpp: No such file or directory
#include
^
compilation terminated.
make[2]: *** [src/gromacs/CMakeFiles/libgromacs.dir/commandline/cmdlinehelpwriter.cpp.o] Error 1
make[1]: *** [src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
make: *** [all] Error 2

Sadly, the solution is to then include -DGMX_EXTERNAL_BOOST=off and stick with the internal boost, which then “makes” just fine. One page references the use of -DGMX_INTERNAL_BOOST=on, but that produced the following:

CMake Warning:
Manually-specified variables were not used by the project:

GMX_INTERNAL_BOOST

— Build files have been written to: /home/user/Downloads/gromacs-5.0.1

There’s more on this issue at: gerrit.gromacs.org/#/c/1232/ and t24960.science-biology-gromacs-development.biotalk.us/compiling-boost-problem-and-error-with-icc-t24960.html, but I’ve opted not to worry about it.

So, with Boost installed, I simply ignore it (and have not installed Boost on my RealBox).

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=ON -DGMX_EXTERNAL_BOOST=off

6. Finishing Step If All Above Goes Well: CUDA-Based GROMACS Build

If everything else above has gone smoothly (and if you ignored the Boost install. If you didn’t, remember to add -DGMX_EXTERNAL_BOOST=off to the cmake below), you should be able to cleanly run a cmake for a GPU version of GROMACS (below, with the final result to be placed into /opt/gromacs_gpu. You then specify the $PATH after and run with it).

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ cmake -DGMX_GPU=ON -DCMAKE_INSTALL_PREFIX=/opt/gromacs_gpu -DGMX_BUILD_OWN_FFTW=ON

— The C compiler identification is GNU 4.8.2
— The CXX compiler identification is GNU 4.8.2

— Generating done
— Build files have been written to: /home/damianallis/Downloads/gromacs-5.0.1

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ make

The make starts with the FFTW3 download and build…

Scanning dependencies of target fftwBuild
[ 0%] Performing pre-download step for ‘fftwBuild’
— downloading…
src=’http://www.fftw.org/fftw-3.3.3.tar.gz’
dest=’/home/damianallis/Downloads/gromacs-5.0.1/src/contrib/fftw/fftw.tar.gz’
— [download 0% complete]

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable ../../bin/gmx
[100%] Built target gmx

Finally, your (sudo) make install places everything into /opt/gromacs_gpu.

user@PROTOTYPE:~/Downloads/gromacs-5.0.1$ sudo make install

— The GROMACS-managed build of FFTW 3 will configure with the following optimizations: –enable-sse2
— Configuring done
— Generating done
— Build files have been written to: /home/damianallis/Downloads/gromacs-5.0.1
[1%] Built target fftwBuild

[100%] Building CXX object src/programs/CMakeFiles/gmx.dir/legacymodules.cpp.o
Linking CXX executable ../../bin/gmx
[100%] Built target gmx

Stupid-Simple (*nix-Specific) Sed Scripts To Get (All Current) Gaussian09 Output Files Working With aClimax

Monday, September 1st, 2014

The following three snippets of Gaussian output are for an optimization and normal mode analysis of simple olde methane (CH4).

...
 ******************************************
 Gaussian 03:  EM64L-G03RevE.01 11-Sep-2007
                31-Aug-2014 
 ******************************************
...
 incident light, reduced masses (AMU), force constants (mDyne/A),
 and normal coordinates:
                     1                      2                      3
                     T                      T                      T
 Frequencies --  1356.0070              1356.0070              1356.0070
 Red. masses --     1.1789                 1.1789                 1.1789
 Frc consts  --     1.2771                 1.2771                 1.2771
 IR Inten    --    14.1122                14.1122                14.1122
 Atom AN      X      Y      Z        X      Y      Z        X      Y      Z
   1   1     0.02  -0.42   0.43    -0.34  -0.13  -0.08    -0.36  -0.23  -0.23
   2   6     0.00   0.08  -0.09     0.00   0.09   0.08     0.12   0.00   0.00
...
 -------------------
 - Thermochemistry -
 -------------------
 Temperature   298.150 Kelvin.  Pressure   1.00000 Atm.
 Atom  1 has atomic number  1 and mass   1.00783
...
...
 ******************************************
 Gaussian 09:  EM64L-G09RevA.02 11-Jun-2009
                31-Aug-2014 
 ******************************************
...
 incident light, reduced masses (AMU), force constants (mDyne/A),
 and normal coordinates:
                     1                      2                      3
                     T                      T                      T
 Frequencies --  1356.0058              1356.0058              1356.0058
 Red. masses --     1.1789                 1.1789                 1.1789
 Frc consts  --     1.2771                 1.2771                 1.2771
 IR Inten    --    14.1123                14.1123                14.1123
  Atom  AN      X      Y      Z        X      Y      Z        X      Y      Z
     1   1    -0.03   0.42   0.43    -0.34  -0.14   0.07    -0.36  -0.23   0.23
     2   6     0.00  -0.08  -0.10     0.01   0.10  -0.08     0.12   0.00   0.00
...
-------------------
 - Thermochemistry -
 -------------------
 Temperature   298.150 Kelvin.  Pressure   1.00000 Atm.
 Atom     1 has atomic number  1 and mass   1.00783
...
...
 ******************************************
 Gaussian 09:  EM64L-G09RevD.01 24-Apr-2013
                31-Aug-2014 
 ******************************************
...
 incident light, reduced masses (AMU), force constants (mDyne/A),
 and normal coordinates:
                      1                      2                      3
                     ?A                     ?A                     ?A
 Frequencies --   1356.0132              1356.0132              1356.0132
 Red. masses --      1.1789                 1.1789                 1.1789
 Frc consts  --      1.2771                 1.2771                 1.2771
 IR Inten    --     14.1119                14.1119                14.1119
  Atom  AN      X      Y      Z        X      Y      Z        X      Y      Z
     1   1     0.02   0.42   0.43     0.34  -0.14   0.08    -0.36   0.23  -0.23
     2   6     0.00  -0.08  -0.09    -0.01   0.09  -0.08     0.12   0.00   0.00
...
 -------------------
 - Thermochemistry -
 -------------------
 Temperature   298.150 Kelvin.  Pressure   1.00000 Atm.
 Atom     1 has atomic number  1 and mass   1.00783
...

Two of these things are not like the other. The data’s nearly identical (and thank heavens. Unfortunately, Gaussian09 D.01 didn’t see the fully-optimized methane as belonging to the Td point group – despite all three versions being run with the same exact input file – but a rigorous re-symmetrization would have taken care of that), but there are some subtle formatting differences between all three versions (including differences between both Gaussian09 versions) that cause the venerable, all-encompassing aClimax program (developed by Timmy, the venerable, all-encompassing A. J. Ramirez-Cuesta) to throw out the following errors for all three cases when you use *.log files from a *nix (UNIX, Linux) machine.

Serious Error: A-CLIMAX has encountered an unhanded error. Please Save your data and contact support
aClimax: Quote Error Number 9
Error Loading File: Error reading data. Please check and try again.
aClimax: WARNING loaded file containing no frequencies

Problem number 1 is the existence of *nix newlines (carriage returns) in the *.log files coming off a *nix machine. Performing a conversion from *nix to DOS (for myself, using LineBreak in OSX, but tofrodos works just as well), the Gaussian03 file now opens just fine in aClimax:

File Loaded: Data Loaded Succesfully [sic].

This, unfortunately, does not improve the matter with the Gaussian09 files, which produce the following error:

Error: One of the numbers you have entered is of the wrong type.Please recheck and try again
Error Loading File: Error reading data. Please check and try again.

Given how little of the .log file aClimax actually needs to produce simulated inelastic neutron scattering (INS) spectra, I ran the methane normal mode analyses in three different Gaussian versions to determine what, in G09, was changed to make it just un-G03 enough to fail to load. With those changes figured out, I had a Perl script drafted up that would have converted everything back to the original G03 format. It was awesome. That said, after a small amount of testing to see where aClimax’s sensitivities lay, I discovered that very little of the .log file contents needed to be changed out, meaning that simple sed scripts would work just as well for those of us using our Windows boxes (or VirtualBox emulations) only for that “one stupid program” that keeps us having to log in (and, by that, I mean that we have sed already on our computers).

So, the problems between G09 and aClimax not related to carriage returns lie in two places.

1. The spacing of “Atom AN” – at the top of the eigenvector lists are the column labels, beginning with “Atom AN” – or something very close to “Atom AN” (the “|” in the boxes below mark the left edge of the output):

G03 E01 | Atom AN
G09 A02 |   Atom  AN
G09 D01 |  Atom  AN

Yes, the addition of a space or two results in a read error by aClimax. I would call this an… aggressive stringency in aClimax. That said, what did the original space in G03 versions not do that they do do in G09?

2. The spacing of “Atom N” – In the “Thermochemistry” section below the eigenvectors, atomic masses are listed as “Atom N” – or something very close to “Atom N” (again, the “|” in the boxes below mark the left edge of the output):

G03 E01 |  Atom  1
G09 A02 |    Atom     1
G09 D01 |   Atom     1

This change in spacing is also enough to cause aClimax to error out.

The Solution

A small sed script performs the necessary conversions on your *nix box (including OSX) for all .log files in a directory without issue:

#!/bin/sh

# This section converts all .log files to aClimax-friendly G03-ish format
find . -type f -name '*.log' -print | while read i
do
sed 's|  Atom  AN| Atom AN |g' $i > $i.aclimaxconversion_step1
sed 's| Atom   | Atom|g' $i.aclimaxconversion_step1 > $i.aClimaxable.log
rm $i.aclimaxconversion_step1
done

# This section converts all .out files to aClimax-friendly G03-ish format
find . -type f -name '*.out' -print | while read i
do
sed 's|  Atom  AN| Atom AN |g' $i > $i.aclimaxconversion_step1
sed 's| Atom   | Atom|g' $i.aclimaxconversion_step1 > $i.aClimaxable.out
rm $i.aclimaxconversion_step1
done

But Wait! Running G0* Jobs Under *nix? Convert To DOS Carriage Returns

The final problem halting your aClimax spectrum generation is the DOS carriage return (^M). For those running DOS-based Gaussian calculations (likely with a .out suffix), your conversion with the short script above (under *nix) likely (hopefully) worked just fine. For those running under *nix, you performed the conversion and still received the following aClimax error:

Serious Error: A-CLIMAX has encountered an unhanded error. Please Save your data and contact support
aClimax: Quote Error Number 9
Error Loading File: Error reading data. Please check and try again.
aClimax: WARNING loaded file containing no frequencies

The solution is an additional line in the sed script that will globally replace all *nix newlines with proper DOS carriage returns. The .out section remains the same.

#!/bin/sh

# This section converts all .log files to aClimax-friendly G03-ish format
find . -type f -name '*.log' -print | while read i
do
sed 's|  Atom  AN| Atom AN |g' $i > $i.aclimaxconversion_step1
sed 's| Atom   | Atom|g' $i.aclimaxconversion_step1 > $i.aclimaxconversion_step2
# This section converts your *nix newlines into DOS carriage returns
CR=`echo "\0015"`  # define the Carriage Return
sed -e "s/$/${CR}/g" $i.aclimaxconversion_step2 > $i.aClimaxable.log
done
# this cleans up your folder of temp files
rm *.aclimaxconversion_step1
rm *.aclimaxconversion_step2

# This section converts all .out files to aClimax-friendly G03-ish format
find . -type f -name '*.out' -print | while read i
do
sed 's|  Atom  AN| Atom AN |g' $i > $i.aclimaxconversion_step1
sed 's| Atom   | Atom|g' $i.aclimaxconversion_step1 > $i.aClimaxable.out
rm $i.aclimaxconversion_step1
done

Q. But what if I run the *nix-to-DOS version of the script on an already DOS-output file?

A1. The simple answer is that you’ll make your text file double-spaced (which is bad enough). aClimax will then provide the following error when you try to open it:

Error Reading File: Unexpected File End. File May be incorrect or corrupt.
Error Loading File: Error reading data. Please check and try again.

A2. I will assume that your problem is that you’re running the script in DOS to try to get your G09 to read more like G03. In this case (assuming you’re generating .out files), you’ll want to use a text editor to make the replacements described above (which is to say, that Perl script might makes it way to this page eventually. If you write a DOS .bat file or similar script for all OS’s, I’d be happy to link to it).

Generating Molecular Orbitals (And Visualizing Assorted Properties) With The Gaussian09 cubegen Utility

Saturday, June 7th, 2014

To begin, this post owes its existence to the efforts of Dr. Douglas Fox at Gaussian, Inc., who provided me with an alternative explanation of how the cubegen utility works. After much wailing and gnashing of teeth, I intend on taking Dr. Fox’s advice and asking Gaussian Support for assistance earlier in my endeavors. What follows below, I hope, will save you some significant frustration (and, given how little there is online that really describes the extra workings of cubegen in a clear and example’ed way, it is my expectation that this page appeared early in your search list).

What I wanted out of cubegen that I couldn’t figure out how to get:

The situation was simple. I wanted my molecule centered and bound within an arbitrarily-sized box (X,Z,Y) for making images and doing additional post-processing. Specifically, I wanted to be able to take many different molecules (from hydrogen gas to big biomolecules) defined within the same-sized box for layering and presentation (different boxes for each, but all the same size).

I am assuming for this that you’re using cubegen from a terminal (not within GaussView or the like) to produce .cub/.cube files for use in some kind of rendering-capable program (like VESTA or VMD) and that cubegen and formchk are in your PATH (either properly placed or by running the Gaussian install script). I’ll be demonstrating usage with benzene (C6H6) and the benzene cation (C6H6+).

1. The Checkpoint File

To extract any kind of data for making .cub/.cube files, you need a checkpoint file (.chk) from your run. This is performed by adding a %chk=FILENAME.chk line to the top of the input file (which, if you’re a Gaussian user, you likely already know). If you want additional properties cube’d, check the Gaussian Tech Document, specifically looking at the Pop keyword for most of the properties you’d want visualized (this data gets placed into the .chk file for .cub/.cube generation after the run). For the standard molecular orbitals, they’re already saved in the .chk file (or their coefficients, anyway).

For benzene.gjf:

%chk=benzene.chk
# b3lyp/6-31G(d,p)

Benzene

0 1
 C                  1.20809735    0.69749533   -0.00000000
 C                  0.00000000    1.39499067   -0.00000000
 C                 -1.20809735    0.69749533   -0.00000000
 C                 -1.20809735   -0.69749533   -0.00000000
 C                  0.00000000   -1.39499067   -0.00000000
 C                  1.20809735   -0.69749533   -0.00000000
 H                  2.16038781    1.24730049   -0.00000000
 H                  0.00000000    2.49460097   -0.00000000
 H                 -2.16038781    1.24730049   -0.00000000
 H                 -2.16038781   -1.24730049   -0.00000000
 H                  0.00000000   -2.49460097   -0.00000000
 H                  2.16038781   -1.24730049   -0.00000000

For benzenecation.gjf:

%chk=benzenecation.chk
# b3lyp/6-31G(d,p)

Benzene cation

1 2
 C                  1.20809735    0.69749533   -0.00000000
 C                  0.00000000    1.39499067   -0.00000000
 C                 -1.20809735    0.69749533   -0.00000000
 C                 -1.20809735   -0.69749533   -0.00000000
 C                  0.00000000   -1.39499067   -0.00000000
 C                  1.20809735   -0.69749533   -0.00000000
 H                  2.16038781    1.24730049   -0.00000000
 H                  0.00000000    2.49460097   -0.00000000
 H                 -2.16038781    1.24730049   -0.00000000
 H                 -2.16038781   -1.24730049   -0.00000000
 H                  0.00000000   -2.49460097   -0.00000000
 H                  2.16038781   -1.24730049   -0.00000000

2. Convert The .chk To .fchk With formchk

As per the Gaussian Tech Doc:

formchk converts the data in a Gaussian checkpoint file into a formatted form which is suitable for input into a variety of visualization software.

Basically, making the .chk file something that cubegen can manipulate to generate .cub/.cube files of orbitals, densities, electrostatic potentials, etc. This run is simple for most users (for the rest, see formchk).

formchk benzene.chk benzene.fchk
formchk benzenecation.chk benzenecation.fchk

3. Using cubegen

And now the fun begins. A typical cubegen run looks like the following:

cubegen 0 MO=HOMO benzene.fchk benzene_HOMO.cub 0 h

cubegen – run cubegen
0 – an old memory flag (must be there, but not important)
MO=HOMO – generate the highest occupied molecular orbital
benzene.fchk – the .fchk file
benzene_HOMO.cub – the generated .cub file
0 – use the default grid point specification (80*80*80 points total in the whole cube file)
h – write out the .cub file with headers

The output you find summarized in VESTA is below for this case.

DEFAULT:
OpenGL version: 2.1 INTEL-8.26.34
Video configuration: Intel HD Graphics 4000 OpenGL Engine
Maximum supported width and height of the viewport: 16384 x 16384
OpenGL depth buffer bit: 16

/Users/damianallis/benzene_HOMO_default_0.cub
====================================================================================
Title Benzene MO=HOMO
Dimensions 87 91 65

Lattice parameters

a b c alpha beta gamma
9.39704 9.82909 7.02078 90.0000 90.0000 90.0000

Unit-cell volume = 648.469273 Å^3

Total number of polygons and unique vertices on slices;
(1 0 0): 0 ( 0), 0 ( 0)
(0 1 0): 0 ( 0), 0 ( 0)
(0 0 1): 0 ( 0), 0 ( 0)
====================================================================================

====================================================================================
Title Benzene

Lattice type P
Space group name P 1
Space group number 1
Setting number 1

Lattice parameters

a b c alpha beta gamma
1.00000 1.00000 1.00000 90.0000 90.0000 90.0000

Unit-cell volume = 1.000000 Å^3

Structure parameters

x y z Occ. B Site Sym.
1 C C1 4.65450 6.23638 3.44640 1.000 1.000 1 –
2 C C2 5.86259 5.53889 3.44640 1.000 1.000 1 –
3 C C3 5.86259 4.14389 3.44640 1.000 1.000 1 –
4 C C4 4.65450 3.44640 3.44640 1.000 1.000 1 –
5 C C5 3.44640 4.14389 3.44640 1.000 1.000 1 –
6 C C6 3.44640 5.53889 3.44640 1.000 1.000 1 –
7 H H1 4.65450 7.33599 3.44640 1.000 1.000 1 –
8 H H2 6.81488 6.08869 3.44640 1.000 1.000 1 –
9 H H3 6.81488 3.59409 3.44640 1.000 1.000 1 –
10 H H4 4.65450 2.34679 3.44640 1.000 1.000 1 –
11 H H5 2.49411 3.59409 3.44640 1.000 1.000 1 –
12 H H6 2.49411 6.08869 3.44640 1.000 1.000 1 –
====================================================================================

Number of polygons and unique vertices on isosurface = 16904 (8460)
12 atoms, 12 bonds, 0 polyhedra; CPU time = 39 ms

For the coarse grid (-2) case:

cubegen 0 MO=HOMO benzene.fchk benzene_HOMO_default_m2.cub -2 h

The output you find summarized in VESTA is below for this case.

/Users/damianallis/benzene_HOMO_default_m2.cub
====================================================================================
Title Benzene MO=HOMO
Dimensions 54 56 40

Lattice parameters

a b c alpha beta gamma
9.52518 9.87796 7.05569 90.0000 90.0000 90.0000

Unit-cell volume = 663.865482 Å^3

Total number of polygons and unique vertices on slices;
(1 0 0): 0 ( 0), 0 ( 0)
(0 1 0): 0 ( 0), 0 ( 0)
(0 0 1): 0 ( 0), 0 ( 0)
====================================================================================

====================================================================================
Title Benzene

Lattice type P
Space group name P 1
Space group number 1
Setting number 1

Lattice parameters

a b c alpha beta gamma
1.00000 1.00000 1.00000 90.0000 90.0000 90.0000

Unit-cell volume = 1.000000 Å^3

Structure parameters

x y z Occ. B Site Sym.
1 C C1 4.65450 6.23638 3.44640 1.000 1.000 1 –
2 C C2 5.86259 5.53889 3.44640 1.000 1.000 1 –
3 C C3 5.86259 4.14389 3.44640 1.000 1.000 1 –
4 C C4 4.65450 3.44640 3.44640 1.000 1.000 1 –
5 C C5 3.44640 4.14389 3.44640 1.000 1.000 1 –
6 C C6 3.44640 5.53889 3.44640 1.000 1.000 1 –
7 H H1 4.65450 7.33599 3.44640 1.000 1.000 1 –
8 H H2 6.81488 6.08869 3.44640 1.000 1.000 1 –
9 H H3 6.81488 3.59409 3.44640 1.000 1.000 1 –
10 H H4 4.65450 2.34679 3.44640 1.000 1.000 1 –
11 H H5 2.49411 3.59409 3.44640 1.000 1.000 1 –
12 H H6 2.49411 6.08869 3.44640 1.000 1.000 1 –
====================================================================================

Number of polygons and unique vertices on isosurface = 6516 (3266)
12 atoms, 12 bonds, 0 polyhedra; CPU time = 10 ms

For the medium grid (-3) case:

cubegen 0 MO=HOMO benzene.fchk benzene_HOMO_default_m3.cub -3 h

The output you find summarized in VESTA is below for this case.

/Users/damianallis/benzene_HOMO_default_m3.cub
====================================================================================
Title Benzene MO=HOMO
Dimensions 107 111 79

Lattice parameters

a b c alpha beta gamma
9.43701 9.78980 6.96751 90.0000 90.0000 90.0000

Unit-cell volume = 643.703858 Å^3

Total number of polygons and unique vertices on slices;
(1 0 0): 0 ( 0), 0 ( 0)
(0 1 0): 0 ( 0), 0 ( 0)
(0 0 1): 0 ( 0), 0 ( 0)
====================================================================================

====================================================================================
Title Benzene

Lattice type P
Space group name P 1
Space group number 1
Setting number 1

Lattice parameters

a b c alpha beta gamma
1.00000 1.00000 1.00000 90.0000 90.0000 90.0000

Unit-cell volume = 1.000000 Å^3

Structure parameters

x y z Occ. B Site Sym.
1 C C1 4.65450 6.23638 3.44640 1.000 1.000 1 –
2 C C2 5.86259 5.53889 3.44640 1.000 1.000 1 –
3 C C3 5.86259 4.14389 3.44640 1.000 1.000 1 –
4 C C4 4.65450 3.44640 3.44640 1.000 1.000 1 –
5 C C5 3.44640 4.14389 3.44640 1.000 1.000 1 –
6 C C6 3.44640 5.53889 3.44640 1.000 1.000 1 –
7 H H1 4.65450 7.33599 3.44640 1.000 1.000 1 –
8 H H2 6.81488 6.08869 3.44640 1.000 1.000 1 –
9 H H3 6.81488 3.59409 3.44640 1.000 1.000 1 –
10 H H4 4.65450 2.34679 3.44640 1.000 1.000 1 –
11 H H5 2.49411 3.59409 3.44640 1.000 1.000 1 –
12 H H6 2.49411 6.08869 3.44640 1.000 1.000 1 –
====================================================================================

Number of polygons and unique vertices on isosurface = 25532 (12774)
12 atoms, 12 bonds, 0 polyhedra; CPU time = 51 ms

For the fine grid (-4) case:

cubegen 0 MO=HOMO benzene.fchk benzene_HOMO_default_m4.cub -4 h

The output you find summarized in VESTA is below for this case.

/Users/damianallis/benzene_HOMO_default_m4.cub
====================================================================================
Title Benzene MO=HOMO
Dimensions 212 221 157

Lattice parameters

a b c alpha beta gamma
9.34876 9.74564 6.92337 90.0000 90.0000 90.0000

Unit-cell volume = 630.786281 Å^3

Total number of polygons and unique vertices on slices;
(1 0 0): 0 ( 0), 0 ( 0)
(0 1 0): 0 ( 0), 0 ( 0)
(0 0 1): 0 ( 0), 0 ( 0)
====================================================================================

====================================================================================
Title Benzene

Lattice type P
Space group name P 1
Space group number 1
Setting number 1

Lattice parameters

a b c alpha beta gamma
1.00000 1.00000 1.00000 90.0000 90.0000 90.0000

Unit-cell volume = 1.000000 Å^3

Structure parameters

x y z Occ. B Site Sym.
1 C C1 4.65450 6.23638 3.44640 1.000 1.000 1 –
2 C C2 5.86259 5.53889 3.44640 1.000 1.000 1 –
3 C C3 5.86259 4.14389 3.44640 1.000 1.000 1 –
4 C C4 4.65450 3.44640 3.44640 1.000 1.000 1 –
5 C C5 3.44640 4.14389 3.44640 1.000 1.000 1 –
6 C C6 3.44640 5.53889 3.44640 1.000 1.000 1 –
7 H H1 4.65450 7.33599 3.44640 1.000 1.000 1 –
8 H H2 6.81488 6.08869 3.44640 1.000 1.000 1 –
9 H H3 6.81488 3.59409 3.44640 1.000 1.000 1 –
10 H H4 4.65450 2.34679 3.44640 1.000 1.000 1 –
11 H H5 2.49411 3.59409 3.44640 1.000 1.000 1 –
12 H H6 2.49411 6.08869 3.44640 1.000 1.000 1 –
====================================================================================

Number of polygons and unique vertices on isosurface = 100680 (50348)
12 atoms, 12 bonds, 0 polyhedra; CPU time = 155 ms

These all generate a file containing the highest occupied molecular orbital (or one of the degenerate HOMO’s in this case. Do I have to qualify that this doesn’t mean what 99.5% of the people coming to this page thinks this means?). The box is generated by something in cubegen to be 9.3ish x 9.7ish x 6.9ish Angstroms on a side and containing X points per Angstrom (and you can change the fineness of the grid points). The image below shows the four cases for the benzene HOMO. Click to see larger versions if you want to see the influence of grid fineness on the final image.

benzene_homo_gaussian_defaults_small

Click for a larger view.

Now, then, while the boxes are almost all identical, the same molecule and input gives four slightly different results. Fine for individual images, but not ideal for the obsessive-compulsive image maker. Also, you see how a box simply bounds the molecule, meaning no standardization of size if you needed that standardization for some reason.

   a        b        c       alpha    beta     gamma
 9.39704  9.82909  7.02078  90.0000  90.0000  90.0000 < - default (0)
  9.52518  9.87796  7.05569  90.0000  90.0000  90.0000 <- coarse (-2)
  9.43701  9.78980  6.96751  90.0000  90.0000  90.0000 <- medium (-3)
  9.34876  9.74564  6.92337  90.0000  90.0000  90.0000 <- fine (-4)
 

So, for a specific case - suppose I wanted this orbital in a box exactly 15 x 20 x 25 Angstroms on a side with the molecule offset from the center by -1.0 Angstrom in each direction.

I was pleased to finally discover that cubegen allows for that, although you have to ask Gaussian Support to find out how (until now, that is) and you need to do a little bit of math to get the placement right (or use the excel file I've linked in a .zip file found at 2014june7_cubegen_excel_file.xlsx).

You begin with the following:

cubegen 0 MO=HOMO benzene.fchk benzene_HOMO.cub -1 h

But for -1, Where do the numbers go?

From the Gaussian Tech Doc:

A value of -1 says to read the cube specification from the input stream, according to the following format:

IFlag, X0, Y0, Z0 Output unit number and initial point.
N1, X1, Y1, Z1 Number of points and step-size in the X-direction.
N2, X2, Y2, Z2 Number of points and step-size in the Y-direction.
N3, X3, Y3, Z3 Number of points and step-size in the Z-direction.

IFlag is the output unit number. If IFlag is less than 0, then a formatted file will be produced; otherwise, an unformatted file will be written.

Admittedly, “input stream” made no sense to me upon first and second read. I just knew that the program didn’t do anything when I ran it. Now obvious, this means you input the cube specifications by typing in (or, better, pasting in) the 16 numbers it asks for.

Continuing…

The -1 tells cubegen to “expect more input.” In this case, without explanation first, my input would look as below:

-12  -6.50000  -9.00000 -11.50000
 60   0.25000   0.00000   0.00000
 80   0.00000   0.25000   0.00000
100   0.00000   0.00000   0.25000

Which you just paste into your terminal at the new line (having pressed ENTER after typing out the cubegen line above).

How this works (and note the use of minus signs!):

-[# Atoms] -[Start Point For Box In X] -[Start Point For Box In Y] -[Start Point For Box In Z]
[Number of Points In X]   [Grid Fineness In X]   [Grid Fineness In Y]   [Grid Fineness In Z]
[Number of Points In Y]   [Grid Fineness In X]   [Grid Fineness In Y]   [Grid Fineness In Z]
[Number of Points In Y]   [Grid Fineness In X]   [Grid Fineness In Y]   [Grid Fineness In Z]

Assuming orthogonality in your box, the off-diagonals for the grid fineness matrix are zero.

-[# Atoms] -[Start Point For Box In X] -[Start Point For Box In Y] -[Start Point For Box In Z]
[Number of Points In X]  [Grid Fineness In X]   0.000   0.000
[Number of Points In Y]  0.000   [Grid Fineness In Y]   0.000
[Number of Points In Y]  0.000   0.000   [Grid Fineness In Z]

4. -6.5, -9, -11.5?

You build the box around your molecule in cubegen, which means you combine (1) where you want the molecule positions with (2) the number of grid points along each direction and (3) the fineness of the grid to generate the box. Here, I’m starting my hypothetical box at -6.5 in X, -9 in Y, and -11.5 in Z, then building out my molecule 121*.25 points in X, 161*.25 in Y, 201*.25 in Z. This will produce the intended box size with the molecule technically centered at the origin in the box (0,0,0), but the generation of all 121, 161, and 201 points in X, Y, and Z will result in the box going from -6.5 to 8.5, -9 to 11, and -11.5 to 13.5 (and there’s your asymmetry in the box). Alternatively, you could think of it as generating a box 15 x 20 x 25, then placing the center of the molecule at 6.5, 9, 11.5 (but you don’t specify the box size directly, instead relying on the relative position of the molecule and the fineness of the grid to determine the position (from which you could work back to get the number of points you needed in each direction if you knew the size of the box you wanted. Yes, you might have to re-read that a few times).

I demonstrate this below for a benzene orbital “walk” along X using direct output from VESTA. The rest of the numbers in my matrix above are the same except for the “-[Start Point For The Box In X]” value.

benzene_homo_walk

The benzene walk (numbers show the spacing based on the cubegen input above).

5. Formula For Boxes And Grid Points

You can, in fact, work from the box size you want and relative position of the molecule in that box with some simple math. That looks like the table below:

-(# Atoms)           -(X Position)  -(Y Position)  -(Z Position)
(Box Size / X Mesh)    X Mesh         0.00000        0.00000
(Box Size / Y Mesh)    0.00000        Y Mesh         0.00000
(Box Size / Z Mesh)    0.00000        0.00000        Z Mesh

You specify # Atoms, X Position, Y Position, Z Position, X Mesh, Y Mesh and Z Mesh, then decide on how big your box is going to be. Also, note that X Position, Y Position, Z Position all need to be 1/2 the size of your box if you want the molecule centered. A way to help force this is to force the molecule to have its center of mass shifted to the origin using Symm=COM in your input file.

As mentioned above, a simple excel file for performing this task is provided for download at 2014june7_cubegen_excel_file.xlsx.

6. Lastly, A Procedure For Scripting The Generation Of Many Orbitals

That first stone passed, everything about making custom .cub/.cube files finally made sense. But it lead to another problem. Suppose I want to generate many molecular orbitals. Does one have to paste in the IFlag…Z3 block each time?

Thankfully, this process can be scripted to automation as well, although it’s not just a matter of pasting IFlag…Z3 below each run of cubegen. Doing that produces the following…

Example:

This isn’t a cubegen problem, it’s a Linux issue with the interpretation of stdin. The cubegen script needs to be fed in the matrix in a file (say cubegen.dat if you always want the same .cub/.cube file generated) or via the use of an EOF call.

Cubegen.dat:

cubegen 0 MO=1 benzene.fchk benzene_MO1.cub -1 h < cubegen.dat
 cubegen 0 MO=2 benzene.fchk benzene_MO2.cub -1 h < cubegen.dat
 cubegen 0 MO=3 benzene.fchk benzene_MO3.cub -1 h < cubegen.dat
 ...
 

EOF

cubegen 0 MO=1 benzene.fchk benzene_MO1.cub -1 h << EOF
-12  -6.50000  -9.00000 -11.50000
 60   0.25000   0.00000   0.00000
 80   0.00000   0.25000   0.00000
100   0.00000   0.00000   0.25000
EOF
cubegen 0 MO=2 benzene.fchk benzene_MO2.cub -1 h << EOF
-12  -6.50000  -9.00000 -11.50000
 60   0.25000   0.00000   0.00000
 80   0.00000   0.25000   0.00000
100   0.00000   0.00000   0.25000
EOF
cubegen 0 MO=3 benzene.fchk benzene_MO3.cub -1 h << EOF
-12  -6.50000  -9.00000 -11.50000
 60   0.25000   0.00000   0.00000
 80   0.00000   0.25000   0.00000
100   0.00000   0.00000   0.25000
EOF
...

7. What’s The Deal With The Benzene Cation?

Nothing, except I saw a question in my perusing of cubegen problems and found one related to UHF wavefunctions. How do you render alpha spin orbitals and beta spin orbitals? The answer is you dig into the .log file for the orbital energies and count (to the best of my knowledge).

Benzene (21 alpha/beta-occupied)

 Alpha  occ. eigenvalues -- -10.18955 -10.18928 -10.18928 -10.18872 -10.18872
 Alpha  occ. eigenvalues -- -10.18845  -0.84761  -0.73971  -0.73971  -0.59595
 Alpha  occ. eigenvalues --  -0.59595  -0.51588  -0.45423  -0.43943  -0.41518
 Alpha  occ. eigenvalues --  -0.41518  -0.36090  -0.33862  -0.33862  -0.24750
 Alpha  occ. eigenvalues --  -0.24750
 Alpha virt. eigenvalues --   0.00266   0.00266   0.08636   0.14126   0.14126
 Alpha virt. eigenvalues --   0.16238   0.17957   0.17957   0.18681   0.29989
 Alpha virt. eigenvalues --   0.29989   0.31908   0.31908   0.46637   0.52628
 Alpha virt. eigenvalues --   0.54782   0.55099   0.56222   0.59294   0.60077
 Alpha virt. eigenvalues --   0.60077   0.60084   0.60084   0.62384   0.62384
 Alpha virt. eigenvalues --   0.66653   0.66653   0.74180   0.81178   0.81178
 Alpha virt. eigenvalues --   0.82134   0.83694   0.83694   0.91676   0.93745
 Alpha virt. eigenvalues --   0.93745   0.95812   1.08054   1.08054   1.12992
 Alpha virt. eigenvalues --   1.12992   1.20098   1.26111   1.30051   1.40786
 Alpha virt. eigenvalues --   1.40786   1.42585   1.42585   1.42914   1.42914
 Alpha virt. eigenvalues --   1.74102   1.76078   1.80542   1.87583   1.90680
 Alpha virt. eigenvalues --   1.90680   1.97195   1.97195   1.97924   1.97924
 Alpha virt. eigenvalues --   2.02762   2.07664   2.07664   2.29609   2.29609
 Alpha virt. eigenvalues --   2.34429   2.34429   2.35491   2.39944   2.40328
 Alpha virt. eigenvalues --   2.40328   2.44636   2.44636   2.48731   2.48731
 Alpha virt. eigenvalues --   2.50802   2.58538   2.58538   2.60300   2.65987
 Alpha virt. eigenvalues --   2.75521   2.80103   2.80103   3.03123   3.03123
 Alpha virt. eigenvalues --   3.18490   3.20485   3.21867   3.21867   3.37166
 Alpha virt. eigenvalues --   3.48298   3.48298   3.93339   4.13215   4.16289
 Alpha virt. eigenvalues --   4.16289   4.43754   4.43754   4.82384

RHF wave functions are easy as the alpha and beta spin orbitals are identical (so you just call one).

Benzene Cation (21 alpha occ, 20 beta occ)

 Alpha  occ. eigenvalues --  -10.44746 -10.44745 -10.44690 -10.44689 -10.41307
 Alpha  occ. eigenvalues --  -10.41306  -1.09893  -0.99649  -0.97270  -0.83278
 Alpha  occ. eigenvalues --   -0.83268  -0.74423  -0.68358  -0.67574  -0.65278
 Alpha  occ. eigenvalues --   -0.63494  -0.61047  -0.56837  -0.56618  -0.51141
 Alpha  occ. eigenvalues --   -0.47878
 Alpha virt. eigenvalues --   -0.25225  -0.22671  -0.10624  -0.07758  -0.05310
 Alpha virt. eigenvalues --   -0.04280  -0.01821  -0.00871   0.00401   0.08260
 Alpha virt. eigenvalues --    0.08579   0.09642   0.10056   0.25206   0.29439
 Alpha virt. eigenvalues --    0.31399   0.31852   0.34121   0.36475   0.36906
 Alpha virt. eigenvalues --    0.37451   0.38343   0.38500   0.39459   0.40284
 Alpha virt. eigenvalues --    0.43576   0.45334   0.52549   0.60260   0.60770
 Alpha virt. eigenvalues --    0.61287   0.62929   0.64337   0.70989   0.71650
 Alpha virt. eigenvalues --    0.71731   0.74333   0.85713   0.86949   0.90112
 Alpha virt. eigenvalues --    0.90952   0.98816   1.00856   1.05831   1.15646
 Alpha virt. eigenvalues --    1.17792   1.17972   1.18789   1.20601   1.20854
 Alpha virt. eigenvalues --    1.49713   1.52475   1.57000   1.65756   1.66784
 Alpha virt. eigenvalues --    1.68337   1.73545   1.74011   1.74167   1.74723
 Alpha virt. eigenvalues --    1.80258   1.82880   1.84586   2.04024   2.06015
 Alpha virt. eigenvalues --    2.12117   2.12667   2.14025   2.17682   2.18940
 Alpha virt. eigenvalues --    2.19096   2.22084   2.22451   2.24748   2.25480
 Alpha virt. eigenvalues --    2.28544   2.35165   2.36888   2.39005   2.41062
 Alpha virt. eigenvalues --    2.52629   2.57091   2.57724   2.79730   2.80863
 Alpha virt. eigenvalues --    2.95189   2.99029   2.99731   3.01110   3.14403
 Alpha virt. eigenvalues --    3.25310   3.26537   3.70063   3.88553   3.90763
 Alpha virt. eigenvalues --    3.92953   4.18629   4.20462   4.58339
  Beta  occ. eigenvalues --  -10.44304 -10.44303 -10.44252 -10.44250 -10.41463
  Beta  occ. eigenvalues --  -10.41462  -1.08758  -0.97673  -0.97028  -0.82708
  Beta  occ. eigenvalues --   -0.82377  -0.74165  -0.67883  -0.67164  -0.64793
  Beta  occ. eigenvalues --   -0.63478  -0.57727  -0.56637  -0.56323  -0.47270
  Beta virt. eigenvalues --   -0.41639  -0.21435  -0.21139  -0.10438  -0.05496
  Beta virt. eigenvalues --   -0.05056  -0.04232  -0.01054  -0.00739   0.00754
  Beta virt. eigenvalues --    0.08748   0.08784   0.10027   0.10356   0.25410
  Beta virt. eigenvalues --    0.30875   0.31655   0.33033   0.34430   0.37599
  Beta virt. eigenvalues --    0.38243   0.38423   0.38827   0.38857   0.40471
  Beta virt. eigenvalues --    0.40510   0.45633   0.45687   0.53548   0.60543
  Beta virt. eigenvalues --    0.61003   0.61366   0.63303   0.64325   0.71163
  Beta virt. eigenvalues --    0.71910   0.72371   0.74501   0.86611   0.87153
  Beta virt. eigenvalues --    0.90721   0.90982   0.99163   1.02443   1.07028
  Beta virt. eigenvalues --    1.17547   1.18130   1.19642   1.19672   1.20955
  Beta virt. eigenvalues --    1.21374   1.51458   1.52709   1.57335   1.66396
  Beta virt. eigenvalues --    1.67580   1.68460   1.73895   1.74747   1.75260
  Beta virt. eigenvalues --    1.75568   1.80924   1.84865   1.84936   2.06229
  Beta virt. eigenvalues --    2.06582   2.12479   2.12665   2.14334   2.18350
  Beta virt. eigenvalues --    2.18883   2.19283   2.22289   2.22978   2.25783
  Beta virt. eigenvalues --    2.25938   2.29233   2.36212   2.37068   2.39062
  Beta virt. eigenvalues --    2.42549   2.53376   2.57824   2.57840   2.79980
  Beta virt. eigenvalues --    2.80952   2.95964   2.99101   2.99875   3.01115
  Beta virt. eigenvalues --    3.14561   3.25632   3.26592   3.70353   3.89317
  Beta virt. eigenvalues --    3.92008   3.93146   4.19813   4.20623   4.58989

In the case of UHF wave functions, you specify alpha or beta using AMO= or BMO= when you run cubegen.

Obligatory

  • CNYO

  • Sol. Sys. Amb.

  • Ubuntu 4 Nano

  • NMT Review

  • N-Fact. Collab.

  • Pres. Asn. CNY

  • T R P Nanosys

  • Nano Gallery

  • nano gallery
  • Aerial Photos

    More @ flickr.com

    Syracuse Scenes

    More @ flickr.com