Common Mistakes

MATH7601: Common Programming Errors (and how to avoid them....to an extent!!) 1. Misspelling variable names / not declaring variables: The error message should say something about IMPLICIT NONE. 2. Not setting the value of a variable before using it: Do not depend on the computer to assign a value to your variables. 3. Confusing single line IF statements with IF ( ) THEN...END IF blocks: A single line IF statement does not require ‘THEN’. For IF ( ) THEN...END IF blocks nothing follows THEN on the first line. Do not put anything after ELSE either, unless you use ELSE IF ( ) THEN. 4. Mis-aligning IF blocks and/or DO loops: Use indentation to make the structure clear. 5. Infinite Loops: Check that the condition in your IF ( ) EXIT line will eventually come true! Use Ctrl-C to exit an infinite loop. 6. Going beyond the bounds of an array: For example, if a variable is declared INTEGER:: monthsize(12) then referring to monthsize(0) or monthsize(21) will exceed the bounds of the array. The resulting error message will be something like ‘segmentation fault’. Program Organisation 1. ALWAYS write small segments of code (e.g. a subroutine or function) and then test thoroughly to see if (A) it compiles, and (B) it does what you think it should, before proceeding. Nothing is more depressing than many pages of code that simply don’t work. 2. If a calculation is repeated, place it in a subroutine or function, which can be called each time it is needed. This leads to shorter programs that are much easier to follow. 3. A single subroutine or function usually performs a single task. 4. Usually, it is better to avoid READ and WRITE statements in subroutines and functions, unless their sole purpose is to read in some complex input, or format some output. 5. Complex calculations should not usually take place in the main program, its main purpose is usually to organise input and output, and call subroutines and functions to do the hard work!

Related docs
Common-Selling Mistakes
Views: 1  |  Downloads: 0
Common credit mistakes
Views: 0  |  Downloads: 0
Common Webmaster Mistakes
Views: 29  |  Downloads: 0
common optimization Mistakes
Views: 24  |  Downloads: 2
Common Mistakes In Letter Writing
Views: 8  |  Downloads: 1
Common Mistakes When It Comes To Refinancing
Views: 0  |  Downloads: 0
Common Business Plan Mistakes
Views: 21  |  Downloads: 4
What are the common credit mistakes
Views: 0  |  Downloads: 0
COMMON TRAFFIC TICKET MISTAKES AND SOLUTIONS
Views: 4  |  Downloads: 0
Common_Resume_Mistakes
Views: 0  |  Downloads: 0
Common mistakes and how to avoid them
Views: 112  |  Downloads: 9
7 Common Refinancing Mistakes to Avoid
Views: 2  |  Downloads: 0
premium docs
Other docs by JoeSouthwick
Time sheets
Views: 612  |  Downloads: 28
Non Disclosure Agreement - Boilerplate
Views: 4727  |  Downloads: 689
Special Power of Attorney
Views: 796  |  Downloads: 31
Permission Request to Use Copyrighted Material
Views: 334  |  Downloads: 16
Board Makes a Resolution Without Holding Meeting
Views: 185  |  Downloads: 2
Company Memorandum Template
Views: 530  |  Downloads: 4
AES China Generating Co Ammendments and By laws
Views: 342  |  Downloads: 1
Cyberian Outpost Inc Ammendments and By laws
Views: 188  |  Downloads: 0