- #36
jedishrfu
Mentor
- 15,094
- 9,624
Another note on the common block, it was used in cases where there were large numbers of variables where it became painful to pass them all in a subroutine call. Doing it the functional way i.e. Not the common block way would often take a lot more time to run the program. In other words common blocks could speed up computationally intense programs due to the register indirection used in subroutine calls.
When common block became hell was when you had the same common block referenced in two or more subroutines use different names for the same variables. Invariably someone would add a new variable in the middle of the block and forget to add it to all the other same named blocks they would use fortrans implicit datatyping convention meaning one block thought it was an integer and another thought it was a float.
Common blocks are a primitive version of the union+structs used in C code for low level data manipulation.
When common block became hell was when you had the same common block referenced in two or more subroutines use different names for the same variables. Invariably someone would add a new variable in the middle of the block and forget to add it to all the other same named blocks they would use fortrans implicit datatyping convention meaning one block thought it was an integer and another thought it was a float.
Common blocks are a primitive version of the union+structs used in C code for low level data manipulation.