\documentclass[12pt]{article}
%\usepackage{latex2html}
\usepackage{enumerate}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{color}
\parindent=0pt
\parskip=12pt
\textheight=24cm
\textwidth=18cm
\topmargin=-2.5cm
\oddsidemargin=-0.5cm
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\begin{document}
\sloppy

\title{UNRES.3.2.1 -- INSTALLATION GUIDE}

\author{Dawid Jagie{\l}a, Adam Liwo\\ Laboratory of Molecular Modeling\\ Faculty of Chemistry\\ University of Gdansk\\ Wita Stwosza 63\\ 80-308 Gdansk, Poland}

\maketitle

\newpage

\tableofcontents

\newpage

\section{Putting the package on your system}
\label{section:put}

The distribution is contained in the unrespack-v.3.2.1.tar.gz file. To put the package
on your system, copy the archive to your UNRES directory (you might want to create
an environmental variable, \$UNRESROOT  or so, to define the location of UNRES on
your system) and  say:

\begin{verbatim}
gzip -cd unrespack-v.3.2.1.tar.gz | tar xf -
\end{verbatim}

This will produce the directory structure shown in Figure \ref{fig:distr}.

\begin{figure}
{\small
\begin{verbatim}
$UNRESROOT
    |
    |---------doc   (documentation)
    |
    |---------PARAM (force field parameters)
    |
    |---------source
    |           |
    |           |-----unres (UNRES source codes; various versions)
    |           |       |
    |           |       |---src_MIN (only energy evaluation and minimization)
    |           |       |---src_CSA (all functions except MD, includes CSA)
    |           |       |---src_MD  (all functions except CSA, includes MD, single chains)
    |           |       |---src_MD-M (all functions except CSA, includes MD, oligomeric proteins)
    |           |-----wham (weighted analysis method source codes)
    |           |       |
    |           |       |---src (single chains)
    |           |       |---src-M (oligomeric proteins)
    |           |
    |           |-----cluster (cluster analysis source coded)
    |           |       |
    |           |       |---clust-unres
    |           |       |         |
    |           |       |         |----src    (input data from UNRES)
    |           |       |
    |           |       |---clust-wham        (input data from WHAM)
    |           |                 |
    |           |                 |----src    (for single-chain proteins)
    |           |                 |----src-M  (for oligomeric proteins)
    |           |
    |           |-----xdrfpdb (file format conversion source codes)
    |                   |
    |                   |---src     (single chains)
    |                   |---src-M   (oligomers)
    |
    |----------bin (C-shell script, batch scripts, and pre-compiled binaries)
    |           |
    |           |-----unres
    |           |       |
    |           |       |---CSA
    |           |       |---MD
    |           |       |---MINIM
    |           |-----wham
    |           |-----cluster
    |           |-----xdrfpdb
    |
    |--------examples
                |
                |-----unres
                |-----wham
                |-----cluster
\end{verbatim}
}
\caption{Directory structure of the unres-3.2.1 package}
\label{fig:distr}
\end{figure}

\section{Installation options}
\label{sect:general}

The most convenient way to install the package is using Cmake, as described 
in section 2. If your system does not run the required version of Cmake or
installation does not work, do step-by-step compilation of the components
of the package, as described in section 3.

\subsection{Requirements}

\begin{description}
\item{--} C compiler
\item{--} Fortran compiler (must understant the Fortran 77 instructions)
\item{--} MPI (for CSA and MREMD)
\end{description}

\section{Installation using Cmake}
\label{section:Cmake}

\subsection{Requirements}

\begin{description}
\item{--} CMake 2.8.0 or later
\item{--} C compiler 
\item{--} Fortran compiler
\item{--} MPI (for CSA and MREMD)
\end{description}

\subsection{Basic installation}

These instructions give a very basic overview of how to configure, compile and
install UNRESPACK on most systems.  If you are using unique install locations
and/or libraries that are not automatically detected please consult the 'Advanced'
section.

\begin{enumerate}

\item
Create a 'build' directory in the package source directory.

\begin{verbatim}
   mkdir build
   cd build
\end{verbatim}

\item
Configure the build system

\begin{verbatim}
   cmake ..
\end{verbatim}

\item
Compile

\begin{verbatim}
   make 
\end{verbatim}

\item
Install

\begin{verbatim}
   sudo make install
\end{verbatim}

\noindent or 

