Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Indent consistently and make sure your auto-tab function in your editor converts tabs to spaces.
    1. Indent of most blocks (do, if, while, etc.): 3 spaces
    2. Indent of "program" blocks (program, module, subroutine, function): 2 spaces
    3. Indent of "associate" blocks: 0 spaces
    4. Indent of continuation lines: 5 (this can vary based on look and feel)

      Code Block
      borderStylesolid
      titleIndentation
      ! a dash, '-', represents a space
      --use thisModule , only : thisRoutine
      !
      --subroutine foo
      ----use thatModule , only : thatRoutine
      ----associate ( &
      -------ptr1 => someDerivedType%ptr1 , &
      -------ptr2 => someDerivedType%ptr2   &
      ----)
      ----if ( someLogical ) then
      -------x=x+1
      ! leave a line before and after statements that stand alone.
      -------if (x == 0) then endrun()
      ! leave a line before and after statements that stand alone.
      -------do while ( x <= 1000 )
      ----------! do some stuff
      ----------z = 1.0_r8 / radius
      -------end do ! end x<=1000
      ----endif ! someLogical
      !
      ----end associate
      --end subroutine
      


  2. Do not leave hanging white space at the end of any line of code; git diff shows this in red spaces.
  3. Do not tabularize code by adding extra spaces to any line of code. It may be tempting to do this for better readability, but it also takes time to manage code that needs realignment when new code comes in.

Statements and Subroutines
Anchor
statement
statement

...