88 |
the current packages (FORTRAN77) are \textbf{not} based upon any |
the current packages (FORTRAN77) are \textbf{not} based upon any |
89 |
concept of libraries. |
concept of libraries. |
90 |
|
|
91 |
\subsubsection{File ``Hiding'' Rules} |
\subsubsection{File Inclusion Rules} |
92 |
|
|
93 |
Instead, packages should be viewed only as directories containing |
Instead, packages should be viewed only as directories containing |
94 |
``sets of source files'' that are built using some simple mechanisms |
``sets of source files'' that are built using some simple mechanisms |
111 |
previously encountered) then the file within the newer (more |
previously encountered) then the file within the newer (more |
112 |
recently visited) package will superseed (or ``hide'') any |
recently visited) package will superseed (or ``hide'') any |
113 |
previous file(s) with the same name. |
previous file(s) with the same name. |
114 |
|
|
115 |
\item Packages are visited (and thus files discovered) {\it in the |
\item Packages are visited (and thus files discovered) {\it in the |
116 |
order that the packages are enabled} within \texttt{genmake2}. |
order that the packages are enabled} within \texttt{genmake2}. |
117 |
Thus, the files in \texttt{PackB} may superseed the files in |
Thus, the files in \texttt{PackB} may superseed the files in |
118 |
\texttt{PackA} if \texttt{PackA} is enabled before |
\texttt{PackA} if \texttt{PackA} is enabled before \texttt{PackB}. |
119 |
\texttt{PackB}. Thus, package ordering can be significant! |
Thus, package ordering can be significant! For this reason, |
120 |
|
\texttt{genmake2} honors the order in which packages are |
121 |
|
specified. |
122 |
\end{enumerate} |
\end{enumerate} |
123 |
\end{enumerate} |
\end{enumerate} |
124 |
|
|
159 |
\end{verbatim} |
\end{verbatim} |
160 |
which is included from the file |
which is included from the file |
161 |
\filelink{calc\_diffusivity.F}{model-src-calc_diffusivity.F} |
\filelink{calc\_diffusivity.F}{model-src-calc_diffusivity.F} |
162 |
|
and shows how both the compile--time \texttt{ALLOW\_GMREDI} flag and the |
163 |
|
run--time \texttt{useGMRedi} are nested. |
164 |
|
|
165 |
There are some benefits to using this technique. The first is that |
There are some benefits to using the technique described here. The |
166 |
code snippets or subroutines associated with packages can be placed or |
first is that code snippets or subroutines associated with packages |
167 |
called from almost anywhere else within the code. The second benefit |
can be placed or called from almost anywhere else within the code. |
168 |
is related to the memory footprint and performance. Since unused code |
The second benefit is related to memory footprint and performance. |
169 |
can be removed, there is no performance penalty due to unnecessary |
Since unused code can be removed, there is no performance penalty due |
170 |
memory allocation or unused function calls. The major problems with |
to unnecessary memory allocation, unused function calls, or extra |
171 |
this approach are difficult-to-read and difficult-to-test code caused |
run-time \texttt{IF (...)} conditions. The major problems with this |
172 |
by the numerous CPP statements. Developers should exerecise some |
approach are the potentially difficult-to-read and difficult-to-debug |
173 |
discipline and avoid ``smearing'' implementation details across |
code caused by an overuse of CPP statements. So while it can be done, |
174 |
numerous files in a haphazard fashion. |
developers should exerecise some discipline and avoid unnecesarily |
175 |
|
``smearing'' their package implementation details across numerous |
176 |
|
files. |
177 |
|
|
178 |
|
|
179 |
|
\subsubsection{Package Startup or Boot Sequence} |
180 |
|
|
181 |
|
Calls to package routines within the core code timestepping loop can |
182 |
|
vary. However, all packages should follow a required "boot" sequence |
183 |
|
outlined here: |
184 |
|
|
185 |
|
{\footnotesize |
186 |
|
\begin{verbatim} |
187 |
|
1. S/R PACKAGES_BOOT() |
188 |
|
: |
189 |
|
CALL OPEN_COPY_DATA_FILE( 'data.pkg', 'PACKAGES_BOOT', ... ) |
190 |
|
|
191 |
|
|
192 |
|
2. S/R PACKAGES_READPARMS() |
193 |
|
: |
194 |
|
#ifdef ALLOW_${PKG} |
195 |
|
if ( use${Pkg} ) |
196 |
|
& CALL ${PKG}_READPARMS( retCode ) |
197 |
|
#endif |
198 |
|
|
199 |
|
3. S/R PACKAGES_INIT_FIXED() |
200 |
|
: |
201 |
|
#ifdef ALLOW_${PKG} |
202 |
|
if ( use${Pkg} ) |
203 |
|
& CALL ${PKG}_INIT_FIXED( retCode ) |
204 |
|
#endif |
205 |
|
|
206 |
|
4. S/R PACKAGES_CHECK() |
207 |
|
: |
208 |
|
#ifdef ALLOW_${PKG} |
209 |
|
if ( use${Pkg} ) |
210 |
|
& CALL ${PKG}_CHECK( retCode ) |
211 |
|
#else |
212 |
|
if ( use${Pkg} ) |
213 |
|
& CALL PACKAGES_CHECK_ERROR('${PKG}') |
214 |
|
#endif |
215 |
|
|
216 |
|
5. S/R PACKAGES_INIT_VARIABLES() |
217 |
|
: |
218 |
|
#ifdef ALLOW_${PKG} |
219 |
|
if ( use${Pkg} ) |
220 |
|
& CALL ${PKG}_INIT_VARIA( ) |
221 |
|
#endif |
222 |
|
|
223 |
|
6. S/R DO_THE_MODEL_IO |
224 |
|
|
225 |
|
#ifdef ALLOW_${PKG} |
226 |
|
if ( use${Pkg} ) |
227 |
|
& CALL ${PKG}_DIAGS( ) |
228 |
|
#endif |
229 |
|
|
230 |
|
7. S/R PACKAGES_WRITE_PICKUP() |
231 |
|
|
232 |
|
#ifdef ALLOW_${PKG} |
233 |
|
if ( use${Pkg} ) |
234 |
|
& CALL ${PKG}_WRITE_PICKUP( ) |
235 |
|
#endif\end{verbatim} |
236 |
|
} |
237 |
|
|
|
\subsection{Interfaces} |
|
238 |
|
|
239 |
|
\subsubsection{Package Startup or Boot Sequence} |
240 |
|
|