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

Diff of /MITgcm/doc/devel_HOWTO.sgml

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

revision 1.2 by edhill, Wed Aug 20 19:47:14 2003 UTC revision 1.10 by jmc, Thu Jan 21 23:59:17 2010 UTC
# Line 2  Line 2 
2    
3  <article id="MITgcm-Development-HOWTO">  <article id="MITgcm-Development-HOWTO">
4    
 <!--  
 Build commands:  
   db2ps -d ldp.dsl devel_HOWTO.sgml  
   db2pdf -d ldp.dsl devel_HOWTO.sgml  
   db2html -d ./ldp.dsl devel_HOWTO.sgml  
   db2html -u -d ./ldp.dsl devel_HOWTO.sgml  
 -->  
   
5    <articleinfo>    <articleinfo>
6      <title>MITgcm Development HOWTO</title>      <title>MITgcm Development HOWTO</title>
7    
# Line 30  Build commands: Line 22  Build commands:
22            Initial version.            Initial version.
23          </revremark>          </revremark>
24        </revision>        </revision>
25          <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      </revhistory>      </revhistory>
34    
35      <abstract>      <abstract>
# Line 45  Build commands: Line 45  Build commands:
45      <sect2>      <sect2>
46        <title>New Versions of This Document</title> <para>You can        <title>New Versions of This Document</title> <para>You can
47        obtain the latest version of this document <ulink        obtain the latest version of this document <ulink
48        url="http://mitgcm.org/dev_docs/devel_HOWTO/">online</ulink> in        url="http://mitgcm.org/public/docs.html">online</ulink> in
49        various formats.</para>        various formats.</para>
50      </sect2>      </sect2>
51      <sect2>      <sect2>
# Line 63  Build commands: Line 63  Build commands:
63      <sect2>      <sect2>
64        <title>User Manual</title>        <title>User Manual</title>
65    
66        <para>Before jumping into        <para>Before jumping into development, please familiarize yourself with
67        development, please familiarize yourself with the MITgcm user          the <ulink url="http://mitgcm.org/public/docs.html"> MITgcm user manual
68        manual which is available <ulink          </ulink>.  This document contains volumes of useful information and is
69        url="http://mitgcm.org/">on the main web page</ulink>.  This          included here by reference.</para>
       document contains volumes of useful information and is included  
       here by reference.</para>  
