Background
The high level overview of my situation is described here. I am breaking it apart into smaller, specific questions, such as this one, regarding extensive use of global variables in a procedural style.
Problem
In the large legacy Fortran codebase that me and some other new team members have inherited, the use of global variables by way of common blocks is extensive. There are thousands of arrays that are passed around between various modules (via include
syntax).
Is there a overall strategy of working with and managing Fortran global variables and common blocks in such a massive way (1000s of shared arrays)? Are there any alternatives to global variables (e.g., database) that don't take a huge performance hit?
It seems to me that since the common block feature is part of the Fortran language (in order to make it fast by basically doing in-memory compute?), then it was intended to be used this way. However, on the other end of the argument is the advice that use of global variables is bad practice, mainly because it is hard to debug because changes to state can happen from so many different places (modules, subroutines).
Also, by alternatives to the global variable approach, I am thinking about some data layer that is not so tightly coupled like a database, where the data storage is abstracted away from the main Fortran program. This way we could be more flexible with our choice for data storage and could also interface to this data storage from other places like Python programs.