Changeset 11967 for NEMO/branches/2019/ENHANCE-02_ISF_nemo_TEST_MERGE/doc/latex/global/coding_rules.tex
- Timestamp:
- 2019-11-26T15:11:43+01:00 (4 years ago)
- Location:
- NEMO/branches/2019/ENHANCE-02_ISF_nemo_TEST_MERGE/doc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2019/ENHANCE-02_ISF_nemo_TEST_MERGE/doc
-
Property
svn:externals
set to
^/utils/badges badges
^/utils/logos logos
-
Property
svn:externals
set to
-
NEMO/branches/2019/ENHANCE-02_ISF_nemo_TEST_MERGE/doc/latex
- Property svn:ignore deleted
-
NEMO/branches/2019/ENHANCE-02_ISF_nemo_TEST_MERGE/doc/latex/global
- Property svn:ignore deleted
-
NEMO/branches/2019/ENHANCE-02_ISF_nemo_TEST_MERGE/doc/latex/global/coding_rules.tex
r11299 r11967 1 %\documentclass{article} 2 3 %\usepackage{fancyhdr} 4 %\usepackage{times} 5 %\usepackage{graphicx} 6 %\usepackage{hyperref} 7 %\usepackage{minted} 8 %\usepackage[normalem]{ulem} % striketrough style with \sout{...} 9 10 %\hypersetup{pdftitle={NEMO coding conventions}, pdfauthor={NEMO System Team}, colorlinks} 11 %\setminted{style=emacs, breaklines, frame=leftline} 12 %\newmintinline[forcode]{fortran}{fontsize=auto, frame=lines} % \forcode{...} 13 %\newminted[forlines]{fortran}{} % \begin{forlines} 14 15 %\pagestyle{empty} 16 %\setlength{\leftmargin}{1 cm} 17 %\setlength{\rightmargin}{1 cm} 18 %\setlength{\oddsidemargin}{0 cm} 19 %\setlength{\evensidemargin}{0 cm} 20 %\setlength{\topmargin}{-1cm} 21 %\setlength{\textwidth}{16 cm} 22 %\setlength{\textheight}{25cm} 23 %\pagestyle{fancy} 24 25 %\title{ 26 % \includegraphics[width=0.3\textwidth]{../../../figures/NEMO_grey} \\ 27 % \vspace{1.0cm} \rule{345pt}{1.5pt} \\ 28 % \vspace{0.45cm} {\Huge NEMO coding conventions} \rule{345pt}{1.5pt} \\ 29 %} 30 %\title{NEMO coding conventions} 31 %\author{\Large NEMO System Team 32 % \thanks{ 33 % To be completed 34 % } 35 %} 36 %\date{version X.X -- month year} 37 38 %\begin{document} 39 40 %\maketitle 41 42 %\newpage 43 44 %\tableofcontents 45 46 %\newpage 47 48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1 49 2 \chapter{Coding Rules} 50 \label{apdx: coding}51 52 \ minitoc3 \label{apdx:CODING} 4 5 \chaptertoc 53 6 54 7 \newpage … … 61 14 Therefore, it is essential that the model development follows some rules: 62 15 63 - well planned and designed 64 65 - well written 66 67 - well documented (both on- and off-line) 68 69 - maintainable 70 71 - easily portable 72 73 - flexible. 74 75 To satisfy part of these aims, \NEMO is written with a coding standard which is close to the ECMWF rules, 76 named DOCTOR \citep{gibson_rpt86}. 16 \begin{itemize} 17 \item well planned and designed 18 \item well written 19 \item well documented (both on- and off-line) 20 \item maintainable 21 \item easily portable 22 \item flexible. 23 \end{itemize} 24 25 To satisfy part of these aims, \NEMO\ is written with a coding standard which is close to the ECMWF rules, 26 named DOCTOR \citep{gibson_rpt86}. 77 27 These rules present some advantages like: 78 28 79 - to provide a well presented program 80 81 - to use rules for variable names which allow recognition of their type 82 (integer, real, parameter, local or shared variables, etc. ). 29 \begin{itemize} 30 \item to provide a well presented program 31 \item to use rules for variable names which allow recognition of their type (integer, real, parameter, local or shared variables, etc. ). 32 \end{itemize} 83 33 84 34 This facilitates both the understanding and the debugging of an algorithm. … … 86 36 \section{Introduction} 87 37 88 This document describes conventions \index{conventions} used in NEMOcoding and suggested for its development.89 The objectives are to offer a guide to all readers of the NEMOcode, and to facilitate the work of38 This document describes conventions used in \NEMO\ coding and suggested for its development. 39 The objectives are to offer a guide to all readers of the \NEMO\ code, and to facilitate the work of 90 40 all the developers, including the validation of their developments, and 91 eventually the implementation of these developments within the NEMOplatform.41 eventually the implementation of these developments within the \NEMO\ platform. 92 42 93 43 A first approach of these rules can be found in the code in \path{./src/OCE/module_example} where … … 96 46 97 47 This work is based on the coding conventions in use for the Community Climate System Model 98 \footnote {\href{http://www.cesm.ucar.edu/working_groups/Software/dev_guide/dev_guide/node7.html}{UCAR conventions}}, 48 \footnote {\href{http://www.cesm.ucar.edu/working_groups/Software/dev_guide/dev_guide/node7.html}{UCAR conventions}}, 99 49 the previous version of this document (``FORTRAN coding standard in the OPA System'') and 100 the expertise of the NEMOSystem Team.50 the expertise of the \NEMO\ System Team. 101 51 After a general overview below, this document will describe: 102 52 103 53 \begin{itemize} 104 \item 105 The style rules, $i.e.$ the syntax, appearance and naming conventions chosen to improve readability of the code; 106 \item 107 The content rules, $i.e.$ the conventions to improve the reliability of the different parts of the code; 108 \item 109 The package rules to go a step further by improving the reliability of the whole and 110 interfaces between routines and modules. 54 \item The style rules, $i.e.$ the syntax, appearance and naming conventions chosen to improve readability of the code; 55 \item The content rules, $i.e.$ the conventions to improve the reliability of the different parts of the code; 56 \item The package rules to go a step further by improving the reliability of the whole and 57 interfaces between routines and modules. 111 58 \end{itemize} 112 59 113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%114 60 \section{Overview and general conventions} 115 61 116 NEMOhas 3 major components: ocean dynamics (\path{./src/OCE}), sea-ice (\path{./src/ICE}) and62 \NEMO\ has 3 major components: ocean dynamics (\path{./src/OCE}), sea-ice (\path{./src/ICE}) and 117 63 marine biogeochemistry (\path{./src/MBG}). 118 64 %, linear-tangent and adjoint of the dynamics ($TAM$) each of them corresponding to a directory. … … 126 72 See \path{.src/OCE/DOM/phycst.F90} files for conversions. 127 73 128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%129 74 \section{Architecture} 130 75 131 Within each directory, organisation of files is driven by orthogonality \index{orthogonality},76 Within each directory, organisation of files is driven by orthogonality, 132 77 $i.e.$ one functionality of the code is intended to be in one and only one directory, and 133 78 one module and all its related routines are in one file. 134 The functional modules \index{module}are:79 The functional modules are: 135 80 136 81 \begin{itemize} … … 138 83 \item \path{IOM} management of the I/O 139 84 \item \path{NST} interface to AGRIF (nesting model) for dynamics and biogeochemistry 140 \item \path{OBC}, \path{BDY} management of structured and unstructured open boundaries 85 \item \path{OBC}, \path{BDY} management of structured and unstructured open boundaries 141 86 \item \path{C1D} 1D (vertical) configuration for dynamics, sea-ice and biogeochemistry 142 87 \item \path{OFF} off-line module: passive tracer or biogeochemistry alone … … 147 92 this module (\texttt{dom\_init, dom\_nam, dom\_ctl}). 148 93 149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%150 94 \section{Style rules} 151 95 152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%153 96 \subsection{Argument list format} 154 97 155 Routine argument lists will contain a maximum 5 variables \index{variable}per line,98 Routine argument lists will contain a maximum 5 variables per line, 156 99 whilst continuation lines can be used. 157 100 This applies both to the calling routine and the dummy argument list in the routine being called. … … 164 107 \end{forlines} 165 108 166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%167 109 \subsection{Array syntax} 168 110 … … 198 140 \end{forlines} 199 141 200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%201 142 \subsection{Case} 202 143 203 144 All FORTRAN keywords are in capital: \forcode{DIMENSION}, \forcode{WRITE}, \forcode{DO}, \forcode{END DO}, 204 \forcode{NAMELIST}, ... All other parts of the NEMO code will be written in lower case. 205 206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 145 \forcode{NAMELIST}, ... All other parts of the \NEMO\ code will be written in lower case. 146 207 147 \subsection{Comments} 208 148 … … 248 188 \end{enumerate} 249 189 250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%251 190 \subsection{Continuation lines} 252 191 … … 265 204 use a ``\&'' as first character of the continuing lines to maintain the alignment. 266 205 267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%268 206 \subsection{Declaration of arguments and local variables} 269 207 … … 277 215 \end{forlines} 278 216 279 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%280 217 \subsection{F90 Standard} 281 218 282 NEMO software adheres to the FORTRAN 95language standard and does not rely on any specific language or219 \NEMO\ software adheres to the \fninety language standard and does not rely on any specific language or 283 220 vendor extensions. 284 221 285 286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%287 222 \subsection{Free-Form Source} 288 223 … … 292 227 Multi-line comments that extend to column 100 are unacceptable. 293 228 294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%295 229 \subsection{Indentation} 296 230 … … 310 244 \end{forlines} 311 245 312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%313 246 \subsection{Loops} 314 247 … … 317 250 In the case of a long loop, a self-descriptive label can be used ($i.e.$ not just a number). 318 251 319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%320 252 \subsection{Naming Conventions: files} 321 253 … … 331 263 } 332 264 333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%334 265 \subsection{Naming Conventions: modules} 335 266 … … 338 269 For example, zdftke, where ``zdf'' stands for vertical diffusion, and ``tke'' for turbulent kinetic energy. \\ 339 270 Note that by implication multiple modules are not allowed in a single file. 340 The use of common blocks is deprecated in Fortran 90 and their use in NEMOis strongly discouraged.271 The use of common blocks is deprecated in \fortran 90 and their use in \NEMO\ is strongly discouraged. 341 272 Modules are a better way to declare static data. 342 273 Among the advantages of modules is the ability to freely mix data of various types, and 343 274 to limit access to contained variables through the use of the \forcode{ONLY} and \forcode{PRIVATE} attributes. 344 275 345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%346 276 \subsection{Naming Conventions: variables} 347 277 348 278 All variable should be named as explicitly as possible in English. 349 279 The naming convention concerns prefix letters of these name, in order to identify the variable type and status. \\ 350 Never use a FORTRANkeyword as a routine or variable name. \\280 Never use a \fortran keyword as a routine or variable name. \\ 351 281 The table below lists the starting letter(s) to be used for variable naming, depending on their type and status: 352 282 %--------------------------------------------------TABLE-------------------------------------------------- … … 355 285 \begin{tabular}{|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|} 356 286 \hline 357 Type \par / Status & integer& real& logical & character& double \par precision& complex \\ 287 Type \par / Status & 288 integer & 289 real & 290 logical & 291 character & 292 double \par precision & 293 complex \\ 358 294 \hline 359 public \par or \par module variable& \textbf{m n} \par \textit{but not } \par \textbf{nn\_}& \textbf{a b e f g h o} \textbf{q} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_}& \textbf{l} \par \textit{but not} \par \textbf{lp ld ll ln\_}& \textbf{c} \par \textit{but not} \par \textbf{cp cd cl cn\_}& \textbf{d} \par \textit{but not} \par \textbf{dp dd dl dn\_}& \textbf{y} \par \textit{but not} \par \textbf{yp yd yl} \\ 295 public \par or \par module variable & 296 \textbf{m n} \par \textit{but not} \par \textbf{nn\_} & 297 \textbf{a b e f g h o} \textbf{q} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_} & 298 \textbf{l} \par \textit{but not} \par \textbf{lp ld ll ln\_} & 299 \textbf{c} \par \textit{but not} \par \textbf{cp cd cl cn\_} & 300 \textbf{d} \par \textit{but not} \par \textbf{dp dd dl dn\_} & 301 \textbf{y} \par \textit{but not} \par \textbf{yp yd yl} \\ 360 302 \hline 361 dummy \par argument& \textbf{k} \par \textit{but not} \par \textbf{kf}& \textbf{p} \par \textit{but not} \par \textbf{pp pf}& \textbf{ld}& \textbf{cd}& \textbf{dd}& \textbf{yd} \\ 303 dummy \par argument & 304 \textbf{k} \par \textit{but not} \par \textbf{kf} & 305 \textbf{p} \par \textit{but not} \par \textbf{pp pf} & 306 \textbf{ld} & 307 \textbf{cd} & 308 \textbf{dd} & 309 \textbf{yd} \\ 362 310 \hline 363 local \par variable& \textbf{i}& \textbf{z}& \textbf{ll}& \textbf{cl}& \textbf{cd}& \textbf{yl} \\ 311 local \par variable & 312 \textbf{i} & 313 \textbf{z} & 314 \textbf{ll} & 315 \textbf{cl} & 316 \textbf{cd} & 317 \textbf{yl} \\ 364 318 \hline 365 loop \par control& \textbf{j} \par \textit{but not } \par \textbf{jp}& & & & & \\ 319 loop \par control & 320 \textbf{j} \par \textit{but not} \par \textbf{jp} & 321 & 322 & 323 & 324 & 325 \\ 366 326 \hline 367 parameter& \textbf{jp}& \textbf{pp}& \textbf{lp}& \textbf{cp}& \textbf{dp}& \textbf{yp} \\ 327 parameter & 328 \textbf{jp} & 329 \textbf{pp} & 330 \textbf{lp} & 331 \textbf{cp} & 332 \textbf{dp} & 333 \textbf{yp} \\ 368 334 \hline 369 namelist& \textbf{nn\_}& \textbf{rn\_}& \textbf{ln\_}& \textbf{cn\_}& \textbf{dn\_}& \\ 335 namelist & 336 \textbf{nn\_} & 337 \textbf{rn\_} & 338 \textbf{ln\_} & 339 \textbf{cn\_} & 340 \textbf{dn\_} & 341 \\ 370 342 \hline 371 CPP \par macro& \textbf{kf}& \textbf{sf} \par & & & & \\ 343 CPP \par macro & 344 \textbf{kf} & 345 \textbf{sf} & 346 & 347 & 348 & 349 \\ 372 350 \hline 373 351 \end{tabular} … … 377 355 %-------------------------------------------------------------------------------------------------------------- 378 356 379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%380 357 \subsection{Operators} 381 358 … … 385 362 In general use the notation: \\ 386 363 $<Blank><Operator><Blank>$ 387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 364 388 365 \subsection{Pre processor} 389 366 … … 412 389 Is to be used rather than the \#ifdef abbreviate form since it may have conflicts with some Unix scripts. 413 390 414 Tests on cpp keys included in NEMOat compilation step:391 Tests on cpp keys included in \NEMO\ at compilation step: 415 392 416 393 \begin{itemize} … … 421 398 If a change occurs in the CPP keys used for a given experiment, the whole compilation phase is done again. 422 399 \end{itemize} 423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 400 424 401 \section{Content rules} 425 402 426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%427 403 \subsection{Configurations} 428 404 429 The configuration defines the domain and the grid on which NEMOis running.430 It may be useful to associate a cppkey and some variables to a given configuration, although405 The configuration defines the domain and the grid on which \NEMO\ is running. 406 It may be useful to associate a CPP key and some variables to a given configuration, although 431 407 the part of the code changed under each of those keys should be minimized. 432 408 As an example, the "ORCA2" configuration (global ocean, 2 degrees grid size) is associated with … … 438 414 \end{forlines} 439 415 440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%441 416 \subsection{Constants} 442 417 443 Physical constants ($e.g.$ $\pi$, gas constants) must never be hard wired into the executable portion of a code.418 Physical constants ($e.g.$ $\pi$, gas constants) must never be hard-wired into the executable portion of a code. 444 419 Instead, a mnemonically named variable or parameter should be set to the appropriate value, 445 in the setup routine for the package \index{package}.420 in the setup routine for the package. 446 421 We realize than many parameterizations rely on empirically derived constants or fudge factors, 447 422 which are not easy to name. … … 450 425 Hard-coded numbers should never be passed through argument lists. 451 426 452 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%453 427 \subsection{Declaration for variables and constants} 454 428 … … 512 486 improve control of variables in routine calls. 513 487 514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%515 488 \subsection{Headers} 516 489 517 Prologues are not used in NEMOfor now, although it may become an interesting tool in combination with490 Prologues are not used in \NEMO\ for now, although it may become an interesting tool in combination with 518 491 ProTeX auto documentation script in the future. 519 492 Rules to code the headers and layout of a module or a routine are illustrated in the example module available with 520 493 the code: \path{./src/OCE/module_example} 521 494 522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%523 495 \subsection{Interface blocks} 524 496 … … 528 500 FORTRAN 95 compilers can automatically provide explicit interface blocks for routines contained in a module. 529 501 530 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%531 502 \subsection{I/O Error Conditions} 532 503 … … 536 507 a negative value means the end of record or end of file was encountered. 537 508 538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%539 509 \subsection{PRINT - ASCII output files} 540 510 … … 551 521 \end{forlines} 552 522 553 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%554 523 \subsection{Precision} 555 524 … … 570 539 \end{forlines} 571 540 572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%573 541 \subsection{Structures} 574 542 575 The \forcode{TYPE} structure allowing to declare some variables is more often used in NEMO,543 The \forcode{TYPE} structure allowing to declare some variables is more often used in \NEMO, 576 544 especially in the modules dealing with reading fields, or interfaces. 577 545 For example: … … 592 560 Missing rule on structure name?? 593 561 594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%595 562 \section{Packages coding rules} 596 563 597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%598 564 \subsection{Bounds checking} 599 565 600 NEMOis able to run when an array bounds checking option is enabled566 \NEMO\ is able to run when an array bounds checking option is enabled 601 567 (provided the cpp key \texttt{key\_vectopt\_loop} is not defined). \\ 602 568 Thus, constructs of the following form are disallowed: … … 610 576 it effectively disables array bounds checking. 611 577 612 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%613 578 \subsection{Communication} 614 579 … … 624 589 } 625 590 626 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%627 591 \subsection{Error conditions} 628 592 … … 634 598 see \textit{stpctl.F90}. 635 599 636 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%637 600 \subsection{Memory management} 638 601 639 602 The main action is to identify and declare which arrays are \forcode{PUBLIC} and which are \forcode{PRIVATE}. \\ 640 As of version 3.3.1 of NEMO, the use of static arrays (size fixed at compile time) has been deprecated.603 As of version 3.3.1 of \NEMO, the use of static arrays (size fixed at compile time) has been deprecated. 641 604 All module arrays are now declared \forcode{ALLOCATABLE} and 642 605 allocated in either the \texttt{<module\_name>\_alloc()} or \texttt{<module\_name>\_init()} routines. … … 644 607 the \texttt{stat=<integer\ variable>} optional argument. \\ 645 608 646 In addition to arrays contained within modules, many routines in NEMOrequire local, ``workspace'' arrays to609 In addition to arrays contained within modules, many routines in \NEMO\ require local, ``workspace'' arrays to 647 610 hold the intermediate results of calculations. 648 In previous versions of NEMO, these arrays were declared in such a way as to be automatically allocated on611 In previous versions of \NEMO, these arrays were declared in such a way as to be automatically allocated on 649 612 the stack when the routine was called. 650 613 An example of an automatic array is: … … 735 698 It is then associated with a sub-array of \texttt{wrk\_3d\_5} once the call to 736 699 \texttt{wrk\_in\_use()} has completed successfully. 737 Note that in F95 (to which NEMOconforms) it is not possible for either the upper or lower array bounds of700 Note that in F95 (to which \NEMO\ conforms) it is not possible for either the upper or lower array bounds of 738 701 the pointer object to differ from those of the target array. \\ 739 702 … … 748 711 This should enable the developer to choose alternatives for use in the subroutine being worked on. \\ 749 712 750 When compiling NEMOfor production runs,713 When compiling \NEMO\ for production runs, 751 714 the calls to {\texttt{wrk\_in\_use()} / \texttt{wrk\_not\_released()} can be reduced to stubs that just 752 715 return \forcode{.false.} by setting the cpp key \texttt{key\_no\_workspace\_check}. 753 These stubs may then be in lined (and thus effectively removed altogether) by setting appropriate compiler flags716 These stubs may then be in-lined (and thus effectively removed altogether) by setting appropriate compiler flags 754 717 ($e.g.$ ``-finline'' for the Intel compiler or ``-Q'' for the IBM compiler). 755 718 756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%757 719 \subsection{Optimisation} 758 720 759 721 Considering the new computer architecture, optimisation cannot be considered independently from the computer type. 760 In NEMO, portability is a priority, before any too specific optimisation.722 In \NEMO, portability is a priority, before any too specific optimisation. 761 723 762 724 Some tools are available to help: for vector computers, \texttt{key\_vectopt\_loop} allows to unroll a loop 763 725 764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%765 726 \subsection{Package attribute: \forcode{PRIVATE}, \forcode{PUBLIC}, \forcode{USE}, \forcode{ONLY}} 766 727 … … 770 731 defined in a module are to be made available to the using routine. 771 732 772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 773 \subsection {Parallelism using MPI} 774 775 NEMO is written in order to be able to run on one processor, or on one or more using MPI 733 \subsection{Parallelism using MPI} 734 735 \NEMO\ is written in order to be able to run on one processor, or on one or more using MPI 776 736 ($i.e.$ activating the cpp key $key\_mpp\_mpi$). 777 The domain decomposition divides the global domain in cubes (see NEMOreference manual).737 The domain decomposition divides the global domain in cubes (see \NEMO\ reference manual). 778 738 Whilst coding a new development, the MPI compatibility has to be taken in account 779 739 (see \path{./src/LBC/lib_mpp.F90}) and should be tested. 780 740 By default, the $x$-$z$ part of the decomposition is chosen to be as square as possible. 781 However, this may be overriden by specifying the number of sub domains in latitude and longitude in741 However, this may be overriden by specifying the number of sub-domains in latitude and longitude in 782 742 the \texttt{nammpp} section of the namelist file. 783 743 784 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%785 744 \section{Features to be avoided} 786 745 … … 790 749 Below is a list of features to avoid: 791 750 \begin{itemize} 792 \item 793 \forcode{COMMON} block 751 \item \forcode{COMMON} block 794 752 (use the declaration part of \forcode{MODULE} instead) 795 \item 796 \forcode{EQUIVALENCE} 753 \item \forcode{EQUIVALENCE} 797 754 (use \forcode{POINTER} or derived data type instead to form data structure) 798 \item 799 Assigned and computed \forcode{GOTO} 755 \item Assigned and computed \forcode{GOTO} 800 756 (use the \forcode{CASE} construct instead) 801 \item 802 Arithmetic \forcode{IF} statement 757 \item Arithmetic \forcode{IF} statement 803 758 (use the block \forcode{IF}, \forcode{ELSE}, \forcode{ELSEIF}, \forcode{ENDIF} or 804 759 \forcode{SELECT CASE} construct instead) 805 \item 806 Labeled \forcode{DO} construct 807 (use unlabeled \forcode{END DO} instead) 808 \item 809 \forcode{FORMAT} statement 760 \item Labelled \forcode{DO} construct 761 (use unlabelled \forcode{END DO} instead) 762 \item \forcode{FORMAT} statement 810 763 (use character parameters or 811 764 explicit format- specifiers inside the \forcode{READ} or \forcode{WRITE} statement instead) 812 \item 813 \forcode{GOTO} and \forcode{CONTINUE} statements 765 \item \forcode{GOTO} and \forcode{CONTINUE} statements 814 766 (use \forcode{IF}, \forcode{CASE}, \forcode{DO WHILE}, \forcode{EXIT} or \forcode{CYCLE} statements or 815 767 a contained ?) 816 \item 817 \forcode{PAUSE} 818 \item 819 \forcode{ENTRY} statement: a subprogram must only have one entry point. 820 \item 821 \forcode{RETURN} is obsolete and so not necessary at the end of program units 822 \item 823 \forcode{FUNCTION} statement 824 \item 825 Avoid functions with side effects. 768 \item \forcode{PAUSE} 769 \item \forcode{ENTRY} statement: a sub-program must only have one entry point. 770 \item \forcode{RETURN} is obsolete and so not necessary at the end of program units 771 \item \forcode{FUNCTION} statement 772 \item Avoid functions with side effects. 826 773 \footnote{ 827 774 First, the code is easier to understand, if you can rely on … … 832 779 This is especially important on massive parallel and as well on vector machines. 833 780 } 834 \item 835 \forcode{DATA} and \forcode{BLOCK DATA} 781 \item \forcode{DATA} and \forcode{BLOCK DATA} 836 782 (use initialisers) 837 783 \end{itemize} 838 784 839 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 840 841 % \printindex 842 % \input NEMO_coding.conv.ind 843 844 %\end{document} 785 %% Imported from introduction 786 %%gm To be put somewhere else .... 787 %%nm We should consider creating a glossary for all this kind of stuff (terms, acronyms and symbols) 788 %% http://en.wikibooks.org/wiki/LaTeX/Glossary 789 %\noindent CPP keys and namelists are used as inputs to the code. 790 791 %\noindent \index{CPP keys} CPP keys 792 793 %Some CPP keys are implemented in the \fortran code to allow code selection at compiling step. 794 %This selection of code at compilation time reduces the reliability of the whole platform since 795 %it changes the code from one set of CPP keys to the other. 796 %It is used only when the addition/suppression of the part of code highly changes the amount of memory at run time. 797 %Usual coding looks like: 798 799 %\begin{forlines} 800 %#if defined key_option1 801 % ! This part of the \fortran code will be active 802 % ! only if key_option1 is activated at compiling step 803 %#endif 804 %\end{forlines} 805 806 %\noindent \index{Namelist} Namelists 807 808 %The namelist allows to input variables (character, logical, real and integer) into the code. 809 %There is one namelist file for each component of \NEMO\ (dynamics, sea-ice, biogeochemistry...) 810 %containing all the \fortran namelists needed. 811 %The implementation in \NEMO\ uses a 2-step process. 812 %For each \fortran namelist, two files are read: 813 814 %\begin{enumerate} 815 %\item 816 % A reference namelist (in \path{./cfgs/SHARED/namelist_ref}) is read first. 817 % This file contains all the namelist variables which are initialised to default values 818 %\item 819 % A configuration namelist (in \path{./cfgs/CFG_NAME/EXP00/namelist_cfg}) is read aferwards. 820 % This file contains only the namelist variables which are changed from default values, and overwrites those. 821 %\end{enumerate} 822 %A template can be found in \path{NEMO/OPA_SRC/module.example}. 823 %The effective namelist, taken in account during the run, is stored at execution time in 824 %an \texttt{output\_namelist\_dyn} (or \texttt{\_ice} or \texttt{\_top}) file. 825 %%gm end 826 827 %%nm: Add some words on the \NEMO\ dependencies 828 %The model is implemented in \fninety, with preprocessing (C pre-processor). 829 %It runs under UNIX. 830 %It is optimized for vector computers and parallelised by domain decomposition with MPI. 831 %All input and output is done in NetCDF (Network Common Data Format) with a optional direct access format for output. 832 %To ensure the clarity and readability of the code it is necessary to follow coding rules. 833 %The coding rules for OPA include conventions for naming variables, 834 %with different starting letters for different types of variables (real, integer, parameter\ldots). 835 %Those rules are briefly presented in \autoref{apdx:coding} and a more complete document is available . 836 837 %The model is organized with a high internal modularity based on physics. 838 %For example, each trend (\ie, a term in the RHS of the prognostic equation) for momentum and tracers 839 %is computed in a dedicated module. 840 %To make it easier for the user to find his way around the code, the module names follow a three-letter rule. 841 %For example, \mdl{traldf} is a module related to the TRAcers equation, computing the Lateral DiFfussion. 842 %The complete list of module names is presented in \autoref{apdx:coding}. %====>>>> to be done ! 843 %Furthermore, modules are organized in a few directories that correspond to their category, 844 %as indicated by the first three letters of their name (\autoref{tab:chapters}).
Note: See TracChangeset
for help on using the changeset viewer.