/[MITgcm]/MITgcm/doc/devel_HOWTO.sgml
ViewVC logotype

Annotation of /MITgcm/doc/devel_HOWTO.sgml

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (hide annotations) (download) (as text)
Thu Jan 21 23:59:17 2010 UTC (14 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62c, checkpoint62b, checkpoint62e, checkpoint62d
Changes since 1.9: +17 -9 lines
File MIME type: text/x-sgml
update links & location

1 edhill 1.1 <!DOCTYPE ARTICLE PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
2    
3     <article id="MITgcm-Development-HOWTO">
4    
5     <articleinfo>
6     <title>MITgcm Development HOWTO</title>
7    
8     <author>
9     <firstname>Ed</firstname>
10     <surname>Hill III</surname>
11     <affiliation>
12     <address><email>eh3@mit.edu</email></address>
13     </affiliation>
14     </author>
15    
16     <revhistory>
17     <revision>
18     <revnumber>0.01</revnumber>
19 edhill 1.2 <date>2003-08-07</date>
20 edhill 1.1 <authorinitials>eh3</authorinitials>
21     <revremark>
22     Initial version.
23     </revremark>
24     </revision>
25 jmc 1.10 <revision>
26     <revnumber>0.02</revnumber>
27     <date>2010-01-21</date>
28     <authorinitials>jmc</authorinitials>
29     <revremark>
30     update links.
31     </revremark>
32     </revision>
33 edhill 1.1 </revhistory>
34    
35     <abstract>
36     <para>This document describes how to develop software for the
37     MITgcm project.</para>
38     </abstract>
39     </articleinfo>
40    
41     <sect1 id="intro">
42     <title>Introduction</title> <para>The purpose of this document is
43     to help new developers get "up to speed" with MITgcm
44     development.</para>
45     <sect2>
46     <title>New Versions of This Document</title> <para>You can
47     obtain the latest version of this document <ulink
48 jmc 1.10 url="http://mitgcm.org/public/docs.html">online</ulink> in
49 edhill 1.1 various formats.</para>
50     </sect2>
51     <sect2>
52     <title>Feedback and corrections</title> <para>If you have
53     questions or comments about this document, please feel free to
54     <ulink url="mailto:MITgcm-support@mitgcm.org">contact the
55     authors</ulink>.
56     </para>
57     </sect2>
58     </sect1>
59    
60     <sect1 id="background">
61     <title>Background</title>
62    
63     <sect2>
64     <title>User Manual</title>
65    
66 edhill 1.5 <para>Before jumping into development, please familiarize yourself with
67 jmc 1.10 the <ulink url="http://mitgcm.org/public/docs.html"> MITgcm user manual
68 edhill 1.5 </ulink>. This document contains volumes of useful information and is
69     included here by reference.</para>
70 edhill 1.1
71 edhill 1.5 <!--
72     <para>Also, a "snapshot" or <ulink
73 edhill 1.1 url="http://mitgcm.org/dev_docs/">development version</ulink> of
74     the user manual may be available, though this is only put on the
75     web for testing purposes.</para>
76 edhill 1.5 -->
77 edhill 1.1 </sect2>
78    
79     <sect2>
80     <title>Prerequisites</title> <para>To develop for MITgcm project
81     you will need a UNIX or UNIX-like set of build tools including
82     the following:</para>
83     <blockquote>
84     <simplelist type="inline">
85     <member>CVS client</member>
86     <member>make or (preferably) GNU make</member>
87     <member>FORTRAN compiler</member>
88     <member>C compiler</member>
89     <member>[ba]sh and [t]csh shells</member>
90     <member>PERL</member>
91     <member>LaTeX and LaTeX2HTML</member>
92     </simplelist>
93     </blockquote>
94     <para>Essentially all of the work described here has been tested
95     on recent versions of Red Hat Linux (eg. 7.3 through 9). Except
96     where noted, all shell commands will be provided using bash
97     syntax.
98     </para>
99     </sect2>
100    
101     </sect1>
102    
103     <sect1 id="cvs">
104     <title>CVS Repository</title>
105     <sect2>
106     <title>Layout</title>
107    
108     <para>Unlike many open source projects, the MITgcm CVS tree does
109     not follow a simple "src", "docs", "share", and "test" directory
110     layout. Instead, there are multiple higher-level directories
111     that each, to some extent, depend upon the presence of the
112     others. The tree currently resembles:</para>
113    
114     <programlisting>gcmpack/
115     MITgcm-contrib contributed code
116     CS-regrid goes into utils
117     cvspolicy.html -save-
118     CVSROOT -save-
119     development experimental stuff
120     manual -save-
121     misc -?-
122    
123     MITgcm code
124     adjoint fold into genmake
125     bin stub for ecco build
126     compare01 old from 20th century
127     diags timeave f77 in pkgs now
128     doc tags -- connect to real docs?
129     eesupp cnh?
130     exe ecco user build
131 edhill 1.4 ,- jobs runtime shell scripts for
132 edhill 1.1 | various platforms
133     | lsopt line search
134     m| model main dynamics (core)
135     e| optimization_drivers ?
136     r| optim line search interface
137     g| pkg alternate and optional numerics, etc.
138 edhill 1.4 e|- tools
139 edhill 1.1 ?| tutorial_examples documented tests
140     | only populated on release1 branch
141 jmc 1.10 | and not validated during "testreport"
142 edhill 1.4 '- utils
143 edhill 1.1 verification std tests
144    
145    
146     mitgcmdoc -> manual -remove-
147     mitgcm.org build web site
148     models -?-
149     packages -?-
150     preprocess -?-
151     tmp -?-
152     </programlisting>
153    
154     <para>Efforts are underway to reduce the complexity.</para>
155    
156     </sect2>
157    
158     <!--
159     <sect2>
160     <title>Releases</title> <para>Currently, there are two main
161     branches:</para>
162     <itemizedlist mark="bullet">
163     <listitem>
164     <para>Development</para>
165     <itemizedlist mark="bullet">
166     <listitem>
167     <para>MAIN</para>
168     </listitem>
169     <listitem>
170     <para>ecco-branch</para>
171     </listitem>
172     </itemizedlist>
173     </listitem>
174     <listitem>
175     <para>Production</para>
176     <itemizedlist mark="bullet">
177     <listitem>
178     <para>Release1</para>
179     </listitem>
180     <listitem>
181     <para>Release2</para>
182     </listitem>
183     </itemizedlist>
184     </listitem>
185     </itemizedlist>
186     </sect2>
187     -->
188    
189     <sect2>
190     <title>Branches</title>
191    
192     <para>As shown in the online <ulink
193 jmc 1.10 url="http://mitgcm.org/viewvc/MITgcm/MITgcm/doc/tag-index?view=graph">
194 edhill 1.7 ViewCVS-generated tree</ulink>, the MITgcm codebase is split into to two
195     branches or "lines" under which development proceeds. These two lines are
196     referred to as the "MAIN" and "ecco" versions of the code. While not
197     identical, the bulk of the MAIN and ecco lines are composed of files from
198     the same codebase.
199 edhill 1.1 </para>
200    
201     <para>Periodically, a "Release" branch is formed from the "MAIN"
202 edhill 1.7 development branch. This is done in order to create a relatively stable
203     reference point for both users and developers. The intent is that once a
204     relese branch has been created, only bug-fixes will be added to it.
205     Meanwhile, development (which might "break" or otherwise render invalid
206     the documentation, tutorials, and/or examples contained within a release
207     branch) is allowed to continue along the MAIN and ecco lines.</para>
208 edhill 1.1 </sect2>
209    
210     <sect2>
211     <title>Tagging</title>
212    
213 edhill 1.7 <para>The intent of tagging is to create "known-good" checkpoints that
214     developers can use as references. Traditionally, MITgcm tagging has
215     maintained the following conventions:</para>
216 edhill 1.1
217     <orderedlist>
218     <listitem>
219 edhill 1.7 <para>Developer checks out code into a local CVS-managed directory,
220     makes various changes/additions, tests these edits, and eventually
221     reaches a point where (s)he is satisfied that the changes form a new
222     "useful" point in the evolution of the code.</para>
223 edhill 1.1 </listitem>
224    
225     <listitem>
226     <para>The developer then runs the <ulink
227 jmc 1.10 url="http://mitgcm.org/viewvc/MITgcm/MITgcm/verification/testreport">
228     testreport</ulink> shell script to see if any problems are introduced.
229 edhill 1.7 While not intended to be exhaustive, the test cases within the
230     verification directory do provide some indication whether gross errors
231     have been introduced.
232 edhill 1.1 </para>
233     </listitem>
234    
235     <listitem>
236     <para>Having satisfied him- or herself that the changes are
237     ready to be committed to the CVS repository, the developer
238     then:</para>
239     <orderedlist>
240     <listitem>
241 edhill 1.7 <para>adds a "checkpointXY_pre" comment (where X is a checkpoint
242     number and Y is a letter) to the <ulink
243 jmc 1.10 url="http://mitgcm.org/viewvc/MITgcm/MITgcm/doc/tag-index">
244 edhill 1.7 tag-index</ulink> file and checks it into the CVS
245     repository</para>
246 edhill 1.1 </listitem>
247     <listitem>
248 edhill 1.7 <para>submits the set of changes to the CVS repository and adds
249     comments to <filename>tag-index</filename> describing what the
250     changes are along with a matching "checkpointXY_post" entry</para>
251 edhill 1.1 </listitem>
252     </orderedlist>
253     </listitem>
254     </orderedlist>
255    
256 edhill 1.7 <para>The result of this tagging procedure is a sequence of development
257     checkpoints with comments which resembles:</para>
258 edhill 1.1
259     <programlisting>
260     checkpoint50e_post
261     o make KPP work with PTRACERS
262     - fix gad_calc_rhs to call new routine kpp_transport_ptr, which is
263     nearly a copy of kpp_transport_s
264     - there is no analogue to SurfaceTendencyS, so I have to use
265     gPtr(of the surface layer) instead
266     o add a new platform SunFire+mpi (SunFire 15000) to genmake
267     checkpoint50e_pre
268    
269     checkpoint50d_post
270     o change kpp output from multiple-record state files to single-record state
271     files analogous to write_state.F
272     o reduce the output frequency of cg3d-related stuff to the monitor frequency,
273     analogous to the cg2d-related output.
274     o fix small problem with in ptracers_write_checkpoint.F: len(suff)=512,
275     so that writing to internal file fn (with length 512) fails.
276     checkpoint50d_pre
277     </programlisting>
278    
279 edhill 1.7 <para>This information can be used to refer to various stages of the code
280     development. For example, bugs can be traced to individual sets of CVS
281     checkins based upon their first appearance when comparing the results from
282     different checkpoints.</para>
283 edhill 1.1
284     </sect2>
285     </sect1>
286    
287    
288     <sect1 id="documentation">
289     <title>Editing the Documentation</title>
290    
291     <sect2 id="documentation_getting">
292     <title>Getting the Docs and Code</title>
293    
294 edhill 1.7 <para>The first step towards editing the documentation is to checkout a
295     copy of code, docs, and build scripts from the CVS server using:</para>
296 edhill 1.1
297     <screen>
298 edhill 1.5 $ export CVS_RSH=ssh
299 edhill 1.7 $ export CVSROOT=':ext:NAME@mitgcm.org:/u/gcmpack'
300 edhill 1.5 $ mkdir scratch
301 jmc 1.9 $ cvs co -P MITgcm manual mitgcm.org
302 edhill 1.1 </screen>
303    
304 edhill 1.7 <para>These commands extract the necessary information from the CVS server
305     and create a temporary (called <filename>scratch</filename>) directory for
306     the storage of the HTML and other files that will be created. Please note
307     that you must either create <filename>scratch</filename> as shown or edit
308     the various <filename>Makefile</filename>s and scripts used to create the
309     documentation.</para>
310 edhill 1.1 </sect2>
311    
312     <sect2>
313 edhill 1.4 <title>Editing the Documentation</title>
314 edhill 1.1
315 edhill 1.7 <para>The documentation is contained in the <filename>manual</filename>
316     directory in a raw LaTeX format. The main document is
317     <filename>manual.tex</filename> and it uses <command>\input{}</command>s
318     to include the chapters and subsections.</para>
319    
320     <para>Since the same LaTeX source is used to produce PostScript, PDF, and
321     HTML output, care should be taken to follow certain conventions. Two of
322     the most important are the usage of the <command>\filelink{}{}</command>
323     and <command>\varlink{}{}</command> commands. Both of these commands have
324     been defined to simplify the connection between the automatically
325     generated ("code browser") HTML and the HTML version of the manual
326     produced by LaTeX2HTML. They each take two arguments (corresponding to
327     the contents of the two sets of curly braces) which are the text that the
328     author wishes to be "wrapped" within the link, and a specially formatted
329     link thats relative to the <filename>MITgcm</filename> directory within
330     the CVS tree.</para>
331 edhill 1.1
332     <para>The result is a command that resembles either</para>
333    
334     <orderedlist>
335     <listitem>
336     <para>a reference to a variable or subroutine name such as
337     <command>\varlink{tRef}{tRef}</command>, or </para>
338     </listitem>
339    
340     <listitem>
341     <para>a reference to a file such as
342     <command>\varlink{tRef}{path-to-the-file_name.F}</command>
343     where the absolute path to the file is of the form
344     <filename>/foo/MITgcm/path/to/the/file_name.F</filename></para>
345     <para>(please note how the leading "/foo/MITgcm"
346     component of the path is dropped leaving the path
347     <emphasis>relative</emphasis> to the head of the code
348     directory and each directory separator "/" is turned
349     into a "-")</para>
350     </listitem>
351     </orderedlist>
352    
353    
354    
355     </sect2>
356    
357     <sect2>
358 edhill 1.4 <title>Building the Documentation</title>
359    
360     <para>Given the directory structure of <xref
361     linkend="documentation_getting">, the entire documentation for the web
362     site can be built using:</para>
363 edhill 1.1
364     <screen>
365 edhill 1.5 $ cd mitgcm.org/devel/buildweb
366     $ make All
367 edhill 1.1 </screen>
368    
369 edhill 1.7 <para>Which builds the PDF from the LaTeX source, creates the HTML output
370     from the LaTeX source, parses the FORTRAN code base to produce a
371     hyperlinked HTML version of the source, and then determines the
372     cross-linking between the various HTML components.</para>
373    
374     <para>If there are no errors, the result of the build process (which can
375     take 30+ minutes on a P4/2.5Ghz) will be contained within a single
376     directory called <filename>scratch/dev_docs</filename>. This is a freshly
377     built version of the entire on-line users manual. If you have the correct
378     permissions, it can be directly copied to the web server area:</para>
379 edhill 1.1
380     <screen>
381 edhill 1.5 $ mv scratch/dev_docs /u/u0/httpd/html
382 edhill 1.1 </screen>
383    
384     <para>and the update is complete.</para>
385    
386     </sect2>
387    
388     </sect1>
389    
390 edhill 1.2 <sect1 id="coding">
391 edhill 1.3 <title>Coding for MITgcm</title>
392    
393     <sect2 id="build_tools">
394     <title>Build Tools</title>
395    
396 edhill 1.4 <para>Many Open Source projects use the "GNU Autotools" to help streamline
397     the build process for various Unix and Unix-like architectures. For a
398     user, the result is the common "configure" (that is,
399     "<filename>./configure && make && make install</filename>") commands.
400     For MITgcm, the process is similar. Typical commands are:</para>
401 edhill 1.3
402     <screen>
403 edhill 1.5 $ genmake -mods=../code
404     $ make depend
405     $ make
406 edhill 1.3 </screen>
407    
408 edhill 1.4 <para>The following sections describe the individual steps in the build
409     process.</para>
410    
411 edhill 1.3 <sect3 id="genmake">
412     <title>The <filename>genmake2</> Utility</title>
413    
414 edhill 1.4 <para><emphasis>Please note that the older <filename>genmake</> is
415     deprecated and will eventually be replaced by <filename>genmake2</>.
416     This HOWTO only describes the newer tool.</emphasis></para>
417    
418     <para>The first step in any MITgcm build is to create a Unix-style
419     <filename>Makefile</filename> which will be parsed by
420     <filename>make</filename> to specify how to compile the MITgcm source
421     files. For more detailed descriptions of what the make tools are and
422     how they are used, please see:</para>
423 edhill 1.3
424     <itemizedlist>
425     <listitem>
426 edhill 1.4 <para><ulink url="http://www.gnu.org/software/make/make.html">
427     http://www.gnu.org/software/make/make.html</></para>
428 edhill 1.3 </listitem>
429     <listitem>
430 edhill 1.4 <para><ulink url="http://www.oreilly.com/catalog/make2/">
431     http://www.oreilly.com/catalog/make2/</></para>
432 edhill 1.3 </listitem>
433     </itemizedlist>
434    
435 edhill 1.4 <para>Genmake can often be invoked successfully with a command line as
436     simple as:</para>
437    
438     <screen>
439 edhill 1.5 $ genmake2 -mods=../code
440 edhill 1.4 </screen>
441    
442     <para>However, some systems (particularly commercial Unixes that lack a
443     more modern "/bin/sh" implementation or that have shells installed in
444     odd locations) may require an explicit shell invocation such as one of
445     the following: </para>
446    
447     <screen>
448 edhill 1.5 $ /usr/bin/sh genmake2 -make=gmake -mods=../code
449     $ /opt/gnu/bin/bash genmake2 -ieee -make=/usr/local/bin/gmake -mods=../code
450 edhill 1.4 </screen>
451    
452     <para>The genmake2 code has been written in a Bourne and BASH (v1)
453     compatible syntax so it should work with most "sh" and all recent "bash"
454     implementations.</para>
455    
456     <para>As the name implies, <filename>genmake2</filename> generates a
457     <filename>Makefile</filename>. It does so by first parsing the
458     information supplied from the following sources</para>
459 edhill 1.3
460     <orderedlist>
461     <listitem>
462 jmc 1.6 <para>a <filename>gemake_local</filename> file in the current
463 edhill 1.4 directory</para>
464 edhill 1.3 </listitem>
465     <listitem>
466     <para>directly from command-line options</para>
467     </listitem>
468     <listitem>
469 edhill 1.4 <para>an "options file" as specified by the command-line option
470     <filename>-optfile='FILENAME'</filename></para>
471 edhill 1.3 </listitem>
472     </orderedlist>
473    
474 edhill 1.4 <para>then checking certain dependency rules (the package dependencies),
475     and finally writing a <filename>Makefile</filename> based upon the
476     source code that it finds. For convenience within various Unix
477     shells, <filename>genmake2</> supports both "long"- and "short"-style
478     options. A complete list of the available options can be obtained
479     from:</para>
480 edhill 1.3
481     <screen>
482 edhill 1.5 $ genmake2 -help
483 edhill 1.3 </screen>
484    
485 edhill 1.4 <para>The most important options for <filename>genmake2</> are:</para>
486 edhill 1.3
487     <variablelist>
488    
489     <varlistentry>
490     <term><filename>--optfile=/PATH/FILENAME</></term>
491 edhill 1.4
492 edhill 1.3 <listitem>
493 edhill 1.4 <para>This specifies the "options file" that should be used for a
494     particular build. The options file is a convenient and
495     machine-indepenent way of specifying parameters such as the
496     FORTRAN compiler (<filename>FC=</>), FORTRAN compiler
497     optimization flags (<filename>FFLAGS=</>), and the locations of
498     various platform- and/or machine-specific tools
499     (eg. <filename>MAKEDEPEND=</>). As with <filename>genmake2</>,
500     all options files should be written to be compatible with
501     Bourne--shell ("sh" or "BASH v1") syntax. Examples of various
502     options files can be found in
503     <filename>$ROOTDIR/tools/build_options</>.</para>
504    
505     <para>If no "optfile" is specified (either through the command lin
506     or the environment variable), genmake2 will try to make a
507     reasonable guess from the list provided in
508     <filename>$ROOTDIR/tools/build_options</>. The method used for
509     making this guess is to first determine the combination of
510     operating system and hardware (eg. "linux_ia32") and then find a
511     working Fortran compiler within the user's path. When these
512     three items have been identified, genmake2 will try to find an
513     optfile that has a matching name. </para>
514    
515     <para>Everyone is encouraged to submit their options files to the
516     MITgcm project for inclusion (please send to
517     <email>MITgcm-support@mitgcm.org</email>). We are particularly
518     grateful for options files tested on new or unique
519     platforms!</para>
520 edhill 1.3 </listitem>
521 edhill 1.4
522 edhill 1.3 </varlistentry>
523    
524     <varlistentry>
525     <term><filename>-pdepend=/PATH/FILENAME</></term>
526 edhill 1.4
527 edhill 1.3 <listitem>
528 edhill 1.4 <para>This specifies the dependency file used for packages. If
529     not specified, the default dependency file is
530     <filename>$ROOTDIR/pkg/pkg_depend</>. The syntax for this file is
531     parsed on a line-by-line basis where each line containes either a
532     comment ("#") or a simple "PKGNAME1 (+|-)PKGNAME2" pairwise rule
533     where the "+" or "-" symbol specifies a "must be used with" or a
534     "must not be used with" relationship, respectively. If no rule is
535     specified, then it is assumed that the two packages are compatible
536     and will function either with or without each other.</para>
537 edhill 1.3 </listitem>
538     </varlistentry>
539    
540     <varlistentry>
541     <term><filename>-pdefault=PKG</></term>
542     <term><filename>-pdefault='PKG1 [PKG2 PKG3 ...]'</></term>
543     <listitem>
544     <para>This option specifies the default set of packages
545     to be used. If not set, the default package list will
546     be read from
547     <filename>$ROOTDIR/pkg/pkg_default</>.</para>
548     </listitem>
549     </varlistentry>
550    
551     <varlistentry>
552 edhill 1.5 <term><filename>-adof=/path/to/file</></term>
553     <term><filename>-adoptfile=/path/to/file</></term>
554     <listitem>
555     <para>This option specifies the "adjoint" or automatic
556     differentiation options file to be used. The file is analogous
557     to the "optfile" defined above but it specifies information for
558     the AD build process. The default file is located in <filename>
559     $ROOTDIR/tools/adjoint_options/adjoint_default </> and it
560     defines the "TAF" and "TAMC" compilers. An alternate version is
561     also available at <filename>
562     $ROOTDIR/tools/adjoint_options/adjoint_staf </> that selects the
563     newer "STAF" compiler. As with any compilers, it is helpful to
564     have their directories listed in your $PATH environment
565     variable.</para>
566     </listitem>
567     </varlistentry>
568    
569     <varlistentry>
570 edhill 1.4 <term><filename>-mods=DIR</></term>
571     <term><filename>-mods='DIR1 [DIR2 ...]'</></term>
572 edhill 1.3 <listitem>
573 edhill 1.4 <para>This option specifies a list of directories containing
574     "modifications". These directories contain files with names
575     that may (or may not) exist in the main MITgcm source tree but
576     will be overridden by any identically-named sources within the
577     "MODS" directories. The order of precedence for this
578     "name-hiding" is as follows:</para>
579    
580     <itemizedlist>
581     <listitem><para>"MODS" directories (in the order given)
582     </para></listitem>
583     <listitem><para>Packages either explicitly specified or
584     provided by default (in the order given)</para></listitem>
585     <listitem><para>Packages included due to package dependencies
586     (in the order that that package dependencies are
587     parsed)</para></listitem>
588     <listitem><para>The "standard dirs" (which may have been
589     specified by the "-standarddirs" option)</para></listitem>
590     </itemizedlist>
591    
592     </listitem>
593     </varlistentry>
594    
595     <varlistentry>
596     <term><filename>-make=/path/to/gmake</></term>
597     <listitem>
598     <para>Due to the poor handling of soft-links and other bugs common
599     with the <filename>make</> versions provided by commercial Unix
600     vendors, GNU <filename>make</filename> (sometimes called
601     <filename>gmake</filename>) should be preferred. This option
602     provides a means for specifying the make program to be
603     used.</para>
604 edhill 1.3 </listitem>
605     </varlistentry>
606    
607     </variablelist>
608    
609 edhill 1.4 <para>A successful run of <filename>genmake2</> will produce a
610     <filename>Makefile</>, a <filename>PACKAGES_CONFIG.h</> file, and
611     various convenience files used for the automatic differentiation
612     process.</para>
613    
614     <para>In general, it is best to use <filename>genmake2</> on a "clean"
615     directory that is free of all source (*.[F,f],*.[F,f]90) and header
616     (*.h,*.inc) files. Generally, this can be accomplished in an
617     "un-clean" directory by running "make CLEAN" followed by "make
618     makefile".</para>
619 edhill 1.3
620     </sect3>
621    
622     <sect3 id="makefile_use">
623 edhill 1.5 <title>Using the <filename>Makefile</></title>
624 edhill 1.3
625 edhill 1.5 <para>Once a <filename>Makefile</> has been created using
626     <filename>genmake2</>, one can build a "standard" (forward
627     simulator) executable using:</para>
628 edhill 1.3
629     <screen>
630 edhill 1.5 $ make CLEAN
631     $ make depend
632     $ make
633 edhill 1.3 </screen>
634    
635 edhill 1.4 <para>The "make CLEAN" step will remove any stale source files, include
636     files, and links. It is strongly recommended for "un-clean"
637     directories which may contain the (perhaps partial) results of
638     previous builds. Such "debris" can interfere with the next stage of
639     the build.</para>
640    
641     <para>The "make depend" step will create a large number of symbolic
642     links from the local directory to the source file locations. It also
643     parses these files and creates an extensive list of dependencies
644     within the <filename>Makefile</> itself. The links that exist at this
645     stage are mostly "large F" files (*.F and *.F90) that need to be
646     processed by a C preprocessor ("CPP"). Since "make depend" edits the
647     <filename>Makefile</>, it is important not to skip this step!</para>
648    
649     <para>The final "make" invokes the C preprocessor to produce the "little
650     f" files (*.f and *.f90) and then compiles them to object code using
651     the specified FORTRAN compiler and options. An intermediate script is
652     often used during this stage to further process (usually, make simple
653     substitutions) custom definitions such as variable types within the
654     source files. This additional stage is necessary in order to overcome
655     some of the inconsistencies in the sizes of objects (bytes) between
656 edhill 1.5 different compilers. The result of the build process is an executable
657     with the name <filename>mitgcmuv</>.</para>
658    
659     <para>In addition to the forward simulator described above, the
660     <filename>Makefile</> also has a number of targets that can be used to
661     produce various adjoint and tangent-linear builds for optimization and
662     other parameter-sensitivity problems. The additional targets within
663     the <filename>Makefile</> are:</para>
664    
665     <variablelist>
666    
667     <varlistentry>
668     <term><filename>make adall</></term>
669     <listitem>
670     <para>This target produces an <filename>mitgcmuv_ad</> executable
671     using the <filename>taf</> or <filename>staf</> adjoint
672     compiler. See the <filename>genmake2</> "-adof" option for
673     compiler selection.</para>
674     </listitem>
675     </varlistentry>
676    
677     <varlistentry>
678     <term><filename>make ftlall</></term>
679     <listitem>
680     <para>Similar to <filename>make adall</> above, this
681     produces...</para>
682     </listitem>
683     </varlistentry>
684    
685     </variablelist>
686 edhill 1.3
687 edhill 1.5 <para>Please report any compilation failures or other build problems to
688     the <email>MITgcm-support@mitgcm.org</email> list.</para>
689 edhill 1.3
690     </sect3>
691    
692     </sect2>
693    
694     <sect2 id="verification">
695     <title>The Verification Suite</title>
696    
697 edhill 1.4 <para>The MITgcm CVS tree (within the <filename>$ROOTDIR/verification/</>
698     directory) includes more than a dozen examples intended for regression
699     testing. Each one of these example directories contains "known-good"
700     output files along with all the input (including both code and data
701     files) required for their re-calculation. These example directories are
702     further broken down into sets of subdirectories
703     (eg. <filename>/input</>, <filename>/code</>) intended to expedite the
704     testing process.</para>
705 edhill 1.3
706     <sect3 id="testreport">
707     <title>The <filename>testreport</> Utility</title>
708    
709 edhill 1.4 <para>Also included in <filename>$ROOTDIR/verification/</> are shell
710     scripts for automated testing. The newest script (which was written
711     to work with <filename>genmake2</>) is called <filename>testreport</>.
712     This script can be used to build different versions of the MITgcm
713     code, run the various examples, compare the output, and (if specified)
714     email the results of each one of these tests to a central
715     repository.</para>
716    
717     <para>On some systems, the testreport script can be run with a command
718     line as simple as:</para>
719    
720     <screen>
721 edhill 1.5 $ cd verification
722     $ ./testreport -ieee
723 edhill 1.4 </screen>
724    
725     <para>However, some systems (those lacking or wiht a broken "/bin/sh")
726     may require an explicit shell invocation such as:</para>
727    
728     <screen>
729 edhill 1.5 $ sh ./testreport -ieee -t 'exp0 exp4'
730     $ /some/path/to/bash ./testreport -ieee -t 'ideal_2D_oce lab_sea natl_box'
731 edhill 1.4 </screen>
732 edhill 1.3
733     <para>The <filename>testreport</> script accepts a number of
734 edhill 1.4 command-line options which can be listed using the <filename>-help</>
735     option. The most important ones are:</para>
736 edhill 1.3
737     <variablelist>
738    
739     <varlistentry>
740 edhill 1.4 <term><filename>-ieee</></term>
741     <listitem>
742     <para>If allowed by the compiler (as defined in the "optfile"),
743     use IEEE arithmetic. This option, along with the GCC compiler,
744     is how the standard results were produced.</para>
745     </listitem>
746     </varlistentry>
747    
748     <varlistentry>
749 edhill 1.3 <term><filename>-tdir TESTDIR</></term>
750     <term><filename>-tdir 'TDIR1 TDIR2 [...]'</></term>
751     <listitem>
752 edhill 1.4 <para>This option specifies the test directory or list of test
753     directories that should be used. Each of these entries should
754     exactly (note: they are case sensitive!) match the names of
755     directries in <filename>$ROOTDIR/verification/</>. If this
756     option is omitted, then all directories that are properly
757     formatted (that is, containing an <filename>input</>
758     sub-directory and a <filename>results/output.txt</> file) will
759     be used.</para>
760 edhill 1.3 </listitem>
761     </varlistentry>
762    
763     <varlistentry>
764     <term><filename>-optfile=/PATH/FILENAME</></term>
765     <term><filename>-optfile '/PATH/F1 [/PATH/F2 ...]'</></term>
766     <listitem>
767 edhill 1.4 <para>This specifies a list of "options files" that will be passed
768     to <filename>genmake2</>. If multiple options files are used
769     (say, to test different compilers or different sets of options
770     for the same compiler), then each options file will be used with
771     each of the test directories.</para>
772 edhill 1.3 </listitem>
773     </varlistentry>
774    
775     <varlistentry>
776     <term><filename>-addr EMAIL</></term>
777     <term><filename>-addr 'EMAIL1 EMAIL2 [...]'</></term>
778     <listitem>
779     <para>Send the results (namely, <filename>output.txt</>,
780 edhill 1.4 <filename>genmake_local</>, <filename>genmake_state</>, and
781     <filename>Makefile</>) to the specified email addresses. The
782     results are gzipped, placed in a tar file, MIME encoded, and
783     sent to the specified address. If no email addresses are
784     specified, no mail is sent.</para>
785     </listitem>
786     </varlistentry>
787    
788     <varlistentry>
789     <term><filename>-mpi</></term>
790     <listitem>
791     <para>If the necessary files
792     (<filename>TESTDIR/code/CPP_EEOPTIONS.h_mpi</> and
793     <filename>TESTDIR/code/SIZE.h_mpi</>) exist, then use them for an
794     MPI--enabled run. Note that the use of MPI typically requires a
795     special command option (see "-command" below) to invoke the MPI
796     executable. Examples of PBS scripts using MPI with testreport can be
797     found in the <ulink
798 jmc 1.10 url="http://mitgcm.org/viewvc/MITgcm/MITgcm_contrib/test_scripts/">
799 edhill 1.4 MITgcm-contrib area</ulink></para>
800     </listitem>
801     </varlistentry>
802    
803     <varlistentry>
804     <term><filename>-command='some command to run'</></term>
805     <listitem>
806     <para>For some tests, particularly MPI runs, the default "make
807     output.txt" is not sufficient. This option allows a more general
808     command (or shell script) to be invoked. Examples of PBS scripts
809     using MPI with testreport can be found in the <ulink
810 jmc 1.10 url="http://mitgcm.org/viewvc/MITgcm/MITgcm_contrib/test_scripts/">
811 edhill 1.4 MITgcm-contrib area</ulink></para>
812 edhill 1.3 </listitem>
813     </varlistentry>
814    
815     </variablelist>
816    
817 edhill 1.4 <para>The <filename>testreport</> script will write progress to the
818     screen (stdout) as it runs. In addition, it will create a
819     <filename>tr_out.txt</> file that contains a brief comparison of the
820     current output with the "known-good" output.</para>
821 edhill 1.3
822     </sect3>
823    
824     </sect2>
825 edhill 1.2
826 edhill 1.4
827 edhill 1.2 <sect2 id="packages">
828 edhill 1.3 <title>Creating MITgcm Packages</title>
829 edhill 1.2
830 edhill 1.4 <para>Optional parts of code have been separated from the MITgcmUV core
831     driver code and organised into packages. The packaging structure
832     provides a mechanism for maintaining suites of code, specific to
833     particular classes of problems, in a way that is cleanly separated from
834     the generic fluid dynamical engine.</para>
835    
836     <para>The MITgcmUV packaging structure is described below using generic
837     package names ${pkg}. A concrete examples of a package is the code for
838     implementing GM/Redi mixing. This code uses the package name</para>
839 edhill 1.2
840     </sect2>
841    
842     </sect1>
843    
844     <sect1>
845     <title>Chris's Notes...</title>
846    
847     <programlisting>
848     MITgcmUV Packages
849     =================
850    
851     Optional parts of code are separated from
852     the MITgcmUV core driver code and organised into
853     packages. The packaging structure provides a mechanism for
854     maintaining suites of code, specific to particular
855     classes of problem, in a way that is cleanly
856     separated from the generic fluid dynamical engine.
857    
858     The MITgcmUV packaging structure is describe
859     below using generic package names ${pkg}.
860     A concrete examples of a package is the code
861     for implementing GM/Redi mixing. This code uses
862     the package name
863     * ${PKG} = GMREDI
864     * ${pkg} = gmredi
865     * ${Pkg} = gmRedi
866    
867     Package states
868     ==============
869    
870     Packages can be any one of four states, included,
871     excluded, enabled, disabled as follows:
872    
873     included(excluded) compile time state which
874     includes(excludes) package
875     code and routine calls from
876     compilation/linking etc...
877    
878     enabled(disabled) run-time state which
879     enables(disables) package code
880     execution.
881    
882     Every call to a ${pkg}_... routine from outside the package
883     should be placed within both a
884     #ifdef ALLOW_${PKG} ... block and a
885     if ( use${Pkg} ) ... then block.
886     Package states are generally not expected to change during
887     a model run.
888    
889     Package structure
890     =================
891    
892     o Each package gets its runtime configuration
893     parameters from a file named "data.${pkg}"
894     Package runtime config. options are imported
895     into a common block held in a header file
896     called "${PKG}.h".
897 jmc 1.8 Note: In some packages, the header file "${PKG}.h" is splitted
898     into "${PKG}_PARAMS.h" that contains the package parameters and
899     ${PKG}_VARS.h" for the field arrays.
900 edhill 1.2
901     o The core driver part of the model can check
902     for runtime enabling or disabling of individual packages
903     through logical flags use${Pkg}.
904     The information is loaded from a
905     global package setup file called "data.pkg".
906     The use${Pkg} flags are not used within
907     individual packages.
908    
909     o Included in "${PKG}.h" is a logical flag
910     called ${Pkg}IsOn. The "${PKG}.h" header file can be imported
911     by other packages to check dependencies and requirements
912     from other packages ( see "Package Boot Sequence" section).
913     NOTE: This procedure is not presently implemented,
914     ----- neither for kpp nor for gmRedi.
915    
916     CPP Flags
917     =========
918    
919     1. Within the core driver code flags of the form
920     ALLOW_${PKG} are used to include or exclude
921     whole packages. The ALLOW_${PKG} flags are included
922 jmc 1.8 from a PACKAGES_CONFIG.h file that is automatically
923     generated by genmake2 (see genmake2 section).
924 edhill 1.2 held in-line in the CPP_OPTIONS.h header file.
925     e.g.
926    
927     Core model code .....
928    
929 jmc 1.8 #include "PACKAGES_CONFIG.h"
930 edhill 1.2 #include "CPP_OPTIONS.h"
931     :
932     :
933     :
934    
935     #ifdef ALLOW_${PKG}
936     if ( use${Pkg} ) CALL ${PKG}_DO_SOMETHING(...)
937     #endif
938    
939     2. Within an individual package a header file,
940     "${PKG}_OPTIONS.h", is used to set CPP flags
941 jmc 1.8 specific to that package. It also includes
942     "PACKAGES_CONFIG.h" and "CPP_OPTIONS.h".
943 edhill 1.2
944    
945     Package Boot Sequence
946     =====================
947    
948     Calls to package routines within the core code timestepping
949     loop can vary. However, all packages follow a required
950     "boot" sequence outlined here:
951    
952     1. S/R PACKAGES_BOOT()
953     :
954     CALL OPEN_COPY_DATA_FILE( 'data.pkg', 'PACKAGES_BOOT', ... )
955    
956    
957     2. S/R PACKAGES_READPARMS()
958     :
959     #ifdef ALLOW_${PKG}
960     if ( use${Pkg} )
961     & CALL ${PKG}_READPARMS( retCode )
962     #endif
963    
964 jmc 1.6 3. S/R PACKAGES_INIT_FIXED()
965     :
966     #ifdef ALLOW_${PKG}
967     if ( use${Pkg} )
968     & CALL ${PKG}_INIT_FIXED( retCode )
969     #endif
970    
971     4. S/R PACKAGES_CHECK()
972 edhill 1.2 :
973     #ifdef ALLOW_${PKG}
974     if ( use${Pkg} )
975     & CALL ${PKG}_CHECK( retCode )
976     #else
977     if ( use${Pkg} )
978     & CALL PACKAGES_CHECK_ERROR('${PKG}')
979     #endif
980    
981 jmc 1.6 5. S/R PACKAGES_INIT_VARIABLES()
982 edhill 1.2 :
983     #ifdef ALLOW_${PKG}
984     if ( use${Pkg} )
985 jmc 1.6 & CALL ${PKG}_INIT_VARIA( )
986     #endif
987    
988     Package Output
989     ==============
990     6. S/R DO_THE_MODEL_IO
991    
992     #ifdef ALLOW_${PKG}
993     if ( use${Pkg} )
994 jmc 1.9 & CALL ${PKG}_OUTPUT( )
995 edhill 1.2 #endif
996    
997 jmc 1.6 7. S/R PACKAGES_WRITE_PICKUP()
998    
999     #ifdef ALLOW_${PKG}
1000     if ( use${Pkg} )
1001     & CALL ${PKG}_WRITE_PICKUP( )
1002     #endif
1003 edhill 1.2
1004     Description
1005     ===========
1006    
1007     - ${PKG}_READPARMS()
1008     is responsible for reading
1009     in the package parameters file data.${pkg}, and storing
1010 jmc 1.8 the package parameters in "${PKG}.h" (or in "${PKG}_PARAMS.h").
1011 jmc 1.6 -> called from INITIALISE_FIXED in PACKAGES_READPARMS
1012    
1013     - ${PKG}_INIT_FIXED()
1014     is responsible for completing the internal setup of a package.
1015     -> called from INITIALISE_FIXED in PACKAGES_INIT_FIXED
1016     note: 1) some pkg use instead:
1017     CALL ${PKG}_INITIALISE ( or the old form CALL ${PKG}_INIT )
1018     2) for simple pkg setup, this part is done inside ${PKG}_READPARMS
1019 edhill 1.2
1020     - ${PKG}_CHECK()
1021     is responsible for validating
1022     basic package setup and inter-package dependencies.
1023     ${PKG}_CHECK can import other package parameters it may
1024     need to check. This is done through header files "${PKG}.h".
1025     It is assumed that parameters owned by other packages
1026     will not be reset during ${PKG}_CHECK().
1027 jmc 1.6 -> called from INITIALISE_FIXED in PACKAGES_CHECK
1028 edhill 1.2
1029 jmc 1.6 - ${PKG}_INIT_VARIA()
1030     is responsible for fill-in all package variables with an initial value.
1031     Contains eventually a call to ${PKG}_READ_PICKUP that will read
1032     from a pickup file the package variables required to restart the model.
1033     This routine is called after the core model state has been completely
1034     initialised but before the core model timestepping starts.
1035     -> called from INITIALISE_VARIA in PACKAGES_INIT_VARIABLES
1036     note: the name ${PKG}_INIT_VARIA is not yet standard and some pkg
1037     use for e.g. ${PKG}_INI_VARS, ${PKG}_INIT_VARIABLES, or the old
1038     form ${PKG}_INIT
1039    
1040 jmc 1.9 - ${PKG}_OUTPUT( )
1041 jmc 1.8 is responsible for writing time-average fields to output files
1042     (but the cumulating step is done within the package main S/R).
1043 jmc 1.6 Can also contain other diagnostics (.e.g. CALL ${PKG}_MONITOR)
1044     and write snap-shot fields that are hold in common blocks. Other
1045     temporary fields are directly dump to file where they are available.
1046 jmc 1.9 NOTE: 1) the S/R old name ${PKG}_DIAGS is used in some packages
1047     but is beeing replaced by ${PKG}_OUTPUT
1048 jmc 1.8 to avoid confusion with pkg/diagnostics functionality.
1049     2) the output part is not yet in a standard form and might still
1050     evolve a lot.
1051 jmc 1.6 -> called within DO_THE_MODEL_IO
1052    
1053     - ${PKG}_WRITE_PICKUP()
1054     is responsible for writing a package pickup file when necessary for
1055     a restart. (found also the old name: ${PKG}_WRITE_CHECKPOINT )
1056     -> called from FORWARD_STEP and THE_MODEL_MAIN in PACKAGES_WRITE_PICKUP
1057 edhill 1.2
1058     Summary
1059     =======
1060    
1061     - CPP options:
1062     -----------------------
1063     * ALLOW_${PKG} include/exclude package for compilation
1064    
1065     - FORTRAN logical:
1066     -----------------------
1067     * use${Pkg} enable package for execution at runtime
1068     -> declared in PARAMS.h
1069     * ${Pkg}IsOn for package cross-dependency check
1070     -> declared in ${PKG}.h
1071     N.B.: Not presently used!
1072    
1073     - header files
1074     -----------------------
1075     * ${PKG}_OPTIONS.h has further package-specific CPP options
1076     * ${PKG}.h package-specific common block variables, fields
1077 jmc 1.8 or ${PKG}_PARAMS.h package-specific common block parameters
1078     and ${PKG}_VARS.h package-specific common block fields
1079 edhill 1.2
1080     - FORTRAN source files
1081     -----------------------
1082 jmc 1.6 * ${pkg}_readparms.F reads parameters from file data.${pkg}
1083     * ${pkg}_init_fixed.F complete the package setup
1084     * ${pkg}_check.F checks package dependencies and consistencies
1085     * ${pkg}_init_varia.F initialises package-related fields
1086     * ${pkg}_... .F package source code
1087 jmc 1.9 * ${pkg}_output.F write output to file.
1088 jmc 1.6 * ${pkg}_write_pickup.F write a package pickup file to restart the model
1089 edhill 1.2
1090 jmc 1.8 New: Subroutine in one package (pkgA) that only contains code which
1091     is connected to a 2nd package (pkgB) (e.g.: gmredi_diagnostics_init.F)
1092     will be named: pkgA_pkgB_something.F
1093    
1094 edhill 1.2 - parameter file
1095     -----------------------
1096     * data.${pkg} parameter file
1097     </programlisting>
1098    
1099     </sect1>
1100 edhill 1.1
1101    
1102     </article>
1103    
1104    

  ViewVC Help
Powered by ViewVC 1.1.22