
\subsubsection{Files and commands in the working directory}

   We shall use an alias name  {\it WORK} for  the directory which has been created by the user
during  the \CompHEP~ installation (Section \ref{u-install}). It contains the following 
sub-directories and files:\\
\hspace*{2cm}{\tt models/ results/    tmp/ }\\
\hspace*{2cm}{\tt comphep   comphep.ini }

  The {\it models} directory contains files which describe physical models. 
 When you 
modify a model or create a new one  all  changes
are kept in this directory. 

  The directory {\it results} keeps a \CompHEP~ output which is produced as
a result of symbolic or numerical calculations. 

  The directory {\it tmp} is used for temporary files. The file {\it tmp/safe} 
keeps  user settings between the sessions. If this file exists the symbolic 
session  starts its work with reading this file to restore the user settings
of the previous session.
A bug presenting in this file could be a reason for a fatal error in the beginning
of the \CompHEP~ session. In the case of such an error we  recommend to remove  
the {\it tmp/safe} file. 
 
  All these directories are necessary for  \CompHEP~ work. Absence
of one of them will lead to a fatal error.

  You can toggle on/off the color and the sound for a \CompHEP~ session as well
as choose the most appropriate font for your X-terminal. To do this  just edit
the {\it comphep.ini}  file. We hope the syntax there is
self-explanatory enough.


 The command \\
\hspace*{2cm}{\tt       ./comphep  }\\
starts a \CompHEP~ session.  This is a shell script which calls
commands disposed in the  \CompHEP~ root directory. It is assumed that the
{\it \$COMPHEP} environment variable (see Section \ref{u-install}) points to this directory.

\subsubsection{Scheme of calls in the  \CompHEP~ session}

  The command {\it ./comphep} being issued from within the {\it WORK} directory launches 
the 
\begin{center} \tt \$COMPHEP/s\_comphep \end{center}
command. The latter is the main \CompHEP~ program. Prefix {\it 's\_'}
denotes symbolic.  It performs symbolic calculations and generates the \C~ and
\Fortran~ codes of calculated Feynman diagrams. 

Below we would like to describe  commands  for compilation  and numerical
module launching. The command names  in the \C~ and \Fortran~ cases are distinguished  by 
suffixes  {\it 'c'} and {\it 'f'} correspondingly. We shall use the '*' symbol 
as a common notation for these {\it 'c'} and {\it 'f'}. The general scheme of calls
can be presented by the following diagram

\noindent
{\tt
s\_comphep $\rightarrow$ launch\_n\_comphep~* $\rightarrow$ 
\begin{tabular}{|l}
make\_\_n\_comphep~* $\rightarrow$ \begin{tabular}{|l}
                                     nCompil\_*\\ 
                                     ld\_*\\
                                   \end{tabular}           \\
n\_comphep\_*\\
\end{tabular}
}


The binary executable {\it n\_comphep\_*} is created in the {\it WORK/results} 
sub-directory as a result of  compilation. Other commands are
disposed in the {\it \$COMPHEP} directory. They  are shell scripts
except of  binary {\it s\_comphep}. It is assumed that {\it s\_comphep}
and  {\it launch\_n\_comphep}  are started  from  the {\it WORK} directory,
whereas  other  commands   are started from within the {\it WORK/results} 
sub-directory.
 

The    program {\it nCompil\_* }  compiles  the source
code produced prior by {\it s\_comphep}.  After  successful compilation it
creates a library of object files   and then removes  the source and 
the object files. 

Another command {\it ld\_*} 
calls a  linker to create the  executable file
{\it n\_comphep\_*}  for  numerical job.

%  Generally the {\it ld\_*} command does not need any arguments. However if you
%would like to attach some program to n\_comphep\_*, you can pass
% corresponding  object files to linker as  arguments of
%ld\_*.  The user structure functions,  cuts and
%histograms could be easily implemented by this mean (see
%\ref{user-prg})
 
The  command  {\it make\_\_n\_comphep } with parameter 
'c' or 'f' is  used to start {\it nCompil\_*} and {\it ld\_*}
subsequently. 

In its turn,   {\it make\_\_n\_comphep} is started  by 
{\it launch\_n\_comphep } 
in a  special window. In the  case of successful compilation  the window is closed 
and  just created {\it n\_comphep\_*} is started in 
another window.

  If you copy  {\it \$COMPHEP/make\_\_n\_comphep}  into  your  {\it WORK/} 
directory, then   {\it launch\_n\_comphep} will call for your own version. 
It gives you a possibility to modify a compilation procedure if necessary. 


The  {\it s\_comphep} command  starts  {\it launch\_n\_comphep}
via the functions 
{\tt
  \begin{center}
    \begin{tabular}{|c|}
      \hline
       ............\\ C-compiler\\ Fortran compiler \\
      \hline
    \end{tabular}
  \end{center}
}
\noindent
of {\it Menu~6} (Fig.\ref{s_chain})
and thus the chain of above  calls  is realized.  

If you have prepared  the \C~ or \Fortran~ codes you could compile 
them outside of the symbolic session by  the {\it make\_\_n\_comphep }  
command  with the {\it c/f} argument  started from  within the {\it results} directory.

Let us say some  words about other programs stored in the {\it \$COMPHEP} 
directory.
 The program {\it genEvents} is used to prepare an event flow and
 histograms using the information saved by Monte Carlo session. 
The programs {\it unweight}, {\it randomize}, {\it filter2D}, 
{\it filterND}, and {\it mk\_tab} transform the event flow
generated by {\it genEvents}. See Section \ref{events} for details. 
The program {\it tab\_view}   provides the user with a possibility of
visual presentation of distributions. See Section \ref{interface}. 

\subsubsection{LOCK files}

  {\it  WORK/comphep} creates a file {\it LOCK} in the {\it WORK/} 
directory.  
Presence of the {\it LOCK} file prevents a double launching of {\it WORK/comphep}
from within the same place of the file system.  {\it LOCK} is automatically
removed in the end of the {\it WORK/comphep} session.
  In the same manner {\it \$COMPHEP/launch\_n\_comphep} creates a file 
{\it c\_LOCK} or {\it f\_LOCK} in the {\it WORK/results} sub-directory. 

If your session has been
canceled abnormally you have to remove these {\it LOCK,  f\_LOCK, c\_LOCK} 
files manually before launching the next session.