70    
71        <para>Also, a "snapshot" or<ulink        <!--
72          <para>Also, a "snapshot" or <ulink
73        url="http://mitgcm.org/dev_docs/">development version</ulink> of        url="http://mitgcm.org/dev_docs/">development version</ulink> of
74        the user manual may be available, though this is only put on the        the user manual may be available, though this is only put on the
75        web for testing purposes.</para>        web for testing purposes.</para>
76          -->
77      </sect2>      </sect2>
78    
79      <sect2>      <sect2>
# Line 128  Build commands: Line 128  Build commands:
128         doc                      tags -- connect to real docs?         doc                      tags -- connect to real docs?
129         eesupp                   cnh?         eesupp                   cnh?
130         exe                      ecco user build         exe                      ecco user build
131      *- jobs                     runtime shell scripts for      ,- jobs                     runtime shell scripts for
132      |                             various platforms      |                             various platforms
133      |  lsopt                    line search      |  lsopt                    line search
134     m|  model                    main dynamics (core)     m|  model                    main dynamics (core)
135     e|    optimization_drivers   ?     e|    optimization_drivers   ?
136     r|  optim                    line search interface     r|  optim                    line search interface
137     g|  pkg                      alternate and optional numerics, etc.     g|  pkg                      alternate and optional numerics, etc.
138     e*- tools     e|- tools
139     ?|  tutorial_examples        documented tests     ?|  tutorial_examples        documented tests
140      |                             only populated on release1 branch      |                             only populated on release1 branch
141      |                             and not validated during "testscript"      |                             and not validated during "testreport"
142      *- utils      '- utils
143         verification             std tests         verification             std tests
144    
145    
# Line 190  Build commands: Line 190  Build commands:
190        <title>Branches</title>        <title>Branches</title>
191    
192        <para>As shown in the online <ulink        <para>As shown in the online <ulink
193        url="http://dev.mitgcm.org/cgi-bin/viewcvs.cgi/MITgcm/doc/tag-index?graph=1.174">ViewCVS-generated        url="http://mitgcm.org/viewvc/MITgcm/MITgcm/doc/tag-index?view=graph">
194        tree</ulink>, the MITgcm codebase is split into to two branches        ViewCVS-generated tree</ulink>, the MITgcm codebase is split into to two
195        or "lines" under which development proceeds.  These two lines        branches or "lines" under which development proceeds.  These two lines are
196        are referred to as the "MAIN" and "ecco" versions of the code.        referred to as the "MAIN" and "ecco" versions of the code.  While not
197        While not identical, the bulk of the MAIN and ecco lines are        identical, the bulk of the MAIN and ecco lines are composed of files from
198        composed of files from the same codebase.        the same codebase.
199        </para>        </para>
200    
201        <para>Periodically, a "Release" branch is formed from the "MAIN"        <para>Periodically, a "Release" branch is formed from the "MAIN"
202        development branch.  This is done in order to create a        development branch.  This is done in order to create a relatively stable
203        relatively stable reference point for both users and developers.        reference point for both users and developers.  The intent is that once a
204        The intent is that once a relese branch has been created, only        relese branch has been created, only bug-fixes will be added to it.
205        bug-fixes will be added to it.  Meanwhile, development (which        Meanwhile, development (which might "break" or otherwise render invalid
206        might "break" or otherwise render invalid the documentation,        the documentation, tutorials, and/or examples contained within a release
207        tutorials, and/or examples contained within a release branch) is        branch) is allowed to continue along the MAIN and ecco lines.</para>
       allowed to continue along the MAIN and ecco lines.</para>  
208      </sect2>      </sect2>
209    
210      <sect2>      <sect2>
211        <title>Tagging</title>        <title>Tagging</title>
212    
213        <para>The intent of tagging is to create "known-good"        <para>The intent of tagging is to create "known-good" checkpoints that
214        checkpoints that developers can use as references.        developers can use as references.  Traditionally, MITgcm tagging has
215        Traditionally, MITgcm tagging has maintained the following        maintained the following conventions:</para>
       conventions:</para>  
216    
217        <orderedlist>        <orderedlist>
218          <listitem>          <listitem>
219            <para>Developer checks out code into a local CVS-managed            <para>Developer checks out code into a local CVS-managed directory,
220            directory, makes various changes/additions, tests these            makes various changes/additions, tests these edits, and eventually
221            edits, and eventually reaches a point where (s)he is            reaches a point where (s)he is satisfied that the changes form a new
222            satisfied that the changes form a new "useful" point in the            "useful" point in the evolution of the code.</para>
           evolution of the code.</para>  
223          </listitem>          </listitem>
224    
225          <listitem>          <listitem>
226            <para>The developer then runs the <ulink            <para>The developer then runs the <ulink
227            url="http://dev.mitgcm.org/cgi-bin/viewcvs.cgi/MITgcm/verification/testscript">testscript</ulink>            url="http://mitgcm.org/viewvc/MITgcm/MITgcm/verification/testreport">
228            shell script to see if any problems are introduced.  While            testreport</ulink> shell script to see if any problems are introduced.
229            not intended to be exhaustive, the test cases within the            While not intended to be exhaustive, the test cases within the
230            verification directory do provide some indication whether            verification directory do provide some indication whether gross errors
231            gross errors have been introduced.            have been introduced.
232            </para>            </para>
233          </listitem>          </listitem>
234    
# Line 241  Build commands: Line 238  Build commands:
238            then:</para>            then:</para>
239            <orderedlist>            <orderedlist>
240              <listitem>              <listitem>
241                <para>adds a "checkpointXY_pre" comment (where X is a                <para>adds a "checkpointXY_pre" comment (where X is a checkpoint
242                checkpoint number and Y is a letter) to the <ulink                number and Y is a letter) to the <ulink
243                url="http://dev.mitgcm.org/cgi-bin/viewcvs.cgi/MITgcm/doc/tag-index">tag-index</ulink>                url="http://mitgcm.org/viewvc/MITgcm/MITgcm/doc/tag-index">
244                file and checks it into the CVS repository</para>                tag-index</ulink> file and checks it into the CVS
245                  repository</para>
246              </listitem>              </listitem>
247              <listitem>              <listitem>
248                <para>submits the set of changes to the CVS repository                <para>submits the set of changes to the CVS repository and adds
249                and adds comments to <filename>tag-index</filename>                comments to <filename>tag-index</filename> describing what the
250                describing what the changes are along with a matching                changes are along with a matching "checkpointXY_post" entry</para>
               "checkpointXY_post" entry</para>  
