Search code examples
fortrandynamic-memory-allocationfortran77

How do fortran 77 programmers manage without dynamic memory allocation?


I'm starting to learn Fortran, coming from a C++/Matlab/Java background. I realize that some Fortran programmers are still clinging to F77, maybe because they don't like object orientation, namespaces and stuff, and are used to the old syntax.

I understand that you can write a program without OOP. What I don't understand is how you can do without dynamic memory management. There are a thousand examples of cases where you don't know the array sizes in advance - for instance when converting a full matrix to a sparse one.

Of course, modern Fortran offers both "automatic arrays" and "allocatable arrays". But these were not present in 1977. How do the F77 guys manage without these constructs?


Solution

  • Within the standard language, the approach was typically to set aside storage in an array that was larger than likely needed, but still within the constraints of the platform running the program, then manually parcel that storage out as required. The language had features, such as sequence association, storage association, and adjustable arrays, that helped with this parcelling.

    Use of language extensions for dynamic memory management was also common.

    The capabilities of Fortran 77 and earlier need to be considered in the context of the capabilities of the platforms of the time.