...
- Indent consistently and make sure your auto-tab function in your editor converts tabs to spaces.
- Indent of most blocks (do, if, while, etc.): 3 spaces
- Indent of "program" blocks (program, module, subroutine, function): 2 spaces
- Indent of "associate" blocks: 0 spaces
Indent of continuation lines: 5 (this can vary based on look and feel)
Code Block borderStyle solid title Indentation ! 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
- Do not leave hanging white space at the end of any line of code; git diff shows this in red spaces.
- 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 | ||||
---|---|---|---|---|
|
...