Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Does EQUIVALENCE to COMMON offer memory savings?

OptiAndrew1
Beginner
558 Views

I'm sprucing up some OLD code and came across something I suspect was an attempt to use less memory. In an attempt to make it more flexible, I would really like to understand it better before I do something ill-advised.

I have a separate COMMON file named "comm.f90" file that defines an array.

REAL*8 RGLOBL(1000)

 

There are several individual routines that INCLUDE this common and have an EQUIVALENCE to the global array like this...

INCLUDE 'comm.f90'

REAL*8 RLOC(1000)

EQUIVALENCE (RGLOBL(1),RLOC(1))

 

It's all working just fine, but all of the routines that use comm.f90 and EQUIVALENCE in this way initialize RLOC, and thus RGLOBL, before using it so RGLOBL seems to be nothing more than a chunk of memory set aside for.. whatever reason. Is there some sort of memory savings to be had from using a central scratch-pad array in this manner? It would seem that I am kind of painted into a corner if I ever need to increase the size of RLOC because I then need to increase the size of RGLOBL in the common, and also update the other routines that use RGLOBL to take advantage of its new larger size. I have had great success adding a PARAMETER type variable to commons and sizing everything with one centralized variable, but is there any downside to simply removing the EQUIVALENCE line in the individual routines and letting RLOC be its own thing?

 

Update: Ha! Just found a FORTRAN 77 book that says EQUIVALENCE is supposed to work EXACTLY as I just described. However, I thought that when a routine ended, any memory it used to do its stuff was "freed up" to be used for something else (as long as it wasn't typed with SAVE). So, what benefit is using EQUIVALENCE?

0 Kudos
1 Reply
OptiAndrew1
Beginner
542 Views

<removed because I accidentally hit REPLY instead of editing the above post>

0 Kudos
Reply