This is the first basic poll for the style of the tutorial code listings. It only covers a few items: Variable and procedure naming style, indentation width, and whether to use a space in various end
statements. They’re quite fundamental and appear in almost any code. The last one I included because a few people expressed that it may be controversial, so it’s useful to get a community pulse on it.
Once we have the results we can write up a basic style guide. Other elements of style we can tackle if the need arises.
Please read the examples below and cast your vote in each of the 4 polls.
Variable naming
What style should we use for naming variables? Examples:
integer :: GRIDSIZE ! UPPERCASE
integer :: gridsize ! lowercase
integer :: grid_size ! snake_case
integer :: gridSize ! camelCase
integer :: GridSize ! PascalCase
Vote below (multiple choice answers):
- UPPERCASE
- lowercase
- snake_case
- camelCase
- PascalCase
0 voters
Procedure naming
How about for procedures? Examples:
function ROOTMEANSQUARE(x)
...
function rootmeansquare(x)
...
function root_mean_square(x)
...
function rootMeanSquare(x)
...
function RootMeanSquare(x)
...
Vote below (multiple choice answers):
- UPPERCASE
- lowercase
- snake_case
- camelCase
- PascalCase
0 voters
Indentation
How many spaces to use when indenting code? Examples:
do i = 1, 5
print *, i ! 1-space indent
end do
do i = 1, 5
print *, i ! 2-space indent
end do
do i = 1, 5
print *, i ! 3-space indent
end do
do i = 1, 5
print *, i ! 4-space indent
end do
Vote below (multiple choice answers):
- 1
- 2
- 3
- 4
0 voters
How to write various end statements?
Various Fortran constructs such as do
-loops and if
-blocks are closed with their corresponding end
statement. For example
do i = 1, 5
print *, i
end do
which can also be written as:
do i = 1, 5
print *, i
enddo
The question is should such end
statements be written together (enddo
, endif
, endwhere
, etc.) or separate (end do
, end if
, end where
, etc.).
Cast your vote below:
- Without space (
enddo
,endif
,endwhere
, etc.) - With space (
end do
,end if
,end where
, etc.)
0 voters