Let us start in the traditional way, with a (sort of) `hello world' program:
<!DOCTYPE programcode PUBLIC "-//Starlink//DTD Fortran Source Code 0.7//EN"> <title>The `hello world' program <codegroup> <title>Group title <description>First test program <routine> <codeopener> subroutine helloworld (language) <routineprologue> <routinename id=hi1> helloworld <description> Greets the world with a sunny hello <argumentlist> <parameter given> <name>language <type>_integer</type> <description>Selects the language to use. 0=english, 1=sanskrit. <authorlist> <author id=ng affiliation='Glasgow'>Norman Gray <codebody> write (*,*) 'ack!' end
This is, obviously, not a compilable Fortran program, but it is a good example, firstly because it displays the structure (which will be a little obscured when we come to consider Fortran programs in Section 5.2.1), and secondly because it could plausibly be the output of some script which extracts documentation from compilable source code files.
As mentioned above, the programcode DTD allow you to make heavy use of SGML tag omission features. As well as the usual such features, the Fortran code DTD allows further abbreviation, and we shall see that the above program could be represented as:
All the material after the<!DOCTYPE programcode PUBLIC "-//Starlink//DTD Fortran Source Code 0.7//EN"> <title>The `hello world' program <codegroup> <title>Group title <description>First test program <routine> <codeopener> subroutine helloworld (language) *+ * <routinename id=hi1> * helloworld * <description> * Greets the world with a sunny hello * <argumentlist> * <parameter given> * language = _integer * Selects the language to use. * 0=english, 1=sanskrit. * <authorlist> * <author id=ng affiliation='Glasgow'>Norman Gray *- write (*,*) 'ack!' end
<codeopener>
start-tag is
compilable Fortran, and might well be read in, using an entity (Section 3.3.2), from the routine source code. The fully
normalised version of this document (modulo a few spaces) is in Figure 4.<programcode><docblock> <title>The `hello world' program</title></docblock> <codegroup><docblock><title>Group title</title> <description><p>First test program</p></description></docblock> <routine> <codeopener> subroutine helloworld (language)</codeopener> <routineprologue> <routinename id="hi1"><name>helloworld</name></routinename> <description><p>Greets the world with a sunny hello</p></description> <argumentlist> <parameter given> <name>language </name> <type> _integer</type> <description><p>Selects the language to use. 0=english, 1=sanskrit.</p> </description></parameter></argumentlist> <authorlist> <author id="ng" affiliation="Glasgow"><name>Norman Gray</name></author> </authorlist></routineprologue> <codebody> write (*,*) 'ack!' end</codebody> </routine></codegroup></programcode> |
Figure 4: A programcode document with all tags in place, the normalised version of the fortrancode document in the text. |