251              </listitem>              </listitem>
252            </orderedlist>            </orderedlist>
253          </listitem>          </listitem>
254        </orderedlist>        </orderedlist>
255    
256        <para>The result of this tagging procedure is a sequence of        <para>The result of this tagging procedure is a sequence of development
257        development checkpoints with comments which resembles:</para>        checkpoints with comments which resembles:</para>
258    
259  <programlisting>  <programlisting>
260  checkpoint50e_post  checkpoint50e_post
# Line 279  o fix small problem with in ptracers_wri Line 276  o fix small problem with in ptracers_wri
276  checkpoint50d_pre  checkpoint50d_pre
277  </programlisting>  </programlisting>
278    
279        <para>This information can be used to refer to various stages of        <para>This information can be used to refer to various stages of the code
280        the code development.  For example, bugs can be traced to        development.  For example, bugs can be traced to individual sets of CVS
281        individual sets of CVS checkins based upon their first        checkins based upon their first appearance when comparing the results from
282        appearance when comparing the results from different        different checkpoints.</para>
       checkpoints.</para>  
283    
284      </sect2>      </sect2>
285    </sect1>    </sect1>
# Line 295  checkpoint50d_pre Line 291  checkpoint50d_pre
291      <sect2 id="documentation_getting">      <sect2 id="documentation_getting">
292        <title>Getting the Docs and Code</title>        <title>Getting the Docs and Code</title>
293    
294        <para>The first step towards editing the documentation is to        <para>The first step towards editing the documentation is to checkout a
295        checkout a copy of code, docs, and build scripts from the CVS        copy of code, docs, and build scripts from the CVS server using:</para>
       server using:</para>  
296    
297  <screen>  <screen>
298  $ export CVS_RSH=ssh    $ export CVS_RSH=ssh
299  $ export CVSROOT=':ext:auden.lcs.mit.edu:/u/u3/gcmpack'    $ export CVSROOT=':ext:NAME@mitgcm.org:/u/gcmpack'
300  $ mkdir scratch    $ mkdir scratch
301  $ cvs co MITgcm manual mitgcm.org    $ cvs co -P MITgcm manual mitgcm.org
302  </screen>  </screen>
303    
304        <para>These commands extract the necessary information from the        <para>These commands extract the necessary information from the CVS server
305        CVS server and create a temporary (called        and create a temporary (called <filename>scratch</filename>) directory for
306        <filename>scratch</filename>) directory for the storage of the        the storage of the HTML and other files that will be created.  Please note
307        HTML and other files that will be created.  Please note that you        that you must either create <filename>scratch</filename> as shown or edit
308        must either create <filename>scratch</filename> as shown or edit        the various <filename>Makefile</filename>s and scripts used to create the
309        the various <filename>Makefile</filename>s and scripts used to        documentation.</para>
       create the documentation.</para>  
