What are program segments, and which segments are different types of variables stored in?
Memory within a computer is typically made of different portions of memory with specialized attributes called segments.
Note: Program segments are different from the notion of segmented memory.
If you have a Fortran or C program, depending on a number of factors, different segments are used to store your variables (data). Following is a list of common variable types and the segments in which they are stored:
Note: Some of the information below is compiler-specific.
- Fortran code:
- A regular Fortran 77 array is in the data region when compiling with xlf77 (and variants thereof, e.g., mpxlf77).
- A regular array is in the stack region when compiled with xlf90
(and variants thereof, e.g., mpxlf90), unless the array appears in a
SAVE statement or a COMMON block, or the
-qsaveoption is used. - A Fortran 90 allocatable array is in the data region.
- A Fortran 90 automatic array is in the stack region.
- C/C++ code:
- Static C data is in the data region.
- Automatic C data is in the stack region.
- C data allocated through
mallocis in the data region.
At Indiana University, to learn more about program segments, email the High Performance Applications group, or see the High Performance Applications web page.
This document was developed with support from the National Science Foundation (NSF) under Grant No. 0503697 to the University of Chicago and subcontracted to Indiana University. Additional support was provided by IU through its participation in the TeraGrid, which is supported by the NSF under Grants No. 0833618, SCI451237, SCI535258, and SCI504075. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF.
This document was developed with support from National Science Foundation (NSF) grant OCI-1053575. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF.
Last modified on September 07, 2011.







