GAMESS をビルドする (OpenBLAS 編)

ふと思い立って GAMESS をビルドして遊んだので記録を残そうと思います。基本的には GAMESS Installation Instructions for Linux に従いつつ、ビルドがコケたところを修正してまとめました。

参考 → mkl 編

環境

OS : Ubuntu 18.04 64bit
gcc : version 7.3.0
GAMESS : Feb 14, 2018 R1 Public Release
BLAS : OpenBlas v0.3.3

必要なソフトウェアをインストール

まず、ビルドのために fortran コンパイラと csh が必要なのでインストールします。

sudo apt-get install gfortran csh

c コンパイラも必要だったと思うので、gcc がインストールされていない場合はしましょう。gcc -v と打ってバージョン情報が出力されなければする必要があります。

sudo apt-get install build-essential

OpenBLAS のビルド

今回は OpenBLAS をビルドして使いました。v0.3.3 を使っていますが、新しいリリースがあればそっちを使うといいでしょう。試していませんが、apt-get でもインストールできるらしいです。面倒ならこっちでもいいとおもいます。

GAMESS にリンクして使う場合に限っていえば、スレッディング機能は無効にしたほうが無難だと思います。スレッディングを有効にしてビルドした場合でも環境変数で無効にできるので好きな方を選びましょう。

git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
git checkout v0.3.3
make USE_THREAD=0
sudo make install PREFIX=/opt/OpenBLAS_NO_THREAD

GAMESS のビルド

GAMESS のソースファイル gamess-current.tar.gz は自分で入手しましょう。gamess-current.tar.gz~/Downloads にあり、ビルドは ~/gamess で行うものとしますが、違ったら適当に読み替えてください。

下の `whoami` はあなたのユーザーネームに置き換えてください。

cd ~/
tar xvf ~/Downloads/gamess-current.tar.gz
chown -R `whoami` gamess
chmod g-s gamess

OpenBLAS は公式にはサポートされていないので、configure の前に以下のどちらかのパッチを当てます。ここ を参考にして新しめの GAMESS に適用できるようにしました。

patch < ~/gamess_2018R1_openblas.diff
rm gamess_2018R1_openblas.diff

ここから対話的(!)な configure が始まります。

cd gamess
./config

This script asks a few questions, depending on your computer system, to set up compiler names, libraries, message passing libraries, and so forth.

You can quit at any time by pressing control-C, and then .

Please open a second window by logging into your target machine, in case this script asks you to 'type' a command to learn something about your system software situation. All such extra questions will use the word 'type' to indicate it is a command for the other window.

After the new window is open, please hit to go on.

<Enter> キーを押します。

GAMESS can compile on the following 32 bit or 64 bit machines:
axp64 - Alpha chip, native compiler, running Tru64 or Linux
cray-xt - Cray's massively parallel system, running CNL
cray-xc - Cray's XC40, with KNL nodes
hpux32 - HP PA-RISC chips (old models only), running HP-UX
hpux64 - HP Intel or PA-RISC chips, running HP-UX
ibm32 - IBM (old models only), running AIX
ibm64 - IBM, Power3 chip or newer, running AIX or Linux
ibm64-sp - IBM SP parallel system, running AIX
ibm-bg - IBM Blue Gene (Q model), these are 64 bit systems
linux32 - Linux (any 32 bit distribution), for x86 (old systems only)
linux64 - Linux (any 64 bit distribution), for x86_64 or ia64 chips,
using gfortran, ifort, or perhaps PGI compilers.
mac32 - Apple Mac, any chip, running OS X 10.4 or older
mac64 - Apple Mac, any chip, running OS X 10.5 or newer
sgi32 - Silicon Graphics Inc., MIPS chip only, running Irix
sgi64 - Silicon Graphics Inc., MIPS chip only, running Irix
sun32 - Sun ultraSPARC chips (old models only), running Solaris
sun64 - Sun ultraSPARC or Opteron chips, running Solaris
win32 - Windows 32-bit (Windows XP, Vista, 7, Compute Cluster, HPC Edition)
win64 - Windows 64-bit (Windows XP, Vista, 7, Compute Cluster, HPC Edition)
winazure - Windows Azure Cloud Platform running Windows 64-bit
type 'uname -a' to partially clarify your computer's flavor.
please enter your target machine name:

