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.

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 (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 -qsave option 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 malloc is in the data region.

At Indiana University, if you have a question about program segments, email the UITS Scientific Applications and Performance Tuning team.

This is document areb in the Knowledge Base.
Last modified on 2018-06-22 11:16:22.

Contact us

For help or to comment, email the UITS Support Center.