1 | \chapter{Program organization and compilation script} |
---|
2 | \label{sc:info} |
---|
3 | \index{Programming organization and compilation} |
---|
4 | |
---|
5 | \label{loc:contenu} |
---|
6 | |
---|
7 | All the elements of the LMD model are in the {\bf LMDZ.GENERIC} directory |
---|
8 | (and subdirectories). |
---|
9 | As explained in Section~\ref{loc:contact1}, this directory |
---|
10 | should be associated with |
---|
11 | environment variable {\bf LMDGCM}:\\ |
---|
12 | If using Csh: |
---|
13 | \begin{verbatim} |
---|
14 | setenv LMDGCM /where/you/put/the/model/LMDZ.GENERIC |
---|
15 | \end{verbatim} |
---|
16 | If using Bash: |
---|
17 | \begin{verbatim} |
---|
18 | export 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 | |
---|
44 | The model source files are stored in various sub directories |
---|
45 | in directory {\bf libf}. |
---|
46 | These 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, |
---|
50 | which contains the parameters that define the model grid, |
---|
51 | i.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 |
---|
57 | related 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 |
---|
62 | upper latitudes, |
---|
63 | where the Courant-Friedrich-Levy stability criterion is violated. |
---|
64 | |
---|
65 | \end{description} |
---|
66 | |
---|
67 | \section{Programming} |
---|
68 | |
---|
69 | The 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"} |
---|
72 | or {\bf ``file.F90''} files. |
---|
73 | The extension .F is the standard extension for fixed-form Fortran and |
---|
74 | the extension .F90 is for free-form Fortran. |
---|
75 | These files must be preprocessed (by a{\bf C preprocessor} |
---|
76 | such as (cpp)) before compilation (this behaviour is, for most |
---|
77 | compilers, implicitly obtained but using a capital F in the extention |
---|
78 | of the file names). |
---|
79 | |
---|
80 | \item Constants are placed in COMMON declarations, |
---|
81 | located 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 |
---|
85 | as arguments (and never as COMMON blocks). |
---|
86 | |
---|
87 | \item In some parts of the code, for ``historical'' reasons, |
---|
88 | the following rule is sometimes used: in the subroutine, |
---|
89 | the variables (ex: \verb+name+) passed as an argument by the calling program |
---|
90 | are given the prefix \verb+p+ (ex: \verb+pname+) |
---|
91 | while the local variables are given the prefix \verb+z+ (ex: \verb+zname+). |
---|
92 | As a result, several variables change their prefix (and thus their name) |
---|
93 | when 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} |
---|
97 | Figure~\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} |
---|
116 | Technically, the model is compiled using the Unix utility {\tt make}. |
---|
117 | The file {\tt makefile}, which describes the code dependencies |
---|
118 | and requirements, |
---|
119 | is created automatically by the script |
---|
120 | \begin{verbatim} |
---|
121 | create_make_gcm |
---|
122 | \end{verbatim} |
---|
123 | This utility script recreates the {\tt makefile} file when necessary, |
---|
124 | for example, when a source file has been added or removed since the last |
---|
125 | compilation. |
---|
126 | |
---|
127 | {\bf None of this is visible to the user. |
---|
128 | To compile the model just run the command} |
---|
129 | \begin{verbatim} |
---|
130 | makegcm |
---|
131 | \end{verbatim} |
---|
132 | with adequate options (e.g. {\tt makegcm -d 62x48x32 -p mars gcm}), as |
---|
133 | discussed below and described in section~\ref{sc:run1}. |
---|
134 | |
---|
135 | |
---|
136 | The {\tt makegcm} command compiles the model ({\bf gcm}) and related utilities |
---|
137 | ({\bf newstart}, {\bf start2archive}, {\bf testphys1d}). |
---|
138 | A detailed description of how to use it and of the various parameters that |
---|
139 | can be supplied |
---|
140 | is given in the help manual below |
---|
141 | (which will also be given by the \verb+makegcm -h+ command).\\ |
---|
142 | Note that before compiling the GCM with {\tt makegcm} you should have set |
---|
143 | the environment variable {\bf LIBOGCM} to a path where intermediate |
---|
144 | objects and libraries will be generated.\\ |
---|
145 | If using Csh: |
---|
146 | \begin{verbatim} |
---|
147 | setenv LIBOGCM /where/you/want/objects/to/go/libo |
---|
148 | \end{verbatim} |
---|
149 | If using Bash: |
---|
150 | \begin{verbatim} |
---|
151 | export 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 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|