Fortran Coding Standards for JULES

3. Standard code templates

«  2.5. Further code guidance and best practices   ::   Contents

3. Standard code templates

Some standard templates for copyright notices and code files are provided as text files with this document. When writing new code, these templates should be used as a guide for the structure of the new files.

3.1. Code templates

Templates are provided for a SUBROUTINE, a FUNCTION and a simple MODULE. Text in angle brackets provides placeholders for Fortran statements.

3.1.1. SUBROUTINE template

< Appropriate copyright notice >

SUBROUTINE < name >(< argument list >)

  < Module imports >

  IMPLICIT NONE

!-----------------------------------------------------------------------------
! Description:
!   < Say what this routine does >
!
! Method:
!   < Say how it does it: include references to external documentation >
!   < If this routine is very complex, then include a "pseudo code"
!     description of it to make its structure and method clear >
!
! Current Code Owner: < Name of person responsible for this code >
!
! Code Description:
!   Language: Fortran 90.
!   This code is written to JULES coding standards v1.
!-----------------------------------------------------------------------------

! Subroutine arguments
  < Arguments with INTENT(IN   ) >
  < Arguments with INTENT(INOUT) >
  < Arguments with INTENT(  OUT) >


! Local constants
  < Local parameters >


! Local variables
  < Local variables >


!-----------------------------------------------------------------------------


  < Executable code >

END SUBROUTINE <name>

3.1.2. FUNCTION template

< Appropriate copyright notice >

FUNCTION < name >(< argument list>) RESULT(< return variable name >)

  < Module imports >

  IMPLICIT NONE

!-----------------------------------------------------------------------------
! Description:
!   < Say what this function does >
!
! Method:
!   < Say how it does it: include references to external documentation >
!   < If this function is very complex, then include a "pseudo code"
!     description of it to make its structure and method clear >
!
! Current Code Owner: < Name of person responsible for this code >
!
! Code Description:
!   Language: Fortran 90.
!   This code is written to JULES coding standards v1.
!-----------------------------------------------------------------------------

! Function arguments
  < Arguments with INTENT(IN) >

  
! Return type
  < Return variable type declaration >


! Local constants
  < Local parameters >


! Local variables
  < Local variables >


!-----------------------------------------------------------------------------


  < Executable code >

END FUNCTION <name>

3.1.3. MODULE template

< Appropriate copyright notice >

MODULE < name >

  < Module imports >

  IMPLICIT NONE

!-----------------------------------------------------------------------------
! Description:
!   < Say what this module contains >
!
! Current Code Owner: < Name of person responsible for this code >
!
! Code Description:
!   Language: Fortran 90.
!   This code is written to JULES coding standards v1.
!-----------------------------------------------------------------------------

  PRIVATE  ! Private scope by default


! Module constants
  < Parameter declarations >


! Module variables
  < Variable declarations >


! Public members
  PUBLIC :: < Public members >


CONTAINS
  
  
  < Any subroutines or functions, each following the appropriate
    template (minus copyright notice) >

END MODULE <name>

«  2.5. Further code guidance and best practices   ::   Contents