Skip to content

Style update #1642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

## Fortran

Expand Down Expand Up @@ -89,7 +94,7 @@
same include subdirectory as the .fh files. See below for details.
## Fortran Example

```Fortran ./example.F90 file
```Fortran ./fms_subfolder_example.F90 file

!***********************************************************************
!* GNU Lesser General Public License
Expand All @@ -115,55 +120,55 @@
!! @author <developer>
!! @email gfdl.climate.model.info@noaa.gov

module example_mod
module fms_subfolder_example_mod
use platform_mod, only r4_kind, r8_kind, i4_kind, i8_kind
use util_mod, only: util_func1
implicit none
private

public :: sub1
public :: func1
public :: ex_subroutine
public :: fms_subfolder_example_sub1
public :: fms_subfolder_example_func1
public :: fms_subfolder_example_ex_subroutine

interface ex_subroutine !< generic interface block. When the user
module procedure ex_subroutine_r4 !! calls ex_subroutine, the compiler checks
module procedure ex_subroutine_r8 !! the input arguments and invokes either
end interface ex_subroutine !! ex_subroutine_r4 or ex_subroutine_r8
!! ex_subroutine_r4/8 are generated by the preprocessor
!! which requires example_r4.fh, example_r8.fh, and
!! example.inc files
interface fms_subfolder_example_ex_subroutine !< generic interface block. When the user
module procedure ex_subroutine_r4 !! calls ex_subroutine, the compiler checks
module procedure ex_subroutine_r8 !! the input arguments and invokes either
end interface ex_subroutine !! ex_subroutine_r4 or ex_subroutine_r8
!! ex_subroutine_r4/8 are generated by the preprocessor
!! which requires example_r4.fh, example_r8.fh, and
!! example.inc files

!> @brief Doxygen description of type.
type,public :: CustomType
type,public :: fms_subfolder_example_CustomType
private
integer(kind=i4_kind) :: a_var !< Inline doxygen description.
real(kind=r8_kind),dimension(:),allocatable :: b_arr !< long description
!! continued on
!! multiple lines.
endtype CustomType
endtype fms_subfolder_example_CustomType

contains

!> @brief Doxygen description.
subroutine sub1(arg1, arg2, &
subroutine fms_subfolder_example_sub1(arg1, arg2, &
& arg3)
real(kind=r4_kind),intent(in) :: arg1 !< Inline doxygen description.
integer(kind=i8_kind),intent(inout) :: arg2 !< Inline doxygen description.
character(len=*),intent(inout) :: arg3 !< Long inline doxygen
!! description.

arg1=2.456_r4_kind
end subroutine sub1
end subroutine fms_subfolder_example_sub1

!> @brief Doxygen description
!! @return Function return value.
function func1(arg1, arg2) result(res)
function fms_subfolder_example_ func1(arg1, arg2) result(res)
integer(kind=i4_kind),intent(in) :: arg1 !< Inline doxygen description
integer(kind=i4_kind),intent(in) :: arg2 !< Inline doxygen description
integer(kind=r8_kind) :: res

res=real(arg1,r8_kind) * 3.14_r8_kind
end function func1
end function fms_subfolder_example_func1

#include "example_r4.fh" !< These two header file contains the macro definition
#include "example_r8.fh" !! and an "#include example.inc" where the procedure
Expand Down
Loading