This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
dev:codingconventions [2018/12/19 12:19] tmueller [Use existing infrastructure] |
dev:codingconventions [2018/12/21 08:41] tmueller [Use existing infrastructure] |
||
---|---|---|---|
Line 40: | Line 40: | ||
===== Use existing infrastructure ===== | ===== Use existing infrastructure ===== | ||
- | Always prefer [[https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gfortran/Intrinsic-Procedures.html|built-in (intrinsic) functions]] instead of hand-coded routines since they usually include extra numerical checks to avoid intermediate under- or overflow while still performing optimally. Example: | + | Always prefer [[https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gfortran/Intrinsic-Procedures.html|built-in (intrinsic) functions]] instead of hand-coded routines since they usually include extra numerical checks to avoid intermediate under- or overflow while still performing optimally. Examples: |
- | + | ||
- | * ''NORM2'' instead of ''%%SQRT(x(1)**2 + x(2)**2 + x(3)**2)%%'' | + | |
+ | * ''NORM2(x)'' instead of ''%%SQRT(x(1)**2 + x(2)**2 + x(3)**2)%%'' | ||
+ | * ''DOT_PRODUCT(x, x)'' instead of ''%%x(1)**2 + x(2)**2 + x(3)**2%%'' | ||
+ | * ''DOT_PRODUCT(x, y)'' instead of ''%%x(1)*y(1) + x(2)*y(2) + x(3)*y(3)%%'' | ||