[CSC 435] Re: SPEED -- and Questions!

Andrew J. Pounds pounds_aj at mercer.edu
Tue Jan 19 14:29:27 EST 2010


Ahh -- the fun of old fortran codes....

The ortho routines have TWO common blocks -- one is named, one is not.  
The named common block is called "intdat" and holds all the zeros and 
weights for the gaussian quadrature.   Any function or subroutine that 
wants to use this common block has to include it with its name.  Look, 
for example, at the function called integ and you will see how this is 
done.  I have seen programs with literally ten to twenty different named 
common blocks -- this has been to a large degree replaced with modules 
in newer versions of fortran.

The other common block does not have  a name.  The compiler sets apart a 
section of memory for these variables and stores them there.   Any  
function or subroutine that wants to use these has to keep up with the 
ORDER in the common statement.  For example, if in the main program I 
defined

common x

I could in another function do a

common y

and y points to the same memory space as x -- so in the subroutine I may 
be using the "name" y, but I am actually using and/or modifying the 
variable named x in another part of the program.    You see this A LOT 
in older scientific libraries where people were trying to develop 
modular, generic code without objects or -- more importantly -- 
pointers.   In your ortho codes you will find this variable referred to 
as both "i" in the main program and "n" in TofX -- it is a nasty example 
of a hidden data dependence between the main program and a subroutine.



Timothy Herold wrote:
> So, we get rid of the factorial subroutine, I got that far, which 
> leaves TofX as a simple definition. My question is, you declare n as 
> common, but it is never associated to a value (that I can find), and, 
> if I knew what to do with n, then I could get rid of the TofX 
> subroutine and put the trig definition right into the main program. I 
> suppose my question is, how does TofX know what n is, and where is it 
> formally defined?
>
> Tim


-- 
Andrew J. Pounds, Ph.D.  (pounds at theochem.mercer.edu)
Associate Professor of Chemistry and Computer Science
Mercer University,  Macon, GA 31207   (478) 301-5627



More information about the csc435 mailing list