310      </sect2>      </sect2>
311    
312      <sect2>      <sect2>
313        <title>Editing</title>        <title>Editing the Documentation</title>
314    
315        <para>The documentation is contained in the        <para>The documentation is contained in the <filename>manual</filename>
316        <filename>manual</filename> directory in a raw LaTeX format.        directory in a raw LaTeX format.  The main document is
317        The main document is <filename>manual.tex</filename> and it uses        <filename>manual.tex</filename> and it uses <command>\input{}</command>s
318        <command>\input{}</command>s to include the chapters and        to include the chapters and subsections.</para>
319        subsections.</para>  
320          <para>Since the same LaTeX source is used to produce PostScript, PDF, and
321        <para>Since the same LaTeX source is used to produce PostScript,        HTML output, care should be taken to follow certain conventions.  Two of
322        PDF, and HTML output, care should be taken to follow certain        the most important are the usage of the <command>\filelink{}{}</command>
323        conventions.  Two of the most important are the usage of the        and <command>\varlink{}{}</command> commands.  Both of these commands have
324        <command>\filelink{}{}</command> and        been defined to simplify the connection between the automatically
325        <command>\varlink{}{}</command> commands.  Both of these        generated ("code browser") HTML and the HTML version of the manual
326        commands have been defined to simplify the connection between        produced by LaTeX2HTML.  They each take two arguments (corresponding to
327        the automatically generated ("code browser") HTML and the HTML        the contents of the two sets of curly braces) which are the text that the
328        version of the manual produced by LaTeX2HTML.  They each take        author wishes to be "wrapped" within the link, and a specially formatted
329        two arguments (corresponding to the contents of the two sets of        link thats relative to the <filename>MITgcm</filename> directory within
330        curly braces) which are the text that the author wishes to be        the CVS tree.</para>
       "wrapped" within the link, and a specially formatted link thats  
       relative to the <filename>MITgcm</filename> directory within the  
       CVS tree.</para>  
331    
332        <para>The result is a command that resembles either</para>        <para>The result is a command that resembles either</para>
333                
# Line 364  $ cvs co MITgcm manual mitgcm.org Line 355  $ cvs co MITgcm manual mitgcm.org
355      </sect2>      </sect2>
356    
357      <sect2>      <sect2>
358        <title>Building</title> <para>Given the directory structure of        <title>Building the Documentation</title>
359        <xref linkend="documentation_getting">, the entire documentation        
360        for the web site can be built using:</para>        <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    
364  <screen>  <screen>
365  $ cd mitgcm.org/devel/buildweb    $ cd mitgcm.org/devel/buildweb
366  $ make All    $ make All
367  </screen>  </screen>
368    
369        <para>Which builds the PDF from the LaTeX source, creates the        <para>Which builds the PDF from the LaTeX source, creates the HTML output
370        HTML output from the LaTeX source, parses the FORTRAN code base        from the LaTeX source, parses the FORTRAN code base to produce a
371        to produce a hyperlinked HTML version of the source, and then        hyperlinked HTML version of the source, and then determines the
372        determines the cross-linking between the various HTML        cross-linking between the various HTML components.</para>
373        components.</para>  
374          <para>If there are no errors, the result of the build process (which can
375        <para>If there are no errors, the result of the build process        take 30+ minutes on a P4/2.5Ghz) will be contained within a single
376        (which can take 30+ minutes on a P4/2.5Ghz) will be contained        directory called <filename>scratch/dev_docs</filename>.  This is a freshly
377        within a single directory called        built version of the entire on-line users manual.  If you have the correct
378        <filename>scratch/dev_docs</filename>.  This is a freshly built        permissions, it can be directly copied to the web server area:</para>
       version of the entire on-line users manual.  If you have the  
       correct permissions, it can be directly copied to the web server  
       area:</para>  
