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 NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/doc/latex/NEMO/subfiles – NEMO

source: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/doc/latex/NEMO/subfiles/annex_D.tex @ 10368

Last change on this file since 10368 was 10368, checked in by smasson, 5 years ago

dev_r10164_HPC09_ESIWACE_PREP_MERGE: merge with trunk@10365, see #2133

File size: 6.3 KB
RevLine 
[9389]1\documentclass[../tex_main/NEMO_manual]{subfiles}
[6997]2\begin{document}
[707]3% ================================================================
[817]4% Appendix D Ñ Coding Rules
[707]5% ================================================================
[817]6\chapter{Coding Rules}
[9407]7\label{apdx:D}
[707]8\minitoc
9
[2282]10\newpage
11$\ $\newline    % force a new ligne
12$\ $\newline    % force a new ligne
[707]13
[2282]14
[10368]15A "model life" is more than ten years.
16Its software, composed of a few hundred modules, is used by many people who are scientists or students and
17do not necessarily know every aspect of computing very well.
18Moreover, a well thought-out program is easier to read and understand, less difficult to modify,
19produces fewer bugs and is easier to maintain.
20Therefore, it is essential that the model development follows some rules:
[707]21
22- well planned and designed
23
24- well written
25
26- well documented (both on- and off-line)
27
28- maintainable
29
30- easily portable
31
32- flexible.
33
[10368]34To satisfy part of these aims, \NEMO is written with a coding standard which is close to the ECMWF rules,
35named DOCTOR \citep{Gibson_TR86}.
36These rules present some advantages like:
[707]37
38- to provide a well presented program
39
[10368]40- to use rules for variable names which allow recognition of their type
[2282]41(integer, real, parameter, local or shared variables, etc. ).
[707]42
[2282]43This facilitates both the understanding and the debugging of an algorithm.
44
[817]45% ================================================================
46% The program structure
47% ================================================================
[9393]48\section{Program structure}
[9407]49\label{sec:D_structure}
[707]50
[10368]51Each program begins with a set of headline comments containing:
[707]52
53- the program title
54
55- the purpose of the routine
56
57- the method and algorithms used
58
59- the detail of input and output interfaces
60
[1223]61- the external routines and functions used (if they exist)
[707]62
[1223]63- references (if they exist)
[707]64
[1223]65- the author name(s), the date of creation and any updates.
[707]66
[10368]67- Each program is split into several well separated sections and
[1223]68sub-sections with an underlined title and specific labelled statements.
[707]69
70- A program has not more than 200 to 300 lines.
71
[10368]72A template of a module style can be found on the NEMO depository in the following file:
73NEMO/OPA\_SRC/module\_example.
[817]74% ================================================================
75% Coding conventions
76% ================================================================
77\section{Coding conventions}
[9407]78\label{sec:D_coding}
[707]79
[10368]80- Use of the universal language \textsc{Fortran} 90, and try to avoid obsolescent features like statement functions,
81do not use GO TO and EQUIVALENCE statements.
[707]82
[10368]83- A continuation line begins with the character {\&} indented by three spaces compared to the previous line,
84while the previous line ended with the character {\&}.
[707]85
[10368]86- All the variables must be declared.
87The code is usually compiled with implicit none.
[2282]88 
[10368]89- Never use continuation lines in the declaration of a variable.
90When searching a variable in the code through a \textit{grep} command, the declaration line will be found.
[2282]91
[10368]92- In the declaration of a PUBLIC variable, the comment part at the end of the line should start with
93the two characters "\verb?!:?".
94The following UNIX command, \\
[2541]95\verb?grep var_name *90 \ grep \!: ? \\
[2282]96will display the module name and the line where the var\_name declaration is.
97
[10368]98- Always use a three spaces indentation in DO loop, CASE, or IF-ELSEIF-ELSE-ENDIF statements.
[707]99
[2282]100- use a space after a comma, except when it appears to separate the indices of an array.
101
[1223]102- use call to ctl\_stop routine instead of just a STOP.
[707]103
[2282]104
105\newpage
[817]106% ================================================================
107% Naming Conventions
108% ================================================================
[9393]109\section{Naming conventions}
[9407]110\label{sec:D_naming}
[707]111
[10368]112The purpose of the naming conventions is to use prefix letters to classify model variables.
113These conventions allow the variable type to be easily known and rapidly identified.
114The naming conventions are summarised in the Table below:
[707]115
[2282]116
[707]117%--------------------------------------------------TABLE--------------------------------------------------
[9407]118\begin{table}[htbp]  \label{tab:VarName}
[707]119\begin{center}
[2282]120\begin{tabular}{|p{45pt}|p{35pt}|p{45pt}|p{40pt}|p{40pt}|p{40pt}|p{40pt}|p{40pt}|}
121\hline  Type \par / Status &   integer&   real&   logical &   character  & structure &   double \par precision&   complex \\ 
[707]122\hline
[1223]123public  \par or  \par module variable& 
[6289]124\textbf{m n} \par \textit{but not} \par \textbf{nn\_ np\_}& 
[2282]125\textbf{a b e f g h o q r} \par \textbf{t} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_}& 
126\textbf{l} \par \textit{but not} \par \textbf{lp ld} \par \textbf{ ll ln\_}& 
127\textbf{c} \par \textit{but not} \par \textbf{cp cd} \par \textbf{cl cn\_}& 
128\textbf{s} \par \textit{but not} \par \textbf{sd sd} \par \textbf{sl sn\_}& 
129\textbf{d} \par \textit{but not} \par \textbf{dp dd} \par \textbf{dl dn\_}& 
130\textbf{y} \par \textit{but not} \par \textbf{yp yd} \par \textbf{yl yn} \\
[707]131\hline
132dummy \par argument& 
133\textbf{k} \par \textit{but not} \par \textbf{kf}& 
[2282]134\textbf{p} \par \textit{but not} \par \textbf{pp pf}& 
[707]135\textbf{ld}& 
136\textbf{cd}& 
[2282]137\textbf{sd}& 
[707]138\textbf{dd}& 
139\textbf{yd} \\
140\hline
141local \par variable& 
142\textbf{i}& 
143\textbf{z}& 
144\textbf{ll}& 
145\textbf{cl}& 
[2282]146\textbf{sl}& 
147\textbf{dl}& 
[707]148\textbf{yl} \\
149\hline
150loop \par control& 
[2282]151\textbf{j} \par \textit{but not} \par \textbf{jp}& 
[707]152& 
153& 
[2282]154&
[707]155& 
156& 
157 \\
158\hline
159parameter& 
[6289]160\textbf{jp np\_}& 
[707]161\textbf{pp}& 
162\textbf{lp}& 
163\textbf{cp}& 
[2282]164\textbf{sp}& 
[707]165\textbf{dp}& 
166\textbf{yp} \\
167\hline
[1223]168
169namelist&
170\textbf{nn\_}& 
171\textbf{rn\_}& 
172\textbf{ln\_}& 
173\textbf{cn\_}& 
[2282]174\textbf{sn\_}& 
[1223]175\textbf{dn\_}& 
[2282]176\textbf{yn\_}
[1223]177\\
178\hline
179CPP \par macro& 
[707]180\textbf{kf}& 
[2282]181\textbf{fs} \par & 
[707]182& 
[2282]183&
[707]184& 
185& 
186 \\
187\hline
188\end{tabular}
[9407]189\label{tab:tab1}
[707]190\end{center}
191\end{table}
192%--------------------------------------------------------------------------------------------------------------
[2349]193
[10368]194N.B. Parameter here, in not only parameter in the \textsc{Fortran} acceptation,
195it is also used for code variables that are read in namelist and should never been modified during a simulation.
[6289]196It is the case, for example, for the size of a domain (jpi,jpj,jpk).
197
[2349]198\newpage
199% ================================================================
200% The program structure
201% ================================================================
[9393]202%\section{Program structure}
[9407]203%abel{sec:Apdx_D_structure}
[2414]204
[9393]205%To be done....
[6997]206\end{document}
Note: See TracBrowser for help on using the repository browser.