5 * Trim all trailing whitespace from every line (some editors can do this
8 * Supply a header for each file with a description of the file and the author(s)
10 * A copy of the [Gnu Lesser General Public License](https://www.gnu.org/licenses/lgpl-3.0.en.html)
11 must be included at the top of each file.
12 * Documentation should be written so that it can be parsed by [Doxygen](http://www.doxygen.nl/).
13 * All variables should be defined, and include units. Unit-less variables should be marked `unitless`
14 * Provide detailed descriptions of modules, interfaces, functions, and subroutines
15 * Define all function/subroutine arguments, and function results (see below)
16 * Follow coding style of the current file, as much as possible.
22 * Use Fortran 95 standard or newer
23 * Two space indentation
24 * Use `KIND` parameters from intrinsic fortran modules such as iso_fortran_env
25 or iso_c_binding to ensure portability
26 * Never use implicit variables (i.e., always specify `IMPLICIT NONE`)
27 * Lines must be <= 120 characters long (including comments)
28 * logical, compound logical, and relational if statements may be one line,
29 using “&” for line continuation if necessary:
31 if(file_exists(fileName)) call open_file(fileObj,fileName, is_restart=.false)
33 * Avoid the use of `GOTO` statements
34 * Avoid the use of Fortran reserved words as variables (e.g. `DATA`, `NAME`)
35 * Avoid the use of `COMMON` blocks
39 * Type names must be in CapitalWord format.
40 * Variables names must be in underscore_word format.
41 * All member variables must be private.
42 * Doxygen description on the line before the type definition.
43 * Inline doxygen descriptions for all member variables.
46 * Functions should include a result variable on its own line, that does not have
48 * Inline doxygen descriptions for all arguments, except the result variable.
49 * Doxygen description on the line(s) before the function definition. This must
50 specify what the function is returning using the `@return` doxygen keyword.
53 * terminate `do` loops with `enddo`
54 * terminate block `if`, `then` statements with `endif`
58 * Directives should start at the beginning of the line, and be in lowercase.
59 * All openMP directives should specify default(none), and then explicitly list
60 all shared and private variables.
61 * All critical sections must have a unique name.
67 !***********************************************************************
68 !* GNU Lesser General Public License
70 !* This file is part of the GFDL Flexible Modeling System (FMS).
72 !* FMS is free software: you can redistribute it and/or modify it under
73 !* the terms of the GNU Lesser General Public License as published by
74 !* the Free Software Foundation, either version 3 of the License, or (at
75 !* your option) any later version.
77 !* FMS is distributed in the hope that it will be useful, but WITHOUT
78 !* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
79 !* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
82 !* You should have received a copy of the GNU Lesser General Public
83 !* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
84 !***********************************************************************
87 !! @brief Example code
88 !! @author <developer>
89 !! @email gfdl.climate.model.info@noaa.gov
92 use, intrinsic :: iso_fortran_env, only: INT32, REAL32
93 use util_mod, only: util_func1
100 !> @brief Doxygen description of type.
101 type,public :: CustomType
103 integer(kind=INT32) :: a_var !< Inline doxygen description.
104 real(kind=REAL32),dimension(:),allocatable :: b_arr !< long description
111 !> @brief Doxygen description.
112 subroutine sub1(arg1, &
115 real(kind=REAL32),intent(in) :: arg1 !< Inline doxygen description.
116 integer(kind=INT32),intent(inout) :: arg2 !< Inline doxygen description.
117 character(len=*),intent(inout) :: arg3 !< Long inline doxygen
121 !> @brief Doxygen description
122 !! @return Function return value.
123 function func1(arg1, &
126 integer(kind=INT32),intent(in) :: arg1 !< Inline doxygen description
127 integer(kind=INT32),intent(in) :: arg2 !< Inline doxygen description
128 integer(kind=INT32) :: res
131 end module example_mod
137 * C code is written in GNU style. Each new level in a program block is indented
138 by 2 spaces. Braces start on a new line, and are also indented by 2 spaces.
139 * See the [Gnome C coding style guide](https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en)