Now the integration is performed in the following order. At this time, results from the fine grids are transfered back to the coarse grid, and the cycle is repeated till next regridding time, when the fine grids are destroyed, and new ones are created, as indicated by the truncation errors. In this computational scheme the number, sizes and locations of the fine grids are unknown until runtime. Therefore, dynamic memory management is crucial here. It is difficult to implement it in Fortran 77.
Known implementations take advantage of the linear memory mapping associated with common blocks.
In essence, a single, huge array is declared in a common block, and then it is dynamically partitoned behind the compiler's back . It is natural to organize the grids into a tree with the coarse grid serving as the root. In addition, it is convenient to declare an array of pointers to the first grid on each level. Creating new nodes in the structure of grids is not difficult, either. Of course, it requires much more effort to fully implement AMR, and the description of it goes beyond scope of this tutorial.