Changes between Version 14 and Version 15 of HowTo/FortranStandards


Ignore:
Timestamp:
2013-04-26T18:12:22+02:00 (11 years ago)
Author:
jryder
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowTo/FortranStandards

    v14 v15  
    11= Fortran style guide = 
     2 
     3[[BR]]  
     4 
    25 
    36= Introduction = 
     
    2528= Interfaces = 
    2629 
    27 Existing structure and interactions between module and subroutines and how to improve it 
     30''Existing structure and interactions between module and subroutines and how to improve it'' 
     31 
     32[[BR]]  
    2833 
    29341) For function/suroutine calls, there should only be five arguments per line. 
     
    4247= Clarity = 
    4348 
    44 Layout of code for clarity to the reader, reminder about the commenting style and ensuring interaction with the documentation compiler (dOxygen) 
     49''Layout of code for clarity to the reader, reminder about the commenting style and ensuring interaction with the documentation compiler (dOxygen)'' 
    4550 
    46 2) Related to point one, in the variable declaration of the subroutine, it's nice to have 
     51[[BR]]  
     52 
     53(1) Related to point one, in the variable declaration of the subroutine, it's nice to have 
    4754all the variables which are passed to/from to be in the same order as they are listed. 
    4855{{{ 
     
    7481}}} 
    7582 
    76 3) '''Comment at end of loop:''' If there is a loop within a loop (nested loop), or a lengthy single loop, it is helpful to repeat the loop instructions as a comment next to the END statement, as so: 
     83[[BR]]  
     84 
     85(2) '''Comment at end of loop:''' If there is a loop within a loop (nested loop), or a lengthy single loop, it is helpful to repeat the loop instructions as a comment next to the END statement, as so: 
    7786 
    7887{{{ 
     
    92101}}} 
    93102 
    94 3) '''Equations:''' Use brackets to improve readability (even though addition and subtraction are treated ahead of division and multiplication, it is easier for the reader to scan the equations if this is made explicit). Also, if the equation runs over several lines, try to break the expression at a close bracket or an addition/subtraction. 
     103[[BR]]  
     104 
     105(3) '''Equations:''' Use brackets to improve readability (even though addition and subtraction are treated ahead of division and multiplication, it is easier for the reader to scan the equations if this is made explicit). Also, if the equation runs over several lines, try to break the expression at a close bracket or an addition/subtraction. 
    95106 
    96107e.g. '''a = (b * i) + (c / n)''' is easier to read than '''a = b * i + c / n''' 
    97108 
    98 4) '''Line length:''' Although the maximum line length of Fortran90 is 132 characters, keep your code to less than 80 characters per line - this preserves the formatting for those who work with small terminal windows on their computer and when producing a printout. 
     109[[BR]]  
    99110 
    100 5) '''Use of space:''' Always indent the code within conditional statements or loops, but don't use tabs, as the formatting will not be preserved across platforms. 
     111 
     112(4) '''Line length:''' Although the maximum line length of Fortran90 is 132 characters, keep your code to less than 80 characters per line - this preserves the formatting for those who work with small terminal windows on their computer and when producing a printout. 
     113 
     114[[BR]]  
     115 
     116(5) '''Use of space:''' Always indent the code within conditional statements or loops, but don't use tabs, as the formatting will not be preserved across platforms. 
     117 
     118[[BR]]  
    101119 
    102120---- 
     
    107125Choosing where and when to define particular variables; portability between compilers; allocation/de-allocation of arrays etc. 
    108126 
    109  
     127[[BR]]  
    110128 
    111129---- 
    112130 
    113131[[BR]]  
    114 = Speed optimisation = 
     132= Debugging and speed optimisation = 
    115133 
    116 guidelines for making loops more efficient, eliminating dead code 
     134''guidelines for making loops more efficient, eliminating dead code'' 
    117135 
     136[[BR]]  
     137 
     138(1) ''''bavard' (chatterbox!):''' is an externalised parameter that can be used to determine the nature of WRITE statements in the code for monitoring and debugging. It is proposed that for the trunk code a uniform set of parameters is used to control the size of the output text files as appropriate to the task in hand. 
     139 
     140For example: 
     141 
     142'''IF''' bavard '''EQUALS''' 0 then no output 
     143 
     144'''IF''' bavard '''=>''' 1 then parameters used are reported 
     145 
     146'''IF''' bavard '''=>''' 2 then entering and leaving subroutines are reported  
     147