Below we shall give some advices of how to improve the performance of a code.
Use only clean loops without IF, GOTO or CALL statements. For example:
DO i = 1, n
IF ( var > 0 ) THEN
a(i) = 0.
ELSE
a(i) = b(i)
ENDIF
ENDDO
should be replaced by
IF ( var > 0 ) THEN
a(:) = 0.
ELSE
a(:) = b(:)
ENDIF
Make sure that the inner loop is the longest one of a series of nested do loops.
Use the inner loop for the first index of multi-dimensional arrays in case of nested
loops. This may increase the efficiency, provided the inner loop is long enough.