New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Annex_D.tex in trunk/DOC/TexFiles/Chapters – NEMO

source: trunk/DOC/TexFiles/Chapters/Annex_D.tex @ 994

Last change on this file since 994 was 994, checked in by gm, 16 years ago

trunk - add steven correction + several other things + rename BETA into TexFiles?

  • Property svn:executable set to *
File size: 5.7 KB
Line 
1% ================================================================
2% Appendix D Ñ Coding Rules
3% ================================================================
4\chapter{Coding Rules}
5\label{Apdx_D}
6\minitoc
7
8
9A "model life" is more than ten years. Its software, composed by a few
10hundred modules, is used by many people who are scientists or students and
11do not necessary know very well all computer aspects. Moreover, a well
12thought-out programme is easy to read and understand, less difficult to
13modify, produces fewer bugs and is easier to maintain. Therefore, it is
14essential that the model development follows some rules :
15
16- well planned and designed
17
18- well written
19
20- well documented (both on- and off-line)
21
22- maintainable
23
24- easily portable
25
26- flexible.
27
28To satisfy part of these aims, \NEMO is written with a coding standard which
29is close to the ECMWF rules, named DOCTOR \citep{Gibson_TR86}. These rules present some advantages like :
30
31- to provide a well presented program
32
33- to use rules for variable names which allow recognition of their type
34(integer, real, parameter, local or shared variables, etc. ) so that debugging is
35facilitated.
36
37% ================================================================
38% The program structure
39% ================================================================
40\section{The program structure}
41\label{Apdx_D_structure}
42
43Each program begins with a set of headline comments containing :
44
45- the program title
46
47- the purpose of the routine
48
49- the method and algorithms used
50
51- the detail of input and output interfaces
52
53- the external routines and functions used (if exist)
54
55- references (if exist)
56
57- the author name (s), the date of creation and of updates.
58
59- Each program is splitted into several well separated sections and
60sub-sections with a underlined title and specific labelled statements.
61
62- A program has not more than 200 to 300 lines.
63
64% ================================================================
65% Coding conventions
66% ================================================================
67\section{Coding conventions}
68\label{Apdx_D_coding}
69
70- Use of the universal language \textsc{Fortran} 5 ANSI 77, with non
71standard extensions, NAMELIST and \textsc{Fortran} 90 (matrix resolution
72algorithm), and some well-identified particular statements or functions for
73weak and massive parallelism, and vectorization
74
75- A comment line begins with a uppercase character C at the first column. A
76space line must have a C. For the on-line documentation, comments are
77classified into three levels :
78
79Overview, triggered by CCC in columns 1 to 3. Only the title and the purpose
80of the program are identified like that. This overview documentation can be
81extracted by the UNIX function : grep -e '\^{}CCC' *
82
83External, triggered by CC in columns 1 to 2, and which correspond to
84headlines of each programme, extracted by : grep -e '\^{}CC' *
85
86Internal which are all the comments, extracted by : grep -e '\^{}C' *
87
88- Statements GO TO, EQUIVALENCE are forbidden.
89
90- A section is numbered with labels which are in agreement with the
91paragraph label and increase from the begin to the end of routine. Labels of
92a hundred ( 200, 201.. 220..) are reserved to a unique section. The
93\textsc{Fortran} 90 extension syntax DO/ENDDO is used except for multitasked
94do-loop. In this case labels 1000, 2000, ... are used. The FORMAT statement
95are labelled with numbers in the range 9000 to 9999.
96
97- A continuation line begins with the character {\$} in column 6.
98
99- All statements begin in column 7 with the following gaps :
100
1012 spaces toward the right in a DO loop.
102
1034 spaces toward the right in IF, ELSEIF, ELSE and ENDIF statements, with
104only 2 spaces for ELSE and ELSEIF lines. All IF statement must be followed
105by a ELSE statement.
106
107Some spaces in the continuation line for alignment.
108
109- Use of different labels for each DO loop statement.
110
111- STOP must be well documented with the name of the subroutine or a number.
112
113% ================================================================
114% Naming Conventions
115% ================================================================
116\section{Naming Conventions}
117\label{Apdx_D_naming}
118
119The purpose of the naming conventions is to use prefix letters to classify
120model variables. These conventions allow to know easily the variable type
121and to identify them rapidly:
122
123
124%--------------------------------------------------TABLE--------------------------------------------------
125\begin{table}[htbp]
126\begin{center}
127\begin{tabular}{|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|}
128\hline  Type \par / Status &   integer&   real&   logical &   character&   double \par precision&   complex \\ 
129\hline
130public & 
131\textbf{m n} \par \textit{but not } \par \textbf{nam}& 
132\textbf{a b e f g h o} \textbf{q} \textit{to} \textbf{x} \par but not \par \textbf{sf}& 
133\textbf{l} \par \textit{but not} \par \textbf{lp ld ll}& 
134\textbf{c} \par \textit{but not} \par \textbf{cp cd cl } \par \textbf{com cim}& 
135\textbf{d} \par \textit{but not} \par \textbf{dp dd dl}& 
136\textbf{y} \par \textit{but not} \par \textbf{yp yd yl} \\
137\hline
138dummy \par argument& 
139\textbf{k} \par \textit{but not} \par \textbf{kf}& 
140\textbf{p} \par \textit{but not}  \par \textbf{pp pf}& 
141\textbf{ld}& 
142\textbf{cd}& 
143\textbf{dd}& 
144\textbf{yd} \\
145\hline
146local \par variable& 
147\textbf{i}& 
148\textbf{z}& 
149\textbf{ll}& 
150\textbf{cl}& 
151\textbf{cd}& 
152\textbf{yl} \\
153\hline
154loop \par control& 
155\textbf{j} \par \textit{but not } \par \textbf{jp}& 
156& 
157& 
158& 
159& 
160 \\
161\hline
162parameter& 
163\textbf{jp}& 
164\textbf{pp}& 
165\textbf{lp}& 
166\textbf{cp}& 
167\textbf{dp}& 
168\textbf{yp} \\
169\hline
170statement \par function& 
171\textbf{kf}& 
172\textbf{sf} \par & 
173& 
174& 
175& 
176 \\
177\hline
178\end{tabular}
179\label{tab1}
180\end{center}
181\end{table}
182%--------------------------------------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.