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.
4_codingRules.md in utils/tools/SIREN/src/docsrc – NEMO

source: utils/tools/SIREN/src/docsrc/4_codingRules.md @ 12080

Last change on this file since 12080 was 12080, checked in by jpaul, 4 years ago

update nemo trunk

File size: 4.7 KB
Line 
1# Coding Rules
2
3The conventions used in SIREN coding are based on the NEMO coding rules
4(see [NEMO coding
5conventions](http://www.nemo-ocean.eu/content/download/15483/73221/file/NEMO_coding.conv_v3.pdf)).<br/>
6However some modifications were added to improve readibility of the code.<br/>
7Some of the NEMO coding rules are reminded here, and extensions are described.
8
9@tableofcontents
10
11# Fortran Standard {#std}
12
13SIREN software adhere to strict __FORTRAN 95__ standard.<br/>
14There is only one exception. The use of functions _COMMAND_ARGUMENT_COUNT_ and
15_GET_COMMAND_ARGUMENT_.<br/>
16There exist no equivalent for those Fortran 03 intrinsec functions in Fortran
1795.<br/> At least none convenient for compilers tested (see @ref md_src_docsrc_1_install).
18
19#  Free Form Source {#free}
20Free Form Source will be used, however a self imposed limit of 80 should
21enhance readibility.
22
23#  Indentation {#indent}
24Code as well as comments lines will be indented 3 characters for readibility.<br/>
25__Indentation should be write without hard tabs__.
26
27Example for vi  :
28~~~~~~~~~~~~~~~~~~~~~
29:set expandtab tabstop=3 shiftwidth=3
30~~~~~~~~~~~~~~~~~~~~~
31
32#  Naming conventions : variable {#namvar}
33All variables should be named as explicitly as possible.<br/>
34The naming conventions concerns prefix letters of these name, in order to
35identify the variable type and status.<br/> It must be composed of two
36letters defining type and status follow by an underscore.<br/>
37table below list the starting letters to be used for variable naming,
38depending on their type and status.
39
40 | Type / Status     | byte (integer(1)) <br/> __b__ | short (integer(2)) <br/> __s__ | integer(4) <br/> __i__  | integer(8) <br/> __k__ | real(4) <br/> __r__ | real(8) <br/> __d__ | logical <br/> __l__ | character <br/> __c__ | complex <br/> __y__ | structure <br/> __t__  |
41 | :----:            | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
42 |global <br/> __g__           | bg_  | sg_  | ig_  | kg_  | rg_  | dg_  | lg_  | cg_  | yg_  | tg_  |
43 |global parameter <br/> __p__ | bp_  | sp_  | ip_  | kp_  | rp_  | dp_  | lp_  | cp_  | yp_  | tp_  |
44 |module <br/> __m__           | bm_  | sm_  | im_  | km_  | rm_  | dm_  | lm_  | cm_  | ym_  | tm_  |
45 |namelist <br/> __n__         | bn_  | sn_  | in_  | kn_  | rn_  | dn_  | ln_  | cn_  | yn_  | tn_  |
46 |dummy argument <br/> __d__   | bd_  | sd_  | id_  | kd_  | rd_  | dd_  | ld_  | cd_  | yd_  | td_  |
47 |local <br/> __l__            | bl_  | sl_  | il_  | kl_  | rl_  | dl_  | ll_  | cl_  | yl_  | tl_  |
48 |function result <br/> __f__  | bf_  | sf_  | if_  | kf_  | rf_  | df_  | lf_  | cf_  | yf_  | tf_  |
49 |loop control                 |      |      | j?   |      |      |      |      |      |      |      |
50
51# Naming conventions : structure {#namstr}
52The structure name should be written in capital letter, and start with
53__T__<br/> Example: TTRACER <br/>
54Variables inside the structure should be named as explicitly as possible.<br/>
55For those variables, the prefix naming conventions only concern the type of variable.<br/>
56It must be composed of one letter defining type follows by an
57underscore.<br/>
58see table of variable conventions.<br/>
59
60Example: __tl\_type\%i\_year__<br/> _year_ is an integer(4) variable in a local strucure
61named _type_. <br/>
62
63# Naming conventions : function-subroutine {#namsub}
64Functions or Subroutines are defined in a module.<br/>
65Their name should start with the module name then with their "functional" name. So it will be
66easy to find it.<br/>
67Example:<br/> a function to realise addition written in a module
68__math__ should be called __math\_add__.<br/>
69
70__PUBLIC__  function or subroutine should used one undescrore: _math_add_<br/>
71__PRIVATE__ function or subroutine should used two undescrores: _math__add_<br/>
72
73# Precision {#precision}
74__All variables should make use of kinds__.<br/>
75Numerical constant need to have a suffix of __kindvalue__
76
77# Declaration for global variable and constants {#global}
78All global data must be accompanied with a comment field on the same
79line.<br/>
80_Note that using doxygen (see [header](#header)), we will use symbol !< instead of !: as separator_
81
82# Implicit none {#implicit}
83All subroutines and functions will include an IMPLICIT NONE statement.
84
85# Header {#header}
86
87SIREN use __doxigen auto documentation__ tool.<br/>
88Information could be find on
89[doxygen](http://www.stack.nl/~dimitri/doxygen/index.html) web page.<br/>
90Some basic tag are described
91[here](http://www.msg.chem.iastate.edu/gamess/DoxygenRules.oct10.pdf).
92
93 <HR>
94   <b>
95   - @ref index
96   - @ref md_src_docsrc_1_install
97   - @ref md_src_docsrc_2_quickstart
98   - @ref md_src_docsrc_3_support_bug
99   - @ref md_src_docsrc_5_changeLog
100   - @ref todo
101   </b>
Note: See TracBrowser for help on using the repository browser.