- Fortran Tutorial
- Fortran - Home
- Fortran - Overview
- Fortran - Environment Setup
- Fortran - Basic Syntax
- Fortran - Data Types
- Fortran - Variables
- Fortran - Constants
- Fortran - Operators
- Fortran - Decisions
- Fortran - Loops
- Fortran - Numbers
- Fortran - Characters
- Fortran - Strings
- Fortran - Arrays
- Fortran - Dynamic Arrays
- Fortran - Derived Data Types
- Fortran - Pointers
- Fortran - Basic Input Output
- Fortran - File Input Output
- Fortran - Procedures
- Fortran - Modules
- Fortran - Intrinsic Functions
- Fortran - Numeric Precision
- Fortran - Program Libraries
- Fortran - Programming Style
- Fortran - Debugging Program

- Fortran Resources
- Fortran - Quick Guide
- Fortran - Useful Resources
- Fortran - Discussion

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Programming style is all about following some rules while developing programs. These good practices impart values like readability, and unambiguity into your program.

A good program should have the following characteristics −

- Readability
- Proper logical structure
- Self-explanatory notes and comments

For example, if you make a comment like the following, it will not be of much help −

! loop from 1 to 10 do i = 1,10

However, if you are calculating binomial coefficient, and need this loop for nCr then a comment like this will be helpful −

! loop to calculate nCr do i = 1,10

Indented code blocks to make various levels of code clear.

Self-checking codes to ensure there will be no numerical errors like division by zero, square root of a negative real number or logarithm of a negative real number.

Including codes that ensure variables do not take illegal or out of range values, i.e., input validation.

Not putting checks where it would be unnecessary and slows down the execution. For example −

real :: x x = sin(y) + 1.0 if (x >= 0.0) then z = sqrt(x) end if

- Clearly written code using appropriate algorithms.
- Splitting the long expressions using the continuation marker ‘&’.
- Making meaningful variable names.

Advertisements