379    
380  <screen>  <screen>
381  $ mv scratch/dev_docs /u/u0/httpd/html    $ mv scratch/dev_docs /u/u0/httpd/html
382  </screen>  </screen>
383    
384        <para>and the update is complete.</para>        <para>and the update is complete.</para>
# Line 398  $ mv scratch/dev_docs /u/u0/httpd/html Line 388  $ mv scratch/dev_docs /u/u0/httpd/html
388    </sect1>    </sect1>
389    
390    <sect1 id="coding">    <sect1 id="coding">
391      <title>Coding</title>      <title>Coding for MITgcm</title>
392    
393        <sect2 id="build_tools">
394          <title>Build Tools</title>
395    
396          <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    
402    <screen>
403      $ genmake -mods=../code
404      $ make depend
405      $ make
406    </screen>
407    
408          <para>The following sections describe the individual steps in the build
409            process.</para>
410          
411          <sect3 id="genmake">
412            <title>The <filename>genmake2</> Utility</title>
413    
414            <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    
424            <itemizedlist>
425              <listitem>
426                <para><ulink url="http://www.gnu.org/software/make/make.html">
427                    http://www.gnu.org/software/make/make.html</></para>
428              </listitem>
429              <listitem>
430                <para><ulink url="http://www.oreilly.com/catalog/make2/">
431                    http://www.oreilly.com/catalog/make2/</></para>
432              </listitem>
433            </itemizedlist>
434    
435            <para>Genmake can often be invoked successfully with a command line as
436            simple as:</para>
437    
438    <screen>
439      $ genmake2 -mods=../code
440    </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      $ /usr/bin/sh genmake2 -make=gmake  -mods=../code
449      $ /opt/gnu/bin/bash genmake2 -ieee -make=/usr/local/bin/gmake -mods=../code
450    </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    
460            <orderedlist>
461              <listitem>
462                <para>a <filename>gemake_local</filename> file in the current
463                  directory</para>
464              </listitem>
465              <listitem>
466                <para>directly from command-line options</para>
467              </listitem>
468              <listitem>
469                <para>an "options file" as specified by the command-line option
470                  <filename>-optfile='FILENAME'</filename></para>
471              </listitem>
472            </orderedlist>
473    
474            <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    
481    <screen>
482      $ genmake2 -help
483    </screen>
484    
485            <para>The most important options for <filename>genmake2</> are:</para>
486    
487            <variablelist>
488    
489              <varlistentry>
490                <term><filename>--optfile=/PATH/FILENAME</></term>
491    
492                <listitem>
493                  <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                </listitem>
521    
522              </varlistentry>
523    
524              <varlistentry>
525                <term><filename>-pdepend=/PATH/FILENAME</></term>
526    
527                <listitem>
528                  <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                </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                <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                <term><filename>-mods=DIR</></term>
571                <term><filename>-mods='DIR1 [DIR2 ...]'</></term>
572                <listitem>
573                  <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                </listitem>
605              </varlistentry>
606    
607            </variablelist>
608            
609            <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    
620          </sect3>
621    
622          <sect3 id="makefile_use">
623            <title>Using the <filename>Makefile</></title>
624    
625            <para>Once a <filename>Makefile</> has been created using
626              <filename>genmake2</>, one can build a "standard" (forward
627              simulator) executable using:</para>
628    
629    <screen>
630      $ make CLEAN
631      $ make depend
632      $ make
633    </screen>
634    
635            <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              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    
687            <para>Please report any compilation failures or other build problems to
688              the <email>MITgcm-support@mitgcm.org</email> list.</para>
689    
690          </sect3>
691    
692        </sect2>
693    
694        <sect2 id="verification">
695          <title>The Verification Suite</title>
696    
697          <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    
706          <sect3 id="testreport">
707            <title>The <filename>testreport</> Utility</title>
708    
709            <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      $ cd verification
722      $ ./testreport -ieee
723    </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      $ sh ./testreport -ieee -t 'exp0 exp4'
730      $ /some/path/to/bash ./testreport -ieee -t 'ideal_2D_oce lab_sea natl_box'
731    </screen>
732    
733            <para>The <filename>testreport</> script accepts a number of
734              command-line options which can be listed using the <filename>-help</>
735              option.  The most important ones are:</para>
736    
737            <variablelist>
738    
739              <varlistentry>
740                <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                <term><filename>-tdir TESTDIR</></term>
750                <term><filename>-tdir 'TDIR1 TDIR2 [...]'</></term>
751                <listitem>
752                  <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                </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                  <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                </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                    <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                  url="http://mitgcm.org/viewvc/MITgcm/MITgcm_contrib/test_scripts/">
799                  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                  url="http://mitgcm.org/viewvc/MITgcm/MITgcm_contrib/test_scripts/">
811                  MITgcm-contrib area</ulink></para>
812                </listitem>
813              </varlistentry>
814    
815            </variablelist>
816    
817            <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    
822          </sect3>
823    
824        </sect2>
825    
826    
827      <sect2 id="packages">      <sect2 id="packages">
828        <title>Coding Packages</title>        <title>Creating MITgcm Packages</title>
829    
830        <para>Optional parts of code have been separated from the MITgcmUV        <para>Optional parts of code have been separated from the MITgcmUV core
831        core driver code and organised into packages. The packaging          driver code and organised into packages.  The packaging structure
832        structure provides a mechanism for maintaining suites of code,          provides a mechanism for maintaining suites of code, specific to
833        specific to particular classes of problems, in a way that is          particular classes of problems, in a way that is cleanly separated from
834        cleanly separated from the generic fluid dynamical          the generic fluid dynamical engine.</para>
835        engine.</para>  
836          <para>The MITgcmUV packaging structure is described below using generic
837        <para>The MITgcmUV packaging structure is described below using          package names ${pkg}.  A concrete examples of a package is the code for
838        generic package names ${pkg}.  A concrete examples of a package          implementing GM/Redi mixing. This code uses the package name</para>
       is the code for implementing GM/Redi mixing. This code uses the  
       package name</para>  