linux64 を入力して <Enter> を押します。

Where is the GAMESS software on your system?
A typical response might be /u1/mike/gamess,
most probably the correct answer is /opt/gamess

GAMESS directory? [/opt/gamess]

<Enter> キーを押します。

Please provide the name of the build locaation.
This may be the same location as the GAMESS directory.

GAMESS build directory? [/opt/gamess]

<Enter> キーを押します。

Please provide a version number for the GAMESS executable.
This will be used as the middle part of the binary's name,
for example: gamess.00.x

Version? [00]

<Enter> キーを押します。

Linux offers many choices for FORTRAN compilers, including the GNU
compiler suite's free compiler 'gfortran', usually included in
any Linux distribution. If gfortran is not installed, it can be
installed from your distribution media.

To check on installed GNU compilers, for RedHat/SUSE style Linux,
type 'rpm -aq | grep gcc' for both languages,
and for Debian/Ubuntu style Linux, it takes two commands
type 'dpkg -l | grep gcc'
type 'dpkg -l | grep gfortran'

There are also commercial compilers, namely Intel's 'ifort', and
Portland Group's 'pgfortran', and Pathscale's 'pathf90'.
The last two are not common, and aren't as well tested.

type 'which gfortran' to look for GNU's gfortran (a good choice),
type 'which ifort' to look for Intel's compiler (a good choice),
type 'which pgfortran' to look for Portland Group's compiler,
type 'which pathf90' to look for Pathscale's compiler.
Please enter your choice of FORTRAN:

gfortran と入力し、<Enter> キーを押します。

gfortran is very robust, so this is a wise choice.

Please type 'gfortran -dumpversion' or else 'gfortran -v' to
detect the version number of your gfortran.
This reply should be a string with at least two decimal points,
such as 4.1.2 or 4.6.1, or maybe even hyphens like 4.4.2-12.
The reply may be labeled as a 'gcc' version,
but it is really your gfortran version.

Please enter only the first decimal place, such as 4.6 or 4.8:

gfortran のバージョンを入力するところです。現在 (Sep. 2018) apt で降ってくる gfortran のバージョンは 7.3 だと思うのですが、残念ながら素直に 7.3 と入力するとエラーになります。その場合は、7.2 と入力して <Enter> しましょう。たぶん大丈夫です。GAMESS がアップデートされたらこの問題もなくなると思います。

hit to continue to the math library setup.

<Enter> キーを押します。

Linux distributions do not include a standard math library.

There are several reasonable add-on library choices,
MKL from Intel for 32 or 64 bit Linux (very fast)
ACML from AMD for 32 or 64 bit Linux (free)
ATLAS from www.rpmfind.net for 32 or 64 bit Linux (free)
PGI BLAS from Portland Group for 32 or 64 bit Linux
and one very unreasonable option, namely 'none', which will use
some slow FORTRAN routines supplied with GAMESS. Choosing 'none'
will run MP2 jobs 2x slower, or CCSD(T) jobs 5x slower.

Some typical places (but not the only ones) to find math libraries are
Type 'ls /opt/intel/mkl' to look for MKL
Type 'ls /opt/intel/Compiler/mkl' to look for MKL
Type 'ls /opt/intel/composerxe/mkl' to look for MKL
Type 'echo '$MKLROOT'"' to look for MKL"
Type 'ls -d /opt/acml' to look for ACML
Type 'ls -d /usr/local/acml
' to look for ACML
Type 'ls /usr/lib64/atlas' to look for Atlas
Type 'ls /opt/pgi/linux86-64//lib/ to look for libblas.a from PGI
Type 'ls /opt/pgi/osx86-64//lib/ to look for libblas.a from PGI

