source: trunk/LMDZ.GENERIC/DOC/compilation.tex @ 1315

Last change on this file since 1315 was 987, checked in by jleconte, 11 years ago

11/06/2013 == JL+EM

  • User manual (+ sources) added in DOC.
File size: 5.6 KB
Line 
1\chapter{Program organization and compilation script}
2\label{sc:info}
3\index{Programming organization and compilation}
4
5\label{loc:contenu}
6
7All the elements of the LMD model are in the {\bf LMDZ.GENERIC} directory
8(and subdirectories).
9As explained in Section~\ref{loc:contact1}, this directory
10should be associated with
11 environment variable {\bf LMDGCM}:\\
12If using Csh:
13\begin{verbatim}
14setenv  LMDGCM /where/you/put/the/model/LMDZ.GENERIC
15\end{verbatim}
16If using Bash:
17\begin{verbatim}
18export  LMDGCM=/where/you/put/the/model/LMDZ.GENERIC
19\end{verbatim}
20
21\noindent Here is a brief description of the
22{\bf LMDZ.GENERIC} directory contents:
23\begin{verbatim}
24  libf/  All the model FORTRAN Sources (.F or .F90)
25         and  include files (.h) organised in sub-directories
26        (physics (phystd), dynamics (dyn3d), filters (filtrez)...)
27
28  deftank/   A collection of examples of parameter files required
29                to run the GCM (run.def, callphys.def, ...)
30
31  makegcm  Script that should be used to compile the GCM as well
32            as related utilities (newstart, start2archive, testphys1d)
33
34  create_make_gcm   Executable used to create the makefile.
35                    This command is run automatically by
36                    "makegcm" (see below).
37
38\end{verbatim}
39
40
41\section{Organization of the model source files}
42\index{Organization of the model source files}
43
44The model source files are stored in various sub directories
45in directory {\bf libf}.
46These sub-directories correspond to the different parts of the model:
47
48\begin{description}
49\item{\bf grid:} mainly made up of "dimensions.h" file,
50which contains the parameters that define the model grid,
51i.e. the number of points in longitude (IIM), latitude (JJM) and altitude
52(LLM), as well as the number of tracers (NQMX).
53
54\item{\bf dyn3d:} contains the dynamical subroutines.
55
56\item{\bf bibio:} contains some generic subroutines not specifically
57related to physics or dynamics but used by either or both.
58
59\item{\bf phymars:} contains the physics routines.
60
61\item{\bf filtrez:} contains the longitudinal filter sources applied in the
62upper latitudes,
63where the Courant-Friedrich-Levy stability criterion is violated.
64
65\end{description}
66
67\section{Programming}
68
69The model is written in {\bf Fortran-77} and {\bf Fortran-90}.
70\begin{itemize}
71\item The program sources are written in {\bf ``file.F"}
72or {\bf ``file.F90''} files.
73The extension .F is the standard extension for fixed-form Fortran and
74the extension .F90 is for free-form Fortran.
75These files must be preprocessed (by a{\bf C preprocessor}
76such as (cpp)) before compilation (this behaviour is, for most
77compilers, implicitly obtained but using a capital F in the extention
78of the file names).
79
80\item Constants are placed in COMMON declarations,
81located in the common ``include'' files {\bf "file.h"}
82
83%\item [also module files now too...]
84\item In general, variables are passed from subroutine to subroutine
85as arguments (and never as COMMON blocks).
86
87\item In some parts of the code, for ``historical'' reasons,
88the following rule is sometimes used: in the subroutine,
89the variables (ex: \verb+name+) passed as an argument by the calling program
90are given the prefix \verb+p+ (ex: \verb+pname+)
91 while the local variables are given the prefix \verb+z+ (ex: \verb+zname+).
92As a result, several variables change their prefix (and thus their name)
93when passing from a calling subroutine to a called subroutine. We're trying to eliminate this as the code is developed.
94\end{itemize}
95
96\section{Model organization}
97Figure~\ref{fg:organi_phys} describes the main subroutines called by physiq.F. OBSOLETE - FOR MARS ONLY!!!
98\index{Model organization}
99\begin{figure}
100\begin{flushleft}
101\includegraphics[scale=0.70,angle=-90]{Fig/physique.eps}
102\caption{Organigram of subroutine function physiq.F90}
103\label{fg:organi_phys}
104\end{flushleft}
105\end{figure}
106
107
108%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109%  Compilation du modele
110%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111
112\section{Compiling the model}
113\index{Compiling the model}
114
115\label{sc:compil1}
116Technically, the model is compiled using the Unix utility {\tt make}.
117The file {\tt makefile}, which describes the code dependencies
118and requirements,
119is created automatically by the script
120\begin{verbatim}
121create_make_gcm
122\end{verbatim}
123This utility script recreates the {\tt makefile} file when necessary,
124for example, when a source file has been added or removed since the last
125compilation.
126
127{\bf None of this is visible to the user.
128To compile the model just run the command}
129\begin{verbatim}
130makegcm
131\end{verbatim}
132with adequate options (e.g. {\tt makegcm -d 62x48x32 -p mars gcm}), as
133discussed below and described in section~\ref{sc:run1}.
134
135
136The {\tt makegcm} command compiles the model ({\bf gcm}) and related utilities
137({\bf newstart}, {\bf start2archive}, {\bf testphys1d}).
138A detailed description of how to use it and of the various parameters that
139can be supplied
140is given in the help manual below
141(which will also be given by the \verb+makegcm -h+ command).\\
142Note that before compiling the GCM with {\tt makegcm} you should have set
143the environment variable {\bf LIBOGCM} to a path where intermediate
144objects and libraries will be generated.\\
145If using Csh:
146\begin{verbatim}
147setenv  LIBOGCM /where/you/want/objects/to/go/libo
148\end{verbatim}
149If using Bash:
150\begin{verbatim}
151export  LIBOGCM=/where/you/want/objects/to/go/libo
152\end{verbatim}
153\paragraph{Help manual for the makegcm script}
154%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155% makegcm.help:  lu dans makegcm
156%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157\input{input/makegcm_help.tex}
158%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the repository browser.