Skip to content

Commit 369d295

Browse files
docs: style guide update (NOAA-GFDL#1642)
1 parent 44f182d commit 369d295

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

CODE_STYLE.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
* A copy of the [Gnu Lesser General Public License](https://www.gnu.org/licenses/lgpl-3.0.en.html)
1111
must be included at the top of each file.
1212
* Documentation should be written so that it can be parsed by [Doxygen](http://www.doxygen.nl/).
13+
* Files, modules, and public routines should be prefixed with `fms_subfolder_` where `subfolder` is
14+
the name of the subfolder that the file is in. Shorten subfolder names (ie diag) are acceptable
15+
as long as they are consistent within the subfolder.
1316
* All variables should be defined, and include units. Unit-less variables should be marked `unitless`
1417
* Provide detailed descriptions of modules, interfaces, functions, and subroutines
1518
* Define all function/subroutine arguments, and function results (see below)
1619
* Follow coding style of the current file, as much as possible.
20+
* Add public routines to be used ouside of FMS to the libFMS.F90 file so they can be accessed
21+
through `use FMS`.
1722

1823
## Fortran
1924

@@ -89,7 +94,7 @@
8994
same include subdirectory as the .fh files. See below for details.
9095
## Fortran Example
9196

92-
```Fortran ./example.F90 file
97+
```Fortran ./fms_subfolder_example.F90 file
9398
9499
!***********************************************************************
95100
!* GNU Lesser General Public License
@@ -115,55 +120,55 @@
115120
!! @author <developer>
116121
!! @email gfdl.climate.model.info@noaa.gov
117122
118-
module example_mod
123+
module fms_subfolder_example_mod
119124
use platform_mod, only r4_kind, r8_kind, i4_kind, i8_kind
120125
use util_mod, only: util_func1
121126
implicit none
122127
private
123128
124-
public :: sub1
125-
public :: func1
126-
public :: ex_subroutine
129+
public :: fms_subfolder_example_sub1
130+
public :: fms_subfolder_example_func1
131+
public :: fms_subfolder_example_ex_subroutine
127132
128-
interface ex_subroutine !< generic interface block. When the user
129-
module procedure ex_subroutine_r4 !! calls ex_subroutine, the compiler checks
130-
module procedure ex_subroutine_r8 !! the input arguments and invokes either
131-
end interface ex_subroutine !! ex_subroutine_r4 or ex_subroutine_r8
132-
!! ex_subroutine_r4/8 are generated by the preprocessor
133-
!! which requires example_r4.fh, example_r8.fh, and
134-
!! example.inc files
133+
interface fms_subfolder_example_ex_subroutine !< generic interface block. When the user
134+
module procedure ex_subroutine_r4 !! calls ex_subroutine, the compiler checks
135+
module procedure ex_subroutine_r8 !! the input arguments and invokes either
136+
end interface ex_subroutine !! ex_subroutine_r4 or ex_subroutine_r8
137+
!! ex_subroutine_r4/8 are generated by the preprocessor
138+
!! which requires example_r4.fh, example_r8.fh, and
139+
!! example.inc files
135140
136141
!> @brief Doxygen description of type.
137-
type,public :: CustomType
142+
type,public :: fms_subfolder_example_CustomType
138143
private
139144
integer(kind=i4_kind) :: a_var !< Inline doxygen description.
140145
real(kind=r8_kind),dimension(:),allocatable :: b_arr !< long description
141146
!! continued on
142147
!! multiple lines.
143-
endtype CustomType
148+
endtype fms_subfolder_example_CustomType
144149
145150
contains
146151
147152
!> @brief Doxygen description.
148-
subroutine sub1(arg1, arg2, &
153+
subroutine fms_subfolder_example_sub1(arg1, arg2, &
149154
& arg3)
150155
real(kind=r4_kind),intent(in) :: arg1 !< Inline doxygen description.
151156
integer(kind=i8_kind),intent(inout) :: arg2 !< Inline doxygen description.
152157
character(len=*),intent(inout) :: arg3 !< Long inline doxygen
153158
!! description.
154159
155160
arg1=2.456_r4_kind
156-
end subroutine sub1
161+
end subroutine fms_subfolder_example_sub1
157162
158163
!> @brief Doxygen description
159164
!! @return Function return value.
160-
function func1(arg1, arg2) result(res)
165+
function fms_subfolder_example_ func1(arg1, arg2) result(res)
161166
integer(kind=i4_kind),intent(in) :: arg1 !< Inline doxygen description
162167
integer(kind=i4_kind),intent(in) :: arg2 !< Inline doxygen description
163168
integer(kind=r8_kind) :: res
164169
165170
res=real(arg1,r8_kind) * 3.14_r8_kind
166-
end function func1
171+
end function fms_subfolder_example_func1
167172
168173
#include "example_r4.fh" !< These two header file contains the macro definition
169174
#include "example_r8.fh" !! and an "#include example.inc" where the procedure

0 commit comments

Comments
 (0)