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>
3.2. Copyright notice¶
Two different copyright notices are provided, one of which should be included at the top of each source file that you write. Met Office contributors should use the Crown Copyright notice, while other developers should use the Consortium Member Copyright notice.
3.2.1. Crown Copyright Notice¶
!******************************COPYRIGHT********************************************
! (c) Crown copyright, Met Office < Year produced, e.g. 2008 >. All rights reserved.
!
! This routine has been licensed to the other JULES partners for use and
! distribution under the JULES collaboration agreement, subject to the terms and
! conditions set out therein.
!
! [Met Office Ref SC0237]
!******************************COPYRIGHT********************************************
3.2.2. Consortium Member Copyright Notice¶
!******************************COPYRIGHT********************************************
! (c) < name of rights owner, e.g. University of xxx > < Year produced, e.g. 2008 >.
! All rights reserved.
!
! This routine has been licensed to the other JULES partners for use and
! distribution under the JULES collaboration agreement, subject to the terms and
! conditions set out therein.
!
! [Met Office Ref SC0237]
!******************************COPYRIGHT********************************************