Basic installation 基本安装

General 总则

Dalton is configured using CMake, typically via the setup script, and subsequently compiled using make or gmake. The setup script is a useful front-end to CMake. You need Python to run setup.
Dalton 通过 CMake 进行配置,通常使用 setup 脚本,然后使用 make 或 gmake 进行编译。 setup 脚本是 CMake 的一个便捷前端。运行 setup 需要 Python。

Basics 基础知识 ¶

To see all options, run:
要查看所有选项,请运行:

$ ./setup --help

The setup script does nothing else than creating the directory “build” and calling CMake with appropriate environment variables and flags. In a typical installation we first configure with setup and then compile with make:
setup 脚本仅执行创建“build”目录并使用适当的环境变量和标志调用 CMake 的操作。在典型的安装过程中,我们首先使用 setup 进行配置,然后使用 make 进行编译:

$ ./setup [--flags]
$ cd build
$ make

By default CMake builds out of source. This means that all object files and the final binary are generated outside of the source directory. Typically the build directory is called “build”, but you can change the name of the build directory (e.g. “build_gfortran”):
默认情况下,CMake 进行外部构建。这意味着所有对象文件和最终二进制文件都在源目录之外生成。通常,构建目录被称为“build”,但您可以更改构建目录的名称(例如“build_gfortran”):

$ ./setup [--flags] build_gfortran
$ cd build_gfortran
$ make

You can compile the code using all available several cores:
您可以使用所有可用的多个核心来编译代码:

$ make -j

Typical examples 典型示例

In order to get familiar with the configuration setup, let us demonstrate some typical configuration scenarios.
为了熟悉配置设置,让我们演示一些典型的配置场景。

Configure for parallel compilation using MPI (make sure to properly export MPI paths):
配置并行编译使用 MPI(确保正确导出 MPI 路径):

$ ./setup --fc=mpif90 --cc=mpicc --cxx=mpicxx

There is a shortcut for it:
有一个捷径:

$ ./setup --mpi

Configure for parallel compilation using Intel MPI:
配置使用 Intel MPI 进行并行编译:

$ ./setup --fc=mpiifort --cc=mpiicc --cxx=mpiicpc

Configure for sequential compilation using ifort/icc/icpc and link against parallel mkl:
配置使用 ifort/icc/icpc 进行顺序编译,并链接至并行 MKL 库:

$ ./setup --fc=ifort --cc=icc --cxx=icpc --mkl=parallel

Configure for sequential compilation using gfortran/gcc/g++:
配置使用 gfortran/gcc/g++进行顺序编译:

$ ./setup --fc=gfortran --cc=gcc --cxx=g++

Parallel compilation on a Cray:
Cray 上的并行编译:

./setup --fc=ftn --cc=cc --cxx=CC --cray --mpi

Parallel compilation on a SGI using Intel compilers and MPT:
在 SGI 上使用 Intel 编译器和 MPT 进行并行编译:

./setup --fc=ifort --cc=icc --cxx=icpc --sgi-mpt

You get the idea. The configuration is usually good at detecting math libraries automatically, provided you export the proper environment variable MATH_ROOT, see Linking to math libraries.
你明白了吧。只要正确导出环境变量 MATH_ROOT ,配置通常能自动检测到数学库,详见《链接至数学库》。

What to do if CMake is not available or too old?
如果 CMake 不可用或版本过旧,该怎么办?¶

If it is your machine and you have an Ubuntu or Debian-based distribution:
如果是您的机器并且您使用的是基于 Ubuntu 或 Debian 的发行版:

$ sudo apt-get install cmake

On Fedora: 在 Fedora 上:

$ sudo yum install cmake

Similar mechanisms exist for other distributions or operating systems. Please consult Google.
其他发行版或操作系统也存在类似的机制。请咨询谷歌。

If it is a cluster, please ask the Administrator to install/upgrade CMake.
如果是集群,请要求管理员安装/升级 CMake。

If it is a cluster, but you prefer to install it yourself (it is easy):
如果是集群,但您更愿意自行安装(这很简单):

  1. Download the latest pre-compiled tarball from http://www.cmake.org/download/
    从 http://www.cmake.org/download/下载最新的预编译 tarball。
  2. Extract the downloaded tarball
    解压下载的压缩包
  3. Set the correct PATH variable
    设置正确的 PATH 变量