I'm coming into FORTRAN with a heavy C background. It's all pretty straightforward, except the actual mechanisms of how COMMON blocks work baffles me, and I can't find anyplace that describes them in detail.
Let's say I have the following COMMON block in FORTRAN.
COMMON/MYBLOCK/ A,B,C
As I understand this, this will set aside a chunk of memory that contains three...things, that aren't really associated with the names in the block, and in fact if If have this next code later in my source:
SUBROUTINE MYSUB(...)
...
COMMON/MYBLOCK/ X,Y,Z
...
END
Then now X is associated with whatever used to be in A, and the same Y to B and Z to C.
So this means COMMON/MYBLOCK/ is...an array of void pointers when it's declared? There's no type associated with any of these pointrers, so...memory is allocated when a value is assigned? What happens if I say A='A' in my main thread, but then in MYSUB I say A=3.141592? If I have a subroutine that I want to return a value into A by reference (because it's part of an external library), can I just say CALL MYSUB2(A) and count on the compiler to sort it out? Or do I need to call MYSUB2 on a local variable first, then assign that to A?
It's weird, FORTRAN is such a strongly typed language everywhere else, but COMMON blocks are just like "do whatever you want, man, we don't do types here"...