839    
840      </sect2>      </sect2>
841    
# Line 472  o  Each package gets its runtime configu Line 894  o  Each package gets its runtime configu
894     Package runtime config. options are imported     Package runtime config. options are imported
895     into a common block held in a header file     into a common block held in a header file
896     called "${PKG}.h".     called "${PKG}.h".
897       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    
901  o  The core driver part of the model can check  o  The core driver part of the model can check
902     for runtime enabling or disabling of individual packages     for runtime enabling or disabling of individual packages
# Line 494  CPP Flags Line 919  CPP Flags
919      1. Within the core driver code flags of the form      1. Within the core driver code flags of the form
920         ALLOW_${PKG} are used to include or exclude         ALLOW_${PKG} are used to include or exclude
921         whole packages. The ALLOW_${PKG} flags are included         whole packages. The ALLOW_${PKG} flags are included
922         from a PKG_CPP_OPTIONS block which is currently         from a PACKAGES_CONFIG.h file that is automatically
923           generated by genmake2 (see genmake2 section).
924         held in-line in the CPP_OPTIONS.h header file.         held in-line in the CPP_OPTIONS.h header file.
925         e.g.         e.g.
926    
927         Core model code .....         Core model code .....
928    
929           #include "PACKAGES_CONFIG.h"
930         #include "CPP_OPTIONS.h"         #include "CPP_OPTIONS.h"
931           :           :
932           :           :
# Line 511  CPP Flags Line 938  CPP Flags
938    
939      2. Within an individual package a header file,      2. Within an individual package a header file,
940         "${PKG}_OPTIONS.h", is used to set CPP flags         "${PKG}_OPTIONS.h", is used to set CPP flags
941         specific to that package. It is not recommended         specific to that package. It also includes
942         to include this file in "CPP_OPTIONS.h".         "PACKAGES_CONFIG.h" and "CPP_OPTIONS.h".
943    
944    
945  Package Boot Sequence  Package Boot Sequence
# Line 534  Package Boot Sequence Line 961  Package Boot Sequence
961       &       CALL ${PKG}_READPARMS( retCode )       &       CALL ${PKG}_READPARMS( retCode )
962          #endif          #endif
963    
964      2. S/R PACKAGES_CHECK()      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              :              :
973          #ifdef ALLOW_${PKG}          #ifdef ALLOW_${PKG}
974            if ( use${Pkg} )            if ( use${Pkg} )
# Line 544  Package Boot Sequence Line 978  Package Boot Sequence
978       &       CALL PACKAGES_CHECK_ERROR('${PKG}')       &       CALL PACKAGES_CHECK_ERROR('${PKG}')
979          #endif          #endif
980    
981      3. S/R PACKAGES_INIT()      5. S/R PACKAGES_INIT_VARIABLES()
982              :              :
983          #ifdef ALLOW_${PKG}          #ifdef ALLOW_${PKG}
984            if ( use${Pkg} )            if ( use${Pkg} )
985       &       CALL ${PKG}_INIT( retCode )       &       CALL ${PKG}_INIT_VARIA( )
986          #endif          #endif
987    
988    Package Output
989    ==============
990         6. S/R DO_THE_MODEL_IO
991    
992            #ifdef ALLOW_${PKG}
993              if ( use${Pkg} )
994         &       CALL ${PKG}_OUTPUT( )
995            #endif
996    
997         7. S/R PACKAGES_WRITE_PICKUP()
998    
999            #ifdef ALLOW_${PKG}
1000              if ( use${Pkg} )
1001         &       CALL ${PKG}_WRITE_PICKUP( )
1002            #endif
1003    
1004  Description  Description
1005  ===========  ===========
# Line 558  Description Line 1007  Description
1007        - ${PKG}_READPARMS()        - ${PKG}_READPARMS()
1008      is responsible for reading      is responsible for reading
1009      in the package parameters file data.${pkg}, and storing      in the package parameters file data.${pkg}, and storing
1010      the package parameters in "${PKG}.h".      the package parameters in "${PKG}.h" (or in "${PKG}_PARAMS.h").
1011      -> called in INITIALISE_FIXED      -> 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    
1020       - ${PKG}_CHECK()       - ${PKG}_CHECK()
1021      is responsible for validating      is responsible for validating
# Line 568  Description Line 1024  Description
1024      need to check. This is done through header files "${PKG}.h".      need to check. This is done through header files "${PKG}.h".
1025      It is assumed that parameters owned by other packages      It is assumed that parameters owned by other packages
1026      will not be reset during ${PKG}_CHECK().      will not be reset during ${PKG}_CHECK().
1027      -> called in INITIALISE_FIXED      -> called from INITIALISE_FIXED in PACKAGES_CHECK
1028    
1029       - ${PKG}_INIT()       - ${PKG}_INIT_VARIA()
1030      is responsible for completing the      is responsible for fill-in all package variables with an initial value.
1031      internal setup of a package. This routine is called after      Contains eventually a call to ${PKG}_READ_PICKUP that will read
1032      the core model state has been completely initialised      from a pickup file the package variables required to restart the model.
1033      but before the core model timestepping starts.      This routine is called after the core model state has been completely
1034      -> called in INITIALISE_VARIA      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         - ${PKG}_OUTPUT( )
1041         is responsible for writing time-average fields to output files
1042         (but the cumulating step is done within the package main S/R).
1043         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         NOTE: 1) the S/R old name ${PKG}_DIAGS is used in some packages
1047                  but is beeing replaced by ${PKG}_OUTPUT
1048                  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        -> 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    
1058  Summary  Summary
1059  =======  =======
# Line 596  Summary Line 1074  Summary
1074    -----------------------    -----------------------
1075    * ${PKG}_OPTIONS.h     has further package-specific CPP options    * ${PKG}_OPTIONS.h     has further package-specific CPP options
1076    * ${PKG}.h             package-specific common block variables, fields    * ${PKG}.h             package-specific common block variables, fields
1077       or  ${PKG}_PARAMS.h   package-specific common block parameters
1078       and ${PKG}_VARS.h     package-specific common block fields
1079    
1080  - FORTRAN source files  - FORTRAN source files
1081    -----------------------    -----------------------
1082    * ${pkg}_readparms.F   reads parameters from file data.${pkg}    * ${pkg}_readparms.F    reads parameters from file data.${pkg}
1083    * ${pkg}_check.F       checks package dependencies and consistencies    * ${pkg}_init_fixed.F   complete the package setup
1084    * ${pkg}_init.F        initialises package-related fields    * ${pkg}_check.F        checks package dependencies and consistencies
1085    * ${pkg}_... .F        package source code    * ${pkg}_init_varia.F   initialises package-related fields
1086      * ${pkg}_... .F         package source code
1087      * ${pkg}_output.F       write output to file.
1088      * ${pkg}_write_pickup.F write a package pickup file to restart the model
1089    
1090      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  - parameter file  - parameter file
1095    -----------------------    -----------------------

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.22