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 tags/nemo_v3_2/nemo_v3_2/DOC/TexFiles/Chapters – NEMO

source: tags/nemo_v3_2/nemo_v3_2/DOC/TexFiles/Chapters/Annex_D.tex @ 1878

Last change on this file since 1878 was 1878, checked in by flavoni, 14 years ago

initial test for nemogcm

File size: 4.5 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 of a few
10hundred modules, is used by many people who are scientists or students
11and do not necessarily know every aspect of computing very well.
12Moreover, a well thought-out program is easier to read and understand,
13less difficult to modify, produces fewer bugs and is easier to maintain.
14Therefore, it is essential 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}.
30These rules present some advantages like :
31
32- to provide a well presented program
33
34- to use rules for variable names which allow recognition of their type
35(integer, real, parameter, local or shared variables, etc. ) so that debugging is
36facilitated.
37
38% ================================================================
39% The program structure
40% ================================================================
41\section{The program structure}
42\label{Apdx_D_structure}
43
44Each program begins with a set of headline comments containing :
45
46- the program title
47
48- the purpose of the routine
49
50- the method and algorithms used
51
52- the detail of input and output interfaces
53
54- the external routines and functions used (if they exist)
55
56- references (if they exist)
57
58- the author name(s), the date of creation and any updates.
59
60- Each program is split into several well separated sections and
61sub-sections with an underlined title and specific labelled statements.
62
63- A program has not more than 200 to 300 lines.
64
65% ================================================================
66% Coding conventions
67% ================================================================
68\section{Coding conventions}
69\label{Apdx_D_coding}
70
71- Use of the universal language \textsc{Fortran} 90, and try to avoid obsolescent
72features like statement functions, do not use GO TO and EQUIVALENCE statements.
73
74- A continuation line begins with the character {\$} indented by three spaces
75compared to the previous line.
76
77- Always use a three spaces indentation in DO loop, CASE, or IF-ELSEIF-ELSE-ENDIF
78statements.
79
80- use call to ctl\_stop routine instead of just a STOP.
81
82% ================================================================
83% Naming Conventions
84% ================================================================
85\section{Naming Conventions}
86\label{Apdx_D_naming}
87
88The purpose of the naming conventions is to use prefix letters to classify
89model variables. These conventions allow the variable type to be easily known
90and rapidly identified:
91
92%--------------------------------------------------TABLE--------------------------------------------------
93\begin{table}[htbp]
94\begin{center}
95\begin{tabular}{|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|}
96\hline  Type \par / Status &   integer&   real&   logical &   character&   double \par precision&   complex \\ 
97\hline
98public  \par or  \par module variable& 
99\textbf{m n} \par \textit{but not } \par \textbf{nn\_}& 
100\textbf{a b e f g h o} \textbf{q} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_}& 
101\textbf{l} \par \textit{but not} \par \textbf{lp ld ll ln\_}& 
102\textbf{c} \par \textit{but not} \par \textbf{cp cd cl cn\_}& 
103\textbf{d} \par \textit{but not} \par \textbf{dp dd dl dn\_}& 
104\textbf{y} \par \textit{but not} \par \textbf{yp yd yl} \\
105\hline
106dummy \par argument& 
107\textbf{k} \par \textit{but not} \par \textbf{kf}& 
108\textbf{p} \par \textit{but not}  \par \textbf{pp pf}& 
109\textbf{ld}& 
110\textbf{cd}& 
111\textbf{dd}& 
112\textbf{yd} \\
113\hline
114local \par variable& 
115\textbf{i}& 
116\textbf{z}& 
117\textbf{ll}& 
118\textbf{cl}& 
119\textbf{cd}& 
120\textbf{yl} \\
121\hline
122loop \par control& 
123\textbf{j} \par \textit{but not } \par \textbf{jp}& 
124& 
125& 
126& 
127& 
128 \\
129\hline
130parameter& 
131\textbf{jp}& 
132\textbf{pp}& 
133\textbf{lp}& 
134\textbf{cp}& 
135\textbf{dp}& 
136\textbf{yp} \\
137\hline
138
139namelist&
140\textbf{nn\_}& 
141\textbf{rn\_}& 
142\textbf{ln\_}& 
143\textbf{cn\_}& 
144\textbf{dn\_}& 
145\\
146\hline
147CPP \par macro& 
148\textbf{kf}& 
149\textbf{sf} \par & 
150& 
151& 
152& 
153 \\
154\hline
155\end{tabular}
156\label{tab1}
157\end{center}
158\end{table}
159%--------------------------------------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.