\begin{verbatim}
   make install
\end{verbatim}

\end{enumerate}

\subsection{Advanced installation}

The build system (CMake) provides mechanisms for specifying non-standard
build parameters.

\begin{enumerate}

\item
\underline{Compilers \& installation}
   
\begin{verbatim}
   -DCMAKE_Fortran_COMPILER=xxx equal to name of Fortran Compiler you wish to use 
     (ifort, gfortran)

   -DCMAKE_INSTALL_PREFIX=xxx specify the binaries installation prefix
                            (default UNRESPACK_source_dir/bin)
\end{verbatim}

\item
\underline{Force fields}

\begin{verbatim}
   -DUNRES_MD_FF=xxx  compiles the MD versions with given force field. 
     Options are: GAB, E0LL2Y. Default: GAB

   -DUNRES_CSA_FF=xxx compiles the CSA versions with given force field
     Options are: CASP3, ALPHA, BETA, ALPHABETA, CASP5, 3P, 4P. Default: 4P.
\end{verbatim}

Please read the online documentation on force fields available at 
 http://unres.eu/unres\#SECTION00090000000000000000
  

\item
\underline{MPI}

MPI implementation on your system should be automatically detected ("MPI Found" 
message after runing cmake). If not you have two options:

\begin{enumerate}

\item
Try setting the path to you MPI wrapper implementation

\begin{verbatim}
   -DMPI_Fortran_COMPILER=xxx MPI wrapper
\end{verbatim}

\item
If option 1 fails or your MPI implementation does not come with a compiler wrapper 
   try setting both the MPI include and library paths manually. This will circumvent
   autodetection entirely. 

\begin{verbatim}
   -DMPI_Fortran_INCLUDE_PATH=xxx
   -DMPI_Fortran_LIBRARY="xxx"
\end{verbatim}

\end{enumerate}
\end{enumerate}

\section{Step-by-step installation}
\label{sect:stepbystep}

For this installation, you will need to visit each source directory (see doc/UNRESPACK.txt
for directory structure). Specific installation instructions are in the documentation of 
of the particular components of the package (UNRES, WHAM, CLUSTER, XDRFPDB). Only general
instructions are given here.

\begin{enumerate}

\item
Go to the respective source directory.

\item
Determine if any of the Makefiles present there matches your needs. The Makefiles for
Intel Fortran and Gnu Fortran are present everywhere and are guaranteed to work (provided
that your compiler/MPI installation is correct). Use this Makefile as the working Makefile

If your system uses a different compiler, copy the most matching Makefile to your working
Makefile (e.g., to Makefile\_CRAY if you'll be working with Cray Fortran).

\item
Make a symbolic link of the working Makefile to Makefile, e.g.,

\begin{verbatim}
ln -s Makefile_gfortran Makefile
\end{verbatim}

Before that, you'll need to remove the existing symbolic link (in the distribution, it
points to Makefile\_ifort). 

\item
Edit the Makefile to define MPI location, libraries, and the binaries directory
and executalble names, if you want to use different location/names from those in the
distribution Makefiles. The present locations are the subdirectories of the bin 
directory and executable names include package component, compiler, MPI information,
and force field, e.g. unres\_csa\_gfort\_MPICH\_4P.exe stands for the CSA component, 
compiled with GNU Fortran in a parallel mode (using MPICH) to run calculations with
the 4P force field.

\item
For the components of XDRFPDB and in the directory cluster/unres/src, say

\begin{verbatim}
make
\end{verbatim}

In other directories say

\begin{verbatim}
make <force_field>
\end{verbatim}

to create the respective executable.

The compiler flags are specified for the 4P (also covers the 3P, and CASP5 ff),
GAB (also covers E0G), and E0LL2Y force fields for all components; the CASP3 force field
is also specified for the CSA and MINIM component.
\end{enumerate}

\section{TECHNICAL SUPPORT CONTACT INFORMATION}
\label{sect:support}

   Dawid Jagie{\l}a\\
   Faculty of Chemistry, University of Gdansk\\
   ul. Wita Stwosza 63, 80-308 Gdansk Poland.\\
   fax: +48 58 523 5012\\
   e-mail: \href{mailto:lightnir@gmail.com}{lightnir@gmail.com}\\

\small{
        Prepared by Dawid Jagie{\l}a and Adam Liwo, 4/12/2014\\
}

\end{document}