Enter your choice of 'mkl' or 'atlas' or 'acml' or 'pgiblas' or 'openblas' or 'none':

openblas と入力して <Enter> を押します。

Enter full path to OpenBLAS libraries (without 'lib' subdirectory):

/opt/OpenBLAS_NO_THREAD と入力し <Enter> を押します。

please hit to compile the GAMESS source code activator

<Enter> を押します。

please hit to set up your network for Linux clusters.

<Enter> を押します。

If you have a slow network, like Gigabit Ethernet (GE), or
if you have so few nodes you won't run extensively in parallel, or
if you have no MPI library installed, or
if you want a fail-safe compile/link and easy execution,
choose 'sockets'
to use good old reliable standard TCP/IP networking.

If you have an expensive but fast network like Infiniband (IB), and
if you have an MPI library correctly installed,
choose 'mpi'.

communication library ('sockets' or 'mpi')?

sockets と入力し <Enter> を押します。

64 bit Linux builds can attach a special LIBCCHEM code for fast
MP2 and CCSD(T) runs. The LIBCCHEM code can utilize nVIDIA GPUs,
through the CUDA libraries, if GPUs are available.
Usage of LIBCCHEM requires installation of HDF5 I/O software as well.
GAMESS+LIBCCHEM binaries are unable to run most of GAMESS computations,
and are a bit harder to create due to the additional CUDA/HDF5 software.
Therefore, the first time you run 'config', the best answer is 'no'!
If you decide to try LIBCCHEM later, just run this 'config' again.

Do you want to try LIBCCHEM? (yes/no):

no と入力して <Enter> を押します。これで configure の終了です。

GAMESS 独自の分散コンピューティング用ライブラリ (?) ddi をビルドします。

cd ddi
./compddi >& compddi.log
mv ddikick.x ..
cd ..

うまく行っていれば、compddi.log の最後の方に "DDI compilation ended successfully." という文があると思います。

いよいよ GAMESS をビルド (&リンク) します。少し時間がかかると思います。

./compall >& compall.log
./lked >& lked.log

最後に rungms スクリプトを編集します。63行目あたりに以下のような箇所があるので、

set TARGET=sockets
set SCR=/scr/$USER
set USERSCR=/u1/$USER/scr
set GMSPATH=/u1/mike/gamess

次のように編集します。

set TARGET=sockets
set SCR=/tmp
set USERSCR=/tmp
set GMSPATH=$HOME/gamess

SCR および、USERSCR は計算のための一時ファイルを置く場所らしいです。編集する行の上のコメントに簡単な説明があります。好きに決めて問題ないと思います。(/tmp はちょっと乱暴かもしれない…)

GMSPATH はビルドした gamess.00.x があるパスなので、ひとまずテストのために $HOME/gamess にします。

GAMESS のテスト

ビルドした GAMESS をテストします。

./runall 00

00 は GAMESS のバイナリを指定するための引数で gamess.00.x を使うという意味です。省略したら 00 になると思います。テストが終わったら、exam01.log から exam47.log までの47のファイルが出力されます。確認するためには

tests/standard/checktst

を実行して All 47 test results are correct! と表示されれば OK です!異常終了しているファイルがあれば内容をよく確認しましょう。

GAMESS のインストール

インストール先は /opt/gamess とします。GAMESS は Filesystem Hierarchy Standard に従っているソフトウェアではないようなので /usr/local 以下は適当なインストール先ではなさそうです。

まず、rungms ファイルを編集して GMSPATH を再度変更します。

set GMSPATH=/opt/gamess

ディレクトリごと移動して所有者を変更して終わりです。

cd ~/
sudo mv gamess /opt
cd /opt
chown -R root:root gamess

おまけ

.bashrc あたりで alias とか作ったら使いやすいと思います。

alias rungms=/opt/gamess/rungms

さらにキャッシュをクリアしてから実行してくれるようなスクリプト~/.local/bin/ に置いて使っています。

alias gamess=~/.local/bin/gamess.sh