User Tools

Site Tools


sudoc:su_prog_rules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sudoc:su_prog_rules [2019/07/30 21:40] seisunixsudoc:su_prog_rules [2019/07/30 21:55] (current) seisunix
Line 20: Line 20:
  
 The reality is that the more items that a user must fetch to install your code, the less likely that they will want to use it. You will also be at the mercy of whims of third party developers who may decide arbitrarily to change their code. The reality is that the more items that a user must fetch to install your code, the less likely that they will want to use it. You will also be at the mercy of whims of third party developers who may decide arbitrarily to change their code.
 +
 ===== Do not include commercial software ===== ===== Do not include commercial software =====
  
Line 29: Line 30:
  
 The limitation is that while code released under a Berkeley License may be absorbed into a GPL software collection, the reverse is not true. You may not include GPL licensed code in the SU distribution. The limitation is that while code released under a Berkeley License may be absorbed into a GPL software collection, the reverse is not true. You may not include GPL licensed code in the SU distribution.
 +
 +===== Avoid using global variables =====
 +If you need to pass a variable to a subroutine then pass it as an argument to the subroutine, do not define it as a global variable.
 +
 +===== Document your code thoroughly =====
 +Make sure there are Notes: in the Self Documentation.
 +Document each declared variable. Put technical information describing the algorithm being used. Remember that "future you" will not remember the things that "present you" knows.
 +
 +Document subroutines as though they will be clipped out and put in a library---because if a subroutine is useful, it will be separated from its parent program.
 +
 +Pretend that the code will not run without the documentation.
  
 ===== Develop from existing code ==== ===== Develop from existing code ====
Line 102: Line 114:
 </code> </code>
  
-** The end self documentation flag **+** The end self documentation flag, this tells updatedoc that this is the end of the documentation**
 <code> <code>
 /**************** end self doc ***********************************/ /**************** end self doc ***********************************/
Line 250: Line 262:
         }         }
         if (icount==0) warn("All amps values are the same");         if (icount==0) warn("All amps values are the same");
 +</code>
  
 +** Dynamic allocation which hides "malloc" from the user **
 +<code>
  
         /* Allocate fft arrays */         /* Allocate fft arrays */
Line 260: Line 275:
         polygonalFilter(f,amps,npoly,nfft,dt,filter);         polygonalFilter(f,amps,npoly,nfft,dt,filter);
  
 +</code>
 +
 +** note that most of the time we loop over input traces, these are in  "do -- while" loops **
 +<code>
         /* Main loop over traces */         /* Main loop over traces */
         do {         do {
Line 371: Line 390:
  
 </code>  </code> 
- 
- 
sudoc/su_prog_rules.1564522811.txt.gz · Last modified: 2019/07/30 21:40 by seisunix