# Compilation and execution

Please note that these instructions are for compilation and direct execution of the CAC simulator. To run CAC simulations using the GUI, please see the section titled: Graphical user interface

### MPI

The PyCAC code is fully parallelized with Message Passing Interface (MPI). Some functions in MPI-3 standard are employed. It works with Open MPI version 2.1, Intel MPI version 5.1, MPICH version 3.3, and MVAPICH2 version 2.3.

### Fortran compiler

Some intrinsic functions in Fortran 2008 is employed in the code, so compilers that fully support Fortran 2008 are preferred. For example, GNU Fortran version 7.0 and Intel Fortran version 17.0 work with the PyCAC code.

To compile the code, simply run the install.sh file in the PyCAC code package, i.e.,

./install.sh


Note that the compilation process has not been tested on Microsoft Windows. On macOS, a message

/opt/local/bin/ranlib: file: libcac.a(constant_para_module.o) has no symbols


may occur. The users are suggested to compile and run the PyCAC code on Linux, which dominates the high performance computing systems.

### Compilation

#### Module

In compilation, the first step is to create a static library libcac.a from the 56 module files *_module.f90 in the module directory. There are five types of module files:

*_comm_module.f90


There is only one *_comm_module.f90 file: precision_comm_module.f90. It controls the precision of the integer and real numbers.

*_para_module.f90


There are 25 *_para_module.f90 files. They define single value variables that may be used globally.

*_array_module.f90


There are 24 *_array_module.f90 files. They define arrays that may be used globally. With a few exceptions, the *_para_module.f90 and *_array_module.f90 files come in pairs.

*_function_module.f90


There are 5 *_function_module.f90 files. They define interatomic potential formulations, arithmetic/linear algebra calculations, unit conversion, etc.

*_tab_module.f90


There is only one *_tab_module.f90 file: eam_tab_module.f90. It contains algorithms that extract the EAM potential-based values from numerical tables.

Note that these module files should be compiled in this order (see that the install.sh file) in creating the static library libcac.a. Otherwise, an error may occur.

#### Subroutine

Then, an executable, named CAC, is compiled using one main program (main.f90) plus 175 subroutines (*.f90) in the src directory and linked with the static library libcac.a.

### Execution

In execution, the executable CAC, the input file cac.in, and the potential files are moved into the same directory. It follows that

mpirun -np num_of_proc ./CAC < cac.in


where positive integer num_of_proc is the number of processors to be used. As an example, see the run.sh file in the PyCAC code package.