Skip to content

Memory management

Alexandros Avdis edited this page Jun 11, 2014 · 4 revisions

Coding rules

Where a procedure requires local variables whose size is known only at runtime, those variables should utilise dynamic memory allocation locally. Work space should not be passed down from higher level routines.

Automatic arrays, which many Fortran compilers place on the stack, are suitable for smaller variables. Variables whose size is that of a single element or another small part of a problem space should generally be automatic variables. For example arrays whose dimensions are ngi or nloc are good candidates.

Automatic arrays are not suitable for arrays which could become very large, for example arrays whose dimensions are nonods or totele are too big to be automatic arrays. These large arrays should be declared as allocatable and expicitly allocated and deallocated.

Clone this wiki locally